tailwindcss-patch 8.7.3 → 9.0.0-alpha.1
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 +45 -5
- package/dist/{chunk-7JAOSSRO.js → chunk-5CWNAWKP.js} +1 -1
- package/dist/{chunk-JHEI2MLC.mjs → chunk-A67ABH3M.mjs} +1 -1
- package/dist/{chunk-3T6WSV7F.mjs → chunk-SWLOK2S6.mjs} +476 -315
- package/dist/{chunk-EFYAZO6C.js → chunk-Z6OMJZTU.js} +456 -295
- package/dist/cli.js +5 -5
- package/dist/cli.mjs +2 -2
- package/dist/{dist-NW65QXLC.js → dist-7O2232CU.js} +1 -1
- package/dist/{dist-EMUBVNNO.mjs → dist-7UDSGIWH.mjs} +1 -1
- package/dist/index.d.mts +15 -107
- package/dist/index.d.ts +15 -107
- package/dist/index.js +6 -4
- package/dist/index.mjs +5 -3
- package/package.json +6 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5CWNAWKPjs = require('./chunk-5CWNAWKP.js');
|
|
4
4
|
|
|
5
5
|
// src/logger.ts
|
|
6
6
|
var _consola = require('consola');
|
|
@@ -20,7 +20,7 @@ var _pathe = require('pathe'); var _pathe2 = _interopRequireDefault(_pathe);
|
|
|
20
20
|
// package.json
|
|
21
21
|
var package_default = {
|
|
22
22
|
name: "tailwindcss-patch",
|
|
23
|
-
version: "
|
|
23
|
+
version: "9.0.0-alpha.1",
|
|
24
24
|
description: "patch tailwindcss for exposing context and extract classes",
|
|
25
25
|
author: "ice breaker <1324318532@qq.com>",
|
|
26
26
|
license: "MIT",
|
|
@@ -41,17 +41,17 @@ var package_default = {
|
|
|
41
41
|
],
|
|
42
42
|
exports: {
|
|
43
43
|
".": {
|
|
44
|
-
types: "./
|
|
45
|
-
import: "./
|
|
46
|
-
require: "./
|
|
44
|
+
types: "./src/index.ts",
|
|
45
|
+
import: "./src/index.ts",
|
|
46
|
+
require: "./src/index.ts"
|
|
47
47
|
},
|
|
48
48
|
"./migration-report.schema.json": "./schema/migration-report.schema.json",
|
|
49
49
|
"./restore-result.schema.json": "./schema/restore-result.schema.json",
|
|
50
50
|
"./validate-result.schema.json": "./schema/validate-result.schema.json"
|
|
51
51
|
},
|
|
52
|
-
main: "./
|
|
53
|
-
module: "./
|
|
54
|
-
types: "./
|
|
52
|
+
main: "./src/index.ts",
|
|
53
|
+
module: "./src/index.ts",
|
|
54
|
+
types: "./src/index.ts",
|
|
55
55
|
bin: {
|
|
56
56
|
"tw-patch": "dev/bin.ts",
|
|
57
57
|
"tailwindcss-patch": "dev/bin.ts"
|
|
@@ -66,6 +66,7 @@ var package_default = {
|
|
|
66
66
|
build: "tsup",
|
|
67
67
|
test: "vitest run",
|
|
68
68
|
"test:dev": "vitest",
|
|
69
|
+
"bench:cold-start": "node --import tsx bench/cold-start.ts",
|
|
69
70
|
patch: "tsx dev/bin.ts install",
|
|
70
71
|
r0: "tsx dev/bin.ts extract",
|
|
71
72
|
r1: "tsx dev/bin.ts extract --css index.css"
|
|
@@ -106,12 +107,12 @@ var package_default = {
|
|
|
106
107
|
"@babel/types": "^7.29.0",
|
|
107
108
|
"@tailwindcss-mangle/config": "workspace:*",
|
|
108
109
|
"@tailwindcss/node": "^4.2.1",
|
|
109
|
-
cac: "^
|
|
110
|
+
cac: "^7.0.0",
|
|
110
111
|
consola: "^3.4.2",
|
|
111
|
-
"fs-extra": "^11.3.
|
|
112
|
+
"fs-extra": "^11.3.4",
|
|
112
113
|
"local-pkg": "^1.1.2",
|
|
113
114
|
pathe: "^2.0.3",
|
|
114
|
-
postcss: "^8.5.
|
|
115
|
+
postcss: "^8.5.8",
|
|
115
116
|
semver: "^7.7.4",
|
|
116
117
|
"tailwindcss-config": "^1.1.4"
|
|
117
118
|
},
|
|
@@ -1515,14 +1516,6 @@ ${Date.now()}`, { flag: "wx" });
|
|
|
1515
1516
|
|
|
1516
1517
|
|
|
1517
1518
|
|
|
1518
|
-
var hasWarnedDeprecatedOptions = false;
|
|
1519
|
-
var deprecatedOptionMapping = {
|
|
1520
|
-
cwd: "projectRoot",
|
|
1521
|
-
overwrite: "apply.overwrite",
|
|
1522
|
-
tailwind: "tailwindcss",
|
|
1523
|
-
features: "apply",
|
|
1524
|
-
output: "extract"
|
|
1525
|
-
};
|
|
1526
1519
|
function resolveRealpathSafe(value) {
|
|
1527
1520
|
const resolved = _pathe2.default.resolve(value);
|
|
1528
1521
|
try {
|
|
@@ -1667,66 +1660,32 @@ function normalizeTailwindOptions(tailwind, projectRoot) {
|
|
|
1667
1660
|
v4
|
|
1668
1661
|
};
|
|
1669
1662
|
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
const
|
|
1679
|
-
const pretty = _nullishCoalesce(_optionalChain([options, 'access', _64 => _64.extract, 'optionalAccess', _65 => _65.pretty]), () => ( _optionalChain([options, 'access', _66 => _66.output, 'optionalAccess', _67 => _67.pretty])));
|
|
1680
|
-
const removeUniversalSelector = _nullishCoalesce(_optionalChain([options, 'access', _68 => _68.extract, 'optionalAccess', _69 => _69.removeUniversalSelector]), () => ( _optionalChain([options, 'access', _70 => _70.output, 'optionalAccess', _71 => _71.removeUniversalSelector])));
|
|
1681
|
-
const extract = {
|
|
1682
|
-
...write === void 0 ? {} : { write },
|
|
1683
|
-
...file === void 0 ? {} : { file },
|
|
1684
|
-
...format === void 0 ? {} : { format },
|
|
1685
|
-
...pretty === void 0 ? {} : { pretty },
|
|
1686
|
-
...removeUniversalSelector === void 0 ? {} : { removeUniversalSelector }
|
|
1687
|
-
};
|
|
1688
|
-
return {
|
|
1689
|
-
...projectRoot === void 0 ? {} : { projectRoot },
|
|
1690
|
-
...overwrite === void 0 ? {} : { overwrite },
|
|
1691
|
-
...tailwind === void 0 ? {} : { tailwind },
|
|
1692
|
-
...Object.keys(extract).length === 0 ? {} : { extract },
|
|
1693
|
-
...exposeContext === void 0 ? {} : { exposeContext },
|
|
1694
|
-
...extendLengthUnits === void 0 ? {} : { extendLengthUnits }
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
function findUsedDeprecatedOptions(options) {
|
|
1698
|
-
const result = [];
|
|
1699
|
-
for (const key of Object.keys(deprecatedOptionMapping)) {
|
|
1700
|
-
if (options[key] !== void 0) {
|
|
1701
|
-
result.push(key);
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
return result;
|
|
1705
|
-
}
|
|
1706
|
-
function warnDeprecatedOptionsIfNeeded(options) {
|
|
1707
|
-
if (hasWarnedDeprecatedOptions) {
|
|
1708
|
-
return;
|
|
1709
|
-
}
|
|
1710
|
-
const used = findUsedDeprecatedOptions(options);
|
|
1663
|
+
var deprecatedOptionMapping = {
|
|
1664
|
+
cwd: "projectRoot",
|
|
1665
|
+
overwrite: "apply.overwrite",
|
|
1666
|
+
tailwind: "tailwindcss",
|
|
1667
|
+
features: "apply",
|
|
1668
|
+
output: "extract"
|
|
1669
|
+
};
|
|
1670
|
+
function assertNoDeprecatedOptions(options) {
|
|
1671
|
+
const used = Object.keys(deprecatedOptionMapping).filter((key) => Object.prototype.hasOwnProperty.call(options, key));
|
|
1711
1672
|
if (used.length === 0) {
|
|
1712
1673
|
return;
|
|
1713
1674
|
}
|
|
1714
|
-
hasWarnedDeprecatedOptions = true;
|
|
1715
1675
|
const mapping = used.map((key) => `${key} -> ${deprecatedOptionMapping[key]}`).join(", ");
|
|
1716
|
-
|
|
1717
|
-
`
|
|
1676
|
+
throw new Error(
|
|
1677
|
+
`Legacy TailwindcssPatcher options are no longer supported: ${used.join(", ")}. Use the modern fields instead: ${mapping}.`
|
|
1718
1678
|
);
|
|
1719
1679
|
}
|
|
1720
1680
|
function normalizeOptions(options = {}) {
|
|
1721
|
-
|
|
1722
|
-
const
|
|
1723
|
-
const
|
|
1724
|
-
const
|
|
1725
|
-
const output = normalizeOutputOptions(resolved.extract);
|
|
1681
|
+
assertNoDeprecatedOptions(options);
|
|
1682
|
+
const projectRoot = resolveRealpathSafe(options.projectRoot ? _pathe2.default.resolve(options.projectRoot) : _process2.default.cwd());
|
|
1683
|
+
const overwrite = _nullishCoalesce(_optionalChain([options, 'access', _42 => _42.apply, 'optionalAccess', _43 => _43.overwrite]), () => ( true));
|
|
1684
|
+
const output = normalizeOutputOptions(options.extract);
|
|
1726
1685
|
const cache = normalizeCacheOptions(options.cache, projectRoot);
|
|
1727
|
-
const tailwind = normalizeTailwindOptions(
|
|
1728
|
-
const exposeContext = normalizeExposeContextOptions(
|
|
1729
|
-
const extendLengthUnits = normalizeExtendLengthUnitsOptions(
|
|
1686
|
+
const tailwind = normalizeTailwindOptions(options.tailwindcss, projectRoot);
|
|
1687
|
+
const exposeContext = normalizeExposeContextOptions(_optionalChain([options, 'access', _44 => _44.apply, 'optionalAccess', _45 => _45.exposeContext]));
|
|
1688
|
+
const extendLengthUnits = normalizeExtendLengthUnitsOptions(_optionalChain([options, 'access', _46 => _46.apply, 'optionalAccess', _47 => _47.extendLengthUnits]));
|
|
1730
1689
|
const filter = (className) => {
|
|
1731
1690
|
if (output.removeUniversalSelector && className === "*") {
|
|
1732
1691
|
return false;
|
|
@@ -1751,122 +1710,70 @@ function normalizeOptions(options = {}) {
|
|
|
1751
1710
|
}
|
|
1752
1711
|
|
|
1753
1712
|
// src/options/legacy.ts
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1713
|
+
var deprecatedRegistryMapping = {
|
|
1714
|
+
output: "extract",
|
|
1715
|
+
tailwind: "tailwindcss"
|
|
1716
|
+
};
|
|
1717
|
+
var deprecatedTailwindMapping = {
|
|
1718
|
+
package: "packageName",
|
|
1719
|
+
legacy: "v2",
|
|
1720
|
+
classic: "v3",
|
|
1721
|
+
next: "v4"
|
|
1722
|
+
};
|
|
1723
|
+
function assertNoDeprecatedRegistryOptions(registry) {
|
|
1724
|
+
const usedRegistryKeys = Object.keys(deprecatedRegistryMapping).filter((key) => Object.prototype.hasOwnProperty.call(registry, key));
|
|
1725
|
+
if (usedRegistryKeys.length > 0) {
|
|
1726
|
+
const mapping = usedRegistryKeys.map((key) => `${key} -> ${deprecatedRegistryMapping[key]}`).join(", ");
|
|
1727
|
+
throw new Error(
|
|
1728
|
+
`Legacy registry fields are no longer supported: ${usedRegistryKeys.join(", ")}. Use the modern fields instead: ${mapping}.`
|
|
1729
|
+
);
|
|
1769
1730
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1731
|
+
const tailwind = registry.tailwindcss;
|
|
1732
|
+
if (!tailwind) {
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
const usedTailwindKeys = Object.keys(deprecatedTailwindMapping).filter((key) => Object.prototype.hasOwnProperty.call(tailwind, key));
|
|
1736
|
+
if (usedTailwindKeys.length > 0) {
|
|
1737
|
+
const mapping = usedTailwindKeys.map((key) => `${key} -> tailwindcss.${deprecatedTailwindMapping[key]}`).join(", ");
|
|
1738
|
+
throw new Error(
|
|
1739
|
+
`Legacy "registry.tailwindcss" fields are no longer supported: ${usedTailwindKeys.join(", ")}. Use the modern fields instead: ${mapping}.`
|
|
1740
|
+
);
|
|
1778
1741
|
}
|
|
1779
|
-
const patch = options.patch;
|
|
1780
|
-
const features = normalizeLegacyFeatures(patch);
|
|
1781
|
-
const output = _optionalChain([patch, 'optionalAccess', _76 => _76.output]);
|
|
1782
|
-
const tailwindConfig = _optionalChain([patch, 'optionalAccess', _77 => _77.tailwindcss]);
|
|
1783
|
-
const tailwindVersion = _optionalChain([tailwindConfig, 'optionalAccess', _78 => _78.version]);
|
|
1784
|
-
const tailwindV2 = _optionalChain([tailwindConfig, 'optionalAccess', _79 => _79.v2]);
|
|
1785
|
-
const tailwindV3 = _optionalChain([tailwindConfig, 'optionalAccess', _80 => _80.v3]);
|
|
1786
|
-
const tailwindV4 = _optionalChain([tailwindConfig, 'optionalAccess', _81 => _81.v4]);
|
|
1787
|
-
const tailwindConfigPath = _nullishCoalesce(_optionalChain([tailwindV3, 'optionalAccess', _82 => _82.config]), () => ( _optionalChain([tailwindV2, 'optionalAccess', _83 => _83.config])));
|
|
1788
|
-
const tailwindCwd = _nullishCoalesce(_nullishCoalesce(_optionalChain([tailwindV3, 'optionalAccess', _84 => _84.cwd]), () => ( _optionalChain([tailwindV2, 'optionalAccess', _85 => _85.cwd]))), () => ( _optionalChain([patch, 'optionalAccess', _86 => _86.cwd])));
|
|
1789
|
-
const normalizedExtract = output ? {
|
|
1790
|
-
...output.filename === void 0 ? {} : { file: output.filename },
|
|
1791
|
-
pretty: output.loose ? 2 : false,
|
|
1792
|
-
...output.removeUniversalSelector === void 0 ? {} : { removeUniversalSelector: output.removeUniversalSelector }
|
|
1793
|
-
} : void 0;
|
|
1794
|
-
const normalizedTailwindcss = {
|
|
1795
|
-
..._optionalChain([patch, 'optionalAccess', _87 => _87.packageName]) === void 0 ? {} : { packageName: patch.packageName },
|
|
1796
|
-
...tailwindVersion === void 0 ? {} : { version: tailwindVersion },
|
|
1797
|
-
..._optionalChain([patch, 'optionalAccess', _88 => _88.resolve]) === void 0 ? {} : { resolve: patch.resolve },
|
|
1798
|
-
...tailwindConfigPath === void 0 ? {} : { config: tailwindConfigPath },
|
|
1799
|
-
...tailwindCwd === void 0 ? {} : { cwd: tailwindCwd },
|
|
1800
|
-
...tailwindV2 === void 0 ? {} : { v2: tailwindV2 },
|
|
1801
|
-
...tailwindV3 === void 0 ? {} : { v3: tailwindV3 },
|
|
1802
|
-
...tailwindV4 === void 0 ? {} : { v4: tailwindV4 }
|
|
1803
|
-
};
|
|
1804
|
-
const normalizedCache = typeof options.cache === "boolean" ? options.cache : options.cache ? {
|
|
1805
|
-
...options.cache,
|
|
1806
|
-
enabled: _nullishCoalesce(options.cache.enabled, () => ( true))
|
|
1807
|
-
} : void 0;
|
|
1808
|
-
const normalizedApply = {
|
|
1809
|
-
..._optionalChain([patch, 'optionalAccess', _89 => _89.overwrite]) === void 0 ? {} : { overwrite: patch.overwrite },
|
|
1810
|
-
exposeContext: features.exposeContext,
|
|
1811
|
-
extendLengthUnits: features.extendLengthUnits
|
|
1812
|
-
};
|
|
1813
|
-
return {
|
|
1814
|
-
..._optionalChain([patch, 'optionalAccess', _90 => _90.cwd]) === void 0 ? {} : { projectRoot: patch.cwd },
|
|
1815
|
-
..._optionalChain([patch, 'optionalAccess', _91 => _91.filter]) === void 0 ? {} : { filter: patch.filter },
|
|
1816
|
-
...normalizedCache === void 0 ? {} : { cache: normalizedCache },
|
|
1817
|
-
...normalizedExtract === void 0 ? {} : { extract: normalizedExtract },
|
|
1818
|
-
...Object.keys(normalizedTailwindcss).length === 0 ? {} : { tailwindcss: normalizedTailwindcss },
|
|
1819
|
-
apply: normalizedApply
|
|
1820
|
-
};
|
|
1821
1742
|
}
|
|
1822
1743
|
function fromUnifiedConfig(registry) {
|
|
1823
1744
|
if (!registry) {
|
|
1824
1745
|
return {};
|
|
1825
1746
|
}
|
|
1826
|
-
|
|
1827
|
-
const
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
}
|
|
1834
|
-
if (typeof value === "boolean") {
|
|
1835
|
-
return value ? 2 : false;
|
|
1836
|
-
}
|
|
1837
|
-
return value;
|
|
1838
|
-
})();
|
|
1839
|
-
const removeUniversalSelector = _nullishCoalesce(_optionalChain([modernExtract, 'optionalAccess', _94 => _94.removeUniversalSelector]), () => ( _optionalChain([legacyOutput, 'optionalAccess', _95 => _95.stripUniversalSelector])));
|
|
1840
|
-
const outputFile = _nullishCoalesce(_optionalChain([modernExtract, 'optionalAccess', _96 => _96.file]), () => ( _optionalChain([legacyOutput, 'optionalAccess', _97 => _97.file])));
|
|
1841
|
-
const normalizedExtract = modernExtract || legacyOutput ? {
|
|
1842
|
-
..._optionalChain([modernExtract, 'optionalAccess', _98 => _98.write]) === void 0 ? {} : { write: modernExtract.write },
|
|
1843
|
-
...outputFile === void 0 ? {} : { file: outputFile },
|
|
1844
|
-
...pretty === void 0 ? {} : { pretty },
|
|
1845
|
-
...removeUniversalSelector === void 0 ? {} : { removeUniversalSelector },
|
|
1846
|
-
..._optionalChain([modernExtract, 'optionalAccess', _99 => _99.format]) === void 0 ? {} : { format: modernExtract.format }
|
|
1747
|
+
assertNoDeprecatedRegistryOptions(registry);
|
|
1748
|
+
const extract = registry.extract ? {
|
|
1749
|
+
...registry.extract.write === void 0 ? {} : { write: registry.extract.write },
|
|
1750
|
+
...registry.extract.file === void 0 ? {} : { file: registry.extract.file },
|
|
1751
|
+
...registry.extract.format === void 0 ? {} : { format: registry.extract.format },
|
|
1752
|
+
...registry.extract.pretty === void 0 ? {} : { pretty: registry.extract.pretty },
|
|
1753
|
+
...registry.extract.removeUniversalSelector === void 0 ? {} : { removeUniversalSelector: registry.extract.removeUniversalSelector }
|
|
1847
1754
|
} : void 0;
|
|
1848
|
-
const
|
|
1849
|
-
...
|
|
1850
|
-
...
|
|
1851
|
-
...
|
|
1852
|
-
...
|
|
1853
|
-
...
|
|
1854
|
-
...
|
|
1855
|
-
...
|
|
1856
|
-
...
|
|
1755
|
+
const tailwindcss = registry.tailwindcss ? {
|
|
1756
|
+
...registry.tailwindcss.version === void 0 ? {} : { version: registry.tailwindcss.version },
|
|
1757
|
+
...registry.tailwindcss.packageName === void 0 ? {} : { packageName: registry.tailwindcss.packageName },
|
|
1758
|
+
...registry.tailwindcss.resolve === void 0 ? {} : { resolve: registry.tailwindcss.resolve },
|
|
1759
|
+
...registry.tailwindcss.config === void 0 ? {} : { config: registry.tailwindcss.config },
|
|
1760
|
+
...registry.tailwindcss.cwd === void 0 ? {} : { cwd: registry.tailwindcss.cwd },
|
|
1761
|
+
...registry.tailwindcss.v2 === void 0 ? {} : { v2: registry.tailwindcss.v2 },
|
|
1762
|
+
...registry.tailwindcss.v3 === void 0 ? {} : { v3: registry.tailwindcss.v3 },
|
|
1763
|
+
...registry.tailwindcss.v4 === void 0 ? {} : { v4: registry.tailwindcss.v4 }
|
|
1857
1764
|
} : void 0;
|
|
1858
|
-
const
|
|
1765
|
+
const apply = registry.apply ? {
|
|
1859
1766
|
...registry.apply.overwrite === void 0 ? {} : { overwrite: registry.apply.overwrite },
|
|
1860
1767
|
...registry.apply.exposeContext === void 0 ? {} : { exposeContext: registry.apply.exposeContext },
|
|
1861
1768
|
...registry.apply.extendLengthUnits === void 0 ? {} : { extendLengthUnits: registry.apply.extendLengthUnits }
|
|
1862
1769
|
} : void 0;
|
|
1863
1770
|
return {
|
|
1864
1771
|
...registry.projectRoot === void 0 ? {} : { projectRoot: registry.projectRoot },
|
|
1865
|
-
...
|
|
1772
|
+
...apply === void 0 ? {} : { apply },
|
|
1866
1773
|
...registry.cache === void 0 ? {} : { cache: registry.cache },
|
|
1867
1774
|
...registry.filter === void 0 ? {} : { filter: registry.filter },
|
|
1868
|
-
...
|
|
1869
|
-
...
|
|
1775
|
+
...extract === void 0 ? {} : { extract },
|
|
1776
|
+
...tailwindcss === void 0 ? {} : { tailwindcss }
|
|
1870
1777
|
};
|
|
1871
1778
|
}
|
|
1872
1779
|
|
|
@@ -1878,19 +1785,22 @@ var defuPromise;
|
|
|
1878
1785
|
function isNodeError(error) {
|
|
1879
1786
|
return !!error && typeof error === "object" && ("code" in error || "message" in error);
|
|
1880
1787
|
}
|
|
1881
|
-
function
|
|
1882
|
-
if (!isNodeError(error)
|
|
1788
|
+
function isMissingModuleError(error, pkgName2) {
|
|
1789
|
+
if (!isNodeError(error)) {
|
|
1883
1790
|
return false;
|
|
1884
1791
|
}
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
}
|
|
1888
|
-
function isMissingSharedModuleError(error) {
|
|
1889
|
-
if (!isNodeError(error) || error.code !== "MODULE_NOT_FOUND") {
|
|
1792
|
+
const code = error.code;
|
|
1793
|
+
if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") {
|
|
1890
1794
|
return false;
|
|
1891
1795
|
}
|
|
1892
1796
|
const message = _nullishCoalesce(error.message, () => ( ""));
|
|
1893
|
-
return message.includes(
|
|
1797
|
+
return message.includes(pkgName2) || message.includes(`${pkgName2}/dist/`);
|
|
1798
|
+
}
|
|
1799
|
+
function isMissingConfigModuleError(error) {
|
|
1800
|
+
return isMissingModuleError(error, "@tailwindcss-mangle/config");
|
|
1801
|
+
}
|
|
1802
|
+
function isMissingSharedModuleError(error) {
|
|
1803
|
+
return isMissingModuleError(error, "@tailwindcss-mangle/shared");
|
|
1894
1804
|
}
|
|
1895
1805
|
async function loadWorkspaceConfigModule() {
|
|
1896
1806
|
if (!configModulePromise) {
|
|
@@ -1906,7 +1816,7 @@ async function loadWorkspaceConfigModule() {
|
|
|
1906
1816
|
}
|
|
1907
1817
|
async function loadWorkspaceDefu() {
|
|
1908
1818
|
if (!defuPromise) {
|
|
1909
|
-
defuPromise = Promise.resolve().then(() => _interopRequireWildcard(require("./dist-
|
|
1819
|
+
defuPromise = Promise.resolve().then(() => _interopRequireWildcard(require("./dist-7O2232CU.js"))).then((mod) => mod.defu).catch(async (error) => {
|
|
1910
1820
|
if (!isMissingSharedModuleError(error)) {
|
|
1911
1821
|
throw error;
|
|
1912
1822
|
}
|
|
@@ -1921,8 +1831,10 @@ async function loadPatchOptionsForWorkspace(cwd, overrides) {
|
|
|
1921
1831
|
const merge = await loadWorkspaceDefu();
|
|
1922
1832
|
const configModule = await loadWorkspaceConfigModule();
|
|
1923
1833
|
const { config } = await configModule.getConfig(cwd);
|
|
1924
|
-
|
|
1925
|
-
|
|
1834
|
+
if (config && typeof config === "object" && "patch" in config && config.patch !== void 0) {
|
|
1835
|
+
throw new Error('Legacy workspace config field "patch" is no longer supported. Move patcher options under "registry".');
|
|
1836
|
+
}
|
|
1837
|
+
const base = _optionalChain([config, 'optionalAccess', _48 => _48.registry]) ? fromUnifiedConfig(config.registry) : {};
|
|
1926
1838
|
const merged = merge(_nullishCoalesce(overrides, () => ( {})), base);
|
|
1927
1839
|
return merged;
|
|
1928
1840
|
}
|
|
@@ -1931,33 +1843,66 @@ async function loadPatchOptionsForWorkspace(cwd, overrides) {
|
|
|
1931
1843
|
var _fs = require('fs');
|
|
1932
1844
|
|
|
1933
1845
|
|
|
1846
|
+
var nodeImportPromise;
|
|
1847
|
+
var oxideImportPromise;
|
|
1848
|
+
var designSystemPromiseCache = /* @__PURE__ */ new Map();
|
|
1849
|
+
var designSystemCandidateCache = /* @__PURE__ */ new Map();
|
|
1934
1850
|
async function importNode() {
|
|
1935
1851
|
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/node")));
|
|
1936
1852
|
}
|
|
1937
1853
|
async function importOxide() {
|
|
1938
1854
|
return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/oxide")));
|
|
1939
1855
|
}
|
|
1856
|
+
function getNodeModule() {
|
|
1857
|
+
nodeImportPromise ??= importNode();
|
|
1858
|
+
return nodeImportPromise;
|
|
1859
|
+
}
|
|
1860
|
+
function getOxideModule() {
|
|
1861
|
+
oxideImportPromise ??= importOxide();
|
|
1862
|
+
return oxideImportPromise;
|
|
1863
|
+
}
|
|
1864
|
+
function createDesignSystemCacheKey(css, bases) {
|
|
1865
|
+
return JSON.stringify({
|
|
1866
|
+
css,
|
|
1867
|
+
bases: Array.from(new Set(bases.filter(Boolean)))
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1940
1870
|
async function loadDesignSystem(css, bases) {
|
|
1941
1871
|
const uniqueBases = Array.from(new Set(bases.filter(Boolean)));
|
|
1942
1872
|
if (uniqueBases.length === 0) {
|
|
1943
1873
|
throw new Error("No base directories provided for Tailwind CSS design system.");
|
|
1944
1874
|
}
|
|
1945
|
-
const
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
return await __unstable__loadDesignSystem(css, { base });
|
|
1950
|
-
} catch (error) {
|
|
1951
|
-
lastError = error;
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
if (lastError instanceof Error) {
|
|
1955
|
-
throw lastError;
|
|
1875
|
+
const cacheKey = createDesignSystemCacheKey(css, uniqueBases);
|
|
1876
|
+
const cached = designSystemPromiseCache.get(cacheKey);
|
|
1877
|
+
if (cached) {
|
|
1878
|
+
return cached;
|
|
1956
1879
|
}
|
|
1957
|
-
|
|
1880
|
+
const promise = (async () => {
|
|
1881
|
+
const { __unstable__loadDesignSystem } = await getNodeModule();
|
|
1882
|
+
let lastError;
|
|
1883
|
+
for (const base of uniqueBases) {
|
|
1884
|
+
try {
|
|
1885
|
+
return await __unstable__loadDesignSystem(css, { base });
|
|
1886
|
+
} catch (error) {
|
|
1887
|
+
lastError = error;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
if (lastError instanceof Error) {
|
|
1891
|
+
throw lastError;
|
|
1892
|
+
}
|
|
1893
|
+
throw new Error("Failed to load Tailwind CSS design system.");
|
|
1894
|
+
})();
|
|
1895
|
+
designSystemPromiseCache.set(cacheKey, promise);
|
|
1896
|
+
promise.catch(() => {
|
|
1897
|
+
if (designSystemPromiseCache.get(cacheKey) === promise) {
|
|
1898
|
+
designSystemPromiseCache.delete(cacheKey);
|
|
1899
|
+
designSystemCandidateCache.delete(cacheKey);
|
|
1900
|
+
}
|
|
1901
|
+
});
|
|
1902
|
+
return promise;
|
|
1958
1903
|
}
|
|
1959
1904
|
async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
1960
|
-
const { Scanner } = await
|
|
1905
|
+
const { Scanner } = await getOxideModule();
|
|
1961
1906
|
const scanner = new Scanner({});
|
|
1962
1907
|
const result = scanner.getCandidatesWithPositions({ content, extension });
|
|
1963
1908
|
return result.map(({ candidate, position }) => ({
|
|
@@ -1967,7 +1912,7 @@ async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
|
1967
1912
|
}));
|
|
1968
1913
|
}
|
|
1969
1914
|
async function extractRawCandidates(sources) {
|
|
1970
|
-
const { Scanner } = await
|
|
1915
|
+
const { Scanner } = await getOxideModule();
|
|
1971
1916
|
const scanner = new Scanner(sources === void 0 ? {} : { sources });
|
|
1972
1917
|
return scanner.scan();
|
|
1973
1918
|
}
|
|
@@ -1988,30 +1933,49 @@ async function extractValidCandidates(options) {
|
|
|
1988
1933
|
pattern: source.pattern,
|
|
1989
1934
|
negated: source.negated
|
|
1990
1935
|
}));
|
|
1936
|
+
const designSystemKey = createDesignSystemCacheKey(css, [base, ...baseFallbacks]);
|
|
1991
1937
|
const designSystem = await loadDesignSystem(css, [base, ...baseFallbacks]);
|
|
1938
|
+
const candidateCache = _nullishCoalesce(designSystemCandidateCache.get(designSystemKey), () => ( /* @__PURE__ */ new Map()));
|
|
1939
|
+
designSystemCandidateCache.set(designSystemKey, candidateCache);
|
|
1992
1940
|
const candidates = await extractRawCandidates(sources);
|
|
1993
|
-
const parsedCandidates = candidates.filter(
|
|
1994
|
-
(rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
|
|
1995
|
-
);
|
|
1996
|
-
if (parsedCandidates.length === 0) {
|
|
1997
|
-
return parsedCandidates;
|
|
1998
|
-
}
|
|
1999
|
-
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
2000
1941
|
const validCandidates = [];
|
|
2001
|
-
|
|
2002
|
-
|
|
1942
|
+
const uncachedCandidates = [];
|
|
1943
|
+
for (const rawCandidate of candidates) {
|
|
1944
|
+
const cached = candidateCache.get(rawCandidate);
|
|
1945
|
+
if (cached === true) {
|
|
1946
|
+
validCandidates.push(rawCandidate);
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1949
|
+
if (cached === false) {
|
|
1950
|
+
continue;
|
|
1951
|
+
}
|
|
1952
|
+
if (designSystem.parseCandidate(rawCandidate).length > 0) {
|
|
1953
|
+
uncachedCandidates.push(rawCandidate);
|
|
1954
|
+
continue;
|
|
1955
|
+
}
|
|
1956
|
+
candidateCache.set(rawCandidate, false);
|
|
1957
|
+
}
|
|
1958
|
+
if (uncachedCandidates.length === 0) {
|
|
1959
|
+
return validCandidates;
|
|
1960
|
+
}
|
|
1961
|
+
const cssByCandidate = designSystem.candidatesToCss(uncachedCandidates);
|
|
1962
|
+
for (let index = 0; index < uncachedCandidates.length; index++) {
|
|
1963
|
+
const candidate = uncachedCandidates[index];
|
|
2003
1964
|
if (candidate === void 0) {
|
|
2004
1965
|
continue;
|
|
2005
1966
|
}
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2008
|
-
|
|
1967
|
+
const candidateCss = cssByCandidate[index];
|
|
1968
|
+
const isValid = typeof candidateCss === "string" && candidateCss.trim().length > 0;
|
|
1969
|
+
candidateCache.set(candidate, isValid);
|
|
1970
|
+
if (!isValid) {
|
|
1971
|
+
continue;
|
|
2009
1972
|
}
|
|
1973
|
+
validCandidates.push(candidate);
|
|
2010
1974
|
}
|
|
2011
1975
|
return validCandidates;
|
|
2012
1976
|
}
|
|
2013
1977
|
function normalizeSources(sources, cwd) {
|
|
2014
|
-
const baseSources = _optionalChain([sources, 'optionalAccess',
|
|
1978
|
+
const baseSources = _optionalChain([sources, 'optionalAccess', _49 => _49.length]) ? sources : [
|
|
2015
1979
|
{
|
|
2016
1980
|
base: cwd,
|
|
2017
1981
|
pattern: "**/*",
|
|
@@ -2076,9 +2040,9 @@ function toRelativeFile(cwd, filename) {
|
|
|
2076
2040
|
return relative === "" ? _pathe2.default.basename(filename) : relative;
|
|
2077
2041
|
}
|
|
2078
2042
|
async function extractProjectCandidatesWithPositions(options) {
|
|
2079
|
-
const cwd = _optionalChain([options, 'optionalAccess',
|
|
2080
|
-
const normalizedSources = normalizeSources(_optionalChain([options, 'optionalAccess',
|
|
2081
|
-
const { Scanner } = await
|
|
2043
|
+
const cwd = _optionalChain([options, 'optionalAccess', _50 => _50.cwd]) ? _pathe2.default.resolve(options.cwd) : _process2.default.cwd();
|
|
2044
|
+
const normalizedSources = normalizeSources(_optionalChain([options, 'optionalAccess', _51 => _51.sources]), cwd);
|
|
2045
|
+
const { Scanner } = await getOxideModule();
|
|
2082
2046
|
const scanner = new Scanner({
|
|
2083
2047
|
sources: normalizedSources
|
|
2084
2048
|
});
|
|
@@ -2131,8 +2095,8 @@ async function extractProjectCandidatesWithPositions(options) {
|
|
|
2131
2095
|
};
|
|
2132
2096
|
}
|
|
2133
2097
|
function groupTokensByFile(report, options) {
|
|
2134
|
-
const key = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2135
|
-
const stripAbsolute = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2098
|
+
const key = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _52 => _52.key]), () => ( "relative"));
|
|
2099
|
+
const stripAbsolute = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.stripAbsolutePaths]), () => ( key !== "absolute"));
|
|
2136
2100
|
return report.entries.reduce((acc, entry) => {
|
|
2137
2101
|
const bucketKey = key === "absolute" ? entry.file : entry.relativeFile;
|
|
2138
2102
|
if (!acc[bucketKey]) {
|
|
@@ -2208,7 +2172,7 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2208
2172
|
const resolvedConfiguredBase = toAbsolute(v4Options.configuredBase);
|
|
2209
2173
|
const resolvedDefaultBase = _nullishCoalesce(toAbsolute(v4Options.base), () => ( _process2.default.cwd()));
|
|
2210
2174
|
const resolveSources = (base) => {
|
|
2211
|
-
if (!_optionalChain([v4Options, 'access',
|
|
2175
|
+
if (!_optionalChain([v4Options, 'access', _54 => _54.sources, 'optionalAccess', _55 => _55.length])) {
|
|
2212
2176
|
return void 0;
|
|
2213
2177
|
}
|
|
2214
2178
|
return v4Options.sources.map((source) => ({
|
|
@@ -2266,7 +2230,7 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2266
2230
|
var _module = require('module');
|
|
2267
2231
|
|
|
2268
2232
|
|
|
2269
|
-
var require2 = _module.createRequire.call(void 0,
|
|
2233
|
+
var require2 = _module.createRequire.call(void 0, _chunk5CWNAWKPjs.importMetaUrl);
|
|
2270
2234
|
function resolveRuntimeEntry(packageInfo, majorVersion) {
|
|
2271
2235
|
const root = packageInfo.rootPath;
|
|
2272
2236
|
if (majorVersion === 2) {
|
|
@@ -2314,9 +2278,52 @@ function loadRuntimeContexts(packageInfo, majorVersion, refProperty) {
|
|
|
2314
2278
|
// src/runtime/process-tailwindcss.ts
|
|
2315
2279
|
|
|
2316
2280
|
|
|
2281
|
+
|
|
2317
2282
|
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
2318
2283
|
var _tailwindcssconfig = require('tailwindcss-config');
|
|
2319
|
-
var require3 = _module.createRequire.call(void 0,
|
|
2284
|
+
var require3 = _module.createRequire.call(void 0, _chunk5CWNAWKPjs.importMetaUrl);
|
|
2285
|
+
function resolveModuleEntry(id) {
|
|
2286
|
+
return _pathe2.default.isAbsolute(id) ? id : require3.resolve(id);
|
|
2287
|
+
}
|
|
2288
|
+
function resolvePackageRootFromEntry(entry) {
|
|
2289
|
+
let current = _pathe2.default.dirname(entry);
|
|
2290
|
+
while (current && current !== _pathe2.default.dirname(current)) {
|
|
2291
|
+
const packageJsonPath = _pathe2.default.join(current, "package.json");
|
|
2292
|
+
if (_fsextra2.default.pathExistsSync(packageJsonPath)) {
|
|
2293
|
+
return current;
|
|
2294
|
+
}
|
|
2295
|
+
current = _pathe2.default.dirname(current);
|
|
2296
|
+
}
|
|
2297
|
+
return void 0;
|
|
2298
|
+
}
|
|
2299
|
+
function clearTailwindV3RuntimeState(pluginName) {
|
|
2300
|
+
try {
|
|
2301
|
+
const entry = resolveModuleEntry(pluginName);
|
|
2302
|
+
const root = resolvePackageRootFromEntry(entry);
|
|
2303
|
+
if (!root) {
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
const sharedStatePath = _pathe2.default.join(root, "lib/lib/sharedState.js");
|
|
2307
|
+
if (!_fsextra2.default.pathExistsSync(sharedStatePath)) {
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
const sharedState = _optionalChain([require3, 'access', _56 => _56.cache, 'access', _57 => _57[sharedStatePath], 'optionalAccess', _58 => _58.exports]);
|
|
2311
|
+
_optionalChain([sharedState, 'optionalAccess', _59 => _59.contextMap, 'optionalAccess', _60 => _60.clear, 'call', _61 => _61()]);
|
|
2312
|
+
_optionalChain([sharedState, 'optionalAccess', _62 => _62.configContextMap, 'optionalAccess', _63 => _63.clear, 'call', _64 => _64()]);
|
|
2313
|
+
_optionalChain([sharedState, 'optionalAccess', _65 => _65.contextSourcesMap, 'optionalAccess', _66 => _66.clear, 'call', _67 => _67()]);
|
|
2314
|
+
_optionalChain([sharedState, 'optionalAccess', _68 => _68.sourceHashMap, 'optionalAccess', _69 => _69.clear, 'call', _70 => _70()]);
|
|
2315
|
+
for (const candidate of ["lib/plugin.js", "lib/index.js"]) {
|
|
2316
|
+
const runtimeEntry = _pathe2.default.join(root, candidate);
|
|
2317
|
+
if (!_fsextra2.default.pathExistsSync(runtimeEntry)) {
|
|
2318
|
+
continue;
|
|
2319
|
+
}
|
|
2320
|
+
const runtimeModule = _optionalChain([require3, 'access', _71 => _71.cache, 'access', _72 => _72[runtimeEntry], 'optionalAccess', _73 => _73.exports]);
|
|
2321
|
+
_optionalChain([runtimeModule, 'optionalAccess', _74 => _74.contextRef, 'optionalAccess', _75 => _75.value, 'optionalAccess', _76 => _76.splice, 'call', _77 => _77(0, runtimeModule.contextRef.value.length)]);
|
|
2322
|
+
break;
|
|
2323
|
+
}
|
|
2324
|
+
} catch (e10) {
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2320
2327
|
async function resolveConfigPath(options) {
|
|
2321
2328
|
if (options.config && _pathe2.default.isAbsolute(options.config)) {
|
|
2322
2329
|
return options.config;
|
|
@@ -2330,6 +2337,9 @@ async function resolveConfigPath(options) {
|
|
|
2330
2337
|
async function runTailwindBuild(options) {
|
|
2331
2338
|
const configPath = await resolveConfigPath(options);
|
|
2332
2339
|
const pluginName = _nullishCoalesce(options.postcssPlugin, () => ( (options.majorVersion === 4 ? "@tailwindcss/postcss" : "tailwindcss")));
|
|
2340
|
+
if (options.majorVersion === 3) {
|
|
2341
|
+
clearTailwindV3RuntimeState(pluginName);
|
|
2342
|
+
}
|
|
2333
2343
|
if (options.majorVersion === 4) {
|
|
2334
2344
|
return _postcss2.default.call(void 0, [
|
|
2335
2345
|
require3(pluginName)({
|
|
@@ -2390,7 +2400,7 @@ function transformProcessTailwindFeaturesReturnContextV2(content) {
|
|
|
2390
2400
|
traverse(ast, {
|
|
2391
2401
|
FunctionDeclaration(path18) {
|
|
2392
2402
|
const node = path18.node;
|
|
2393
|
-
if (_optionalChain([node, 'access',
|
|
2403
|
+
if (_optionalChain([node, 'access', _78 => _78.id, 'optionalAccess', _79 => _79.name]) !== "processTailwindFeatures" || node.body.body.length !== 1 || !t.isReturnStatement(node.body.body[0])) {
|
|
2394
2404
|
return;
|
|
2395
2405
|
}
|
|
2396
2406
|
const returnStatement3 = node.body.body[0];
|
|
@@ -2423,7 +2433,7 @@ function transformPostcssPluginV2(content, options) {
|
|
|
2423
2433
|
Program(path18) {
|
|
2424
2434
|
const program = path18.node;
|
|
2425
2435
|
const index = program.body.findIndex((statement) => {
|
|
2426
|
-
return t.isFunctionDeclaration(statement) && _optionalChain([statement, 'access',
|
|
2436
|
+
return t.isFunctionDeclaration(statement) && _optionalChain([statement, 'access', _80 => _80.id, 'optionalAccess', _81 => _81.name]) === "_default";
|
|
2427
2437
|
});
|
|
2428
2438
|
if (index === -1) {
|
|
2429
2439
|
return;
|
|
@@ -2460,7 +2470,7 @@ function transformPostcssPluginV2(content, options) {
|
|
|
2460
2470
|
return;
|
|
2461
2471
|
}
|
|
2462
2472
|
const fn = path18.node;
|
|
2463
|
-
if (_optionalChain([fn, 'access',
|
|
2473
|
+
if (_optionalChain([fn, 'access', _82 => _82.id, 'optionalAccess', _83 => _83.name]) !== "_default") {
|
|
2464
2474
|
return;
|
|
2465
2475
|
}
|
|
2466
2476
|
if (fn.body.body.length !== 1 || !t.isReturnStatement(fn.body.body[0])) {
|
|
@@ -2550,7 +2560,7 @@ function transformProcessTailwindFeaturesReturnContext(content) {
|
|
|
2550
2560
|
traverse(ast, {
|
|
2551
2561
|
FunctionDeclaration(path18) {
|
|
2552
2562
|
const node = path18.node;
|
|
2553
|
-
if (_optionalChain([node, 'access',
|
|
2563
|
+
if (_optionalChain([node, 'access', _84 => _84.id, 'optionalAccess', _85 => _85.name]) !== "processTailwindFeatures" || node.body.body.length !== 1) {
|
|
2554
2564
|
return;
|
|
2555
2565
|
}
|
|
2556
2566
|
const [returnStatement3] = node.body.body;
|
|
@@ -2584,7 +2594,7 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
2584
2594
|
Program(path18) {
|
|
2585
2595
|
const program = path18.node;
|
|
2586
2596
|
const index = program.body.findIndex((statement) => {
|
|
2587
|
-
return t2.isExpressionStatement(statement) && t2.isAssignmentExpression(statement.expression) && t2.isMemberExpression(statement.expression.left) && t2.isFunctionExpression(statement.expression.right) && _optionalChain([statement, 'access',
|
|
2597
|
+
return t2.isExpressionStatement(statement) && t2.isAssignmentExpression(statement.expression) && t2.isMemberExpression(statement.expression.left) && t2.isFunctionExpression(statement.expression.right) && _optionalChain([statement, 'access', _86 => _86.expression, 'access', _87 => _87.right, 'access', _88 => _88.id, 'optionalAccess', _89 => _89.name]) === "tailwindcss";
|
|
2588
2598
|
});
|
|
2589
2599
|
if (index === -1) {
|
|
2590
2600
|
return;
|
|
@@ -2625,7 +2635,7 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
2625
2635
|
return;
|
|
2626
2636
|
}
|
|
2627
2637
|
const fn = path18.node;
|
|
2628
|
-
if (_optionalChain([fn, 'access',
|
|
2638
|
+
if (_optionalChain([fn, 'access', _90 => _90.id, 'optionalAccess', _91 => _91.name]) !== "tailwindcss" || fn.body.body.length !== 1) {
|
|
2629
2639
|
return;
|
|
2630
2640
|
}
|
|
2631
2641
|
const [returnStatement3] = fn.body.body;
|
|
@@ -3022,7 +3032,7 @@ function checkExtendLengthUnitsPatch(context) {
|
|
|
3022
3032
|
function getPatchStatusReport(context) {
|
|
3023
3033
|
return {
|
|
3024
3034
|
package: {
|
|
3025
|
-
name: _nullishCoalesce(context.packageInfo.name, () => ( _optionalChain([context, 'access',
|
|
3035
|
+
name: _nullishCoalesce(context.packageInfo.name, () => ( _optionalChain([context, 'access', _92 => _92.packageInfo, 'access', _93 => _93.packageJson, 'optionalAccess', _94 => _94.name]))),
|
|
3026
3036
|
version: context.packageInfo.version,
|
|
3027
3037
|
root: context.packageInfo.rootPath
|
|
3028
3038
|
},
|
|
@@ -3142,7 +3152,7 @@ function applyTailwindPatches(context) {
|
|
|
3142
3152
|
majorVersion
|
|
3143
3153
|
});
|
|
3144
3154
|
}
|
|
3145
|
-
if (_optionalChain([options, 'access',
|
|
3155
|
+
if (_optionalChain([options, 'access', _95 => _95.features, 'access', _96 => _96.extendLengthUnits, 'optionalAccess', _97 => _97.enabled])) {
|
|
3146
3156
|
if (majorVersion === 3) {
|
|
3147
3157
|
results.extendLengthUnits = applyExtendLengthUnitsPatchV3(
|
|
3148
3158
|
packageInfo.rootPath,
|
|
@@ -3158,25 +3168,7 @@ function applyTailwindPatches(context) {
|
|
|
3158
3168
|
return results;
|
|
3159
3169
|
}
|
|
3160
3170
|
|
|
3161
|
-
// src/
|
|
3162
|
-
function resolveMajorVersion(version, hint) {
|
|
3163
|
-
if (hint && [2, 3, 4].includes(hint)) {
|
|
3164
|
-
return hint;
|
|
3165
|
-
}
|
|
3166
|
-
if (version) {
|
|
3167
|
-
const coerced = _semver.coerce.call(void 0, version);
|
|
3168
|
-
if (coerced) {
|
|
3169
|
-
const major = coerced.major;
|
|
3170
|
-
if (major === 2 || major === 3 || major === 4) {
|
|
3171
|
-
return major;
|
|
3172
|
-
}
|
|
3173
|
-
if (major >= 4) {
|
|
3174
|
-
return 4;
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3177
|
-
}
|
|
3178
|
-
return 3;
|
|
3179
|
-
}
|
|
3171
|
+
// src/runtime/collector.ts
|
|
3180
3172
|
function resolveTailwindExecutionOptions(normalized, majorVersion) {
|
|
3181
3173
|
const base = normalized.tailwind;
|
|
3182
3174
|
if (majorVersion === 2 && base.v2) {
|
|
@@ -3199,15 +3191,138 @@ function resolveTailwindExecutionOptions(normalized, majorVersion) {
|
|
|
3199
3191
|
postcssPlugin: base.postcssPlugin
|
|
3200
3192
|
};
|
|
3201
3193
|
}
|
|
3194
|
+
var BaseCollector = class {
|
|
3195
|
+
constructor(packageInfo, options, majorVersion) {
|
|
3196
|
+
this.packageInfo = packageInfo;
|
|
3197
|
+
this.options = options;
|
|
3198
|
+
this.majorVersion = majorVersion;
|
|
3199
|
+
}
|
|
3200
|
+
async patch() {
|
|
3201
|
+
return applyTailwindPatches({
|
|
3202
|
+
packageInfo: this.packageInfo,
|
|
3203
|
+
options: this.options,
|
|
3204
|
+
majorVersion: this.majorVersion
|
|
3205
|
+
});
|
|
3206
|
+
}
|
|
3207
|
+
async getPatchStatus() {
|
|
3208
|
+
return getPatchStatusReport({
|
|
3209
|
+
packageInfo: this.packageInfo,
|
|
3210
|
+
options: this.options,
|
|
3211
|
+
majorVersion: this.majorVersion
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
getContexts() {
|
|
3215
|
+
return loadRuntimeContexts(
|
|
3216
|
+
this.packageInfo,
|
|
3217
|
+
this.majorVersion,
|
|
3218
|
+
this.options.features.exposeContext.refProperty
|
|
3219
|
+
);
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3222
|
+
var RuntimeCollector = class extends BaseCollector {
|
|
3223
|
+
constructor(packageInfo, options, majorVersion, snapshotFactory) {
|
|
3224
|
+
super(packageInfo, options, majorVersion);
|
|
3225
|
+
this.snapshotFactory = snapshotFactory;
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
async collectClassSet() {
|
|
3229
|
+
const contexts = this.getContexts();
|
|
3230
|
+
return collectClassesFromContexts(contexts, this.options.filter);
|
|
3231
|
+
}
|
|
3232
|
+
getPatchSnapshot() {
|
|
3233
|
+
return this.snapshotFactory();
|
|
3234
|
+
}
|
|
3235
|
+
async runTailwindBuildIfNeeded() {
|
|
3236
|
+
if (this.inFlightBuild) {
|
|
3237
|
+
return this.inFlightBuild;
|
|
3238
|
+
}
|
|
3239
|
+
const executionOptions = resolveTailwindExecutionOptions(this.options, this.majorVersion);
|
|
3240
|
+
const buildOptions = {
|
|
3241
|
+
cwd: executionOptions.cwd,
|
|
3242
|
+
majorVersion: this.majorVersion,
|
|
3243
|
+
...executionOptions.config === void 0 ? {} : { config: executionOptions.config },
|
|
3244
|
+
...executionOptions.postcssPlugin === void 0 ? {} : { postcssPlugin: executionOptions.postcssPlugin }
|
|
3245
|
+
};
|
|
3246
|
+
this.inFlightBuild = runTailwindBuild(buildOptions).then(() => void 0);
|
|
3247
|
+
try {
|
|
3248
|
+
await this.inFlightBuild;
|
|
3249
|
+
} finally {
|
|
3250
|
+
this.inFlightBuild = void 0;
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
};
|
|
3254
|
+
var TailwindV4Collector = class extends BaseCollector {
|
|
3255
|
+
constructor(packageInfo, options, snapshotFactory) {
|
|
3256
|
+
super(packageInfo, options, 4);
|
|
3257
|
+
this.snapshotFactory = snapshotFactory;
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
async collectClassSet() {
|
|
3261
|
+
return collectClassesFromTailwindV4(this.options);
|
|
3262
|
+
}
|
|
3263
|
+
getPatchSnapshot() {
|
|
3264
|
+
return this.snapshotFactory();
|
|
3265
|
+
}
|
|
3266
|
+
};
|
|
3267
|
+
|
|
3268
|
+
// src/api/tailwindcss-patcher.ts
|
|
3269
|
+
function resolveInstalledMajorVersion(version) {
|
|
3270
|
+
if (!version) {
|
|
3271
|
+
return void 0;
|
|
3272
|
+
}
|
|
3273
|
+
const coerced = _semver.coerce.call(void 0, version);
|
|
3274
|
+
if (!coerced) {
|
|
3275
|
+
return void 0;
|
|
3276
|
+
}
|
|
3277
|
+
const major = coerced.major;
|
|
3278
|
+
if (major === 2 || major === 3 || major === 4) {
|
|
3279
|
+
return major;
|
|
3280
|
+
}
|
|
3281
|
+
if (major >= 4) {
|
|
3282
|
+
return 4;
|
|
3283
|
+
}
|
|
3284
|
+
return void 0;
|
|
3285
|
+
}
|
|
3286
|
+
function validateInstalledVersion(packageVersion, expectedMajor, packageName) {
|
|
3287
|
+
const installedMajor = resolveInstalledMajorVersion(packageVersion);
|
|
3288
|
+
if (installedMajor === void 0) {
|
|
3289
|
+
return;
|
|
3290
|
+
}
|
|
3291
|
+
if (installedMajor !== expectedMajor) {
|
|
3292
|
+
throw new Error(
|
|
3293
|
+
`Configured tailwindcss.version=${expectedMajor}, but resolved package "${packageName}" is version ${packageVersion}. Update the configuration or resolve the correct package.`
|
|
3294
|
+
);
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
function resolveMajorVersionOrThrow(configuredMajor, packageVersion, packageName) {
|
|
3298
|
+
if (configuredMajor !== void 0) {
|
|
3299
|
+
validateInstalledVersion(packageVersion, configuredMajor, packageName);
|
|
3300
|
+
return configuredMajor;
|
|
3301
|
+
}
|
|
3302
|
+
const installedMajor = resolveInstalledMajorVersion(packageVersion);
|
|
3303
|
+
if (installedMajor !== void 0) {
|
|
3304
|
+
return installedMajor;
|
|
3305
|
+
}
|
|
3306
|
+
throw new Error(
|
|
3307
|
+
`Unable to infer Tailwind CSS major version from resolved package "${packageName}" (${_nullishCoalesce(packageVersion, () => ( "unknown"))}). Set "tailwindcss.version" to 2, 3, or 4 explicitly.`
|
|
3308
|
+
);
|
|
3309
|
+
}
|
|
3310
|
+
function createCollector(packageInfo, options, majorVersion, snapshotFactory) {
|
|
3311
|
+
if (majorVersion === 4) {
|
|
3312
|
+
return new TailwindV4Collector(packageInfo, options, snapshotFactory);
|
|
3313
|
+
}
|
|
3314
|
+
return new RuntimeCollector(packageInfo, options, majorVersion, snapshotFactory);
|
|
3315
|
+
}
|
|
3202
3316
|
var TailwindcssPatcher = (_class2 = class {
|
|
3203
3317
|
|
|
3204
3318
|
|
|
3205
3319
|
|
|
3206
3320
|
|
|
3207
3321
|
|
|
3322
|
+
|
|
3323
|
+
|
|
3208
3324
|
constructor(options = {}) {;_class2.prototype.__init4.call(this);
|
|
3209
|
-
|
|
3210
|
-
this.options = normalizeOptions(resolvedOptions);
|
|
3325
|
+
this.options = normalizeOptions(options);
|
|
3211
3326
|
const packageInfo = _localpkg.getPackageInfoSync.call(void 0,
|
|
3212
3327
|
this.options.tailwind.packageName,
|
|
3213
3328
|
this.options.tailwind.resolve
|
|
@@ -3216,9 +3331,10 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3216
3331
|
throw new Error(`Unable to locate Tailwind CSS package "${this.options.tailwind.packageName}".`);
|
|
3217
3332
|
}
|
|
3218
3333
|
this.packageInfo = packageInfo;
|
|
3219
|
-
this.majorVersion =
|
|
3334
|
+
this.majorVersion = resolveMajorVersionOrThrow(
|
|
3335
|
+
this.options.tailwind.versionHint,
|
|
3220
3336
|
this.packageInfo.version,
|
|
3221
|
-
this.options.tailwind.
|
|
3337
|
+
this.options.tailwind.packageName
|
|
3222
3338
|
);
|
|
3223
3339
|
this.cacheContext = createCacheContextDescriptor(
|
|
3224
3340
|
this.options,
|
|
@@ -3226,56 +3342,90 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3226
3342
|
this.majorVersion
|
|
3227
3343
|
);
|
|
3228
3344
|
this.cacheStore = new CacheStore(this.options.cache, this.cacheContext);
|
|
3345
|
+
this.collector = createCollector(
|
|
3346
|
+
this.packageInfo,
|
|
3347
|
+
this.options,
|
|
3348
|
+
this.majorVersion,
|
|
3349
|
+
() => this.createPatchSnapshot()
|
|
3350
|
+
);
|
|
3229
3351
|
}
|
|
3230
3352
|
async patch() {
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3353
|
+
const snapshot = this.collector.getPatchSnapshot();
|
|
3354
|
+
if (this.patchMemo && this.patchMemo.snapshot === snapshot) {
|
|
3355
|
+
return this.patchMemo.result;
|
|
3356
|
+
}
|
|
3357
|
+
const result = await this.collector.patch();
|
|
3358
|
+
this.patchMemo = {
|
|
3359
|
+
result,
|
|
3360
|
+
snapshot: this.collector.getPatchSnapshot()
|
|
3361
|
+
};
|
|
3362
|
+
return result;
|
|
3236
3363
|
}
|
|
3237
3364
|
async getPatchStatus() {
|
|
3238
|
-
return
|
|
3239
|
-
packageInfo: this.packageInfo,
|
|
3240
|
-
options: this.options,
|
|
3241
|
-
majorVersion: this.majorVersion
|
|
3242
|
-
});
|
|
3365
|
+
return this.collector.getPatchStatus();
|
|
3243
3366
|
}
|
|
3244
3367
|
getContexts() {
|
|
3245
|
-
return
|
|
3246
|
-
this.packageInfo,
|
|
3247
|
-
this.majorVersion,
|
|
3248
|
-
this.options.features.exposeContext.refProperty
|
|
3249
|
-
);
|
|
3368
|
+
return this.collector.getContexts();
|
|
3250
3369
|
}
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
};
|
|
3260
|
-
|
|
3370
|
+
createPatchSnapshot() {
|
|
3371
|
+
const entries = [];
|
|
3372
|
+
const pushSnapshot = (filePath) => {
|
|
3373
|
+
if (!_fsextra2.default.pathExistsSync(filePath)) {
|
|
3374
|
+
entries.push(`${filePath}:missing`);
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
const stat = _fsextra2.default.statSync(filePath);
|
|
3378
|
+
entries.push(`${filePath}:${stat.size}:${Math.trunc(stat.mtimeMs)}`);
|
|
3379
|
+
};
|
|
3380
|
+
if (this.options.features.exposeContext.enabled && (this.majorVersion === 2 || this.majorVersion === 3)) {
|
|
3381
|
+
if (this.majorVersion === 2) {
|
|
3382
|
+
pushSnapshot(_pathe2.default.resolve(this.packageInfo.rootPath, "lib/jit/processTailwindFeatures.js"));
|
|
3383
|
+
pushSnapshot(_pathe2.default.resolve(this.packageInfo.rootPath, "lib/jit/index.js"));
|
|
3384
|
+
} else {
|
|
3385
|
+
pushSnapshot(_pathe2.default.resolve(this.packageInfo.rootPath, "lib/processTailwindFeatures.js"));
|
|
3386
|
+
const pluginPath = ["lib/plugin.js", "lib/index.js"].map((file) => _pathe2.default.resolve(this.packageInfo.rootPath, file)).find((file) => _fsextra2.default.pathExistsSync(file));
|
|
3387
|
+
if (pluginPath) {
|
|
3388
|
+
pushSnapshot(pluginPath);
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3261
3391
|
}
|
|
3392
|
+
if (_optionalChain([this, 'access', _98 => _98.options, 'access', _99 => _99.features, 'access', _100 => _100.extendLengthUnits, 'optionalAccess', _101 => _101.enabled])) {
|
|
3393
|
+
if (this.majorVersion === 3) {
|
|
3394
|
+
const target = _nullishCoalesce(this.options.features.extendLengthUnits.lengthUnitsFilePath, () => ( "lib/util/dataTypes.js"));
|
|
3395
|
+
pushSnapshot(_pathe2.default.resolve(this.packageInfo.rootPath, target));
|
|
3396
|
+
} else if (this.majorVersion === 4) {
|
|
3397
|
+
const distDir = _pathe2.default.resolve(this.packageInfo.rootPath, "dist");
|
|
3398
|
+
if (_fsextra2.default.pathExistsSync(distDir)) {
|
|
3399
|
+
const chunkNames = _fsextra2.default.readdirSync(distDir).filter((entry) => entry.endsWith(".js") || entry.endsWith(".mjs")).sort();
|
|
3400
|
+
for (const chunkName of chunkNames) {
|
|
3401
|
+
pushSnapshot(_pathe2.default.join(distDir, chunkName));
|
|
3402
|
+
}
|
|
3403
|
+
} else {
|
|
3404
|
+
entries.push(`${distDir}:missing`);
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
return entries.join("|");
|
|
3262
3409
|
}
|
|
3263
3410
|
async collectClassSet() {
|
|
3264
3411
|
if (this.majorVersion === 4) {
|
|
3265
|
-
return
|
|
3412
|
+
return this.collector.collectClassSet();
|
|
3266
3413
|
}
|
|
3267
3414
|
const contexts = this.getContexts();
|
|
3268
3415
|
return collectClassesFromContexts(contexts, this.options.filter);
|
|
3269
3416
|
}
|
|
3417
|
+
async runTailwindBuildIfNeeded() {
|
|
3418
|
+
await _optionalChain([this, 'access', _102 => _102.collector, 'access', _103 => _103.runTailwindBuildIfNeeded, 'optionalCall', _104 => _104()]);
|
|
3419
|
+
}
|
|
3270
3420
|
debugCacheRead(meta) {
|
|
3271
3421
|
if (meta.hit) {
|
|
3272
3422
|
logger_default.debug(
|
|
3273
|
-
`[cache] hit fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access',
|
|
3423
|
+
`[cache] hit fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access', _105 => _105.fingerprint, 'optionalAccess', _106 => _106.slice, 'call', _107 => _107(0, 12)]), () => ( "n/a"))} schema=${_nullishCoalesce(meta.schemaVersion, () => ( "legacy"))} ${meta.details.join("; ")}`
|
|
3274
3424
|
);
|
|
3275
3425
|
return;
|
|
3276
3426
|
}
|
|
3277
3427
|
logger_default.debug(
|
|
3278
|
-
`[cache] miss reason=${meta.reason} fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access',
|
|
3428
|
+
`[cache] miss reason=${meta.reason} fingerprint=${_nullishCoalesce(_optionalChain([meta, 'access', _108 => _108.fingerprint, 'optionalAccess', _109 => _109.slice, 'call', _110 => _110(0, 12)]), () => ( "n/a"))} schema=${_nullishCoalesce(meta.schemaVersion, () => ( "legacy"))} ${meta.details.join("; ")}`
|
|
3279
3429
|
);
|
|
3280
3430
|
}
|
|
3281
3431
|
async mergeWithCache(set) {
|
|
@@ -3288,13 +3438,13 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3288
3438
|
for (const value of existing) {
|
|
3289
3439
|
set.add(value);
|
|
3290
3440
|
}
|
|
3291
|
-
const writeTarget = await this.cacheStore.write(set);
|
|
3441
|
+
const writeTarget = this.areSetsEqual(existing, set) ? void 0 : await this.cacheStore.write(set);
|
|
3292
3442
|
if (writeTarget) {
|
|
3293
3443
|
logger_default.debug(`[cache] stored ${set.size} classes -> ${writeTarget}`);
|
|
3294
3444
|
}
|
|
3295
3445
|
} else {
|
|
3296
3446
|
if (set.size > 0) {
|
|
3297
|
-
const writeTarget = await this.cacheStore.write(set);
|
|
3447
|
+
const writeTarget = this.areSetsEqual(existing, set) ? void 0 : await this.cacheStore.write(set);
|
|
3298
3448
|
if (writeTarget) {
|
|
3299
3449
|
logger_default.debug(`[cache] stored ${set.size} classes -> ${writeTarget}`);
|
|
3300
3450
|
}
|
|
@@ -3314,13 +3464,13 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3314
3464
|
for (const value of existing) {
|
|
3315
3465
|
set.add(value);
|
|
3316
3466
|
}
|
|
3317
|
-
const writeTarget = this.cacheStore.writeSync(set);
|
|
3467
|
+
const writeTarget = this.areSetsEqual(existing, set) ? void 0 : this.cacheStore.writeSync(set);
|
|
3318
3468
|
if (writeTarget) {
|
|
3319
3469
|
logger_default.debug(`[cache] stored ${set.size} classes -> ${writeTarget}`);
|
|
3320
3470
|
}
|
|
3321
3471
|
} else {
|
|
3322
3472
|
if (set.size > 0) {
|
|
3323
|
-
const writeTarget = this.cacheStore.writeSync(set);
|
|
3473
|
+
const writeTarget = this.areSetsEqual(existing, set) ? void 0 : this.cacheStore.writeSync(set);
|
|
3324
3474
|
if (writeTarget) {
|
|
3325
3475
|
logger_default.debug(`[cache] stored ${set.size} classes -> ${writeTarget}`);
|
|
3326
3476
|
}
|
|
@@ -3330,6 +3480,17 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3330
3480
|
}
|
|
3331
3481
|
return set;
|
|
3332
3482
|
}
|
|
3483
|
+
areSetsEqual(a, b) {
|
|
3484
|
+
if (a.size !== b.size) {
|
|
3485
|
+
return false;
|
|
3486
|
+
}
|
|
3487
|
+
for (const value of a) {
|
|
3488
|
+
if (!b.has(value)) {
|
|
3489
|
+
return false;
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
return true;
|
|
3493
|
+
}
|
|
3333
3494
|
async getClassSet() {
|
|
3334
3495
|
await this.runTailwindBuildIfNeeded();
|
|
3335
3496
|
const set = await this.collectClassSet();
|
|
@@ -3348,7 +3509,7 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3348
3509
|
return merged;
|
|
3349
3510
|
}
|
|
3350
3511
|
async extract(options) {
|
|
3351
|
-
const shouldWrite = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3512
|
+
const shouldWrite = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _111 => _111.write]), () => ( this.options.output.enabled));
|
|
3352
3513
|
const classSet = await this.getClassSet();
|
|
3353
3514
|
const classList = Array.from(classSet);
|
|
3354
3515
|
const result = {
|
|
@@ -3384,19 +3545,19 @@ var TailwindcssPatcher = (_class2 = class {
|
|
|
3384
3545
|
__init4() {this.extractValidCandidates = exports.extractValidCandidates = extractValidCandidates}
|
|
3385
3546
|
async collectContentTokens(options) {
|
|
3386
3547
|
return extractProjectCandidatesWithPositions({
|
|
3387
|
-
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3388
|
-
sources: _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3548
|
+
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _112 => _112.cwd]), () => ( this.options.projectRoot)),
|
|
3549
|
+
sources: _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _113 => _113.sources]), () => ( _optionalChain([this, 'access', _114 => _114.options, 'access', _115 => _115.tailwind, 'access', _116 => _116.v4, 'optionalAccess', _117 => _117.sources]))), () => ( []))
|
|
3389
3550
|
});
|
|
3390
3551
|
}
|
|
3391
3552
|
async collectContentTokensByFile(options) {
|
|
3392
3553
|
const collectContentOptions = {
|
|
3393
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3394
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3554
|
+
..._optionalChain([options, 'optionalAccess', _118 => _118.cwd]) === void 0 ? {} : { cwd: options.cwd },
|
|
3555
|
+
..._optionalChain([options, 'optionalAccess', _119 => _119.sources]) === void 0 ? {} : { sources: options.sources }
|
|
3395
3556
|
};
|
|
3396
3557
|
const report = await this.collectContentTokens(collectContentOptions);
|
|
3397
3558
|
const groupOptions = {
|
|
3398
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3399
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3559
|
+
..._optionalChain([options, 'optionalAccess', _120 => _120.key]) === void 0 ? {} : { key: options.key },
|
|
3560
|
+
..._optionalChain([options, 'optionalAccess', _121 => _121.stripAbsolutePaths]) === void 0 ? {} : { stripAbsolutePaths: options.stripAbsolutePaths }
|
|
3400
3561
|
};
|
|
3401
3562
|
return groupTokensByFile(report, groupOptions);
|
|
3402
3563
|
}
|
|
@@ -3797,7 +3958,7 @@ async function collectWorkspaceConfigFiles(cwd, maxDepth) {
|
|
|
3797
3958
|
let entries;
|
|
3798
3959
|
try {
|
|
3799
3960
|
entries = await _fsextra2.default.readdir(dir, { withFileTypes: true });
|
|
3800
|
-
} catch (
|
|
3961
|
+
} catch (e11) {
|
|
3801
3962
|
continue;
|
|
3802
3963
|
}
|
|
3803
3964
|
for (const entry of entries) {
|
|
@@ -3897,7 +4058,7 @@ async function rollbackWrittenEntries(wroteEntries) {
|
|
|
3897
4058
|
written.entry.written = false;
|
|
3898
4059
|
written.entry.rolledBack = true;
|
|
3899
4060
|
rollbackCount += 1;
|
|
3900
|
-
} catch (
|
|
4061
|
+
} catch (e12) {
|
|
3901
4062
|
}
|
|
3902
4063
|
}
|
|
3903
4064
|
return rollbackCount;
|
|
@@ -4289,10 +4450,10 @@ function addPrefixIfMissing(value, prefix) {
|
|
|
4289
4450
|
return `${prefix}${value}`;
|
|
4290
4451
|
}
|
|
4291
4452
|
function resolveCommandNames(command, mountOptions, prefix) {
|
|
4292
|
-
const override = _optionalChain([mountOptions, 'access',
|
|
4293
|
-
const baseName = _nullishCoalesce(_optionalChain([override, 'optionalAccess',
|
|
4453
|
+
const override = _optionalChain([mountOptions, 'access', _122 => _122.commandOptions, 'optionalAccess', _123 => _123[command]]);
|
|
4454
|
+
const baseName = _nullishCoalesce(_optionalChain([override, 'optionalAccess', _124 => _124.name]), () => ( command));
|
|
4294
4455
|
const name = addPrefixIfMissing(baseName, prefix);
|
|
4295
|
-
const aliases = (_nullishCoalesce(_optionalChain([override, 'optionalAccess',
|
|
4456
|
+
const aliases = (_nullishCoalesce(_optionalChain([override, 'optionalAccess', _125 => _125.aliases]), () => ( []))).map((alias) => addPrefixIfMissing(alias, prefix));
|
|
4296
4457
|
return { name, aliases };
|
|
4297
4458
|
}
|
|
4298
4459
|
function resolveOptionDefinitions(defaults, override) {
|
|
@@ -4312,8 +4473,8 @@ function resolveOptionDefinitions(defaults, override) {
|
|
|
4312
4473
|
function resolveCommandMetadata(command, mountOptions, prefix, defaults) {
|
|
4313
4474
|
const names = resolveCommandNames(command, mountOptions, prefix);
|
|
4314
4475
|
const definition = defaults[command];
|
|
4315
|
-
const override = _optionalChain([mountOptions, 'access',
|
|
4316
|
-
const description = _nullishCoalesce(_optionalChain([override, 'optionalAccess',
|
|
4476
|
+
const override = _optionalChain([mountOptions, 'access', _126 => _126.commandOptions, 'optionalAccess', _127 => _127[command]]);
|
|
4477
|
+
const description = _nullishCoalesce(_optionalChain([override, 'optionalAccess', _128 => _128.description]), () => ( definition.description));
|
|
4317
4478
|
const optionDefs = resolveOptionDefinitions(definition.optionDefs, override);
|
|
4318
4479
|
return { ...names, description, optionDefs };
|
|
4319
4480
|
}
|
|
@@ -4395,7 +4556,7 @@ function runWithCommandHandler(cli, command, commandName, args, handler, default
|
|
|
4395
4556
|
|
|
4396
4557
|
var DEFAULT_CONFIG_NAME = "tailwindcss-mangle";
|
|
4397
4558
|
async function installCommandDefaultHandler(_ctx) {
|
|
4398
|
-
const patcher =
|
|
4559
|
+
const patcher = await _ctx.createPatcher();
|
|
4399
4560
|
await patcher.patch();
|
|
4400
4561
|
logger_default.success("Tailwind CSS runtime patched successfully.");
|
|
4401
4562
|
}
|
|
@@ -4832,7 +4993,7 @@ function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defa
|
|
|
4832
4993
|
command,
|
|
4833
4994
|
commandName,
|
|
4834
4995
|
args,
|
|
4835
|
-
_optionalChain([options, 'access',
|
|
4996
|
+
_optionalChain([options, 'access', _129 => _129.commandHandlers, 'optionalAccess', _130 => _130[commandName]]),
|
|
4836
4997
|
defaultCommandHandlers[commandName]
|
|
4837
4998
|
);
|
|
4838
4999
|
});
|