purgecss 4.1.3 → 6.0.0-alpha.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,334 +1,515 @@
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(
107
- userDefinedSafelist?: UserDefinedSafelist
108
- ): Required<ComplexSafelist>;
109
- /**
110
- * Load the configuration file from the path
111
- * @param configFile Path of the config file
112
- */
113
- declare function setOptions(configFile?: string): Promise<Options>;
114
- /**
115
- * Merge two extractor selectors
116
- * @param extractorSelectorsA extractor selectors A
117
- * @param extractorSelectorsB extractor selectors B
118
- */
119
- declare function mergeExtractorSelectors(
120
- ...extractors: (ExtractorResultDetailed | ExtractorResultSets)[]
121
- ): ExtractorResultSets;
122
- declare class PurgeCSS {
123
- private ignore;
124
- private atRules;
125
- private usedAnimations;
126
- private usedFontFaces;
127
- selectorsRemoved: Set<string>;
128
- removedNodes: postcss.Node[];
129
- private variablesStructure;
130
- options: Options;
131
- private collectDeclarationsData;
132
- /**
133
- * Get the extractor corresponding to the extension file
134
- * @param filename Name of the file
135
- * @param extractors Array of extractors definition
136
- */
137
- /**
138
- * Get the extractor corresponding to the extension file
139
- * @param filename Name of the file
140
- * @param extractors Array of extractors definition
141
- */
142
- private getFileExtractor;
143
- /**
144
- * Extract the selectors present in the files using a purgecss extractor
145
- * @param files Array of files path or glob pattern
146
- * @param extractors Array of extractors
147
- */
148
- /**
149
- * Extract the selectors present in the files using a purgecss extractor
150
- * @param files Array of files path or glob pattern
151
- * @param extractors Array of extractors
152
- */
153
- extractSelectorsFromFiles(
154
- files: string[],
155
- extractors: Extractors[]
156
- ): Promise<ExtractorResultSets>;
157
- /**
158
- * Extract the selectors present in the passed string using a PurgeCSS extractor
159
- * @param content Array of content
160
- * @param extractors Array of extractors
161
- */
162
- /**
163
- * Extract the selectors present in the passed string using a PurgeCSS extractor
164
- * @param content Array of content
165
- * @param extractors Array of extractors
166
- */
167
- extractSelectorsFromString(
168
- content: RawContent[],
169
- extractors: Extractors[]
170
- ): Promise<ExtractorResultSets>;
171
- /**
172
- * Evaluate at-rule and register it for future reference
173
- * @param node node of postcss AST
174
- */
175
- /**
176
- * Evaluate at-rule and register it for future reference
177
- * @param node node of postcss AST
178
- */
179
- private evaluateAtRule;
180
- /**
181
- * Evaluate css selector and decide if it should be removed or not
182
- * @param node node of postcss AST
183
- * @param selectors selectors used in content files
184
- */
185
- /**
186
- * Evaluate css selector and decide if it should be removed or not
187
- * @param node node of postcss AST
188
- * @param selectors selectors used in content files
189
- */
190
- private evaluateRule;
191
- /**
192
- * Get the purged version of the css based on the files
193
- * @param cssOptions css options, files or raw strings
194
- * @param selectors set of extracted css selectors
195
- */
196
- /**
197
- * Get the purged version of the css based on the files
198
- * @param cssOptions css options, files or raw strings
199
- * @param selectors set of extracted css selectors
200
- */
201
- getPurgedCSS(
202
- cssOptions: Array<string | RawCSS>,
203
- selectors: ExtractorResultSets
204
- ): Promise<ResultPurge[]>;
205
- /**
206
- * Check if the keyframe is safelisted with the option safelist keyframes
207
- * @param keyframesName name of the keyframe animation
208
- */
209
- /**
210
- * Check if the keyframe is safelisted with the option safelist keyframes
211
- * @param keyframesName name of the keyframe animation
212
- */
213
- private isKeyframesSafelisted;
214
- /**
215
- * Check if the selector is blocklisted with the option blocklist
216
- * @param selector css selector
217
- */
218
- /**
219
- * Check if the selector is blocklisted with the option blocklist
220
- * @param selector css selector
221
- */
222
- private isSelectorBlocklisted;
223
- /**
224
- * Check if the selector is safelisted with the option safelist standard
225
- * @param selector css selector
226
- */
227
- /**
228
- * Check if the selector is safelisted with the option safelist standard
229
- * @param selector css selector
230
- */
231
- private isSelectorSafelisted;
232
- /**
233
- * Check if the selector is safelisted with the option safelist deep
234
- * @param selector selector
235
- */
236
- /**
237
- * Check if the selector is safelisted with the option safelist deep
238
- * @param selector selector
239
- */
240
- private isSelectorSafelistedDeep;
241
- /**
242
- * Check if the selector is safelisted with the option safelist greedy
243
- * @param selector selector
244
- */
245
- /**
246
- * Check if the selector is safelisted with the option safelist greedy
247
- * @param selector selector
248
- */
249
- private isSelectorSafelistedGreedy;
250
- /**
251
- * Remove unused css
252
- * @param userOptions PurgeCSS options
253
- */
254
- /**
255
- * Remove unused css
256
- * @param userOptions PurgeCSS options
257
- */
258
- purge(
259
- userOptions: UserDefinedOptions | string | undefined
260
- ): Promise<ResultPurge[]>;
261
- /**
262
- * Remove unused CSS variables
263
- */
264
- /**
265
- * Remove unused CSS variables
266
- */
267
- removeUnusedCSSVariables(): void;
268
- /**
269
- * Remove unused font-faces
270
- */
271
- /**
272
- * Remove unused font-faces
273
- */
274
- removeUnusedFontFaces(): void;
275
- /**
276
- * Remove unused keyframes
277
- */
278
- /**
279
- * Remove unused keyframes
280
- */
281
- removeUnusedKeyframes(): void;
282
- /**
283
- * Transform a selector node into a string
284
- */
285
- /**
286
- * Transform a selector node into a string
287
- */
288
- private getSelectorValue;
289
- /**
290
- * Determine if the selector should be kept, based on the selectors found in the files
291
- * @param selector set of css selectors found in the content files or string
292
- * @param selectorsFromExtractor selectors in the css rule
293
- */
294
- /**
295
- * Determine if the selector should be kept, based on the selectors found in the files
296
- * @param selector set of css selectors found in the content files or string
297
- * @param selectorsFromExtractor selectors in the css rule
298
- */
299
- private shouldKeepSelector;
300
- /**
301
- * Walk through the CSS AST and remove unused CSS
302
- * @param root root node of the postcss AST
303
- * @param selectors selectors used in content files
304
- */
305
- /**
306
- * Walk through the CSS AST and remove unused CSS
307
- * @param root root node of the postcss AST
308
- * @param selectors selectors used in content files
309
- */
310
- walkThroughCSS(root: PostCSSRoot, selectors: ExtractorResultSets): void;
311
- }
312
- export {
313
- PurgeCSS as default,
314
- PurgeCSS,
315
- defaultOptions,
316
- PostCSSRoot,
317
- AtRules,
318
- RawContent,
319
- RawCSS,
320
- ExtractorResultDetailed,
321
- ExtractorResult,
322
- ExtractorFunction,
323
- Extractors,
324
- IgnoreType,
325
- StringRegExpArray,
326
- ComplexSafelist,
327
- UserDefinedSafelist,
328
- UserDefinedOptions,
329
- Options,
330
- ResultPurge,
331
- standardizeSafelist,
332
- setOptions,
333
- mergeExtractorSelectors,
334
- };
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 purgecss#Options.content} */
448
+ content: Array<string | RawContent>;
449
+ /** {@inheritDoc purgecss#Options.css} */
450
+ css: Array<string | RawCSS>;
451
+ /** {@inheritDoc purgecss#Options.defaultExtractor} */
452
+ defaultExtractor?: ExtractorFunction;
453
+ /** {@inheritDoc purgecss#Options.extractors} */
454
+ extractors?: Array<Extractors>;
455
+ /** {@inheritDoc purgecss#Options.fontFace} */
456
+ fontFace?: boolean;
457
+ /** {@inheritDoc purgecss#Options.keyframes} */
458
+ keyframes?: boolean;
459
+ /** {@inheritDoc purgecss#Options.output} */
460
+ output?: string;
461
+ /** {@inheritDoc purgecss#Options.rejected} */
462
+ rejected?: boolean;
463
+ /** {@inheritDoc purgecss#Options.rejectedCss} */
464
+ rejectedCss?: boolean;
465
+ /** {@inheritDoc purgecss#Options.sourceMap } */
466
+ sourceMap?: boolean | (postcss.SourceMapOptions & {
467
+ to?: string;
468
+ });
469
+ /** {@inheritDoc purgecss#Options.stdin} */
470
+ stdin?: boolean;
471
+ /** {@inheritDoc purgecss#Options.stdout} */
472
+ stdout?: boolean;
473
+ /** {@inheritDoc purgecss#Options.variables} */
474
+ variables?: boolean;
475
+ /** {@inheritDoc purgecss#Options.safelist} */
476
+ safelist?: UserDefinedSafelist;
477
+ /** {@inheritDoc purgecss#Options.blocklist} */
478
+ blocklist?: StringRegExpArray;
479
+ /** {@inheritDoc purgecss#Options.skippedContentGlobs} */
480
+ skippedContentGlobs?: Array<string>;
481
+ /** {@inheritDoc purgecss#Options.dynamicAttributes} */
482
+ dynamicAttributes?: string[];
483
+ }
484
+
485
+ /**
486
+ * @public
487
+ */
488
+ export declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
489
+
490
+ /**
491
+ * @public
492
+ */
493
+ export declare class VariableNode {
494
+ nodes: VariableNode[];
495
+ value: postcss.Declaration;
496
+ isUsed: boolean;
497
+ constructor(declaration: postcss.Declaration);
498
+ }
499
+
500
+ /**
501
+ * @public
502
+ */
503
+ export declare class VariablesStructure {
504
+ nodes: Map<string, VariableNode[]>;
505
+ usedVariables: Set<string>;
506
+ safelist: StringRegExpArray;
507
+ addVariable(declaration: postcss.Declaration): void;
508
+ addVariableUsage(declaration: postcss.Declaration, matchedVariables: IterableIterator<RegExpMatchArray>): void;
509
+ addVariableUsageInProperties(matchedVariables: IterableIterator<RegExpMatchArray>): void;
510
+ setAsUsed(variableName: string): void;
511
+ removeUnused(): void;
512
+ isVariablesSafelisted(variable: string): boolean;
513
+ }
514
+
515
+ export { }