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
|
@@ -18,7 +18,7 @@ import _babelTraverse from "@babel/traverse";
|
|
|
18
18
|
import { parse, parse as parse$1 } from "@babel/parser";
|
|
19
19
|
import { loadConfig } from "tailwindcss-config";
|
|
20
20
|
//#region package.json
|
|
21
|
-
var version = "9.4.
|
|
21
|
+
var version = "9.4.2";
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/constants.ts
|
|
24
24
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1489,6 +1489,8 @@ const DEFAULT_BARE_ARBITRARY_VALUE_UNITS = [
|
|
|
1489
1489
|
const NUMBER_RE = /^-?(?:\d+|\d*\.\d+)$/;
|
|
1490
1490
|
const FUNCTION_VALUE_RE = /^[a-z_-][\w-]*\(/i;
|
|
1491
1491
|
const HEX_ESCAPE_RE = /^[\da-f]$/i;
|
|
1492
|
+
const ASPECT_RATIO_RE = /^\d+\/\d+$/;
|
|
1493
|
+
const ESCAPED_WHITESPACE_RE = /\\[nrt]/g;
|
|
1492
1494
|
function splitVariantPrefix(candidate) {
|
|
1493
1495
|
let depth = 0;
|
|
1494
1496
|
let quote;
|
|
@@ -1608,6 +1610,9 @@ function normalizeBareArbitraryValueOptions(options) {
|
|
|
1608
1610
|
if (normalizedUnits.length === 0) return;
|
|
1609
1611
|
return { units: normalizedUnits.sort((a, b) => b.length - a.length) };
|
|
1610
1612
|
}
|
|
1613
|
+
function isBareArbitraryValuesEnabled(options) {
|
|
1614
|
+
return normalizeBareArbitraryValueOptions(options) !== void 0;
|
|
1615
|
+
}
|
|
1611
1616
|
function normalizeEscapedValue(value) {
|
|
1612
1617
|
let result = "";
|
|
1613
1618
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -1649,13 +1654,17 @@ function resolveValueWithUnit(body, units) {
|
|
|
1649
1654
|
if (NUMBER_RE.test(numberPart)) return `${numberPart}${unit}`;
|
|
1650
1655
|
}
|
|
1651
1656
|
}
|
|
1652
|
-
function resolveArbitraryValue(body, units) {
|
|
1657
|
+
function resolveArbitraryValue(utility, body, units) {
|
|
1653
1658
|
const value = normalizeEscapedValue(body);
|
|
1654
1659
|
const withUnit = resolveValueWithUnit(value, units);
|
|
1655
1660
|
if (withUnit) return withUnit;
|
|
1661
|
+
if (utility === "aspect" && ASPECT_RATIO_RE.test(value)) return value;
|
|
1656
1662
|
if (isHexColorValue(value)) return value;
|
|
1657
1663
|
if (isQuotedValue(value)) return value;
|
|
1658
|
-
if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value))
|
|
1664
|
+
if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value)) {
|
|
1665
|
+
if (utility === "text" && /^var\(/i.test(value)) return `color:${value}`;
|
|
1666
|
+
return value;
|
|
1667
|
+
}
|
|
1659
1668
|
}
|
|
1660
1669
|
function resolveUtilityAndValue(body, units) {
|
|
1661
1670
|
let depth = 0;
|
|
@@ -1683,7 +1692,7 @@ function resolveUtilityAndValue(body, units) {
|
|
|
1683
1692
|
const utility = body.slice(0, index);
|
|
1684
1693
|
const rawValue = body.slice(index + 1);
|
|
1685
1694
|
if (!utility || !rawValue) continue;
|
|
1686
|
-
const value = resolveArbitraryValue(rawValue, units);
|
|
1695
|
+
const value = resolveArbitraryValue(utility, rawValue, units);
|
|
1687
1696
|
if (value) return {
|
|
1688
1697
|
utility,
|
|
1689
1698
|
value
|
|
@@ -1706,6 +1715,65 @@ function resolveBareArbitraryValueCandidate(candidate, options) {
|
|
|
1706
1715
|
canonicalCandidate: `${prefix}${important}${negative}${resolved.utility}-[${resolved.value}]`
|
|
1707
1716
|
};
|
|
1708
1717
|
}
|
|
1718
|
+
function isBareArbitrarySourceSplitter(char) {
|
|
1719
|
+
return /\s/.test(char);
|
|
1720
|
+
}
|
|
1721
|
+
function isQuoteBoundary(content, start, index) {
|
|
1722
|
+
const tokenPrefix = content.slice(start, index);
|
|
1723
|
+
return tokenPrefix.length === 0 || !tokenPrefix.endsWith("-");
|
|
1724
|
+
}
|
|
1725
|
+
function trimBareArbitrarySourceToken(token, start) {
|
|
1726
|
+
let nextToken = token;
|
|
1727
|
+
let nextStart = start;
|
|
1728
|
+
while (nextToken.length > 0 && /^[<{([]$/.test(nextToken[0])) {
|
|
1729
|
+
nextToken = nextToken.slice(1);
|
|
1730
|
+
nextStart++;
|
|
1731
|
+
}
|
|
1732
|
+
while (nextToken.length > 0 && /^[>\],;]$/.test(nextToken[nextToken.length - 1])) nextToken = nextToken.slice(0, -1);
|
|
1733
|
+
return {
|
|
1734
|
+
token: nextToken,
|
|
1735
|
+
start: nextStart
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
function pushBareArbitrarySourceCandidate(result, token, start, options) {
|
|
1739
|
+
const trimmed = trimBareArbitrarySourceToken(token, start);
|
|
1740
|
+
if (!trimmed.token || trimmed.token.includes("=") || trimmed.token.includes("[") || trimmed.token.includes("]")) return;
|
|
1741
|
+
if (!resolveBareArbitraryValueCandidate(trimmed.token, options)) return;
|
|
1742
|
+
result.push({
|
|
1743
|
+
rawCandidate: trimmed.token,
|
|
1744
|
+
start: trimmed.start,
|
|
1745
|
+
end: trimmed.start + trimmed.token.length
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
function extractBareArbitraryValueSourceCandidatesWithPositions(content, options) {
|
|
1749
|
+
if (!isBareArbitraryValuesEnabled(options)) return [];
|
|
1750
|
+
const normalized = content.includes("\\") ? content.replace(ESCAPED_WHITESPACE_RE, " ") : content;
|
|
1751
|
+
const result = [];
|
|
1752
|
+
let depth = 0;
|
|
1753
|
+
let quote;
|
|
1754
|
+
let start = 0;
|
|
1755
|
+
for (let index = 0; index < normalized.length; index++) {
|
|
1756
|
+
const char = normalized[index];
|
|
1757
|
+
if (char === void 0) continue;
|
|
1758
|
+
if (char === "\\") {
|
|
1759
|
+
index++;
|
|
1760
|
+
continue;
|
|
1761
|
+
}
|
|
1762
|
+
if (quote) {
|
|
1763
|
+
if (char === quote) quote = void 0;
|
|
1764
|
+
} else if ((char === "\"" || char === "'" || char === "`") && !isQuoteBoundary(normalized, start, index)) quote = char;
|
|
1765
|
+
else if (char === "(" || char === "{" || char === "[") depth++;
|
|
1766
|
+
else if (char === ")" || char === "}" || char === "]") depth = Math.max(0, depth - 1);
|
|
1767
|
+
if (!isBareArbitrarySourceSplitter(char) && !((char === "\"" || char === "'" || char === "`") && depth === 0 && isQuoteBoundary(normalized, start, index))) continue;
|
|
1768
|
+
pushBareArbitrarySourceCandidate(result, normalized.slice(start, index), start, options);
|
|
1769
|
+
start = index + 1;
|
|
1770
|
+
}
|
|
1771
|
+
pushBareArbitrarySourceCandidate(result, normalized.slice(start), start, options);
|
|
1772
|
+
return result;
|
|
1773
|
+
}
|
|
1774
|
+
function extractBareArbitraryValueSourceCandidates(content, options) {
|
|
1775
|
+
return [...new Set(extractBareArbitraryValueSourceCandidatesWithPositions(content, options).map((candidate) => candidate.rawCandidate))];
|
|
1776
|
+
}
|
|
1709
1777
|
function escapeCssClassName(value) {
|
|
1710
1778
|
let result = "";
|
|
1711
1779
|
for (let index = 0; index < value.length; index++) {
|
|
@@ -2367,7 +2435,7 @@ const HTML_ATTRIBUTE_NAME_CANDIDATE_RE = /^(?:class|className|hover-class|hoverC
|
|
|
2367
2435
|
const CSS_DIRECTIVE_CANDIDATE_RE = /^@(?:apply|tailwind|source|config|plugin|theme|utility|custom-variant|variant)$/;
|
|
2368
2436
|
const CSS_APPLY_IMPORTANT = "!important";
|
|
2369
2437
|
const CSS_APPLY_RE = /@apply\s+([^;{}]+)/g;
|
|
2370
|
-
const JS_LIKE_SOURCE_EXTENSION_RE = /^
|
|
2438
|
+
const JS_LIKE_SOURCE_EXTENSION_RE = /^[cm]?[jt]sx?$/;
|
|
2371
2439
|
const MIXED_TEMPLATE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue|svelte|mpx)$/;
|
|
2372
2440
|
const CSS_LIKE_SOURCE_EXTENSION_RE = /^(?:css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|styl|stylus)$/;
|
|
2373
2441
|
const SFC_SCRIPT_BLOCK_RE = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
@@ -2383,7 +2451,7 @@ function isHtmlAttributeNameCandidate(content, candidate) {
|
|
|
2383
2451
|
function isInsideHtmlTagText(content, candidate) {
|
|
2384
2452
|
if (content.lastIndexOf("<", candidate.start) > content.lastIndexOf(">", candidate.start)) return false;
|
|
2385
2453
|
const nextOpen = content.indexOf("<", candidate.end);
|
|
2386
|
-
return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || content.
|
|
2454
|
+
return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || !content.includes(">", candidate.end));
|
|
2387
2455
|
}
|
|
2388
2456
|
function isCssDirectiveCandidate(candidate) {
|
|
2389
2457
|
return candidate === CSS_APPLY_IMPORTANT || CSS_DIRECTIVE_CANDIDATE_RE.test(candidate);
|
|
@@ -2470,7 +2538,26 @@ function createLocalCandidate(candidate) {
|
|
|
2470
2538
|
end: candidate.localStart + candidate.rawCandidate.length
|
|
2471
2539
|
};
|
|
2472
2540
|
}
|
|
2473
|
-
|
|
2541
|
+
function dedupeCandidatesWithPositions(candidates) {
|
|
2542
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2543
|
+
return candidates.filter((candidate) => {
|
|
2544
|
+
const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`;
|
|
2545
|
+
if (seen.has(key)) return false;
|
|
2546
|
+
seen.add(key);
|
|
2547
|
+
return true;
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
function createBareArbitraryValueCandidateContexts(content, extension, offset, options) {
|
|
2551
|
+
return extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues).map((candidate) => ({
|
|
2552
|
+
content,
|
|
2553
|
+
extension,
|
|
2554
|
+
localStart: candidate.start,
|
|
2555
|
+
rawCandidate: candidate.rawCandidate,
|
|
2556
|
+
start: candidate.start + offset,
|
|
2557
|
+
end: candidate.end + offset
|
|
2558
|
+
}));
|
|
2559
|
+
}
|
|
2560
|
+
async function extractCssApplyCandidates(content, extension, options) {
|
|
2474
2561
|
const candidates = [];
|
|
2475
2562
|
CSS_APPLY_RE.lastIndex = 0;
|
|
2476
2563
|
let match = CSS_APPLY_RE.exec(content);
|
|
@@ -2486,11 +2573,12 @@ async function extractCssApplyCandidates(content, extension) {
|
|
|
2486
2573
|
start: candidate.start + applyParamsStart,
|
|
2487
2574
|
end: candidate.end + applyParamsStart
|
|
2488
2575
|
})));
|
|
2576
|
+
candidates.push(...createBareArbitraryValueCandidateContexts(applyParams, "html", applyParamsStart, options));
|
|
2489
2577
|
match = CSS_APPLY_RE.exec(content);
|
|
2490
2578
|
}
|
|
2491
2579
|
return candidates;
|
|
2492
2580
|
}
|
|
2493
|
-
async function extractMixedSourceScriptCandidates(content) {
|
|
2581
|
+
async function extractMixedSourceScriptCandidates(content, options) {
|
|
2494
2582
|
const candidates = [];
|
|
2495
2583
|
SFC_SCRIPT_BLOCK_RE.lastIndex = 0;
|
|
2496
2584
|
let match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
@@ -2506,6 +2594,7 @@ async function extractMixedSourceScriptCandidates(content) {
|
|
|
2506
2594
|
start: candidate.start + scriptStart,
|
|
2507
2595
|
end: candidate.end + scriptStart
|
|
2508
2596
|
})));
|
|
2597
|
+
candidates.push(...createBareArbitraryValueCandidateContexts(scriptContent, "js", scriptStart, options));
|
|
2509
2598
|
match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
2510
2599
|
}
|
|
2511
2600
|
return candidates;
|
|
@@ -2514,9 +2603,9 @@ function createCandidateCacheKey(designSystemKey, options) {
|
|
|
2514
2603
|
if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return designSystemKey;
|
|
2515
2604
|
return `${designSystemKey}:bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
|
|
2516
2605
|
}
|
|
2517
|
-
async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
2606
|
+
async function extractRawCandidatesWithPositions(content, extension = "html", options) {
|
|
2518
2607
|
const { Scanner } = await getOxideModule();
|
|
2519
|
-
|
|
2608
|
+
const candidates = new Scanner({}).getCandidatesWithPositions({
|
|
2520
2609
|
content,
|
|
2521
2610
|
extension
|
|
2522
2611
|
}).map(({ candidate, position }) => ({
|
|
@@ -2524,16 +2613,18 @@ async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
|
2524
2613
|
start: position,
|
|
2525
2614
|
end: position + candidate.length
|
|
2526
2615
|
}));
|
|
2616
|
+
candidates.push(...extractBareArbitraryValueSourceCandidatesWithPositions(content, options?.bareArbitraryValues));
|
|
2617
|
+
return dedupeCandidatesWithPositions(candidates);
|
|
2527
2618
|
}
|
|
2528
|
-
async function extractSourceCandidatesWithPositions(content, extension = "html") {
|
|
2619
|
+
async function extractSourceCandidatesWithPositions(content, extension = "html", options) {
|
|
2529
2620
|
const normalizedExtension = extension.replace(/^\./, "");
|
|
2530
|
-
const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension) : (await extractRawCandidatesWithPositions(content, normalizedExtension)).map((candidate) => ({
|
|
2621
|
+
const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension, options) : (await extractRawCandidatesWithPositions(content, normalizedExtension, options)).map((candidate) => ({
|
|
2531
2622
|
...candidate,
|
|
2532
2623
|
content,
|
|
2533
2624
|
extension: normalizedExtension,
|
|
2534
2625
|
localStart: candidate.start
|
|
2535
2626
|
}));
|
|
2536
|
-
if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content));
|
|
2627
|
+
if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content, options));
|
|
2537
2628
|
const seen = /* @__PURE__ */ new Set();
|
|
2538
2629
|
return candidates.filter((candidate) => {
|
|
2539
2630
|
if (!shouldKeepSourceCandidate(candidate.content, candidate.extension, createLocalCandidate(candidate))) return false;
|
|
@@ -2547,13 +2638,22 @@ async function extractSourceCandidatesWithPositions(content, extension = "html")
|
|
|
2547
2638
|
end
|
|
2548
2639
|
}));
|
|
2549
2640
|
}
|
|
2550
|
-
async function extractSourceCandidates(content, extension = "html") {
|
|
2551
|
-
const candidates = await extractSourceCandidatesWithPositions(content, extension);
|
|
2641
|
+
async function extractSourceCandidates(content, extension = "html", options) {
|
|
2642
|
+
const candidates = await extractSourceCandidatesWithPositions(content, extension, options);
|
|
2552
2643
|
return [...new Set(candidates.map((candidate) => candidate.rawCandidate))];
|
|
2553
2644
|
}
|
|
2554
|
-
async function extractRawCandidates(sources) {
|
|
2645
|
+
async function extractRawCandidates(sources, options) {
|
|
2555
2646
|
const { Scanner } = await getOxideModule();
|
|
2556
|
-
|
|
2647
|
+
const scanner = new Scanner(sources === void 0 ? {} : { sources });
|
|
2648
|
+
const candidates = new Set(scanner.scan());
|
|
2649
|
+
if (options?.bareArbitraryValues !== void 0 && options.bareArbitraryValues !== false) await Promise.all((scanner.files ?? []).map(async (file) => {
|
|
2650
|
+
try {
|
|
2651
|
+
const content = await promises.readFile(file, "utf8");
|
|
2652
|
+
const extension = toExtension(file);
|
|
2653
|
+
for (const candidate of extractBareArbitraryValueSourceCandidatesWithPositions(content, options.bareArbitraryValues)) if (shouldKeepSourceCandidate(content, extension, candidate)) candidates.add(candidate.rawCandidate);
|
|
2654
|
+
} catch {}
|
|
2655
|
+
}));
|
|
2656
|
+
return [...candidates];
|
|
2557
2657
|
}
|
|
2558
2658
|
async function extractValidCandidates(options) {
|
|
2559
2659
|
const providedOptions = options ?? {};
|
|
@@ -2582,7 +2682,7 @@ async function extractValidCandidates(options) {
|
|
|
2582
2682
|
const candidateCacheKey = createCandidateCacheKey(designSystemKey, providedOptions);
|
|
2583
2683
|
const candidateCache = designSystemCandidateCache.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
|
|
2584
2684
|
designSystemCandidateCache.set(candidateCacheKey, candidateCache);
|
|
2585
|
-
const candidates = await extractRawCandidates(sources);
|
|
2685
|
+
const candidates = await extractRawCandidates(sources, providedOptions.bareArbitraryValues === void 0 ? void 0 : { bareArbitraryValues: providedOptions.bareArbitraryValues });
|
|
2586
2686
|
const inlineSources = extractTailwindV4InlineSourceCandidates(css);
|
|
2587
2687
|
for (const candidate of inlineSources.included) candidates.push(candidate);
|
|
2588
2688
|
for (const candidate of inlineSources.excluded) {
|
|
@@ -3810,78 +3910,6 @@ var TailwindcssPatcher = class {
|
|
|
3810
3910
|
}
|
|
3811
3911
|
};
|
|
3812
3912
|
//#endregion
|
|
3813
|
-
//#region src/commands/types.ts
|
|
3814
|
-
const tailwindcssPatchCommands = [
|
|
3815
|
-
"install",
|
|
3816
|
-
"extract",
|
|
3817
|
-
"tokens",
|
|
3818
|
-
"init",
|
|
3819
|
-
"migrate",
|
|
3820
|
-
"restore",
|
|
3821
|
-
"validate",
|
|
3822
|
-
"status"
|
|
3823
|
-
];
|
|
3824
|
-
//#endregion
|
|
3825
|
-
//#region src/commands/validate.ts
|
|
3826
|
-
const VALIDATE_EXIT_CODES = {
|
|
3827
|
-
OK: 0,
|
|
3828
|
-
REPORT_INCOMPATIBLE: 21,
|
|
3829
|
-
MISSING_BACKUPS: 22,
|
|
3830
|
-
IO_ERROR: 23,
|
|
3831
|
-
UNKNOWN_ERROR: 24
|
|
3832
|
-
};
|
|
3833
|
-
const VALIDATE_FAILURE_REASONS = [
|
|
3834
|
-
"report-incompatible",
|
|
3835
|
-
"missing-backups",
|
|
3836
|
-
"io-error",
|
|
3837
|
-
"unknown-error"
|
|
3838
|
-
];
|
|
3839
|
-
const IO_ERROR_CODES = new Set([
|
|
3840
|
-
"ENOENT",
|
|
3841
|
-
"EACCES",
|
|
3842
|
-
"EPERM",
|
|
3843
|
-
"EISDIR",
|
|
3844
|
-
"ENOTDIR",
|
|
3845
|
-
"EMFILE",
|
|
3846
|
-
"ENFILE"
|
|
3847
|
-
]);
|
|
3848
|
-
function isNodeError(error) {
|
|
3849
|
-
return !!error && typeof error === "object" && ("code" in error || "message" in error);
|
|
3850
|
-
}
|
|
3851
|
-
function classifyValidateError(error) {
|
|
3852
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3853
|
-
if (message.startsWith("Unsupported report kind") || message.startsWith("Unsupported report schema version")) return {
|
|
3854
|
-
reason: "report-incompatible",
|
|
3855
|
-
exitCode: VALIDATE_EXIT_CODES.REPORT_INCOMPATIBLE,
|
|
3856
|
-
message
|
|
3857
|
-
};
|
|
3858
|
-
if (message.startsWith("Restore failed:")) return {
|
|
3859
|
-
reason: "missing-backups",
|
|
3860
|
-
exitCode: VALIDATE_EXIT_CODES.MISSING_BACKUPS,
|
|
3861
|
-
message
|
|
3862
|
-
};
|
|
3863
|
-
if (isNodeError(error) && typeof error.code === "string" && IO_ERROR_CODES.has(error.code)) return {
|
|
3864
|
-
reason: "io-error",
|
|
3865
|
-
exitCode: VALIDATE_EXIT_CODES.IO_ERROR,
|
|
3866
|
-
message
|
|
3867
|
-
};
|
|
3868
|
-
return {
|
|
3869
|
-
reason: "unknown-error",
|
|
3870
|
-
exitCode: VALIDATE_EXIT_CODES.UNKNOWN_ERROR,
|
|
3871
|
-
message
|
|
3872
|
-
};
|
|
3873
|
-
}
|
|
3874
|
-
var ValidateCommandError = class extends Error {
|
|
3875
|
-
reason;
|
|
3876
|
-
exitCode;
|
|
3877
|
-
constructor(summary, options) {
|
|
3878
|
-
super(summary.message, options);
|
|
3879
|
-
this.name = "ValidateCommandError";
|
|
3880
|
-
this.reason = summary.reason;
|
|
3881
|
-
this.exitCode = summary.exitCode;
|
|
3882
|
-
}
|
|
3883
|
-
};
|
|
3884
|
-
//#endregion
|
|
3885
3913
|
//#region src/commands/migration-report.ts
|
|
3886
3914
|
const MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
|
|
3887
3915
|
const MIGRATION_REPORT_SCHEMA_VERSION = 1;
|
|
@@ -4428,4 +4456,76 @@ async function restoreConfigFiles(options) {
|
|
|
4428
4456
|
};
|
|
4429
4457
|
}
|
|
4430
4458
|
//#endregion
|
|
4431
|
-
|
|
4459
|
+
//#region src/commands/types.ts
|
|
4460
|
+
const tailwindcssPatchCommands = [
|
|
4461
|
+
"install",
|
|
4462
|
+
"extract",
|
|
4463
|
+
"tokens",
|
|
4464
|
+
"init",
|
|
4465
|
+
"migrate",
|
|
4466
|
+
"restore",
|
|
4467
|
+
"validate",
|
|
4468
|
+
"status"
|
|
4469
|
+
];
|
|
4470
|
+
//#endregion
|
|
4471
|
+
//#region src/commands/validate.ts
|
|
4472
|
+
const VALIDATE_EXIT_CODES = {
|
|
4473
|
+
OK: 0,
|
|
4474
|
+
REPORT_INCOMPATIBLE: 21,
|
|
4475
|
+
MISSING_BACKUPS: 22,
|
|
4476
|
+
IO_ERROR: 23,
|
|
4477
|
+
UNKNOWN_ERROR: 24
|
|
4478
|
+
};
|
|
4479
|
+
const VALIDATE_FAILURE_REASONS = [
|
|
4480
|
+
"report-incompatible",
|
|
4481
|
+
"missing-backups",
|
|
4482
|
+
"io-error",
|
|
4483
|
+
"unknown-error"
|
|
4484
|
+
];
|
|
4485
|
+
const IO_ERROR_CODES = new Set([
|
|
4486
|
+
"ENOENT",
|
|
4487
|
+
"EACCES",
|
|
4488
|
+
"EPERM",
|
|
4489
|
+
"EISDIR",
|
|
4490
|
+
"ENOTDIR",
|
|
4491
|
+
"EMFILE",
|
|
4492
|
+
"ENFILE"
|
|
4493
|
+
]);
|
|
4494
|
+
function isNodeError(error) {
|
|
4495
|
+
return !!error && typeof error === "object" && ("code" in error || "message" in error);
|
|
4496
|
+
}
|
|
4497
|
+
function classifyValidateError(error) {
|
|
4498
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4499
|
+
if (message.startsWith("Unsupported report kind") || message.startsWith("Unsupported report schema version")) return {
|
|
4500
|
+
reason: "report-incompatible",
|
|
4501
|
+
exitCode: VALIDATE_EXIT_CODES.REPORT_INCOMPATIBLE,
|
|
4502
|
+
message
|
|
4503
|
+
};
|
|
4504
|
+
if (message.startsWith("Restore failed:")) return {
|
|
4505
|
+
reason: "missing-backups",
|
|
4506
|
+
exitCode: VALIDATE_EXIT_CODES.MISSING_BACKUPS,
|
|
4507
|
+
message
|
|
4508
|
+
};
|
|
4509
|
+
if (isNodeError(error) && typeof error.code === "string" && IO_ERROR_CODES.has(error.code)) return {
|
|
4510
|
+
reason: "io-error",
|
|
4511
|
+
exitCode: VALIDATE_EXIT_CODES.IO_ERROR,
|
|
4512
|
+
message
|
|
4513
|
+
};
|
|
4514
|
+
return {
|
|
4515
|
+
reason: "unknown-error",
|
|
4516
|
+
exitCode: VALIDATE_EXIT_CODES.UNKNOWN_ERROR,
|
|
4517
|
+
message
|
|
4518
|
+
};
|
|
4519
|
+
}
|
|
4520
|
+
var ValidateCommandError = class extends Error {
|
|
4521
|
+
reason;
|
|
4522
|
+
exitCode;
|
|
4523
|
+
constructor(summary, options) {
|
|
4524
|
+
super(summary.message, options);
|
|
4525
|
+
this.name = "ValidateCommandError";
|
|
4526
|
+
this.reason = summary.reason;
|
|
4527
|
+
this.exitCode = summary.exitCode;
|
|
4528
|
+
}
|
|
4529
|
+
};
|
|
4530
|
+
//#endregion
|
|
4531
|
+
export { resolveBareArbitraryValueCandidate as $, createTailwindV4RootSources as A, resolveSourceScanPath as B, resolveProjectSourceFiles as C, TAILWIND_V4_IGNORED_FILES as D, TAILWIND_V4_IGNORED_EXTENSIONS as E, isFileExcludedByTailwindV4SourceEntries as F, canonicalizeBareArbitraryValueCandidates as G, resolveTailwindV4SourceEntry as H, isFileMatchedByTailwindV4SourceEntries as I, resolveValidTailwindV4Candidates as J, extractTailwindV4InlineSourceCandidates as K, mergeTailwindV4SourceEntries as L, createTailwindV4SourceExclusionMatcher as M, expandTailwindV4SourceEntries as N, createTailwindV4CompiledSourceEntries as O, expandTailwindV4SourceEntryBraces as P, isBareArbitraryValuesEnabled as Q, normalizeTailwindV4ScannerSources as R, groupTokensByFile as S, TAILWIND_V4_IGNORED_CONTENT_DIRS as T, compileTailwindV4Source as U, resolveTailwindV4SourceBaseCandidates as V, loadTailwindV4DesignSystem as W, extractBareArbitraryValueSourceCandidates as X, escapeCssClassName as Y, extractBareArbitraryValueSourceCandidatesWithPositions as Z, extractRawCandidates as _, tailwindcssPatchCommands as a, extractSourceCandidatesWithPositions as b, MIGRATION_REPORT_KIND as c, getPatchStatusReport as d, loadPatchOptionsForWorkspace as et, runTailwindBuild as f, extractProjectCandidatesWithPositions as g, collectClassesFromTailwindV4 as h, classifyValidateError as i, logger as it, createTailwindV4SourceEntryMatcher as j, createTailwindV4DefaultIgnoreSources as k, MIGRATION_REPORT_SCHEMA_VERSION as l, collectClassesFromContexts as m, VALIDATE_FAILURE_REASONS as n, normalizeOptions as nt, migrateConfigFiles as o, loadRuntimeContexts as p, replaceBareArbitraryValueSelectors as q, ValidateCommandError as r, CacheStore as rt, restoreConfigFiles as s, VALIDATE_EXIT_CODES as t, loadWorkspaceConfigModule as tt, TailwindcssPatcher as u, extractRawCandidatesWithPositions as v, TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN as w, extractValidCandidates as x, extractSourceCandidates as y, normalizeTailwindV4SourceEntries as z };
|
|
@@ -504,6 +504,20 @@ interface BareArbitraryValueOptions {
|
|
|
504
504
|
*/
|
|
505
505
|
units?: string[];
|
|
506
506
|
}
|
|
507
|
+
interface BareArbitraryValueResolveResult {
|
|
508
|
+
candidate: string;
|
|
509
|
+
canonicalCandidate: string;
|
|
510
|
+
}
|
|
511
|
+
interface BareArbitraryValueSourceCandidate {
|
|
512
|
+
rawCandidate: string;
|
|
513
|
+
start: number;
|
|
514
|
+
end: number;
|
|
515
|
+
}
|
|
516
|
+
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
517
|
+
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
518
|
+
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
519
|
+
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
520
|
+
declare function escapeCssClassName(value: string): string;
|
|
507
521
|
//#endregion
|
|
508
522
|
//#region src/extraction/candidate-extractor.d.ts
|
|
509
523
|
interface ExtractValidCandidatesOption {
|
|
@@ -514,15 +528,18 @@ interface ExtractValidCandidatesOption {
|
|
|
514
528
|
cwd?: string;
|
|
515
529
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
516
530
|
}
|
|
531
|
+
interface ExtractCandidateOptions {
|
|
532
|
+
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
533
|
+
}
|
|
517
534
|
interface ExtractSourceCandidate {
|
|
518
535
|
rawCandidate: string;
|
|
519
536
|
start: number;
|
|
520
537
|
end: number;
|
|
521
538
|
}
|
|
522
|
-
declare function extractRawCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
523
|
-
declare function extractSourceCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
524
|
-
declare function extractSourceCandidates(content: string, extension?: string): Promise<string[]>;
|
|
525
|
-
declare function extractRawCandidates(sources?: SourceEntry[]): Promise<string[]>;
|
|
539
|
+
declare function extractRawCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
540
|
+
declare function extractSourceCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
541
|
+
declare function extractSourceCandidates(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<string[]>;
|
|
542
|
+
declare function extractRawCandidates(sources?: SourceEntry[], options?: ExtractCandidateOptions): Promise<string[]>;
|
|
526
543
|
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
527
544
|
interface ExtractProjectCandidatesOptions {
|
|
528
545
|
cwd?: string;
|
|
@@ -791,4 +808,4 @@ declare class ValidateCommandError extends Error {
|
|
|
791
808
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
792
809
|
}
|
|
793
810
|
//#endregion
|
|
794
|
-
export {
|
|
811
|
+
export { TailwindV3Options as $, extractSourceCandidates as A, CacheReadMeta as At, resolveBareArbitraryValueCandidate as B, MIGRATION_REPORT_SCHEMA_VERSION as C, TailwindcssRuntimeContext as Ct, extractProjectCandidatesWithPositions as D, CacheContextDescriptor as Dt, ExtractSourceCandidate as E, CacheClearScope as Et, BareArbitraryValueOptions as F, ExposeContextOptions as G, ApplyOptions as H, escapeCssClassName as I, NormalizedCacheOptions as J, ExtendLengthUnitsOptions as K, extractBareArbitraryValueSourceCandidates as L, extractValidCandidates as M, groupTokensByFile as N, extractRawCandidates as O, CacheContextMetadata as Ot, resolveProjectSourceFiles as P, TailwindV2Options as Q, extractBareArbitraryValueSourceCandidatesWithPositions as R, MIGRATION_REPORT_KIND as S, TailwindcssClassCache as St, TailwindcssPatcher as T, CacheClearResult as Tt, CacheOptions as U, normalizeOptions as V, CacheStrategy as W, TailwindCssOptions as X, NormalizedTailwindCssPatchOptions as Y, TailwindCssPatchOptions as Z, ConfigFileMigrationEntry as _, TailwindPatchRuntime as _t, ValidateFailureSummary as a, TailwindV4Engine as at, RestoreConfigFilesOptions as b, TailwindTokenLocation as bt, TailwindcssPatchCliMountOptions as c, TailwindV4ResolvedSource as ct, TailwindcssPatchCommandContext as d, ExtractResult as dt, TailwindV4Options as et, TailwindcssPatchCommandHandler as f, ILengthUnitsPatchOptions as ft, tailwindcssPatchCommands as g, PatchStatusReport as gt, TailwindcssPatchCommandOptions as h, PatchStatusEntry as ht, ValidateFailureReason as i, TailwindV4DesignSystem as it, extractSourceCandidatesWithPositions as j, CacheReadResult as jt, extractRawCandidatesWithPositions as k, CacheIndexFileV2 as kt, TailwindcssPatchCliOptions as l, TailwindV4SourceOptions as lt, TailwindcssPatchCommandOptionDefinition as m, PatchName as mt, VALIDATE_FAILURE_REASONS as n, TailwindV4CompiledSourceRoot as nt, ValidateJsonFailurePayload as o, TailwindV4GenerateOptions as ot, TailwindcssPatchCommandHandlerMap as p, PatchCheckStatus as pt, ExtractOptions as q, ValidateCommandError as r, TailwindV4CssSource as rt, ValidateJsonSuccessPayload as s, TailwindV4GenerateResult as st, VALIDATE_EXIT_CODES as t, TailwindV4CandidateSource as tt, TailwindcssPatchCommand as u, TailwindV4SourcePattern as ut, ConfigFileMigrationReport as v, TailwindTokenByFileMap as vt, logger as w, CacheClearOptions as wt, RestoreConfigFilesResult as x, TailwindTokenReport as xt, MigrateConfigFilesOptions as y, TailwindTokenFileKey as yt, isBareArbitraryValuesEnabled as z };
|
|
@@ -503,6 +503,20 @@ interface BareArbitraryValueOptions {
|
|
|
503
503
|
*/
|
|
504
504
|
units?: string[];
|
|
505
505
|
}
|
|
506
|
+
interface BareArbitraryValueResolveResult {
|
|
507
|
+
candidate: string;
|
|
508
|
+
canonicalCandidate: string;
|
|
509
|
+
}
|
|
510
|
+
interface BareArbitraryValueSourceCandidate {
|
|
511
|
+
rawCandidate: string;
|
|
512
|
+
start: number;
|
|
513
|
+
end: number;
|
|
514
|
+
}
|
|
515
|
+
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
516
|
+
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
517
|
+
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
518
|
+
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
519
|
+
declare function escapeCssClassName(value: string): string;
|
|
506
520
|
//#endregion
|
|
507
521
|
//#region src/extraction/candidate-extractor.d.ts
|
|
508
522
|
interface ExtractValidCandidatesOption {
|
|
@@ -513,15 +527,18 @@ interface ExtractValidCandidatesOption {
|
|
|
513
527
|
cwd?: string;
|
|
514
528
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
515
529
|
}
|
|
530
|
+
interface ExtractCandidateOptions {
|
|
531
|
+
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
532
|
+
}
|
|
516
533
|
interface ExtractSourceCandidate {
|
|
517
534
|
rawCandidate: string;
|
|
518
535
|
start: number;
|
|
519
536
|
end: number;
|
|
520
537
|
}
|
|
521
|
-
declare function extractRawCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
522
|
-
declare function extractSourceCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
523
|
-
declare function extractSourceCandidates(content: string, extension?: string): Promise<string[]>;
|
|
524
|
-
declare function extractRawCandidates(sources?: SourceEntry[]): Promise<string[]>;
|
|
538
|
+
declare function extractRawCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
539
|
+
declare function extractSourceCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
540
|
+
declare function extractSourceCandidates(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<string[]>;
|
|
541
|
+
declare function extractRawCandidates(sources?: SourceEntry[], options?: ExtractCandidateOptions): Promise<string[]>;
|
|
525
542
|
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
526
543
|
interface ExtractProjectCandidatesOptions {
|
|
527
544
|
cwd?: string;
|
|
@@ -790,4 +807,4 @@ declare class ValidateCommandError extends Error {
|
|
|
790
807
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
791
808
|
}
|
|
792
809
|
//#endregion
|
|
793
|
-
export {
|
|
810
|
+
export { TailwindV3Options as $, extractSourceCandidates as A, CacheReadMeta as At, resolveBareArbitraryValueCandidate as B, MIGRATION_REPORT_SCHEMA_VERSION as C, TailwindcssRuntimeContext as Ct, extractProjectCandidatesWithPositions as D, CacheContextDescriptor as Dt, ExtractSourceCandidate as E, CacheClearScope as Et, BareArbitraryValueOptions as F, ExposeContextOptions as G, ApplyOptions as H, escapeCssClassName as I, NormalizedCacheOptions as J, ExtendLengthUnitsOptions as K, extractBareArbitraryValueSourceCandidates as L, extractValidCandidates as M, groupTokensByFile as N, extractRawCandidates as O, CacheContextMetadata as Ot, resolveProjectSourceFiles as P, TailwindV2Options as Q, extractBareArbitraryValueSourceCandidatesWithPositions as R, MIGRATION_REPORT_KIND as S, TailwindcssClassCache as St, TailwindcssPatcher as T, CacheClearResult as Tt, CacheOptions as U, normalizeOptions as V, CacheStrategy as W, TailwindCssOptions as X, NormalizedTailwindCssPatchOptions as Y, TailwindCssPatchOptions as Z, ConfigFileMigrationEntry as _, TailwindPatchRuntime as _t, ValidateFailureSummary as a, TailwindV4Engine as at, RestoreConfigFilesOptions as b, TailwindTokenLocation as bt, TailwindcssPatchCliMountOptions as c, TailwindV4ResolvedSource as ct, TailwindcssPatchCommandContext as d, ExtractResult as dt, TailwindV4Options as et, TailwindcssPatchCommandHandler as f, ILengthUnitsPatchOptions as ft, tailwindcssPatchCommands as g, PatchStatusReport as gt, TailwindcssPatchCommandOptions as h, PatchStatusEntry as ht, ValidateFailureReason as i, TailwindV4DesignSystem as it, extractSourceCandidatesWithPositions as j, CacheReadResult as jt, extractRawCandidatesWithPositions as k, CacheIndexFileV2 as kt, TailwindcssPatchCliOptions as l, TailwindV4SourceOptions as lt, TailwindcssPatchCommandOptionDefinition as m, PatchName as mt, VALIDATE_FAILURE_REASONS as n, TailwindV4CompiledSourceRoot as nt, ValidateJsonFailurePayload as o, TailwindV4GenerateOptions as ot, TailwindcssPatchCommandHandlerMap as p, PatchCheckStatus as pt, ExtractOptions as q, ValidateCommandError as r, TailwindV4CssSource as rt, ValidateJsonSuccessPayload as s, TailwindV4GenerateResult as st, VALIDATE_EXIT_CODES as t, TailwindV4CandidateSource as tt, TailwindcssPatchCommand as u, TailwindV4SourcePattern as ut, ConfigFileMigrationReport as v, TailwindTokenByFileMap as vt, logger as w, CacheClearOptions as wt, RestoreConfigFilesResult as x, TailwindTokenReport as xt, MigrateConfigFilesOptions as y, TailwindTokenFileKey as yt, isBareArbitraryValuesEnabled as z };
|