tailwindcss-patch 9.3.5 → 9.3.6
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-Cz6ZOOFG.js → index.bundle-BF-qTWsU.js} +17 -6
- package/dist/{index.bundle-BXhvZOy8.mjs → index.bundle-BR8XOc2F.mjs} +17 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/index.mjs +3 -3
- package/dist/{validate-SJIkeBUb.mjs → validate-BF0OladD.mjs} +122 -22
- package/dist/{validate-5TFH6ktk.js → validate-CLTQnfBI.js} +126 -20
- package/dist/{validate-ZwyABmFW.d.ts → validate-DoeOD2Su.d.mts} +17 -5
- package/dist/{validate-Bd5gnHL1.d.mts → validate-eCzgDdk_.d.ts} +18 -4
- package/package.json +4 -4
- package/src/extraction/candidate-extractor.ts +161 -24
- package/src/index.bundle.ts +2 -0
- package/src/index.ts +1 -0
- package/src/v4/candidates.ts +4 -4
- package/src/v4/engine.ts +15 -3
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_validate = require("./validate-
|
|
3
|
-
const require_index_bundle = require("./index.bundle-
|
|
2
|
+
const require_validate = require("./validate-CLTQnfBI.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-BF-qTWsU.js");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
6
6
|
//#region src/cli.bundle.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as createTailwindcssPatchCli } from "./index.bundle-
|
|
1
|
+
import { P as logger, r as ValidateCommandError } from "./validate-BF0OladD.mjs";
|
|
2
|
+
import { t as createTailwindcssPatchCli } from "./index.bundle-BR8XOc2F.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
//#region src/cli.bundle.ts
|
|
5
5
|
async function main() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-
|
|
1
|
+
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-DoeOD2Su.mjs";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
|
|
4
4
|
//#region src/commands/cli.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-
|
|
1
|
+
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-eCzgDdk_.js";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
|
|
4
4
|
//#region src/commands/cli.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../chunk-8l464Juk.js");
|
|
3
|
-
const require_validate = require("../validate-
|
|
3
|
+
const require_validate = require("../validate-CLTQnfBI.js");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
6
6
|
let fs_extra = require("fs-extra");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as loadPatchOptionsForWorkspace, P as logger, S as groupTokensByFile, a as tailwindcssPatchCommands, i as classifyValidateError, j as loadWorkspaceConfigModule, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher } from "../validate-BF0OladD.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
import path from "pathe";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_validate = require("./validate-
|
|
2
|
+
const require_validate = require("./validate-CLTQnfBI.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -7,19 +7,30 @@ let pathe = require("pathe");
|
|
|
7
7
|
pathe = require_chunk.__toESM(pathe);
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
//#region src/v4/engine.ts
|
|
10
|
-
function resolveScanSources(options, compiledSources) {
|
|
10
|
+
function resolveScanSources(options, source, compiledRoot, compiledSources) {
|
|
11
11
|
if (Array.isArray(options?.scanSources)) return options.scanSources;
|
|
12
|
-
if (options?.scanSources === true) return
|
|
12
|
+
if (options?.scanSources === true) return [...(() => {
|
|
13
|
+
if (compiledRoot === "none") return [];
|
|
14
|
+
if (compiledRoot === null) return [{
|
|
15
|
+
base: source.base,
|
|
16
|
+
pattern: "**/*",
|
|
17
|
+
negated: false
|
|
18
|
+
}];
|
|
19
|
+
return [{
|
|
20
|
+
...compiledRoot,
|
|
21
|
+
negated: false
|
|
22
|
+
}];
|
|
23
|
+
})(), ...compiledSources];
|
|
13
24
|
return [];
|
|
14
25
|
}
|
|
15
|
-
async function collectRawCandidates(source, options, compiledSources = []) {
|
|
26
|
+
async function collectRawCandidates(source, options, compiledRoot, compiledSources = []) {
|
|
16
27
|
const rawCandidates = /* @__PURE__ */ new Set();
|
|
17
28
|
for (const candidate of options?.candidates ?? []) rawCandidates.add(candidate);
|
|
18
29
|
for (const candidateSource of options?.sources ?? []) {
|
|
19
30
|
const candidates = await require_validate.extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension);
|
|
20
31
|
for (const candidate of candidates) rawCandidates.add(candidate.rawCandidate);
|
|
21
32
|
}
|
|
22
|
-
const filesystemSources = resolveScanSources(options, compiledSources);
|
|
33
|
+
const filesystemSources = resolveScanSources(options, source, compiledRoot, compiledSources);
|
|
23
34
|
if (filesystemSources.length > 0) for (const candidate of await require_validate.extractRawCandidates(filesystemSources)) rawCandidates.add(candidate);
|
|
24
35
|
const inlineSources = require_validate.extractTailwindV4InlineSourceCandidates(source.css);
|
|
25
36
|
for (const candidate of inlineSources.included) rawCandidates.add(candidate);
|
|
@@ -37,7 +48,7 @@ function createTailwindV4Engine(source) {
|
|
|
37
48
|
},
|
|
38
49
|
async generate(options) {
|
|
39
50
|
const { compiled, dependencies } = await require_validate.compileTailwindV4Source(source);
|
|
40
|
-
const rawCandidates = await collectRawCandidates(source, options, compiled.sources);
|
|
51
|
+
const rawCandidates = await collectRawCandidates(source, options, compiled.root, compiled.sources);
|
|
41
52
|
const classSet = require_validate.resolveValidTailwindV4Candidates(await require_validate.loadTailwindV4DesignSystem(source), rawCandidates, { ...options?.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
42
53
|
const inlineSources = require_validate.extractTailwindV4InlineSourceCandidates(source.css);
|
|
43
54
|
for (const candidate of inlineSources.excluded) classSet.delete(candidate);
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as extractTailwindV4InlineSourceCandidates, E as canonicalizeBareArbitraryValueCandidates, M as normalizeOptions, O as replaceBareArbitraryValueSelectors, T as loadTailwindV4DesignSystem, _ as extractRawCandidates, k as resolveValidTailwindV4Candidates, v as extractRawCandidatesWithPositions, w as compileTailwindV4Source } from "./validate-BF0OladD.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import path from "pathe";
|
|
5
5
|
import { promises } from "node:fs";
|
|
6
6
|
//#region src/v4/engine.ts
|
|
7
|
-
function resolveScanSources(options, compiledSources) {
|
|
7
|
+
function resolveScanSources(options, source, compiledRoot, compiledSources) {
|
|
8
8
|
if (Array.isArray(options?.scanSources)) return options.scanSources;
|
|
9
|
-
if (options?.scanSources === true) return
|
|
9
|
+
if (options?.scanSources === true) return [...(() => {
|
|
10
|
+
if (compiledRoot === "none") return [];
|
|
11
|
+
if (compiledRoot === null) return [{
|
|
12
|
+
base: source.base,
|
|
13
|
+
pattern: "**/*",
|
|
14
|
+
negated: false
|
|
15
|
+
}];
|
|
16
|
+
return [{
|
|
17
|
+
...compiledRoot,
|
|
18
|
+
negated: false
|
|
19
|
+
}];
|
|
20
|
+
})(), ...compiledSources];
|
|
10
21
|
return [];
|
|
11
22
|
}
|
|
12
|
-
async function collectRawCandidates(source, options, compiledSources = []) {
|
|
23
|
+
async function collectRawCandidates(source, options, compiledRoot, compiledSources = []) {
|
|
13
24
|
const rawCandidates = /* @__PURE__ */ new Set();
|
|
14
25
|
for (const candidate of options?.candidates ?? []) rawCandidates.add(candidate);
|
|
15
26
|
for (const candidateSource of options?.sources ?? []) {
|
|
16
27
|
const candidates = await extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension);
|
|
17
28
|
for (const candidate of candidates) rawCandidates.add(candidate.rawCandidate);
|
|
18
29
|
}
|
|
19
|
-
const filesystemSources = resolveScanSources(options, compiledSources);
|
|
30
|
+
const filesystemSources = resolveScanSources(options, source, compiledRoot, compiledSources);
|
|
20
31
|
if (filesystemSources.length > 0) for (const candidate of await extractRawCandidates(filesystemSources)) rawCandidates.add(candidate);
|
|
21
32
|
const inlineSources = extractTailwindV4InlineSourceCandidates(source.css);
|
|
22
33
|
for (const candidate of inlineSources.included) rawCandidates.add(candidate);
|
|
@@ -34,7 +45,7 @@ function createTailwindV4Engine(source) {
|
|
|
34
45
|
},
|
|
35
46
|
async generate(options) {
|
|
36
47
|
const { compiled, dependencies } = await compileTailwindV4Source(source);
|
|
37
|
-
const rawCandidates = await collectRawCandidates(source, options, compiled.sources);
|
|
48
|
+
const rawCandidates = await collectRawCandidates(source, options, compiled.root, compiled.sources);
|
|
38
49
|
const classSet = resolveValidTailwindV4Candidates(await loadTailwindV4DesignSystem(source), rawCandidates, { ...options?.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
39
50
|
const inlineSources = extractTailwindV4InlineSourceCandidates(source.css);
|
|
40
51
|
for (const candidate of inlineSources.excluded) classSet.delete(candidate);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TailwindV4GenerateOptions, A as extractSourceCandidatesWithPositions, B as ExtendLengthUnitsOptions, C as MIGRATION_REPORT_SCHEMA_VERSION, Ct as CacheReadResult, D as extractRawCandidates, E as extractProjectCandidatesWithPositions, F as normalizeOptions, G as TailwindCssPatchOptions, H as NormalizedCacheOptions, I as ApplyOptions, J as TailwindV4Options, K as TailwindV2Options, L as CacheOptions, M as groupTokensByFile, N as resolveProjectSourceFiles, O as extractRawCandidatesWithPositions, P as BareArbitraryValueOptions, Q as TailwindV4Engine, R as CacheStrategy, S as MIGRATION_REPORT_KIND, St as CacheReadMeta, T as TailwindcssPatcher, U as NormalizedTailwindCssPatchOptions, V as ExtractOptions, W as TailwindCssOptions, X as TailwindV4CssSource, Y as TailwindV4CandidateSource, Z as TailwindV4DesignSystem, _ as ConfigFileMigrationEntry, _t as CacheClearResult, a as ValidateFailureSummary, at as PatchCheckStatus, b as RestoreConfigFilesOptions, bt as CacheContextMetadata, c as TailwindcssPatchCliMountOptions, ct as PatchStatusReport, d as TailwindcssPatchCommandContext, dt as TailwindTokenFileKey, et as TailwindV4GenerateResult, f as TailwindcssPatchCommandHandler, ft as TailwindTokenLocation, g as tailwindcssPatchCommands, gt as CacheClearOptions, h as TailwindcssPatchCommandOptions, ht as TailwindcssRuntimeContext, i as ValidateFailureReason, it as ILengthUnitsPatchOptions, j as extractValidCandidates, k as extractSourceCandidates, l as TailwindcssPatchCliOptions, lt as TailwindPatchRuntime, m as TailwindcssPatchCommandOptionDefinition, mt as TailwindcssClassCache, n as VALIDATE_FAILURE_REASONS, nt as TailwindV4SourceOptions, o as ValidateJsonFailurePayload, ot as PatchName, p as TailwindcssPatchCommandHandlerMap, pt as TailwindTokenReport, q as TailwindV3Options, r as ValidateCommandError, rt as ExtractResult, s as ValidateJsonSuccessPayload, st as PatchStatusEntry, t as VALIDATE_EXIT_CODES, tt as TailwindV4ResolvedSource, u as TailwindcssPatchCommand, ut as TailwindTokenByFileMap, v as ConfigFileMigrationReport, vt as CacheClearScope, w as logger, x as RestoreConfigFilesResult, xt as CacheIndexFileV2, y as MigrateConfigFilesOptions, yt as CacheContextDescriptor, z as ExposeContextOptions } from "./validate-DoeOD2Su.mjs";
|
|
2
2
|
import { PackageInfo } from "local-pkg";
|
|
3
3
|
import postcss from "postcss";
|
|
4
4
|
import { CAC } from "cac";
|
|
@@ -97,4 +97,4 @@ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPa
|
|
|
97
97
|
declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
|
|
98
98
|
declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
|
|
99
99
|
//#endregion
|
|
100
|
-
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
100
|
+
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveProjectSourceFiles, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TailwindV4GenerateOptions, A as extractSourceCandidatesWithPositions, B as ExtendLengthUnitsOptions, C as MIGRATION_REPORT_SCHEMA_VERSION, Ct as CacheReadResult, D as extractRawCandidates, E as extractProjectCandidatesWithPositions, F as normalizeOptions, G as TailwindCssPatchOptions, H as NormalizedCacheOptions, I as ApplyOptions, J as TailwindV4Options, K as TailwindV2Options, L as CacheOptions, M as groupTokensByFile, N as resolveProjectSourceFiles, O as extractRawCandidatesWithPositions, P as BareArbitraryValueOptions, Q as TailwindV4Engine, R as CacheStrategy, S as MIGRATION_REPORT_KIND, St as CacheReadMeta, T as TailwindcssPatcher, U as NormalizedTailwindCssPatchOptions, V as ExtractOptions, W as TailwindCssOptions, X as TailwindV4CssSource, Y as TailwindV4CandidateSource, Z as TailwindV4DesignSystem, _ as ConfigFileMigrationEntry, _t as CacheClearResult, a as ValidateFailureSummary, at as PatchCheckStatus, b as RestoreConfigFilesOptions, bt as CacheContextMetadata, c as TailwindcssPatchCliMountOptions, ct as PatchStatusReport, d as TailwindcssPatchCommandContext, dt as TailwindTokenFileKey, et as TailwindV4GenerateResult, f as TailwindcssPatchCommandHandler, ft as TailwindTokenLocation, g as tailwindcssPatchCommands, gt as CacheClearOptions, h as TailwindcssPatchCommandOptions, ht as TailwindcssRuntimeContext, i as ValidateFailureReason, it as ILengthUnitsPatchOptions, j as extractValidCandidates, k as extractSourceCandidates, l as TailwindcssPatchCliOptions, lt as TailwindPatchRuntime, m as TailwindcssPatchCommandOptionDefinition, mt as TailwindcssClassCache, n as VALIDATE_FAILURE_REASONS, nt as TailwindV4SourceOptions, o as ValidateJsonFailurePayload, ot as PatchName, p as TailwindcssPatchCommandHandlerMap, pt as TailwindTokenReport, q as TailwindV3Options, r as ValidateCommandError, rt as ExtractResult, s as ValidateJsonSuccessPayload, st as PatchStatusEntry, t as VALIDATE_EXIT_CODES, tt as TailwindV4ResolvedSource, u as TailwindcssPatchCommand, ut as TailwindTokenByFileMap, v as ConfigFileMigrationReport, vt as CacheClearScope, w as logger, x as RestoreConfigFilesResult, xt as CacheIndexFileV2, y as MigrateConfigFilesOptions, yt as CacheContextDescriptor, z as ExposeContextOptions } from "./validate-eCzgDdk_.js";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
import { PackageInfo } from "local-pkg";
|
|
4
4
|
import postcss from "postcss";
|
|
@@ -97,4 +97,4 @@ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPa
|
|
|
97
97
|
declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
|
|
98
98
|
declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
|
|
99
99
|
//#endregion
|
|
100
|
-
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
100
|
+
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveProjectSourceFiles, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
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-CLTQnfBI.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-BF-qTWsU.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;
|
|
@@ -27,6 +27,7 @@ exports.logger = require_validate.logger;
|
|
|
27
27
|
exports.migrateConfigFiles = require_validate.migrateConfigFiles;
|
|
28
28
|
exports.mountTailwindcssPatchCommands = require_index_bundle.mountTailwindcssPatchCommands;
|
|
29
29
|
exports.normalizeOptions = require_validate.normalizeOptions;
|
|
30
|
+
exports.resolveProjectSourceFiles = require_validate.resolveProjectSourceFiles;
|
|
30
31
|
exports.resolveTailwindV4Source = require_index_bundle.resolveTailwindV4Source;
|
|
31
32
|
exports.resolveTailwindV4SourceFromPatchOptions = require_index_bundle.resolveTailwindV4SourceFromPatchOptions;
|
|
32
33
|
exports.resolveValidTailwindV4Candidates = require_validate.resolveValidTailwindV4Candidates;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { M as
|
|
2
|
-
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, 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, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
1
|
+
import { C as resolveProjectSourceFiles, M as normalizeOptions, N as CacheStore, P as logger, S as groupTokensByFile, T as loadTailwindV4DesignSystem, _ as extractRawCandidates, a as tailwindcssPatchCommands, b as extractSourceCandidatesWithPositions, c as MIGRATION_REPORT_KIND, d as getPatchStatusReport, f as runTailwindBuild, g as extractProjectCandidatesWithPositions, h as collectClassesFromTailwindV4, k as resolveValidTailwindV4Candidates, 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, x as extractValidCandidates, y as extractSourceCandidates } from "./validate-BF0OladD.mjs";
|
|
2
|
+
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-BR8XOc2F.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, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveProjectSourceFiles, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
@@ -16,7 +16,7 @@ import _babelTraverse from "@babel/traverse";
|
|
|
16
16
|
import { parse, parse as parse$1 } from "@babel/parser";
|
|
17
17
|
import { loadConfig } from "tailwindcss-config";
|
|
18
18
|
//#region package.json
|
|
19
|
-
var version = "9.3.
|
|
19
|
+
var version = "9.3.6";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/constants.ts
|
|
22
22
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1410,7 +1410,7 @@ function normalizeOptions(options = {}) {
|
|
|
1410
1410
|
};
|
|
1411
1411
|
}
|
|
1412
1412
|
//#endregion
|
|
1413
|
-
//#region ../../node_modules/.pnpm/tsdown@0.22.0_tsx@4.
|
|
1413
|
+
//#region ../../node_modules/.pnpm/tsdown@0.22.0_tsx@4.22.3_typescript@6.0.3_unrun@0.2.37_synckit@0.11.12_/node_modules/tsdown/esm-shims.js
|
|
1414
1414
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
1415
1415
|
const getDirname = () => path$1.dirname(getFilename());
|
|
1416
1416
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -1798,7 +1798,7 @@ function canonicalizeBareArbitraryValueCandidates(candidates, options) {
|
|
|
1798
1798
|
return resolveBareArbitraryValueCandidate(candidate, options)?.canonicalCandidate ?? candidate;
|
|
1799
1799
|
});
|
|
1800
1800
|
}
|
|
1801
|
-
function splitTopLevel(value, separator) {
|
|
1801
|
+
function splitTopLevel(value, separator, options) {
|
|
1802
1802
|
const result = [];
|
|
1803
1803
|
let start = 0;
|
|
1804
1804
|
let depth = 0;
|
|
@@ -1827,12 +1827,12 @@ function splitTopLevel(value, separator) {
|
|
|
1827
1827
|
}
|
|
1828
1828
|
if (depth === 0 && character === separator) {
|
|
1829
1829
|
const item = value.slice(start, index).trim();
|
|
1830
|
-
if (item) result.push(item);
|
|
1830
|
+
if (item || options?.keepEmpty) result.push(item);
|
|
1831
1831
|
start = index + 1;
|
|
1832
1832
|
}
|
|
1833
1833
|
}
|
|
1834
1834
|
const item = value.slice(start).trim();
|
|
1835
|
-
if (item) result.push(item);
|
|
1835
|
+
if (item || options?.keepEmpty) result.push(item);
|
|
1836
1836
|
return result;
|
|
1837
1837
|
}
|
|
1838
1838
|
const sequencePattern = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
@@ -1873,7 +1873,7 @@ function expandInlinePattern(pattern) {
|
|
|
1873
1873
|
if (closeIndex === -1) throw new Error(`The Tailwind CSS v4 inline source pattern "${pattern}" is not balanced.`);
|
|
1874
1874
|
const body = rest.slice(1, closeIndex);
|
|
1875
1875
|
const suffix = rest.slice(closeIndex + 1);
|
|
1876
|
-
const parts = sequencePattern.test(body) ? expandSequence(body) : splitTopLevel(body, ",").flatMap((part) => expandInlinePattern(part));
|
|
1876
|
+
const parts = sequencePattern.test(body) ? expandSequence(body) : splitTopLevel(body, ",", { keepEmpty: true }).flatMap((part) => expandInlinePattern(part));
|
|
1877
1877
|
const suffixes = expandInlinePattern(suffix);
|
|
1878
1878
|
const result = [];
|
|
1879
1879
|
for (const part of parts) for (const expandedSuffix of suffixes) result.push(`${prefix}${part}${expandedSuffix}`);
|
|
@@ -2284,6 +2284,15 @@ async function extractValidCandidates(options) {
|
|
|
2284
2284
|
const candidateCache = designSystemCandidateCache.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
|
|
2285
2285
|
designSystemCandidateCache.set(candidateCacheKey, candidateCache);
|
|
2286
2286
|
const candidates = await extractRawCandidates(sources);
|
|
2287
|
+
const inlineSources = extractTailwindV4InlineSourceCandidates(css);
|
|
2288
|
+
for (const candidate of inlineSources.included) candidates.push(candidate);
|
|
2289
|
+
for (const candidate of inlineSources.excluded) {
|
|
2290
|
+
let index = candidates.indexOf(candidate);
|
|
2291
|
+
while (index !== -1) {
|
|
2292
|
+
candidates.splice(index, 1);
|
|
2293
|
+
index = candidates.indexOf(candidate);
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2287
2296
|
const validCandidates = [];
|
|
2288
2297
|
const uncachedCandidates = [];
|
|
2289
2298
|
for (const rawCandidate of candidates) {
|
|
@@ -2310,17 +2319,6 @@ async function extractValidCandidates(options) {
|
|
|
2310
2319
|
}
|
|
2311
2320
|
return validCandidates;
|
|
2312
2321
|
}
|
|
2313
|
-
function normalizeSources(sources, cwd) {
|
|
2314
|
-
return (sources?.length ? sources : [{
|
|
2315
|
-
base: cwd,
|
|
2316
|
-
pattern: "**/*",
|
|
2317
|
-
negated: false
|
|
2318
|
-
}]).map((source) => ({
|
|
2319
|
-
base: source.base ?? cwd,
|
|
2320
|
-
pattern: source.pattern,
|
|
2321
|
-
negated: source.negated
|
|
2322
|
-
}));
|
|
2323
|
-
}
|
|
2324
2322
|
function buildLineOffsets(content) {
|
|
2325
2323
|
const offsets = [0];
|
|
2326
2324
|
for (let i = 0; i < content.length; i++) if (content[i] === "\n") offsets.push(i + 1);
|
|
@@ -2366,11 +2364,113 @@ function toRelativeFile(cwd, filename) {
|
|
|
2366
2364
|
const relative = path.relative(cwd, filename);
|
|
2367
2365
|
return relative === "" ? path.basename(filename) : relative;
|
|
2368
2366
|
}
|
|
2369
|
-
|
|
2367
|
+
function expandBracePattern(pattern) {
|
|
2368
|
+
const index = pattern.indexOf("{");
|
|
2369
|
+
if (index === -1) return [pattern];
|
|
2370
|
+
const rest = pattern.slice(index);
|
|
2371
|
+
let depth = 0;
|
|
2372
|
+
let endIndex = -1;
|
|
2373
|
+
for (let i = 0; i < rest.length; i++) {
|
|
2374
|
+
const char = rest[i];
|
|
2375
|
+
if (char === "\\") {
|
|
2376
|
+
i += 1;
|
|
2377
|
+
continue;
|
|
2378
|
+
}
|
|
2379
|
+
if (char === "{") {
|
|
2380
|
+
depth += 1;
|
|
2381
|
+
continue;
|
|
2382
|
+
}
|
|
2383
|
+
if (char === "}") {
|
|
2384
|
+
depth -= 1;
|
|
2385
|
+
if (depth === 0) {
|
|
2386
|
+
endIndex = i;
|
|
2387
|
+
break;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
if (endIndex === -1) return [pattern];
|
|
2392
|
+
const prefix = pattern.slice(0, index);
|
|
2393
|
+
const inner = rest.slice(1, endIndex);
|
|
2394
|
+
const suffix = rest.slice(endIndex + 1);
|
|
2395
|
+
const parts = [];
|
|
2396
|
+
const stack = [];
|
|
2397
|
+
let lastPos = 0;
|
|
2398
|
+
for (let i = 0; i < inner.length; i++) {
|
|
2399
|
+
const char = inner[i];
|
|
2400
|
+
if (char === "\\") {
|
|
2401
|
+
i += 1;
|
|
2402
|
+
continue;
|
|
2403
|
+
}
|
|
2404
|
+
if (char === "{") {
|
|
2405
|
+
stack.push("}");
|
|
2406
|
+
continue;
|
|
2407
|
+
}
|
|
2408
|
+
if (char === "}" && stack[stack.length - 1] === "}") {
|
|
2409
|
+
stack.pop();
|
|
2410
|
+
continue;
|
|
2411
|
+
}
|
|
2412
|
+
if (char === "," && stack.length === 0) {
|
|
2413
|
+
parts.push(inner.slice(lastPos, i));
|
|
2414
|
+
lastPos = i + 1;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
parts.push(inner.slice(lastPos));
|
|
2418
|
+
return parts.flatMap((part) => expandBracePattern(`${prefix}${part}${suffix}`));
|
|
2419
|
+
}
|
|
2420
|
+
function normalizeScannerSources(sources, cwd, ignoredSources = []) {
|
|
2421
|
+
return [...sources?.length ? sources : [{
|
|
2422
|
+
base: cwd,
|
|
2423
|
+
pattern: "**/*",
|
|
2424
|
+
negated: false
|
|
2425
|
+
}], ...ignoredSources].flatMap((source) => {
|
|
2426
|
+
const base = source.base ?? cwd;
|
|
2427
|
+
return expandBracePattern(source.pattern).map((pattern) => ({
|
|
2428
|
+
base,
|
|
2429
|
+
pattern,
|
|
2430
|
+
negated: source.negated
|
|
2431
|
+
}));
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
async function resolveScannerSources(options) {
|
|
2370
2435
|
const cwd = options?.cwd ? path.resolve(options.cwd) : process.cwd();
|
|
2371
|
-
|
|
2436
|
+
if (options?.sources?.length || options?.css === void 0) return {
|
|
2437
|
+
cwd,
|
|
2438
|
+
sources: normalizeScannerSources(options?.sources, cwd, options?.ignoredSources)
|
|
2439
|
+
};
|
|
2440
|
+
const base = options.base ? path.resolve(options.base) : cwd;
|
|
2441
|
+
const { compiled } = await compileTailwindV4Source({
|
|
2442
|
+
projectRoot: cwd,
|
|
2443
|
+
base,
|
|
2444
|
+
baseFallbacks: options.baseFallbacks?.map((baseFallback) => path.resolve(baseFallback)) ?? [],
|
|
2445
|
+
css: options.css,
|
|
2446
|
+
dependencies: []
|
|
2447
|
+
});
|
|
2448
|
+
return {
|
|
2449
|
+
cwd,
|
|
2450
|
+
sources: normalizeScannerSources([...(() => {
|
|
2451
|
+
if (compiled.root === "none") return [];
|
|
2452
|
+
if (compiled.root === null) return [{
|
|
2453
|
+
base,
|
|
2454
|
+
pattern: "**/*",
|
|
2455
|
+
negated: false
|
|
2456
|
+
}];
|
|
2457
|
+
return [{
|
|
2458
|
+
...compiled.root,
|
|
2459
|
+
negated: false
|
|
2460
|
+
}];
|
|
2461
|
+
})(), ...compiled.sources], cwd, options.ignoredSources)
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
2464
|
+
async function resolveProjectSourceFiles(options) {
|
|
2465
|
+
const { sources } = await resolveScannerSources(options);
|
|
2466
|
+
const { Scanner } = await getOxideModule();
|
|
2467
|
+
const files = new Scanner({ sources }).files ?? [];
|
|
2468
|
+
return options?.filter ? files.filter(options.filter) : files;
|
|
2469
|
+
}
|
|
2470
|
+
async function extractProjectCandidatesWithPositions(options) {
|
|
2471
|
+
const { cwd, sources } = await resolveScannerSources(options);
|
|
2372
2472
|
const { Scanner } = await getOxideModule();
|
|
2373
|
-
const scanner = new Scanner({ sources
|
|
2473
|
+
const scanner = new Scanner({ sources });
|
|
2374
2474
|
const files = scanner.files ?? [];
|
|
2375
2475
|
const entries = [];
|
|
2376
2476
|
const skipped = [];
|
|
@@ -2414,7 +2514,7 @@ async function extractProjectCandidatesWithPositions(options) {
|
|
|
2414
2514
|
entries,
|
|
2415
2515
|
filesScanned: files.length,
|
|
2416
2516
|
skippedFiles: skipped,
|
|
2417
|
-
sources
|
|
2517
|
+
sources
|
|
2418
2518
|
};
|
|
2419
2519
|
}
|
|
2420
2520
|
function groupTokensByFile(report, options) {
|
|
@@ -4107,4 +4207,4 @@ var ValidateCommandError = class extends Error {
|
|
|
4107
4207
|
}
|
|
4108
4208
|
};
|
|
4109
4209
|
//#endregion
|
|
4110
|
-
export {
|
|
4210
|
+
export { loadPatchOptionsForWorkspace as A, resolveProjectSourceFiles as C, extractTailwindV4InlineSourceCandidates as D, canonicalizeBareArbitraryValueCandidates as E, normalizeOptions as M, CacheStore as N, replaceBareArbitraryValueSelectors as O, logger as P, groupTokensByFile as S, loadTailwindV4DesignSystem as T, extractRawCandidates as _, tailwindcssPatchCommands as a, extractSourceCandidatesWithPositions as b, MIGRATION_REPORT_KIND as c, getPatchStatusReport as d, runTailwindBuild as f, extractProjectCandidatesWithPositions as g, collectClassesFromTailwindV4 as h, classifyValidateError as i, loadWorkspaceConfigModule as j, resolveValidTailwindV4Candidates as k, MIGRATION_REPORT_SCHEMA_VERSION as l, collectClassesFromContexts as m, VALIDATE_FAILURE_REASONS as n, migrateConfigFiles as o, loadRuntimeContexts as p, ValidateCommandError as r, restoreConfigFiles as s, VALIDATE_EXIT_CODES as t, TailwindcssPatcher as u, extractRawCandidatesWithPositions as v, compileTailwindV4Source as w, extractValidCandidates as x, extractSourceCandidates as y };
|
|
@@ -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.6";
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/constants.ts
|
|
29
29
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1800,7 +1800,7 @@ function canonicalizeBareArbitraryValueCandidates(candidates, options) {
|
|
|
1800
1800
|
return resolveBareArbitraryValueCandidate(candidate, options)?.canonicalCandidate ?? candidate;
|
|
1801
1801
|
});
|
|
1802
1802
|
}
|
|
1803
|
-
function splitTopLevel(value, separator) {
|
|
1803
|
+
function splitTopLevel(value, separator, options) {
|
|
1804
1804
|
const result = [];
|
|
1805
1805
|
let start = 0;
|
|
1806
1806
|
let depth = 0;
|
|
@@ -1829,12 +1829,12 @@ function splitTopLevel(value, separator) {
|
|
|
1829
1829
|
}
|
|
1830
1830
|
if (depth === 0 && character === separator) {
|
|
1831
1831
|
const item = value.slice(start, index).trim();
|
|
1832
|
-
if (item) result.push(item);
|
|
1832
|
+
if (item || options?.keepEmpty) result.push(item);
|
|
1833
1833
|
start = index + 1;
|
|
1834
1834
|
}
|
|
1835
1835
|
}
|
|
1836
1836
|
const item = value.slice(start).trim();
|
|
1837
|
-
if (item) result.push(item);
|
|
1837
|
+
if (item || options?.keepEmpty) result.push(item);
|
|
1838
1838
|
return result;
|
|
1839
1839
|
}
|
|
1840
1840
|
const sequencePattern = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
@@ -1875,7 +1875,7 @@ function expandInlinePattern(pattern) {
|
|
|
1875
1875
|
if (closeIndex === -1) throw new Error(`The Tailwind CSS v4 inline source pattern "${pattern}" is not balanced.`);
|
|
1876
1876
|
const body = rest.slice(1, closeIndex);
|
|
1877
1877
|
const suffix = rest.slice(closeIndex + 1);
|
|
1878
|
-
const parts = sequencePattern.test(body) ? expandSequence(body) : splitTopLevel(body, ",").flatMap((part) => expandInlinePattern(part));
|
|
1878
|
+
const parts = sequencePattern.test(body) ? expandSequence(body) : splitTopLevel(body, ",", { keepEmpty: true }).flatMap((part) => expandInlinePattern(part));
|
|
1879
1879
|
const suffixes = expandInlinePattern(suffix);
|
|
1880
1880
|
const result = [];
|
|
1881
1881
|
for (const part of parts) for (const expandedSuffix of suffixes) result.push(`${prefix}${part}${expandedSuffix}`);
|
|
@@ -2286,6 +2286,15 @@ async function extractValidCandidates(options) {
|
|
|
2286
2286
|
const candidateCache = designSystemCandidateCache.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
|
|
2287
2287
|
designSystemCandidateCache.set(candidateCacheKey, candidateCache);
|
|
2288
2288
|
const candidates = await extractRawCandidates(sources);
|
|
2289
|
+
const inlineSources = extractTailwindV4InlineSourceCandidates(css);
|
|
2290
|
+
for (const candidate of inlineSources.included) candidates.push(candidate);
|
|
2291
|
+
for (const candidate of inlineSources.excluded) {
|
|
2292
|
+
let index = candidates.indexOf(candidate);
|
|
2293
|
+
while (index !== -1) {
|
|
2294
|
+
candidates.splice(index, 1);
|
|
2295
|
+
index = candidates.indexOf(candidate);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2289
2298
|
const validCandidates = [];
|
|
2290
2299
|
const uncachedCandidates = [];
|
|
2291
2300
|
for (const rawCandidate of candidates) {
|
|
@@ -2312,17 +2321,6 @@ async function extractValidCandidates(options) {
|
|
|
2312
2321
|
}
|
|
2313
2322
|
return validCandidates;
|
|
2314
2323
|
}
|
|
2315
|
-
function normalizeSources(sources, cwd) {
|
|
2316
|
-
return (sources?.length ? sources : [{
|
|
2317
|
-
base: cwd,
|
|
2318
|
-
pattern: "**/*",
|
|
2319
|
-
negated: false
|
|
2320
|
-
}]).map((source) => ({
|
|
2321
|
-
base: source.base ?? cwd,
|
|
2322
|
-
pattern: source.pattern,
|
|
2323
|
-
negated: source.negated
|
|
2324
|
-
}));
|
|
2325
|
-
}
|
|
2326
2324
|
function buildLineOffsets(content) {
|
|
2327
2325
|
const offsets = [0];
|
|
2328
2326
|
for (let i = 0; i < content.length; i++) if (content[i] === "\n") offsets.push(i + 1);
|
|
@@ -2368,11 +2366,113 @@ function toRelativeFile(cwd, filename) {
|
|
|
2368
2366
|
const relative = pathe.default.relative(cwd, filename);
|
|
2369
2367
|
return relative === "" ? pathe.default.basename(filename) : relative;
|
|
2370
2368
|
}
|
|
2371
|
-
|
|
2369
|
+
function expandBracePattern(pattern) {
|
|
2370
|
+
const index = pattern.indexOf("{");
|
|
2371
|
+
if (index === -1) return [pattern];
|
|
2372
|
+
const rest = pattern.slice(index);
|
|
2373
|
+
let depth = 0;
|
|
2374
|
+
let endIndex = -1;
|
|
2375
|
+
for (let i = 0; i < rest.length; i++) {
|
|
2376
|
+
const char = rest[i];
|
|
2377
|
+
if (char === "\\") {
|
|
2378
|
+
i += 1;
|
|
2379
|
+
continue;
|
|
2380
|
+
}
|
|
2381
|
+
if (char === "{") {
|
|
2382
|
+
depth += 1;
|
|
2383
|
+
continue;
|
|
2384
|
+
}
|
|
2385
|
+
if (char === "}") {
|
|
2386
|
+
depth -= 1;
|
|
2387
|
+
if (depth === 0) {
|
|
2388
|
+
endIndex = i;
|
|
2389
|
+
break;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
if (endIndex === -1) return [pattern];
|
|
2394
|
+
const prefix = pattern.slice(0, index);
|
|
2395
|
+
const inner = rest.slice(1, endIndex);
|
|
2396
|
+
const suffix = rest.slice(endIndex + 1);
|
|
2397
|
+
const parts = [];
|
|
2398
|
+
const stack = [];
|
|
2399
|
+
let lastPos = 0;
|
|
2400
|
+
for (let i = 0; i < inner.length; i++) {
|
|
2401
|
+
const char = inner[i];
|
|
2402
|
+
if (char === "\\") {
|
|
2403
|
+
i += 1;
|
|
2404
|
+
continue;
|
|
2405
|
+
}
|
|
2406
|
+
if (char === "{") {
|
|
2407
|
+
stack.push("}");
|
|
2408
|
+
continue;
|
|
2409
|
+
}
|
|
2410
|
+
if (char === "}" && stack[stack.length - 1] === "}") {
|
|
2411
|
+
stack.pop();
|
|
2412
|
+
continue;
|
|
2413
|
+
}
|
|
2414
|
+
if (char === "," && stack.length === 0) {
|
|
2415
|
+
parts.push(inner.slice(lastPos, i));
|
|
2416
|
+
lastPos = i + 1;
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
parts.push(inner.slice(lastPos));
|
|
2420
|
+
return parts.flatMap((part) => expandBracePattern(`${prefix}${part}${suffix}`));
|
|
2421
|
+
}
|
|
2422
|
+
function normalizeScannerSources(sources, cwd, ignoredSources = []) {
|
|
2423
|
+
return [...sources?.length ? sources : [{
|
|
2424
|
+
base: cwd,
|
|
2425
|
+
pattern: "**/*",
|
|
2426
|
+
negated: false
|
|
2427
|
+
}], ...ignoredSources].flatMap((source) => {
|
|
2428
|
+
const base = source.base ?? cwd;
|
|
2429
|
+
return expandBracePattern(source.pattern).map((pattern) => ({
|
|
2430
|
+
base,
|
|
2431
|
+
pattern,
|
|
2432
|
+
negated: source.negated
|
|
2433
|
+
}));
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
async function resolveScannerSources(options) {
|
|
2372
2437
|
const cwd = options?.cwd ? pathe.default.resolve(options.cwd) : node_process.default.cwd();
|
|
2373
|
-
|
|
2438
|
+
if (options?.sources?.length || options?.css === void 0) return {
|
|
2439
|
+
cwd,
|
|
2440
|
+
sources: normalizeScannerSources(options?.sources, cwd, options?.ignoredSources)
|
|
2441
|
+
};
|
|
2442
|
+
const base = options.base ? pathe.default.resolve(options.base) : cwd;
|
|
2443
|
+
const { compiled } = await compileTailwindV4Source({
|
|
2444
|
+
projectRoot: cwd,
|
|
2445
|
+
base,
|
|
2446
|
+
baseFallbacks: options.baseFallbacks?.map((baseFallback) => pathe.default.resolve(baseFallback)) ?? [],
|
|
2447
|
+
css: options.css,
|
|
2448
|
+
dependencies: []
|
|
2449
|
+
});
|
|
2450
|
+
return {
|
|
2451
|
+
cwd,
|
|
2452
|
+
sources: normalizeScannerSources([...(() => {
|
|
2453
|
+
if (compiled.root === "none") return [];
|
|
2454
|
+
if (compiled.root === null) return [{
|
|
2455
|
+
base,
|
|
2456
|
+
pattern: "**/*",
|
|
2457
|
+
negated: false
|
|
2458
|
+
}];
|
|
2459
|
+
return [{
|
|
2460
|
+
...compiled.root,
|
|
2461
|
+
negated: false
|
|
2462
|
+
}];
|
|
2463
|
+
})(), ...compiled.sources], cwd, options.ignoredSources)
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
async function resolveProjectSourceFiles(options) {
|
|
2467
|
+
const { sources } = await resolveScannerSources(options);
|
|
2374
2468
|
const { Scanner } = await getOxideModule();
|
|
2375
|
-
const
|
|
2469
|
+
const files = new Scanner({ sources }).files ?? [];
|
|
2470
|
+
return options?.filter ? files.filter(options.filter) : files;
|
|
2471
|
+
}
|
|
2472
|
+
async function extractProjectCandidatesWithPositions(options) {
|
|
2473
|
+
const { cwd, sources } = await resolveScannerSources(options);
|
|
2474
|
+
const { Scanner } = await getOxideModule();
|
|
2475
|
+
const scanner = new Scanner({ sources });
|
|
2376
2476
|
const files = scanner.files ?? [];
|
|
2377
2477
|
const entries = [];
|
|
2378
2478
|
const skipped = [];
|
|
@@ -2416,7 +2516,7 @@ async function extractProjectCandidatesWithPositions(options) {
|
|
|
2416
2516
|
entries,
|
|
2417
2517
|
filesScanned: files.length,
|
|
2418
2518
|
skippedFiles: skipped,
|
|
2419
|
-
sources
|
|
2519
|
+
sources
|
|
2420
2520
|
};
|
|
2421
2521
|
}
|
|
2422
2522
|
function groupTokensByFile(report, options) {
|
|
@@ -4283,6 +4383,12 @@ Object.defineProperty(exports, "replaceBareArbitraryValueSelectors", {
|
|
|
4283
4383
|
return replaceBareArbitraryValueSelectors;
|
|
4284
4384
|
}
|
|
4285
4385
|
});
|
|
4386
|
+
Object.defineProperty(exports, "resolveProjectSourceFiles", {
|
|
4387
|
+
enumerable: true,
|
|
4388
|
+
get: function() {
|
|
4389
|
+
return resolveProjectSourceFiles;
|
|
4390
|
+
}
|
|
4391
|
+
});
|
|
4286
4392
|
Object.defineProperty(exports, "resolveValidTailwindV4Candidates", {
|
|
4287
4393
|
enumerable: true,
|
|
4288
4394
|
get: function() {
|
|
@@ -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;
|
|
@@ -526,7 +525,20 @@ declare function extractValidCandidates(options?: ExtractValidCandidatesOption):
|
|
|
526
525
|
interface ExtractProjectCandidatesOptions {
|
|
527
526
|
cwd?: string;
|
|
528
527
|
sources?: SourceEntry[];
|
|
528
|
+
base?: string;
|
|
529
|
+
baseFallbacks?: string[];
|
|
530
|
+
css?: string;
|
|
531
|
+
}
|
|
532
|
+
interface ResolveProjectSourceFilesOptions {
|
|
533
|
+
cwd?: string;
|
|
534
|
+
sources?: SourceEntry[];
|
|
535
|
+
ignoredSources?: SourceEntry[];
|
|
536
|
+
base?: string;
|
|
537
|
+
baseFallbacks?: string[];
|
|
538
|
+
css?: string;
|
|
539
|
+
filter?: (file: string) => boolean;
|
|
529
540
|
}
|
|
541
|
+
declare function resolveProjectSourceFiles(options?: ResolveProjectSourceFilesOptions): Promise<string[]>;
|
|
530
542
|
declare function extractProjectCandidatesWithPositions(options?: ExtractProjectCandidatesOptions): Promise<TailwindTokenReport>;
|
|
531
543
|
declare function groupTokensByFile(report: TailwindTokenReport, options?: {
|
|
532
544
|
key?: TailwindTokenFileKey;
|
|
@@ -777,4 +789,4 @@ declare class ValidateCommandError extends Error {
|
|
|
777
789
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
778
790
|
}
|
|
779
791
|
//#endregion
|
|
780
|
-
export {
|
|
792
|
+
export { TailwindV4GenerateOptions as $, extractSourceCandidatesWithPositions as A, ExtendLengthUnitsOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, CacheReadResult as Ct, extractRawCandidates as D, extractProjectCandidatesWithPositions as E, normalizeOptions as F, TailwindCssPatchOptions as G, NormalizedCacheOptions as H, ApplyOptions as I, TailwindV4Options as J, TailwindV2Options as K, CacheOptions as L, groupTokensByFile as M, resolveProjectSourceFiles as N, extractRawCandidatesWithPositions as O, BareArbitraryValueOptions as P, TailwindV4Engine as Q, CacheStrategy as R, MIGRATION_REPORT_KIND as S, CacheReadMeta as St, TailwindcssPatcher as T, NormalizedTailwindCssPatchOptions as U, ExtractOptions as V, TailwindCssOptions as W, TailwindV4CssSource as X, TailwindV4CandidateSource as Y, TailwindV4DesignSystem as Z, ConfigFileMigrationEntry as _, CacheClearResult as _t, ValidateFailureSummary as a, PatchCheckStatus as at, RestoreConfigFilesOptions as b, CacheContextMetadata as bt, TailwindcssPatchCliMountOptions as c, PatchStatusReport as ct, TailwindcssPatchCommandContext as d, TailwindTokenFileKey as dt, TailwindV4GenerateResult as et, TailwindcssPatchCommandHandler as f, TailwindTokenLocation as ft, tailwindcssPatchCommands as g, CacheClearOptions as gt, TailwindcssPatchCommandOptions as h, TailwindcssRuntimeContext as ht, ValidateFailureReason as i, ILengthUnitsPatchOptions as it, extractValidCandidates as j, extractSourceCandidates as k, TailwindcssPatchCliOptions as l, TailwindPatchRuntime as lt, TailwindcssPatchCommandOptionDefinition as m, TailwindcssClassCache as mt, VALIDATE_FAILURE_REASONS as n, TailwindV4SourceOptions as nt, ValidateJsonFailurePayload as o, PatchName as ot, TailwindcssPatchCommandHandlerMap as p, TailwindTokenReport as pt, TailwindV3Options as q, ValidateCommandError as r, ExtractResult as rt, ValidateJsonSuccessPayload as s, PatchStatusEntry as st, VALIDATE_EXIT_CODES as t, TailwindV4ResolvedSource as tt, TailwindcssPatchCommand as u, TailwindTokenByFileMap as ut, ConfigFileMigrationReport as v, CacheClearScope as vt, logger as w, RestoreConfigFilesResult as x, CacheIndexFileV2 as xt, MigrateConfigFilesOptions as y, CacheContextDescriptor as yt, ExposeContextOptions as z };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
2
|
-
import * as _$consola from "consola";
|
|
3
|
-
import { Node, Rule } from "postcss";
|
|
4
1
|
import { CAC, Command } from "cac";
|
|
2
|
+
import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
5
3
|
import { SourceEntry } from "@tailwindcss/oxide";
|
|
4
|
+
import { Node, Rule } from "postcss";
|
|
6
5
|
import { Config } from "tailwindcss";
|
|
6
|
+
import * as _$consola from "consola";
|
|
7
|
+
|
|
7
8
|
//#region src/cache/types.d.ts
|
|
8
9
|
declare const CACHE_SCHEMA_VERSION = 2;
|
|
9
10
|
declare const CACHE_FINGERPRINT_VERSION = 1;
|
|
@@ -525,7 +526,20 @@ declare function extractValidCandidates(options?: ExtractValidCandidatesOption):
|
|
|
525
526
|
interface ExtractProjectCandidatesOptions {
|
|
526
527
|
cwd?: string;
|
|
527
528
|
sources?: SourceEntry[];
|
|
529
|
+
base?: string;
|
|
530
|
+
baseFallbacks?: string[];
|
|
531
|
+
css?: string;
|
|
532
|
+
}
|
|
533
|
+
interface ResolveProjectSourceFilesOptions {
|
|
534
|
+
cwd?: string;
|
|
535
|
+
sources?: SourceEntry[];
|
|
536
|
+
ignoredSources?: SourceEntry[];
|
|
537
|
+
base?: string;
|
|
538
|
+
baseFallbacks?: string[];
|
|
539
|
+
css?: string;
|
|
540
|
+
filter?: (file: string) => boolean;
|
|
528
541
|
}
|
|
542
|
+
declare function resolveProjectSourceFiles(options?: ResolveProjectSourceFilesOptions): Promise<string[]>;
|
|
529
543
|
declare function extractProjectCandidatesWithPositions(options?: ExtractProjectCandidatesOptions): Promise<TailwindTokenReport>;
|
|
530
544
|
declare function groupTokensByFile(report: TailwindTokenReport, options?: {
|
|
531
545
|
key?: TailwindTokenFileKey;
|
|
@@ -776,4 +790,4 @@ declare class ValidateCommandError extends Error {
|
|
|
776
790
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
777
791
|
}
|
|
778
792
|
//#endregion
|
|
779
|
-
export {
|
|
793
|
+
export { TailwindV4GenerateOptions as $, extractSourceCandidatesWithPositions as A, ExtendLengthUnitsOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, CacheReadResult as Ct, extractRawCandidates as D, extractProjectCandidatesWithPositions as E, normalizeOptions as F, TailwindCssPatchOptions as G, NormalizedCacheOptions as H, ApplyOptions as I, TailwindV4Options as J, TailwindV2Options as K, CacheOptions as L, groupTokensByFile as M, resolveProjectSourceFiles as N, extractRawCandidatesWithPositions as O, BareArbitraryValueOptions as P, TailwindV4Engine as Q, CacheStrategy as R, MIGRATION_REPORT_KIND as S, CacheReadMeta as St, TailwindcssPatcher as T, NormalizedTailwindCssPatchOptions as U, ExtractOptions as V, TailwindCssOptions as W, TailwindV4CssSource as X, TailwindV4CandidateSource as Y, TailwindV4DesignSystem as Z, ConfigFileMigrationEntry as _, CacheClearResult as _t, ValidateFailureSummary as a, PatchCheckStatus as at, RestoreConfigFilesOptions as b, CacheContextMetadata as bt, TailwindcssPatchCliMountOptions as c, PatchStatusReport as ct, TailwindcssPatchCommandContext as d, TailwindTokenFileKey as dt, TailwindV4GenerateResult as et, TailwindcssPatchCommandHandler as f, TailwindTokenLocation as ft, tailwindcssPatchCommands as g, CacheClearOptions as gt, TailwindcssPatchCommandOptions as h, TailwindcssRuntimeContext as ht, ValidateFailureReason as i, ILengthUnitsPatchOptions as it, extractValidCandidates as j, extractSourceCandidates as k, TailwindcssPatchCliOptions as l, TailwindPatchRuntime as lt, TailwindcssPatchCommandOptionDefinition as m, TailwindcssClassCache as mt, VALIDATE_FAILURE_REASONS as n, TailwindV4SourceOptions as nt, ValidateJsonFailurePayload as o, PatchName as ot, TailwindcssPatchCommandHandlerMap as p, TailwindTokenReport as pt, TailwindV3Options as q, ValidateCommandError as r, ExtractResult as rt, ValidateJsonSuccessPayload as s, PatchStatusEntry as st, VALIDATE_EXIT_CODES as t, TailwindV4ResolvedSource as tt, TailwindcssPatchCommand as u, TailwindTokenByFileMap as ut, ConfigFileMigrationReport as v, CacheClearScope as vt, logger as w, RestoreConfigFilesResult as x, CacheIndexFileV2 as xt, MigrateConfigFilesOptions as y, CacheContextDescriptor as yt, ExposeContextOptions as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-patch",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.6",
|
|
4
4
|
"description": "patch tailwindcss for exposing context and extract classes",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"cac": "6.7.14",
|
|
71
71
|
"consola": "^3.4.2",
|
|
72
72
|
"fs-extra": "^11.3.5",
|
|
73
|
-
"local-pkg": "^1.1
|
|
73
|
+
"local-pkg": "^1.2.1",
|
|
74
74
|
"pathe": "^2.0.3",
|
|
75
|
-
"postcss": "^8.5.
|
|
76
|
-
"semver": "^7.8.
|
|
75
|
+
"postcss": "^8.5.15",
|
|
76
|
+
"semver": "^7.8.1",
|
|
77
77
|
"tailwindcss-config": "^1.1.5",
|
|
78
78
|
"@tailwindcss-mangle/config": "7.0.2"
|
|
79
79
|
},
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
type BareArbitraryValueOptions,
|
|
13
13
|
resolveBareArbitraryValueCandidate,
|
|
14
14
|
} from '../v4/bare-arbitrary-values'
|
|
15
|
-
import { resolveValidTailwindV4Candidates } from '../v4/candidates'
|
|
16
|
-
import { getTailwindV4DesignSystemCacheKey, loadTailwindV4DesignSystem } from '../v4/node-adapter'
|
|
15
|
+
import { extractTailwindV4InlineSourceCandidates, resolveValidTailwindV4Candidates } from '../v4/candidates'
|
|
16
|
+
import { compileTailwindV4Source, getTailwindV4DesignSystemCacheKey, loadTailwindV4DesignSystem } from '../v4/node-adapter'
|
|
17
17
|
|
|
18
18
|
let oxideImportPromise: ReturnType<typeof importOxide> | undefined
|
|
19
19
|
const designSystemCandidateCache = new Map<string, Map<string, boolean>>()
|
|
@@ -367,6 +367,17 @@ export async function extractValidCandidates(options?: ExtractValidCandidatesOpt
|
|
|
367
367
|
designSystemCandidateCache.set(candidateCacheKey, candidateCache)
|
|
368
368
|
|
|
369
369
|
const candidates = await extractRawCandidates(sources)
|
|
370
|
+
const inlineSources = extractTailwindV4InlineSourceCandidates(css)
|
|
371
|
+
for (const candidate of inlineSources.included) {
|
|
372
|
+
candidates.push(candidate)
|
|
373
|
+
}
|
|
374
|
+
for (const candidate of inlineSources.excluded) {
|
|
375
|
+
let index = candidates.indexOf(candidate)
|
|
376
|
+
while (index !== -1) {
|
|
377
|
+
candidates.splice(index, 1)
|
|
378
|
+
index = candidates.indexOf(candidate)
|
|
379
|
+
}
|
|
380
|
+
}
|
|
370
381
|
const validCandidates: string[] = []
|
|
371
382
|
const uncachedCandidates: string[] = []
|
|
372
383
|
|
|
@@ -417,24 +428,6 @@ export async function extractValidCandidates(options?: ExtractValidCandidatesOpt
|
|
|
417
428
|
return validCandidates
|
|
418
429
|
}
|
|
419
430
|
|
|
420
|
-
function normalizeSources(sources: SourceEntry[] | undefined, cwd: string) {
|
|
421
|
-
const baseSources = sources?.length
|
|
422
|
-
? sources
|
|
423
|
-
: [
|
|
424
|
-
{
|
|
425
|
-
base: cwd,
|
|
426
|
-
pattern: '**/*',
|
|
427
|
-
negated: false,
|
|
428
|
-
},
|
|
429
|
-
]
|
|
430
|
-
|
|
431
|
-
return baseSources.map(source => ({
|
|
432
|
-
base: source.base ?? cwd,
|
|
433
|
-
pattern: source.pattern,
|
|
434
|
-
negated: source.negated,
|
|
435
|
-
}))
|
|
436
|
-
}
|
|
437
|
-
|
|
438
431
|
function buildLineOffsets(content: string) {
|
|
439
432
|
const offsets: number[] = [0]
|
|
440
433
|
for (let i = 0; i < content.length; i++) {
|
|
@@ -499,16 +492,160 @@ function toRelativeFile(cwd: string, filename: string) {
|
|
|
499
492
|
export interface ExtractProjectCandidatesOptions {
|
|
500
493
|
cwd?: string
|
|
501
494
|
sources?: SourceEntry[]
|
|
495
|
+
base?: string
|
|
496
|
+
baseFallbacks?: string[]
|
|
497
|
+
css?: string
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
export interface ResolveProjectSourceFilesOptions {
|
|
501
|
+
cwd?: string
|
|
502
|
+
sources?: SourceEntry[]
|
|
503
|
+
ignoredSources?: SourceEntry[]
|
|
504
|
+
base?: string
|
|
505
|
+
baseFallbacks?: string[]
|
|
506
|
+
css?: string
|
|
507
|
+
filter?: (file: string) => boolean
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function expandBracePattern(pattern: string) {
|
|
511
|
+
const index = pattern.indexOf('{')
|
|
512
|
+
if (index === -1) {
|
|
513
|
+
return [pattern]
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const rest = pattern.slice(index)
|
|
517
|
+
let depth = 0
|
|
518
|
+
let endIndex = -1
|
|
519
|
+
for (let i = 0; i < rest.length; i++) {
|
|
520
|
+
const char = rest[i]
|
|
521
|
+
if (char === '\\') {
|
|
522
|
+
i += 1
|
|
523
|
+
continue
|
|
524
|
+
}
|
|
525
|
+
if (char === '{') {
|
|
526
|
+
depth += 1
|
|
527
|
+
continue
|
|
528
|
+
}
|
|
529
|
+
if (char === '}') {
|
|
530
|
+
depth -= 1
|
|
531
|
+
if (depth === 0) {
|
|
532
|
+
endIndex = i
|
|
533
|
+
break
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (endIndex === -1) {
|
|
538
|
+
return [pattern]
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const prefix = pattern.slice(0, index)
|
|
542
|
+
const inner = rest.slice(1, endIndex)
|
|
543
|
+
const suffix = rest.slice(endIndex + 1)
|
|
544
|
+
const parts: string[] = []
|
|
545
|
+
const stack: string[] = []
|
|
546
|
+
let lastPos = 0
|
|
547
|
+
for (let i = 0; i < inner.length; i++) {
|
|
548
|
+
const char = inner[i]
|
|
549
|
+
if (char === '\\') {
|
|
550
|
+
i += 1
|
|
551
|
+
continue
|
|
552
|
+
}
|
|
553
|
+
if (char === '{') {
|
|
554
|
+
stack.push('}')
|
|
555
|
+
continue
|
|
556
|
+
}
|
|
557
|
+
if (char === '}' && stack[stack.length - 1] === '}') {
|
|
558
|
+
stack.pop()
|
|
559
|
+
continue
|
|
560
|
+
}
|
|
561
|
+
if (char === ',' && stack.length === 0) {
|
|
562
|
+
parts.push(inner.slice(lastPos, i))
|
|
563
|
+
lastPos = i + 1
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
parts.push(inner.slice(lastPos))
|
|
567
|
+
|
|
568
|
+
return parts.flatMap(part =>
|
|
569
|
+
expandBracePattern(`${prefix}${part}${suffix}`))
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function normalizeScannerSources(
|
|
573
|
+
sources: SourceEntry[] | undefined,
|
|
574
|
+
cwd: string,
|
|
575
|
+
ignoredSources: SourceEntry[] = [],
|
|
576
|
+
) {
|
|
577
|
+
const baseSources = sources?.length
|
|
578
|
+
? sources
|
|
579
|
+
: [
|
|
580
|
+
{
|
|
581
|
+
base: cwd,
|
|
582
|
+
pattern: '**/*',
|
|
583
|
+
negated: false,
|
|
584
|
+
},
|
|
585
|
+
]
|
|
586
|
+
|
|
587
|
+
return [...baseSources, ...ignoredSources].flatMap((source) => {
|
|
588
|
+
const base = source.base ?? cwd
|
|
589
|
+
return expandBracePattern(source.pattern).map(pattern => ({
|
|
590
|
+
base,
|
|
591
|
+
pattern,
|
|
592
|
+
negated: source.negated,
|
|
593
|
+
}))
|
|
594
|
+
})
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
async function resolveScannerSources(options?: ResolveProjectSourceFilesOptions) {
|
|
598
|
+
const cwd = options?.cwd ? path.resolve(options.cwd) : process.cwd()
|
|
599
|
+
if (options?.sources?.length || options?.css === undefined) {
|
|
600
|
+
return {
|
|
601
|
+
cwd,
|
|
602
|
+
sources: normalizeScannerSources(options?.sources, cwd, options?.ignoredSources),
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const base = options.base ? path.resolve(options.base) : cwd
|
|
607
|
+
const { compiled } = await compileTailwindV4Source({
|
|
608
|
+
projectRoot: cwd,
|
|
609
|
+
base,
|
|
610
|
+
baseFallbacks: options.baseFallbacks?.map(baseFallback => path.resolve(baseFallback)) ?? [],
|
|
611
|
+
css: options.css,
|
|
612
|
+
dependencies: [],
|
|
613
|
+
})
|
|
614
|
+
const rootSources = (() => {
|
|
615
|
+
if (compiled.root === 'none') {
|
|
616
|
+
return []
|
|
617
|
+
}
|
|
618
|
+
if (compiled.root === null) {
|
|
619
|
+
return [{ base, pattern: '**/*', negated: false }]
|
|
620
|
+
}
|
|
621
|
+
return [{ ...compiled.root, negated: false }]
|
|
622
|
+
})()
|
|
623
|
+
|
|
624
|
+
return {
|
|
625
|
+
cwd,
|
|
626
|
+
sources: normalizeScannerSources([...rootSources, ...compiled.sources], cwd, options.ignoredSources),
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export async function resolveProjectSourceFiles(options?: ResolveProjectSourceFilesOptions): Promise<string[]> {
|
|
631
|
+
const { sources } = await resolveScannerSources(options)
|
|
632
|
+
const { Scanner } = await getOxideModule()
|
|
633
|
+
const scanner = new Scanner({
|
|
634
|
+
sources,
|
|
635
|
+
})
|
|
636
|
+
const files = scanner.files ?? []
|
|
637
|
+
return options?.filter
|
|
638
|
+
? files.filter(options.filter)
|
|
639
|
+
: files
|
|
502
640
|
}
|
|
503
641
|
|
|
504
642
|
export async function extractProjectCandidatesWithPositions(
|
|
505
643
|
options?: ExtractProjectCandidatesOptions,
|
|
506
644
|
): Promise<TailwindTokenReport> {
|
|
507
|
-
const cwd =
|
|
508
|
-
const normalizedSources = normalizeSources(options?.sources, cwd)
|
|
645
|
+
const { cwd, sources } = await resolveScannerSources(options)
|
|
509
646
|
const { Scanner } = await getOxideModule()
|
|
510
647
|
const scanner = new Scanner({
|
|
511
|
-
sources
|
|
648
|
+
sources,
|
|
512
649
|
})
|
|
513
650
|
|
|
514
651
|
const files = scanner.files ?? []
|
|
@@ -563,7 +700,7 @@ export async function extractProjectCandidatesWithPositions(
|
|
|
563
700
|
entries,
|
|
564
701
|
filesScanned: files.length,
|
|
565
702
|
skippedFiles: skipped,
|
|
566
|
-
sources
|
|
703
|
+
sources,
|
|
567
704
|
}
|
|
568
705
|
}
|
|
569
706
|
|
package/src/index.bundle.ts
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
extractSourceCandidatesWithPositions,
|
|
27
27
|
extractValidCandidates,
|
|
28
28
|
groupTokensByFile,
|
|
29
|
+
resolveProjectSourceFiles,
|
|
29
30
|
} from './extraction/candidate-extractor'
|
|
30
31
|
import {
|
|
31
32
|
collectClassesFromContexts,
|
|
@@ -73,6 +74,7 @@ export {
|
|
|
73
74
|
normalizeOptions,
|
|
74
75
|
resolveTailwindV4Source,
|
|
75
76
|
resolveTailwindV4SourceFromPatchOptions,
|
|
77
|
+
resolveProjectSourceFiles,
|
|
76
78
|
resolveValidTailwindV4Candidates,
|
|
77
79
|
restoreConfigFiles,
|
|
78
80
|
runTailwindBuild,
|
package/src/index.ts
CHANGED
package/src/v4/candidates.ts
CHANGED
|
@@ -126,7 +126,7 @@ export function canonicalizeBareArbitraryValueCandidates(
|
|
|
126
126
|
})
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
function splitTopLevel(value: string, separator: string) {
|
|
129
|
+
function splitTopLevel(value: string, separator: string, options?: { keepEmpty?: boolean }) {
|
|
130
130
|
const result: string[] = []
|
|
131
131
|
let start = 0
|
|
132
132
|
let depth = 0
|
|
@@ -163,7 +163,7 @@ function splitTopLevel(value: string, separator: string) {
|
|
|
163
163
|
|
|
164
164
|
if (depth === 0 && character === separator) {
|
|
165
165
|
const item = value.slice(start, index).trim()
|
|
166
|
-
if (item) {
|
|
166
|
+
if (item || options?.keepEmpty) {
|
|
167
167
|
result.push(item)
|
|
168
168
|
}
|
|
169
169
|
start = index + 1
|
|
@@ -171,7 +171,7 @@ function splitTopLevel(value: string, separator: string) {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
const item = value.slice(start).trim()
|
|
174
|
-
if (item) {
|
|
174
|
+
if (item || options?.keepEmpty) {
|
|
175
175
|
result.push(item)
|
|
176
176
|
}
|
|
177
177
|
return result
|
|
@@ -244,7 +244,7 @@ function expandInlinePattern(pattern: string): string[] {
|
|
|
244
244
|
const suffix = rest.slice(closeIndex + 1)
|
|
245
245
|
const parts = sequencePattern.test(body)
|
|
246
246
|
? expandSequence(body)
|
|
247
|
-
: splitTopLevel(body, ',').flatMap(part => expandInlinePattern(part))
|
|
247
|
+
: splitTopLevel(body, ',', { keepEmpty: true }).flatMap(part => expandInlinePattern(part))
|
|
248
248
|
const suffixes = expandInlinePattern(suffix)
|
|
249
249
|
|
|
250
250
|
const result: string[] = []
|
package/src/v4/engine.ts
CHANGED
|
@@ -16,13 +16,24 @@ import { compileTailwindV4Source, loadTailwindV4DesignSystem } from './node-adap
|
|
|
16
16
|
|
|
17
17
|
function resolveScanSources(
|
|
18
18
|
options: TailwindV4GenerateOptions | undefined,
|
|
19
|
+
source: TailwindV4ResolvedSource,
|
|
20
|
+
compiledRoot: TailwindV4GenerateResult['root'],
|
|
19
21
|
compiledSources: TailwindV4SourcePattern[],
|
|
20
22
|
) {
|
|
21
23
|
if (Array.isArray(options?.scanSources)) {
|
|
22
24
|
return options.scanSources
|
|
23
25
|
}
|
|
24
26
|
if (options?.scanSources === true) {
|
|
25
|
-
|
|
27
|
+
const rootSources = (() => {
|
|
28
|
+
if (compiledRoot === 'none') {
|
|
29
|
+
return []
|
|
30
|
+
}
|
|
31
|
+
if (compiledRoot === null) {
|
|
32
|
+
return [{ base: source.base, pattern: '**/*', negated: false }]
|
|
33
|
+
}
|
|
34
|
+
return [{ ...compiledRoot, negated: false }]
|
|
35
|
+
})()
|
|
36
|
+
return [...rootSources, ...compiledSources]
|
|
26
37
|
}
|
|
27
38
|
return []
|
|
28
39
|
}
|
|
@@ -30,6 +41,7 @@ function resolveScanSources(
|
|
|
30
41
|
async function collectRawCandidates(
|
|
31
42
|
source: TailwindV4ResolvedSource,
|
|
32
43
|
options: TailwindV4GenerateOptions | undefined,
|
|
44
|
+
compiledRoot: TailwindV4GenerateResult['root'],
|
|
33
45
|
compiledSources: TailwindV4SourcePattern[] = [],
|
|
34
46
|
) {
|
|
35
47
|
const rawCandidates = new Set<string>()
|
|
@@ -45,7 +57,7 @@ async function collectRawCandidates(
|
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
const filesystemSources = resolveScanSources(options, compiledSources)
|
|
60
|
+
const filesystemSources = resolveScanSources(options, source, compiledRoot, compiledSources)
|
|
49
61
|
if (filesystemSources.length > 0) {
|
|
50
62
|
for (const candidate of await extractRawCandidates(filesystemSources)) {
|
|
51
63
|
rawCandidates.add(candidate)
|
|
@@ -75,7 +87,7 @@ export function createTailwindV4Engine(source: TailwindV4ResolvedSource): Tailwi
|
|
|
75
87
|
},
|
|
76
88
|
async generate(options): Promise<TailwindV4GenerateResult> {
|
|
77
89
|
const { compiled, dependencies } = await compileTailwindV4Source(source)
|
|
78
|
-
const rawCandidates = await collectRawCandidates(source, options, compiled.sources)
|
|
90
|
+
const rawCandidates = await collectRawCandidates(source, options, compiled.root, compiled.sources)
|
|
79
91
|
const designSystem = await loadTailwindV4DesignSystem(source)
|
|
80
92
|
const classSet = resolveValidTailwindV4Candidates(designSystem, rawCandidates, {
|
|
81
93
|
...(options?.bareArbitraryValues === undefined ? {} : { bareArbitraryValues: options.bareArbitraryValues }),
|