tailwindcss-patch 7.1.5 → 8.0.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/README.md +87 -73
- package/dist/chunk-FSTUQMKT.js +1320 -0
- package/dist/chunk-Y45IACSP.mjs +1316 -0
- package/dist/cli.js +131 -38
- package/dist/cli.mjs +132 -38
- package/dist/index.d.mts +237 -87
- package/dist/index.d.ts +237 -87
- package/dist/index.js +6 -2
- package/dist/index.mjs +19 -15
- package/package.json +20 -20
- package/dist/chunk-N2DIY7M3.js +0 -1107
- package/dist/chunk-NS2I2YPX.mjs +0 -1102
package/dist/index.d.mts
CHANGED
|
@@ -1,45 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { TailwindcssUserConfig, defineConfig } from '@tailwindcss-mangle/config';
|
|
3
|
-
import { Node, Rule } from 'postcss';
|
|
1
|
+
import postcss, { Node, Rule } from 'postcss';
|
|
4
2
|
import { Config } from 'tailwindcss';
|
|
5
|
-
import { PackageInfo } from 'local-pkg';
|
|
6
3
|
import { SourceEntry } from '@tailwindcss/oxide';
|
|
4
|
+
import { PackageResolvingOptions, PackageInfo } from 'local-pkg';
|
|
5
|
+
import { TailwindLocatorOptions, TailwindNextOptions } from '@tailwindcss-mangle/config';
|
|
6
|
+
export { defineConfig } from '@tailwindcss-mangle/config';
|
|
7
7
|
import * as consola from 'consola';
|
|
8
8
|
|
|
9
9
|
type CacheStrategy = 'merge' | 'overwrite';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
dir?: string;
|
|
10
|
+
interface CacheUserOptions {
|
|
11
|
+
enabled?: boolean;
|
|
13
12
|
cwd?: string;
|
|
13
|
+
dir?: string;
|
|
14
14
|
file?: string;
|
|
15
15
|
strategy?: CacheStrategy;
|
|
16
16
|
}
|
|
17
|
-
interface
|
|
18
|
-
|
|
17
|
+
interface OutputUserOptions {
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
file?: string;
|
|
20
|
+
format?: 'json' | 'lines';
|
|
21
|
+
pretty?: number | boolean;
|
|
22
|
+
removeUniversalSelector?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ExposeContextUserOptions {
|
|
25
|
+
refProperty?: string;
|
|
26
|
+
}
|
|
27
|
+
interface ExtendLengthUnitsUserOptions extends Partial<ILengthUnitsPatchOptions> {
|
|
28
|
+
enabled?: boolean;
|
|
19
29
|
}
|
|
20
|
-
interface
|
|
30
|
+
interface FeatureUserOptions {
|
|
31
|
+
exposeContext?: boolean | ExposeContextUserOptions;
|
|
32
|
+
extendLengthUnits?: false | ExtendLengthUnitsUserOptions;
|
|
33
|
+
}
|
|
34
|
+
interface TailwindConfigUserOptions {
|
|
35
|
+
config?: string;
|
|
36
|
+
cwd?: string;
|
|
37
|
+
postcssPlugin?: string;
|
|
38
|
+
}
|
|
39
|
+
interface TailwindV4UserOptions {
|
|
40
|
+
base?: string;
|
|
41
|
+
css?: string;
|
|
42
|
+
cssEntries?: string[];
|
|
43
|
+
sources?: SourceEntry[];
|
|
44
|
+
}
|
|
45
|
+
interface TailwindUserOptions extends TailwindConfigUserOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Optional hint for picking the patch strategy.
|
|
48
|
+
* When omitted we infer from the installed Tailwind CSS package version.
|
|
49
|
+
*/
|
|
50
|
+
version?: 2 | 3 | 4;
|
|
51
|
+
packageName?: string;
|
|
52
|
+
resolve?: PackageResolvingOptions;
|
|
53
|
+
v2?: TailwindConfigUserOptions;
|
|
54
|
+
v3?: TailwindConfigUserOptions;
|
|
55
|
+
v4?: TailwindV4UserOptions;
|
|
56
|
+
}
|
|
57
|
+
interface TailwindcssPatchOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Base directory used when resolving Tailwind resources.
|
|
60
|
+
* Defaults to `process.cwd()`.
|
|
61
|
+
*/
|
|
62
|
+
cwd?: string;
|
|
21
63
|
overwrite?: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
applyPatches?: {
|
|
25
|
-
exportContext?: boolean;
|
|
26
|
-
extendLengthUnits?: boolean | ILengthUnitsPatchOptions;
|
|
27
|
-
};
|
|
64
|
+
tailwind?: TailwindUserOptions;
|
|
65
|
+
features?: FeatureUserOptions;
|
|
28
66
|
filter?: (className: string) => boolean;
|
|
29
|
-
|
|
67
|
+
cache?: boolean | CacheUserOptions;
|
|
68
|
+
output?: OutputUserOptions;
|
|
69
|
+
}
|
|
70
|
+
interface NormalizedOutputOptions {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
file?: string;
|
|
73
|
+
format: 'json' | 'lines';
|
|
74
|
+
pretty: number | false;
|
|
75
|
+
removeUniversalSelector: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface NormalizedCacheOptions {
|
|
78
|
+
enabled: boolean;
|
|
79
|
+
cwd: string;
|
|
80
|
+
dir: string;
|
|
81
|
+
file: string;
|
|
82
|
+
path: string;
|
|
83
|
+
strategy: CacheStrategy;
|
|
84
|
+
}
|
|
85
|
+
interface NormalizedExposeContextOptions {
|
|
86
|
+
enabled: boolean;
|
|
87
|
+
refProperty: string;
|
|
88
|
+
}
|
|
89
|
+
interface NormalizedExtendLengthUnitsOptions extends ILengthUnitsPatchOptions {
|
|
90
|
+
enabled: boolean;
|
|
91
|
+
}
|
|
92
|
+
interface NormalizedTailwindV4Options {
|
|
93
|
+
base: string;
|
|
94
|
+
css?: string;
|
|
95
|
+
cssEntries: string[];
|
|
96
|
+
sources: SourceEntry[];
|
|
30
97
|
}
|
|
31
|
-
interface
|
|
32
|
-
|
|
98
|
+
interface NormalizedTailwindConfigOptions extends TailwindConfigUserOptions {
|
|
99
|
+
packageName: string;
|
|
100
|
+
versionHint?: 2 | 3 | 4;
|
|
101
|
+
resolve?: PackageResolvingOptions;
|
|
102
|
+
v2?: TailwindConfigUserOptions;
|
|
103
|
+
v3?: TailwindConfigUserOptions;
|
|
104
|
+
v4?: NormalizedTailwindV4Options;
|
|
33
105
|
}
|
|
34
|
-
interface
|
|
35
|
-
|
|
36
|
-
|
|
106
|
+
interface NormalizedFeatureOptions {
|
|
107
|
+
exposeContext: NormalizedExposeContextOptions;
|
|
108
|
+
extendLengthUnits: NormalizedExtendLengthUnitsOptions | null;
|
|
37
109
|
}
|
|
38
|
-
|
|
110
|
+
interface NormalizedTailwindcssPatchOptions {
|
|
111
|
+
projectRoot: string;
|
|
112
|
+
overwrite: boolean;
|
|
113
|
+
tailwind: NormalizedTailwindConfigOptions;
|
|
114
|
+
features: NormalizedFeatureOptions;
|
|
115
|
+
output: NormalizedOutputOptions;
|
|
116
|
+
cache: NormalizedCacheOptions;
|
|
117
|
+
filter: (className: string) => boolean;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
type TailwindcssClassCacheEntry = Rule | {
|
|
39
121
|
layer: string;
|
|
40
122
|
options: Record<string, any>;
|
|
41
123
|
sort: Record<string, any>;
|
|
42
|
-
}
|
|
124
|
+
};
|
|
125
|
+
type TailwindcssClassCache = Map<string, TailwindcssClassCacheEntry[]>;
|
|
43
126
|
interface TailwindcssRuntimeContext {
|
|
44
127
|
applyClassCache: Map<any, any>;
|
|
45
128
|
candidateRuleCache: Map<string, Set<[
|
|
@@ -58,11 +141,11 @@ interface TailwindcssRuntimeContext {
|
|
|
58
141
|
changedContent: any[];
|
|
59
142
|
classCache: TailwindcssClassCache;
|
|
60
143
|
disposables: any[];
|
|
61
|
-
getClassList:
|
|
62
|
-
getClassOrder:
|
|
63
|
-
getVariants:
|
|
64
|
-
markInvalidUtilityCandidate:
|
|
65
|
-
markInvalidUtilityNode:
|
|
144
|
+
getClassList: (...args: any[]) => any;
|
|
145
|
+
getClassOrder: (...args: any[]) => any;
|
|
146
|
+
getVariants: (...args: any[]) => any;
|
|
147
|
+
markInvalidUtilityCandidate: (...args: any[]) => any;
|
|
148
|
+
markInvalidUtilityNode: (...args: any[]) => any;
|
|
66
149
|
notClassCache: Set<string>;
|
|
67
150
|
offsets: {
|
|
68
151
|
layerPositions: object;
|
|
@@ -75,12 +158,19 @@ interface TailwindcssRuntimeContext {
|
|
|
75
158
|
stylesheetCache: Record<string, Set<any>>;
|
|
76
159
|
tailwindConfig: Config;
|
|
77
160
|
userConfigPath: string | null;
|
|
78
|
-
variantMap: Map<string, [[object,
|
|
161
|
+
variantMap: Map<string, [[object, (...args: any[]) => unknown]]>;
|
|
79
162
|
variantOptions: Map<string, object>;
|
|
80
163
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
164
|
+
interface ExtractResult {
|
|
165
|
+
classList: string[];
|
|
166
|
+
classSet: Set<string>;
|
|
167
|
+
filename?: string;
|
|
168
|
+
}
|
|
169
|
+
interface TailwindPatchRuntime {
|
|
170
|
+
options: NormalizedTailwindcssPatchOptions;
|
|
171
|
+
majorVersion: 2 | 3 | 4;
|
|
172
|
+
}
|
|
173
|
+
|
|
84
174
|
interface ILengthUnitsPatchOptions {
|
|
85
175
|
units: string[];
|
|
86
176
|
lengthUnitsFilePath?: string;
|
|
@@ -89,17 +179,79 @@ interface ILengthUnitsPatchOptions {
|
|
|
89
179
|
destPath?: string;
|
|
90
180
|
}
|
|
91
181
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
182
|
+
interface ExposeContextPatchParams {
|
|
183
|
+
rootDir: string;
|
|
184
|
+
refProperty: string;
|
|
185
|
+
overwrite: boolean;
|
|
186
|
+
majorVersion: 2 | 3;
|
|
187
|
+
}
|
|
188
|
+
interface ExposeContextPatchResult {
|
|
189
|
+
applied: boolean;
|
|
190
|
+
files: Record<string, string>;
|
|
191
|
+
}
|
|
192
|
+
declare function applyExposeContextPatch(params: ExposeContextPatchParams): ExposeContextPatchResult;
|
|
193
|
+
|
|
194
|
+
declare function applyExtendLengthUnitsPatchV3(rootDir: string, options: NormalizedExtendLengthUnitsOptions): {
|
|
195
|
+
changed: boolean;
|
|
196
|
+
code: undefined;
|
|
197
|
+
} | {
|
|
198
|
+
changed: boolean;
|
|
199
|
+
code: string;
|
|
200
|
+
};
|
|
201
|
+
interface V4FilePatch {
|
|
202
|
+
file: string;
|
|
203
|
+
code: string;
|
|
204
|
+
hasPatched: boolean;
|
|
205
|
+
}
|
|
206
|
+
interface V4Candidate extends V4FilePatch {
|
|
207
|
+
match: RegExpExecArray;
|
|
208
|
+
}
|
|
209
|
+
declare function applyExtendLengthUnitsPatchV4(rootDir: string, options: NormalizedExtendLengthUnitsOptions): {
|
|
210
|
+
changed: boolean;
|
|
211
|
+
files: V4Candidate[];
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
interface PatchRunnerResult {
|
|
215
|
+
exposeContext?: ReturnType<typeof applyExposeContextPatch>;
|
|
216
|
+
extendLengthUnits?: ReturnType<typeof applyExtendLengthUnitsPatchV3> | ReturnType<typeof applyExtendLengthUnitsPatchV4>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface LegacyCacheOptions {
|
|
220
|
+
dir?: string;
|
|
221
|
+
cwd?: string;
|
|
222
|
+
file?: string;
|
|
223
|
+
strategy?: 'merge' | 'overwrite';
|
|
224
|
+
enabled?: boolean;
|
|
225
|
+
}
|
|
226
|
+
interface LegacyOutputOptions {
|
|
227
|
+
filename?: string;
|
|
228
|
+
loose?: boolean;
|
|
229
|
+
removeUniversalSelector?: boolean;
|
|
230
|
+
}
|
|
231
|
+
interface LegacyTailwindcssOptions {
|
|
232
|
+
version?: 2 | 3 | 4;
|
|
233
|
+
v2?: TailwindLocatorOptions;
|
|
234
|
+
v3?: TailwindLocatorOptions;
|
|
235
|
+
v4?: TailwindNextOptions;
|
|
236
|
+
config?: string;
|
|
237
|
+
cwd?: string;
|
|
238
|
+
}
|
|
239
|
+
interface LegacyPatchOptions {
|
|
240
|
+
packageName?: string;
|
|
241
|
+
output?: LegacyOutputOptions;
|
|
242
|
+
tailwindcss?: LegacyTailwindcssOptions;
|
|
243
|
+
overwrite?: boolean;
|
|
244
|
+
applyPatches?: {
|
|
245
|
+
exportContext?: boolean;
|
|
246
|
+
extendLengthUnits?: boolean | ILengthUnitsPatchOptions;
|
|
100
247
|
};
|
|
101
|
-
|
|
102
|
-
|
|
248
|
+
filter?: (className: string) => boolean;
|
|
249
|
+
cwd?: string;
|
|
250
|
+
resolve?: PackageResolvingOptions;
|
|
251
|
+
}
|
|
252
|
+
interface LegacyTailwindcssPatcherOptions {
|
|
253
|
+
cache?: LegacyCacheOptions | boolean;
|
|
254
|
+
patch?: LegacyPatchOptions;
|
|
103
255
|
}
|
|
104
256
|
|
|
105
257
|
interface ExtractValidCandidatesOption {
|
|
@@ -108,59 +260,57 @@ interface ExtractValidCandidatesOption {
|
|
|
108
260
|
css?: string;
|
|
109
261
|
cwd?: string;
|
|
110
262
|
}
|
|
263
|
+
declare function extractRawCandidatesWithPositions(content: string, extension?: string): Promise<{
|
|
264
|
+
rawCandidate: string;
|
|
265
|
+
start: number;
|
|
266
|
+
end: number;
|
|
267
|
+
}[]>;
|
|
268
|
+
declare function extractRawCandidates(sources?: SourceEntry[]): Promise<string[]>;
|
|
111
269
|
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
112
270
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
271
|
+
type TailwindMajorVersion = 2 | 3 | 4;
|
|
272
|
+
type TailwindcssPatcherInitOptions = TailwindcssPatchOptions | LegacyTailwindcssPatcherOptions;
|
|
116
273
|
declare class TailwindcssPatcher {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
majorVersion?: number;
|
|
124
|
-
filter?: (className: string) => boolean;
|
|
125
|
-
constructor(options?: TailwindcssPatcherOptions);
|
|
126
|
-
setCache(set: Set<string>): string | undefined;
|
|
127
|
-
getCache(): Set<string>;
|
|
274
|
+
readonly options: NormalizedTailwindcssPatchOptions;
|
|
275
|
+
readonly packageInfo: PackageInfo;
|
|
276
|
+
readonly majorVersion: TailwindMajorVersion;
|
|
277
|
+
private readonly cacheStore;
|
|
278
|
+
constructor(options?: TailwindcssPatcherInitOptions);
|
|
279
|
+
patch(): Promise<PatchRunnerResult>;
|
|
128
280
|
getContexts(): TailwindcssRuntimeContext[];
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
134
|
-
*/
|
|
281
|
+
private runTailwindBuildIfNeeded;
|
|
282
|
+
private collectClassSet;
|
|
283
|
+
private mergeWithCache;
|
|
135
284
|
getClassSet(): Promise<Set<string>>;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
classSet: Set<string>;
|
|
140
|
-
filename?: string;
|
|
141
|
-
} | undefined>;
|
|
285
|
+
extract(options?: {
|
|
286
|
+
write?: boolean;
|
|
287
|
+
}): Promise<ExtractResult>;
|
|
142
288
|
extractValidCandidates: typeof extractValidCandidates;
|
|
143
289
|
}
|
|
144
290
|
|
|
145
|
-
declare
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
interface V4GuessFile {
|
|
152
|
-
code: string;
|
|
153
|
-
hasPatched: boolean;
|
|
154
|
-
file: string;
|
|
155
|
-
matches: RegExpMatchArray;
|
|
291
|
+
declare class CacheStore {
|
|
292
|
+
private readonly options;
|
|
293
|
+
constructor(options: NormalizedCacheOptions);
|
|
294
|
+
private ensureDir;
|
|
295
|
+
write(data: Set<string>): Promise<string | undefined>;
|
|
296
|
+
read(): Promise<Set<string>>;
|
|
156
297
|
}
|
|
157
|
-
declare function monkeyPatchForSupportingCustomUnitV4(rootDir: string, options?: Partial<ILengthUnitsPatchOptions>): {
|
|
158
|
-
files: V4GuessFile[];
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
declare function internalPatch(pkgJsonPath: PackageInfo, options: InternalPatchOptions): any;
|
|
162
|
-
declare function internalPatch(pkgJsonPath: string, options: InternalPatchOptions): any;
|
|
163
298
|
|
|
164
299
|
declare const logger: consola.ConsolaInstance;
|
|
165
300
|
|
|
166
|
-
|
|
301
|
+
declare function normalizeOptions(options?: TailwindcssPatchOptions): NormalizedTailwindcssPatchOptions;
|
|
302
|
+
|
|
303
|
+
declare function collectClassesFromContexts(contexts: TailwindcssRuntimeContext[], filter: (className: string) => boolean): Set<string>;
|
|
304
|
+
declare function collectClassesFromTailwindV4(options: NormalizedTailwindcssPatchOptions): Promise<Set<string>>;
|
|
305
|
+
|
|
306
|
+
declare function loadRuntimeContexts(packageInfo: PackageInfo, majorVersion: 2 | 3 | 4, refProperty: string): TailwindcssRuntimeContext[];
|
|
307
|
+
|
|
308
|
+
interface TailwindBuildOptions {
|
|
309
|
+
cwd: string;
|
|
310
|
+
config?: string;
|
|
311
|
+
majorVersion: 2 | 3 | 4;
|
|
312
|
+
postcssPlugin?: string;
|
|
313
|
+
}
|
|
314
|
+
declare function runTailwindBuild(options: TailwindBuildOptions): Promise<postcss.Result<postcss.Root>>;
|
|
315
|
+
|
|
316
|
+
export { CacheStore, type CacheStrategy, type ExtractResult, type ILengthUnitsPatchOptions, type NormalizedTailwindcssPatchOptions, type TailwindPatchRuntime, type TailwindcssClassCache, type TailwindcssPatchOptions, TailwindcssPatcher, type TailwindcssRuntimeContext, collectClassesFromContexts, collectClassesFromTailwindV4, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, loadRuntimeContexts, logger, normalizeOptions, runTailwindBuild };
|