weapp-tailwindcss 4.8.11 → 4.8.12

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.
Files changed (45) hide show
  1. package/dist/{chunk-22ETJBBT.js → chunk-243FNJFQ.js} +127 -127
  2. package/dist/{chunk-YXT3T3LH.js → chunk-3DQN7M5U.js} +2 -2
  3. package/dist/{chunk-LAVN5SDT.mjs → chunk-4H3RCNUP.mjs} +2 -2
  4. package/dist/{chunk-W6ASDRWZ.mjs → chunk-6LYLDH5F.mjs} +1 -1
  5. package/dist/{chunk-CFFV3OIP.js → chunk-A5JYBYB2.js} +1 -1
  6. package/dist/{chunk-2SG4SGMQ.js → chunk-AVR4TFX3.js} +7 -7
  7. package/dist/{chunk-FGNKGESE.mjs → chunk-AVUQQ4GH.mjs} +4 -4
  8. package/dist/{chunk-FAKEMDGU.js → chunk-CGCWO2U6.js} +6 -6
  9. package/dist/{chunk-TWF4BQKE.mjs → chunk-HMFOJPZG.mjs} +2 -2
  10. package/dist/{chunk-BSGZZCLH.mjs → chunk-K2Y3FXU7.mjs} +108 -108
  11. package/dist/{chunk-SXBK4NF4.mjs → chunk-MDZGOZZP.mjs} +1 -1
  12. package/dist/{chunk-FM3FLOYY.js → chunk-WIET7TXZ.js} +5 -5
  13. package/dist/{chunk-6LNKARWD.js → chunk-WILVISNS.js} +28 -28
  14. package/dist/{chunk-3NLDVPXD.mjs → chunk-XSRP6OF5.mjs} +1 -1
  15. package/dist/{chunk-45BMEACS.js → chunk-ZADOXTZC.js} +4 -4
  16. package/dist/{chunk-DLSEDDLQ.js → chunk-ZSI6C3R4.js} +22 -22
  17. package/dist/cli.js +240 -168
  18. package/dist/cli.mjs +216 -144
  19. package/dist/core.js +10 -10
  20. package/dist/core.mjs +3 -3
  21. package/dist/css-macro/postcss.js +1 -1
  22. package/dist/css-macro/postcss.mjs +1 -1
  23. package/dist/css-macro.js +1 -1
  24. package/dist/css-macro.mjs +1 -1
  25. package/dist/defaults.js +1 -1
  26. package/dist/defaults.mjs +1 -1
  27. package/dist/gulp.js +6 -6
  28. package/dist/gulp.mjs +4 -4
  29. package/dist/index.js +10 -10
  30. package/dist/index.mjs +7 -7
  31. package/dist/postcss-html-transform.js +1 -1
  32. package/dist/postcss-html-transform.mjs +1 -1
  33. package/dist/presets.js +4 -4
  34. package/dist/presets.mjs +1 -1
  35. package/dist/reset.js +1 -1
  36. package/dist/reset.mjs +1 -1
  37. package/dist/types.js +1 -1
  38. package/dist/types.mjs +1 -1
  39. package/dist/vite.js +7 -7
  40. package/dist/vite.mjs +4 -4
  41. package/dist/webpack.js +8 -8
  42. package/dist/webpack.mjs +5 -5
  43. package/dist/webpack4.js +31 -31
  44. package/dist/webpack4.mjs +4 -4
  45. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -3,14 +3,14 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk22ETJBBTjs = require('./chunk-22ETJBBT.js');
6
+ var _chunk243FNJFQjs = require('./chunk-243FNJFQ.js');
7
7
 
8
8
 
9
9
 
10
- var _chunk45BMEACSjs = require('./chunk-45BMEACS.js');
10
+ var _chunkZADOXTZCjs = require('./chunk-ZADOXTZC.js');
11
11
  require('./chunk-3URI7W6X.js');
12
12
  require('./chunk-UW3WHSZ5.js');
13
- require('./chunk-CFFV3OIP.js');
13
+ require('./chunk-A5JYBYB2.js');
14
14
 
15
15
  // src/cli.ts
