tailwindcss-patch 9.0.1 → 9.2.0
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.js +1 -1
- package/dist/commands/cli-runtime.mjs +1 -1
- package/dist/index.bundle-BQ_yKkd8.js +239 -0
- package/dist/index.bundle-dp_pw5fq.mjs +201 -0
- package/dist/index.d.mts +73 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.js +7 -2
- package/dist/index.mjs +3 -3
- package/dist/{validate-B8H-8rWO.js → validate-749MHvAC.js} +284 -38
- package/dist/{validate-BI8356RT.mjs → validate-D5elFZMj.mjs} +260 -38
- package/package.json +2 -2
- package/src/extraction/candidate-extractor.ts +14 -69
- package/src/index.bundle.ts +21 -0
- package/src/index.ts +16 -0
- package/src/v4/candidates.ts +224 -0
- package/src/v4/engine.ts +93 -0
- package/src/v4/index.ts +25 -0
- package/src/v4/node-adapter.ts +209 -0
- package/src/v4/source.ts +193 -0
- package/src/v4/types.ts +64 -0
- package/dist/index.bundle-BGBMTX9A.js +0 -35
- package/dist/index.bundle-ByrTqrr3.mjs +0 -18
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_validate = require("./validate-
|
|
3
|
-
const require_index_bundle = require("./index.bundle-
|
|
2
|
+
const require_validate = require("./validate-749MHvAC.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-BQ_yKkd8.js");
|
|
4
4
|
exports.CacheStore = require_validate.CacheStore;
|
|
5
5
|
exports.MIGRATION_REPORT_KIND = require_validate.MIGRATION_REPORT_KIND;
|
|
6
6
|
exports.MIGRATION_REPORT_SCHEMA_VERSION = require_validate.MIGRATION_REPORT_SCHEMA_VERSION;
|
|
@@ -10,6 +10,7 @@ exports.VALIDATE_FAILURE_REASONS = require_validate.VALIDATE_FAILURE_REASONS;
|
|
|
10
10
|
exports.ValidateCommandError = require_validate.ValidateCommandError;
|
|
11
11
|
exports.collectClassesFromContexts = require_validate.collectClassesFromContexts;
|
|
12
12
|
exports.collectClassesFromTailwindV4 = require_validate.collectClassesFromTailwindV4;
|
|
13
|
+
exports.createTailwindV4Engine = require_index_bundle.createTailwindV4Engine;
|
|
13
14
|
exports.createTailwindcssPatchCli = require_index_bundle.createTailwindcssPatchCli;
|
|
14
15
|
exports.defineConfig = require_index_bundle.defineConfig;
|
|
15
16
|
exports.extractProjectCandidatesWithPositions = require_validate.extractProjectCandidatesWithPositions;
|
|
@@ -19,10 +20,14 @@ exports.extractValidCandidates = require_validate.extractValidCandidates;
|
|
|
19
20
|
exports.getPatchStatusReport = require_validate.getPatchStatusReport;
|
|
20
21
|
exports.groupTokensByFile = require_validate.groupTokensByFile;
|
|
21
22
|
exports.loadRuntimeContexts = require_validate.loadRuntimeContexts;
|
|
23
|
+
exports.loadTailwindV4DesignSystem = require_validate.loadTailwindV4DesignSystem;
|
|
22
24
|
exports.logger = require_validate.logger;
|
|
23
25
|
exports.migrateConfigFiles = require_validate.migrateConfigFiles;
|
|
24
26
|
exports.mountTailwindcssPatchCommands = require_index_bundle.mountTailwindcssPatchCommands;
|
|
25
27
|
exports.normalizeOptions = require_validate.normalizeOptions;
|
|
28
|
+
exports.resolveTailwindV4Source = require_index_bundle.resolveTailwindV4Source;
|
|
29
|
+
exports.resolveTailwindV4SourceFromPatchOptions = require_index_bundle.resolveTailwindV4SourceFromPatchOptions;
|
|
30
|
+
exports.resolveValidTailwindV4Candidates = require_validate.resolveValidTailwindV4Candidates;
|
|
26
31
|
exports.restoreConfigFiles = require_validate.restoreConfigFiles;
|
|
27
32
|
exports.runTailwindBuild = require_validate.runTailwindBuild;
|
|
28
33
|
exports.tailwindcssPatchCommands = require_validate.tailwindcssPatchCommands;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as defineConfig, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-
|
|
3
|
-
export { CacheStore, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, TailwindcssPatcher, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
1
|
+
import { D as normalizeOptions, O as CacheStore, S as loadTailwindV4DesignSystem, _ as extractRawCandidates, a as tailwindcssPatchCommands, b as groupTokensByFile, c as MIGRATION_REPORT_KIND, d as getPatchStatusReport, f as runTailwindBuild, g as extractProjectCandidatesWithPositions, h as collectClassesFromTailwindV4, k as logger, l as MIGRATION_REPORT_SCHEMA_VERSION, m as collectClassesFromContexts, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, p as loadRuntimeContexts, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher, v as extractRawCandidatesWithPositions, w as resolveValidTailwindV4Candidates, y as extractValidCandidates } from "./validate-D5elFZMj.mjs";
|
|
2
|
+
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-dp_pw5fq.mjs";
|
|
3
|
+
export { CacheStore, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, TailwindcssPatcher, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
@@ -12,6 +12,8 @@ let node_crypto = require("node:crypto");
|
|
|
12
12
|
let consola = require("consola");
|
|
13
13
|
let node_url = require("node:url");
|
|
14
14
|
let node_fs = require("node:fs");
|
|
15
|
+
let postcss = require("postcss");
|
|
16
|
+
postcss = require_chunk.__toESM(postcss);
|
|
15
17
|
let _babel_types = require("@babel/types");
|
|
16
18
|
_babel_types = require_chunk.__toESM(_babel_types);
|
|
17
19
|
let _babel_generator = require("@babel/generator");
|
|
@@ -19,11 +21,9 @@ _babel_generator = require_chunk.__toESM(_babel_generator);
|
|
|
19
21
|
let _babel_traverse = require("@babel/traverse");
|
|
20
22
|
_babel_traverse = require_chunk.__toESM(_babel_traverse);
|
|
21
23
|
let _babel_parser = require("@babel/parser");
|
|
22
|
-
let postcss = require("postcss");
|
|
23
|
-
postcss = require_chunk.__toESM(postcss);
|
|
24
24
|
let tailwindcss_config = require("tailwindcss-config");
|
|
25
25
|
//#region package.json
|
|
26
|
-
var version = "9.0
|
|
26
|
+
var version = "9.2.0";
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/constants.ts
|
|
29
29
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1447,57 +1447,275 @@ async function loadPatchOptionsForWorkspace(cwd, overrides) {
|
|
|
1447
1447
|
return merge(overrides ?? {}, base, { projectRoot: cwd });
|
|
1448
1448
|
}
|
|
1449
1449
|
//#endregion
|
|
1450
|
-
//#region src/
|
|
1451
|
-
|
|
1452
|
-
|
|
1450
|
+
//#region src/v4/candidates.ts
|
|
1451
|
+
function resolveValidTailwindV4Candidates(designSystem, candidates) {
|
|
1452
|
+
const validCandidates = /* @__PURE__ */ new Set();
|
|
1453
|
+
const parsedCandidates = [];
|
|
1454
|
+
for (const candidate of candidates) {
|
|
1455
|
+
if (!candidate || parsedCandidates.includes(candidate)) continue;
|
|
1456
|
+
if (designSystem.parseCandidate(candidate).length > 0) parsedCandidates.push(candidate);
|
|
1457
|
+
}
|
|
1458
|
+
if (parsedCandidates.length === 0) return validCandidates;
|
|
1459
|
+
const cssByCandidate = designSystem.candidatesToCss(parsedCandidates);
|
|
1460
|
+
for (let index = 0; index < parsedCandidates.length; index++) {
|
|
1461
|
+
const candidate = parsedCandidates[index];
|
|
1462
|
+
const candidateCss = cssByCandidate[index];
|
|
1463
|
+
if (candidate && typeof candidateCss === "string" && candidateCss.trim().length > 0) validCandidates.add(candidate);
|
|
1464
|
+
}
|
|
1465
|
+
return validCandidates;
|
|
1466
|
+
}
|
|
1467
|
+
function splitTopLevel(value, separator) {
|
|
1468
|
+
const result = [];
|
|
1469
|
+
let start = 0;
|
|
1470
|
+
let depth = 0;
|
|
1471
|
+
let quote;
|
|
1472
|
+
for (let index = 0; index < value.length; index++) {
|
|
1473
|
+
const character = value[index];
|
|
1474
|
+
if (character === "\\") {
|
|
1475
|
+
index++;
|
|
1476
|
+
continue;
|
|
1477
|
+
}
|
|
1478
|
+
if (quote) {
|
|
1479
|
+
if (character === quote) quote = void 0;
|
|
1480
|
+
continue;
|
|
1481
|
+
}
|
|
1482
|
+
if (character === "\"" || character === "'") {
|
|
1483
|
+
quote = character;
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
if (character === "(" || character === "[" || character === "{") {
|
|
1487
|
+
depth++;
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
if (character === ")" || character === "]" || character === "}") {
|
|
1491
|
+
depth = Math.max(0, depth - 1);
|
|
1492
|
+
continue;
|
|
1493
|
+
}
|
|
1494
|
+
if (depth === 0 && character === separator) {
|
|
1495
|
+
const item = value.slice(start, index).trim();
|
|
1496
|
+
if (item) result.push(item);
|
|
1497
|
+
start = index + 1;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
const item = value.slice(start).trim();
|
|
1501
|
+
if (item) result.push(item);
|
|
1502
|
+
return result;
|
|
1503
|
+
}
|
|
1504
|
+
const sequencePattern = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
1505
|
+
function expandSequence(value) {
|
|
1506
|
+
const match = value.match(sequencePattern);
|
|
1507
|
+
if (!match) return [value];
|
|
1508
|
+
const [, startValue, endValue, stepValue] = match;
|
|
1509
|
+
if (startValue === void 0 || endValue === void 0) return [value];
|
|
1510
|
+
const start = Number.parseInt(startValue, 10);
|
|
1511
|
+
const end = Number.parseInt(endValue, 10);
|
|
1512
|
+
let step = stepValue === void 0 ? start <= end ? 1 : -1 : Number.parseInt(stepValue, 10);
|
|
1513
|
+
if (step === 0) throw new Error("Step cannot be zero in Tailwind CSS v4 inline source sequence.");
|
|
1514
|
+
const ascending = start < end;
|
|
1515
|
+
if (ascending && step < 0) step = -step;
|
|
1516
|
+
if (!ascending && step > 0) step = -step;
|
|
1517
|
+
const result = [];
|
|
1518
|
+
for (let current = start; ascending ? current <= end : current >= end; current += step) result.push(current.toString());
|
|
1519
|
+
return result;
|
|
1520
|
+
}
|
|
1521
|
+
function expandInlinePattern(pattern) {
|
|
1522
|
+
const openIndex = pattern.indexOf("{");
|
|
1523
|
+
if (openIndex === -1) return [pattern];
|
|
1524
|
+
const prefix = pattern.slice(0, openIndex);
|
|
1525
|
+
const rest = pattern.slice(openIndex);
|
|
1526
|
+
let depth = 0;
|
|
1527
|
+
let closeIndex = -1;
|
|
1528
|
+
for (let index = 0; index < rest.length; index++) {
|
|
1529
|
+
const character = rest[index];
|
|
1530
|
+
if (character === "{") depth++;
|
|
1531
|
+
else if (character === "}") {
|
|
1532
|
+
depth--;
|
|
1533
|
+
if (depth === 0) {
|
|
1534
|
+
closeIndex = index;
|
|
1535
|
+
break;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
if (closeIndex === -1) throw new Error(`The Tailwind CSS v4 inline source pattern "${pattern}" is not balanced.`);
|
|
1540
|
+
const body = rest.slice(1, closeIndex);
|
|
1541
|
+
const suffix = rest.slice(closeIndex + 1);
|
|
1542
|
+
const parts = sequencePattern.test(body) ? expandSequence(body) : splitTopLevel(body, ",").flatMap((part) => expandInlinePattern(part));
|
|
1543
|
+
const suffixes = expandInlinePattern(suffix);
|
|
1544
|
+
const result = [];
|
|
1545
|
+
for (const part of parts) for (const expandedSuffix of suffixes) result.push(`${prefix}${part}${expandedSuffix}`);
|
|
1546
|
+
return result;
|
|
1547
|
+
}
|
|
1548
|
+
function unquoteCssString(value) {
|
|
1549
|
+
const quote = value[0];
|
|
1550
|
+
if (quote !== "\"" && quote !== "'" || value[value.length - 1] !== quote) return;
|
|
1551
|
+
let result = "";
|
|
1552
|
+
for (let index = 1; index < value.length - 1; index++) {
|
|
1553
|
+
const character = value[index];
|
|
1554
|
+
if (character === "\\") {
|
|
1555
|
+
index++;
|
|
1556
|
+
result += value[index] ?? "";
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
result += character;
|
|
1560
|
+
}
|
|
1561
|
+
return result;
|
|
1562
|
+
}
|
|
1563
|
+
function extractTailwindV4InlineSourceCandidates(css) {
|
|
1564
|
+
const included = /* @__PURE__ */ new Set();
|
|
1565
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
1566
|
+
postcss.default.parse(css).walkAtRules("source", (rule) => {
|
|
1567
|
+
let params = rule.params.trim();
|
|
1568
|
+
if (!params) return;
|
|
1569
|
+
let negated = false;
|
|
1570
|
+
if (params.startsWith("not ")) {
|
|
1571
|
+
negated = true;
|
|
1572
|
+
params = params.slice(4).trim();
|
|
1573
|
+
}
|
|
1574
|
+
if (!params.startsWith("inline(") || !params.endsWith(")")) return;
|
|
1575
|
+
const inlineValue = unquoteCssString(params.slice(7, -1).trim());
|
|
1576
|
+
if (inlineValue === void 0) return;
|
|
1577
|
+
const target = negated ? excluded : included;
|
|
1578
|
+
for (const part of splitTopLevel(inlineValue, " ")) for (const candidate of expandInlinePattern(part)) target.add(candidate);
|
|
1579
|
+
});
|
|
1580
|
+
return {
|
|
1581
|
+
included,
|
|
1582
|
+
excluded
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
//#endregion
|
|
1586
|
+
//#region src/v4/node-adapter.ts
|
|
1587
|
+
const nodeModulePromiseCache = /* @__PURE__ */ new Map();
|
|
1453
1588
|
const designSystemPromiseCache = /* @__PURE__ */ new Map();
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
return import("@tailwindcss/node");
|
|
1589
|
+
function unique(values) {
|
|
1590
|
+
return Array.from(new Set(Array.from(values).filter(Boolean).map((value) => pathe.default.resolve(value))));
|
|
1457
1591
|
}
|
|
1458
|
-
|
|
1459
|
-
return
|
|
1592
|
+
function createRequireBase(base) {
|
|
1593
|
+
return pathe.default.join(base, "package.json");
|
|
1460
1594
|
}
|
|
1461
|
-
function
|
|
1462
|
-
|
|
1463
|
-
return nodeImportPromise;
|
|
1595
|
+
function isRelativeSpecifier(id) {
|
|
1596
|
+
return id.startsWith("./") || id.startsWith("../") || id === "." || id === "..";
|
|
1464
1597
|
}
|
|
1465
|
-
function
|
|
1466
|
-
|
|
1467
|
-
|
|
1598
|
+
function isAbsoluteSpecifier(id) {
|
|
1599
|
+
return pathe.default.isAbsolute(id);
|
|
1600
|
+
}
|
|
1601
|
+
function isCssSpecifier(id) {
|
|
1602
|
+
return pathe.default.extname(id) === ".css";
|
|
1603
|
+
}
|
|
1604
|
+
function createCssResolutionCandidates(id) {
|
|
1605
|
+
if (isCssSpecifier(id)) return [id];
|
|
1606
|
+
return [`${id}/index.css`, id];
|
|
1607
|
+
}
|
|
1608
|
+
function createFallbackCssResolver(baseCandidates) {
|
|
1609
|
+
const bases = unique(baseCandidates);
|
|
1610
|
+
return async (id) => {
|
|
1611
|
+
if (isRelativeSpecifier(id) || isAbsoluteSpecifier(id)) return;
|
|
1612
|
+
for (const base of bases) {
|
|
1613
|
+
const requireFromBase = (0, node_module.createRequire)(createRequireBase(base));
|
|
1614
|
+
for (const candidate of createCssResolutionCandidates(id)) try {
|
|
1615
|
+
return requireFromBase.resolve(candidate);
|
|
1616
|
+
} catch {}
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
async function importResolvedModule(resolved) {
|
|
1621
|
+
return import((0, node_url.pathToFileURL)(resolved).href);
|
|
1622
|
+
}
|
|
1623
|
+
async function importTailwindNodeFromBase(base) {
|
|
1624
|
+
try {
|
|
1625
|
+
return await importResolvedModule((0, node_module.createRequire)(createRequireBase(base)).resolve("@tailwindcss/node"));
|
|
1626
|
+
} catch {
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
async function importFallbackTailwindNode() {
|
|
1631
|
+
return import("@tailwindcss/node");
|
|
1632
|
+
}
|
|
1633
|
+
async function loadTailwindV4NodeModule(baseCandidates) {
|
|
1634
|
+
const bases = unique(baseCandidates);
|
|
1635
|
+
const cacheKey = JSON.stringify(bases);
|
|
1636
|
+
const cached = nodeModulePromiseCache.get(cacheKey);
|
|
1637
|
+
if (cached) return cached;
|
|
1638
|
+
const promise = (async () => {
|
|
1639
|
+
for (const base of bases) {
|
|
1640
|
+
const loaded = await importTailwindNodeFromBase(base);
|
|
1641
|
+
if (loaded) return loaded;
|
|
1642
|
+
}
|
|
1643
|
+
return importFallbackTailwindNode();
|
|
1644
|
+
})();
|
|
1645
|
+
nodeModulePromiseCache.set(cacheKey, promise);
|
|
1646
|
+
promise.catch(() => {
|
|
1647
|
+
if (nodeModulePromiseCache.get(cacheKey) === promise) nodeModulePromiseCache.delete(cacheKey);
|
|
1648
|
+
});
|
|
1649
|
+
return promise;
|
|
1468
1650
|
}
|
|
1469
1651
|
function createDesignSystemCacheKey(css, bases) {
|
|
1470
1652
|
return JSON.stringify({
|
|
1471
1653
|
css,
|
|
1472
|
-
bases:
|
|
1654
|
+
bases: unique(bases)
|
|
1473
1655
|
});
|
|
1474
1656
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1657
|
+
function getTailwindV4DesignSystemCacheKey(source) {
|
|
1658
|
+
return createDesignSystemCacheKey(source.css, [source.base, ...source.baseFallbacks]);
|
|
1659
|
+
}
|
|
1660
|
+
async function loadTailwindV4DesignSystem(source) {
|
|
1661
|
+
const bases = unique([source.base, ...source.baseFallbacks]);
|
|
1662
|
+
if (bases.length === 0) throw new Error("No base directories provided for Tailwind CSS v4 design system.");
|
|
1663
|
+
const cacheKey = createDesignSystemCacheKey(source.css, bases);
|
|
1479
1664
|
const cached = designSystemPromiseCache.get(cacheKey);
|
|
1480
1665
|
if (cached) return cached;
|
|
1481
1666
|
const promise = (async () => {
|
|
1482
|
-
const
|
|
1667
|
+
const node = await loadTailwindV4NodeModule([source.projectRoot, ...bases]);
|
|
1483
1668
|
let lastError;
|
|
1484
|
-
for (const base of
|
|
1485
|
-
return await __unstable__loadDesignSystem(css, { base });
|
|
1669
|
+
for (const base of bases) try {
|
|
1670
|
+
return await node.__unstable__loadDesignSystem(source.css, { base });
|
|
1486
1671
|
} catch (error) {
|
|
1487
1672
|
lastError = error;
|
|
1488
1673
|
}
|
|
1489
1674
|
if (lastError instanceof Error) throw lastError;
|
|
1490
|
-
throw new Error("Failed to load Tailwind CSS design system.");
|
|
1675
|
+
throw new Error("Failed to load Tailwind CSS v4 design system.");
|
|
1491
1676
|
})();
|
|
1492
1677
|
designSystemPromiseCache.set(cacheKey, promise);
|
|
1493
1678
|
promise.catch(() => {
|
|
1494
|
-
if (designSystemPromiseCache.get(cacheKey) === promise)
|
|
1495
|
-
designSystemPromiseCache.delete(cacheKey);
|
|
1496
|
-
designSystemCandidateCache.delete(cacheKey);
|
|
1497
|
-
}
|
|
1679
|
+
if (designSystemPromiseCache.get(cacheKey) === promise) designSystemPromiseCache.delete(cacheKey);
|
|
1498
1680
|
});
|
|
1499
1681
|
return promise;
|
|
1500
1682
|
}
|
|
1683
|
+
async function compileTailwindV4Source(source) {
|
|
1684
|
+
const bases = unique([source.base, ...source.baseFallbacks]);
|
|
1685
|
+
if (bases.length === 0) throw new Error("No base directories provided for Tailwind CSS v4 compiler.");
|
|
1686
|
+
const node = await loadTailwindV4NodeModule([source.projectRoot, ...bases]);
|
|
1687
|
+
let lastError;
|
|
1688
|
+
for (const base of bases) {
|
|
1689
|
+
const dependencies = new Set(source.dependencies);
|
|
1690
|
+
try {
|
|
1691
|
+
return {
|
|
1692
|
+
compiled: await node.compile(source.css, {
|
|
1693
|
+
base,
|
|
1694
|
+
customCssResolver: createFallbackCssResolver([source.projectRoot, ...bases]),
|
|
1695
|
+
onDependency(dependency) {
|
|
1696
|
+
dependencies.add(pathe.default.resolve(dependency));
|
|
1697
|
+
}
|
|
1698
|
+
}),
|
|
1699
|
+
dependencies
|
|
1700
|
+
};
|
|
1701
|
+
} catch (error) {
|
|
1702
|
+
lastError = error;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
if (lastError instanceof Error) throw lastError;
|
|
1706
|
+
throw new Error("Failed to compile Tailwind CSS v4 source.");
|
|
1707
|
+
}
|
|
1708
|
+
//#endregion
|
|
1709
|
+
//#region src/extraction/candidate-extractor.ts
|
|
1710
|
+
let oxideImportPromise;
|
|
1711
|
+
const designSystemCandidateCache = /* @__PURE__ */ new Map();
|
|
1712
|
+
async function importOxide() {
|
|
1713
|
+
return import("@tailwindcss/oxide");
|
|
1714
|
+
}
|
|
1715
|
+
function getOxideModule() {
|
|
1716
|
+
oxideImportPromise ??= importOxide();
|
|
1717
|
+
return oxideImportPromise;
|
|
1718
|
+
}
|
|
1501
1719
|
async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
1502
1720
|
const { Scanner } = await getOxideModule();
|
|
1503
1721
|
return new Scanner({}).getCandidatesWithPositions({
|
|
@@ -1528,8 +1746,15 @@ async function extractValidCandidates(options) {
|
|
|
1528
1746
|
pattern: source.pattern,
|
|
1529
1747
|
negated: source.negated
|
|
1530
1748
|
}));
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1749
|
+
const source = {
|
|
1750
|
+
projectRoot: defaultCwd,
|
|
1751
|
+
base,
|
|
1752
|
+
baseFallbacks,
|
|
1753
|
+
css,
|
|
1754
|
+
dependencies: []
|
|
1755
|
+
};
|
|
1756
|
+
const designSystemKey = getTailwindV4DesignSystemCacheKey(source);
|
|
1757
|
+
const designSystem = await loadTailwindV4DesignSystem(source);
|
|
1533
1758
|
const candidateCache = designSystemCandidateCache.get(designSystemKey) ?? /* @__PURE__ */ new Map();
|
|
1534
1759
|
designSystemCandidateCache.set(designSystemKey, candidateCache);
|
|
1535
1760
|
const candidates = await extractRawCandidates(sources);
|
|
@@ -1549,12 +1774,9 @@ async function extractValidCandidates(options) {
|
|
|
1549
1774
|
candidateCache.set(rawCandidate, false);
|
|
1550
1775
|
}
|
|
1551
1776
|
if (uncachedCandidates.length === 0) return validCandidates;
|
|
1552
|
-
const
|
|
1553
|
-
for (
|
|
1554
|
-
const
|
|
1555
|
-
if (candidate === void 0) continue;
|
|
1556
|
-
const candidateCss = cssByCandidate[index];
|
|
1557
|
-
const isValid = typeof candidateCss === "string" && candidateCss.trim().length > 0;
|
|
1777
|
+
const validUncachedCandidates = resolveValidTailwindV4Candidates(designSystem, uncachedCandidates);
|
|
1778
|
+
for (const candidate of uncachedCandidates) {
|
|
1779
|
+
const isValid = validUncachedCandidates.has(candidate);
|
|
1558
1780
|
candidateCache.set(candidate, isValid);
|
|
1559
1781
|
if (!isValid) continue;
|
|
1560
1782
|
validCandidates.push(candidate);
|
|
@@ -3395,6 +3617,12 @@ Object.defineProperty(exports, "collectClassesFromTailwindV4", {
|
|
|
3395
3617
|
return collectClassesFromTailwindV4;
|
|
3396
3618
|
}
|
|
3397
3619
|
});
|
|
3620
|
+
Object.defineProperty(exports, "compileTailwindV4Source", {
|
|
3621
|
+
enumerable: true,
|
|
3622
|
+
get: function() {
|
|
3623
|
+
return compileTailwindV4Source;
|
|
3624
|
+
}
|
|
3625
|
+
});
|
|
3398
3626
|
Object.defineProperty(exports, "extractProjectCandidatesWithPositions", {
|
|
3399
3627
|
enumerable: true,
|
|
3400
3628
|
get: function() {
|
|
@@ -3413,6 +3641,12 @@ Object.defineProperty(exports, "extractRawCandidatesWithPositions", {
|
|
|
3413
3641
|
return extractRawCandidatesWithPositions;
|
|
3414
3642
|
}
|
|
3415
3643
|
});
|
|
3644
|
+
Object.defineProperty(exports, "extractTailwindV4InlineSourceCandidates", {
|
|
3645
|
+
enumerable: true,
|
|
3646
|
+
get: function() {
|
|
3647
|
+
return extractTailwindV4InlineSourceCandidates;
|
|
3648
|
+
}
|
|
3649
|
+
});
|
|
3416
3650
|
Object.defineProperty(exports, "extractValidCandidates", {
|
|
3417
3651
|
enumerable: true,
|
|
3418
3652
|
get: function() {
|
|
@@ -3443,6 +3677,12 @@ Object.defineProperty(exports, "loadRuntimeContexts", {
|
|
|
3443
3677
|
return loadRuntimeContexts;
|
|
3444
3678
|
}
|
|
3445
3679
|
});
|
|
3680
|
+
Object.defineProperty(exports, "loadTailwindV4DesignSystem", {
|
|
3681
|
+
enumerable: true,
|
|
3682
|
+
get: function() {
|
|
3683
|
+
return loadTailwindV4DesignSystem;
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3446
3686
|
Object.defineProperty(exports, "loadWorkspaceConfigModule", {
|
|
3447
3687
|
enumerable: true,
|
|
3448
3688
|
get: function() {
|
|
@@ -3467,6 +3707,12 @@ Object.defineProperty(exports, "normalizeOptions", {
|
|
|
3467
3707
|
return normalizeOptions;
|
|
3468
3708
|
}
|
|
3469
3709
|
});
|
|
3710
|
+
Object.defineProperty(exports, "resolveValidTailwindV4Candidates", {
|
|
3711
|
+
enumerable: true,
|
|
3712
|
+
get: function() {
|
|
3713
|
+
return resolveValidTailwindV4Candidates;
|
|
3714
|
+
}
|
|
3715
|
+
});
|
|
3470
3716
|
Object.defineProperty(exports, "restoreConfigFiles", {
|
|
3471
3717
|
enumerable: true,
|
|
3472
3718
|
get: function() {
|