tailwindcss-patch 9.0.1 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_validate = require("./validate-B8H-8rWO.js");
3
- const require_index_bundle = require("./index.bundle-BGBMTX9A.js");
2
+ const require_validate = require("./validate-749MHvAC.js");
3
+ const require_index_bundle = require("./index.bundle-BQ_yKkd8.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 { T as logger, r as ValidateCommandError } from "./validate-BI8356RT.mjs";
2
- import { t as createTailwindcssPatchCli } from "./index.bundle-ByrTqrr3.mjs";
1
+ import { k as logger, r as ValidateCommandError } from "./validate-D5elFZMj.mjs";
2
+ import { t as createTailwindcssPatchCli } from "./index.bundle-dp_pw5fq.mjs";
3
3
  import process from "node:process";
4
4
  //#region src/cli.bundle.ts
5
5
  async function main() {
@@ -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-B8H-8rWO.js");
3
+ const require_validate = require("../validate-749MHvAC.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 { S as loadWorkspaceConfigModule, T as logger, a as tailwindcssPatchCommands, b as groupTokensByFile, i as classifyValidateError, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher, x as loadPatchOptionsForWorkspace } from "../validate-BI8356RT.mjs";
1
+ import { E as loadWorkspaceConfigModule, T as loadPatchOptionsForWorkspace, a as tailwindcssPatchCommands, b as groupTokensByFile, i as classifyValidateError, k 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-D5elFZMj.mjs";
2
2
  import process from "node:process";
3
3
  import fs from "fs-extra";
4
4
  import path from "pathe";
@@ -0,0 +1,239 @@
1
+ const require_chunk = require("./chunk-8l464Juk.js");
2
+ const require_validate = require("./validate-749MHvAC.js");
3
+ let node_module = require("node:module");
4
+ let node_process = require("node:process");
5
+ node_process = require_chunk.__toESM(node_process);
6
+ let pathe = require("pathe");
7
+ pathe = require_chunk.__toESM(pathe);
8
+ let node_fs = require("node:fs");
9
+ //#region src/v4/engine.ts
10
+ function resolveScanSources(options, compiledSources) {
11
+ if (Array.isArray(options?.scanSources)) return options.scanSources;
12
+ if (options?.scanSources === true) return compiledSources;
13
+ return [];
14
+ }
15
+ async function collectRawCandidates(source, options, compiledSources = []) {
16
+ const rawCandidates = /* @__PURE__ */ new Set();
17
+ for (const candidate of options?.candidates ?? []) rawCandidates.add(candidate);
18
+ for (const candidateSource of options?.sources ?? []) {
19
+ const candidates = await require_validate.extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension);
20
+ for (const candidate of candidates) rawCandidates.add(candidate.rawCandidate);
21
+ }
22
+ const filesystemSources = resolveScanSources(options, compiledSources);
23
+ if (filesystemSources.length > 0) for (const candidate of await require_validate.extractRawCandidates(filesystemSources)) rawCandidates.add(candidate);
24
+ const inlineSources = require_validate.extractTailwindV4InlineSourceCandidates(source.css);
25
+ for (const candidate of inlineSources.included) rawCandidates.add(candidate);
26
+ for (const candidate of inlineSources.excluded) rawCandidates.delete(candidate);
27
+ return rawCandidates;
28
+ }
29
+ function createTailwindV4Engine(source) {
30
+ return {
31
+ source,
32
+ loadDesignSystem() {
33
+ return require_validate.loadTailwindV4DesignSystem(source);
34
+ },
35
+ async validateCandidates(candidates) {
36
+ return require_validate.resolveValidTailwindV4Candidates(await require_validate.loadTailwindV4DesignSystem(source), candidates);
37
+ },
38
+ async generate(options) {
39
+ const { compiled, dependencies } = await require_validate.compileTailwindV4Source(source);
40
+ const rawCandidates = await collectRawCandidates(source, options, compiled.sources);
41
+ const classSet = require_validate.resolveValidTailwindV4Candidates(await require_validate.loadTailwindV4DesignSystem(source), rawCandidates);
42
+ const inlineSources = require_validate.extractTailwindV4InlineSourceCandidates(source.css);
43
+ for (const candidate of inlineSources.excluded) classSet.delete(candidate);
44
+ return {
45
+ css: compiled.build(Array.from(classSet)),
46
+ classSet,
47
+ rawCandidates,
48
+ dependencies: Array.from(dependencies),
49
+ sources: compiled.sources,
50
+ root: compiled.root
51
+ };
52
+ }
53
+ };
54
+ }
55
+ //#endregion
56
+ //#region src/v4/source.ts
57
+ function resolveBase(value, fallback) {
58
+ return value === void 0 ? fallback : pathe.default.isAbsolute(value) ? pathe.default.resolve(value) : pathe.default.resolve(fallback, value);
59
+ }
60
+ function uniquePaths(values) {
61
+ const result = [];
62
+ for (const value of values) {
63
+ if (!value) continue;
64
+ const resolved = pathe.default.resolve(value);
65
+ if (!result.includes(resolved)) result.push(resolved);
66
+ }
67
+ return result;
68
+ }
69
+ function toCssImportPath(value) {
70
+ return value.replaceAll("\\", "/");
71
+ }
72
+ function quoteCssImport(value) {
73
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
74
+ }
75
+ function isPostcssPluginSpecifier(packageName) {
76
+ return packageName === "@tailwindcss/postcss" || /(?:^|[/\\])@tailwindcss[/\\]postcss(?:[/\\]|$)/.test(packageName) || /(?:^|[/\\])postcss(?:[/\\]|$)/i.test(packageName) || /postcss\.config\.[cm]?[jt]s$/i.test(packageName);
77
+ }
78
+ function createDefaultCss(packageName) {
79
+ return `@import "${quoteCssImport(toCssImportPath(packageName && !isPostcssPluginSpecifier(packageName) ? packageName : "tailwindcss"))}";`;
80
+ }
81
+ async function pathExists(filePath) {
82
+ try {
83
+ await node_fs.promises.access(filePath);
84
+ return true;
85
+ } catch {
86
+ return false;
87
+ }
88
+ }
89
+ async function resolveCssEntries(entries, projectRoot, base) {
90
+ const resolvedEntries = entries.map((entry) => ({
91
+ original: entry,
92
+ absolute: pathe.default.isAbsolute(entry) ? pathe.default.resolve(entry) : pathe.default.resolve(projectRoot, entry)
93
+ }));
94
+ const resolvedBase = base ?? pathe.default.dirname(resolvedEntries[0]?.absolute ?? projectRoot);
95
+ const dependencies = resolvedEntries.map((entry) => entry.absolute);
96
+ const cssParts = [];
97
+ for (const entry of resolvedEntries) {
98
+ if (await pathExists(entry.absolute)) {
99
+ cssParts.push(await node_fs.promises.readFile(entry.absolute, "utf8"));
100
+ continue;
101
+ }
102
+ const importPath = pathe.default.isAbsolute(entry.original) ? entry.absolute : pathe.default.relative(resolvedBase, entry.absolute);
103
+ cssParts.push(`@import "${quoteCssImport(toCssImportPath(importPath))}";`);
104
+ }
105
+ return {
106
+ base: resolvedBase,
107
+ css: cssParts.join("\n"),
108
+ dependencies
109
+ };
110
+ }
111
+ function normalizeResolvedSource(source) {
112
+ const baseFallbacks = uniquePaths([
113
+ ...source.baseFallbacks,
114
+ source.projectRoot,
115
+ source.cwd
116
+ ]).filter((base) => base !== source.base);
117
+ return {
118
+ projectRoot: source.projectRoot,
119
+ base: source.base,
120
+ baseFallbacks,
121
+ css: source.css,
122
+ dependencies: Array.from(new Set(source.dependencies.map((dependency) => pathe.default.resolve(dependency))))
123
+ };
124
+ }
125
+ async function resolveTailwindV4Source(options = {}) {
126
+ const projectRoot = resolveBase(options.projectRoot, node_process.default.cwd());
127
+ const cwd = resolveBase(options.cwd, projectRoot);
128
+ const configuredBase = options.base === void 0 ? void 0 : resolveBase(options.base, projectRoot);
129
+ const baseFallbacks = uniquePaths(options.baseFallbacks?.map((base) => resolveBase(base, projectRoot)) ?? []);
130
+ if (options.css !== void 0) return normalizeResolvedSource({
131
+ projectRoot,
132
+ cwd,
133
+ base: configuredBase ?? cwd,
134
+ baseFallbacks,
135
+ css: options.css,
136
+ dependencies: []
137
+ });
138
+ if (options.cssEntries?.length) {
139
+ const entries = await resolveCssEntries(options.cssEntries, projectRoot, configuredBase);
140
+ return normalizeResolvedSource({
141
+ projectRoot,
142
+ cwd,
143
+ base: entries.base,
144
+ baseFallbacks,
145
+ css: entries.css,
146
+ dependencies: entries.dependencies
147
+ });
148
+ }
149
+ return normalizeResolvedSource({
150
+ projectRoot,
151
+ cwd,
152
+ base: configuredBase ?? cwd,
153
+ baseFallbacks,
154
+ css: createDefaultCss(options.packageName),
155
+ dependencies: []
156
+ });
157
+ }
158
+ function resolveConfigDir(config, projectRoot) {
159
+ if (!config) return;
160
+ const configPath = pathe.default.isAbsolute(config) ? config : pathe.default.resolve(projectRoot, config);
161
+ return pathe.default.dirname(configPath);
162
+ }
163
+ function createSourceOptionsFromNormalizedPatchOptions(options) {
164
+ const v4 = options.tailwind.v4;
165
+ const configDir = resolveConfigDir(options.tailwind.config, options.projectRoot);
166
+ const baseFallbacks = uniquePaths([
167
+ v4?.configuredBase,
168
+ options.tailwind.cwd,
169
+ options.projectRoot,
170
+ configDir
171
+ ]);
172
+ return {
173
+ projectRoot: options.projectRoot,
174
+ ...options.tailwind.cwd === void 0 ? {} : { cwd: options.tailwind.cwd },
175
+ ...v4?.configuredBase === void 0 ? {} : { base: v4.configuredBase },
176
+ baseFallbacks,
177
+ ...v4?.css === void 0 ? {} : { css: v4.css },
178
+ ...v4?.cssEntries === void 0 ? {} : { cssEntries: v4.cssEntries },
179
+ packageName: options.tailwind.packageName
180
+ };
181
+ }
182
+ function tailwindV4SourceOptionsFromPatchOptions(options) {
183
+ return createSourceOptionsFromNormalizedPatchOptions(require_validate.normalizeOptions(options));
184
+ }
185
+ async function resolveTailwindV4SourceFromPatchOptions(options) {
186
+ return resolveTailwindV4Source(tailwindV4SourceOptionsFromPatchOptions(options));
187
+ }
188
+ //#endregion
189
+ //#region src/index.bundle.ts
190
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
191
+ function loadCliModule() {
192
+ return require$1("./commands/cli-runtime.js");
193
+ }
194
+ function mountTailwindcssPatchCommands(cli, options = {}) {
195
+ return loadCliModule().mountTailwindcssPatchCommands(cli, options);
196
+ }
197
+ function createTailwindcssPatchCli(options = {}) {
198
+ return loadCliModule().createTailwindcssPatchCli(options);
199
+ }
200
+ function defineConfig(config) {
201
+ return config;
202
+ }
203
+ //#endregion
204
+ Object.defineProperty(exports, "createTailwindV4Engine", {
205
+ enumerable: true,
206
+ get: function() {
207
+ return createTailwindV4Engine;
208
+ }
209
+ });
210
+ Object.defineProperty(exports, "createTailwindcssPatchCli", {
211
+ enumerable: true,
212
+ get: function() {
213
+ return createTailwindcssPatchCli;
214
+ }
215
+ });
216
+ Object.defineProperty(exports, "defineConfig", {
217
+ enumerable: true,
218
+ get: function() {
219
+ return defineConfig;
220
+ }
221
+ });
222
+ Object.defineProperty(exports, "mountTailwindcssPatchCommands", {
223
+ enumerable: true,
224
+ get: function() {
225
+ return mountTailwindcssPatchCommands;
226
+ }
227
+ });
228
+ Object.defineProperty(exports, "resolveTailwindV4Source", {
229
+ enumerable: true,
230
+ get: function() {
231
+ return resolveTailwindV4Source;
232
+ }
233
+ });
234
+ Object.defineProperty(exports, "resolveTailwindV4SourceFromPatchOptions", {
235
+ enumerable: true,
236
+ get: function() {
237
+ return resolveTailwindV4SourceFromPatchOptions;
238
+ }
239
+ });
@@ -0,0 +1,201 @@
1
+ import { C as extractTailwindV4InlineSourceCandidates, D as normalizeOptions, S as loadTailwindV4DesignSystem, _ as extractRawCandidates, v as extractRawCandidatesWithPositions, w as resolveValidTailwindV4Candidates, x as compileTailwindV4Source } from "./validate-D5elFZMj.mjs";
2
+ import { createRequire } from "node:module";
3
+ import process from "node:process";
4
+ import path from "pathe";
5
+ import { promises } from "node:fs";
6
+ //#region src/v4/engine.ts
7
+ function resolveScanSources(options, compiledSources) {
8
+ if (Array.isArray(options?.scanSources)) return options.scanSources;
9
+ if (options?.scanSources === true) return compiledSources;
10
+ return [];
11
+ }
12
+ async function collectRawCandidates(source, options, compiledSources = []) {
13
+ const rawCandidates = /* @__PURE__ */ new Set();
14
+ for (const candidate of options?.candidates ?? []) rawCandidates.add(candidate);
15
+ for (const candidateSource of options?.sources ?? []) {
16
+ const candidates = await extractRawCandidatesWithPositions(candidateSource.content, candidateSource.extension);
17
+ for (const candidate of candidates) rawCandidates.add(candidate.rawCandidate);
18
+ }
19
+ const filesystemSources = resolveScanSources(options, compiledSources);
20
+ if (filesystemSources.length > 0) for (const candidate of await extractRawCandidates(filesystemSources)) rawCandidates.add(candidate);
21
+ const inlineSources = extractTailwindV4InlineSourceCandidates(source.css);
22
+ for (const candidate of inlineSources.included) rawCandidates.add(candidate);
23
+ for (const candidate of inlineSources.excluded) rawCandidates.delete(candidate);
24
+ return rawCandidates;
25
+ }
26
+ function createTailwindV4Engine(source) {
27
+ return {
28
+ source,
29
+ loadDesignSystem() {
30
+ return loadTailwindV4DesignSystem(source);
31
+ },
32
+ async validateCandidates(candidates) {
33
+ return resolveValidTailwindV4Candidates(await loadTailwindV4DesignSystem(source), candidates);
34
+ },
35
+ async generate(options) {
36
+ const { compiled, dependencies } = await compileTailwindV4Source(source);
37
+ const rawCandidates = await collectRawCandidates(source, options, compiled.sources);
38
+ const classSet = resolveValidTailwindV4Candidates(await loadTailwindV4DesignSystem(source), rawCandidates);
39
+ const inlineSources = extractTailwindV4InlineSourceCandidates(source.css);
40
+ for (const candidate of inlineSources.excluded) classSet.delete(candidate);
41
+ return {
42
+ css: compiled.build(Array.from(classSet)),
43
+ classSet,
44
+ rawCandidates,
45
+ dependencies: Array.from(dependencies),
46
+ sources: compiled.sources,
47
+ root: compiled.root
48
+ };
49
+ }
50
+ };
51
+ }
52
+ //#endregion
53
+ //#region src/v4/source.ts
54
+ function resolveBase(value, fallback) {
55
+ return value === void 0 ? fallback : path.isAbsolute(value) ? path.resolve(value) : path.resolve(fallback, value);
56
+ }
57
+ function uniquePaths(values) {
58
+ const result = [];
59
+ for (const value of values) {
60
+ if (!value) continue;
61
+ const resolved = path.resolve(value);
62
+ if (!result.includes(resolved)) result.push(resolved);
63
+ }
64
+ return result;
65
+ }
66
+ function toCssImportPath(value) {
67
+ return value.replaceAll("\\", "/");
68
+ }
69
+ function quoteCssImport(value) {
70
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
71
+ }
72
+ function isPostcssPluginSpecifier(packageName) {
73
+ return packageName === "@tailwindcss/postcss" || /(?:^|[/\\])@tailwindcss[/\\]postcss(?:[/\\]|$)/.test(packageName) || /(?:^|[/\\])postcss(?:[/\\]|$)/i.test(packageName) || /postcss\.config\.[cm]?[jt]s$/i.test(packageName);
74
+ }
75
+ function createDefaultCss(packageName) {
76
+ return `@import "${quoteCssImport(toCssImportPath(packageName && !isPostcssPluginSpecifier(packageName) ? packageName : "tailwindcss"))}";`;
77
+ }
78
+ async function pathExists(filePath) {
79
+ try {
80
+ await promises.access(filePath);
81
+ return true;
82
+ } catch {
83
+ return false;
84
+ }
85
+ }
86
+ async function resolveCssEntries(entries, projectRoot, base) {
87
+ const resolvedEntries = entries.map((entry) => ({
88
+ original: entry,
89
+ absolute: path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(projectRoot, entry)
90
+ }));
91
+ const resolvedBase = base ?? path.dirname(resolvedEntries[0]?.absolute ?? projectRoot);
92
+ const dependencies = resolvedEntries.map((entry) => entry.absolute);
93
+ const cssParts = [];
94
+ for (const entry of resolvedEntries) {
95
+ if (await pathExists(entry.absolute)) {
96
+ cssParts.push(await promises.readFile(entry.absolute, "utf8"));
97
+ continue;
98
+ }
99
+ const importPath = path.isAbsolute(entry.original) ? entry.absolute : path.relative(resolvedBase, entry.absolute);
100
+ cssParts.push(`@import "${quoteCssImport(toCssImportPath(importPath))}";`);
101
+ }
102
+ return {
103
+ base: resolvedBase,
104
+ css: cssParts.join("\n"),
105
+ dependencies
106
+ };
107
+ }
108
+ function normalizeResolvedSource(source) {
109
+ const baseFallbacks = uniquePaths([
110
+ ...source.baseFallbacks,
111
+ source.projectRoot,
112
+ source.cwd
113
+ ]).filter((base) => base !== source.base);
114
+ return {
115
+ projectRoot: source.projectRoot,
116
+ base: source.base,
117
+ baseFallbacks,
118
+ css: source.css,
119
+ dependencies: Array.from(new Set(source.dependencies.map((dependency) => path.resolve(dependency))))
120
+ };
121
+ }
122
+ async function resolveTailwindV4Source(options = {}) {
123
+ const projectRoot = resolveBase(options.projectRoot, process.cwd());
124
+ const cwd = resolveBase(options.cwd, projectRoot);
125
+ const configuredBase = options.base === void 0 ? void 0 : resolveBase(options.base, projectRoot);
126
+ const baseFallbacks = uniquePaths(options.baseFallbacks?.map((base) => resolveBase(base, projectRoot)) ?? []);
127
+ if (options.css !== void 0) return normalizeResolvedSource({
128
+ projectRoot,
129
+ cwd,
130
+ base: configuredBase ?? cwd,
131
+ baseFallbacks,
132
+ css: options.css,
133
+ dependencies: []
134
+ });
135
+ if (options.cssEntries?.length) {
136
+ const entries = await resolveCssEntries(options.cssEntries, projectRoot, configuredBase);
137
+ return normalizeResolvedSource({
138
+ projectRoot,
139
+ cwd,
140
+ base: entries.base,
141
+ baseFallbacks,
142
+ css: entries.css,
143
+ dependencies: entries.dependencies
144
+ });
145
+ }
146
+ return normalizeResolvedSource({
147
+ projectRoot,
148
+ cwd,
149
+ base: configuredBase ?? cwd,
150
+ baseFallbacks,
151
+ css: createDefaultCss(options.packageName),
152
+ dependencies: []
153
+ });
154
+ }
155
+ function resolveConfigDir(config, projectRoot) {
156
+ if (!config) return;
157
+ const configPath = path.isAbsolute(config) ? config : path.resolve(projectRoot, config);
158
+ return path.dirname(configPath);
159
+ }
160
+ function createSourceOptionsFromNormalizedPatchOptions(options) {
161
+ const v4 = options.tailwind.v4;
162
+ const configDir = resolveConfigDir(options.tailwind.config, options.projectRoot);
163
+ const baseFallbacks = uniquePaths([
164
+ v4?.configuredBase,
165
+ options.tailwind.cwd,
166
+ options.projectRoot,
167
+ configDir
168
+ ]);
169
+ return {
170
+ projectRoot: options.projectRoot,
171
+ ...options.tailwind.cwd === void 0 ? {} : { cwd: options.tailwind.cwd },
172
+ ...v4?.configuredBase === void 0 ? {} : { base: v4.configuredBase },
173
+ baseFallbacks,
174
+ ...v4?.css === void 0 ? {} : { css: v4.css },
175
+ ...v4?.cssEntries === void 0 ? {} : { cssEntries: v4.cssEntries },
176
+ packageName: options.tailwind.packageName
177
+ };
178
+ }
179
+ function tailwindV4SourceOptionsFromPatchOptions(options) {
180
+ return createSourceOptionsFromNormalizedPatchOptions(normalizeOptions(options));
181
+ }
182
+ async function resolveTailwindV4SourceFromPatchOptions(options) {
183
+ return resolveTailwindV4Source(tailwindV4SourceOptionsFromPatchOptions(options));
184
+ }
185
+ //#endregion
186
+ //#region src/index.bundle.ts
187
+ const require = createRequire(import.meta.url);
188
+ function loadCliModule() {
189
+ return require("./commands/cli-runtime.js");
190
+ }
191
+ function mountTailwindcssPatchCommands(cli, options = {}) {
192
+ return loadCliModule().mountTailwindcssPatchCommands(cli, options);
193
+ }
194
+ function createTailwindcssPatchCli(options = {}) {
195
+ return loadCliModule().createTailwindcssPatchCli(options);
196
+ }
197
+ function defineConfig(config) {
198
+ return config;
199
+ }
200
+ //#endregion
201
+ export { resolveTailwindV4SourceFromPatchOptions as a, resolveTailwindV4Source as i, defineConfig as n, createTailwindV4Engine as o, mountTailwindcssPatchCommands as r, createTailwindcssPatchCli as t };
package/dist/index.d.mts CHANGED
@@ -77,9 +77,81 @@ 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
+ * 扫描文件系统 source entries 中的候选类名。
106
+ *
107
+ * - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
108
+ * - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
109
+ */
110
+ scanSources?: boolean | TailwindV4SourcePattern[];
111
+ }
112
+ interface TailwindV4SourcePattern {
113
+ base: string;
114
+ pattern: string;
115
+ negated: boolean;
116
+ }
117
+ interface TailwindV4GenerateResult {
118
+ css: string;
119
+ classSet: Set<string>;
120
+ rawCandidates: Set<string>;
121
+ dependencies: string[];
122
+ sources: TailwindV4SourcePattern[];
123
+ root: null | 'none' | {
124
+ base: string;
125
+ pattern: string;
126
+ };
127
+ }
128
+ interface TailwindV4DesignSystem {
129
+ parseCandidate: (candidate: string) => unknown[];
130
+ candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
131
+ }
132
+ interface TailwindV4Engine {
133
+ source: TailwindV4ResolvedSource;
134
+ loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
135
+ validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
136
+ generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
137
+ }
138
+ //#endregion
139
+ //#region src/v4/candidates.d.ts
140
+ declare function resolveValidTailwindV4Candidates(designSystem: TailwindV4DesignSystem, candidates: Iterable<string>): Set<string>;
141
+ //#endregion
142
+ //#region src/v4/engine.d.ts
143
+ declare function createTailwindV4Engine(source: TailwindV4ResolvedSource): TailwindV4Engine;
144
+ //#endregion
145
+ //#region src/v4/node-adapter.d.ts
146
+ declare function loadTailwindV4DesignSystem(source: TailwindV4ResolvedSource): Promise<TailwindV4DesignSystem>;
147
+ //#endregion
148
+ //#region src/v4/source.d.ts
149
+ declare function resolveTailwindV4Source(options?: TailwindV4SourceOptions): Promise<TailwindV4ResolvedSource>;
150
+ declare function resolveTailwindV4SourceFromPatchOptions(options: TailwindCssPatchOptions): Promise<TailwindV4ResolvedSource>;
151
+ //#endregion
80
152
  //#region src/index.bundle.d.ts
81
153
  declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPatchCliMountOptions): CAC;
82
154
  declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
83
155
  declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
84
156
  //#endregion
85
- 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, TailwindV4Options, 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, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
157
+ 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 };
package/dist/index.d.ts CHANGED
@@ -77,9 +77,81 @@ 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
+ * 扫描文件系统 source entries 中的候选类名。
106
+ *
107
+ * - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
108
+ * - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
109
+ */
110
+ scanSources?: boolean | TailwindV4SourcePattern[];
111
+ }
112
+ interface TailwindV4SourcePattern {
113
+ base: string;
114
+ pattern: string;
115
+ negated: boolean;
116
+ }
117
+ interface TailwindV4GenerateResult {
118
+ css: string;
119
+ classSet: Set<string>;
120
+ rawCandidates: Set<string>;
121
+ dependencies: string[];
122
+ sources: TailwindV4SourcePattern[];
123
+ root: null | 'none' | {
124
+ base: string;
125
+ pattern: string;
126
+ };
127
+ }
128
+ interface TailwindV4DesignSystem {
129
+ parseCandidate: (candidate: string) => unknown[];
130
+ candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
131
+ }
132
+ interface TailwindV4Engine {
133
+ source: TailwindV4ResolvedSource;
134
+ loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
135
+ validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
136
+ generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
137
+ }
138
+ //#endregion
139
+ //#region src/v4/candidates.d.ts
140
+ declare function resolveValidTailwindV4Candidates(designSystem: TailwindV4DesignSystem, candidates: Iterable<string>): Set<string>;
141
+ //#endregion
142
+ //#region src/v4/engine.d.ts
143
+ declare function createTailwindV4Engine(source: TailwindV4ResolvedSource): TailwindV4Engine;
144
+ //#endregion
145
+ //#region src/v4/node-adapter.d.ts
146
+ declare function loadTailwindV4DesignSystem(source: TailwindV4ResolvedSource): Promise<TailwindV4DesignSystem>;
147
+ //#endregion
148
+ //#region src/v4/source.d.ts
149
+ declare function resolveTailwindV4Source(options?: TailwindV4SourceOptions): Promise<TailwindV4ResolvedSource>;
150
+ declare function resolveTailwindV4SourceFromPatchOptions(options: TailwindCssPatchOptions): Promise<TailwindV4ResolvedSource>;
151
+ //#endregion
80
152
  //#region src/index.bundle.d.ts
81
153
  declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPatchCliMountOptions): CAC;
82
154
  declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
83
155
  declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
84
156
  //#endregion
85
- 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, TailwindV4Options, 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, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
157
+ 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 };