16
16
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
@@ -125,7 +125,7 @@ function resolvePatchDefaultCwd(currentCwd = _process2.default.cwd()) {
125
125
  if (explicitCwd) {
126
126
  return explicitCwd;
127
127
  }
128
- const workspaceRoot = _chunk45BMEACSjs.findWorkspaceRoot.call(void 0, baseDir);
128
+ const workspaceRoot = _chunkZADOXTZCjs.findWorkspaceRoot.call(void 0, baseDir);
129
129
  const initCwd = normalizeCandidatePath(baseDir, _process2.default.env.INIT_CWD);
130
130
  const localPrefix = normalizeCandidatePath(baseDir, _process2.default.env.npm_config_local_prefix);
131
131
  const candidates = [
@@ -145,12 +145,12 @@ async function ensureDir(dir) {
145
145
  }
146
146
  function handleCliError(error) {
147
147
  if (error instanceof Error) {
148
- _chunk45BMEACSjs.logger.error(error.message);
148
+ _chunkZADOXTZCjs.logger.error(error.message);
149
149
  if (error.stack && _process2.default.env.WEAPP_TW_DEBUG === "1") {
150
- _chunk45BMEACSjs.logger.error(error.stack);
150
+ _chunkZADOXTZCjs.logger.error(error.stack);
151
151
  }
152
152
  } else {
153
- _chunk45BMEACSjs.logger.error(String(error));
153
+ _chunkZADOXTZCjs.logger.error(String(error));
154
154
  }
155
155
  }
156
156
  function commandAction(handler) {
@@ -164,6 +164,9 @@ function commandAction(handler) {
164
164
  };
165
165
  }
166
166
 
167
+ // src/cli/mount-options.ts
168
+
169
+
167
170
  // src/cli/patch-options.ts
168
171
  var DEFAULT_EXTEND_LENGTH_UNITS_FEATURE = {
169
172
  enabled: true,
@@ -197,128 +200,8 @@ function buildExtendLengthUnitsOverride(options) {
197
200
  return void 0;
198
201
  }
199
202
 
200
- // src/cli/vscode-entry.ts
201
- var _fs = require('fs');
202
-
203
-
204
- var DEFAULT_VSCODE_ENTRY_OUTPUT = ".vscode/weapp-tailwindcss.intellisense.css";
205
- var DEFAULT_VSCODE_SOURCES = [
206
- 'not "./dist"',
207
- 'not "./unpackage"',
208
- "./src/**/*.{wxml,axml,swan,qml,ttml,ux,uts}",
209
- "./src/**/*.{js,jsx,ts,tsx}",
210
- "./src/**/*.{vue,svelte,html,md,mdx}"
211
- ];
212
- var SINGLE_QUOTE = "'";
213
- var DOUBLE_QUOTE = '"';
214
- function toPosixPath(filepath) {
215
- return filepath.replace(/\\/g, "/");
216
- }
217
- async function assertFileExists(filepath) {
218
- try {
219
- await _promises.access.call(void 0, filepath, _fs.constants.F_OK);
220
- } catch (error) {
221
- const err = error;
222
- if (_optionalChain([err, 'optionalAccess', _7 => _7.code]) === "ENOENT") {
223
- throw new Error(`CSS entry file not found: ${filepath}`);
224
- }
225
- throw err;
226
- }
227
- }
228
- async function assertCanWrite(filepath, force) {
229
- try {
230
- await _promises.access.call(void 0, filepath, _fs.constants.F_OK);
231
- if (!force) {
232
- throw new Error(
233
- `VS Code helper already exists at ${filepath}. Re-run with --force to overwrite it.`
234
- );
235
- }
236
- } catch (error) {
237
- const err = error;
238
- if (_optionalChain([err, 'optionalAccess', _8 => _8.code]) === "ENOENT") {
239
- return;
240
- }
241
- throw err;
242
- }
243
- }
244
- function toCssLiteral(value) {
245
- const normalized = toPosixPath(value);
246
- return JSON.stringify(normalized);
247
- }
248
- function formatSource(pattern) {
249
- const trimmed = pattern.trim();
250
- if (!trimmed) {
251
- return null;
252
- }
253
- if (trimmed.startsWith("@source ")) {
254
- return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
255
- }
256
- let body = trimmed;
257
- let keyword = "";
258
- if (body.startsWith("not ")) {
259
- keyword = "not ";
260
- body = body.slice(4).trim();
261
- } else if (body.startsWith("!")) {
262
- keyword = "not ";
263
- body = body.slice(1).trim();
264
- }
265
- if (!body) {
266
- throw new Error("Invalid @source pattern: empty body.");
267
- }
268
- if (!body.startsWith(SINGLE_QUOTE) && !body.startsWith(DOUBLE_QUOTE)) {
269
- body = toCssLiteral(body);
270
- }
271
- return `@source ${keyword}${body};`;
272
- }
273
- function resolveOutputPath(baseDir, output) {
274
- const target = _nullishCoalesce(output, () => ( DEFAULT_VSCODE_ENTRY_OUTPUT));
275
- return _path2.default.isAbsolute(target) ? _path2.default.normalize(target) : _path2.default.resolve(baseDir, target);
276
- }
277
- function resolveCssEntry(baseDir, entry) {
278
- return _path2.default.isAbsolute(entry) ? _path2.default.normalize(entry) : _path2.default.resolve(baseDir, entry);
279
- }
280
- function toRelativeImport(fromFile, targetFile) {
281
- const fromDir = _path2.default.dirname(fromFile);
282
- let relative = _path2.default.relative(fromDir, targetFile);
283
- if (!relative) {
284
- relative = _path2.default.basename(targetFile);
285
- }
286
- if (!relative.startsWith(".")) {
287
- relative = `./${relative}`;
288
- }
289
- return toPosixPath(relative);
290
- }
291
- async function generateVscodeIntellisenseEntry(options) {
292
- const baseDir = options.baseDir;
293
- const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry);
294
- await assertFileExists(cssEntryPath);
295
- const outputPath = resolveOutputPath(baseDir, options.output);
296
- await ensureDir(_path2.default.dirname(outputPath));
297
- await assertCanWrite(outputPath, options.force);
298
- const sources = options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES;
299
- const formattedSources = sources.map(formatSource).filter((statement) => Boolean(statement));
300
- const cssImport = toRelativeImport(outputPath, cssEntryPath);
301
- const separator = formattedSources.length > 0 ? [""] : [];
302
- const content = [
303
- "/*",
304
- " * Auto-generated by weapp-tailwindcss.",
305
- " * This file exists solely to activate Tailwind CSS IntelliSense in VS Code.",
306
- " * Do not import it in your actual mini-program bundles.",
307
- " */",
308
- "@import 'tailwindcss';",
309
- "",
310
- ...formattedSources,
311
- ...separator,
312
- `@import '${cssImport}';`,
313
- ""
314
- ].filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join("\n");
315
- await _promises.writeFile.call(void 0, outputPath, `${content}
316
- `, "utf8");
317
- return { outputPath, cssEntryPath };
318
- }
319
-
320
203
  // src/cli/workspace.ts
321
-
204
+ var _fs = require('fs');
322
205
 
323
206
 
324
207
  var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
@@ -335,7 +218,7 @@ function tryReadJson(file) {
335
218
  function parseWorkspaceGlobsFromPackageJson(workspaceRoot) {
336
219
  const pkgJsonPath = _path2.default.join(workspaceRoot, "package.json");
337
220
  const pkg = tryReadJson(pkgJsonPath);
338
- if (!_optionalChain([pkg, 'optionalAccess', _9 => _9.workspaces])) {
221
+ if (!_optionalChain([pkg, 'optionalAccess', _7 => _7.workspaces])) {
339
222
  return [];
340
223
  }
341
224
  if (Array.isArray(pkg.workspaces)) {
@@ -353,7 +236,7 @@ function parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot) {
353
236
  }
354
237
  try {
355
238
  const parsed = _yaml.parse.call(void 0, _fs.readFileSync.call(void 0, workspaceFile, "utf8"));
356
- return Array.isArray(_optionalChain([parsed, 'optionalAccess', _10 => _10.packages])) ? parsed.packages.filter(Boolean) : [];
239
+ return Array.isArray(_optionalChain([parsed, 'optionalAccess', _8 => _8.packages])) ? parsed.packages.filter(Boolean) : [];
357
240
  } catch (e3) {
358
241
  return [];
359
242
  }
@@ -365,7 +248,7 @@ function parseImportersFromLock(workspaceRoot) {
365
248
  }
366
249
  try {
367
250
  const parsed = _yaml.parse.call(void 0, _fs.readFileSync.call(void 0, lockPath, "utf8"));
368
- const importers = _optionalChain([parsed, 'optionalAccess', _11 => _11.importers]);
251
+ const importers = _optionalChain([parsed, 'optionalAccess', _9 => _9.importers]);
369
252
  if (!importers) {
370
253
  return [];
371
254
  }
@@ -426,82 +309,82 @@ function formatDisplayName(workspaceRoot, dir, name) {
426
309
  }
427
310
  async function patchWorkspace(options) {
428
311
  const cwd = _nullishCoalesce(options.cwd, () => ( _process2.default.cwd()));
429
- const workspaceRoot = _nullishCoalesce(_chunk45BMEACSjs.findWorkspaceRoot.call(void 0, cwd), () => ( cwd));
312
+ const workspaceRoot = _nullishCoalesce(_chunkZADOXTZCjs.findWorkspaceRoot.call(void 0, cwd), () => ( cwd));
430
313
  const packageDirs = await resolveWorkspacePackageDirs(workspaceRoot);
431
314
  if (packageDirs.length === 0) {
432
- _chunk45BMEACSjs.logger.warn("\u672A\u5728 %s \u68C0\u6D4B\u5230 workspace \u5305\uFF0C\u5DF2\u8DF3\u8FC7\u6279\u91CF patch\u3002", workspaceRoot);
315
+ _chunkZADOXTZCjs.logger.warn("\u672A\u5728 %s \u68C0\u6D4B\u5230 workspace \u5305\uFF0C\u5DF2\u8DF3\u8FC7\u6279\u91CF patch\u3002", workspaceRoot);
433
316
  return;
434
317
  }
435
318
  const results = [];
436
319
  for (const dir of packageDirs) {
437
320
  const pkgJsonPath = _path2.default.join(dir, "package.json");
438
321
  const pkgJson = tryReadJson(pkgJsonPath);
439
- const displayName = formatDisplayName(workspaceRoot, dir, _optionalChain([pkgJson, 'optionalAccess', _12 => _12.name]));
322
+ const displayName = formatDisplayName(workspaceRoot, dir, _optionalChain([pkgJson, 'optionalAccess', _10 => _10.name]));
440
323
  const tailwindInfo = getTailwindcssPackageInfo({ paths: [dir] });
441
- if (!_optionalChain([tailwindInfo, 'optionalAccess', _13 => _13.rootPath])) {
324
+ if (!_optionalChain([tailwindInfo, 'optionalAccess', _11 => _11.rootPath])) {
442
325
  results.push({
443
326
  dir,
444
- name: _optionalChain([pkgJson, 'optionalAccess', _14 => _14.name]),
327
+ name: _optionalChain([pkgJson, 'optionalAccess', _12 => _12.name]),
445
328
  status: "skipped",
446
329
  message: "tailwindcss \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
447
330
  });
448
- _chunk45BMEACSjs.logger.info("[workspace] \u8DF3\u8FC7 %s\uFF08tailwindcss \u672A\u5B89\u88C5\uFF09\u3002", displayName);
331
+ _chunkZADOXTZCjs.logger.info("[workspace] \u8DF3\u8FC7 %s\uFF08tailwindcss \u672A\u5B89\u88C5\uFF09\u3002", displayName);
449
332
  continue;
450
333
  }
451
334
  try {
452
335
  const patcher = createWorkspacePatcher(dir);
453
336
  if (options.clearCache) {
454
- await _chunk22ETJBBTjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
337
+ await _chunk243FNJFQjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
455
338
  }
456
- const recorder = _chunk22ETJBBTjs.createPatchTargetRecorder.call(void 0, dir, patcher, {
339
+ const recorder = _chunk243FNJFQjs.createPatchTargetRecorder.call(void 0, dir, patcher, {
457
340
  source: "cli",
458
341
  cwd: dir,
459
342
  recordTarget: options.recordTarget !== false,
460
343
  alwaysRecord: true
461
344
  });
462
- if (_optionalChain([recorder, 'optionalAccess', _15 => _15.message])) {
463
- _chunk45BMEACSjs.logger.info("[workspace] %s %s", displayName, recorder.message);
345
+ if (_optionalChain([recorder, 'optionalAccess', _13 => _13.message])) {
346
+ _chunkZADOXTZCjs.logger.info("[workspace] %s %s", displayName, recorder.message);
464
347
  }
465
- _chunk22ETJBBTjs.logTailwindcssTarget.call(void 0, "cli", patcher, dir);
348
+ _chunk243FNJFQjs.logTailwindcssTarget.call(void 0, "cli", patcher, dir);
466
349
  await patcher.patch();
467
- if (_optionalChain([recorder, 'optionalAccess', _16 => _16.onPatched])) {
350
+ if (_optionalChain([recorder, 'optionalAccess', _14 => _14.onPatched])) {
468
351
  await recorder.onPatched();
469
352
  }
470
353
  results.push({
471
354
  dir,
472
- name: _optionalChain([pkgJson, 'optionalAccess', _17 => _17.name]),
355
+ name: _optionalChain([pkgJson, 'optionalAccess', _15 => _15.name]),
473
356
  status: "patched",
474
357
  message: "\u5DF2\u5B8C\u6210 patch\u3002"
475
358
  });
476
- _chunk45BMEACSjs.logger.success("[workspace] \u5DF2\u8865\u4E01 %s", displayName);
359
+ _chunkZADOXTZCjs.logger.success("[workspace] \u5DF2\u8865\u4E01 %s", displayName);
477
360
  } catch (error) {
478
361
  const reason = error instanceof Error ? error.message : String(error);
479
362
  const suggestion = `\u8BF7\u5728 ${dir} \u8FD0\u884C "weapp-tw patch --cwd ${dir}".`;
480
363
  const message = `${reason}\uFF0C${suggestion}`;
481
364
  results.push({
482
365
  dir,
483
- name: _optionalChain([pkgJson, 'optionalAccess', _18 => _18.name]),
366
+ name: _optionalChain([pkgJson, 'optionalAccess', _16 => _16.name]),
484
367
  status: "failed",
485
368
  message
486
369
  });
487
- _chunk45BMEACSjs.logger.error("[workspace] \u8865\u4E01\u5931\u8D25 %s\uFF1A%s", displayName, message);
370
+ _chunkZADOXTZCjs.logger.error("[workspace] \u8865\u4E01\u5931\u8D25 %s\uFF1A%s", displayName, message);
488
371
  }
489
372
  }
490
373
  const patched = results.filter((result) => result.status === "patched").length;
491
374
  const skipped = results.filter((result) => result.status === "skipped").length;
492
375
  const failed = results.filter((result) => result.status === "failed").length;
493
- _chunk45BMEACSjs.logger.info("[workspace] \u6C47\u603B\uFF1A\u5DF2\u8865\u4E01 %d\uFF0C\u8DF3\u8FC7 %d\uFF0C\u5931\u8D25 %d", patched, skipped, failed);
376
+ _chunkZADOXTZCjs.logger.info("[workspace] \u6C47\u603B\uFF1A\u5DF2\u8865\u4E01 %d\uFF0C\u8DF3\u8FC7 %d\uFF0C\u5931\u8D25 %d", patched, skipped, failed);
494
377
  }
495
378
 
496
- // src/cli.ts
379
+ // src/cli/mount-options.ts
497
380
  function handleCliError2(error) {
498
381
  if (error instanceof Error) {
499
- _chunk45BMEACSjs.logger.error(error.message);
382
+ _chunkZADOXTZCjs.logger.error(error.message);
500
383
  if (error.stack && _process2.default.env.WEAPP_TW_DEBUG === "1") {
501
- _chunk45BMEACSjs.logger.error(error.stack);
384
+ _chunkZADOXTZCjs.logger.error(error.stack);
502
385
  }
503
386
  } else {
504
- _chunk45BMEACSjs.logger.error(String(error));
387
+ _chunkZADOXTZCjs.logger.error(String(error));
505
388
  }
506
389
  }
507
390
  function withCommandErrorHandling(handler) {
@@ -515,6 +398,51 @@ function withCommandErrorHandling(handler) {
515
398
  }
516
399
  });
517
400
  }
401
+ async function createPatcherWithDefaultExtendLengthUnits(ctx) {
402
+ const patchOptions = await ctx.loadPatchOptions();
403
+ const extendLengthUnitsOverride = buildExtendLengthUnitsOverride(patchOptions);
404
+ if (extendLengthUnitsOverride) {
405
+ return ctx.createPatcher(extendLengthUnitsOverride);
406
+ }
407
+ return ctx.createPatcher();
408
+ }
409
+ function formatStatusFilesHint(files) {
410
+ if (!_optionalChain([files, 'optionalAccess', _17 => _17.length])) {
411
+ return "";
412
+ }
413
+ return ` (${files.join(", ")})`;
414
+ }
415
+ function logPatchStatusReport(report) {
416
+ const applied = report.entries.filter((entry) => entry.status === "applied");
417
+ const pending = report.entries.filter((entry) => entry.status === "not-applied");
418
+ const skipped = report.entries.filter(
419
+ (entry) => entry.status === "skipped" || entry.status === "unsupported"
420
+ );
421
+ const packageLabel = `${_nullishCoalesce(report.package.name, () => ( "tailwindcss"))}@${_nullishCoalesce(report.package.version, () => ( "unknown"))}`;
422
+ _chunkZADOXTZCjs.logger.info(`Patch status for ${packageLabel} (v${report.majorVersion})`);
423
+ if (applied.length) {
424
+ _chunkZADOXTZCjs.logger.success("Applied:");
425
+ applied.forEach((entry) => {
426
+ _chunkZADOXTZCjs.logger.success(` - ${entry.name}${formatStatusFilesHint(entry.files)}`);
427
+ });
428
+ }
429
+ if (pending.length) {
430
+ _chunkZADOXTZCjs.logger.warn("Needs attention:");
431
+ pending.forEach((entry) => {
432
+ const details = entry.reason ? ` - ${entry.reason}` : "";
433
+ _chunkZADOXTZCjs.logger.warn(` - ${entry.name}${formatStatusFilesHint(entry.files)}${details}`);
434
+ });
435
+ } else {
436
+ _chunkZADOXTZCjs.logger.success("All applicable patches are applied.");
437
+ }
438
+ if (skipped.length) {
439
+ _chunkZADOXTZCjs.logger.info("Skipped:");
440
+ skipped.forEach((entry) => {
441
+ const details = entry.reason ? ` - ${entry.reason}` : "";
442
+ _chunkZADOXTZCjs.logger.info(` - ${entry.name}${details}`);
443
+ });
444
+ }
445
+ }
518
446
  var mountOptions = {
519
447
  commandOptions: {
520
448
  install: {
@@ -541,6 +469,20 @@ var mountOptions = {
541
469
  description: "Scan pnpm workspace packages and patch each Tailwind CSS dependency"
542
470
  }
543
471
  ]
472
+ },
473
+ status: {
474
+ appendDefaultOptions: false,
475
+ optionDefs: [
476
+ {
477
+ flags: "--cwd <dir>",
478
+ description: "Working directory",
479
+ config: { default: resolvePatchDefaultCwd() }
480
+ },
481
+ {
482
+ flags: "--json",
483
+ description: "Print a JSON report of patch status"
484
+ }
485
+ ]
544
486
  }
545
487
  },
546
488
  commandHandlers: {
@@ -556,40 +498,170 @@ var mountOptions = {
556
498
  });
557
499
  return;
558
500
  }
559
- const patchOptions = await ctx.loadPatchOptions();
560
- const extendLengthUnitsOverride = buildExtendLengthUnitsOverride(patchOptions);
561
- const patcher = extendLengthUnitsOverride ? await ctx.createPatcher(extendLengthUnitsOverride) : await ctx.createPatcher();
501
+ const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx);
562
502
  if (shouldClearCache) {
563
- await _chunk22ETJBBTjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
503
+ await _chunk243FNJFQjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
564
504
  }
565
- const recorder = _chunk22ETJBBTjs.createPatchTargetRecorder.call(void 0, ctx.cwd, patcher, {
505
+ const recorder = _chunk243FNJFQjs.createPatchTargetRecorder.call(void 0, ctx.cwd, patcher, {
566
506
  source: "cli",
567
507
  cwd: ctx.cwd,
568
508
  recordTarget: shouldRecordTarget,
569
509
  alwaysRecord: true
570
510
  });
571
- if (_optionalChain([recorder, 'optionalAccess', _19 => _19.message])) {
572
- _chunk45BMEACSjs.logger.info(recorder.message);
511
+ if (_optionalChain([recorder, 'optionalAccess', _18 => _18.message])) {
512
+ _chunkZADOXTZCjs.logger.info(recorder.message);
573
513
  }
574
- _chunk22ETJBBTjs.logTailwindcssTarget.call(void 0, "cli", patcher, ctx.cwd);
514
+ _chunk243FNJFQjs.logTailwindcssTarget.call(void 0, "cli", patcher, ctx.cwd);
575
515
  await patcher.patch();
576
- if (_optionalChain([recorder, 'optionalAccess', _20 => _20.onPatched])) {
516
+ if (_optionalChain([recorder, 'optionalAccess', _19 => _19.onPatched])) {
577
517
  const recordPath = await recorder.onPatched();
578
518
  if (recordPath) {
579
- _chunk45BMEACSjs.logger.info(`\u8BB0\u5F55 weapp-tw patch \u76EE\u6807 -> ${formatOutputPath(recordPath, ctx.cwd)}`);
519
+ _chunkZADOXTZCjs.logger.info(`\u8BB0\u5F55 weapp-tw patch \u76EE\u6807 -> ${formatOutputPath(recordPath, ctx.cwd)}`);
580
520
  }
581
521
  }
582
- _chunk45BMEACSjs.logger.success("Tailwind CSS \u8FD0\u884C\u65F6\u8865\u4E01\u5DF2\u5B8C\u6210\u3002");
522
+ _chunkZADOXTZCjs.logger.success("Tailwind CSS \u8FD0\u884C\u65F6\u8865\u4E01\u5DF2\u5B8C\u6210\u3002");
583
523
  }),
584
524
  extract: withCommandErrorHandling(async (_ctx, next) => next()),
585
525
  tokens: withCommandErrorHandling(async (_ctx, next) => next()),
586
- init: withCommandErrorHandling(async (_ctx, next) => next())
526
+ init: withCommandErrorHandling(async (_ctx, next) => next()),
527
+ status: withCommandErrorHandling(async (ctx) => {
528
+ const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx);
529
+ const report = await patcher.getPatchStatus();
530
+ if (ctx.args.json) {
531
+ _chunkZADOXTZCjs.logger.log(JSON.stringify(report, null, 2));
532
+ return report;
533
+ }
534
+ logPatchStatusReport(report);
535
+ return report;
536
+ })
587
537
  }
588
538
  };
539
+
540
+ // src/cli/vscode-entry.ts
541
+
542
+
543
+
544
+ var DEFAULT_VSCODE_ENTRY_OUTPUT = ".vscode/weapp-tailwindcss.intellisense.css";
545
+ var DEFAULT_VSCODE_SOURCES = [
546
+ 'not "./dist"',
547
+ 'not "./unpackage"',
548
+ "./src/**/*.{wxml,axml,swan,qml,ttml,ux,uts}",
549
+ "./src/**/*.{js,jsx,ts,tsx}",
550
+ "./src/**/*.{vue,svelte,html,md,mdx}"
551
+ ];
552
+ var SINGLE_QUOTE = "'";
553
+ var DOUBLE_QUOTE = '"';
554
+ function toPosixPath(filepath) {
555
+ return filepath.replace(/\\/g, "/");
556
+ }
557
+ async function assertFileExists(filepath) {
558
+ try {
559
+ await _promises.access.call(void 0, filepath, _fs.constants.F_OK);
560
+ } catch (error) {
561
+ const err = error;
562
+ if (_optionalChain([err, 'optionalAccess', _20 => _20.code]) === "ENOENT") {
563
+ throw new Error(`CSS entry file not found: ${filepath}`);
564
+ }
565
+ throw err;
566
+ }
567
+ }
568
+ async function assertCanWrite(filepath, force) {
569
+ try {
570
+ await _promises.access.call(void 0, filepath, _fs.constants.F_OK);
571
+ if (!force) {
572
+ throw new Error(
573
+ `VS Code helper already exists at ${filepath}. Re-run with --force to overwrite it.`
574
+ );
575
+ }
576
+ } catch (error) {
577
+ const err = error;
578
+ if (_optionalChain([err, 'optionalAccess', _21 => _21.code]) === "ENOENT") {
579
+ return;
580
+ }
581
+ throw err;
582
+ }
583
+ }
584
+ function toCssLiteral(value) {
585
+ const normalized = toPosixPath(value);
586
+ return JSON.stringify(normalized);
587
+ }
588
+ function formatSource(pattern) {
589
+ const trimmed = pattern.trim();
590
+ if (!trimmed) {
591
+ return null;
592
+ }
593
+ if (trimmed.startsWith("@source ")) {
594
+ return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
595
+ }
596
+ let body = trimmed;
597
+ let keyword = "";
598
+ if (body.startsWith("not ")) {
599
+ keyword = "not ";
600
+ body = body.slice(4).trim();
601
+ } else if (body.startsWith("!")) {
602
+ keyword = "not ";
603
+ body = body.slice(1).trim();
604
+ }
605
+ if (!body) {
606
+ throw new Error("Invalid @source pattern: empty body.");
607
+ }
608
+ if (!body.startsWith(SINGLE_QUOTE) && !body.startsWith(DOUBLE_QUOTE)) {
609
+ body = toCssLiteral(body);
610
+ }
611
+ return `@source ${keyword}${body};`;
612
+ }
613
+ function resolveOutputPath(baseDir, output) {
614
+ const target = _nullishCoalesce(output, () => ( DEFAULT_VSCODE_ENTRY_OUTPUT));
615
+ return _path2.default.isAbsolute(target) ? _path2.default.normalize(target) : _path2.default.resolve(baseDir, target);
616
+ }
617
+ function resolveCssEntry(baseDir, entry) {
618
+ return _path2.default.isAbsolute(entry) ? _path2.default.normalize(entry) : _path2.default.resolve(baseDir, entry);
619
+ }
620
+ function toRelativeImport(fromFile, targetFile) {
621
+ const fromDir = _path2.default.dirname(fromFile);
622
+ let relative = _path2.default.relative(fromDir, targetFile);
623
+ if (!relative) {
624
+ relative = _path2.default.basename(targetFile);
625
+ }
626
+ if (!relative.startsWith(".")) {
627
+ relative = `./${relative}`;
628
+ }
629
+ return toPosixPath(relative);
630
+ }
631
+ async function generateVscodeIntellisenseEntry(options) {
632
+ const baseDir = options.baseDir;
633
+ const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry);
634
+ await assertFileExists(cssEntryPath);
635
+ const outputPath = resolveOutputPath(baseDir, options.output);
636
+ await ensureDir(_path2.default.dirname(outputPath));
637
+ await assertCanWrite(outputPath, options.force);
638
+ const sources = options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES;
639
+ const formattedSources = sources.map(formatSource).filter((statement) => Boolean(statement));
640
+ const cssImport = toRelativeImport(outputPath, cssEntryPath);
641
+ const separator = formattedSources.length > 0 ? [""] : [];
642
+ const content = [
643
+ "/*",
644
+ " * Auto-generated by weapp-tailwindcss.",
645
+ " * This file exists solely to activate Tailwind CSS IntelliSense in VS Code.",
646
+ " * Do not import it in your actual mini-program bundles.",
647
+ " */",
648
+ "@import 'tailwindcss';",
649
+ "",
650
+ ...formattedSources,
651
+ ...separator,
652
+ `@import '${cssImport}';`,
653
+ ""
654
+ ].filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join("\n");
655
+ await _promises.writeFile.call(void 0, outputPath, `${content}
656
+ `, "utf8");
657
+ return { outputPath, cssEntryPath };
658
+ }
659
+
660
+ // src/cli.ts
589
661
  _process2.default.title = "node (weapp-tailwindcss)";
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.`
662
+ if (_semver2.default.lt(_process2.default.versions.node, _chunk243FNJFQjs.WEAPP_TW_REQUIRED_NODE_VERSION)) {
663
+ _chunkZADOXTZCjs.logger.warn(
664
+ `You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunk243FNJFQjs.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
593
665
  );
594
666
  }
595
667
  var cli = _tailwindcsspatch.createTailwindcssPatchCli.call(void 0, {
@@ -614,7 +686,7 @@ cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliS
614
686
  sources,
615
687
  force
616
688
  });
617
- _chunk45BMEACSjs.logger.success(
689
+ _chunkZADOXTZCjs.logger.success(
618
690
  `VS Code helper generated -> ${formatOutputPath(result.outputPath, resolvedCwd)}`
619
691
  );
620
692
  })