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.
- package/README.md +69 -0
- package/dist/{cli-CBVPia5Z.js → cli-BztQHMRp.js} +63 -64
- package/dist/{cli-CgBdW1U5.mjs → cli-D0jXMGXf.mjs} +1 -1
- package/dist/cli.js +5 -6
- 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/{dist-B1VBpHtd.js → dist-DDcbvOwe.js} +2 -2
- package/dist/index.d.mts +105 -5
- package/dist/index.d.ts +105 -5
- package/dist/index.js +325 -62
- package/dist/index.mjs +253 -4
- package/dist/{migrate-config-DqknZpUe.mjs → validate-Bug_WYcU.mjs} +193 -93
- package/dist/{validate-CaJv2g5K.d.ts → validate-BuqRodYI.d.ts} +65 -16
- package/dist/{migrate-config-Dn9OTXpO.js → validate-DbuKewV-.js} +257 -100
- package/dist/{validate-Dr7IkGU8.d.mts → validate-oAkURzUC.d.mts} +65 -15
- package/package.json +9 -9
- package/src/extraction/candidate-extractor.ts +76 -12
- package/src/public-api.ts +54 -13
- package/src/style-candidates.ts +35 -0
- package/src/style-generator.ts +80 -0
- package/src/v3/index.ts +11 -0
- package/src/v3/style-generator.ts +384 -0
- package/src/v4/bare-arbitrary-values.ts +127 -2
- package/src/v4/engine.ts +5 -2
- package/src/v4/index.ts +20 -4
- package/src/v4/node-adapter.ts +1 -1
- package/src/v4/source-scan.ts +1 -1
- package/src/v4/style-generator.ts +44 -0
- package/src/v4/types.ts +23 -0
- package/dist/chunk-8l464Juk.js +0 -28
- /package/dist/{dist-BjUV1yEM.mjs → dist-CxmNpfyy.mjs} +0 -0
|
@@ -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.3";
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/constants.ts
|
|
24
24
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1412,7 +1412,7 @@ function normalizeOptions(options = {}) {
|
|
|
1412
1412
|
};
|
|
1413
1413
|
}
|
|
1414
1414
|
//#endregion
|
|
1415
|
-
//#region ../../node_modules/.pnpm/tsdown@0.22.
|
|
1415
|
+
//#region ../../node_modules/.pnpm/tsdown@0.22.2_tsx@4.22.4_typescript@6.0.3_unrun@0.2.37_synckit@0.11.13_/node_modules/tsdown/esm-shims.js
|
|
1416
1416
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
1417
1417
|
const getDirname = () => path$1.dirname(getFilename());
|
|
1418
1418
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -1444,7 +1444,7 @@ async function loadWorkspaceConfigModule() {
|
|
|
1444
1444
|
return configModulePromise;
|
|
1445
1445
|
}
|
|
1446
1446
|
async function loadWorkspaceDefu() {
|
|
1447
|
-
if (!defuPromise) defuPromise = import("./dist-
|
|
1447
|
+
if (!defuPromise) defuPromise = import("./dist-CxmNpfyy.mjs").then((mod) => mod.defu).catch(async (error) => {
|
|
1448
1448
|
if (!isMissingSharedModuleError(error)) throw error;
|
|
1449
1449
|
return (await import(pathToFileURL(path.resolve(__dirname, "../../../shared/src/utils.ts")).href)).defu;
|
|
1450
1450
|
});
|
|
@@ -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 };
|
|
@@ -3,8 +3,6 @@ import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
|
3
3
|
import { SourceEntry } from "@tailwindcss/oxide";
|
|
4
4
|
import { Node, Rule } from "postcss";
|
|
5
5
|
import { Config } from "tailwindcss";
|
|
6
|
-
import * as _$consola from "consola";
|
|
7
|
-
|
|
8
6
|
//#region src/cache/types.d.ts
|
|
9
7
|
declare const CACHE_SCHEMA_VERSION = 2;
|
|
10
8
|
declare const CACHE_FINGERPRINT_VERSION = 1;
|
|
@@ -159,6 +157,44 @@ interface PatchStatusReport {
|
|
|
159
157
|
entries: PatchStatusEntry[];
|
|
160
158
|
}
|
|
161
159
|
//#endregion
|
|
160
|
+
//#region src/v4/bare-arbitrary-values.d.ts
|
|
161
|
+
interface BareArbitraryValueOptions {
|
|
162
|
+
/**
|
|
163
|
+
* 允许作为无方括号任意值的单位列表。
|
|
164
|
+
*/
|
|
165
|
+
units?: string[];
|
|
166
|
+
}
|
|
167
|
+
interface BareArbitraryValueResolveResult {
|
|
168
|
+
candidate: string;
|
|
169
|
+
canonicalCandidate: string;
|
|
170
|
+
}
|
|
171
|
+
interface BareArbitraryValueSourceCandidate {
|
|
172
|
+
rawCandidate: string;
|
|
173
|
+
start: number;
|
|
174
|
+
end: number;
|
|
175
|
+
}
|
|
176
|
+
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
177
|
+
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
178
|
+
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
179
|
+
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
180
|
+
declare function escapeCssClassName(value: string): string;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/style-candidates.d.ts
|
|
183
|
+
interface TailwindStyleSource {
|
|
184
|
+
content: string;
|
|
185
|
+
extension?: string;
|
|
186
|
+
file?: string;
|
|
187
|
+
}
|
|
188
|
+
interface TailwindStyleCandidateOptions {
|
|
189
|
+
candidates?: Iterable<string>;
|
|
190
|
+
sources?: TailwindStyleSource[];
|
|
191
|
+
/**
|
|
192
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
193
|
+
*/
|
|
194
|
+
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
195
|
+
}
|
|
196
|
+
declare function collectTailwindStyleCandidates(options?: TailwindStyleCandidateOptions): Promise<Set<string>>;
|
|
197
|
+
//#endregion
|
|
162
198
|
//#region src/v4/types.d.ts
|
|
163
199
|
interface TailwindV4SourceOptions {
|
|
164
200
|
projectRoot?: string;
|
|
@@ -187,6 +223,7 @@ interface TailwindV4CandidateSource {
|
|
|
187
223
|
content: string;
|
|
188
224
|
extension?: string;
|
|
189
225
|
}
|
|
226
|
+
interface TailwindV4StyleSource extends TailwindStyleSource {}
|
|
190
227
|
interface TailwindV4GenerateOptions {
|
|
191
228
|
candidates?: Iterable<string>;
|
|
192
229
|
sources?: TailwindV4CandidateSource[];
|
|
@@ -221,6 +258,23 @@ interface TailwindV4GenerateResult {
|
|
|
221
258
|
sources: TailwindV4SourcePattern[];
|
|
222
259
|
root: TailwindV4CompiledSourceRoot;
|
|
223
260
|
}
|
|
261
|
+
interface TailwindV4StyleGenerateOptions extends TailwindV4SourceOptions {
|
|
262
|
+
source?: TailwindV4ResolvedSource;
|
|
263
|
+
candidates?: Iterable<string>;
|
|
264
|
+
sources?: TailwindV4StyleSource[];
|
|
265
|
+
/**
|
|
266
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
267
|
+
*/
|
|
268
|
+
bareArbitraryValues?: TailwindV4GenerateOptions['bareArbitraryValues'];
|
|
269
|
+
/**
|
|
270
|
+
* Scans the compiled Tailwind CSS v4 source entries in addition to in-memory sources.
|
|
271
|
+
*/
|
|
272
|
+
scanSources?: TailwindV4GenerateOptions['scanSources'];
|
|
273
|
+
}
|
|
274
|
+
interface TailwindV4StyleGenerateResult extends TailwindV4GenerateResult {
|
|
275
|
+
tokens: Set<string>;
|
|
276
|
+
source: TailwindV4ResolvedSource;
|
|
277
|
+
}
|
|
224
278
|
interface TailwindV4DesignSystem {
|
|
225
279
|
parseCandidate: (candidate: string) => unknown[];
|
|
226
280
|
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
@@ -497,14 +551,6 @@ type TailwindcssConfigResult = Awaited<ReturnType<TailwindcssConfigModule['getCo
|
|
|
497
551
|
//#region src/runtime/collector.d.ts
|
|
498
552
|
type TailwindMajorVersion = 2 | 3 | 4;
|
|
499
553
|
//#endregion
|
|
500
|
-
//#region src/v4/bare-arbitrary-values.d.ts
|
|
501
|
-
interface BareArbitraryValueOptions {
|
|
502
|
-
/**
|
|
503
|
-
* 允许作为无方括号任意值的单位列表。
|
|
504
|
-
*/
|
|
505
|
-
units?: string[];
|
|
506
|
-
}
|
|
507
|
-
//#endregion
|
|
508
554
|
//#region src/extraction/candidate-extractor.d.ts
|
|
509
555
|
interface ExtractValidCandidatesOption {
|
|
510
556
|
sources?: SourceEntry[];
|
|
@@ -514,15 +560,18 @@ interface ExtractValidCandidatesOption {
|
|
|
514
560
|
cwd?: string;
|
|
515
561
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
516
562
|
}
|
|
563
|
+
interface ExtractCandidateOptions {
|
|
564
|
+
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
565
|
+
}
|
|
517
566
|
interface ExtractSourceCandidate {
|
|
518
567
|
rawCandidate: string;
|
|
519
568
|
start: number;
|
|
520
569
|
end: number;
|
|
521
570
|
}
|
|
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[]>;
|
|
571
|
+
declare function extractRawCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
572
|
+
declare function extractSourceCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
573
|
+
declare function extractSourceCandidates(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<string[]>;
|
|
574
|
+
declare function extractRawCandidates(sources?: SourceEntry[], options?: ExtractCandidateOptions): Promise<string[]>;
|
|
526
575
|
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
527
576
|
interface ExtractProjectCandidatesOptions {
|
|
528
577
|
cwd?: string;
|
|
@@ -587,7 +636,7 @@ declare class TailwindcssPatcher {
|
|
|
587
636
|
}
|
|
588
637
|
//#endregion
|
|
589
638
|
//#region src/logger.d.ts
|
|
590
|
-
declare const logger:
|
|
639
|
+
declare const logger: import("consola").ConsolaInstance;
|
|
591
640
|
//#endregion
|
|
592
641
|
//#region src/commands/migration-report.d.ts
|
|
593
642
|
declare const MIGRATION_REPORT_KIND = "tw-patch-migrate-report";
|
|
@@ -791,4 +840,4 @@ declare class ValidateCommandError extends Error {
|
|
|
791
840
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
792
841
|
}
|
|
793
842
|
//#endregion
|
|
794
|
-
export {
|
|
843
|
+
export { TailwindV4Engine as $, extractSourceCandidates as A, CacheClearOptions as At, ExtendLengthUnitsOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, TailwindPatchRuntime as Ct, extractProjectCandidatesWithPositions as D, TailwindTokenReport as Dt, ExtractSourceCandidate as E, TailwindTokenLocation as Et, normalizeOptions as F, CacheIndexFileV2 as Ft, TailwindCssPatchOptions as G, NormalizedCacheOptions as H, ApplyOptions as I, CacheReadMeta as It, TailwindV4Options as J, TailwindV2Options as K, CacheOptions as L, CacheReadResult as Lt, extractValidCandidates as M, CacheClearScope as Mt, groupTokensByFile as N, CacheContextDescriptor as Nt, extractRawCandidates as O, TailwindcssClassCache as Ot, resolveProjectSourceFiles as P, CacheContextMetadata as Pt, TailwindV4DesignSystem as Q, CacheStrategy as R, MIGRATION_REPORT_KIND as S, PatchStatusReport as St, TailwindcssPatcher as T, TailwindTokenFileKey as Tt, NormalizedTailwindCssPatchOptions as U, ExtractOptions as V, TailwindCssOptions as W, TailwindV4CompiledSourceRoot as X, TailwindV4CandidateSource as Y, TailwindV4CssSource as Z, ConfigFileMigrationEntry as _, ExtractResult as _t, ValidateFailureSummary as a, TailwindV4StyleGenerateOptions as at, RestoreConfigFilesOptions as b, PatchName as bt, TailwindcssPatchCliMountOptions as c, TailwindStyleCandidateOptions as ct, TailwindcssPatchCommandContext as d, BareArbitraryValueOptions as dt, TailwindV4GenerateOptions as et, TailwindcssPatchCommandHandler as f, escapeCssClassName as ft, tailwindcssPatchCommands as g, resolveBareArbitraryValueCandidate as gt, TailwindcssPatchCommandOptions as h, isBareArbitraryValuesEnabled as ht, ValidateFailureReason as i, TailwindV4SourcePattern as it, extractSourceCandidatesWithPositions as j, CacheClearResult as jt, extractRawCandidatesWithPositions as k, TailwindcssRuntimeContext as kt, TailwindcssPatchCliOptions as l, TailwindStyleSource as lt, TailwindcssPatchCommandOptionDefinition as m, extractBareArbitraryValueSourceCandidatesWithPositions as mt, VALIDATE_FAILURE_REASONS as n, TailwindV4ResolvedSource as nt, ValidateJsonFailurePayload as o, TailwindV4StyleGenerateResult as ot, TailwindcssPatchCommandHandlerMap as p, extractBareArbitraryValueSourceCandidates as pt, TailwindV3Options as q, ValidateCommandError as r, TailwindV4SourceOptions as rt, ValidateJsonSuccessPayload as s, TailwindV4StyleSource as st, VALIDATE_EXIT_CODES as t, TailwindV4GenerateResult as tt, TailwindcssPatchCommand as u, collectTailwindStyleCandidates as ut, ConfigFileMigrationReport as v, ILengthUnitsPatchOptions as vt, logger as w, TailwindTokenByFileMap as wt, RestoreConfigFilesResult as x, PatchStatusEntry as xt, MigrateConfigFilesOptions as y, PatchCheckStatus as yt, ExposeContextOptions as z };
|