tailwindcss-patch 9.4.3 → 9.5.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-BztQHMRp.js → cli-CGyUnvFc.js} +3 -2
- package/dist/{cli-D0jXMGXf.mjs → cli-DRfALTSo.mjs} +1 -1
- 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 +2 -2
- package/dist/commands/cli-runtime.mjs +2 -2
- package/dist/{dist-DDcbvOwe.js → dist-DlC5vuI2.js} +1 -1
- package/dist/index.d.mts +7 -149
- package/dist/index.d.ts +8 -150
- package/dist/index.js +294 -521
- package/dist/index.mjs +6 -471
- package/dist/{validate-BuqRodYI.d.ts → validate-B5-08lrU.d.ts} +7 -251
- package/dist/{validate-oAkURzUC.d.mts → validate-CgrG4aAY.d.mts} +7 -251
- package/dist/{validate-Bug_WYcU.mjs → validate-Q00Ccqht.mjs} +8 -1405
- package/dist/{validate-DbuKewV-.js → validate-XiYmTZcd.js} +82 -1708
- package/package.json +8 -10
- package/src/api/tailwindcss-patcher.ts +8 -5
- package/src/extraction/candidate-extractor.ts +17 -701
- package/src/extraction/split-candidate-tokens.ts +5 -101
- package/src/options/types.ts +1 -2
- package/src/style-candidates.ts +5 -35
- package/src/style-generator.ts +11 -80
- package/src/types.ts +21 -95
- package/src/v3/index.ts +2 -2
- package/src/v4/index.ts +104 -28
- package/src/v3/style-generator.ts +0 -384
- package/src/v4/bare-arbitrary-values.ts +0 -545
- package/src/v4/candidates.ts +0 -316
- package/src/v4/engine.ts +0 -112
- package/src/v4/node-adapter.ts +0 -207
- package/src/v4/source-scan.ts +0 -432
- package/src/v4/source.ts +0 -235
- package/src/v4/style-generator.ts +0 -44
- package/src/v4/types.ts +0 -103
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CAC, Command } from "cac";
|
|
2
2
|
import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Config } from "tailwindcss";
|
|
3
|
+
import { TailwindV4CssSource, TailwindV4SourcePattern } from "@tailwindcss-mangle/engine/v4";
|
|
4
|
+
import { ExtractResult, ExtractSourceCandidate, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindcssClassCache, TailwindcssRuntimeContext, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, groupTokensByFile, resolveProjectSourceFiles } from "@tailwindcss-mangle/engine";
|
|
6
5
|
//#region src/cache/types.d.ts
|
|
7
6
|
declare const CACHE_SCHEMA_VERSION = 2;
|
|
8
7
|
declare const CACHE_FINGERPRINT_VERSION = 1;
|
|
@@ -59,75 +58,6 @@ interface CacheClearResult {
|
|
|
59
58
|
}
|
|
60
59
|
//#endregion
|
|
61
60
|
//#region src/types.d.ts
|
|
62
|
-
type TailwindcssClassCacheEntry = Rule | {
|
|
63
|
-
layer: string;
|
|
64
|
-
options: Record<string, any>;
|
|
65
|
-
sort: Record<string, any>;
|
|
66
|
-
};
|
|
67
|
-
type TailwindcssClassCache = Map<string, TailwindcssClassCacheEntry[]>;
|
|
68
|
-
interface TailwindcssRuntimeContext {
|
|
69
|
-
applyClassCache: Map<any, any>;
|
|
70
|
-
candidateRuleCache: Map<string, Set<[{
|
|
71
|
-
arbitrary: any;
|
|
72
|
-
index: any;
|
|
73
|
-
layer: string;
|
|
74
|
-
options: any[];
|
|
75
|
-
parallelIndex: any;
|
|
76
|
-
parentLayer: string;
|
|
77
|
-
variants: any;
|
|
78
|
-
}, Node]>>;
|
|
79
|
-
candidateRuleMap: Map<string | string, [object, Node][]>;
|
|
80
|
-
changedContent: any[];
|
|
81
|
-
classCache: TailwindcssClassCache;
|
|
82
|
-
disposables: any[];
|
|
83
|
-
getClassList: (...args: any[]) => any;
|
|
84
|
-
getClassOrder: (...args: any[]) => any;
|
|
85
|
-
getVariants: (...args: any[]) => any;
|
|
86
|
-
markInvalidUtilityCandidate: (...args: any[]) => any;
|
|
87
|
-
markInvalidUtilityNode: (...args: any[]) => any;
|
|
88
|
-
notClassCache: Set<string>;
|
|
89
|
-
offsets: {
|
|
90
|
-
layerPositions: object;
|
|
91
|
-
offsets: object;
|
|
92
|
-
reservedVariantBits: any;
|
|
93
|
-
variantOffsets: Map<string, any>;
|
|
94
|
-
};
|
|
95
|
-
postCssNodeCache: Map<object, [Node]>;
|
|
96
|
-
ruleCache: Set<[object, Node]>;
|
|
97
|
-
stylesheetCache: Record<string, Set<any>>;
|
|
98
|
-
tailwindConfig: Config;
|
|
99
|
-
userConfigPath: string | null;
|
|
100
|
-
variantMap: Map<string, [[object, (...args: any[]) => unknown]]>;
|
|
101
|
-
variantOptions: Map<string, object>;
|
|
102
|
-
}
|
|
103
|
-
interface ExtractResult {
|
|
104
|
-
classList: string[];
|
|
105
|
-
classSet: Set<string>;
|
|
106
|
-
filename?: string;
|
|
107
|
-
}
|
|
108
|
-
interface TailwindTokenLocation {
|
|
109
|
-
rawCandidate: string;
|
|
110
|
-
file: string;
|
|
111
|
-
relativeFile: string;
|
|
112
|
-
extension: string;
|
|
113
|
-
start: number;
|
|
114
|
-
end: number;
|
|
115
|
-
length: number;
|
|
116
|
-
line: number;
|
|
117
|
-
column: number;
|
|
118
|
-
lineText: string;
|
|
119
|
-
}
|
|
120
|
-
type TailwindTokenFileKey = 'relative' | 'absolute';
|
|
121
|
-
interface TailwindTokenReport {
|
|
122
|
-
entries: TailwindTokenLocation[];
|
|
123
|
-
filesScanned: number;
|
|
124
|
-
sources: SourceEntry[];
|
|
125
|
-
skippedFiles: {
|
|
126
|
-
file: string;
|
|
127
|
-
reason: string;
|
|
128
|
-
}[];
|
|
129
|
-
}
|
|
130
|
-
type TailwindTokenByFileMap = Record<string, TailwindTokenLocation[]>;
|
|
131
61
|
interface TailwindPatchRuntime {
|
|
132
62
|
options: NormalizedTailwindCssPatchOptions;
|
|
133
63
|
majorVersion: 2 | 3 | 4;
|
|
@@ -157,135 +87,6 @@ interface PatchStatusReport {
|
|
|
157
87
|
entries: PatchStatusEntry[];
|
|
158
88
|
}
|
|
159
89
|
//#endregion
|
|
160
|
-
//#region src/v4/bare-arbitrary-values.d.ts
|
|
161
|
-
interface BareArbitraryValueOptions {
|
|
162
|
-
/**
|
|
163
|
-
* 允许作为无方括号任意值的单位列表。
|
|
164
|
-
*/
|
|
165
|
-
units?: string[];
|
|
166
|
-
}
|
|
167
|
-
interface BareArbitraryValueResolveResult {
|
|
168
|
-
candidate: string;
|
|
169
|
-
canonicalCandidate: string;
|
|
170
|
-
}
|
|
171
|
-
interface BareArbitraryValueSourceCandidate {
|
|
172
|
-
rawCandidate: string;
|
|
173
|
-
start: number;
|
|
174
|
-
end: number;
|
|
175
|
-
}
|
|
176
|
-
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
177
|
-
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
178
|
-
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
179
|
-
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
180
|
-
declare function escapeCssClassName(value: string): string;
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/style-candidates.d.ts
|
|
183
|
-
interface TailwindStyleSource {
|
|
184
|
-
content: string;
|
|
185
|
-
extension?: string;
|
|
186
|
-
file?: string;
|
|
187
|
-
}
|
|
188
|
-
interface TailwindStyleCandidateOptions {
|
|
189
|
-
candidates?: Iterable<string>;
|
|
190
|
-
sources?: TailwindStyleSource[];
|
|
191
|
-
/**
|
|
192
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
193
|
-
*/
|
|
194
|
-
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
195
|
-
}
|
|
196
|
-
declare function collectTailwindStyleCandidates(options?: TailwindStyleCandidateOptions): Promise<Set<string>>;
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/v4/types.d.ts
|
|
199
|
-
interface TailwindV4SourceOptions {
|
|
200
|
-
projectRoot?: string;
|
|
201
|
-
cwd?: string;
|
|
202
|
-
base?: string;
|
|
203
|
-
baseFallbacks?: string[];
|
|
204
|
-
css?: string;
|
|
205
|
-
cssSources?: TailwindV4CssSource[];
|
|
206
|
-
cssEntries?: string[];
|
|
207
|
-
packageName?: string;
|
|
208
|
-
}
|
|
209
|
-
interface TailwindV4CssSource {
|
|
210
|
-
css: string;
|
|
211
|
-
base?: string;
|
|
212
|
-
file?: string;
|
|
213
|
-
dependencies?: string[];
|
|
214
|
-
}
|
|
215
|
-
interface TailwindV4ResolvedSource {
|
|
216
|
-
projectRoot: string;
|
|
217
|
-
base: string;
|
|
218
|
-
baseFallbacks: string[];
|
|
219
|
-
css: string;
|
|
220
|
-
dependencies: string[];
|
|
221
|
-
}
|
|
222
|
-
interface TailwindV4CandidateSource {
|
|
223
|
-
content: string;
|
|
224
|
-
extension?: string;
|
|
225
|
-
}
|
|
226
|
-
interface TailwindV4StyleSource extends TailwindStyleSource {}
|
|
227
|
-
interface TailwindV4GenerateOptions {
|
|
228
|
-
candidates?: Iterable<string>;
|
|
229
|
-
sources?: TailwindV4CandidateSource[];
|
|
230
|
-
/**
|
|
231
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
232
|
-
*/
|
|
233
|
-
bareArbitraryValues?: boolean | {
|
|
234
|
-
units?: string[];
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* 扫描文件系统 source entries 中的候选类名。
|
|
238
|
-
*
|
|
239
|
-
* - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
|
|
240
|
-
* - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
|
|
241
|
-
*/
|
|
242
|
-
scanSources?: boolean | TailwindV4SourcePattern[];
|
|
243
|
-
}
|
|
244
|
-
type TailwindV4CompiledSourceRoot = null | 'none' | {
|
|
245
|
-
base: string;
|
|
246
|
-
pattern: string;
|
|
247
|
-
};
|
|
248
|
-
interface TailwindV4SourcePattern {
|
|
249
|
-
base: string;
|
|
250
|
-
pattern: string;
|
|
251
|
-
negated: boolean;
|
|
252
|
-
}
|
|
253
|
-
interface TailwindV4GenerateResult {
|
|
254
|
-
css: string;
|
|
255
|
-
classSet: Set<string>;
|
|
256
|
-
rawCandidates: Set<string>;
|
|
257
|
-
dependencies: string[];
|
|
258
|
-
sources: TailwindV4SourcePattern[];
|
|
259
|
-
root: TailwindV4CompiledSourceRoot;
|
|
260
|
-
}
|
|
261
|
-
interface TailwindV4StyleGenerateOptions extends TailwindV4SourceOptions {
|
|
262
|
-
source?: TailwindV4ResolvedSource;
|
|
263
|
-
candidates?: Iterable<string>;
|
|
264
|
-
sources?: TailwindV4StyleSource[];
|
|
265
|
-
/**
|
|
266
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
267
|
-
*/
|
|
268
|
-
bareArbitraryValues?: TailwindV4GenerateOptions['bareArbitraryValues'];
|
|
269
|
-
/**
|
|
270
|
-
* Scans the compiled Tailwind CSS v4 source entries in addition to in-memory sources.
|
|
271
|
-
*/
|
|
272
|
-
scanSources?: TailwindV4GenerateOptions['scanSources'];
|
|
273
|
-
}
|
|
274
|
-
interface TailwindV4StyleGenerateResult extends TailwindV4GenerateResult {
|
|
275
|
-
tokens: Set<string>;
|
|
276
|
-
source: TailwindV4ResolvedSource;
|
|
277
|
-
}
|
|
278
|
-
interface TailwindV4DesignSystem {
|
|
279
|
-
parseCandidate: (candidate: string) => unknown[];
|
|
280
|
-
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
281
|
-
}
|
|
282
|
-
interface TailwindV4Engine {
|
|
283
|
-
source: TailwindV4ResolvedSource;
|
|
284
|
-
loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
|
|
285
|
-
validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
|
|
286
|
-
generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
|
|
287
|
-
}
|
|
288
|
-
//#endregion
|
|
289
90
|
//#region src/options/types.d.ts
|
|
290
91
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
291
92
|
type CacheDriver = 'file' | 'memory' | 'noop';
|
|
@@ -378,7 +179,7 @@ interface TailwindV4Options {
|
|
|
378
179
|
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
379
180
|
cssEntries?: string[];
|
|
380
181
|
/** Overrides the content sources scanned by the oxide scanner. */
|
|
381
|
-
sources?:
|
|
182
|
+
sources?: TailwindV4SourcePattern[];
|
|
382
183
|
/** Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`. */
|
|
383
184
|
bareArbitraryValues?: boolean | {
|
|
384
185
|
/** Unit allow-list used when detecting bare arbitrary values. */units?: string[];
|
|
@@ -459,7 +260,7 @@ interface NormalizedTailwindV4Options {
|
|
|
459
260
|
css?: string;
|
|
460
261
|
cssSources: TailwindV4CssSource[];
|
|
461
262
|
cssEntries: string[];
|
|
462
|
-
sources:
|
|
263
|
+
sources: TailwindV4SourcePattern[];
|
|
463
264
|
hasUserDefinedSources: boolean;
|
|
464
265
|
bareArbitraryValues: false | {
|
|
465
266
|
units?: string[];
|
|
@@ -551,51 +352,6 @@ type TailwindcssConfigResult = Awaited<ReturnType<TailwindcssConfigModule['getCo
|
|
|
551
352
|
//#region src/runtime/collector.d.ts
|
|
552
353
|
type TailwindMajorVersion = 2 | 3 | 4;
|
|
553
354
|
//#endregion
|
|
554
|
-
//#region src/extraction/candidate-extractor.d.ts
|
|
555
|
-
interface ExtractValidCandidatesOption {
|
|
556
|
-
sources?: SourceEntry[];
|
|
557
|
-
base?: string;
|
|
558
|
-
baseFallbacks?: string[];
|
|
559
|
-
css?: string;
|
|
560
|
-
cwd?: string;
|
|
561
|
-
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
562
|
-
}
|
|
563
|
-
interface ExtractCandidateOptions {
|
|
564
|
-
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
565
|
-
}
|
|
566
|
-
interface ExtractSourceCandidate {
|
|
567
|
-
rawCandidate: string;
|
|
568
|
-
start: number;
|
|
569
|
-
end: number;
|
|
570
|
-
}
|
|
571
|
-
declare function extractRawCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
572
|
-
declare function extractSourceCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
573
|
-
declare function extractSourceCandidates(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<string[]>;
|
|
574
|
-
declare function extractRawCandidates(sources?: SourceEntry[], options?: ExtractCandidateOptions): Promise<string[]>;
|
|
575
|
-
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
576
|
-
interface ExtractProjectCandidatesOptions {
|
|
577
|
-
cwd?: string;
|
|
578
|
-
sources?: SourceEntry[];
|
|
579
|
-
base?: string;
|
|
580
|
-
baseFallbacks?: string[];
|
|
581
|
-
css?: string;
|
|
582
|
-
}
|
|
583
|
-
interface ResolveProjectSourceFilesOptions {
|
|
584
|
-
cwd?: string;
|
|
585
|
-
sources?: SourceEntry[];
|
|
586
|
-
ignoredSources?: SourceEntry[];
|
|
587
|
-
base?: string;
|
|
588
|
-
baseFallbacks?: string[];
|
|
589
|
-
css?: string;
|
|
590
|
-
filter?: (file: string) => boolean;
|
|
591
|
-
}
|
|
592
|
-
declare function resolveProjectSourceFiles(options?: ResolveProjectSourceFilesOptions): Promise<string[]>;
|
|
593
|
-
declare function extractProjectCandidatesWithPositions(options?: ExtractProjectCandidatesOptions): Promise<TailwindTokenReport>;
|
|
594
|
-
declare function groupTokensByFile(report: TailwindTokenReport, options?: {
|
|
595
|
-
key?: TailwindTokenFileKey;
|
|
596
|
-
stripAbsolutePaths?: boolean;
|
|
597
|
-
}): TailwindTokenByFileMap;
|
|
598
|
-
//#endregion
|
|
599
355
|
//#region src/api/tailwindcss-patcher.d.ts
|
|
600
356
|
declare class TailwindcssPatcher {
|
|
601
357
|
readonly options: NormalizedTailwindCssPatchOptions;
|
|
@@ -625,11 +381,11 @@ declare class TailwindcssPatcher {
|
|
|
625
381
|
extractValidCandidates: typeof extractValidCandidates;
|
|
626
382
|
collectContentTokens(options?: {
|
|
627
383
|
cwd?: string;
|
|
628
|
-
sources?:
|
|
384
|
+
sources?: TailwindV4SourcePattern[];
|
|
629
385
|
}): Promise<TailwindTokenReport>;
|
|
630
386
|
collectContentTokensByFile(options?: {
|
|
631
387
|
cwd?: string;
|
|
632
|
-
sources?:
|
|
388
|
+
sources?: TailwindV4SourcePattern[];
|
|
633
389
|
key?: TailwindTokenFileKey;
|
|
634
390
|
stripAbsolutePaths?: boolean;
|
|
635
391
|
}): Promise<TailwindTokenByFileMap>;
|
|
@@ -840,4 +596,4 @@ declare class ValidateCommandError extends Error {
|
|
|
840
596
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
841
597
|
}
|
|
842
598
|
//#endregion
|
|
843
|
-
export {
|
|
599
|
+
export { PatchStatusEntry as $, extractSourceCandidates as A, ExtendLengthUnitsOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, extractProjectCandidatesWithPositions as D, ExtractSourceCandidate as E, normalizeOptions as F, TailwindCssPatchOptions as G, NormalizedCacheOptions as H, ApplyOptions as I, TailwindV4Options as J, TailwindV2Options as K, CacheOptions as L, extractValidCandidates as M, groupTokensByFile as N, extractRawCandidates as O, resolveProjectSourceFiles as P, PatchName as Q, CacheStrategy as R, MIGRATION_REPORT_KIND as S, TailwindcssPatcher as T, NormalizedTailwindCssPatchOptions as U, ExtractOptions as V, TailwindCssOptions as W, ILengthUnitsPatchOptions as X, ExtractResult as Y, PatchCheckStatus as Z, ConfigFileMigrationEntry as _, ValidateFailureSummary as a, TailwindTokenReport as at, RestoreConfigFilesOptions as b, TailwindcssPatchCliMountOptions as c, CacheClearOptions as ct, TailwindcssPatchCommandContext as d, CacheContextDescriptor as dt, PatchStatusReport as et, TailwindcssPatchCommandHandler as f, CacheContextMetadata as ft, tailwindcssPatchCommands as g, TailwindcssPatchCommandOptions as h, CacheReadResult as ht, ValidateFailureReason as i, TailwindTokenLocation as it, extractSourceCandidatesWithPositions as j, extractRawCandidatesWithPositions as k, TailwindcssPatchCliOptions as l, CacheClearResult as lt, TailwindcssPatchCommandOptionDefinition as m, CacheReadMeta as mt, VALIDATE_FAILURE_REASONS as n, TailwindTokenByFileMap as nt, ValidateJsonFailurePayload as o, TailwindcssClassCache as ot, TailwindcssPatchCommandHandlerMap as p, CacheIndexFileV2 as pt, TailwindV3Options as q, ValidateCommandError as r, TailwindTokenFileKey as rt, ValidateJsonSuccessPayload as s, TailwindcssRuntimeContext as st, VALIDATE_EXIT_CODES as t, TailwindPatchRuntime as tt, TailwindcssPatchCommand as u, CacheClearScope as ut, ConfigFileMigrationReport as v, logger as w, RestoreConfigFilesResult as x, MigrateConfigFilesOptions as y, ExposeContextOptions as z };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { PackageInfo, PackageResolvingOptions } from "local-pkg";
|
|
2
|
-
import {
|
|
2
|
+
import { ExtractResult, ExtractSourceCandidate, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindcssClassCache, TailwindcssRuntimeContext, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, groupTokensByFile, resolveProjectSourceFiles } from "@tailwindcss-mangle/engine";
|
|
3
|
+
import { TailwindV4CssSource, TailwindV4SourcePattern } from "@tailwindcss-mangle/engine/v4";
|
|
3
4
|
import { CAC, Command } from "cac";
|
|
4
|
-
import { SourceEntry } from "@tailwindcss/oxide";
|
|
5
|
-
import { Config } from "tailwindcss";
|
|
6
5
|
//#region src/cache/types.d.ts
|
|
7
6
|
declare const CACHE_SCHEMA_VERSION = 2;
|
|
8
7
|
declare const CACHE_FINGERPRINT_VERSION = 1;
|
|
@@ -59,75 +58,6 @@ interface CacheClearResult {
|
|
|
59
58
|
}
|
|
60
59
|
//#endregion
|
|
61
60
|
//#region src/types.d.ts
|
|
62
|
-
type TailwindcssClassCacheEntry = Rule | {
|
|
63
|
-
layer: string;
|
|
64
|
-
options: Record<string, any>;
|
|
65
|
-
sort: Record<string, any>;
|
|
66
|
-
};
|
|
67
|
-
type TailwindcssClassCache = Map<string, TailwindcssClassCacheEntry[]>;
|
|
68
|
-
interface TailwindcssRuntimeContext {
|
|
69
|
-
applyClassCache: Map<any, any>;
|
|
70
|
-
candidateRuleCache: Map<string, Set<[{
|
|
71
|
-
arbitrary: any;
|
|
72
|
-
index: any;
|
|
73
|
-
layer: string;
|
|
74
|
-
options: any[];
|
|
75
|
-
parallelIndex: any;
|
|
76
|
-
parentLayer: string;
|
|
77
|
-
variants: any;
|
|
78
|
-
}, Node]>>;
|
|
79
|
-
candidateRuleMap: Map<string | string, [object, Node][]>;
|
|
80
|
-
changedContent: any[];
|
|
81
|
-
classCache: TailwindcssClassCache;
|
|
82
|
-
disposables: any[];
|
|
83
|
-
getClassList: (...args: any[]) => any;
|
|
84
|
-
getClassOrder: (...args: any[]) => any;
|
|
85
|
-
getVariants: (...args: any[]) => any;
|
|
86
|
-
markInvalidUtilityCandidate: (...args: any[]) => any;
|
|
87
|
-
markInvalidUtilityNode: (...args: any[]) => any;
|
|
88
|
-
notClassCache: Set<string>;
|
|
89
|
-
offsets: {
|
|
90
|
-
layerPositions: object;
|
|
91
|
-
offsets: object;
|
|
92
|
-
reservedVariantBits: any;
|
|
93
|
-
variantOffsets: Map<string, any>;
|
|
94
|
-
};
|
|
95
|
-
postCssNodeCache: Map<object, [Node]>;
|
|
96
|
-
ruleCache: Set<[object, Node]>;
|
|
97
|
-
stylesheetCache: Record<string, Set<any>>;
|
|
98
|
-
tailwindConfig: Config;
|
|
99
|
-
userConfigPath: string | null;
|
|
100
|
-
variantMap: Map<string, [[object, (...args: any[]) => unknown]]>;
|
|
101
|
-
variantOptions: Map<string, object>;
|
|
102
|
-
}
|
|
103
|
-
interface ExtractResult {
|
|
104
|
-
classList: string[];
|
|
105
|
-
classSet: Set<string>;
|
|
106
|
-
filename?: string;
|
|
107
|
-
}
|
|
108
|
-
interface TailwindTokenLocation {
|
|
109
|
-
rawCandidate: string;
|
|
110
|
-
file: string;
|
|
111
|
-
relativeFile: string;
|
|
112
|
-
extension: string;
|
|
113
|
-
start: number;
|
|
114
|
-
end: number;
|
|
115
|
-
length: number;
|
|
116
|
-
line: number;
|
|
117
|
-
column: number;
|
|
118
|
-
lineText: string;
|
|
119
|
-
}
|
|
120
|
-
type TailwindTokenFileKey = 'relative' | 'absolute';
|
|
121
|
-
interface TailwindTokenReport {
|
|
122
|
-
entries: TailwindTokenLocation[];
|
|
123
|
-
filesScanned: number;
|
|
124
|
-
sources: SourceEntry[];
|
|
125
|
-
skippedFiles: {
|
|
126
|
-
file: string;
|
|
127
|
-
reason: string;
|
|
128
|
-
}[];
|
|
129
|
-
}
|
|
130
|
-
type TailwindTokenByFileMap = Record<string, TailwindTokenLocation[]>;
|
|
131
61
|
interface TailwindPatchRuntime {
|
|
132
62
|
options: NormalizedTailwindCssPatchOptions;
|
|
133
63
|
majorVersion: 2 | 3 | 4;
|
|
@@ -157,135 +87,6 @@ interface PatchStatusReport {
|
|
|
157
87
|
entries: PatchStatusEntry[];
|
|
158
88
|
}
|
|
159
89
|
//#endregion
|
|
160
|
-
//#region src/v4/bare-arbitrary-values.d.ts
|
|
161
|
-
interface BareArbitraryValueOptions {
|
|
162
|
-
/**
|
|
163
|
-
* 允许作为无方括号任意值的单位列表。
|
|
164
|
-
*/
|
|
165
|
-
units?: string[];
|
|
166
|
-
}
|
|
167
|
-
interface BareArbitraryValueResolveResult {
|
|
168
|
-
candidate: string;
|
|
169
|
-
canonicalCandidate: string;
|
|
170
|
-
}
|
|
171
|
-
interface BareArbitraryValueSourceCandidate {
|
|
172
|
-
rawCandidate: string;
|
|
173
|
-
start: number;
|
|
174
|
-
end: number;
|
|
175
|
-
}
|
|
176
|
-
declare function isBareArbitraryValuesEnabled(options: boolean | BareArbitraryValueOptions | undefined): boolean;
|
|
177
|
-
declare function resolveBareArbitraryValueCandidate(candidate: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueResolveResult | undefined;
|
|
178
|
-
declare function extractBareArbitraryValueSourceCandidatesWithPositions(content: string, options?: boolean | BareArbitraryValueOptions): BareArbitraryValueSourceCandidate[];
|
|
179
|
-
declare function extractBareArbitraryValueSourceCandidates(content: string, options?: boolean | BareArbitraryValueOptions): string[];
|
|
180
|
-
declare function escapeCssClassName(value: string): string;
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/style-candidates.d.ts
|
|
183
|
-
interface TailwindStyleSource {
|
|
184
|
-
content: string;
|
|
185
|
-
extension?: string;
|
|
186
|
-
file?: string;
|
|
187
|
-
}
|
|
188
|
-
interface TailwindStyleCandidateOptions {
|
|
189
|
-
candidates?: Iterable<string>;
|
|
190
|
-
sources?: TailwindStyleSource[];
|
|
191
|
-
/**
|
|
192
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
193
|
-
*/
|
|
194
|
-
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
195
|
-
}
|
|
196
|
-
declare function collectTailwindStyleCandidates(options?: TailwindStyleCandidateOptions): Promise<Set<string>>;
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/v4/types.d.ts
|
|
199
|
-
interface TailwindV4SourceOptions {
|
|
200
|
-
projectRoot?: string;
|
|
201
|
-
cwd?: string;
|
|
202
|
-
base?: string;
|
|
203
|
-
baseFallbacks?: string[];
|
|
204
|
-
css?: string;
|
|
205
|
-
cssSources?: TailwindV4CssSource[];
|
|
206
|
-
cssEntries?: string[];
|
|
207
|
-
packageName?: string;
|
|
208
|
-
}
|
|
209
|
-
interface TailwindV4CssSource {
|
|
210
|
-
css: string;
|
|
211
|
-
base?: string;
|
|
212
|
-
file?: string;
|
|
213
|
-
dependencies?: string[];
|
|
214
|
-
}
|
|
215
|
-
interface TailwindV4ResolvedSource {
|
|
216
|
-
projectRoot: string;
|
|
217
|
-
base: string;
|
|
218
|
-
baseFallbacks: string[];
|
|
219
|
-
css: string;
|
|
220
|
-
dependencies: string[];
|
|
221
|
-
}
|
|
222
|
-
interface TailwindV4CandidateSource {
|
|
223
|
-
content: string;
|
|
224
|
-
extension?: string;
|
|
225
|
-
}
|
|
226
|
-
interface TailwindV4StyleSource extends TailwindStyleSource {}
|
|
227
|
-
interface TailwindV4GenerateOptions {
|
|
228
|
-
candidates?: Iterable<string>;
|
|
229
|
-
sources?: TailwindV4CandidateSource[];
|
|
230
|
-
/**
|
|
231
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
232
|
-
*/
|
|
233
|
-
bareArbitraryValues?: boolean | {
|
|
234
|
-
units?: string[];
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* 扫描文件系统 source entries 中的候选类名。
|
|
238
|
-
*
|
|
239
|
-
* - `true`:使用 Tailwind v4 编译入口解析出的 `@source` 列表。
|
|
240
|
-
* - `TailwindV4SourcePattern[]`:使用调用方显式传入的 source 列表。
|
|
241
|
-
*/
|
|
242
|
-
scanSources?: boolean | TailwindV4SourcePattern[];
|
|
243
|
-
}
|
|
244
|
-
type TailwindV4CompiledSourceRoot = null | 'none' | {
|
|
245
|
-
base: string;
|
|
246
|
-
pattern: string;
|
|
247
|
-
};
|
|
248
|
-
interface TailwindV4SourcePattern {
|
|
249
|
-
base: string;
|
|
250
|
-
pattern: string;
|
|
251
|
-
negated: boolean;
|
|
252
|
-
}
|
|
253
|
-
interface TailwindV4GenerateResult {
|
|
254
|
-
css: string;
|
|
255
|
-
classSet: Set<string>;
|
|
256
|
-
rawCandidates: Set<string>;
|
|
257
|
-
dependencies: string[];
|
|
258
|
-
sources: TailwindV4SourcePattern[];
|
|
259
|
-
root: TailwindV4CompiledSourceRoot;
|
|
260
|
-
}
|
|
261
|
-
interface TailwindV4StyleGenerateOptions extends TailwindV4SourceOptions {
|
|
262
|
-
source?: TailwindV4ResolvedSource;
|
|
263
|
-
candidates?: Iterable<string>;
|
|
264
|
-
sources?: TailwindV4StyleSource[];
|
|
265
|
-
/**
|
|
266
|
-
* Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`.
|
|
267
|
-
*/
|
|
268
|
-
bareArbitraryValues?: TailwindV4GenerateOptions['bareArbitraryValues'];
|
|
269
|
-
/**
|
|
270
|
-
* Scans the compiled Tailwind CSS v4 source entries in addition to in-memory sources.
|
|
271
|
-
*/
|
|
272
|
-
scanSources?: TailwindV4GenerateOptions['scanSources'];
|
|
273
|
-
}
|
|
274
|
-
interface TailwindV4StyleGenerateResult extends TailwindV4GenerateResult {
|
|
275
|
-
tokens: Set<string>;
|
|
276
|
-
source: TailwindV4ResolvedSource;
|
|
277
|
-
}
|
|
278
|
-
interface TailwindV4DesignSystem {
|
|
279
|
-
parseCandidate: (candidate: string) => unknown[];
|
|
280
|
-
candidatesToCss: (candidates: string[]) => Array<string | null | undefined>;
|
|
281
|
-
}
|
|
282
|
-
interface TailwindV4Engine {
|
|
283
|
-
source: TailwindV4ResolvedSource;
|
|
284
|
-
loadDesignSystem: () => Promise<TailwindV4DesignSystem>;
|
|
285
|
-
validateCandidates: (candidates: Iterable<string>) => Promise<Set<string>>;
|
|
286
|
-
generate: (options?: TailwindV4GenerateOptions) => Promise<TailwindV4GenerateResult>;
|
|
287
|
-
}
|
|
288
|
-
//#endregion
|
|
289
90
|
//#region src/options/types.d.ts
|
|
290
91
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
291
92
|
type CacheDriver = 'file' | 'memory' | 'noop';
|
|
@@ -378,7 +179,7 @@ interface TailwindV4Options {
|
|
|
378
179
|
/** Set of CSS entry files that should be scanned for `@config` directives. */
|
|
379
180
|
cssEntries?: string[];
|
|
380
181
|
/** Overrides the content sources scanned by the oxide scanner. */
|
|
381
|
-
sources?:
|
|
182
|
+
sources?: TailwindV4SourcePattern[];
|
|
382
183
|
/** Enables UnoCSS-style bare arbitrary values such as `p-10%` and `p-2.5px`. */
|
|
383
184
|
bareArbitraryValues?: boolean | {
|
|
384
185
|
/** Unit allow-list used when detecting bare arbitrary values. */units?: string[];
|
|
@@ -459,7 +260,7 @@ interface NormalizedTailwindV4Options {
|
|
|
459
260
|
css?: string;
|
|
460
261
|
cssSources: TailwindV4CssSource[];
|
|
461
262
|
cssEntries: string[];
|
|
462
|
-
sources:
|
|
263
|
+
sources: TailwindV4SourcePattern[];
|
|
463
264
|
hasUserDefinedSources: boolean;
|
|
464
265
|
bareArbitraryValues: false | {
|
|
465
266
|
units?: string[];
|
|
@@ -551,51 +352,6 @@ type TailwindcssConfigResult = Awaited<ReturnType<TailwindcssConfigModule['getCo
|
|
|
551
352
|
//#region src/runtime/collector.d.ts
|
|
552
353
|
type TailwindMajorVersion = 2 | 3 | 4;
|
|
553
354
|
//#endregion
|
|
554
|
-
//#region src/extraction/candidate-extractor.d.ts
|
|
555
|
-
interface ExtractValidCandidatesOption {
|
|
556
|
-
sources?: SourceEntry[];
|
|
557
|
-
base?: string;
|
|
558
|
-
baseFallbacks?: string[];
|
|
559
|
-
css?: string;
|
|
560
|
-
cwd?: string;
|
|
561
|
-
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
562
|
-
}
|
|
563
|
-
interface ExtractCandidateOptions {
|
|
564
|
-
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
565
|
-
}
|
|
566
|
-
interface ExtractSourceCandidate {
|
|
567
|
-
rawCandidate: string;
|
|
568
|
-
start: number;
|
|
569
|
-
end: number;
|
|
570
|
-
}
|
|
571
|
-
declare function extractRawCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
572
|
-
declare function extractSourceCandidatesWithPositions(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<ExtractSourceCandidate[]>;
|
|
573
|
-
declare function extractSourceCandidates(content: string, extension?: string, options?: ExtractCandidateOptions): Promise<string[]>;
|
|
574
|
-
declare function extractRawCandidates(sources?: SourceEntry[], options?: ExtractCandidateOptions): Promise<string[]>;
|
|
575
|
-
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
576
|
-
interface ExtractProjectCandidatesOptions {
|
|
577
|
-
cwd?: string;
|
|
578
|
-
sources?: SourceEntry[];
|
|
579
|
-
base?: string;
|
|
580
|
-
baseFallbacks?: string[];
|
|
581
|
-
css?: string;
|
|
582
|
-
}
|
|
583
|
-
interface ResolveProjectSourceFilesOptions {
|
|
584
|
-
cwd?: string;
|
|
585
|
-
sources?: SourceEntry[];
|
|
586
|
-
ignoredSources?: SourceEntry[];
|
|
587
|
-
base?: string;
|
|
588
|
-
baseFallbacks?: string[];
|
|
589
|
-
css?: string;
|
|
590
|
-
filter?: (file: string) => boolean;
|
|
591
|
-
}
|
|
592
|
-
declare function resolveProjectSourceFiles(options?: ResolveProjectSourceFilesOptions): Promise<string[]>;
|
|
593
|
-
declare function extractProjectCandidatesWithPositions(options?: ExtractProjectCandidatesOptions): Promise<TailwindTokenReport>;
|
|
594
|
-
declare function groupTokensByFile(report: TailwindTokenReport, options?: {
|
|
595
|
-
key?: TailwindTokenFileKey;
|
|
596
|
-
stripAbsolutePaths?: boolean;
|
|
597
|
-
}): TailwindTokenByFileMap;
|
|
598
|
-
//#endregion
|
|
599
355
|
//#region src/api/tailwindcss-patcher.d.ts
|
|
600
356
|
declare class TailwindcssPatcher {
|
|
601
357
|
readonly options: NormalizedTailwindCssPatchOptions;
|
|
@@ -625,11 +381,11 @@ declare class TailwindcssPatcher {
|
|
|
625
381
|
extractValidCandidates: typeof extractValidCandidates;
|
|
626
382
|
collectContentTokens(options?: {
|
|
627
383
|
cwd?: string;
|
|
628
|
-
sources?:
|
|
384
|
+
sources?: TailwindV4SourcePattern[];
|
|
629
385
|
}): Promise<TailwindTokenReport>;
|
|
630
386
|
collectContentTokensByFile(options?: {
|
|
631
387
|
cwd?: string;
|
|
632
|
-
sources?:
|
|
388
|
+
sources?: TailwindV4SourcePattern[];
|
|
633
389
|
key?: TailwindTokenFileKey;
|
|
634
390
|
stripAbsolutePaths?: boolean;
|
|
635
391
|
}): Promise<TailwindTokenByFileMap>;
|
|
@@ -840,4 +596,4 @@ declare class ValidateCommandError extends Error {
|
|
|
840
596
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
841
597
|
}
|
|
842
598
|
//#endregion
|
|
843
|
-
export {
|
|
599
|
+
export { PatchStatusEntry as $, extractSourceCandidates as A, ExtendLengthUnitsOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, extractProjectCandidatesWithPositions as D, ExtractSourceCandidate as E, normalizeOptions as F, TailwindCssPatchOptions as G, NormalizedCacheOptions as H, ApplyOptions as I, TailwindV4Options as J, TailwindV2Options as K, CacheOptions as L, extractValidCandidates as M, groupTokensByFile as N, extractRawCandidates as O, resolveProjectSourceFiles as P, PatchName as Q, CacheStrategy as R, MIGRATION_REPORT_KIND as S, TailwindcssPatcher as T, NormalizedTailwindCssPatchOptions as U, ExtractOptions as V, TailwindCssOptions as W, ILengthUnitsPatchOptions as X, ExtractResult as Y, PatchCheckStatus as Z, ConfigFileMigrationEntry as _, ValidateFailureSummary as a, TailwindTokenReport as at, RestoreConfigFilesOptions as b, TailwindcssPatchCliMountOptions as c, CacheClearOptions as ct, TailwindcssPatchCommandContext as d, CacheContextDescriptor as dt, PatchStatusReport as et, TailwindcssPatchCommandHandler as f, CacheContextMetadata as ft, tailwindcssPatchCommands as g, TailwindcssPatchCommandOptions as h, CacheReadResult as ht, ValidateFailureReason as i, TailwindTokenLocation as it, extractSourceCandidatesWithPositions as j, extractRawCandidatesWithPositions as k, TailwindcssPatchCliOptions as l, CacheClearResult as lt, TailwindcssPatchCommandOptionDefinition as m, CacheReadMeta as mt, VALIDATE_FAILURE_REASONS as n, TailwindTokenByFileMap as nt, ValidateJsonFailurePayload as o, TailwindcssClassCache as ot, TailwindcssPatchCommandHandlerMap as p, CacheIndexFileV2 as pt, TailwindV3Options as q, ValidateCommandError as r, TailwindTokenFileKey as rt, ValidateJsonSuccessPayload as s, TailwindcssRuntimeContext as st, VALIDATE_EXIT_CODES as t, TailwindPatchRuntime as tt, TailwindcssPatchCommand as u, CacheClearScope as ut, ConfigFileMigrationReport as v, logger as w, RestoreConfigFilesResult as x, MigrateConfigFilesOptions as y, ExposeContextOptions as z };
|