weapp-tailwindcss 4.8.10 → 4.8.11
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-MNZW5VG5.js → chunk-22ETJBBT.js} +7 -7
- package/dist/{chunk-YM3HBJ3Q.js → chunk-2SG4SGMQ.js} +7 -7
- package/dist/{chunk-OBOKBKZQ.mjs → chunk-3NLDVPXD.mjs} +2 -2
- package/dist/{chunk-W7H4R6CP.js → chunk-45BMEACS.js} +38 -16
- package/dist/{chunk-VMX23GDK.js → chunk-6LNKARWD.js} +17 -17
- package/dist/{chunk-JCG2LT63.mjs → chunk-BSGZZCLH.mjs} +2 -2
- package/dist/{chunk-OACITA4W.js → chunk-DLSEDDLQ.js} +13 -13
- package/dist/{chunk-INF2Q5LI.js → chunk-FAKEMDGU.js} +3 -3
- package/dist/{chunk-B7QESXH4.mjs → chunk-FGNKGESE.mjs} +3 -3
- package/dist/{chunk-XP5623NL.js → chunk-FM3FLOYY.js} +5 -5
- package/dist/{chunk-IXK4ZWFR.mjs → chunk-HHSKDU3Z.mjs} +28 -6
- package/dist/{chunk-BZXRUB2B.mjs → chunk-LAVN5SDT.mjs} +2 -2
- package/dist/{chunk-HFAC5AYM.mjs → chunk-TWF4BQKE.mjs} +2 -2
- package/dist/{chunk-XXO2FHP7.mjs → chunk-W6ASDRWZ.mjs} +1 -1
- package/dist/cli.js +139 -57
- package/dist/cli.mjs +96 -14
- package/dist/core.js +9 -9
- package/dist/core.mjs +3 -3
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +4 -4
- package/dist/index.js +8 -8
- package/dist/index.mjs +7 -7
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +1 -1
- package/dist/vite.js +5 -5
- package/dist/vite.mjs +4 -4
- package/dist/webpack.js +6 -6
- package/dist/webpack.mjs +5 -5
- package/dist/webpack4.js +18 -18
- package/dist/webpack4.mjs +4 -4
- package/package.json +1 -1
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-RRHPTTCP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
setupPatchRecorder
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3NLDVPXD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
collectRuntimeClassSet,
|
|
9
9
|
createDebug,
|
|
10
10
|
getCompilerContext,
|
|
11
11
|
refreshTailwindRuntimeState
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BSGZZCLH.mjs";
|
|
13
13
|
|
|
14
14
|
// src/bundlers/gulp/index.ts
|
|
15
15
|
import { Buffer } from "buffer";
|
package/dist/cli.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk22ETJBBTjs = require('./chunk-22ETJBBT.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk45BMEACSjs = require('./chunk-45BMEACS.js');
|
|
11
11
|
require('./chunk-3URI7W6X.js');
|
|
12
12
|
require('./chunk-UW3WHSZ5.js');
|
|
13
13
|
require('./chunk-CFFV3OIP.js');
|
|
@@ -36,6 +36,14 @@ function formatOutputPath(target, baseDir) {
|
|
|
36
36
|
var _promises = require('fs/promises');
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
// src/tailwindcss/index.ts
|
|
41
|
+
var _localpkg = require('local-pkg');
|
|
42
|
+
function getTailwindcssPackageInfo(options) {
|
|
43
|
+
return _localpkg.getPackageInfoSync.call(void 0, "tailwindcss", options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/cli/helpers.ts
|
|
39
47
|
function readStringOption(flag, value) {
|
|
40
48
|
if (value == null) {
|
|
41
49
|
return void 0;
|
|
@@ -93,17 +101,56 @@ function resolveCliCwd(value) {
|
|
|
93
101
|
}
|
|
94
102
|
return _path2.default.isAbsolute(raw) ? _path2.default.normalize(raw) : _path2.default.resolve(_process2.default.cwd(), raw);
|
|
95
103
|
}
|
|
104
|
+
function normalizeCandidatePath(baseDir, candidate) {
|
|
105
|
+
if (!candidate) {
|
|
106
|
+
return void 0;
|
|
107
|
+
}
|
|
108
|
+
return _path2.default.isAbsolute(candidate) ? _path2.default.normalize(candidate) : _path2.default.resolve(baseDir, candidate);
|
|
109
|
+
}
|
|
110
|
+
function detectTailwindWorkspace(paths) {
|
|
111
|
+
for (const candidate of paths) {
|
|
112
|
+
try {
|
|
113
|
+
const info = getTailwindcssPackageInfo({ paths: [candidate] });
|
|
114
|
+
if (_optionalChain([info, 'optionalAccess', _ => _.rootPath])) {
|
|
115
|
+
return candidate;
|
|
116
|
+
}
|
|
117
|
+
} catch (e) {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
function resolvePatchDefaultCwd(currentCwd = _process2.default.cwd()) {
|
|
123
|
+
const baseDir = _path2.default.normalize(currentCwd);
|
|
124
|
+
const explicitCwd = normalizeCandidatePath(baseDir, _process2.default.env.WEAPP_TW_PATCH_CWD);
|
|
125
|
+
if (explicitCwd) {
|
|
126
|
+
return explicitCwd;
|
|
127
|
+
}
|
|
128
|
+
const workspaceRoot = _chunk45BMEACSjs.findWorkspaceRoot.call(void 0, baseDir);
|
|
129
|
+
const initCwd = normalizeCandidatePath(baseDir, _process2.default.env.INIT_CWD);
|
|
130
|
+
const localPrefix = normalizeCandidatePath(baseDir, _process2.default.env.npm_config_local_prefix);
|
|
131
|
+
const candidates = [
|
|
132
|
+
baseDir,
|
|
133
|
+
workspaceRoot,
|
|
134
|
+
initCwd,
|
|
135
|
+
localPrefix
|
|
136
|
+
].filter(Boolean);
|
|
137
|
+
const detected = detectTailwindWorkspace([...new Set(candidates)]);
|
|
138
|
+
if (detected) {
|
|
139
|
+
return detected;
|
|
140
|
+
}
|
|
141
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(initCwd, () => ( localPrefix)), () => ( workspaceRoot)), () => ( baseDir));
|
|
142
|
+
}
|
|
96
143
|
async function ensureDir(dir) {
|
|
97
144
|
await _promises.mkdir.call(void 0, dir, { recursive: true });
|
|
98
145
|
}
|
|
99
146
|
function handleCliError(error) {
|
|
100
147
|
if (error instanceof Error) {
|
|
101
|
-
|
|
148
|
+
_chunk45BMEACSjs.logger.error(error.message);
|
|
102
149
|
if (error.stack && _process2.default.env.WEAPP_TW_DEBUG === "1") {
|
|
103
|
-
|
|
150
|
+
_chunk45BMEACSjs.logger.error(error.stack);
|
|
104
151
|
}
|
|
105
152
|
} else {
|
|
106
|
-
|
|
153
|
+
_chunk45BMEACSjs.logger.error(String(error));
|
|
107
154
|
}
|
|
108
155
|
}
|
|
109
156
|
function commandAction(handler) {
|
|
@@ -117,6 +164,39 @@ function commandAction(handler) {
|
|
|
117
164
|
};
|
|
118
165
|
}
|
|
119
166
|
|
|
167
|
+
// src/cli/patch-options.ts
|
|
168
|
+
var DEFAULT_EXTEND_LENGTH_UNITS_FEATURE = {
|
|
169
|
+
enabled: true,
|
|
170
|
+
units: ["rpx"],
|
|
171
|
+
overwrite: true
|
|
172
|
+
};
|
|
173
|
+
function withDefaultExtendLengthUnits(options) {
|
|
174
|
+
const normalized = _nullishCoalesce(options, () => ( {}));
|
|
175
|
+
const extendLengthUnits = _optionalChain([normalized, 'access', _2 => _2.features, 'optionalAccess', _3 => _3.extendLengthUnits]);
|
|
176
|
+
if (extendLengthUnits == null) {
|
|
177
|
+
return {
|
|
178
|
+
...normalized,
|
|
179
|
+
features: {
|
|
180
|
+
..._nullishCoalesce(normalized.features, () => ( {})),
|
|
181
|
+
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return normalized;
|
|
186
|
+
}
|
|
187
|
+
function buildExtendLengthUnitsOverride(options) {
|
|
188
|
+
const extendLengthUnits = _optionalChain([options, 'optionalAccess', _4 => _4.features, 'optionalAccess', _5 => _5.extendLengthUnits]);
|
|
189
|
+
if (extendLengthUnits == null) {
|
|
190
|
+
return {
|
|
191
|
+
features: {
|
|
192
|
+
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.features]), () => ( {})),
|
|
193
|
+
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
120
200
|
// src/cli/vscode-entry.ts
|
|
121
201
|
var _fs = require('fs');
|
|
122
202
|
|
|
@@ -139,7 +219,7 @@ async function assertFileExists(filepath) {
|
|
|
139
219
|
await _promises.access.call(void 0, filepath, _fs.constants.F_OK);
|
|
140
220
|
} catch (error) {
|
|
141
221
|
const err = error;
|
|
142
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
222
|
+
if (_optionalChain([err, 'optionalAccess', _7 => _7.code]) === "ENOENT") {
|
|
143
223
|
throw new Error(`CSS entry file not found: ${filepath}`);
|
|
144
224
|
}
|
|
145
225
|
throw err;
|
|
@@ -155,7 +235,7 @@ async function assertCanWrite(filepath, force) {
|
|
|
155
235
|
}
|
|
156
236
|
} catch (error) {
|
|
157
237
|
const err = error;
|
|
158
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
238
|
+
if (_optionalChain([err, 'optionalAccess', _8 => _8.code]) === "ENOENT") {
|
|
159
239
|
return;
|
|
160
240
|
}
|
|
161
241
|
throw err;
|
|
@@ -244,26 +324,18 @@ async function generateVscodeIntellisenseEntry(options) {
|
|
|
244
324
|
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
|
|
245
325
|
|
|
246
326
|
var _yaml = require('yaml');
|
|
247
|
-
|
|
248
|
-
// src/tailwindcss/index.ts
|
|
249
|
-
var _localpkg = require('local-pkg');
|
|
250
|
-
function getTailwindcssPackageInfo(options) {
|
|
251
|
-
return _localpkg.getPackageInfoSync.call(void 0, "tailwindcss", options);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// src/cli/workspace.ts
|
|
255
327
|
function tryReadJson(file) {
|
|
256
328
|
try {
|
|
257
329
|
const content = _fs.readFileSync.call(void 0, file, "utf8");
|
|
258
330
|
return JSON.parse(content);
|
|
259
|
-
} catch (
|
|
331
|
+
} catch (e2) {
|
|
260
332
|
return void 0;
|
|
261
333
|
}
|
|
262
334
|
}
|
|
263
335
|
function parseWorkspaceGlobsFromPackageJson(workspaceRoot) {
|
|
264
336
|
const pkgJsonPath = _path2.default.join(workspaceRoot, "package.json");
|
|
265
337
|
const pkg = tryReadJson(pkgJsonPath);
|
|
266
|
-
if (!_optionalChain([pkg, 'optionalAccess',
|
|
338
|
+
if (!_optionalChain([pkg, 'optionalAccess', _9 => _9.workspaces])) {
|
|
267
339
|
return [];
|
|
268
340
|
}
|
|
269
341
|
if (Array.isArray(pkg.workspaces)) {
|
|
@@ -281,8 +353,8 @@ function parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot) {
|
|
|
281
353
|
}
|
|
282
354
|
try {
|
|
283
355
|
const parsed = _yaml.parse.call(void 0, _fs.readFileSync.call(void 0, workspaceFile, "utf8"));
|
|
284
|
-
return Array.isArray(_optionalChain([parsed, 'optionalAccess',
|
|
285
|
-
} catch (
|
|
356
|
+
return Array.isArray(_optionalChain([parsed, 'optionalAccess', _10 => _10.packages])) ? parsed.packages.filter(Boolean) : [];
|
|
357
|
+
} catch (e3) {
|
|
286
358
|
return [];
|
|
287
359
|
}
|
|
288
360
|
}
|
|
@@ -293,7 +365,7 @@ function parseImportersFromLock(workspaceRoot) {
|
|
|
293
365
|
}
|
|
294
366
|
try {
|
|
295
367
|
const parsed = _yaml.parse.call(void 0, _fs.readFileSync.call(void 0, lockPath, "utf8"));
|
|
296
|
-
const importers = _optionalChain([parsed, 'optionalAccess',
|
|
368
|
+
const importers = _optionalChain([parsed, 'optionalAccess', _11 => _11.importers]);
|
|
297
369
|
if (!importers) {
|
|
298
370
|
return [];
|
|
299
371
|
}
|
|
@@ -303,7 +375,7 @@ function parseImportersFromLock(workspaceRoot) {
|
|
|
303
375
|
}
|
|
304
376
|
return _path2.default.join(workspaceRoot, key);
|
|
305
377
|
});
|
|
306
|
-
} catch (
|
|
378
|
+
} catch (e4) {
|
|
307
379
|
return [];
|
|
308
380
|
}
|
|
309
381
|
}
|
|
@@ -341,9 +413,11 @@ async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
|
341
413
|
return [...dirs];
|
|
342
414
|
}
|
|
343
415
|
function createWorkspacePatcher(cwd) {
|
|
344
|
-
const normalized = _tailwindcsspatch.normalizeOptions.call(void 0,
|
|
345
|
-
|
|
346
|
-
|
|
416
|
+
const normalized = _tailwindcsspatch.normalizeOptions.call(void 0,
|
|
417
|
+
withDefaultExtendLengthUnits({
|
|
418
|
+
cwd
|
|
419
|
+
})
|
|
420
|
+
);
|
|
347
421
|
return new (0, _tailwindcsspatch.TailwindcssPatcher)(normalized);
|
|
348
422
|
}
|
|
349
423
|
function formatDisplayName(workspaceRoot, dir, name) {
|
|
@@ -352,82 +426,82 @@ function formatDisplayName(workspaceRoot, dir, name) {
|
|
|
352
426
|
}
|
|
353
427
|
async function patchWorkspace(options) {
|
|
354
428
|
const cwd = _nullishCoalesce(options.cwd, () => ( _process2.default.cwd()));
|
|
355
|
-
const workspaceRoot = _nullishCoalesce(
|
|
429
|
+
const workspaceRoot = _nullishCoalesce(_chunk45BMEACSjs.findWorkspaceRoot.call(void 0, cwd), () => ( cwd));
|
|
356
430
|
const packageDirs = await resolveWorkspacePackageDirs(workspaceRoot);
|
|
357
431
|
if (packageDirs.length === 0) {
|
|
358
|
-
|
|
432
|
+
_chunk45BMEACSjs.logger.warn("\u672A\u5728 %s \u68C0\u6D4B\u5230 workspace \u5305\uFF0C\u5DF2\u8DF3\u8FC7\u6279\u91CF patch\u3002", workspaceRoot);
|
|
359
433
|
return;
|
|
360
434
|
}
|
|
361
435
|
const results = [];
|
|
362
436
|
for (const dir of packageDirs) {
|
|
363
437
|
const pkgJsonPath = _path2.default.join(dir, "package.json");
|
|
364
438
|
const pkgJson = tryReadJson(pkgJsonPath);
|
|
365
|
-
const displayName = formatDisplayName(workspaceRoot, dir, _optionalChain([pkgJson, 'optionalAccess',
|
|
439
|
+
const displayName = formatDisplayName(workspaceRoot, dir, _optionalChain([pkgJson, 'optionalAccess', _12 => _12.name]));
|
|
366
440
|
const tailwindInfo = getTailwindcssPackageInfo({ paths: [dir] });
|
|
367
|
-
if (!_optionalChain([tailwindInfo, 'optionalAccess',
|
|
441
|
+
if (!_optionalChain([tailwindInfo, 'optionalAccess', _13 => _13.rootPath])) {
|
|
368
442
|
results.push({
|
|
369
443
|
dir,
|
|
370
|
-
name: _optionalChain([pkgJson, 'optionalAccess',
|
|
444
|
+
name: _optionalChain([pkgJson, 'optionalAccess', _14 => _14.name]),
|
|
371
445
|
status: "skipped",
|
|
372
446
|
message: "tailwindcss \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
373
447
|
});
|
|
374
|
-
|
|
448
|
+
_chunk45BMEACSjs.logger.info("[workspace] \u8DF3\u8FC7 %s\uFF08tailwindcss \u672A\u5B89\u88C5\uFF09\u3002", displayName);
|
|
375
449
|
continue;
|
|
376
450
|
}
|
|
377
451
|
try {
|
|
378
452
|
const patcher = createWorkspacePatcher(dir);
|
|
379
453
|
if (options.clearCache) {
|
|
380
|
-
await
|
|
454
|
+
await _chunk22ETJBBTjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
|
|
381
455
|
}
|
|
382
|
-
const recorder =
|
|
456
|
+
const recorder = _chunk22ETJBBTjs.createPatchTargetRecorder.call(void 0, dir, patcher, {
|
|
383
457
|
source: "cli",
|
|
384
458
|
cwd: dir,
|
|
385
459
|
recordTarget: options.recordTarget !== false,
|
|
386
460
|
alwaysRecord: true
|
|
387
461
|
});
|
|
388
|
-
if (_optionalChain([recorder, 'optionalAccess',
|
|
389
|
-
|
|
462
|
+
if (_optionalChain([recorder, 'optionalAccess', _15 => _15.message])) {
|
|
463
|
+
_chunk45BMEACSjs.logger.info("[workspace] %s %s", displayName, recorder.message);
|
|
390
464
|
}
|
|
391
|
-
|
|
465
|
+
_chunk22ETJBBTjs.logTailwindcssTarget.call(void 0, "cli", patcher, dir);
|
|
392
466
|
await patcher.patch();
|
|
393
|
-
if (_optionalChain([recorder, 'optionalAccess',
|
|
467
|
+
if (_optionalChain([recorder, 'optionalAccess', _16 => _16.onPatched])) {
|
|
394
468
|
await recorder.onPatched();
|
|
395
469
|
}
|
|
396
470
|
results.push({
|
|
397
471
|
dir,
|
|
398
|
-
name: _optionalChain([pkgJson, 'optionalAccess',
|
|
472
|
+
name: _optionalChain([pkgJson, 'optionalAccess', _17 => _17.name]),
|
|
399
473
|
status: "patched",
|
|
400
474
|
message: "\u5DF2\u5B8C\u6210 patch\u3002"
|
|
401
475
|
});
|
|
402
|
-
|
|
476
|
+
_chunk45BMEACSjs.logger.success("[workspace] \u5DF2\u8865\u4E01 %s", displayName);
|
|
403
477
|
} catch (error) {
|
|
404
478
|
const reason = error instanceof Error ? error.message : String(error);
|
|
405
479
|
const suggestion = `\u8BF7\u5728 ${dir} \u8FD0\u884C "weapp-tw patch --cwd ${dir}".`;
|
|
406
480
|
const message = `${reason}\uFF0C${suggestion}`;
|
|
407
481
|
results.push({
|
|
408
482
|
dir,
|
|
409
|
-
name: _optionalChain([pkgJson, 'optionalAccess',
|
|
483
|
+
name: _optionalChain([pkgJson, 'optionalAccess', _18 => _18.name]),
|
|
410
484
|
status: "failed",
|
|
411
485
|
message
|
|
412
486
|
});
|
|
413
|
-
|
|
487
|
+
_chunk45BMEACSjs.logger.error("[workspace] \u8865\u4E01\u5931\u8D25 %s\uFF1A%s", displayName, message);
|
|
414
488
|
}
|
|
415
489
|
}
|
|
416
490
|
const patched = results.filter((result) => result.status === "patched").length;
|
|
417
491
|
const skipped = results.filter((result) => result.status === "skipped").length;
|
|
418
492
|
const failed = results.filter((result) => result.status === "failed").length;
|
|
419
|
-
|
|
493
|
+
_chunk45BMEACSjs.logger.info("[workspace] \u6C47\u603B\uFF1A\u5DF2\u8865\u4E01 %d\uFF0C\u8DF3\u8FC7 %d\uFF0C\u5931\u8D25 %d", patched, skipped, failed);
|
|
420
494
|
}
|
|
421
495
|
|
|
422
496
|
// src/cli.ts
|
|
423
497
|
function handleCliError2(error) {
|
|
424
498
|
if (error instanceof Error) {
|
|
425
|
-
|
|
499
|
+
_chunk45BMEACSjs.logger.error(error.message);
|
|
426
500
|
if (error.stack && _process2.default.env.WEAPP_TW_DEBUG === "1") {
|
|
427
|
-
|
|
501
|
+
_chunk45BMEACSjs.logger.error(error.stack);
|
|
428
502
|
}
|
|
429
503
|
} else {
|
|
430
|
-
|
|
504
|
+
_chunk45BMEACSjs.logger.error(String(error));
|
|
431
505
|
}
|
|
432
506
|
}
|
|
433
507
|
function withCommandErrorHandling(handler) {
|
|
@@ -446,7 +520,13 @@ var mountOptions = {
|
|
|
446
520
|
install: {
|
|
447
521
|
name: "patch",
|
|
448
522
|
aliases: ["install"],
|
|
523
|
+
appendDefaultOptions: false,
|
|
449
524
|
optionDefs: [
|
|
525
|
+
{
|
|
526
|
+
flags: "--cwd <dir>",
|
|
527
|
+
description: "Working directory",
|
|
528
|
+
config: { default: resolvePatchDefaultCwd() }
|
|
529
|
+
},
|
|
450
530
|
{
|
|
451
531
|
flags: "--record-target",
|
|
452
532
|
description: 'Write tailwindcss target metadata (node_modules/.cache/weapp-tailwindcss/tailwindcss-target.json). Pass "--record-target false" to skip.',
|
|
@@ -476,28 +556,30 @@ var mountOptions = {
|
|
|
476
556
|
});
|
|
477
557
|
return;
|
|
478
558
|
}
|
|
479
|
-
const
|
|
559
|
+
const patchOptions = await ctx.loadPatchOptions();
|
|
560
|
+
const extendLengthUnitsOverride = buildExtendLengthUnitsOverride(patchOptions);
|
|
561
|
+
const patcher = extendLengthUnitsOverride ? await ctx.createPatcher(extendLengthUnitsOverride) : await ctx.createPatcher();
|
|
480
562
|
if (shouldClearCache) {
|
|
481
|
-
await
|
|
563
|
+
await _chunk22ETJBBTjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
|
|
482
564
|
}
|
|
483
|
-
const recorder =
|
|
565
|
+
const recorder = _chunk22ETJBBTjs.createPatchTargetRecorder.call(void 0, ctx.cwd, patcher, {
|
|
484
566
|
source: "cli",
|
|
485
567
|
cwd: ctx.cwd,
|
|
486
568
|
recordTarget: shouldRecordTarget,
|
|
487
569
|
alwaysRecord: true
|
|
488
570
|
});
|
|
489
|
-
if (_optionalChain([recorder, 'optionalAccess',
|
|
490
|
-
|
|
571
|
+
if (_optionalChain([recorder, 'optionalAccess', _19 => _19.message])) {
|
|
572
|
+
_chunk45BMEACSjs.logger.info(recorder.message);
|
|
491
573
|
}
|
|
492
|
-
|
|
574
|
+
_chunk22ETJBBTjs.logTailwindcssTarget.call(void 0, "cli", patcher, ctx.cwd);
|
|
493
575
|
await patcher.patch();
|
|
494
|
-
if (_optionalChain([recorder, 'optionalAccess',
|
|
576
|
+
if (_optionalChain([recorder, 'optionalAccess', _20 => _20.onPatched])) {
|
|
495
577
|
const recordPath = await recorder.onPatched();
|
|
496
578
|
if (recordPath) {
|
|
497
|
-
|
|
579
|
+
_chunk45BMEACSjs.logger.info(`\u8BB0\u5F55 weapp-tw patch \u76EE\u6807 -> ${formatOutputPath(recordPath, ctx.cwd)}`);
|
|
498
580
|
}
|
|
499
581
|
}
|
|
500
|
-
|
|
582
|
+
_chunk45BMEACSjs.logger.success("Tailwind CSS \u8FD0\u884C\u65F6\u8865\u4E01\u5DF2\u5B8C\u6210\u3002");
|
|
501
583
|
}),
|
|
502
584
|
extract: withCommandErrorHandling(async (_ctx, next) => next()),
|
|
503
585
|
tokens: withCommandErrorHandling(async (_ctx, next) => next()),
|
|
@@ -505,9 +587,9 @@ var mountOptions = {
|
|
|
505
587
|
}
|
|
506
588
|
};
|
|
507
589
|
_process2.default.title = "node (weapp-tailwindcss)";
|
|
508
|
-
if (_semver2.default.lt(_process2.default.versions.node,
|
|
509
|
-
|
|
510
|
-
`You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${
|
|
590
|
+
if (_semver2.default.lt(_process2.default.versions.node, _chunk22ETJBBTjs.WEAPP_TW_REQUIRED_NODE_VERSION)) {
|
|
591
|
+
_chunk45BMEACSjs.logger.warn(
|
|
592
|
+
`You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunk22ETJBBTjs.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
|
|
511
593
|
);
|
|
512
594
|
}
|
|
513
595
|
var cli = _tailwindcsspatch.createTailwindcssPatchCli.call(void 0, {
|
|
@@ -532,7 +614,7 @@ cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliS
|
|
|
532
614
|
sources,
|
|
533
615
|
force
|
|
534
616
|
});
|
|
535
|
-
|
|
617
|
+
_chunk45BMEACSjs.logger.success(
|
|
536
618
|
`VS Code helper generated -> ${formatOutputPath(result.outputPath, resolvedCwd)}`
|
|
537
619
|
);
|
|
538
620
|
})
|
package/dist/cli.mjs
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
clearTailwindcssPatcherCache,
|
|
4
4
|
createPatchTargetRecorder,
|
|
5
5
|
logTailwindcssTarget
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BSGZZCLH.mjs";
|
|
7
7
|
import {
|
|
8
8
|
findWorkspaceRoot,
|
|
9
9
|
logger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HHSKDU3Z.mjs";
|
|
11
11
|
import "./chunk-QF65JGNW.mjs";
|
|
12
12
|
import "./chunk-ZNKIYZRQ.mjs";
|
|
13
13
|
import "./chunk-SXBK4NF4.mjs";
|
|
@@ -36,6 +36,14 @@ function formatOutputPath(target, baseDir) {
|
|
|
36
36
|
import { mkdir } from "fs/promises";
|
|
37
37
|
import path2 from "path";
|
|
38
38
|
import process2 from "process";
|
|
39
|
+
|
|
40
|
+
// src/tailwindcss/index.ts
|
|
41
|
+
import { getPackageInfoSync } from "local-pkg";
|
|
42
|
+
function getTailwindcssPackageInfo(options) {
|
|
43
|
+
return getPackageInfoSync("tailwindcss", options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/cli/helpers.ts
|
|
39
47
|
function readStringOption(flag, value) {
|
|
40
48
|
if (value == null) {
|
|
41
49
|
return void 0;
|
|
@@ -93,6 +101,45 @@ function resolveCliCwd(value) {
|
|
|
93
101
|
}
|
|
94
102
|
return path2.isAbsolute(raw) ? path2.normalize(raw) : path2.resolve(process2.cwd(), raw);
|
|
95
103
|
}
|
|
104
|
+
function normalizeCandidatePath(baseDir, candidate) {
|
|
105
|
+
if (!candidate) {
|
|
106
|
+
return void 0;
|
|
107
|
+
}
|
|
108
|
+
return path2.isAbsolute(candidate) ? path2.normalize(candidate) : path2.resolve(baseDir, candidate);
|
|
109
|
+
}
|
|
110
|
+
function detectTailwindWorkspace(paths) {
|
|
111
|
+
for (const candidate of paths) {
|
|
112
|
+
try {
|
|
113
|
+
const info = getTailwindcssPackageInfo({ paths: [candidate] });
|
|
114
|
+
if (info?.rootPath) {
|
|
115
|
+
return candidate;
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
function resolvePatchDefaultCwd(currentCwd = process2.cwd()) {
|
|
123
|
+
const baseDir = path2.normalize(currentCwd);
|
|
124
|
+
const explicitCwd = normalizeCandidatePath(baseDir, process2.env.WEAPP_TW_PATCH_CWD);
|
|
125
|
+
if (explicitCwd) {
|
|
126
|
+
return explicitCwd;
|
|
127
|
+
}
|
|
128
|
+
const workspaceRoot = findWorkspaceRoot(baseDir);
|
|
129
|
+
const initCwd = normalizeCandidatePath(baseDir, process2.env.INIT_CWD);
|
|
130
|
+
const localPrefix = normalizeCandidatePath(baseDir, process2.env.npm_config_local_prefix);
|
|
131
|
+
const candidates = [
|
|
132
|
+
baseDir,
|
|
133
|
+
workspaceRoot,
|
|
134
|
+
initCwd,
|
|
135
|
+
localPrefix
|
|
136
|
+
].filter(Boolean);
|
|
137
|
+
const detected = detectTailwindWorkspace([...new Set(candidates)]);
|
|
138
|
+
if (detected) {
|
|
139
|
+
return detected;
|
|
140
|
+
}
|
|
141
|
+
return initCwd ?? localPrefix ?? workspaceRoot ?? baseDir;
|
|
142
|
+
}
|
|
96
143
|
async function ensureDir(dir) {
|
|
97
144
|
await mkdir(dir, { recursive: true });
|
|
98
145
|
}
|
|
@@ -117,6 +164,39 @@ function commandAction(handler) {
|
|
|
117
164
|
};
|
|
118
165
|
}
|
|
119
166
|
|
|
167
|
+
// src/cli/patch-options.ts
|
|
168
|
+
var DEFAULT_EXTEND_LENGTH_UNITS_FEATURE = {
|
|
169
|
+
enabled: true,
|
|
170
|
+
units: ["rpx"],
|
|
171
|
+
overwrite: true
|
|
172
|
+
};
|
|
173
|
+
function withDefaultExtendLengthUnits(options) {
|
|
174
|
+
const normalized = options ?? {};
|
|
175
|
+
const extendLengthUnits = normalized.features?.extendLengthUnits;
|
|
176
|
+
if (extendLengthUnits == null) {
|
|
177
|
+
return {
|
|
178
|
+
...normalized,
|
|
179
|
+
features: {
|
|
180
|
+
...normalized.features ?? {},
|
|
181
|
+
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return normalized;
|
|
186
|
+
}
|
|
187
|
+
function buildExtendLengthUnitsOverride(options) {
|
|
188
|
+
const extendLengthUnits = options?.features?.extendLengthUnits;
|
|
189
|
+
if (extendLengthUnits == null) {
|
|
190
|
+
return {
|
|
191
|
+
features: {
|
|
192
|
+
...options?.features ?? {},
|
|
193
|
+
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
120
200
|
// src/cli/vscode-entry.ts
|
|
121
201
|
import { constants } from "fs";
|
|
122
202
|
import { access, writeFile } from "fs/promises";
|
|
@@ -244,14 +324,6 @@ import process3 from "process";
|
|
|
244
324
|
import fg from "fast-glob";
|
|
245
325
|
import { normalizeOptions, TailwindcssPatcher } from "tailwindcss-patch";
|
|
246
326
|
import { parse as parseYaml } from "yaml";
|
|
247
|
-
|
|
248
|
-
// src/tailwindcss/index.ts
|
|
249
|
-
import { getPackageInfoSync } from "local-pkg";
|
|
250
|
-
function getTailwindcssPackageInfo(options) {
|
|
251
|
-
return getPackageInfoSync("tailwindcss", options);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// src/cli/workspace.ts
|
|
255
327
|
function tryReadJson(file) {
|
|
256
328
|
try {
|
|
257
329
|
const content = readFileSync(file, "utf8");
|
|
@@ -341,9 +413,11 @@ async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
|
341
413
|
return [...dirs];
|
|
342
414
|
}
|
|
343
415
|
function createWorkspacePatcher(cwd) {
|
|
344
|
-
const normalized = normalizeOptions(
|
|
345
|
-
|
|
346
|
-
|
|
416
|
+
const normalized = normalizeOptions(
|
|
417
|
+
withDefaultExtendLengthUnits({
|
|
418
|
+
cwd
|
|
419
|
+
})
|
|
420
|
+
);
|
|
347
421
|
return new TailwindcssPatcher(normalized);
|
|
348
422
|
}
|
|
349
423
|
function formatDisplayName(workspaceRoot, dir, name) {
|
|
@@ -446,7 +520,13 @@ var mountOptions = {
|
|
|
446
520
|
install: {
|
|
447
521
|
name: "patch",
|
|
448
522
|
aliases: ["install"],
|
|
523
|
+
appendDefaultOptions: false,
|
|
449
524
|
optionDefs: [
|
|
525
|
+
{
|
|
526
|
+
flags: "--cwd <dir>",
|
|
527
|
+
description: "Working directory",
|
|
528
|
+
config: { default: resolvePatchDefaultCwd() }
|
|
529
|
+
},
|
|
450
530
|
{
|
|
451
531
|
flags: "--record-target",
|
|
452
532
|
description: 'Write tailwindcss target metadata (node_modules/.cache/weapp-tailwindcss/tailwindcss-target.json). Pass "--record-target false" to skip.',
|
|
@@ -476,7 +556,9 @@ var mountOptions = {
|
|
|
476
556
|
});
|
|
477
557
|
return;
|
|
478
558
|
}
|
|
479
|
-
const
|
|
559
|
+
const patchOptions = await ctx.loadPatchOptions();
|
|
560
|
+
const extendLengthUnitsOverride = buildExtendLengthUnitsOverride(patchOptions);
|
|
561
|
+
const patcher = extendLengthUnitsOverride ? await ctx.createPatcher(extendLengthUnitsOverride) : await ctx.createPatcher();
|
|
480
562
|
if (shouldClearCache) {
|
|
481
563
|
await clearTailwindcssPatcherCache(patcher, { removeDirectory: true });
|
|
482
564
|
}
|
package/dist/core.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunkFM3FLOYYjs = require('./chunk-FM3FLOYY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('./chunk-
|
|
8
|
+
var _chunk22ETJBBTjs = require('./chunk-22ETJBBT.js');
|
|
9
|
+
require('./chunk-45BMEACS.js');
|
|
10
10
|
require('./chunk-3URI7W6X.js');
|
|
11
11
|
require('./chunk-UW3WHSZ5.js');
|
|
12
12
|
require('./chunk-CFFV3OIP.js');
|
|
@@ -15,9 +15,9 @@ require('./chunk-CFFV3OIP.js');
|
|
|
15
15
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
16
16
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
17
17
|
function createContext(options = {}) {
|
|
18
|
-
const opts =
|
|
18
|
+
const opts = _chunk22ETJBBTjs.getCompilerContext.call(void 0, options);
|
|
19
19
|
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
20
|
-
const patchRecorderState =
|
|
20
|
+
const patchRecorderState = _chunkFM3FLOYYjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
21
21
|
source: "runtime",
|
|
22
22
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
23
23
|
});
|
|
@@ -29,7 +29,7 @@ function createContext(options = {}) {
|
|
|
29
29
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
30
30
|
};
|
|
31
31
|
async function refreshRuntimeState(force) {
|
|
32
|
-
await
|
|
32
|
+
await _chunk22ETJBBTjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
33
33
|
}
|
|
34
34
|
async function transformWxss(rawCss, options2) {
|
|
35
35
|
await runtimeState.patchPromise;
|
|
@@ -38,7 +38,7 @@ function createContext(options = {}) {
|
|
|
38
38
|
}));
|
|
39
39
|
await refreshRuntimeState(true);
|
|
40
40
|
await runtimeState.patchPromise;
|
|
41
|
-
runtimeSet = await
|
|
41
|
+
runtimeSet = await _chunk22ETJBBTjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
44
|
async function transformJs(rawJs, options2 = {}) {
|
|
@@ -48,7 +48,7 @@ function createContext(options = {}) {
|
|
|
48
48
|
} else {
|
|
49
49
|
await refreshRuntimeState(true);
|
|
50
50
|
await runtimeState.patchPromise;
|
|
51
|
-
runtimeSet = await
|
|
51
|
+
runtimeSet = await _chunk22ETJBBTjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
52
52
|
}
|
|
53
53
|
return await jsHandler(rawJs, runtimeSet, options2);
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@ function createContext(options = {}) {
|
|
|
57
57
|
if (!_optionalChain([options2, 'optionalAccess', _2 => _2.runtimeSet]) && runtimeSet.size === 0) {
|
|
58
58
|
await refreshRuntimeState(true);
|
|
59
59
|
await runtimeState.patchPromise;
|
|
60
|
-
runtimeSet = await
|
|
60
|
+
runtimeSet = await _chunk22ETJBBTjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
61
61
|
}
|
|
62
62
|
return templateHandler(rawWxml, _shared.defuOverrideArray.call(void 0, options2, {
|
|
63
63
|
runtimeSet
|
package/dist/core.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setupPatchRecorder
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3NLDVPXD.mjs";
|
|
4
4
|
import {
|
|
5
5
|
collectRuntimeClassSet,
|
|
6
6
|
getCompilerContext,
|
|
7
7
|
refreshTailwindRuntimeState
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-BSGZZCLH.mjs";
|
|
9
|
+
import "./chunk-HHSKDU3Z.mjs";
|
|
10
10
|
import "./chunk-QF65JGNW.mjs";
|
|
11
11
|
import "./chunk-ZNKIYZRQ.mjs";
|
|
12
12
|
import "./chunk-SXBK4NF4.mjs";
|