tailwindcss-patch 9.3.2 → 9.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/commands/cli-runtime.d.mts +1 -1
- package/dist/commands/cli-runtime.d.ts +1 -1
- package/dist/commands/cli-runtime.js +1 -1
- package/dist/commands/cli-runtime.mjs +1 -1
- package/dist/{index.bundle-CcVIAfDb.js → index.bundle-BdxyJef9.js} +25 -6
- package/dist/{index.bundle-DjS24i5r.mjs → index.bundle-C39laqrA.mjs} +25 -6
- package/dist/index.d.mts +2 -67
- package/dist/index.d.ts +2 -67
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{validate-CF0M_7KH.js → validate-DABvQ44V.js} +31 -6
- package/dist/{validate-Bqych-z9.d.ts → validate-DDJnolx2.d.mts} +79 -5
- package/dist/{validate-Sq_yuh3r.mjs → validate-cMWKFUKS.mjs} +31 -6
- package/dist/{validate-C8-qsOWo.d.mts → validate-rPPCy1cl.d.ts} +80 -4
- package/package.json +1 -1
- package/src/index.bundle.ts +1 -0
- package/src/index.ts +1 -0
- package/src/options/normalize.ts +14 -0
- package/src/options/types.ts +4 -0
- package/src/runtime/class-collector.ts +33 -13
- package/src/v4/index.ts +1 -0
- package/src/v4/source.ts +48 -6
- package/src/v4/types.ts +8 -0
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-DABvQ44V.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-BdxyJef9.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 { j as logger, r as ValidateCommandError } from "./validate-
|
|
2
|
-
import { t as createTailwindcssPatchCli } from "./index.bundle-
|
|
1
|
+
import { j as logger, r as ValidateCommandError } from "./validate-cMWKFUKS.mjs";
|
|
2
|
+
import { t as createTailwindcssPatchCli } from "./index.bundle-C39laqrA.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-DDJnolx2.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-rPPCy1cl.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-DABvQ44V.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 { D as loadPatchOptionsForWorkspace, O as loadWorkspaceConfigModule, a as tailwindcssPatchCommands, b as groupTokensByFile, i as classifyValidateError, j as logger, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher } from "../validate-
|
|
1
|
+
import { D as loadPatchOptionsForWorkspace, O as loadWorkspaceConfigModule, a as tailwindcssPatchCommands, b as groupTokensByFile, i as classifyValidateError, j as logger, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher } from "../validate-cMWKFUKS.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-DABvQ44V.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);
|
|
@@ -109,6 +109,22 @@ async function resolveCssEntries(entries, projectRoot, base) {
|
|
|
109
109
|
dependencies
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
function resolveCssSources(sources, projectRoot, base) {
|
|
113
|
+
const resolvedSources = sources.map((source) => ({
|
|
114
|
+
...source,
|
|
115
|
+
base: source.base === void 0 ? void 0 : resolveBase(source.base, projectRoot),
|
|
116
|
+
file: source.file === void 0 ? void 0 : pathe.default.isAbsolute(source.file) ? pathe.default.resolve(source.file) : pathe.default.resolve(projectRoot, source.file),
|
|
117
|
+
dependencies: source.dependencies?.map((dependency) => pathe.default.isAbsolute(dependency) ? pathe.default.resolve(dependency) : pathe.default.resolve(projectRoot, dependency)) ?? []
|
|
118
|
+
}));
|
|
119
|
+
const firstSource = resolvedSources[0];
|
|
120
|
+
const resolvedBase = base ?? firstSource?.base ?? (firstSource?.file ? pathe.default.dirname(firstSource.file) : projectRoot);
|
|
121
|
+
const dependencies = resolvedSources.flatMap((source) => [source.file, ...source.dependencies]).filter((dependency) => Boolean(dependency));
|
|
122
|
+
return {
|
|
123
|
+
base: resolvedBase,
|
|
124
|
+
css: resolvedSources.map((source) => source.css).join("\n"),
|
|
125
|
+
dependencies
|
|
126
|
+
};
|
|
127
|
+
}
|
|
112
128
|
function normalizeResolvedSource(source) {
|
|
113
129
|
const baseFallbacks = uniquePaths([
|
|
114
130
|
...source.baseFallbacks,
|
|
@@ -136,15 +152,17 @@ async function resolveTailwindV4Source(options = {}) {
|
|
|
136
152
|
css: options.css,
|
|
137
153
|
dependencies: []
|
|
138
154
|
});
|
|
139
|
-
if (options.cssEntries?.length) {
|
|
140
|
-
const entries = await resolveCssEntries(options.cssEntries, projectRoot, configuredBase);
|
|
155
|
+
if (options.cssEntries?.length || options.cssSources?.length) {
|
|
156
|
+
const entries = options.cssEntries?.length ? await resolveCssEntries(options.cssEntries, projectRoot, configuredBase) : void 0;
|
|
157
|
+
const sources = options.cssSources?.length ? resolveCssSources(options.cssSources, projectRoot, configuredBase) : void 0;
|
|
158
|
+
const css = [entries?.css, sources?.css].filter(Boolean).join("\n");
|
|
141
159
|
return normalizeResolvedSource({
|
|
142
160
|
projectRoot,
|
|
143
161
|
cwd,
|
|
144
|
-
base: entries
|
|
162
|
+
base: configuredBase ?? entries?.base ?? sources?.base ?? cwd,
|
|
145
163
|
baseFallbacks,
|
|
146
|
-
css
|
|
147
|
-
dependencies: entries
|
|
164
|
+
css,
|
|
165
|
+
dependencies: [...entries?.dependencies ?? [], ...sources?.dependencies ?? []]
|
|
148
166
|
});
|
|
149
167
|
}
|
|
150
168
|
return normalizeResolvedSource({
|
|
@@ -176,6 +194,7 @@ function createSourceOptionsFromNormalizedPatchOptions(options) {
|
|
|
176
194
|
...v4?.configuredBase === void 0 ? {} : { base: v4.configuredBase },
|
|
177
195
|
baseFallbacks,
|
|
178
196
|
...v4?.css === void 0 ? {} : { css: v4.css },
|
|
197
|
+
...v4?.cssSources === void 0 ? {} : { cssSources: v4.cssSources },
|
|
179
198
|
...v4?.cssEntries === void 0 ? {} : { cssEntries: v4.cssEntries },
|
|
180
199
|
packageName: options.tailwind.packageName
|
|
181
200
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as canonicalizeBareArbitraryValueCandidates, E as resolveValidTailwindV4Candidates, S as loadTailwindV4DesignSystem, T as replaceBareArbitraryValueSelectors, _ as extractRawCandidates, k as normalizeOptions, v as extractRawCandidatesWithPositions, w as extractTailwindV4InlineSourceCandidates, x as compileTailwindV4Source } from "./validate-
|
|
1
|
+
import { C as canonicalizeBareArbitraryValueCandidates, E as resolveValidTailwindV4Candidates, S as loadTailwindV4DesignSystem, T as replaceBareArbitraryValueSelectors, _ as extractRawCandidates, k as normalizeOptions, v as extractRawCandidatesWithPositions, w as extractTailwindV4InlineSourceCandidates, x as compileTailwindV4Source } from "./validate-cMWKFUKS.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import path from "pathe";
|
|
@@ -106,6 +106,22 @@ async function resolveCssEntries(entries, projectRoot, base) {
|
|
|
106
106
|
dependencies
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
+
function resolveCssSources(sources, projectRoot, base) {
|
|
110
|
+
const resolvedSources = sources.map((source) => ({
|
|
111
|
+
...source,
|
|
112
|
+
base: source.base === void 0 ? void 0 : resolveBase(source.base, projectRoot),
|
|
113
|
+
file: source.file === void 0 ? void 0 : path.isAbsolute(source.file) ? path.resolve(source.file) : path.resolve(projectRoot, source.file),
|
|
114
|
+
dependencies: source.dependencies?.map((dependency) => path.isAbsolute(dependency) ? path.resolve(dependency) : path.resolve(projectRoot, dependency)) ?? []
|
|
115
|
+
}));
|
|
116
|
+
const firstSource = resolvedSources[0];
|
|
117
|
+
const resolvedBase = base ?? firstSource?.base ?? (firstSource?.file ? path.dirname(firstSource.file) : projectRoot);
|
|
118
|
+
const dependencies = resolvedSources.flatMap((source) => [source.file, ...source.dependencies]).filter((dependency) => Boolean(dependency));
|
|
119
|
+
return {
|
|
120
|
+
base: resolvedBase,
|
|
121
|
+
css: resolvedSources.map((source) => source.css).join("\n"),
|
|
122
|
+
dependencies
|
|
123
|
+
};
|
|
124
|
+
}
|
|
109
125
|
function normalizeResolvedSource(source) {
|
|
110
126
|
const baseFallbacks = uniquePaths([
|
|
111
127
|
...source.baseFallbacks,
|
|
@@ -133,15 +149,17 @@ async function resolveTailwindV4Source(options = {}) {
|
|
|
133
149
|
css: options.css,
|
|
134
150
|
dependencies: []
|
|
135
151
|
});
|
|
136
|
-
if (options.cssEntries?.length) {
|
|
137
|
-
const entries = await resolveCssEntries(options.cssEntries, projectRoot, configuredBase);
|
|
152
|
+
if (options.cssEntries?.length || options.cssSources?.length) {
|
|
153
|
+
const entries = options.cssEntries?.length ? await resolveCssEntries(options.cssEntries, projectRoot, configuredBase) : void 0;
|
|
154
|
+
const sources = options.cssSources?.length ? resolveCssSources(options.cssSources, projectRoot, configuredBase) : void 0;
|
|
155
|
+
const css = [entries?.css, sources?.css].filter(Boolean).join("\n");
|
|
138
156
|
return normalizeResolvedSource({
|
|
139
157
|
projectRoot,
|
|
140
158
|
cwd,
|
|
141
|
-
base: entries
|
|
159
|
+
base: configuredBase ?? entries?.base ?? sources?.base ?? cwd,
|
|
142
160
|
baseFallbacks,
|
|
143
|
-
css
|
|
144
|
-
dependencies: entries
|
|
161
|
+
css,
|
|
162
|
+
dependencies: [...entries?.dependencies ?? [], ...sources?.dependencies ?? []]
|
|
145
163
|
});
|
|
146
164
|
}
|
|
147
165
|
return normalizeResolvedSource({
|
|
@@ -173,6 +191,7 @@ function createSourceOptionsFromNormalizedPatchOptions(options) {
|
|
|
173
191
|
...v4?.configuredBase === void 0 ? {} : { base: v4.configuredBase },
|
|
174
192
|
baseFallbacks,
|
|
175
193
|
...v4?.css === void 0 ? {} : { css: v4.css },
|
|
194
|
+
...v4?.cssSources === void 0 ? {} : { cssSources: v4.cssSources },
|
|
176
195
|
...v4?.cssEntries === void 0 ? {} : { cssEntries: v4.cssEntries },
|
|
177
196
|
packageName: options.tailwind.packageName
|
|
178
197
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TailwindV4SourceOptions, A as groupTokensByFile, B as NormalizedTailwindCssPatchOptions, C as MIGRATION_REPORT_SCHEMA_VERSION, D as extractRawCandidates, E as extractProjectCandidatesWithPositions, F as CacheStrategy, G as TailwindV4Options, H as TailwindCssPatchOptions, I as ExposeContextOptions, J as TailwindV4DesignSystem, K as TailwindV4CandidateSource, L as ExtendLengthUnitsOptions, M as normalizeOptions, N as ApplyOptions, O as extractRawCandidatesWithPositions, P as CacheOptions, Q as TailwindV4ResolvedSource, R as ExtractOptions, S as MIGRATION_REPORT_KIND, T as TailwindcssPatcher, U as TailwindV2Options, V as TailwindCssOptions, W as TailwindV3Options, X as TailwindV4GenerateOptions, Y as TailwindV4Engine, Z as TailwindV4GenerateResult, _ as ConfigFileMigrationEntry, _t as CacheContextMetadata, a as ValidateFailureSummary, at as PatchStatusReport, b as RestoreConfigFilesOptions, bt as CacheReadResult, c as TailwindcssPatchCliMountOptions, ct as TailwindTokenFileKey, d as TailwindcssPatchCommandContext, dt as TailwindcssClassCache, et as ExtractResult, f as TailwindcssPatchCommandHandler, ft as TailwindcssRuntimeContext, g as tailwindcssPatchCommands, gt as CacheContextDescriptor, h as TailwindcssPatchCommandOptions, ht as CacheClearScope, i as ValidateFailureReason, it as PatchStatusEntry, j as BareArbitraryValueOptions, k as extractValidCandidates, l as TailwindcssPatchCliOptions, lt as TailwindTokenLocation, m as TailwindcssPatchCommandOptionDefinition, mt as CacheClearResult, n as VALIDATE_FAILURE_REASONS, nt as PatchCheckStatus, o as ValidateJsonFailurePayload, ot as TailwindPatchRuntime, p as TailwindcssPatchCommandHandlerMap, pt as CacheClearOptions, q as TailwindV4CssSource, r as ValidateCommandError, rt as PatchName, s as ValidateJsonSuccessPayload, st as TailwindTokenByFileMap, t as VALIDATE_EXIT_CODES, tt as ILengthUnitsPatchOptions, u as TailwindcssPatchCommand, ut as TailwindTokenReport, v as ConfigFileMigrationReport, vt as CacheIndexFileV2, w as logger, x as RestoreConfigFilesResult, y as MigrateConfigFilesOptions, yt as CacheReadMeta, z as NormalizedCacheOptions } from "./validate-DDJnolx2.mjs";
|
|
2
2
|
import { PackageInfo } from "local-pkg";
|
|
3
3
|
import postcss from "postcss";
|
|
4
4
|
import { CAC } from "cac";
|
|
@@ -77,71 +77,6 @@ interface PatchStatusContext {
|
|
|
77
77
|
}
|
|
78
78
|
declare function getPatchStatusReport(context: PatchStatusContext): PatchStatusReport;
|
|
79
79
|
//#endregion
|
|
80
|
-
//#region src/v4/types.d.ts
|
|
81
|
-
interface TailwindV4SourceOptions {
|
|
82
|
-
projectRoot?: string;
|
|
83
|
-
cwd?: string;
|
|
84
|
-
base?: string;
|
|
85
|
-
baseFallbacks?: string[];
|
|
86
|
-
css?: string;
|
|
87
|
-
cssEntries?: string[];
|
|
88
|
-
packageName?: string;
|
|
89
|
-
}
|
|
90
|
-
interface TailwindV4ResolvedSource {
|
|
91
|
-
projectRoot: string;
|
|
92
|
-
base: string;
|
|
93
|
-
baseFallbacks: string[];
|
|
94
|
-
css: string;
|
|
95
|
-
dependencies: string[];
|
|
96
|
-
}
|
|
97
|
-
interface TailwindV4CandidateSource {
|
|
98
|
-
content: string;
|
|
99
|
-
extension?: string;
|
|
100
|
-
}
|
|
101
|
-
interface TailwindV4GenerateOptions {
|
|
102
|
-
candidates?: Iterable<string>;
|
|
103
|
-
sources?: TailwindV4CandidateSource[];
|
|
104
|
-
/**
|
|
105
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
106
|
-
*/
|
|
107
|
-
bareArbitraryValues?: boolean | {
|
|
108
|
-
units?: string[];
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* 扫描文件系统 source entries 中的候选类名。
|
|
112
|
-
*
|
|
113
|
-
* - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
|
|
114
|
-
* - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
|
|
115
|
-
*/
|
|
116
|
-
scanSources?: boolean | TailwindV4SourcePattern[];
|
|
117
|
-
}
|
|
118
|
-
interface TailwindV4SourcePattern {
|
|
119
|
-
base: string;
|
|
120
|
-
pattern: string;
|
|
121
|
-
negated: boolean;
|
|
122
|
-
}
|
|
123
|
-
interface TailwindV4GenerateResult {
|
|
124
|
-
css: string;
|
|
125
|
-
classSet: Set<string>;
|
|
126
|
-
rawCandidates: Set<string>;
|
|
127
|
-
dependencies: string[];
|
|
128
|
-
sources: TailwindV4SourcePattern[];
|
|
129
|
-
root: null | 'none' | {
|
|
130
|
-
base: string;
|
|
131
|
-
pattern: string;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
interface TailwindV4DesignSystem {
|
|
135
|
-
parseCandidate: (candidate: string) => unknown[];
|
|
136
|
-
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
137
|
-
}
|
|
138
|
-
interface TailwindV4Engine {
|
|
139
|
-
source: TailwindV4ResolvedSource;
|
|
140
|
-
loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
|
|
141
|
-
validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
|
|
142
|
-
generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
145
80
|
//#region src/v4/candidates.d.ts
|
|
146
81
|
declare function resolveValidTailwindV4Candidates(designSystem: TailwindV4DesignSystem, candidates: Iterable<string>, options?: {
|
|
147
82
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
@@ -162,4 +97,4 @@ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPa
|
|
|
162
97
|
declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
|
|
163
98
|
declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
|
|
164
99
|
//#endregion
|
|
165
|
-
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 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, 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, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TailwindV4SourceOptions, A as groupTokensByFile, B as NormalizedTailwindCssPatchOptions, C as MIGRATION_REPORT_SCHEMA_VERSION, D as extractRawCandidates, E as extractProjectCandidatesWithPositions, F as CacheStrategy, G as TailwindV4Options, H as TailwindCssPatchOptions, I as ExposeContextOptions, J as TailwindV4DesignSystem, K as TailwindV4CandidateSource, L as ExtendLengthUnitsOptions, M as normalizeOptions, N as ApplyOptions, O as extractRawCandidatesWithPositions, P as CacheOptions, Q as TailwindV4ResolvedSource, R as ExtractOptions, S as MIGRATION_REPORT_KIND, T as TailwindcssPatcher, U as TailwindV2Options, V as TailwindCssOptions, W as TailwindV3Options, X as TailwindV4GenerateOptions, Y as TailwindV4Engine, Z as TailwindV4GenerateResult, _ as ConfigFileMigrationEntry, _t as CacheContextMetadata, a as ValidateFailureSummary, at as PatchStatusReport, b as RestoreConfigFilesOptions, bt as CacheReadResult, c as TailwindcssPatchCliMountOptions, ct as TailwindTokenFileKey, d as TailwindcssPatchCommandContext, dt as TailwindcssClassCache, et as ExtractResult, f as TailwindcssPatchCommandHandler, ft as TailwindcssRuntimeContext, g as tailwindcssPatchCommands, gt as CacheContextDescriptor, h as TailwindcssPatchCommandOptions, ht as CacheClearScope, i as ValidateFailureReason, it as PatchStatusEntry, j as BareArbitraryValueOptions, k as extractValidCandidates, l as TailwindcssPatchCliOptions, lt as TailwindTokenLocation, m as TailwindcssPatchCommandOptionDefinition, mt as CacheClearResult, n as VALIDATE_FAILURE_REASONS, nt as PatchCheckStatus, o as ValidateJsonFailurePayload, ot as TailwindPatchRuntime, p as TailwindcssPatchCommandHandlerMap, pt as CacheClearOptions, q as TailwindV4CssSource, r as ValidateCommandError, rt as PatchName, s as ValidateJsonSuccessPayload, st as TailwindTokenByFileMap, t as VALIDATE_EXIT_CODES, tt as ILengthUnitsPatchOptions, u as TailwindcssPatchCommand, ut as TailwindTokenReport, v as ConfigFileMigrationReport, vt as CacheIndexFileV2, w as logger, x as RestoreConfigFilesResult, y as MigrateConfigFilesOptions, yt as CacheReadMeta, z as NormalizedCacheOptions } from "./validate-rPPCy1cl.js";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
import { PackageInfo } from "local-pkg";
|
|
4
4
|
import postcss from "postcss";
|
|
@@ -77,71 +77,6 @@ interface PatchStatusContext {
|
|
|
77
77
|
}
|
|
78
78
|
declare function getPatchStatusReport(context: PatchStatusContext): PatchStatusReport;
|
|
79
79
|
//#endregion
|
|
80
|
-
//#region src/v4/types.d.ts
|
|
81
|
-
interface TailwindV4SourceOptions {
|
|
82
|
-
projectRoot?: string;
|
|
83
|
-
cwd?: string;
|
|
84
|
-
base?: string;
|
|
85
|
-
baseFallbacks?: string[];
|
|
86
|
-
css?: string;
|
|
87
|
-
cssEntries?: string[];
|
|
88
|
-
packageName?: string;
|
|
89
|
-
}
|
|
90
|
-
interface TailwindV4ResolvedSource {
|
|
91
|
-
projectRoot: string;
|
|
92
|
-
base: string;
|
|
93
|
-
baseFallbacks: string[];
|
|
94
|
-
css: string;
|
|
95
|
-
dependencies: string[];
|
|
96
|
-
}
|
|
97
|
-
interface TailwindV4CandidateSource {
|
|
98
|
-
content: string;
|
|
99
|
-
extension?: string;
|
|
100
|
-
}
|
|
101
|
-
interface TailwindV4GenerateOptions {
|
|
102
|
-
candidates?: Iterable<string>;
|
|
103
|
-
sources?: TailwindV4CandidateSource[];
|
|
104
|
-
/**
|
|
105
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
106
|
-
*/
|
|
107
|
-
bareArbitraryValues?: boolean | {
|
|
108
|
-
units?: string[];
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* 扫描文件系统 source entries 中的候选类名。
|
|
112
|
-
*
|
|
113
|
-
* - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
|
|
114
|
-
* - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
|
|
115
|
-
*/
|
|
116
|
-
scanSources?: boolean | TailwindV4SourcePattern[];
|
|
117
|
-
}
|
|
118
|
-
interface TailwindV4SourcePattern {
|
|
119
|
-
base: string;
|
|
120
|
-
pattern: string;
|
|
121
|
-
negated: boolean;
|
|
122
|
-
}
|
|
123
|
-
interface TailwindV4GenerateResult {
|
|
124
|
-
css: string;
|
|
125
|
-
classSet: Set<string>;
|
|
126
|
-
rawCandidates: Set<string>;
|
|
127
|
-
dependencies: string[];
|
|
128
|
-
sources: TailwindV4SourcePattern[];
|
|
129
|
-
root: null | 'none' | {
|
|
130
|
-
base: string;
|
|
131
|
-
pattern: string;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
interface TailwindV4DesignSystem {
|
|
135
|
-
parseCandidate: (candidate: string) => unknown[];
|
|
136
|
-
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
137
|
-
}
|
|
138
|
-
interface TailwindV4Engine {
|
|
139
|
-
source: TailwindV4ResolvedSource;
|
|
140
|
-
loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
|
|
141
|
-
validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
|
|
142
|
-
generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
145
80
|
//#region src/v4/candidates.d.ts
|
|
146
81
|
declare function resolveValidTailwindV4Candidates(designSystem: TailwindV4DesignSystem, candidates: Iterable<string>, options?: {
|
|
147
82
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
@@ -162,4 +97,4 @@ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPa
|
|
|
162
97
|
declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
|
|
163
98
|
declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
|
|
164
99
|
//#endregion
|
|
165
|
-
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 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, 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, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, 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-DABvQ44V.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-BdxyJef9.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;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as CacheStore, E as resolveValidTailwindV4Candidates, 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, j as logger, k as normalizeOptions, 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, y as extractValidCandidates } from "./validate-
|
|
2
|
-
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-
|
|
1
|
+
import { A as CacheStore, E as resolveValidTailwindV4Candidates, 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, j as logger, k as normalizeOptions, 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, y as extractValidCandidates } from "./validate-cMWKFUKS.mjs";
|
|
2
|
+
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-C39laqrA.mjs";
|
|
3
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 };
|
|
@@ -23,7 +23,7 @@ _babel_traverse = require_chunk.__toESM(_babel_traverse);
|
|
|
23
23
|
let _babel_parser = require("@babel/parser");
|
|
24
24
|
let tailwindcss_config = require("tailwindcss-config");
|
|
25
25
|
//#region package.json
|
|
26
|
-
var version = "9.3.
|
|
26
|
+
var version = "9.3.3";
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/constants.ts
|
|
29
29
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1330,6 +1330,13 @@ function normalizeExtendLengthUnitsOptions(extend) {
|
|
|
1330
1330
|
function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
1331
1331
|
const configuredBase = v4?.base ? pathe.default.resolve(v4.base) : void 0;
|
|
1332
1332
|
const base = configuredBase ?? fallbackBase;
|
|
1333
|
+
const resolveV4Path = (value) => pathe.default.isAbsolute(value) ? pathe.default.resolve(value) : pathe.default.resolve(fallbackBase, value);
|
|
1334
|
+
const cssSources = Array.isArray(v4?.cssSources) ? v4.cssSources.filter((source) => typeof source?.css === "string").map((source) => ({
|
|
1335
|
+
css: source.css,
|
|
1336
|
+
...source.base === void 0 ? {} : { base: resolveV4Path(source.base) },
|
|
1337
|
+
...source.file === void 0 ? {} : { file: resolveV4Path(source.file) },
|
|
1338
|
+
...source.dependencies === void 0 ? {} : { dependencies: source.dependencies.filter(Boolean).map(resolveV4Path) }
|
|
1339
|
+
})) : [];
|
|
1333
1340
|
const cssEntries = Array.isArray(v4?.cssEntries) ? v4.cssEntries.filter((entry) => Boolean(entry)).map((entry) => pathe.default.resolve(entry)) : [];
|
|
1334
1341
|
const userSources = v4?.sources;
|
|
1335
1342
|
const hasUserDefinedSources = Boolean(userSources?.length);
|
|
@@ -1342,6 +1349,7 @@ function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
|
1342
1349
|
base,
|
|
1343
1350
|
...configuredBase === void 0 ? {} : { configuredBase },
|
|
1344
1351
|
...v4?.css === void 0 ? {} : { css: v4.css },
|
|
1352
|
+
cssSources,
|
|
1345
1353
|
cssEntries,
|
|
1346
1354
|
sources,
|
|
1347
1355
|
hasUserDefinedSources,
|
|
@@ -2317,6 +2325,25 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2317
2325
|
negated: source.negated
|
|
2318
2326
|
}));
|
|
2319
2327
|
};
|
|
2328
|
+
const addCandidates = async (extractOptions) => {
|
|
2329
|
+
const candidates = await extractValidCandidates(extractOptions);
|
|
2330
|
+
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2331
|
+
};
|
|
2332
|
+
if (v4Options.cssSources.length > 0) for (const source of v4Options.cssSources) {
|
|
2333
|
+
const sourceFile = toAbsolute(source.file);
|
|
2334
|
+
const sourceBase = toAbsolute(source.base) ?? (sourceFile ? pathe.default.dirname(sourceFile) : resolvedDefaultBase);
|
|
2335
|
+
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== sourceBase ? [sourceBase, resolvedConfiguredBase] : [sourceBase];
|
|
2336
|
+
const sources = resolveSources(sourceBase);
|
|
2337
|
+
const firstBase = designSystemBases[0] ?? sourceBase;
|
|
2338
|
+
await addCandidates({
|
|
2339
|
+
cwd: options.projectRoot,
|
|
2340
|
+
base: firstBase,
|
|
2341
|
+
baseFallbacks: designSystemBases.slice(1),
|
|
2342
|
+
css: source.css,
|
|
2343
|
+
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2344
|
+
...sources === void 0 ? {} : { sources }
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2320
2347
|
if (v4Options.cssEntries.length > 0) for (const entry of v4Options.cssEntries) {
|
|
2321
2348
|
const filePath = pathe.default.isAbsolute(entry) ? entry : pathe.default.resolve(options.projectRoot, entry);
|
|
2322
2349
|
if (!await fs_extra.default.pathExists(filePath)) continue;
|
|
@@ -2325,7 +2352,7 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2325
2352
|
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== entryDir ? [entryDir, resolvedConfiguredBase] : [entryDir];
|
|
2326
2353
|
const sources = resolveSources(resolvedConfiguredBase ?? entryDir);
|
|
2327
2354
|
const firstBase = designSystemBases[0] ?? entryDir;
|
|
2328
|
-
|
|
2355
|
+
await addCandidates({
|
|
2329
2356
|
cwd: options.projectRoot,
|
|
2330
2357
|
base: firstBase,
|
|
2331
2358
|
baseFallbacks: designSystemBases.slice(1),
|
|
@@ -2333,19 +2360,17 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2333
2360
|
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2334
2361
|
...sources === void 0 ? {} : { sources }
|
|
2335
2362
|
});
|
|
2336
|
-
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2337
2363
|
}
|
|
2338
|
-
else {
|
|
2364
|
+
else if (v4Options.cssSources.length === 0) {
|
|
2339
2365
|
const baseForCss = resolvedConfiguredBase ?? resolvedDefaultBase;
|
|
2340
2366
|
const sources = resolveSources(baseForCss);
|
|
2341
|
-
|
|
2367
|
+
await addCandidates({
|
|
2342
2368
|
cwd: options.projectRoot,
|
|
2343
2369
|
base: baseForCss,
|
|
2344
2370
|
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2345
2371
|
...v4Options.css === void 0 ? {} : { css: v4Options.css },
|
|
2346
2372
|
...sources === void 0 ? {} : { sources }
|
|
2347
2373
|
});
|
|
2348
|
-
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2349
2374
|
}
|
|
2350
2375
|
return set;
|
|
2351
2376
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CAC, Command } from "cac";
|
|
2
1
|
import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
3
|
-
import
|
|
2
|
+
import * as _$consola from "consola";
|
|
4
3
|
import { Node, Rule } from "postcss";
|
|
4
|
+
import { CAC, Command } from "cac";
|
|
5
|
+
import { SourceEntry } from "@tailwindcss/oxide";
|
|
5
6
|
import { Config } from "tailwindcss";
|
|
6
|
-
import * as _$consola from "consola";
|
|
7
|
-
|
|
8
7
|
//#region src/cache/types.d.ts
|
|
9
8
|
declare const CACHE_SCHEMA_VERSION = 2;
|
|
10
9
|
declare const CACHE_FINGERPRINT_VERSION = 1;
|
|
@@ -159,6 +158,78 @@ interface PatchStatusReport {
|
|
|
159
158
|
entries: PatchStatusEntry[];
|
|
160
159
|
}
|
|
161
160
|
//#endregion
|
|
161
|
+
//#region src/v4/types.d.ts
|
|
162
|
+
interface TailwindV4SourceOptions {
|
|
163
|
+
projectRoot?: string;
|
|
164
|
+
cwd?: string;
|
|
165
|
+
base?: string;
|
|
166
|
+
baseFallbacks?: string[];
|
|
167
|
+
css?: string;
|
|
168
|
+
cssSources?: TailwindV4CssSource[];
|
|
169
|
+
cssEntries?: string[];
|
|
170
|
+
packageName?: string;
|
|
171
|
+
}
|
|
172
|
+
interface TailwindV4CssSource {
|
|
173
|
+
css: string;
|
|
174
|
+
base?: string;
|
|
175
|
+
file?: string;
|
|
176
|
+
dependencies?: string[];
|
|
177
|
+
}
|
|
178
|
+
interface TailwindV4ResolvedSource {
|
|
179
|
+
projectRoot: string;
|
|
180
|
+
base: string;
|
|
181
|
+
baseFallbacks: string[];
|
|
182
|
+
css: string;
|
|
183
|
+
dependencies: string[];
|
|
184
|
+
}
|
|
185
|
+
interface TailwindV4CandidateSource {
|
|
186
|
+
content: string;
|
|
187
|
+
extension?: string;
|
|
188
|
+
}
|
|
189
|
+
interface TailwindV4GenerateOptions {
|
|
190
|
+
candidates?: Iterable<string>;
|
|
191
|
+
sources?: TailwindV4CandidateSource[];
|
|
192
|
+
/**
|
|
193
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
194
|
+
*/
|
|
195
|
+
bareArbitraryValues?: boolean | {
|
|
196
|
+
units?: string[];
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* 扫描文件系统 source entries 中的候选类名。
|
|
200
|
+
*
|
|
201
|
+
* - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
|
|
202
|
+
* - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
|
|
203
|
+
*/
|
|
204
|
+
scanSources?: boolean | TailwindV4SourcePattern[];
|
|
205
|
+
}
|
|
206
|
+
interface TailwindV4SourcePattern {
|
|
207
|
+
base: string;
|
|
208
|
+
pattern: string;
|
|
209
|
+
negated: boolean;
|
|
210
|
+
}
|
|
211
|
+
interface TailwindV4GenerateResult {
|
|
212
|
+
css: string;
|
|
213
|
+
classSet: Set<string>;
|
|
214
|
+
rawCandidates: Set<string>;
|
|
215
|
+
dependencies: string[];
|
|
216
|
+
sources: TailwindV4SourcePattern[];
|
|
217
|
+
root: null | 'none' | {
|
|
218
|
+
base: string;
|
|
219
|
+
pattern: string;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
interface TailwindV4DesignSystem {
|
|
223
|
+
parseCandidate: (candidate: string) => unknown[];
|
|
224
|
+
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
225
|
+
}
|
|
226
|
+
interface TailwindV4Engine {
|
|
227
|
+
source: TailwindV4ResolvedSource;
|
|
228
|
+
loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
|
|
229
|
+
validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
|
|
230
|
+
generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
162
233
|
//#region src/options/types.d.ts
|
|
163
234
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
164
235
|
type CacheDriver = 'file' | 'memory' | 'noop';
|
|
@@ -246,6 +317,8 @@ interface TailwindV4Options {
|
|
|
246
317
|
base?: string;
|
|
247
318
|
/** Raw CSS passed directly to the v4 design system. */
|
|
248
319
|
css?: string;
|
|
320
|
+
/** 构建器在 CSS 落盘前捕获的内存 CSS 入口。 */
|
|
321
|
+
cssSources?: TailwindV4CssSource[];
|
|
249
322
|
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
250
323
|
cssEntries?: string[];
|
|
251
324
|
/** Overrides the content sources scanned by the oxide scanner. */
|
|
@@ -328,6 +401,7 @@ interface NormalizedTailwindV4Options {
|
|
|
328
401
|
base: string;
|
|
329
402
|
configuredBase?: string;
|
|
330
403
|
css?: string;
|
|
404
|
+
cssSources: TailwindV4CssSource[];
|
|
331
405
|
cssEntries: string[];
|
|
332
406
|
sources: SourceEntry[];
|
|
333
407
|
hasUserDefinedSources: boolean;
|
|
@@ -699,4 +773,4 @@ declare class ValidateCommandError extends Error {
|
|
|
699
773
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
700
774
|
}
|
|
701
775
|
//#endregion
|
|
702
|
-
export {
|
|
776
|
+
export { TailwindV4SourceOptions as $, groupTokensByFile as A, NormalizedTailwindCssPatchOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, extractRawCandidates as D, extractProjectCandidatesWithPositions as E, CacheStrategy as F, TailwindV4Options as G, TailwindCssPatchOptions as H, ExposeContextOptions as I, TailwindV4DesignSystem as J, TailwindV4CandidateSource as K, ExtendLengthUnitsOptions as L, normalizeOptions as M, ApplyOptions as N, extractRawCandidatesWithPositions as O, CacheOptions as P, TailwindV4ResolvedSource as Q, ExtractOptions as R, MIGRATION_REPORT_KIND as S, TailwindcssPatcher as T, TailwindV2Options as U, TailwindCssOptions as V, TailwindV3Options as W, TailwindV4GenerateOptions as X, TailwindV4Engine as Y, TailwindV4GenerateResult as Z, ConfigFileMigrationEntry as _, CacheContextMetadata as _t, ValidateFailureSummary as a, PatchStatusReport as at, RestoreConfigFilesOptions as b, CacheReadResult as bt, TailwindcssPatchCliMountOptions as c, TailwindTokenFileKey as ct, TailwindcssPatchCommandContext as d, TailwindcssClassCache as dt, ExtractResult as et, TailwindcssPatchCommandHandler as f, TailwindcssRuntimeContext as ft, tailwindcssPatchCommands as g, CacheContextDescriptor as gt, TailwindcssPatchCommandOptions as h, CacheClearScope as ht, ValidateFailureReason as i, PatchStatusEntry as it, BareArbitraryValueOptions as j, extractValidCandidates as k, TailwindcssPatchCliOptions as l, TailwindTokenLocation as lt, TailwindcssPatchCommandOptionDefinition as m, CacheClearResult as mt, VALIDATE_FAILURE_REASONS as n, PatchCheckStatus as nt, ValidateJsonFailurePayload as o, TailwindPatchRuntime as ot, TailwindcssPatchCommandHandlerMap as p, CacheClearOptions as pt, TailwindV4CssSource as q, ValidateCommandError as r, PatchName as rt, ValidateJsonSuccessPayload as s, TailwindTokenByFileMap as st, VALIDATE_EXIT_CODES as t, ILengthUnitsPatchOptions as tt, TailwindcssPatchCommand as u, TailwindTokenReport as ut, ConfigFileMigrationReport as v, CacheIndexFileV2 as vt, logger as w, RestoreConfigFilesResult as x, MigrateConfigFilesOptions as y, CacheReadMeta as yt, NormalizedCacheOptions as z };
|
|
@@ -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.3";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/constants.ts
|
|
22
22
|
const pkgName = "tailwindcss-patch";
|
|
@@ -1323,6 +1323,13 @@ function normalizeExtendLengthUnitsOptions(extend) {
|
|
|
1323
1323
|
function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
1324
1324
|
const configuredBase = v4?.base ? path.resolve(v4.base) : void 0;
|
|
1325
1325
|
const base = configuredBase ?? fallbackBase;
|
|
1326
|
+
const resolveV4Path = (value) => path.isAbsolute(value) ? path.resolve(value) : path.resolve(fallbackBase, value);
|
|
1327
|
+
const cssSources = Array.isArray(v4?.cssSources) ? v4.cssSources.filter((source) => typeof source?.css === "string").map((source) => ({
|
|
1328
|
+
css: source.css,
|
|
1329
|
+
...source.base === void 0 ? {} : { base: resolveV4Path(source.base) },
|
|
1330
|
+
...source.file === void 0 ? {} : { file: resolveV4Path(source.file) },
|
|
1331
|
+
...source.dependencies === void 0 ? {} : { dependencies: source.dependencies.filter(Boolean).map(resolveV4Path) }
|
|
1332
|
+
})) : [];
|
|
1326
1333
|
const cssEntries = Array.isArray(v4?.cssEntries) ? v4.cssEntries.filter((entry) => Boolean(entry)).map((entry) => path.resolve(entry)) : [];
|
|
1327
1334
|
const userSources = v4?.sources;
|
|
1328
1335
|
const hasUserDefinedSources = Boolean(userSources?.length);
|
|
@@ -1335,6 +1342,7 @@ function normalizeTailwindV4Options(v4, fallbackBase) {
|
|
|
1335
1342
|
base,
|
|
1336
1343
|
...configuredBase === void 0 ? {} : { configuredBase },
|
|
1337
1344
|
...v4?.css === void 0 ? {} : { css: v4.css },
|
|
1345
|
+
cssSources,
|
|
1338
1346
|
cssEntries,
|
|
1339
1347
|
sources,
|
|
1340
1348
|
hasUserDefinedSources,
|
|
@@ -2315,6 +2323,25 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2315
2323
|
negated: source.negated
|
|
2316
2324
|
}));
|
|
2317
2325
|
};
|
|
2326
|
+
const addCandidates = async (extractOptions) => {
|
|
2327
|
+
const candidates = await extractValidCandidates(extractOptions);
|
|
2328
|
+
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2329
|
+
};
|
|
2330
|
+
if (v4Options.cssSources.length > 0) for (const source of v4Options.cssSources) {
|
|
2331
|
+
const sourceFile = toAbsolute(source.file);
|
|
2332
|
+
const sourceBase = toAbsolute(source.base) ?? (sourceFile ? path.dirname(sourceFile) : resolvedDefaultBase);
|
|
2333
|
+
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== sourceBase ? [sourceBase, resolvedConfiguredBase] : [sourceBase];
|
|
2334
|
+
const sources = resolveSources(sourceBase);
|
|
2335
|
+
const firstBase = designSystemBases[0] ?? sourceBase;
|
|
2336
|
+
await addCandidates({
|
|
2337
|
+
cwd: options.projectRoot,
|
|
2338
|
+
base: firstBase,
|
|
2339
|
+
baseFallbacks: designSystemBases.slice(1),
|
|
2340
|
+
css: source.css,
|
|
2341
|
+
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2342
|
+
...sources === void 0 ? {} : { sources }
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2318
2345
|
if (v4Options.cssEntries.length > 0) for (const entry of v4Options.cssEntries) {
|
|
2319
2346
|
const filePath = path.isAbsolute(entry) ? entry : path.resolve(options.projectRoot, entry);
|
|
2320
2347
|
if (!await fs.pathExists(filePath)) continue;
|
|
@@ -2323,7 +2350,7 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2323
2350
|
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== entryDir ? [entryDir, resolvedConfiguredBase] : [entryDir];
|
|
2324
2351
|
const sources = resolveSources(resolvedConfiguredBase ?? entryDir);
|
|
2325
2352
|
const firstBase = designSystemBases[0] ?? entryDir;
|
|
2326
|
-
|
|
2353
|
+
await addCandidates({
|
|
2327
2354
|
cwd: options.projectRoot,
|
|
2328
2355
|
base: firstBase,
|
|
2329
2356
|
baseFallbacks: designSystemBases.slice(1),
|
|
@@ -2331,19 +2358,17 @@ async function collectClassesFromTailwindV4(options) {
|
|
|
2331
2358
|
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2332
2359
|
...sources === void 0 ? {} : { sources }
|
|
2333
2360
|
});
|
|
2334
|
-
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2335
2361
|
}
|
|
2336
|
-
else {
|
|
2362
|
+
else if (v4Options.cssSources.length === 0) {
|
|
2337
2363
|
const baseForCss = resolvedConfiguredBase ?? resolvedDefaultBase;
|
|
2338
2364
|
const sources = resolveSources(baseForCss);
|
|
2339
|
-
|
|
2365
|
+
await addCandidates({
|
|
2340
2366
|
cwd: options.projectRoot,
|
|
2341
2367
|
base: baseForCss,
|
|
2342
2368
|
...v4Options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues },
|
|
2343
2369
|
...v4Options.css === void 0 ? {} : { css: v4Options.css },
|
|
2344
2370
|
...sources === void 0 ? {} : { sources }
|
|
2345
2371
|
});
|
|
2346
|
-
for (const candidate of candidates) if (options.filter(candidate)) set.add(candidate);
|
|
2347
2372
|
}
|
|
2348
2373
|
return set;
|
|
2349
2374
|
}
|
|
@@ -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;
|
|
@@ -158,6 +159,78 @@ interface PatchStatusReport {
|
|
|
158
159
|
entries: PatchStatusEntry[];
|
|
159
160
|
}
|
|
160
161
|
//#endregion
|
|
162
|
+
//#region src/v4/types.d.ts
|
|
163
|
+
interface TailwindV4SourceOptions {
|
|
164
|
+
projectRoot?: string;
|
|
165
|
+
cwd?: string;
|
|
166
|
+
base?: string;
|
|
167
|
+
baseFallbacks?: string[];
|
|
168
|
+
css?: string;
|
|
169
|
+
cssSources?: TailwindV4CssSource[];
|
|
170
|
+
cssEntries?: string[];
|
|
171
|
+
packageName?: string;
|
|
172
|
+
}
|
|
173
|
+
interface TailwindV4CssSource {
|
|
174
|
+
css: string;
|
|
175
|
+
base?: string;
|
|
176
|
+
file?: string;
|
|
177
|
+
dependencies?: string[];
|
|
178
|
+
}
|
|
179
|
+
interface TailwindV4ResolvedSource {
|
|
180
|
+
projectRoot: string;
|
|
181
|
+
base: string;
|
|
182
|
+
baseFallbacks: string[];
|
|
183
|
+
css: string;
|
|
184
|
+
dependencies: string[];
|
|
185
|
+
}
|
|
186
|
+
interface TailwindV4CandidateSource {
|
|
187
|
+
content: string;
|
|
188
|
+
extension?: string;
|
|
189
|
+
}
|
|
190
|
+
interface TailwindV4GenerateOptions {
|
|
191
|
+
candidates?: Iterable<string>;
|
|
192
|
+
sources?: TailwindV4CandidateSource[];
|
|
193
|
+
/**
|
|
194
|
+
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
195
|
+
*/
|
|
196
|
+
bareArbitraryValues?: boolean | {
|
|
197
|
+
units?: string[];
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* 扫描文件系统 source entries 中的候选类名。
|
|
201
|
+
*
|
|
202
|
+
* - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
|
|
203
|
+
* - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
|
|
204
|
+
*/
|
|
205
|
+
scanSources?: boolean | TailwindV4SourcePattern[];
|
|
206
|
+
}
|
|
207
|
+
interface TailwindV4SourcePattern {
|
|
208
|
+
base: string;
|
|
209
|
+
pattern: string;
|
|
210
|
+
negated: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface TailwindV4GenerateResult {
|
|
213
|
+
css: string;
|
|
214
|
+
classSet: Set<string>;
|
|
215
|
+
rawCandidates: Set<string>;
|
|
216
|
+
dependencies: string[];
|
|
217
|
+
sources: TailwindV4SourcePattern[];
|
|
218
|
+
root: null | 'none' | {
|
|
219
|
+
base: string;
|
|
220
|
+
pattern: string;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
interface TailwindV4DesignSystem {
|
|
224
|
+
parseCandidate: (candidate: string) => unknown[];
|
|
225
|
+
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
226
|
+
}
|
|
227
|
+
interface TailwindV4Engine {
|
|
228
|
+
source: TailwindV4ResolvedSource;
|
|
229
|
+
loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
|
|
230
|
+
validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
|
|
231
|
+
generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
161
234
|
//#region src/options/types.d.ts
|
|
162
235
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
163
236
|
type CacheDriver = 'file' | 'memory' | 'noop';
|
|
@@ -245,6 +318,8 @@ interface TailwindV4Options {
|
|
|
245
318
|
base?: string;
|
|
246
319
|
/** Raw CSS passed directly to the v4 design system. */
|
|
247
320
|
css?: string;
|
|
321
|
+
/** 构建器在 CSS 落盘前捕获的内存 CSS 入口。 */
|
|
322
|
+
cssSources?: TailwindV4CssSource[];
|
|
248
323
|
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
249
324
|
cssEntries?: string[];
|
|
250
325
|
/** Overrides the content sources scanned by the oxide scanner. */
|
|
@@ -327,6 +402,7 @@ interface NormalizedTailwindV4Options {
|
|
|
327
402
|
base: string;
|
|
328
403
|
configuredBase?: string;
|
|
329
404
|
css?: string;
|
|
405
|
+
cssSources: TailwindV4CssSource[];
|
|
330
406
|
cssEntries: string[];
|
|
331
407
|
sources: SourceEntry[];
|
|
332
408
|
hasUserDefinedSources: boolean;
|
|
@@ -698,4 +774,4 @@ declare class ValidateCommandError extends Error {
|
|
|
698
774
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
699
775
|
}
|
|
700
776
|
//#endregion
|
|
701
|
-
export {
|
|
777
|
+
export { TailwindV4SourceOptions as $, groupTokensByFile as A, NormalizedTailwindCssPatchOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, extractRawCandidates as D, extractProjectCandidatesWithPositions as E, CacheStrategy as F, TailwindV4Options as G, TailwindCssPatchOptions as H, ExposeContextOptions as I, TailwindV4DesignSystem as J, TailwindV4CandidateSource as K, ExtendLengthUnitsOptions as L, normalizeOptions as M, ApplyOptions as N, extractRawCandidatesWithPositions as O, CacheOptions as P, TailwindV4ResolvedSource as Q, ExtractOptions as R, MIGRATION_REPORT_KIND as S, TailwindcssPatcher as T, TailwindV2Options as U, TailwindCssOptions as V, TailwindV3Options as W, TailwindV4GenerateOptions as X, TailwindV4Engine as Y, TailwindV4GenerateResult as Z, ConfigFileMigrationEntry as _, CacheContextMetadata as _t, ValidateFailureSummary as a, PatchStatusReport as at, RestoreConfigFilesOptions as b, CacheReadResult as bt, TailwindcssPatchCliMountOptions as c, TailwindTokenFileKey as ct, TailwindcssPatchCommandContext as d, TailwindcssClassCache as dt, ExtractResult as et, TailwindcssPatchCommandHandler as f, TailwindcssRuntimeContext as ft, tailwindcssPatchCommands as g, CacheContextDescriptor as gt, TailwindcssPatchCommandOptions as h, CacheClearScope as ht, ValidateFailureReason as i, PatchStatusEntry as it, BareArbitraryValueOptions as j, extractValidCandidates as k, TailwindcssPatchCliOptions as l, TailwindTokenLocation as lt, TailwindcssPatchCommandOptionDefinition as m, CacheClearResult as mt, VALIDATE_FAILURE_REASONS as n, PatchCheckStatus as nt, ValidateJsonFailurePayload as o, TailwindPatchRuntime as ot, TailwindcssPatchCommandHandlerMap as p, CacheClearOptions as pt, TailwindV4CssSource as q, ValidateCommandError as r, PatchName as rt, ValidateJsonSuccessPayload as s, TailwindTokenByFileMap as st, VALIDATE_EXIT_CODES as t, ILengthUnitsPatchOptions as tt, TailwindcssPatchCommand as u, TailwindTokenReport as ut, ConfigFileMigrationReport as v, CacheIndexFileV2 as vt, logger as w, RestoreConfigFilesResult as x, MigrateConfigFilesOptions as y, CacheReadMeta as yt, NormalizedCacheOptions as z };
|
package/package.json
CHANGED
package/src/index.bundle.ts
CHANGED
package/src/index.ts
CHANGED
package/src/options/normalize.ts
CHANGED
|
@@ -148,6 +148,19 @@ function normalizeTailwindV4Options(
|
|
|
148
148
|
): NormalizedTailwindV4Options {
|
|
149
149
|
const configuredBase = v4?.base ? path.resolve(v4.base) : undefined
|
|
150
150
|
const base = configuredBase ?? fallbackBase
|
|
151
|
+
const resolveV4Path = (value: string) => path.isAbsolute(value) ? path.resolve(value) : path.resolve(fallbackBase, value)
|
|
152
|
+
const cssSources = Array.isArray(v4?.cssSources)
|
|
153
|
+
? v4!.cssSources
|
|
154
|
+
.filter(source => typeof source?.css === 'string')
|
|
155
|
+
.map(source => ({
|
|
156
|
+
css: source.css,
|
|
157
|
+
...(source.base === undefined ? {} : { base: resolveV4Path(source.base) }),
|
|
158
|
+
...(source.file === undefined ? {} : { file: resolveV4Path(source.file) }),
|
|
159
|
+
...(source.dependencies === undefined
|
|
160
|
+
? {}
|
|
161
|
+
: { dependencies: source.dependencies.filter(Boolean).map(resolveV4Path) }),
|
|
162
|
+
}))
|
|
163
|
+
: []
|
|
151
164
|
const cssEntries = Array.isArray(v4?.cssEntries)
|
|
152
165
|
? v4!.cssEntries.filter((entry): entry is string => Boolean(entry)).map(entry => path.resolve(entry))
|
|
153
166
|
: []
|
|
@@ -167,6 +180,7 @@ function normalizeTailwindV4Options(
|
|
|
167
180
|
base,
|
|
168
181
|
...(configuredBase === undefined ? {} : { configuredBase }),
|
|
169
182
|
...(v4?.css === undefined ? {} : { css: v4.css }),
|
|
183
|
+
cssSources,
|
|
170
184
|
cssEntries,
|
|
171
185
|
sources,
|
|
172
186
|
hasUserDefinedSources,
|
package/src/options/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SourceEntry } from '@tailwindcss/oxide'
|
|
2
2
|
import type { PackageResolvingOptions } from 'local-pkg'
|
|
3
3
|
import type { ILengthUnitsPatchOptions } from '../types'
|
|
4
|
+
import type { TailwindV4CssSource } from '../v4/types'
|
|
4
5
|
|
|
5
6
|
export type CacheStrategy = 'merge' | 'overwrite'
|
|
6
7
|
export type CacheDriver = 'file' | 'memory' | 'noop'
|
|
@@ -97,6 +98,8 @@ export interface TailwindV4Options {
|
|
|
97
98
|
base?: string
|
|
98
99
|
/** Raw CSS passed directly to the v4 design system. */
|
|
99
100
|
css?: string
|
|
101
|
+
/** 构建器在 CSS 落盘前捕获的内存 CSS 入口。 */
|
|
102
|
+
cssSources?: TailwindV4CssSource[]
|
|
100
103
|
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
101
104
|
cssEntries?: string[]
|
|
102
105
|
/** Overrides the content sources scanned by the oxide scanner. */
|
|
@@ -187,6 +190,7 @@ export interface NormalizedTailwindV4Options {
|
|
|
187
190
|
base: string
|
|
188
191
|
configuredBase?: string
|
|
189
192
|
css?: string
|
|
193
|
+
cssSources: TailwindV4CssSource[]
|
|
190
194
|
cssEntries: string[]
|
|
191
195
|
sources: SourceEntry[]
|
|
192
196
|
hasUserDefinedSources: boolean
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExtractValidCandidatesOption } from '../extraction/candidate-extractor'
|
|
1
2
|
import type { NormalizedTailwindCssPatchOptions } from '../options/types'
|
|
2
3
|
import type { TailwindcssRuntimeContext } from '../types'
|
|
3
4
|
import process from 'node:process'
|
|
@@ -63,6 +64,35 @@ export async function collectClassesFromTailwindV4(
|
|
|
63
64
|
negated: source.negated,
|
|
64
65
|
}))
|
|
65
66
|
}
|
|
67
|
+
const addCandidates = async (extractOptions: ExtractValidCandidatesOption) => {
|
|
68
|
+
const candidates = await extractValidCandidates(extractOptions)
|
|
69
|
+
for (const candidate of candidates) {
|
|
70
|
+
if (options.filter(candidate)) {
|
|
71
|
+
set.add(candidate)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (v4Options.cssSources.length > 0) {
|
|
77
|
+
for (const source of v4Options.cssSources) {
|
|
78
|
+
const sourceFile = toAbsolute(source.file)
|
|
79
|
+
const sourceBase = toAbsolute(source.base)
|
|
80
|
+
?? (sourceFile ? path.dirname(sourceFile) : resolvedDefaultBase)
|
|
81
|
+
const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== sourceBase
|
|
82
|
+
? [sourceBase, resolvedConfiguredBase]
|
|
83
|
+
: [sourceBase]
|
|
84
|
+
const sources = resolveSources(sourceBase)
|
|
85
|
+
const firstBase = designSystemBases[0] ?? sourceBase
|
|
86
|
+
await addCandidates({
|
|
87
|
+
cwd: options.projectRoot,
|
|
88
|
+
base: firstBase,
|
|
89
|
+
baseFallbacks: designSystemBases.slice(1),
|
|
90
|
+
css: source.css,
|
|
91
|
+
...(v4Options.bareArbitraryValues === undefined ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues }),
|
|
92
|
+
...(sources === undefined ? {} : { sources }),
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
}
|
|
66
96
|
|
|
67
97
|
if (v4Options.cssEntries.length > 0) {
|
|
68
98
|
for (const entry of v4Options.cssEntries) {
|
|
@@ -86,15 +116,10 @@ export async function collectClassesFromTailwindV4(
|
|
|
86
116
|
...(v4Options.bareArbitraryValues === undefined ? {} : { bareArbitraryValues: v4Options.bareArbitraryValues }),
|
|
87
117
|
...(sources === undefined ? {} : { sources }),
|
|
88
118
|
}
|
|
89
|
-
|
|
90
|
-
for (const candidate of candidates) {
|
|
91
|
-
if (options.filter(candidate)) {
|
|
92
|
-
set.add(candidate)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
119
|
+
await addCandidates(extractOptions)
|
|
95
120
|
}
|
|
96
121
|
}
|
|
97
|
-
else {
|
|
122
|
+
else if (v4Options.cssSources.length === 0) {
|
|
98
123
|
const baseForCss = resolvedConfiguredBase ?? resolvedDefaultBase
|
|
99
124
|
const sources = resolveSources(baseForCss)
|
|
100
125
|
const extractOptions = {
|
|
@@ -104,12 +129,7 @@ export async function collectClassesFromTailwindV4(
|
|
|
104
129
|
...(v4Options.css === undefined ? {} : { css: v4Options.css }),
|
|
105
130
|
...(sources === undefined ? {} : { sources }),
|
|
106
131
|
}
|
|
107
|
-
|
|
108
|
-
for (const candidate of candidates) {
|
|
109
|
-
if (options.filter(candidate)) {
|
|
110
|
-
set.add(candidate)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
132
|
+
await addCandidates(extractOptions)
|
|
113
133
|
}
|
|
114
134
|
|
|
115
135
|
return set
|
package/src/v4/index.ts
CHANGED
package/src/v4/source.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NormalizedTailwindCssPatchOptions, TailwindCssPatchOptions } from '../config'
|
|
2
|
-
import type { TailwindV4ResolvedSource, TailwindV4SourceOptions } from './types'
|
|
2
|
+
import type { TailwindV4CssSource, TailwindV4ResolvedSource, TailwindV4SourceOptions } from './types'
|
|
3
3
|
import { promises as fs } from 'node:fs'
|
|
4
4
|
import process from 'node:process'
|
|
5
5
|
import path from 'pathe'
|
|
@@ -87,6 +87,35 @@ async function resolveCssEntries(entries: string[], projectRoot: string, base: s
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function resolveCssSources(sources: TailwindV4CssSource[], projectRoot: string, base: string | undefined) {
|
|
91
|
+
const resolvedSources = sources.map(source => ({
|
|
92
|
+
...source,
|
|
93
|
+
base: source.base === undefined ? undefined : resolveBase(source.base, projectRoot),
|
|
94
|
+
file: source.file === undefined
|
|
95
|
+
? undefined
|
|
96
|
+
: path.isAbsolute(source.file)
|
|
97
|
+
? path.resolve(source.file)
|
|
98
|
+
: path.resolve(projectRoot, source.file),
|
|
99
|
+
dependencies: source.dependencies?.map(dependency =>
|
|
100
|
+
path.isAbsolute(dependency) ? path.resolve(dependency) : path.resolve(projectRoot, dependency),
|
|
101
|
+
) ?? [],
|
|
102
|
+
}))
|
|
103
|
+
const firstSource = resolvedSources[0]
|
|
104
|
+
const resolvedBase = base
|
|
105
|
+
?? firstSource?.base
|
|
106
|
+
?? (firstSource?.file ? path.dirname(firstSource.file) : projectRoot)
|
|
107
|
+
const dependencies = resolvedSources.flatMap(source => [
|
|
108
|
+
source.file,
|
|
109
|
+
...source.dependencies,
|
|
110
|
+
]).filter((dependency): dependency is string => Boolean(dependency))
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
base: resolvedBase,
|
|
114
|
+
css: resolvedSources.map(source => source.css).join('\n'),
|
|
115
|
+
dependencies,
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
90
119
|
function normalizeResolvedSource(
|
|
91
120
|
source: {
|
|
92
121
|
projectRoot: string
|
|
@@ -129,15 +158,27 @@ export async function resolveTailwindV4Source(options: TailwindV4SourceOptions =
|
|
|
129
158
|
})
|
|
130
159
|
}
|
|
131
160
|
|
|
132
|
-
if (options.cssEntries?.length) {
|
|
133
|
-
const entries =
|
|
161
|
+
if (options.cssEntries?.length || options.cssSources?.length) {
|
|
162
|
+
const entries = options.cssEntries?.length
|
|
163
|
+
? await resolveCssEntries(options.cssEntries, projectRoot, configuredBase)
|
|
164
|
+
: undefined
|
|
165
|
+
const sources = options.cssSources?.length
|
|
166
|
+
? resolveCssSources(options.cssSources, projectRoot, configuredBase)
|
|
167
|
+
: undefined
|
|
168
|
+
const css = [
|
|
169
|
+
entries?.css,
|
|
170
|
+
sources?.css,
|
|
171
|
+
].filter(Boolean).join('\n')
|
|
134
172
|
return normalizeResolvedSource({
|
|
135
173
|
projectRoot,
|
|
136
174
|
cwd,
|
|
137
|
-
base: entries
|
|
175
|
+
base: configuredBase ?? entries?.base ?? sources?.base ?? cwd,
|
|
138
176
|
baseFallbacks,
|
|
139
|
-
css
|
|
140
|
-
dependencies:
|
|
177
|
+
css,
|
|
178
|
+
dependencies: [
|
|
179
|
+
...(entries?.dependencies ?? []),
|
|
180
|
+
...(sources?.dependencies ?? []),
|
|
181
|
+
],
|
|
141
182
|
})
|
|
142
183
|
}
|
|
143
184
|
|
|
@@ -177,6 +218,7 @@ function createSourceOptionsFromNormalizedPatchOptions(
|
|
|
177
218
|
...(v4?.configuredBase === undefined ? {} : { base: v4.configuredBase }),
|
|
178
219
|
baseFallbacks,
|
|
179
220
|
...(v4?.css === undefined ? {} : { css: v4.css }),
|
|
221
|
+
...(v4?.cssSources === undefined ? {} : { cssSources: v4.cssSources }),
|
|
180
222
|
...(v4?.cssEntries === undefined ? {} : { cssEntries: v4.cssEntries }),
|
|
181
223
|
packageName: options.tailwind.packageName,
|
|
182
224
|
}
|
package/src/v4/types.ts
CHANGED
|
@@ -4,10 +4,18 @@ export interface TailwindV4SourceOptions {
|
|
|
4
4
|
base?: string
|
|
5
5
|
baseFallbacks?: string[]
|
|
6
6
|
css?: string
|
|
7
|
+
cssSources?: TailwindV4CssSource[]
|
|
7
8
|
cssEntries?: string[]
|
|
8
9
|
packageName?: string
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
export interface TailwindV4CssSource {
|
|
13
|
+
css: string
|
|
14
|
+
base?: string
|
|
15
|
+
file?: string
|
|
16
|
+
dependencies?: string[]
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
export interface TailwindV4ResolvedSource {
|
|
12
20
|
projectRoot: string
|
|
13
21
|
base: string
|