tailwindcss-patch 9.3.1 → 9.3.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/dist/cli.js +2 -2
- 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 +1 -1
- package/dist/commands/cli-runtime.mjs +1 -1
- package/dist/{index.bundle-Y1jzXpYx.js → index.bundle-BdxyJef9.js} +25 -6
- package/dist/{index.bundle-BKRsKEHP.mjs → index.bundle-C39laqrA.mjs} +25 -6
- package/dist/index.d.mts +2 -67
- package/dist/index.d.ts +2 -67
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{validate-Bd1fbQsd.js → validate-DABvQ44V.js} +147 -31
- package/dist/{validate-Bqych-z9.d.ts → validate-DDJnolx2.d.mts} +79 -5
- package/dist/{validate-CVInpab6.mjs → validate-cMWKFUKS.mjs} +147 -31
- package/dist/{validate-C8-qsOWo.d.mts → validate-rPPCy1cl.d.ts} +80 -4
- package/package.json +1 -1
- package/src/index.bundle.ts +1 -0
- package/src/index.ts +1 -0
- package/src/options/normalize.ts +14 -0
- package/src/options/types.ts +4 -0
- package/src/runtime/class-collector.ts +33 -13
- package/src/v4/bare-arbitrary-values.ts +110 -16
- package/src/v4/candidates.ts +48 -20
- package/src/v4/index.ts +1 -0
- package/src/v4/source.ts +48 -6
- package/src/v4/types.ts +8 -0
|
@@ -23,7 +23,7 @@ _babel_traverse = require_chunk.__toESM(_babel_traverse);
|
|
|
23
23
|
let _babel_parser = require("@babel/parser");
|
|
24
24
|
let tailwindcss_config = require("tailwindcss-config");
|
|
25
25
|
//#region package.json
|
|
26
|
-
var version = "9.3.
|
|
26
|
+
var version = "9.3.3";
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/constants.ts
|
|
29
29
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1330,6 +1330,13 @@ function normalizeExtendLengthUnitsOptions(extend) {
|
|
|
1330
1330
|
function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
1331
1331
|
const configuredBase = v4?.base ? pathe.default.resolve(v4.base) : void 0;
|
|
1332
1332
|
const base = configuredBase ?? fallbackBase;
|
|
1333
|
+
const resolveV4Path = (value) => pathe.default.isAbsolute(value) ? pathe.default.resolve(value) : pathe.default.resolve(fallbackBase, value);
|
|
1334
|
+
const cssSources = Array.isArray(v4?.cssSources) ? v4.cssSources.filter((source) => typeof source?.css === "string").map((source) => ({
|
|
1335
|
+
css: source.css,
|
|
1336
|
+
...source.base === void 0 ? {} : { base: resolveV4Path(source.base) },
|
|
1337
|
+
...source.file === void 0 ? {} : { file: resolveV4Path(source.file) },
|
|
1338
|
+
...source.dependencies === void 0 ? {} : { dependencies: source.dependencies.filter(Boolean).map(resolveV4Path) }
|
|
1339
|
+
})) : [];
|
|
1333
1340
|
const cssEntries = Array.isArray(v4?.cssEntries) ? v4.cssEntries.filter((entry) => Boolean(entry)).map((entry) => pathe.default.resolve(entry)) : [];
|
|
1334
1341
|
const userSources = v4?.sources;
|
|
1335
1342
|
const hasUserDefinedSources = Boolean(userSources?.length);
|
|
@@ -1342,6 +1349,7 @@ function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
|
1342
1349
|
base,
|
|
1343
1350
|
...configuredBase === void 0 ? {} : { configuredBase },
|
|
1344
1351
|
...v4?.css === void 0 ? {} : { css: v4.css },
|
|
1352
|
+
cssSources,
|
|
1345
1353
|
cssEntries,
|
|
1346
1354
|
sources,
|
|
1347
1355
|
hasUserDefinedSources,
|
|
@@ -1479,7 +1487,8 @@ const DEFAULT_BARE_ARBITRARY_VALUE_UNITS = [
|
|
|
1479
1487
|
"ms"
|
|
1480
1488
|
];
|
|
1481
1489
|
const NUMBER_RE = /^-?(?:\d+|\d*\.\d+)$/;
|
|
1482
|
-
const FUNCTION_VALUE_RE = /^[a-
|
|
1490
|
+
const FUNCTION_VALUE_RE = /^[a-z_-][\w-]*\(/i;
|
|
1491
|
+
const HEX_ESCAPE_RE = /^[\da-f]$/i;
|
|
1483
1492
|
function splitVariantPrefix(candidate) {
|
|
1484
1493
|
let depth = 0;
|
|
1485
1494
|
let quote;
|
|
@@ -1545,8 +1554,38 @@ function isBalancedFunctionValue(value) {
|
|
|
1545
1554
|
}
|
|
1546
1555
|
return depth === 0 && quote === void 0;
|
|
1547
1556
|
}
|
|
1557
|
+
function isEscapedAt(value, index) {
|
|
1558
|
+
let slashCount = 0;
|
|
1559
|
+
for (let slashIndex = index - 1; slashIndex >= 0 && value[slashIndex] === "\\"; slashIndex--) slashCount++;
|
|
1560
|
+
return slashCount % 2 === 1;
|
|
1561
|
+
}
|
|
1562
|
+
function isBalancedBareArbitraryBody(value) {
|
|
1563
|
+
let depth = 0;
|
|
1564
|
+
let quote;
|
|
1565
|
+
for (let index = 0; index < value.length; index++) {
|
|
1566
|
+
const character = value[index];
|
|
1567
|
+
if (isEscapedAt(value, index)) continue;
|
|
1568
|
+
if (quote) {
|
|
1569
|
+
if (character === quote) quote = void 0;
|
|
1570
|
+
continue;
|
|
1571
|
+
}
|
|
1572
|
+
if (character === "\"" || character === "'") {
|
|
1573
|
+
quote = character;
|
|
1574
|
+
continue;
|
|
1575
|
+
}
|
|
1576
|
+
if (character === "(" || character === "{") {
|
|
1577
|
+
depth++;
|
|
1578
|
+
continue;
|
|
1579
|
+
}
|
|
1580
|
+
if (character === ")" || character === "}") {
|
|
1581
|
+
depth--;
|
|
1582
|
+
if (depth < 0) return false;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
return depth === 0 && quote === void 0;
|
|
1586
|
+
}
|
|
1548
1587
|
function isHexColorValue(value) {
|
|
1549
|
-
return /^#(?:[0-9a-
|
|
1588
|
+
return /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6,8})$/i.test(value);
|
|
1550
1589
|
}
|
|
1551
1590
|
function isQuotedValue(value) {
|
|
1552
1591
|
const quote = value[0];
|
|
@@ -1569,29 +1608,61 @@ function normalizeBareArbitraryValueOptions(options) {
|
|
|
1569
1608
|
if (normalizedUnits.length === 0) return;
|
|
1570
1609
|
return { units: normalizedUnits.sort((a, b) => b.length - a.length) };
|
|
1571
1610
|
}
|
|
1611
|
+
function normalizeEscapedValue(value) {
|
|
1612
|
+
let result = "";
|
|
1613
|
+
for (let index = 0; index < value.length; index++) {
|
|
1614
|
+
const character = value[index];
|
|
1615
|
+
if (character !== "\\") {
|
|
1616
|
+
result += character;
|
|
1617
|
+
continue;
|
|
1618
|
+
}
|
|
1619
|
+
const nextCharacter = value[index + 1];
|
|
1620
|
+
if (nextCharacter === void 0) {
|
|
1621
|
+
result += character;
|
|
1622
|
+
continue;
|
|
1623
|
+
}
|
|
1624
|
+
if (HEX_ESCAPE_RE.test(nextCharacter)) {
|
|
1625
|
+
let hex = "";
|
|
1626
|
+
let nextIndex = index + 1;
|
|
1627
|
+
while (nextIndex < value.length && hex.length < 6) {
|
|
1628
|
+
const hexCharacter = value[nextIndex];
|
|
1629
|
+
if (hexCharacter === void 0 || !HEX_ESCAPE_RE.test(hexCharacter)) break;
|
|
1630
|
+
hex += hexCharacter;
|
|
1631
|
+
nextIndex++;
|
|
1632
|
+
}
|
|
1633
|
+
if (/[\t\n\f\r ]/.test(value[nextIndex] ?? "")) nextIndex++;
|
|
1634
|
+
const decoded = String.fromCodePoint(Number.parseInt(hex, 16));
|
|
1635
|
+
result += decoded === "_" ? "\\_" : decoded;
|
|
1636
|
+
index = nextIndex - 1;
|
|
1637
|
+
continue;
|
|
1638
|
+
}
|
|
1639
|
+
result += nextCharacter === "_" ? "\\_" : nextCharacter;
|
|
1640
|
+
index++;
|
|
1641
|
+
}
|
|
1642
|
+
return result;
|
|
1643
|
+
}
|
|
1572
1644
|
function resolveValueWithUnit(body, units) {
|
|
1645
|
+
const value = normalizeEscapedValue(body);
|
|
1573
1646
|
for (const unit of units) {
|
|
1574
|
-
if (!
|
|
1575
|
-
const numberPart =
|
|
1647
|
+
if (!value.endsWith(unit)) continue;
|
|
1648
|
+
const numberPart = value.slice(0, -unit.length);
|
|
1576
1649
|
if (NUMBER_RE.test(numberPart)) return `${numberPart}${unit}`;
|
|
1577
1650
|
}
|
|
1578
1651
|
}
|
|
1579
1652
|
function resolveArbitraryValue(body, units) {
|
|
1580
|
-
const
|
|
1653
|
+
const value = normalizeEscapedValue(body);
|
|
1654
|
+
const withUnit = resolveValueWithUnit(value, units);
|
|
1581
1655
|
if (withUnit) return withUnit;
|
|
1582
|
-
if (isHexColorValue(
|
|
1583
|
-
if (isQuotedValue(
|
|
1584
|
-
if (FUNCTION_VALUE_RE.test(
|
|
1656
|
+
if (isHexColorValue(value)) return value;
|
|
1657
|
+
if (isQuotedValue(value)) return value;
|
|
1658
|
+
if (FUNCTION_VALUE_RE.test(value) && value.endsWith(")") && isBalancedFunctionValue(value)) return value;
|
|
1585
1659
|
}
|
|
1586
1660
|
function resolveUtilityAndValue(body, units) {
|
|
1587
1661
|
let depth = 0;
|
|
1588
1662
|
let quote;
|
|
1589
|
-
for (let index = 1; index
|
|
1663
|
+
for (let index = body.length - 1; index > 0; index--) {
|
|
1590
1664
|
const character = body[index];
|
|
1591
|
-
if (
|
|
1592
|
-
index++;
|
|
1593
|
-
continue;
|
|
1594
|
-
}
|
|
1665
|
+
if (isEscapedAt(body, index)) continue;
|
|
1595
1666
|
if (quote) {
|
|
1596
1667
|
if (character === quote) quote = void 0;
|
|
1597
1668
|
continue;
|
|
@@ -1600,11 +1671,11 @@ function resolveUtilityAndValue(body, units) {
|
|
|
1600
1671
|
quote = character;
|
|
1601
1672
|
continue;
|
|
1602
1673
|
}
|
|
1603
|
-
if (character === "
|
|
1674
|
+
if (character === ")" || character === "}") {
|
|
1604
1675
|
depth++;
|
|
1605
1676
|
continue;
|
|
1606
1677
|
}
|
|
1607
|
-
if (character === "
|
|
1678
|
+
if (character === "(" || character === "{") {
|
|
1608
1679
|
depth = Math.max(0, depth - 1);
|
|
1609
1680
|
continue;
|
|
1610
1681
|
}
|
|
@@ -1627,6 +1698,7 @@ function resolveBareArbitraryValueCandidate(candidate, options) {
|
|
|
1627
1698
|
let normalizedBody = important ? body.slice(1) : body;
|
|
1628
1699
|
const negative = normalizedBody.startsWith("-") ? "-" : "";
|
|
1629
1700
|
if (negative) normalizedBody = normalizedBody.slice(1);
|
|
1701
|
+
if (!isBalancedBareArbitraryBody(normalizedBody)) return;
|
|
1630
1702
|
const resolved = resolveUtilityAndValue(normalizedBody, normalizedOptions.units);
|
|
1631
1703
|
if (!resolved) return;
|
|
1632
1704
|
return {
|
|
@@ -1660,23 +1732,32 @@ function escapeCssClassName(value) {
|
|
|
1660
1732
|
function resolveValidTailwindV4Candidates(designSystem, candidates, options) {
|
|
1661
1733
|
const validCandidates = /* @__PURE__ */ new Set();
|
|
1662
1734
|
const parsedCandidates = [];
|
|
1663
|
-
const
|
|
1735
|
+
const originalCandidatesByCanonical = /* @__PURE__ */ new Map();
|
|
1664
1736
|
for (const candidate of candidates) {
|
|
1665
1737
|
if (!candidate) continue;
|
|
1666
1738
|
const bareArbitrary = resolveBareArbitraryValueCandidate(candidate, options?.bareArbitraryValues);
|
|
1667
1739
|
const candidateToCheck = bareArbitrary?.canonicalCandidate ?? candidate;
|
|
1668
|
-
if (
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1740
|
+
if (bareArbitrary) {
|
|
1741
|
+
const originalCandidates = originalCandidatesByCanonical.get(candidateToCheck) ?? /* @__PURE__ */ new Set();
|
|
1742
|
+
originalCandidates.add(candidate);
|
|
1743
|
+
originalCandidatesByCanonical.set(candidateToCheck, originalCandidates);
|
|
1672
1744
|
}
|
|
1745
|
+
if (parsedCandidates.includes(candidateToCheck)) continue;
|
|
1746
|
+
if (designSystem.parseCandidate(candidateToCheck).length > 0) parsedCandidates.push(candidateToCheck);
|
|
1673
1747
|
}
|
|
1674
1748
|
if (parsedCandidates.length === 0) return validCandidates;
|
|
1675
1749
|
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
1676
1750
|
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
1677
1751
|
const candidate = parsedCandidates[index];
|
|
1678
1752
|
const candidateCss = cssByCandidate[index];
|
|
1679
|
-
if (candidate && typeof candidateCss === "string" && candidateCss.trim().length > 0)
|
|
1753
|
+
if (candidate && typeof candidateCss === "string" && candidateCss.trim().length > 0) {
|
|
1754
|
+
const originalCandidates = originalCandidatesByCanonical.get(candidate);
|
|
1755
|
+
if (originalCandidates) {
|
|
1756
|
+
for (const originalCandidate of originalCandidates) validCandidates.add(originalCandidate);
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
validCandidates.add(candidate);
|
|
1760
|
+
}
|
|
1680
1761
|
}
|
|
1681
1762
|
return validCandidates;
|
|
1682
1763
|
}
|
|
@@ -1685,16 +1766,34 @@ function createSelectorAliasMap(candidates, options) {
|
|
|
1685
1766
|
for (const candidate of candidates) {
|
|
1686
1767
|
const bareArbitrary = resolveBareArbitraryValueCandidate(candidate, options);
|
|
1687
1768
|
if (!bareArbitrary) continue;
|
|
1688
|
-
|
|
1769
|
+
const canonicalSelector = escapeCssClassName(bareArbitrary.canonicalCandidate);
|
|
1770
|
+
const bareSelectors = aliases.get(canonicalSelector) ?? /* @__PURE__ */ new Set();
|
|
1771
|
+
bareSelectors.add(escapeCssClassName(bareArbitrary.candidate));
|
|
1772
|
+
aliases.set(canonicalSelector, bareSelectors);
|
|
1689
1773
|
}
|
|
1690
1774
|
return aliases;
|
|
1691
1775
|
}
|
|
1692
1776
|
function replaceBareArbitraryValueSelectors(css, candidates, options) {
|
|
1693
1777
|
const aliases = createSelectorAliasMap(candidates, options);
|
|
1694
1778
|
if (aliases.size === 0) return css;
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1779
|
+
if (Array.from(aliases.values()).every((bareSelectors) => bareSelectors.size === 1)) {
|
|
1780
|
+
let result = css;
|
|
1781
|
+
for (const [canonicalSelector, bareSelectors] of aliases) {
|
|
1782
|
+
const bareSelector = Array.from(bareSelectors)[0];
|
|
1783
|
+
if (bareSelector !== void 0) result = result.replaceAll(canonicalSelector, bareSelector);
|
|
1784
|
+
}
|
|
1785
|
+
return result;
|
|
1786
|
+
}
|
|
1787
|
+
const root = postcss.default.parse(css);
|
|
1788
|
+
root.walkRules((rule) => {
|
|
1789
|
+
let selectors = rule.selectors;
|
|
1790
|
+
for (const [canonicalSelector, bareSelectors] of aliases) selectors = selectors.flatMap((selector) => {
|
|
1791
|
+
if (!selector.includes(canonicalSelector)) return selector;
|
|
1792
|
+
return Array.from(bareSelectors, (bareSelector) => selector.replaceAll(canonicalSelector, bareSelector));
|
|
1793
|
+
});
|
|
1794
|
+
rule.selectors = selectors;
|
|
1795
|
+
});
|
|
1796
|
+
return root.toString();
|
|
1698
1797
|
}
|
|
1699
1798
|
function canonicalizeBareArbitraryValueCandidates(candidates, options) {
|
|
1700
1799
|
return Array.from(candidates, (candidate) => {
|
|
@@ -2226,6 +2325,25 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2226
2325
|
negated: source.negated
|
|
2227
2326
|
}));
|
|
2228
2327
|
};
|
|
2328
|
+
const addCandidates = async (extractOptions) => {
|
|
2329
|
+
const candidates = await extractValidCandidates(extractOptions);
|
|
2330
|
+
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2331
|
+
};
|
|
2332
|
+
if (v4Options.cssSources.length > 0) for (const source of v4Options.cssSources) {
|
|
2333
|
+
const sourceFile = toAbsolute(source.file);
|
|
2334
|
+
const sourceBase = toAbsolute(source.base) ?? (sourceFile ? pathe.default.dirname(sourceFile) : resolvedDefaultBase);
|
|
2335
|
+
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== sourceBase ? [sourceBase, resolvedConfiguredBase] : [sourceBase];
|
|
2336
|
+
const sources = resolveSources(sourceBase);
|
|
2337
|
+
const firstBase = designSystemBases[0] ?? sourceBase;
|
|
2338
|
+
await addCandidates({
|
|
2339
|
+
cwd: options.projectRoot,
|
|
2340
|
+
base: firstBase,
|
|
2341
|
+
baseFallbacks: designSystemBases.slice(1),
|
|
2342
|
+
css: source.css,
|
|
2343
|
+
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2344
|
+
...sources === void 0 ? {} : { sources }
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2229
2347
|
if (v4Options.cssEntries.length > 0) for (const entry of v4Options.cssEntries) {
|
|
2230
2348
|
const filePath = pathe.default.isAbsolute(entry) ? entry : pathe.default.resolve(options.projectRoot, entry);
|
|
2231
2349
|
if (!await fs_extra.default.pathExists(filePath)) continue;
|
|
@@ -2234,7 +2352,7 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2234
2352
|
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== entryDir ? [entryDir, resolvedConfiguredBase] : [entryDir];
|
|
2235
2353
|
const sources = resolveSources(resolvedConfiguredBase ?? entryDir);
|
|
2236
2354
|
const firstBase = designSystemBases[0] ?? entryDir;
|
|
2237
|
-
|
|
2355
|
+
await addCandidates({
|
|
2238
2356
|
cwd: options.projectRoot,
|
|
2239
2357
|
base: firstBase,
|
|
2240
2358
|
baseFallbacks: designSystemBases.slice(1),
|
|
@@ -2242,19 +2360,17 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2242
2360
|
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2243
2361
|
...sources === void 0 ? {} : { sources }
|
|
2244
2362
|
});
|
|
2245
|
-
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2246
2363
|
}
|
|
2247
|
-
else {
|
|
2364
|
+
else if (v4Options.cssSources.length === 0) {
|
|
2248
2365
|
const baseForCss = resolvedConfiguredBase ?? resolvedDefaultBase;
|
|
2249
2366
|
const sources = resolveSources(baseForCss);
|
|
2250
|
-
|
|
2367
|
+
await addCandidates({
|
|
2251
2368
|
cwd: options.projectRoot,
|
|
2252
2369
|
base: baseForCss,
|
|
2253
2370
|
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2254
2371
|
...v4Options.css === void 0 ? {} : { css: v4Options.css },
|
|
2255
2372
|
...sources === void 0 ? {} : { sources }
|
|
2256
2373
|
});
|
|
2257
|
-
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2258
2374
|
}
|
|
2259
2375
|
return set;
|
|
2260
2376
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CAC, Command } from "cac";
|
|
2
1
|
import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
3
|
-
import
|
|
2
|
+
import * as _$consola from "consola";
|
|
4
3
|
import { Node, Rule } from "postcss";
|
|
4
|
+
import { CAC, Command } from "cac";
|
|
5
|
+
import { SourceEntry } from "@tailwindcss/oxide";
|
|
5
6
|
import { Config } from "tailwindcss";
|
|
6
|
-
import * as _$consola from "consola";
|
|
7
|
-
|
|
8
7
|
//#region src/cache/types.d.ts
|
|
9
8
|
declare const CACHE_SCHEMA_VERSION = 2;
|
|
10
9
|
declare const CACHE_FINGERPRINT_VERSION = 1;
|
|
@@ -159,6 +158,78 @@ interface PatchStatusReport {
|
|
|
159
158
|
entries: PatchStatusEntry[];
|
|
160
159
|
}
|
|
161
160
|
//#endregion
|
|
161
|
+
//#region src/v4/types.d.ts
|
|
162
|
+
interface TailwindV4SourceOptions {
|
|
163
|
+
projectRoot?: string;
|
|
164
|
+
cwd?: string;
|
|
165
|
+
base?: string;
|
|
166
|
+
baseFallbacks?: string[];
|
|
167
|
+
css?: string;
|
|
168
|
+
cssSources?: TailwindV4CssSource[];
|
|
169
|
+
cssEntries?: string[];
|
|
170
|
+
packageName?: string;
|
|
171
|
+
}
|
|
172
|
+
interface TailwindV4CssSource {
|
|
173
|
+
css: string;
|
|
174
|
+
base?: string;
|
|
175
|
+
file?: string;
|
|
176
|
+
dependencies?: string[];
|
|
177
|
+
}
|
|
178
|
+
interface TailwindV4ResolvedSource {
|
|
179
|
+
projectRoot: string;
|
|
180
|
+
base: string;
|
|
181
|
+
baseFallbacks: string[];
|
|
182
|
+
css: string;
|
|
183
|
+
dependencies: string[];
|
|
184
|
+
}
|
|
185
|
+
interface TailwindV4CandidateSource {
|
|
186
|
+
content: string;
|
|
187
|
+
extension?: string;
|
|
188
|
+
}
|
|
189
|
+
interface TailwindV4GenerateOptions {
|
|
190
|
+
candidates?: Iterable<string>;
|
|
191
|
+
sources?: TailwindV4CandidateSource[];
|
|
192
|
+
/**
|
|
193
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
194
|
+
*/
|
|
195
|
+
bareArbitraryValues?: boolean | {
|
|
196
|
+
units?: string[];
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* 扫描文件系统 source entries 中的候选类名。
|
|
200
|
+
*
|
|
201
|
+
* - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
|
|
202
|
+
* - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
|
|
203
|
+
*/
|
|
204
|
+
scanSources?: boolean | TailwindV4SourcePattern[];
|
|
205
|
+
}
|
|
206
|
+
interface TailwindV4SourcePattern {
|
|
207
|
+
base: string;
|
|
208
|
+
pattern: string;
|
|
209
|
+
negated: boolean;
|
|
210
|
+
}
|
|
211
|
+
interface TailwindV4GenerateResult {
|
|
212
|
+
css: string;
|
|
213
|
+
classSet: Set<string>;
|
|
214
|
+
rawCandidates: Set<string>;
|
|
215
|
+
dependencies: string[];
|
|
216
|
+
sources: TailwindV4SourcePattern[];
|
|
217
|
+
root: null | 'none' | {
|
|
218
|
+
base: string;
|
|
219
|
+
pattern: string;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
interface TailwindV4DesignSystem {
|
|
223
|
+
parseCandidate: (candidate: string) => unknown[];
|
|
224
|
+
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
225
|
+
}
|
|
226
|
+
interface TailwindV4Engine {
|
|
227
|
+
source: TailwindV4ResolvedSource;
|
|
228
|
+
loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
|
|
229
|
+
validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
|
|
230
|
+
generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
162
233
|
//#region src/options/types.d.ts
|
|
163
234
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
164
235
|
type CacheDriver = 'file' | 'memory' | 'noop';
|
|
@@ -246,6 +317,8 @@ interface TailwindV4Options {
|
|
|
246
317
|
base?: string;
|
|
247
318
|
/** Raw CSS passed directly to the v4 design system. */
|
|
248
319
|
css?: string;
|
|
320
|
+
/** 构建器在 CSS 落盘前捕获的内存 CSS 入口。 */
|
|
321
|
+
cssSources?: TailwindV4CssSource[];
|
|
249
322
|
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
250
323
|
cssEntries?: string[];
|
|
251
324
|
/** Overrides the content sources scanned by the oxide scanner. */
|
|
@@ -328,6 +401,7 @@ interface NormalizedTailwindV4Options {
|
|
|
328
401
|
base: string;
|
|
329
402
|
configuredBase?: string;
|
|
330
403
|
css?: string;
|
|
404
|
+
cssSources: TailwindV4CssSource[];
|
|
331
405
|
cssEntries: string[];
|
|
332
406
|
sources: SourceEntry[];
|
|
333
407
|
hasUserDefinedSources: boolean;
|
|
@@ -699,4 +773,4 @@ declare class ValidateCommandError extends Error {
|
|
|
699
773
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
700
774
|
}
|
|
701
775
|
//#endregion
|
|
702
|
-
export {
|
|
776
|
+
export { TailwindV4SourceOptions as $, groupTokensByFile as A, NormalizedTailwindCssPatchOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, extractRawCandidates as D, extractProjectCandidatesWithPositions as E, CacheStrategy as F, TailwindV4Options as G, TailwindCssPatchOptions as H, ExposeContextOptions as I, TailwindV4DesignSystem as J, TailwindV4CandidateSource as K, ExtendLengthUnitsOptions as L, normalizeOptions as M, ApplyOptions as N, extractRawCandidatesWithPositions as O, CacheOptions as P, TailwindV4ResolvedSource as Q, ExtractOptions as R, MIGRATION_REPORT_KIND as S, TailwindcssPatcher as T, TailwindV2Options as U, TailwindCssOptions as V, TailwindV3Options as W, TailwindV4GenerateOptions as X, TailwindV4Engine as Y, TailwindV4GenerateResult as Z, ConfigFileMigrationEntry as _, CacheContextMetadata as _t, ValidateFailureSummary as a, PatchStatusReport as at, RestoreConfigFilesOptions as b, CacheReadResult as bt, TailwindcssPatchCliMountOptions as c, TailwindTokenFileKey as ct, TailwindcssPatchCommandContext as d, TailwindcssClassCache as dt, ExtractResult as et, TailwindcssPatchCommandHandler as f, TailwindcssRuntimeContext as ft, tailwindcssPatchCommands as g, CacheContextDescriptor as gt, TailwindcssPatchCommandOptions as h, CacheClearScope as ht, ValidateFailureReason as i, PatchStatusEntry as it, BareArbitraryValueOptions as j, extractValidCandidates as k, TailwindcssPatchCliOptions as l, TailwindTokenLocation as lt, TailwindcssPatchCommandOptionDefinition as m, CacheClearResult as mt, VALIDATE_FAILURE_REASONS as n, PatchCheckStatus as nt, ValidateJsonFailurePayload as o, TailwindPatchRuntime as ot, TailwindcssPatchCommandHandlerMap as p, CacheClearOptions as pt, TailwindV4CssSource as q, ValidateCommandError as r, PatchName as rt, ValidateJsonSuccessPayload as s, TailwindTokenByFileMap as st, VALIDATE_EXIT_CODES as t, ILengthUnitsPatchOptions as tt, TailwindcssPatchCommand as u, TailwindTokenReport as ut, ConfigFileMigrationReport as v, CacheIndexFileV2 as vt, logger as w, RestoreConfigFilesResult as x, MigrateConfigFilesOptions as y, CacheReadMeta as yt, NormalizedCacheOptions as z };
|