tailwindcss-patch 9.4.1 → 9.4.3

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 (34) hide show
  1. package/README.md +69 -0
  2. package/dist/{cli-CBVPia5Z.js → cli-BztQHMRp.js} +63 -64
  3. package/dist/{cli-CgBdW1U5.mjs → cli-D0jXMGXf.mjs} +1 -1
  4. package/dist/cli.js +5 -6
  5. package/dist/cli.mjs +2 -2
  6. package/dist/commands/cli-runtime.d.mts +1 -1
  7. package/dist/commands/cli-runtime.d.ts +1 -1
  8. package/dist/commands/cli-runtime.js +6 -6
  9. package/dist/commands/cli-runtime.mjs +2 -2
  10. package/dist/{dist-B1VBpHtd.js → dist-DDcbvOwe.js} +2 -2
  11. package/dist/index.d.mts +105 -5
  12. package/dist/index.d.ts +105 -5
  13. package/dist/index.js +325 -62
  14. package/dist/index.mjs +253 -4
  15. package/dist/{migrate-config-DqknZpUe.mjs → validate-Bug_WYcU.mjs} +193 -93
  16. package/dist/{validate-CaJv2g5K.d.ts → validate-BuqRodYI.d.ts} +65 -16
  17. package/dist/{migrate-config-Dn9OTXpO.js → validate-DbuKewV-.js} +257 -100
  18. package/dist/{validate-Dr7IkGU8.d.mts → validate-oAkURzUC.d.mts} +65 -15
  19. package/package.json +9 -9
  20. package/src/extraction/candidate-extractor.ts +76 -12
  21. package/src/public-api.ts +54 -13
  22. package/src/style-candidates.ts +35 -0
  23. package/src/style-generator.ts +80 -0
  24. package/src/v3/index.ts +11 -0
  25. package/src/v3/style-generator.ts +384 -0
  26. package/src/v4/bare-arbitrary-values.ts +127 -2
  27. package/src/v4/engine.ts +5 -2
  28. package/src/v4/index.ts +20 -4
  29. package/src/v4/node-adapter.ts +1 -1
  30. package/src/v4/source-scan.ts +1 -1
  31. package/src/v4/style-generator.ts +44 -0
  32. package/src/v4/types.ts +23 -0
  33. package/dist/chunk-8l464Juk.js +0 -28
  34. /package/dist/{dist-BjUV1yEM.mjs → dist-CxmNpfyy.mjs} +0 -0
@@ -1,32 +1,53 @@
1
- const require_chunk = require("./chunk-8l464Juk.js");
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
2
23
  let node_module = require("node:module");
3
24
  let node_process = require("node:process");
4
- node_process = require_chunk.__toESM(node_process);
25
+ node_process = __toESM(node_process);
5
26
  let fs_extra = require("fs-extra");
6
- fs_extra = require_chunk.__toESM(fs_extra);
27
+ fs_extra = __toESM(fs_extra);
7
28
  let local_pkg = require("local-pkg");
8
29
  let pathe = require("pathe");
9
- pathe = require_chunk.__toESM(pathe);
30
+ pathe = __toESM(pathe);
10
31
  let semver = require("semver");
11
32
  let node_crypto = require("node:crypto");
12
33
  let consola = require("consola");
13
34
  let node_url = require("node:url");
14
35
  let node_fs = require("node:fs");
15
36
  let postcss = require("postcss");
16
- postcss = require_chunk.__toESM(postcss);
37
+ postcss = __toESM(postcss);
17
38
  let node_fs_promises = require("node:fs/promises");
18
39
  let micromatch = require("micromatch");
19
- micromatch = require_chunk.__toESM(micromatch);
40
+ micromatch = __toESM(micromatch);
20
41
  let _babel_types = require("@babel/types");
21
- _babel_types = require_chunk.__toESM(_babel_types);
42
+ _babel_types = __toESM(_babel_types);
22
43
  let _babel_generator = require("@babel/generator");
23
- _babel_generator = require_chunk.__toESM(_babel_generator);
44
+ _babel_generator = __toESM(_babel_generator);
24
45
  let _babel_traverse = require("@babel/traverse");
25
- _babel_traverse = require_chunk.__toESM(_babel_traverse);
46
+ _babel_traverse = __toESM(_babel_traverse);
26
47
  let _babel_parser = require("@babel/parser");
27
48
  let tailwindcss_config = require("tailwindcss-config");
