purgecss 4.1.2 → 5.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/lib/purgecss.d.ts CHANGED
@@ -1,297 +1,509 @@
1
- import * as postcss from "postcss";
2
- type PostCSSRoot = postcss.Root;
3
- interface AtRules {
4
- fontFace: Array<{
5
- name: string;
6
- node: postcss.AtRule;
7
- }>;
8
- keyframes: postcss.AtRule[];
9
- }
10
- interface RawContent<T = string> {
11
- extension: string;
12
- raw: T;
13
- }
14
- interface RawCSS {
15
- raw: string;
16
- name?: string;
17
- }
18
- interface ExtractorResultDetailed {
19
- attributes: {
20
- names: string[];
21
- values: string[];
22
- };
23
- classes: string[];
24
- ids: string[];
25
- tags: string[];
26
- undetermined: string[];
27
- }
28
- type ExtractorResult = ExtractorResultDetailed | string[];
29
- type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
30
- interface Extractors {
31
- extensions: string[];
32
- extractor: ExtractorFunction;
33
- }
34
- type IgnoreType = "end" | "start" | "next";
35
- type StringRegExpArray = Array<RegExp | string>;
36
- type ComplexSafelist = {
37
- standard?: StringRegExpArray;
38
- deep?: RegExp[];
39
- greedy?: RegExp[];
40
- variables?: StringRegExpArray;
41
- keyframes?: StringRegExpArray;
42
- };
43
- type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
44
- interface UserDefinedOptions {
45
- content: Array<string | RawContent>;
46
- css: Array<string | RawCSS>;
47
- defaultExtractor?: ExtractorFunction;
48
- extractors?: Array<Extractors>;
49
- fontFace?: boolean;
50
- keyframes?: boolean;
51
- output?: string;
52
- rejected?: boolean;
53
- rejectedCss?: boolean;
54
- stdin?: boolean;
55
- stdout?: boolean;
56
- variables?: boolean;
57
- safelist?: UserDefinedSafelist;
58
- blocklist?: StringRegExpArray;
59
- skippedContentGlobs?: Array<string>;
60
- dynamicAttributes?: string[];
61
- }
62
- interface Options {
63
- content: Array<string | RawContent>;
64
- css: Array<string | RawCSS>;
65
- defaultExtractor: ExtractorFunction;
66
- extractors: Array<Extractors>;
67
- fontFace: boolean;
68
- keyframes: boolean;
69
- output?: string;
70
- rejected: boolean;
71
- rejectedCss: boolean;
72
- stdin: boolean;
73
- stdout: boolean;
74
- variables: boolean;
75
- safelist: Required<ComplexSafelist>;
76
- blocklist: StringRegExpArray;
77
- skippedContentGlobs: Array<string>;
78
- dynamicAttributes: string[];
79
- }
80
- interface ResultPurge {
81
- css: string;
82
- rejectedCss?: string;
83
- file?: string;
84
- rejected?: string[];
85
- }
86
- declare class ExtractorResultSets {
87
- private undetermined;
88
- private attrNames;
89
- private attrValues;
90
- private classes;
91
- private ids;
92
- private tags;
93
- constructor(er: ExtractorResult);
94
- merge(that: ExtractorResult | ExtractorResultSets): this;
95
- hasAttrName(name: string): boolean;
96
- private someAttrValue;
97
- hasAttrPrefix(prefix: string): boolean;
98
- hasAttrSuffix(suffix: string): boolean;
99
- hasAttrSubstr(substr: string): boolean;
100
- hasAttrValue(value: string): boolean;
101
- hasClass(name: string): boolean;
102
- hasId(id: string): boolean;
103
- hasTag(tag: string): boolean;
104
- }
105
- declare const defaultOptions: Options;
106
- declare function standardizeSafelist(userDefinedSafelist?: UserDefinedSafelist): Required<ComplexSafelist>;
107
- /**
108
- * Load the configuration file from the path
109
- * @param configFile Path of the config file
110
- */
111
- declare function setOptions(configFile?: string): Promise<Options>;
112
- /**
113
- * Merge two extractor selectors
114
- * @param extractorSelectorsA extractor selectors A
115
- * @param extractorSelectorsB extractor selectors B
116
- */
117
- declare function mergeExtractorSelectors(...extractors: (ExtractorResultDetailed | ExtractorResultSets)[]): ExtractorResultSets;
118
- declare class PurgeCSS {
119
- private ignore;
120
- private atRules;
121
- private usedAnimations;
122
- private usedFontFaces;
123
- selectorsRemoved: Set<string>;
124
- removedNodes: postcss.Node[];
125
- private variablesStructure;
126
- options: Options;
127
- private collectDeclarationsData;
128
- /**
129
- * Get the extractor corresponding to the extension file
130
- * @param filename Name of the file
131
- * @param extractors Array of extractors definition
132
- */
133
- /**
134
- * Get the extractor corresponding to the extension file
135
- * @param filename Name of the file
136
- * @param extractors Array of extractors definition
137
- */
138
- private getFileExtractor;
139
- /**
140
- * Extract the selectors present in the files using a purgecss extractor
141
- * @param files Array of files path or glob pattern
142
- * @param extractors Array of extractors
143
- */
144
- /**
145
- * Extract the selectors present in the files using a purgecss extractor
146
- * @param files Array of files path or glob pattern
147
- * @param extractors Array of extractors
148
- */
149
- extractSelectorsFromFiles(files: string[], extractors: Extractors[]): Promise<ExtractorResultSets>;
150
- /**
151
- * Extract the selectors present in the passed string using a PurgeCSS extractor
152
- * @param content Array of content
153
- * @param extractors Array of extractors
154
- */
155
- /**
156
- * Extract the selectors present in the passed string using a PurgeCSS extractor
157
- * @param content Array of content
158
- * @param extractors Array of extractors
159
- */
160
- extractSelectorsFromString(content: RawContent[], extractors: Extractors[]): Promise<ExtractorResultSets>;
161
- /**
162
- * Evaluate at-rule and register it for future reference
163
- * @param node node of postcss AST
164
- */
165
- /**
166
- * Evaluate at-rule and register it for future reference
167
- * @param node node of postcss AST
168
- */
169
- private evaluateAtRule;
170
- /**
171
- * Evaluate css selector and decide if it should be removed or not
172
- * @param node node of postcss AST
173
- * @param selectors selectors used in content files
174
- */
175
- /**
176
- * Evaluate css selector and decide if it should be removed or not
177
- * @param node node of postcss AST
178
- * @param selectors selectors used in content files
179
- */
180
- private evaluateRule;
181
- /**
182
- * Get the purged version of the css based on the files
183
- * @param cssOptions css options, files or raw strings
184
- * @param selectors set of extracted css selectors
185
- */
186
- /**
187
- * Get the purged version of the css based on the files
188
- * @param cssOptions css options, files or raw strings
189
- * @param selectors set of extracted css selectors
190
- */
191
- getPurgedCSS(cssOptions: Array<string | RawCSS>, selectors: ExtractorResultSets): Promise<ResultPurge[]>;
192
- /**
193
- * Check if the keyframe is safelisted with the option safelist keyframes
194
- * @param keyframesName name of the keyframe animation
195
- */
196
- /**
197
- * Check if the keyframe is safelisted with the option safelist keyframes
198
- * @param keyframesName name of the keyframe animation
199
- */
200
- private isKeyframesSafelisted;
201
- /**
202
- * Check if the selector is blocklisted with the option blocklist
203
- * @param selector css selector
204
- */
205
- /**
206
- * Check if the selector is blocklisted with the option blocklist
207
- * @param selector css selector
208
- */
209
- private isSelectorBlocklisted;
210
- /**
211
- * Check if the selector is safelisted with the option safelist standard
212
- * @param selector css selector
213
- */
214
- /**
215
- * Check if the selector is safelisted with the option safelist standard
216
- * @param selector css selector
217
- */
218
- private isSelectorSafelisted;
219
- /**
220
- * Check if the selector is safelisted with the option safelist deep
221
- * @param selector selector
222
- */
223
- /**
224
- * Check if the selector is safelisted with the option safelist deep
225
- * @param selector selector
226
- */
227
- private isSelectorSafelistedDeep;
228
- /**
229
- * Check if the selector is safelisted with the option safelist greedy
230
- * @param selector selector
231
- */
232
- /**
233
- * Check if the selector is safelisted with the option safelist greedy
234
- * @param selector selector
235
- */
236
- private isSelectorSafelistedGreedy;
237
- /**
238
- * Remove unused css
239
- * @param userOptions PurgeCSS options
240
- */
241
- /**
242
- * Remove unused css
243
- * @param userOptions PurgeCSS options
244
- */
245
- purge(userOptions: UserDefinedOptions | string | undefined): Promise<ResultPurge[]>;
246
- /**
247
- * Remove unused CSS variables
248
- */
249
- /**
250
- * Remove unused CSS variables
251
- */
252
- removeUnusedCSSVariables(): void;
253
- /**
254
- * Remove unused font-faces
255
- */
256
- /**
257
- * Remove unused font-faces
258
- */
259
- removeUnusedFontFaces(): void;
260
- /**
261
- * Remove unused keyframes
262
- */
263
- /**
264
- * Remove unused keyframes
265
- */
266
- removeUnusedKeyframes(): void;
267
- /**
268
- * Transform a selector node into a string
269
- */
270
- /**
271
- * Transform a selector node into a string
272
- */
273
- private getSelectorValue;
274
- /**
275
- * Determine if the selector should be kept, based on the selectors found in the files
276
- * @param selector set of css selectors found in the content files or string
277
- * @param selectorsFromExtractor selectors in the css rule
278
- */
279
- /**
280
- * Determine if the selector should be kept, based on the selectors found in the files
281
- * @param selector set of css selectors found in the content files or string
282
- * @param selectorsFromExtractor selectors in the css rule
283
- */
284
- private shouldKeepSelector;
285
- /**
286
- * Walk through the CSS AST and remove unused CSS
287
- * @param root root node of the postcss AST
288
- * @param selectors selectors used in content files
289
- */
290
- /**
291
- * Walk through the CSS AST and remove unused CSS
292
- * @param root root node of the postcss AST
293
- * @param selectors selectors used in content files
294
- */
295
- walkThroughCSS(root: PostCSSRoot, selectors: ExtractorResultSets): void;
296
- }
297
- export { PurgeCSS as default, PurgeCSS, defaultOptions, PostCSSRoot, AtRules, RawContent, RawCSS, ExtractorResultDetailed, ExtractorResult, ExtractorFunction, Extractors, IgnoreType, StringRegExpArray, ComplexSafelist, UserDefinedSafelist, UserDefinedOptions, Options, ResultPurge, standardizeSafelist, setOptions, mergeExtractorSelectors };
1
+ /**
2
+ * Core package of PurgeCSS
3
+ *
4
+ * Contains the core methods to analyze the files, remove unused CSS.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ import * as postcss from 'postcss';
10
+
11
+ /* Excluded from this release type: AtRules */
12
+
13
+ /**
14
+ * @public
15
+ */
16
+ export declare type ComplexSafelist = {
17
+ standard?: StringRegExpArray;
18
+ /**
19
+ * You can safelist selectors and their children based on a regular
20
+ * expression with `safelist.deep`
21
+ *
22
+ * @example
23
+ *
24
+ * ```ts
25
+ * const purgecss = await new PurgeCSS().purge({
26
+ * content: [],
27
+ * css: [],
28
+ * safelist: {
29
+ * deep: [/red$/]
30
+ * }
31
+ * })
32
+ * ```
33
+ *
34
+ * In this example, selectors such as `.bg-red .child-of-bg` will be left
35
+ * in the final CSS, even if `child-of-bg` is not found.
36
+ *
37
+ */
38
+ deep?: RegExp[];
39
+ greedy?: RegExp[];
40
+ variables?: StringRegExpArray;
41
+ keyframes?: StringRegExpArray;
42
+ };
43
+
44
+ /**
45
+ * @public
46
+ */
47
+ export declare const defaultOptions: Options;
48
+
49
+ /**
50
+ * @public
51
+ */
52
+ export declare type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
53
+
54
+ /**
55
+ * @public
56
+ */
57
+ export declare type ExtractorResult = ExtractorResultDetailed | string[];
58
+
59
+ /**
60
+ * @public
61
+ */
62
+ export declare interface ExtractorResultDetailed {
63
+ attributes: {
64
+ names: string[];
65
+ values: string[];
66
+ };
67
+ classes: string[];
68
+ ids: string[];
69
+ tags: string[];
70
+ undetermined: string[];
71
+ }
72
+
73
+ /**
74
+ * @public
75
+ */
76
+ export declare class ExtractorResultSets {
77
+ private undetermined;
78
+ private attrNames;
79
+ private attrValues;
80
+ private classes;
81
+ private ids;
82
+ private tags;
83
+ constructor(er: ExtractorResult);
84
+ merge(that: ExtractorResult | ExtractorResultSets): this;
85
+ hasAttrName(name: string): boolean;
86
+ private someAttrValue;
87
+ hasAttrPrefix(prefix: string): boolean;
88
+ hasAttrSuffix(suffix: string): boolean;
89
+ hasAttrSubstr(substr: string): boolean;
90
+ hasAttrValue(value: string): boolean;
91
+ hasClass(name: string): boolean;
92
+ hasId(id: string): boolean;
93
+ hasTag(tag: string): boolean;
94
+ }
95
+
96
+ /**
97
+ * @public
98
+ */
99
+ export declare interface Extractors {
100
+ extensions: string[];
101
+ extractor: ExtractorFunction;
102
+ }
103
+
104
+ /* Excluded from this release type: IgnoreType */
105
+
106
+ /**
107
+ * Merge two extractor selectors
108
+ *
109
+ * @param extractorSelectorsA - extractor selectors A
110
+ * @param extractorSelectorsB - extractor selectors B
111
+ * @returns the merged extractor result sets
112
+ *
113
+ * @public
114
+ */
115
+ export declare function mergeExtractorSelectors(...extractors: (ExtractorResultDetailed | ExtractorResultSets)[]): ExtractorResultSets;
116
+
117
+ /**
118
+ * Options used by PurgeCSS to remove unused CSS
119
+ * Those options are used internally
120
+ * @see {@link UserDefinedOptions} for the options defined by the user
121
+ *
122
+ * @public
123
+ */
124
+ export declare interface Options {
125
+ /**
126
+ * You can specify content that should be analyzed by PurgeCSS with an
127
+ * array of filenames or globs. The files can be HTML, Pug, Blade, etc.
128
+ *
129
+ * @example
130
+ *
131
+ * ```ts
132
+ * await new PurgeCSS().purge({
133
+ * content: ['index.html', '*.js', '*.html', '*.vue'],
134
+ * css: ['css/app.css']
135
+ * })
136
+ * ```
137
+ *
138
+ * @example
139
+ * PurgeCSS also works with raw content. To do this, you need to pass an
140
+ * object with the `raw` property instead of a filename. To work properly
141
+ * with custom extractors you need to pass the `extension` property along
142
+ * with the raw content.
143
+ *
144
+ * ```ts
145
+ * await new PurgeCSS().purge({
146
+ * content: [
147
+ * {
148
+ * raw: '<html><body><div class="app"></div></body></html>',
149
+ * extension: 'html'
150
+ * },
151
+ * '*.js',
152
+ * '*.html',
153
+ * '*.vue'
154
+ * ],
155
+ * css: [
156
+ * {
157
+ * raw: 'body { margin: 0 }'
158
+ * },
159
+ * 'css/app.css'
160
+ * ]
161
+ * })
162
+ * ```
163
+ */
164
+ content: Array<string | RawContent>;
165
+ /**
166
+ * Similar to content, you can specify css that should be processed by
167
+ * PurgeCSS with an array of filenames or globs
168
+ */
169
+ css: Array<string | RawCSS>;
170
+ defaultExtractor: ExtractorFunction;
171
+ extractors: Array<Extractors>;
172
+ /**
173
+ * If there are any unused \@font-face rules in your css, you can remove
174
+ * them by setting the `fontFace` option to `true`.
175
+ *
176
+ * @defaultValue `false`
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * await new PurgeCSS().purge({
181
+ * content: ['index.html', '*.js', '*.html', '*.vue'],
182
+ * css: ['css/app.css'],
183
+ * fontFace: true
184
+ * })
185
+ * ```
186
+ */
187
+ fontFace: boolean;
188
+ keyframes: boolean;
189
+ output?: string;
190
+ rejected: boolean;
191
+ rejectedCss: boolean;
192
+ /** {@inheritDoc postcss#SourceMapOptions} */
193
+ sourceMap: boolean | (postcss.SourceMapOptions & {
194
+ to?: string;
195
+ });
196
+ stdin: boolean;
197
+ stdout: boolean;
198
+ variables: boolean;
199
+ /**
200
+ * You can indicate which selectors are safe to leave in the final CSS.
201
+ * This can be accomplished with the option safelist.
202
+ */
203
+ safelist: Required<ComplexSafelist>;
204
+ /**
205
+ * Blocklist will block the CSS selectors from appearing in the final
206
+ * output CSS. The selectors will be removed even when they are seen
207
+ * as used by PurgeCSS.
208
+ */
209
+ blocklist: StringRegExpArray;
210
+ /**
211
+ * If you provide globs for the content parameter, you can use this option
212
+ * to exclude certain files or folders that would otherwise be scanned.
213
+ * Pass an array of globs matching items that should be excluded.
214
+ * (Note: this option has no effect if content is not globs.)
215
+ */
216
+ skippedContentGlobs: Array<string>;
217
+ /**
218
+ * Option to add custom CSS attribute selectors like "aria-selected",
219
+ * "data-selected", ...etc.
220
+ */
221
+ dynamicAttributes: string[];
222
+ }
223
+
224
+ /**
225
+ * @public
226
+ */
227
+ export declare type PostCSSRoot = postcss.Root;
228
+
229
+ /**
230
+ * Class used to instantiate PurgeCSS and can then be used
231
+ * to purge CSS files.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * await new PurgeCSS().purge({
236
+ * content: ['index.html'],
237
+ * css: ['css/app.css']
238
+ * })
239
+ * ```
240
+ *
241
+ * @public
242
+ */
243
+ export declare class PurgeCSS {
244
+ private ignore;
245
+ private atRules;
246
+ private usedAnimations;
247
+ private usedFontFaces;
248
+ selectorsRemoved: Set<string>;
249
+ removedNodes: postcss.Node[];
250
+ variablesStructure: VariablesStructure;
251
+ options: Options;
252
+ private collectDeclarationsData;
253
+ /**
254
+ * Get the extractor corresponding to the extension file
255
+ * @param filename - Name of the file
256
+ * @param extractors - Array of extractors definition
257
+ */
258
+ private getFileExtractor;
259
+ /**
260
+ * Extract the selectors present in the files using a PurgeCSS extractor
261
+ *
262
+ * @param files - Array of files path or glob pattern
263
+ * @param extractors - Array of extractors
264
+ */
265
+ extractSelectorsFromFiles(files: string[], extractors: Extractors[]): Promise<ExtractorResultSets>;
266
+ /**
267
+ * Extract the selectors present in the passed string using a PurgeCSS extractor
268
+ *
269
+ * @param content - Array of content
270
+ * @param extractors - Array of extractors
271
+ */
272
+ extractSelectorsFromString(content: RawContent[], extractors: Extractors[]): Promise<ExtractorResultSets>;
273
+ /**
274
+ * Evaluate at-rule and register it for future reference
275
+ * @param node - node of postcss AST
276
+ */
277
+ private evaluateAtRule;
278
+ /**
279
+ * Evaluate css selector and decide if it should be removed or not
280
+ *
281
+ * @param node - node of postcss AST
282
+ * @param selectors - selectors used in content files
283
+ */
284
+ private evaluateRule;
285
+ /**
286
+ * Get the purged version of the css based on the files
287
+ *
288
+ * @param cssOptions - css options, files or raw strings
289
+ * @param selectors - set of extracted css selectors
290
+ */
291
+ getPurgedCSS(cssOptions: Array<string | RawCSS>, selectors: ExtractorResultSets): Promise<ResultPurge[]>;
292
+ /**
293
+ * Check if the keyframe is safelisted with the option safelist keyframes
294
+ *
295
+ * @param keyframesName - name of the keyframe animation
296
+ */
297
+ private isKeyframesSafelisted;
298
+ /**
299
+ * Check if the selector is blocklisted with the option blocklist
300
+ *
301
+ * @param selector - css selector
302
+ */
303
+ private isSelectorBlocklisted;
304
+ /**
305
+ * Check if the selector is safelisted with the option safelist standard
306
+ *
307
+ * @param selector - css selector
308
+ */
309
+ private isSelectorSafelisted;
310
+ /**
311
+ * Check if the selector is safelisted with the option safelist deep
312
+ *
313
+ * @param selector - selector
314
+ */
315
+ private isSelectorSafelistedDeep;
316
+ /**
317
+ * Check if the selector is safelisted with the option safelist greedy
318
+ *
319
+ * @param selector - selector
320
+ */
321
+ private isSelectorSafelistedGreedy;
322
+ /**
323
+ * Remove unused CSS
324
+ *
325
+ * @param userOptions - PurgeCSS options or path to the configuration file
326
+ * @returns an array of object containing the filename and the associated CSS
327
+ *
328
+ * @example Using a configuration file named purgecss.config.js
329
+ * ```ts
330
+ * const purgeCSSResults = await new PurgeCSS().purge()
331
+ * ```
332
+ *
333
+ * @example Using a custom path to the configuration file
334
+ * ```ts
335
+ * const purgeCSSResults = await new PurgeCSS().purge('./purgecss.config.js')
336
+ * ```
337
+ *
338
+ * @example Using the PurgeCSS options
339
+ * ```ts
340
+ * const purgeCSSResults = await new PurgeCSS().purge({
341
+ * content: ['index.html', '**\/*.js', '**\/*.html', '**\/*.vue'],
342
+ * css: ['css/app.css']
343
+ * })
344
+ * ```
345
+ */
346
+ purge(userOptions: UserDefinedOptions | string | undefined): Promise<ResultPurge[]>;
347
+ /**
348
+ * Remove unused CSS variables
349
+ */
350
+ removeUnusedCSSVariables(): void;
351
+ /**
352
+ * Remove unused font-faces
353
+ */
354
+ removeUnusedFontFaces(): void;
355
+ /**
356
+ * Remove unused keyframes
357
+ */
358
+ removeUnusedKeyframes(): void;
359
+ /**
360
+ * Transform a selector node into a string
361
+ */
362
+ private getSelectorValue;
363
+ /**
364
+ * Determine if the selector should be kept, based on the selectors found in the files
365
+ *
366
+ * @param selector - set of css selectors found in the content files or string
367
+ * @param selectorsFromExtractor - selectors in the css rule
368
+ *
369
+ * @returns true if the selector should be kept in the processed CSS
370
+ */
371
+ private shouldKeepSelector;
372
+ /**
373
+ * Walk through the CSS AST and remove unused CSS
374
+ *
375
+ * @param root - root node of the postcss AST
376
+ * @param selectors - selectors used in content files
377
+ */
378
+ walkThroughCSS(root: PostCSSRoot, selectors: ExtractorResultSets): void;
379
+ }
380
+
381
+ /**
382
+ * @public
383
+ */
384
+ export declare interface RawContent<T = string> {
385
+ extension: string;
386
+ raw: T;
387
+ }
388
+
389
+ /**
390
+ * @public
391
+ */
392
+ export declare interface RawCSS {
393
+ raw: string;
394
+ name?: string;
395
+ }
396
+
397
+ /**
398
+ * @public
399
+ */
400
+ export declare interface ResultPurge {
401
+ css: string;
402
+ /**
403
+ * sourceMap property will be empty if
404
+ * {@link UserDefinedOptions.sourceMap} inline is not set to false, as the
405
+ * source map will be contained within the text of ResultPurge.css
406
+ */
407
+ sourceMap?: string;
408
+ rejectedCss?: string;
409
+ file?: string;
410
+ rejected?: string[];
411
+ }
412
+
413
+ /**
414
+ * Load the configuration file from the path
415
+ *
416
+ * @param configFile - Path of the config file
417
+ * @returns The options from the configuration file
418
+ *
419
+ * @throws Error
420
+ * This exception is thrown if the configuration file was not imported
421
+ *
422
+ * @public
423
+ */
424
+ export declare function setOptions(configFile?: string): Promise<Options>;
425
+
426
+ /**
427
+ * Format the user defined safelist into a standardized safelist object
428
+ *
429
+ * @param userDefinedSafelist - the user defined safelist
430
+ * @returns the formatted safelist object that can be used in the PurgeCSS options
431
+ *
432
+ * @public
433
+ */
434
+ export declare function standardizeSafelist(userDefinedSafelist?: UserDefinedSafelist): Required<ComplexSafelist>;
435
+
436
+ /**
437
+ * @public
438
+ */
439
+ export declare type StringRegExpArray = Array<RegExp | string>;
440
+
441
+ /**
442
+ * Options used by PurgeCSS to remove unused CSS
443
+ *
444
+ * @public
445
+ */
446
+ export declare interface UserDefinedOptions {
447
+ /** {@inheritDoc Options.content} */
448
+ content: Array<string | RawContent>;
449
+ /** {@inheritDoc Options.css} */
450
+ css: Array<string | RawCSS>;
451
+ /** {@inheritDoc Options.defaultExtractor} */
452
+ defaultExtractor?: ExtractorFunction;
453
+ /** {@inheritDoc Options.extractors} */
454
+ extractors?: Array<Extractors>;
455
+ /** {@inheritDoc Options.fontFace} */
456
+ fontFace?: boolean;
457
+ /** {@inheritDoc Options.keyframes} */
458
+ keyframes?: boolean;
459
+ /** {@inheritDoc Options.output} */
460
+ output?: string;
461
+ /** {@inheritDoc Options.rejected} */
462
+ rejected?: boolean;
463
+ /** {@inheritDoc Options.rejectedCss} */
464
+ rejectedCss?: boolean;
465
+ /** {@inheritDoc Options.sourceMap } */
466
+ sourceMap?: boolean | (postcss.SourceMapOptions & {
467
+ to?: string;
468
+ });
469
+ /** {@inheritDoc Options.stdin} */
470
+ stdin?: boolean;
471
+ /** {@inheritDoc Options.stdout} */
472
+ stdout?: boolean;
473
+ /** {@inheritDoc Options.variables} */
474
+ variables?: boolean;
475
+ /** {@inheritDoc Options.safelist} */
476
+ safelist?: UserDefinedSafelist;
477
+ /** {@inheritDoc Options.blocklist} */
478
+ blocklist?: StringRegExpArray;
479
+ /** {@inheritDoc Options.skippedContentGlobs} */
480
+ skippedContentGlobs?: Array<string>;
481
+ /** {@inheritDoc Options.dynamicAttributes} */
482
+ dynamicAttributes?: string[];
483
+ }
484
+
485
+ /**
486
+ * @public
487
+ */
488
+ export declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
489
+
490
+ declare class VariableNode {
491
+ nodes: VariableNode[];
492
+ value: postcss.Declaration;
493
+ isUsed: boolean;
494
+ constructor(declaration: postcss.Declaration);
495
+ }
496
+
497
+ declare class VariablesStructure {
498
+ nodes: Map<string, VariableNode[]>;
499
+ usedVariables: Set<string>;
500
+ safelist: StringRegExpArray;
501
+ addVariable(declaration: postcss.Declaration): void;
502
+ addVariableUsage(declaration: postcss.Declaration, matchedVariables: RegExpMatchArray[]): void;
503
+ addVariableUsageInProperties(matchedVariables: RegExpMatchArray[]): void;
504
+ setAsUsed(variableName: string): void;
505
+ removeUnused(): void;
506
+ isVariablesSafelisted(variable: string): boolean;
507
+ }
508
+
509
+ export { }