tailwindcss-patch 9.4.1 → 9.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-CgBdW1U5.mjs → cli-D5D3Yj69.mjs} +1 -1
- package/dist/{cli-CBVPia5Z.js → cli-DsXcyl2O.js} +59 -59
- package/dist/cli.js +4 -4
- package/dist/cli.mjs +2 -2
- package/dist/commands/cli-runtime.d.mts +1 -1
- package/dist/commands/cli-runtime.d.ts +1 -1
- package/dist/commands/cli-runtime.js +6 -6
- package/dist/commands/cli-runtime.mjs +2 -2
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +67 -59
- package/dist/index.mjs +5 -4
- package/dist/{migrate-config-Dn9OTXpO.js → validate-5eUbRAzl.js} +220 -90
- package/dist/{migrate-config-DqknZpUe.mjs → validate-CInDiiYy.mjs} +191 -91
- package/dist/{validate-CaJv2g5K.d.ts → validate-CYB-90BG.d.ts} +22 -5
- package/dist/{validate-Dr7IkGU8.d.mts → validate-D6MO6lZo.d.mts} +22 -5
- package/package.json +1 -1
- package/src/extraction/candidate-extractor.ts +76 -12
- package/src/public-api.ts +20 -13
- package/src/v4/bare-arbitrary-values.ts +127 -2
- package/src/v4/engine.ts +5 -2
- package/src/v4/index.ts +14 -5
- package/src/v4/node-adapter.ts +1 -1
- package/src/v4/source-scan.ts +1 -1
|
@@ -26,7 +26,7 @@ _babel_traverse = require_chunk.__toESM(_babel_traverse);
|
|
|
26
26
|
let _babel_parser = require("@babel/parser");
|
|
27
27
|
let tailwindcss_config = require("tailwindcss-config");
|
|
28
28
|
//#region package.json
|
|
29
|
-
var version = "9.4.
|
|
29
|
+
var version = "9.4.2";
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/constants.ts
|
|
32
32
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1492,6 +1492,8 @@ const DEFAULT_BARE_ARBITRARY_VALUE_UNITS = [
|
|
|
1492
1492
|
const NUMBER_RE = /^-?(?:\d+|\d*\.\d+)$/;
|
|
1493
1493
|
const FUNCTION_VALUE_RE = /^[a-z_-][\w-]*\(/i;
|
|
1494
1494
|
const HEX_ESCAPE_RE = /^[\da-f]$/i;
|
|
1495
|
+
const ASPECT_RATIO_RE = /^\d+\/\d+$/;
|
|
1496
|
+
const ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
|
|
1495
1497
|
function splitVariantPrefix(candidate) {
|
|
1496
1498
|
let depth = 0;
|
|
1497
1499
|
let quote;
|
|
@@ -1611,6 +1613,9 @@ function normalizeBareArbitraryValueOptions(options) {
|
|
|
1611
1613
|
if (normalizedUnits.length === 0) return;
|
|
1612
1614
|
return { units: normalizedUnits.sort((a, b) => b.length - a.length) };
|
|
1613
1615
|
}
|
|
1616
|
+
function isBareArbitraryValuesEnabled(options) {
|
|
1617
|
+
return normalizeBareArbitraryValueOptions(options) !== void 0;
|
|
1618
|
+
}
|
|
1614
1619
|
function normalizeEscapedValue(value) {
|
|
1615
1620
|
let result = "";
|
|
1616
1621
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -1652,13 +1657,17 @@ function resolveValueWithUnit(body, units) {
|
|
|
1652
1657
|
if (NUMBER_RE.test(numberPart)) return `${numberPart}${unit}`;
|
|
1653
1658
|
}
|
|
1654
1659
|
}
|
|
1655
|
-
function resolveArbitraryValue(body, units) {
|
|
1660
|
+
function resolveArbitraryValue(utility, body, units) {
|
|
1656
1661
|
const value = normalizeEscapedValue(body);
|
|
1657
1662
|
const withUnit = resolveValueWithUnit(value, units);
|
|
1658
1663
|
if (withUnit) return withUnit;
|
|
1664
|
+
if (utility === "aspect" && ASPECT_RATIO_RE.test(value)) return value;
|
|
1659
1665
|
if (isHexColorValue(value)) return value;
|
|
1660
1666
|
if (isQuotedValue(value)) return value;
|
|
1661
|
-
if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value))
|
|
1667
|
+
if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value)) {
|
|
1668
|
+
if (utility === "text" && /^var\(/i.test(value)) return `color:${value}`;
|
|
1669
|
+
return value;
|
|
1670
|
+
}
|
|
1662
1671
|
}
|
|
1663
1672
|
function resolveUtilityAndValue(body, units) {
|
|
1664
1673
|
let depth = 0;
|
|
@@ -1686,7 +1695,7 @@ function resolveUtilityAndValue(body, units) {
|
|
|
1686
1695
|
const utility = body.slice(0, index);
|
|
1687
1696
|
const rawValue = body.slice(index + 1);
|
|
1688
1697
|
if (!utility || !rawValue) continue;
|
|
1689
|
-
const value = resolveArbitraryValue(rawValue, units);
|
|
1698
|
+
const value = resolveArbitraryValue(utility, rawValue, units);
|
|
1690
1699
|
if (value) return {
|
|
1691
1700
|
utility,
|
|
1692
1701
|
value
|
|
@@ -1709,6 +1718,65 @@ function resolveBareArbitraryValueCandidate(candidate, options) {
|
|
|
1709
1718
|
canonicalCandidate: `${prefix}${important}${negative}${resolved.utility}-[${resolved.value}]`
|
|
1710
1719
|
};
|
|
1711
1720
|
}
|
|
1721
|
+
function isBareArbitrarySourceSplitter(char) {
|
|
1722
|
+
return /\s/.test(char);
|
|
1723
|
+
}
|
|
1724
|
+
function isQuoteBoundary(content, start, index) {
|
|
1725
|
+
const tokenPrefix = content.slice(start, index);
|
|
1726
|
+
return tokenPrefix.length === 0 || !tokenPrefix.endsWith("-");
|
|
1727
|
+
}
|
|
1728
|
+
function trimBareArbitrarySourceToken(token, start) {
|
|
1729
|
+
let nextToken = token;
|
|
1730
|
+
let nextStart = start;
|
|
1731
|
+
while (nextToken.length > 0 && /^[<{([]$/.test(nextToken[0])) {
|
|
1732
|
+
nextToken = nextToken.slice(1);
|
|
1733
|
+
nextStart++;
|
|
1734
|
+
}
|
|
1735
|
+
while (nextToken.length > 0 && /^[>\],;]$/.test(nextToken[nextToken.length - 1])) nextToken = nextToken.slice(0, -1);
|
|
1736
|
+
return {
|
|
1737
|
+
token: nextToken,
|
|
1738
|
+
start: nextStart
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
function pushBareArbitrarySourceCandidate(result, token, start, options) {
|
|
1742
|
+
const trimmed = trimBareArbitrarySourceToken(token, start);
|
|
1743
|
+
if (!trimmed.token || trimmed.token.includes("=") || trimmed.token.includes("[") || trimmed.token.includes("]")) return;
|
|
1744
|
+
if (!resolveBareArbitraryValueCandidate(trimmed.token, options)) return;
|
|
1745
|
+
result.push({
|
|
1746
|
+
rawCandidate: trimmed.token,
|
|
1747
|
+
start: trimmed.start,
|
|
1748
|
+
end: trimmed.start + trimmed.token.length
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
function extractBareArbitraryValueSourceCandidatesWithPositions(content, options) {
|
|
1752
|
+
if (!isBareArbitraryValuesEnabled(options)) return [];
|
|
1753
|
+
const normalized = content.includes("\\") ? content.replace(ESCAPED_WHITESPACE_RE, " ") : content;
|
|
1754
|
+
const result = [];
|
|
1755
|
+
let depth = 0;
|
|
1756
|
+
let quote;
|
|
1757
|
+
let start = 0;
|
|
1758
|
+
for (let index = 0; index < normalized.length; index++) {
|
|
1759
|
+
const char = normalized[index];
|
|
1760
|
+
if (char === void 0) continue;
|
|
1761
|
+
if (char === "\\") {
|
|
1762
|
+
index++;
|
|
1763
|
+
continue;
|
|
1764
|
+
}
|
|
1765
|
+
if (quote) {
|
|
1766
|
+
if (char === quote) quote = void 0;
|
|
1767
|
+
} else if ((char === "\"" || char === "'" || char === "`") && !isQuoteBoundary(normalized, start, index)) quote = char;
|
|
1768
|
+
else if (char === "(" || char === "{" || char === "[") depth++;
|
|
1769
|
+
else if (char === ")" || char === "}" || char === "]") depth = Math.max(0, depth - 1);
|
|
1770
|
+
if (!isBareArbitrarySourceSplitter(char) && !((char === "\"" || char === "'" || char === "`") && depth === 0 && isQuoteBoundary(normalized, start, index))) continue;
|
|
1771
|
+
pushBareArbitrarySourceCandidate(result, normalized.slice(start, index), start, options);
|
|
1772
|
+
start = index + 1;
|
|
1773
|
+
}
|
|
1774
|
+
pushBareArbitrarySourceCandidate(result, normalized.slice(start), start, options);
|
|
1775
|
+
return result;
|
|
1776
|
+
}
|
|
1777
|
+
function extractBareArbitraryValueSourceCandidates(content, options) {
|
|
1778
|
+
return [...new Set(extractBareArbitraryValueSourceCandidatesWithPositions(content, options).map((candidate) => candidate.rawCandidate))];
|
|
1779
|
+
}
|
|
1712
1780
|
function escapeCssClassName(value) {
|
|
1713
1781
|
let result = "";
|
|
1714
1782
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -2370,7 +2438,7 @@ const HTML_ATTRIBUTE_NAME_CANDIDATE_RE = /^(?:class|className|hover-class|hoverC
|
|
|
2370
2438
|
const CSS_DIRECTIVE_CANDIDATE_RE = /^@(?:apply|tailwind|source|config|plugin|theme|utility|custom-variant|variant)$/;
|
|
2371
2439
|
const CSS_APPLY_IMPORTANT = "!important";
|
|
2372
2440
|
const CSS_APPLY_RE = /@apply\s+([^;{}]+)/g;
|
|
2373
|
-
const JS_LIKE_SOURCE_EXTENSION_RE = /^
|
|
2441
|
+
const JS_LIKE_SOURCE_EXTENSION_RE = /^[cm]?[jt]sx?$/;
|
|
2374
2442
|
const MIXED_TEMPLATE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue|svelte|mpx)$/;
|
|
2375
2443
|
const CSS_LIKE_SOURCE_EXTENSION_RE = /^(?:css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|styl|stylus)$/;
|
|
2376
2444
|
const SFC_SCRIPT_BLOCK_RE = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
@@ -2386,7 +2454,7 @@ function isHtmlAttributeNameCandidate(content, candidate) {
|
|
|
2386
2454
|
function isInsideHtmlTagText(content, candidate) {
|
|
2387
2455
|
if (content.lastIndexOf("<", candidate.start) > content.lastIndexOf(">", candidate.start)) return false;
|
|
2388
2456
|
const nextOpen = content.indexOf("<", candidate.end);
|
|
2389
|
-
return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || content.
|
|
2457
|
+
return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || !content.includes(">", candidate.end));
|
|
2390
2458
|
}
|
|
2391
2459
|
function isCssDirectiveCandidate(candidate) {
|
|
2392
2460
|
return candidate === CSS_APPLY_IMPORTANT || CSS_DIRECTIVE_CANDIDATE_RE.test(candidate);
|
|
@@ -2473,7 +2541,26 @@ function createLocalCandidate(candidate) {
|
|
|
2473
2541
|
end: candidate.localStart + candidate.rawCandidate.length
|
|
2474
2542
|
};
|
|
2475
2543
|
}
|
|
2476
|
-
|
|
2544
|
+
function dedupeCandidatesWithPositions(candidates) {
|
|
2545
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2546
|
+
return candidates.filter((candidate) => {
|
|
2547
|
+
const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`;
|
|
2548
|
+
if (seen.has(key)) return false;
|
|
2549
|
+
seen.add(key);
|
|
2550
|
+
return true;
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
function createBareArbitraryValueCandidateContexts(content, extension, offset, options) {
|
|
2554
|
+
return extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues).map((candidate) => ({
|
|
2555
|
+
content,
|
|
2556
|
+
extension,
|
|
2557
|
+
localStart: candidate.start,
|
|
2558
|
+
rawCandidate: candidate.rawCandidate,
|
|
2559
|
+
start: candidate.start + offset,
|
|
2560
|
+
end: candidate.end + offset
|
|
2561
|
+
}));
|
|
2562
|
+
}
|
|
2563
|
+
async function extractCssApplyCandidates(content, extension, options) {
|
|
2477
2564
|
const candidates = [];
|
|
2478
2565
|
CSS_APPLY_RE.lastIndex = 0;
|
|
2479
2566
|
let match = CSS_APPLY_RE.exec(content);
|
|
@@ -2489,11 +2576,12 @@ async function extractCssApplyCandidates(content, extension) {
|
|
|
2489
2576
|
start: candidate.start + applyParamsStart,
|
|
2490
2577
|
end: candidate.end + applyParamsStart
|
|
2491
2578
|
})));
|
|
2579
|
+
candidates.push(...createBareArbitraryValueCandidateContexts(applyParams, "html", applyParamsStart, options));
|
|
2492
2580
|
match = CSS_APPLY_RE.exec(content);
|
|
2493
2581
|
}
|
|
2494
2582
|
return candidates;
|
|
2495
2583
|
}
|
|
2496
|
-
async function extractMixedSourceScriptCandidates(content) {
|
|
2584
|
+
async function extractMixedSourceScriptCandidates(content, options) {
|
|
2497
2585
|
const candidates = [];
|
|
2498
2586
|
SFC_SCRIPT_BLOCK_RE.lastIndex = 0;
|
|
2499
2587
|
let match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
@@ -2509,6 +2597,7 @@ async function extractMixedSourceScriptCandidates(content) {
|
|
|
2509
2597
|
start: candidate.start + scriptStart,
|
|
2510
2598
|
end: candidate.end + scriptStart
|
|
2511
2599
|
})));
|
|
2600
|
+
candidates.push(...createBareArbitraryValueCandidateContexts(scriptContent, "js", scriptStart, options));
|
|
2512
2601
|
match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
2513
2602
|
}
|
|
2514
2603
|
return candidates;
|
|
@@ -2517,9 +2606,9 @@ function createCandidateCacheKey(designSystemKey, options) {
|
|
|
2517
2606
|
if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return designSystemKey;
|
|
2518
2607
|
return `${designSystemKey}:bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
|
|
2519
2608
|
}
|
|
2520
|
-
async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
2609
|
+
async function extractRawCandidatesWithPositions(content, extension = "html", options) {
|
|
2521
2610
|
const { Scanner } = await getOxideModule();
|
|
2522
|
-
|
|
2611
|
+
const candidates = new Scanner({}).getCandidatesWithPositions({
|
|
2523
2612
|
content,
|
|
2524
2613
|
extension
|
|
2525
2614
|
}).map(({ candidate, position }) => ({
|
|
@@ -2527,16 +2616,18 @@ async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
|
2527
2616
|
start: position,
|
|
2528
2617
|
end: position + candidate.length
|
|
2529
2618
|
}));
|
|
2619
|
+
candidates.push(...extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues));
|
|
2620
|
+
return dedupeCandidatesWithPositions(candidates);
|
|
2530
2621
|
}
|
|
2531
|
-
async function extractSourceCandidatesWithPositions(content, extension = "html") {
|
|
2622
|
+
async function extractSourceCandidatesWithPositions(content, extension = "html", options) {
|
|
2532
2623
|
const normalizedExtension = extension.replace(/^\./, "");
|
|
2533
|
-
const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension) : (await extractRawCandidatesWithPositions(content, normalizedExtension)).map((candidate) => ({
|
|
2624
|
+
const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension, options) : (await extractRawCandidatesWithPositions(content, normalizedExtension, options)).map((candidate) => ({
|
|
2534
2625
|
...candidate,
|
|
2535
2626
|
content,
|
|
2536
2627
|
extension: normalizedExtension,
|
|
2537
2628
|
localStart: candidate.start
|
|
2538
2629
|
}));
|
|
2539
|
-
if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content));
|
|
2630
|
+
if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content, options));
|
|
2540
2631
|
const seen = /* @__PURE__ */ new Set();
|
|
2541
2632
|
return candidates.filter((candidate) => {
|
|
2542
2633
|
if (!shouldKeepSourceCandidate(candidate.content, candidate.extension, createLocalCandidate(candidate))) return false;
|
|
@@ -2550,13 +2641,22 @@ async function extractSourceCandidatesWithPositions(content, extension = "html")
|
|
|
2550
2641
|
end
|
|
2551
2642
|
}));
|
|
2552
2643
|
}
|
|
2553
|
-
async function extractSourceCandidates(content, extension = "html") {
|
|
2554
|
-
const candidates = await extractSourceCandidatesWithPositions(content, extension);
|
|
2644
|
+
async function extractSourceCandidates(content, extension = "html", options) {
|
|
2645
|
+
const candidates = await extractSourceCandidatesWithPositions(content, extension, options);
|
|
2555
2646
|
return [...new Set(candidates.map((candidate) => candidate.rawCandidate))];
|
|
2556
2647
|
}
|
|
2557
|
-
async function extractRawCandidates(sources) {
|
|
2648
|
+
async function extractRawCandidates(sources, options) {
|
|
2558
2649
|
const { Scanner } = await getOxideModule();
|
|
2559
|
-
|
|
2650
|
+
const scanner = new Scanner(sources === void 0 ? {} : { sources });
|
|
2651
|
+
const candidates = new Set(scanner.scan());
|
|
2652
|
+
if (options?.bareArbitraryValues !== void 0 && options.bareArbitraryValues !== false) await Promise.all((scanner.files ?? []).map(async (file) => {
|
|
2653
|
+
try {
|
|
2654
|
+
const content = await node_fs.promises.readFile(file, "utf8");
|
|
2655
|
+
const extension = toExtension(file);
|
|
2656
|
+
for (const candidate of extractBareArbitraryValueSourceCandidatesWithPositions(content, options.bareArbitraryValues)) if (shouldKeepSourceCandidate(content, extension, candidate)) candidates.add(candidate.rawCandidate);
|
|
2657
|
+
} catch {}
|
|
2658
|
+
}));
|
|
2659
|
+
return [...candidates];
|
|
2560
2660
|
}
|
|
2561
2661
|
async function extractValidCandidates(options) {
|
|
2562
2662
|
const providedOptions = options ?? {};
|
|
@@ -2585,7 +2685,7 @@ async function extractValidCandidates(options) {
|
|
|
2585
2685
|
const candidateCacheKey = createCandidateCacheKey(designSystemKey, providedOptions);
|
|
2586
2686
|
const candidateCache = designSystemCandidateCache.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
|
|
2587
2687
|
designSystemCandidateCache.set(candidateCacheKey, candidateCache);
|
|
2588
|
-
const candidates = await extractRawCandidates(sources);
|
|
2688
|
+
const candidates = await extractRawCandidates(sources, providedOptions.bareArbitraryValues === void 0 ? void 0 : { bareArbitraryValues: providedOptions.bareArbitraryValues });
|
|
2589
2689
|
const inlineSources = extractTailwindV4InlineSourceCandidates(css);
|
|
2590
2690
|
for (const candidate of inlineSources.included) candidates.push(candidate);
|
|
2591
2691
|
for (const candidate of inlineSources.excluded) {
|
|
@@ -3813,78 +3913,6 @@ var TailwindcssPatcher = class {
|
|
|
3813
3913
|
}
|
|
3814
3914
|
};
|
|
3815
3915
|
//#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
3916
|
//#region src/commands/migration-report.ts
|
|
3889
3917
|
const MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
|
|
3890
3918
|
const MIGRATION_REPORT_SCHEMA_VERSION = 1;
|
|
@@ -4431,6 +4459,78 @@ async function restoreConfigFiles(options) {
|
|
|
4431
4459
|
};
|
|
4432
4460
|
}
|
|
4433
4461
|
//#endregion
|
|
4462
|
+
//#region src/commands/types.ts
|
|
4463
|
+
const tailwindcssPatchCommands = [
|
|
4464
|
+
"install",
|
|
4465
|
+
"extract",
|
|
4466
|
+
"tokens",
|
|
4467
|
+
"init",
|
|
4468
|
+
"migrate",
|
|
4469
|
+
"restore",
|
|
4470
|
+
"validate",
|
|
4471
|
+
"status"
|
|
4472
|
+
];
|
|
4473
|
+
//#endregion
|
|
4474
|
+
//#region src/commands/validate.ts
|
|
4475
|
+
const VALIDATE_EXIT_CODES = {
|
|
4476
|
+
OK: 0,
|
|
4477
|
+
REPORT_INCOMPATIBLE: 21,
|
|
4478
|
+
MISSING_BACKUPS: 22,
|
|
4479
|
+
IO_ERROR: 23,
|
|
4480
|
+
UNKNOWN_ERROR: 24
|
|
4481
|
+
};
|
|
4482
|
+
const VALIDATE_FAILURE_REASONS = [
|
|
4483
|
+
"report-incompatible",
|
|
4484
|
+
"missing-backups",
|
|
4485
|
+
"io-error",
|
|
4486
|
+
"unknown-error"
|
|
4487
|
+
];
|
|
4488
|
+
const IO_ERROR_CODES = new Set([
|
|
4489
|
+
"ENOENT",
|
|
4490
|
+
"EACCES",
|
|
4491
|
+
"EPERM",
|
|
4492
|
+
"EISDIR",
|
|
4493
|
+
"ENOTDIR",
|
|
4494
|
+
"EMFILE",
|
|
4495
|
+
"ENFILE"
|
|
4496
|
+
]);
|
|
4497
|
+
function isNodeError(error) {
|
|
4498
|
+
return !!error && typeof error === "object" && ("code" in error || "message" in error);
|
|
4499
|
+
}
|
|
4500
|
+
function classifyValidateError(error) {
|
|
4501
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4502
|
+
if (message.startsWith("Unsupported report kind") || message.startsWith("Unsupported report schema version")) return {
|
|
4503
|
+
reason: "report-incompatible",
|
|
4504
|
+
exitCode: VALIDATE_EXIT_CODES.REPORT_INCOMPATIBLE,
|
|
4505
|
+
message
|
|
4506
|
+
};
|
|
4507
|
+
if (message.startsWith("Restore failed:")) return {
|
|
4508
|
+
reason: "missing-backups",
|
|
4509
|
+
exitCode: VALIDATE_EXIT_CODES.MISSING_BACKUPS,
|
|
4510
|
+
message
|
|
4511
|
+
};
|
|
4512
|
+
if (isNodeError(error) && typeof error.code === "string" && IO_ERROR_CODES.has(error.code)) return {
|
|
4513
|
+
reason: "io-error",
|
|
4514
|
+
exitCode: VALIDATE_EXIT_CODES.IO_ERROR,
|
|
4515
|
+
message
|
|
4516
|
+
};
|
|
4517
|
+
return {
|
|
4518
|
+
reason: "unknown-error",
|
|
4519
|
+
exitCode: VALIDATE_EXIT_CODES.UNKNOWN_ERROR,
|
|
4520
|
+
message
|
|
4521
|
+
};
|
|
4522
|
+
}
|
|
4523
|
+
var ValidateCommandError = class extends Error {
|
|
4524
|
+
reason;
|
|
4525
|
+
exitCode;
|
|
4526
|
+
constructor(summary, options) {
|
|
4527
|
+
super(summary.message, options);
|
|
4528
|
+
this.name = "ValidateCommandError";
|
|
4529
|
+
this.reason = summary.reason;
|
|
4530
|
+
this.exitCode = summary.exitCode;
|
|
4531
|
+
}
|
|
4532
|
+
};
|
|
4533
|
+
//#endregion
|
|
4434
4534
|
Object.defineProperty(exports, "CacheStore", {
|
|
4435
4535
|
enumerable: true,
|
|
4436
4536
|
get: function() {
|
|
@@ -4557,6 +4657,12 @@ Object.defineProperty(exports, "createTailwindV4SourceExclusionMatcher", {
|
|
|
4557
4657
|
return createTailwindV4SourceExclusionMatcher;
|
|
4558
4658
|
}
|
|
4559
4659
|
});
|
|
4660
|
+
Object.defineProperty(exports, "escapeCssClassName", {
|
|
4661
|
+
enumerable: true,
|
|
4662
|
+
get: function() {
|
|
4663
|
+
return escapeCssClassName;
|
|
4664
|
+
}
|
|
4665
|
+
});
|
|
4560
4666
|
Object.defineProperty(exports, "expandTailwindV4SourceEntries", {
|
|
4561
4667
|
enumerable: true,
|
|
4562
4668
|
get: function() {
|
|
@@ -4569,6 +4675,18 @@ Object.defineProperty(exports, "expandTailwindV4SourceEntryBraces", {
|
|
|
4569
4675
|
return expandTailwindV4SourceEntryBraces;
|
|
4570
4676
|
}
|
|
4571
4677
|
});
|
|
4678
|
+
Object.defineProperty(exports, "extractBareArbitraryValueSourceCandidates", {
|
|
4679
|
+
enumerable: true,
|
|
4680
|
+
get: function() {
|
|
4681
|
+
return extractBareArbitraryValueSourceCandidates;
|
|
4682
|
+
}
|
|
4683
|
+
});
|
|
4684
|
+
Object.defineProperty(exports, "extractBareArbitraryValueSourceCandidatesWithPositions", {
|
|
4685
|
+
enumerable: true,
|
|
4686
|
+
get: function() {
|
|
4687
|
+
return extractBareArbitraryValueSourceCandidatesWithPositions;
|
|
4688
|
+
}
|
|
4689
|
+
});
|
|
4572
4690
|
Object.defineProperty(exports, "extractProjectCandidatesWithPositions", {
|
|
4573
4691
|
enumerable: true,
|
|
4574
4692
|
get: function() {
|
|
@@ -4623,6 +4741,12 @@ Object.defineProperty(exports, "groupTokensByFile", {
|
|
|
4623
4741
|
return groupTokensByFile;
|
|
4624
4742
|
}
|
|
4625
4743
|
});
|
|
4744
|
+
Object.defineProperty(exports, "isBareArbitraryValuesEnabled", {
|
|
4745
|
+
enumerable: true,
|
|
4746
|
+
get: function() {
|
|
4747
|
+
return isBareArbitraryValuesEnabled;
|
|
4748
|
+
}
|
|
4749
|
+
});
|
|
4626
4750
|
Object.defineProperty(exports, "isFileExcludedByTailwindV4SourceEntries", {
|
|
4627
4751
|
enumerable: true,
|
|
4628
4752
|
get: function() {
|
|
@@ -4701,6 +4825,12 @@ Object.defineProperty(exports, "replaceBareArbitraryValueSelectors", {
|
|
|
4701
4825
|
return replaceBareArbitraryValueSelectors;
|
|
4702
4826
|
}
|
|
4703
4827
|
});
|
|
4828
|
+
Object.defineProperty(exports, "resolveBareArbitraryValueCandidate", {
|
|
4829
|
+
enumerable: true,
|
|
4830
|
+
get: function() {
|
|
4831
|
+
return resolveBareArbitraryValueCandidate;
|
|
4832
|
+
}
|
|
4833
|
+
});
|
|
4704
4834
|
Object.defineProperty(exports, "resolveProjectSourceFiles", {
|
|
4705
4835
|
enumerable: true,
|
|
4706
4836
|
get: function() {
|