28
49
  //#region package.json
29
- var version = "9.4.1";
50
+ var version = "9.4.3";
30
51
  //#endregion
31
52
  //#region src/constants.ts
32
53
  const pkgName = "tailwindcss-patch";
@@ -1447,7 +1468,7 @@ async function loadWorkspaceConfigModule() {
1447
1468
  return configModulePromise;
1448
1469
  }
1449
1470
  async function loadWorkspaceDefu() {
1450
- if (!defuPromise) defuPromise = Promise.resolve().then(() => require("./dist-B1VBpHtd.js")).then((mod) => mod.defu).catch(async (error) => {
1471
+ if (!defuPromise) defuPromise = Promise.resolve().then(() => require("./dist-DDcbvOwe.js")).then((mod) => mod.defu).catch(async (error) => {
1451
1472
  if (!isMissingSharedModuleError(error)) throw error;
1452
1473
  return (await import((0, node_url.pathToFileURL)(pathe.default.resolve(__dirname, "../../../shared/src/utils.ts")).href)).defu;
1453
1474
  });
@@ -1492,6 +1513,8 @@ const DEFAULT_BARE_ARBITRARY_VALUE_UNITS = [
1492
1513
  const NUMBER_RE = /^-?(?:\d+|\d*\.\d+)$/;
1493
1514
  const FUNCTION_VALUE_RE = /^[a-z_-][\w-]*\(/i;
1494
1515
  const HEX_ESCAPE_RE = /^[\da-f]$/i;
1516
+ const ASPECT_RATIO_RE = /^\d+\/\d+$/;
1517
+ const ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
1495
1518
  function splitVariantPrefix(candidate) {
1496
1519
  let depth = 0;
1497
1520
  let quote;
@@ -1611,6 +1634,9 @@ function normalizeBareArbitraryValueOptions(options) {
1611
1634
  if (normalizedUnits.length === 0) return;
1612
1635
  return { units: normalizedUnits.sort((a, b) => b.length - a.length) };
1613
1636
  }
1637
+ function isBareArbitraryValuesEnabled(options) {
1638
+ return normalizeBareArbitraryValueOptions(options) !== void 0;
1639
+ }
1614
1640
  function normalizeEscapedValue(value) {
1615
1641
  let result = "";
1616
1642
  for (let index = 0; index < value.length; index++) {
@@ -1652,13 +1678,17 @@ function resolveValueWithUnit(body, units) {
1652
1678
  if (NUMBER_RE.test(numberPart)) return `${numberPart}${unit}`;
1653
1679
  }
1654
1680
  }
1655
- function resolveArbitraryValue(body, units) {
1681
+ function resolveArbitraryValue(utility, body, units) {
1656
1682
  const value = normalizeEscapedValue(body);
1657
1683
  const withUnit = resolveValueWithUnit(value, units);
1658
1684
  if (withUnit) return withUnit;
1685
+ if (utility === "aspect" && ASPECT_RATIO_RE.test(value)) return value;
1659
1686
  if (isHexColorValue(value)) return value;
1660
1687
  if (isQuotedValue(value)) return value;
1661
- if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value)) return value;
1688
+ if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value)) {
1689
+ if (utility === "text" && /^var\(/i.test(value)) return `color:${value}`;
1690
+ return value;
1691
+ }
1662
1692
  }
1663
1693
  function resolveUtilityAndValue(body, units) {
1664
1694
  let depth = 0;
@@ -1686,7 +1716,7 @@ function resolveUtilityAndValue(body, units) {
1686
1716
  const utility = body.slice(0, index);
1687
1717
  const rawValue = body.slice(index + 1);
1688
1718
  if (!utility || !rawValue) continue;
1689
- const value = resolveArbitraryValue(rawValue, units);
1719
+ const value = resolveArbitraryValue(utility, rawValue, units);
1690
1720
  if (value) return {
1691
1721
  utility,
1692
1722
  value
@@ -1709,6 +1739,65 @@ function resolveBareArbitraryValueCandidate(candidate, options) {
1709
1739
  canonicalCandidate: `${prefix}${important}${negative}${resolved.utility}-[${resolved.value}]`
1710
1740
  };
1711
1741
  }
1742
+ function isBareArbitrarySourceSplitter(char) {
1743
+ return /\s/.test(char);
1744
+ }
1745
+ function isQuoteBoundary(content, start, index) {
1746
+ const tokenPrefix = content.slice(start, index);
1747
+ return tokenPrefix.length === 0 || !tokenPrefix.endsWith("-");
1748
+ }
1749
+ function trimBareArbitrarySourceToken(token, start) {
1750
+ let nextToken = token;
1751
+ let nextStart = start;
1752
+ while (nextToken.length > 0 && /^[<{([]$/.test(nextToken[0])) {
1753
+ nextToken = nextToken.slice(1);
1754
+ nextStart++;
1755
+ }
1756
+ while (nextToken.length > 0 && /^[>\],;]$/.test(nextToken[nextToken.length - 1])) nextToken = nextToken.slice(0, -1);
1757
+ return {
1758
+ token: nextToken,
1759
+ start: nextStart
1760
+ };
1761
+ }
1762
+ function pushBareArbitrarySourceCandidate(result, token, start, options) {
1763
+ const trimmed = trimBareArbitrarySourceToken(token, start);
1764
+ if (!trimmed.token || trimmed.token.includes("=") || trimmed.token.includes("[") || trimmed.token.includes("]")) return;
1765
+ if (!resolveBareArbitraryValueCandidate(trimmed.token, options)) return;
1766
+ result.push({
1767
+ rawCandidate: trimmed.token,
1768
+ start: trimmed.start,
1769
+ end: trimmed.start + trimmed.token.length
1770
+ });
1771
+ }
1772
+ function extractBareArbitraryValueSourceCandidatesWithPositions(content, options) {
1773
+ if (!isBareArbitraryValuesEnabled(options)) return [];
1774
+ const normalized = content.includes("\\") ? content.replace(ESCAPED_WHITESPACE_RE, " ") : content;
1775
+ const result = [];
1776
+ let depth = 0;
1777
+ let quote;
1778
+ let start = 0;
1779
+ for (let index = 0; index < normalized.length; index++) {
1780
+ const char = normalized[index];
1781
+ if (char === void 0) continue;
1782
+ if (char === "\\") {
1783
+ index++;
1784
+ continue;
1785
+ }
1786
+ if (quote) {
1787
+ if (char === quote) quote = void 0;
1788
+ } else if ((char === "\"" || char === "'" || char === "`") && !isQuoteBoundary(normalized, start, index)) quote = char;
1789
+ else if (char === "(" || char === "{" || char === "[") depth++;
1790
+ else if (char === ")" || char === "}" || char === "]") depth = Math.max(0, depth - 1);
1791
+ if (!isBareArbitrarySourceSplitter(char) && !((char === "\"" || char === "'" || char === "`") && depth === 0 && isQuoteBoundary(normalized, start, index))) continue;
1792
+ pushBareArbitrarySourceCandidate(result, normalized.slice(start, index), start, options);
1793
+ start = index + 1;
1794
+ }
1795
+ pushBareArbitrarySourceCandidate(result, normalized.slice(start), start, options);
1796
+ return result;
1797
+ }
1798
+ function extractBareArbitraryValueSourceCandidates(content, options) {
1799
+ return [...new Set(extractBareArbitraryValueSourceCandidatesWithPositions(content, options).map((candidate) => candidate.rawCandidate))];
1800
+ }
1712
1801
  function escapeCssClassName(value) {
1713
1802
  let result = "";
1714
1803
  for (let index = 0; index < value.length; index++) {
@@ -2370,7 +2459,7 @@ const HTML_ATTRIBUTE_NAME_CANDIDATE_RE = /^(?:class|className|hover-class|hoverC
2370
2459
  const CSS_DIRECTIVE_CANDIDATE_RE = /^@(?:apply|tailwind|source|config|plugin|theme|utility|custom-variant|variant)$/;
2371
2460
  const CSS_APPLY_IMPORTANT = "!important";
2372
2461
  const CSS_APPLY_RE = /@apply\s+([^;{}]+)/g;
2373
- const JS_LIKE_SOURCE_EXTENSION_RE = /^(?:[cm]?[jt]sx?)$/;
2462
+ const JS_LIKE_SOURCE_EXTENSION_RE = /^[cm]?[jt]sx?$/;
2374
2463
  const MIXED_TEMPLATE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue|svelte|mpx)$/;
2375
2464
  const CSS_LIKE_SOURCE_EXTENSION_RE = /^(?:css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|styl|stylus)$/;
2376
2465
  const SFC_SCRIPT_BLOCK_RE = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
@@ -2386,7 +2475,7 @@ function isHtmlAttributeNameCandidate(content, candidate) {
2386
2475
  function isInsideHtmlTagText(content, candidate) {
2387
2476
  if (content.lastIndexOf("<", candidate.start) > content.lastIndexOf(">", candidate.start)) return false;
2388
2477
  const nextOpen = content.indexOf("<", candidate.end);
2389
- return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || content.indexOf(">", candidate.end) === -1);
2478
+ return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || !content.includes(">", candidate.end));
2390
2479
  }
2391
2480
  function isCssDirectiveCandidate(candidate) {
2392
2481
  return candidate === CSS_APPLY_IMPORTANT || CSS_DIRECTIVE_CANDIDATE_RE.test(candidate);
@@ -2473,7 +2562,26 @@ function createLocalCandidate(candidate) {
2473
2562
  end: candidate.localStart + candidate.rawCandidate.length
2474
2563
  };
2475
2564
  }
2476
- async function extractCssApplyCandidates(content, extension) {
2565
+ function dedupeCandidatesWithPositions(candidates) {
2566
+ const seen = /* @__PURE__ */ new Set();
2567
+ return candidates.filter((candidate) => {
2568
+ const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`;
2569
+ if (seen.has(key)) return false;
2570
+ seen.add(key);
2571
+ return true;
2572
+ });
2573
+ }
2574
+ function createBareArbitraryValueCandidateContexts(content, extension, offset, options) {
2575
+ return extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues).map((candidate) => ({
2576
+ content,
2577
+ extension,
2578
+ localStart: candidate.start,
2579
+ rawCandidate: candidate.rawCandidate,
2580
+ start: candidate.start + offset,
2581
+ end: candidate.end + offset
2582
+ }));
2583
+ }
2584
+ async function extractCssApplyCandidates(content, extension, options) {
2477
2585
  const candidates = [];
2478
2586
  CSS_APPLY_RE.lastIndex = 0;
2479
2587
  let match = CSS_APPLY_RE.exec(content);
@@ -2489,11 +2597,12 @@ async function extractCssApplyCandidates(content, extension) {
2489
2597
  start: candidate.start + applyParamsStart,
2490
2598
  end: candidate.end + applyParamsStart
2491
2599
  })));
2600
+ candidates.push(...createBareArbitraryValueCandidateContexts(applyParams, "html", applyParamsStart, options));
2492
2601
  match = CSS_APPLY_RE.exec(content);
2493
2602
  }
2494
2603
  return candidates;
2495
2604
  }
2496
- async function extractMixedSourceScriptCandidates(content) {
2605
+ async function extractMixedSourceScriptCandidates(content, options) {
2497
2606
  const candidates = [];
2498
2607
  SFC_SCRIPT_BLOCK_RE.lastIndex = 0;
2499
2608
  let match = SFC_SCRIPT_BLOCK_RE.exec(content);
@@ -2509,6 +2618,7 @@ async function extractMixedSourceScriptCandidates(content) {
2509
2618
  start: candidate.start + scriptStart,
2510
2619
  end: candidate.end + scriptStart
2511
2620
  })));
2621
+ candidates.push(...createBareArbitraryValueCandidateContexts(scriptContent, "js", scriptStart, options));
2512
2622
  match = SFC_SCRIPT_BLOCK_RE.exec(content);
2513
2623
  }
2514
2624
  return candidates;
@@ -2517,9 +2627,9 @@ function createCandidateCacheKey(designSystemKey, options) {
2517
2627
  if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return designSystemKey;
2518
2628
  return `${designSystemKey}:bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
2519
2629
  }
2520
- async function extractRawCandidatesWithPositions(content, extension = "html") {
2630
+ async function extractRawCandidatesWithPositions(content, extension = "html", options) {
2521
2631
  const { Scanner } = await getOxideModule();
2522
- return new Scanner({}).getCandidatesWithPositions({
2632
+ const candidates = new Scanner({}).getCandidatesWithPositions({
2523
2633
  content,
2524
2634
  extension
2525
2635
  }).map(({ candidate, position }) => ({
@@ -2527,16 +2637,18 @@ async function extractRawCandidatesWithPositions(content, extension = "html") {
2527
2637
  start: position,
2528
2638
  end: position + candidate.length
2529
2639
  }));
2640
+ candidates.push(...extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues));
2641
+ return dedupeCandidatesWithPositions(candidates);
2530
2642
  }
2531
- async function extractSourceCandidatesWithPositions(content, extension = "html") {
2643
+ async function extractSourceCandidatesWithPositions(content, extension = "html", options) {
2532
2644
  const normalizedExtension = extension.replace(/^\./, "");
2533
- const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension) : (await extractRawCandidatesWithPositions(content, normalizedExtension)).map((candidate) => ({
2645
+ const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension, options) : (await extractRawCandidatesWithPositions(content, normalizedExtension, options)).map((candidate) => ({
2534
2646
  ...candidate,
2535
2647
  content,
2536
2648
  extension: normalizedExtension,
2537
2649
  localStart: candidate.start
2538
2650
  }));
2539
- if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content));
2651
+ if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content, options));
2540
2652
  const seen = /* @__PURE__ */ new Set();
2541
2653
  return candidates.filter((candidate) => {
2542
2654
  if (!shouldKeepSourceCandidate(candidate.content, candidate.extension, createLocalCandidate(candidate))) return false;
@@ -2550,13 +2662,22 @@ async function extractSourceCandidatesWithPositions(content, extension = "html")
2550
2662
  end
2551
2663
  }));
2552
2664
  }
2553
- async function extractSourceCandidates(content, extension = "html") {
2554
- const candidates = await extractSourceCandidatesWithPositions(content, extension);
2665
+ async function extractSourceCandidates(content, extension = "html", options) {
2666
+ const candidates = await extractSourceCandidatesWithPositions(content, extension, options);
2555
2667
  return [...new Set(candidates.map((candidate) => candidate.rawCandidate))];
2556
2668
  }
2557
- async function extractRawCandidates(sources) {
2669
+ async function extractRawCandidates(sources, options) {
2558
2670
  const { Scanner } = await getOxideModule();
2559
- return new Scanner(sources === void 0 ? {} : { sources }).scan();
2671
+ const scanner = new Scanner(sources === void 0 ? {} : { sources });
2672
+ const candidates = new Set(scanner.scan());
2673
+ if (options?.bareArbitraryValues !== void 0 && options.bareArbitraryValues !== false) await Promise.all((scanner.files ?? []).map(async (file) => {
2674
+ try {
2675
+ const content = await node_fs.promises.readFile(file, "utf8");
2676
+ const extension = toExtension(file);
2677
+ for (const candidate of extractBareArbitraryValueSourceCandidatesWithPositions(content, options.bareArbitraryValues)) if (shouldKeepSourceCandidate(content, extension, candidate)) candidates.add(candidate.rawCandidate);
2678
+ } catch {}
2679
+ }));
2680
+ return [...candidates];
2560
2681
  }
2561
2682
  async function extractValidCandidates(options) {
2562
2683
  const providedOptions = options ?? {};
@@ -2585,7 +2706,7 @@ async function extractValidCandidates(options) {
2585
2706
  const candidateCacheKey = createCandidateCacheKey(designSystemKey, providedOptions);
2586
2707
  const candidateCache = designSystemCandidateCache.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
2587
2708
  designSystemCandidateCache.set(candidateCacheKey, candidateCache);
2588
- const candidates = await extractRawCandidates(sources);
2709
+ const candidates = await extractRawCandidates(sources, providedOptions.bareArbitraryValues === void 0 ? void 0 : { bareArbitraryValues: providedOptions.bareArbitraryValues });
2589
2710
  const inlineSources = extractTailwindV4InlineSourceCandidates(css);
2590
2711
  for (const candidate of inlineSources.included) candidates.push(candidate);
2591
2712
  for (const candidate of inlineSources.excluded) {
@@ -3813,78 +3934,6 @@ var TailwindcssPatcher = class {
3813
3934
  }
3814
3935
  };
3815
3936
  //#endregion
3816
- //#region src/commands/types.ts
3817
- const tailwindcssPatchCommands = [
3818
- "install",
3819
- "extract",
3820
- "tokens",
3821
- "init",
3822
- "migrate",
3823
- "restore",
3824
- "validate",
3825
- "status"
3826
- ];
3827
- //#endregion
3828
- //#region src/commands/validate.ts
3829
- const VALIDATE_EXIT_CODES = {
3830
- OK: 0,
3831
- REPORT_INCOMPATIBLE: 21,
3832
- MISSING_BACKUPS: 22,
3833
- IO_ERROR: 23,
3834
- UNKNOWN_ERROR: 24
3835
- };
3836
- const VALIDATE_FAILURE_REASONS = [
3837
- "report-incompatible",
3838
- "missing-backups",
3839
- "io-error",
3840
- "unknown-error"
3841
- ];
3842
- const IO_ERROR_CODES = new Set([
3843
- "ENOENT",
3844
- "EACCES",
3845
- "EPERM",
3846
- "EISDIR",
3847
- "ENOTDIR",
3848
- "EMFILE",
3849
- "ENFILE"
3850
- ]);
3851
- function isNodeError(error) {
3852
- return !!error && typeof error === "object" && ("code" in error || "message" in error);
3853
- }
3854
- function classifyValidateError(error) {
3855
- const message = error instanceof Error ? error.message : String(error);
3856
- if (message.startsWith("Unsupported report kind") || message.startsWith("Unsupported report schema version")) return {
3857
- reason: "report-incompatible",
3858
- exitCode: VALIDATE_EXIT_CODES.REPORT_INCOMPATIBLE,
3859
- message
3860
- };
3861
- if (message.startsWith("Restore failed:")) return {
3862
- reason: "missing-backups",
3863
- exitCode: VALIDATE_EXIT_CODES.MISSING_BACKUPS,
3864
- message
3865
- };
3866
- if (isNodeError(error) && typeof error.code === "string" && IO_ERROR_CODES.has(error.code)) return {
3867
- reason: "io-error",
3868
- exitCode: VALIDATE_EXIT_CODES.IO_ERROR,
3869
- message
3870
- };
3871
- return {
3872
- reason: "unknown-error",
3873
- exitCode: VALIDATE_EXIT_CODES.UNKNOWN_ERROR,
3874
- message
3875
- };
3876
- }
3877
- var ValidateCommandError = class extends Error {
3878
- reason;
3879
- exitCode;
3880
- constructor(summary, options) {
3881
- super(summary.message, options);
3882
- this.name = "ValidateCommandError";
3883
- this.reason = summary.reason;
3884
- this.exitCode = summary.exitCode;
3885
- }
3886
- };
3887
- //#endregion
3888
3937
  //#region src/commands/migration-report.ts
3889
3938
  const MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
3890
3939
  const MIGRATION_REPORT_SCHEMA_VERSION = 1;
@@ -4431,6 +4480,78 @@ async function restoreConfigFiles(options) {
4431
4480
  };
4432
4481
  }
4433
4482
  //#endregion
4483
+ //#region src/commands/types.ts
4484
+ const tailwindcssPatchCommands = [
4485
+ "install",
4486
+ "extract",
4487
+ "tokens",
4488
+ "init",
4489
+ "migrate",
4490
+ "restore",
4491
+ "validate",
4492
+ "status"
4493
+ ];
4494
+ //#endregion
4495
+ //#region src/commands/validate.ts
4496
+ const VALIDATE_EXIT_CODES = {
4497
+ OK: 0,
4498
+ REPORT_INCOMPATIBLE: 21,
4499
+ MISSING_BACKUPS: 22,
4500
+ IO_ERROR: 23,
4501
+ UNKNOWN_ERROR: 24
4502
+ };
4503
+ const VALIDATE_FAILURE_REASONS = [
4504
+ "report-incompatible",
4505
+ "missing-backups",
4506
+ "io-error",
4507
+ "unknown-error"
4508
+ ];
4509
+ const IO_ERROR_CODES = new Set([
4510
+ "ENOENT",
4511
+ "EACCES",
4512
+ "EPERM",
4513
+ "EISDIR",
4514
+ "ENOTDIR",
4515
+ "EMFILE",
4516
+ "ENFILE"
4517
+ ]);
4518
+ function isNodeError(error) {
4519
+ return !!error && typeof error === "object" && ("code" in error || "message" in error);
4520
+ }
4521
+ function classifyValidateError(error) {
4522
+ const message = error instanceof Error ? error.message : String(error);
4523
+ if (message.startsWith("Unsupported report kind") || message.startsWith("Unsupported report schema version")) return {
4524
+ reason: "report-incompatible",
4525
+ exitCode: VALIDATE_EXIT_CODES.REPORT_INCOMPATIBLE,
4526
+ message
4527
+ };
4528
+ if (message.startsWith("Restore failed:")) return {
4529
+ reason: "missing-backups",
4530
+ exitCode: VALIDATE_EXIT_CODES.MISSING_BACKUPS,
4531
+ message
4532
+ };
4533
+ if (isNodeError(error) && typeof error.code === "string" && IO_ERROR_CODES.has(error.code)) return {
4534
+ reason: "io-error",
4535
+ exitCode: VALIDATE_EXIT_CODES.IO_ERROR,
4536
+ message
4537
+ };
4538
+ return {
4539
+ reason: "unknown-error",
4540
+ exitCode: VALIDATE_EXIT_CODES.UNKNOWN_ERROR,
4541
+ message
4542
+ };
4543
+ }
4544
+ var ValidateCommandError = class extends Error {
4545
+ reason;
4546
+ exitCode;
4547
+ constructor(summary, options) {
4548
+ super(summary.message, options);
4549
+ this.name = "ValidateCommandError";
4550
+ this.reason = summary.reason;
4551
+ this.exitCode = summary.exitCode;
4552
+ }
4553
+ };
4554
+ //#endregion
4434
4555
  Object.defineProperty(exports, "CacheStore", {
4435
4556
  enumerable: true,
4436
4557
  get: function() {
@@ -4497,6 +4618,12 @@ Object.defineProperty(exports, "ValidateCommandError", {
4497
4618
  return ValidateCommandError;
4498
4619
  }
4499
4620
  });
4621
+ Object.defineProperty(exports, "__toESM", {
4622
+ enumerable: true,
4623
+ get: function() {
4624
+ return __toESM;
4625
+ }
4626
+ });
4500
4627
  Object.defineProperty(exports, "canonicalizeBareArbitraryValueCandidates", {
4501
4628
  enumerable: true,
4502
4629
  get: function() {
@@ -4557,6 +4684,12 @@ Object.defineProperty(exports, "createTailwindV4SourceExclusionMatcher", {
4557
4684
  return createTailwindV4SourceExclusionMatcher;
4558
4685
  }
4559
4686
  });
4687
+ Object.defineProperty(exports, "escapeCssClassName", {
4688
+ enumerable: true,
4689
+ get: function() {
4690
+ return escapeCssClassName;
4691
+ }
4692
+ });
4560
4693
  Object.defineProperty(exports, "expandTailwindV4SourceEntries", {
4561
4694
  enumerable: true,
4562
4695
  get: function() {
@@ -4569,6 +4702,18 @@ Object.defineProperty(exports, "expandTailwindV4SourceEntryBraces", {
4569
4702
  return expandTailwindV4SourceEntryBraces;
4570
4703
  }
4571
4704
  });
4705
+ Object.defineProperty(exports, "extractBareArbitraryValueSourceCandidates", {
4706
+ enumerable: true,
4707
+ get: function() {
4708
+ return extractBareArbitraryValueSourceCandidates;
4709
+ }
4710
+ });
4711
+ Object.defineProperty(exports, "extractBareArbitraryValueSourceCandidatesWithPositions", {
4712
+ enumerable: true,
4713
+ get: function() {
4714
+ return extractBareArbitraryValueSourceCandidatesWithPositions;
4715
+ }
4716
+ });
4572
4717
  Object.defineProperty(exports, "extractProjectCandidatesWithPositions", {
4573
4718
  enumerable: true,
4574
4719
  get: function() {
@@ -4623,6 +4768,12 @@ Object.defineProperty(exports, "groupTokensByFile", {
4623
4768
  return groupTokensByFile;
4624
4769
  }
4625
4770
  });
4771
+ Object.defineProperty(exports, "isBareArbitraryValuesEnabled", {
4772
+ enumerable: true,
4773
+ get: function() {
4774
+ return isBareArbitraryValuesEnabled;
4775
+ }
4776
+ });
4626
4777
  Object.defineProperty(exports, "isFileExcludedByTailwindV4SourceEntries", {
4627
4778
  enumerable: true,
4628
4779
  get: function() {
@@ -4701,6 +4852,12 @@ Object.defineProperty(exports, "replaceBareArbitraryValueSelectors", {
4701
4852
  return replaceBareArbitraryValueSelectors;
4702
4853
  }
4703
4854
  });
4855
+ Object.defineProperty(exports, "resolveBareArbitraryValueCandidate", {
4856
+ enumerable: true,
4857
+ get: function() {
4858
+ return resolveBareArbitraryValueCandidate;
4859
+ }
4860
+ });
4704
4861
  Object.defineProperty(exports, "resolveProjectSourceFiles", {
4705
4862
  enumerable: true,
4706
4863
  get: function() {