postcss 8.4.21 → 8.4.22

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.

Potentially problematic release.


This version of postcss might be problematic. Click here for more details.

package/lib/postcss.d.ts CHANGED
@@ -20,65 +20,24 @@ import Result, { Message } from './result.js'
20
20
  import Root, { RootProps } from './root.js'
21
21
  import Rule, { RuleProps } from './rule.js'
22
22
  import CssSyntaxError from './css-syntax-error.js'
23
- import list, { List } from './list.js'
23
+ import list from './list.js'
24
24
  import LazyResult from './lazy-result.js'
25
25
  import Processor from './processor.js'
26
26
 
27
- export {
28
- NodeErrorOptions,
29
- DeclarationProps,
30
- CssSyntaxError,
31
- ContainerProps,
32
- WarningOptions,
33
- DocumentProps,
34
- FilePosition,
35
- CommentProps,
36
- AtRuleProps,
37
- Declaration,
38
- ChildProps,
39
- LazyResult,
40
- ChildNode,
41
- NodeProps,
42
- Processor,
43
- RuleProps,
44
- RootProps,
45
- Container,
46
- Position,
47
- Document,
48
- AnyNode,
49
- Warning,
50
- Message,
51
- Comment,
52
- Source,
53
- AtRule,
54
- Result,
55
- Input,
56
- Node,
57
- list,
58
- Rule,
59
- Root
60
- }
61
-
62
- export type SourceMap = SourceMapGenerator & {
63
- toJSON(): RawSourceMap
64
- }
65
-
66
- export type Helpers = { result: Result; postcss: Postcss } & Postcss
67
-
68
27
  type DocumentProcessor = (
69
28
  document: Document,
70
- helper: Helpers
29
+ helper: postcss.Helpers
71
30
  ) => Promise<void> | void
72
- type RootProcessor = (root: Root, helper: Helpers) => Promise<void> | void
31
+ type RootProcessor = (root: Root, helper: postcss.Helpers) => Promise<void> | void
73
32
  type DeclarationProcessor = (
74
33
  decl: Declaration,
75
- helper: Helpers
34
+ helper: postcss.Helpers
76
35
  ) => Promise<void> | void
77
- type RuleProcessor = (rule: Rule, helper: Helpers) => Promise<void> | void
78
- type AtRuleProcessor = (atRule: AtRule, helper: Helpers) => Promise<void> | void
36
+ type RuleProcessor = (rule: Rule, helper: postcss.Helpers) => Promise<void> | void
37
+ type AtRuleProcessor = (atRule: AtRule, helper: postcss.Helpers) => Promise<void> | void
79
38
  type CommentProcessor = (
80
39
  comment: Comment,
81
- helper: Helpers
40
+ helper: postcss.Helpers
82
41
  ) => Promise<void> | void
83
42
 
84
43
  interface Processors {
@@ -188,185 +147,210 @@ interface Processors {
188
147
  Exit?: RootProcessor
189
148
  }
190
149
 
191
- export interface Plugin extends Processors {
192
- postcssPlugin: string
193
- prepare?: (result: Result) => Processors
194
- }
195
-
196
- export interface PluginCreator<PluginOptions> {
197
- (opts?: PluginOptions): Plugin | Processor
198
- postcss: true
199
- }
200
-
201
- export interface Transformer extends TransformCallback {
202
- postcssPlugin: string
203
- postcssVersion: string
204
- }
205
-
206
- export interface TransformCallback {
207
- (root: Root, result: Result): Promise<void> | void
208
- }
209
-
210
- export interface OldPlugin<T> extends Transformer {
211
- (opts?: T): Transformer
212
- postcss: Transformer
213
- }
214
-
215
- export type AcceptedPlugin =
216
- | Plugin
217
- | PluginCreator<any>
218
- | OldPlugin<any>
219
- | TransformCallback
220
- | {
221
- postcss: TransformCallback | Processor
222
- }
223
- | Processor
224
-
225
- export interface Parser<RootNode = Root | Document> {
226
- (
227
- css: string | { toString(): string },
228
- opts?: Pick<ProcessOptions, 'map' | 'from'>
229
- ): RootNode
230
- }
231
-
232
- export interface Builder {
233
- (part: string, node?: AnyNode, type?: 'start' | 'end'): void
234
- }
235
-
236
- export interface Stringifier {
237
- (node: AnyNode, builder: Builder): void
238
- }
239
-
240
- export interface JSONHydrator {
241
- (data: object[]): Node[]
242
- (data: object): Node
243
- }
244
-
245
- export interface Syntax {
246
- /**
247
- * Function to generate AST by string.
248
- */
249
- parse?: Parser
250
-
251
- /**
252
- * Class to generate string by AST.
253
- */
254
- stringify?: Stringifier
255
- }
256
-
257
- export interface SourceMapOptions {
258
- /**
259
- * Indicates that the source map should be embedded in the output CSS
260
- * as a Base64-encoded comment. By default, it is `true`.
261
- * But if all previous maps are external, not inline, PostCSS will not embed
262
- * the map even if you do not set this option.
263
- *
264
- * If you have an inline source map, the result.map property will be empty,
265
- * as the source map will be contained within the text of `result.css`.
266
- */
267
- inline?: boolean
268
-
269
- /**
270
- * Source map content from a previous processing step (e.g., Sass).
271
- *
272
- * PostCSS will try to read the previous source map
273
- * automatically (based on comments within the source CSS), but you can use
274
- * this option to identify it manually.
275
- *
276
- * If desired, you can omit the previous map with prev: `false`.
277
- */
278
- prev?: string | boolean | object | ((file: string) => string)
279
-
280
- /**
281
- * Indicates that PostCSS should set the origin content (e.g., Sass source)
282
- * of the source map. By default, it is true. But if all previous maps do not
283
- * contain sources content, PostCSS will also leave it out even if you
284
- * do not set this option.
285
- */
286
- sourcesContent?: boolean
287
-
288
- /**
289
- * Indicates that PostCSS should add annotation comments to the CSS.
290
- * By default, PostCSS will always add a comment with a path
291
- * to the source map. PostCSS will not add annotations to CSS files
292
- * that do not contain any comments.
293
- *
294
- * By default, PostCSS presumes that you want to save the source map as
295
- * `opts.to + '.map'` and will use this path in the annotation comment.
296
- * A different path can be set by providing a string value for annotation.
297
- *
298
- * If you have set `inline: true`, annotation cannot be disabled.
299
- */
300
- annotation?: string | boolean | ((file: string, root: Root) => string)
301
-
302
- /**
303
- * Override `from` in map’s sources.
304
- */
305
- from?: string
306
-
307
- /**
308
- * Use absolute path in generated source map.
309
- */
310
- absolute?: boolean
311
- }
312
-
313
- export interface ProcessOptions {
314
- /**
315
- * The path of the CSS source file. You should always set `from`,
316
- * because it is used in source map generation and syntax error messages.
317
- */
318
- from?: string
319
-
320
- /**
321
- * The path where you'll put the output CSS file. You should always set `to`
322
- * to generate correct source maps.
323
- */
324
- to?: string
325
-
326
- /**
327
- * Function to generate AST by string.
328
- */
329
- parser?: Syntax | Parser
330
-
331
- /**
332
- * Class to generate string by AST.
333
- */
334
- stringifier?: Syntax | Stringifier
335
-
336
- /**
337
- * Object with parse and stringify.
338
- */
339
- syntax?: Syntax
340
-
341
- /**
342
- * Source map options
343
- */
344
- map?: SourceMapOptions | boolean
345
- }
346
-
347
- export interface Postcss {
348
- /**
349
- * Create a new `Processor` instance that will apply `plugins`
350
- * as CSS processors.
351
- *
352
- * ```js
353
- * let postcss = require('postcss')
354
- *
355
- * postcss(plugins).process(css, { from, to }).then(result => {
356
- * console.log(result.css)
357
- * })
358
- * ```
359
- *
360
- * @param plugins PostCSS plugins.
361
- * @return Processor to process multiple CSS.
362
- */
363
- (plugins?: AcceptedPlugin[]): Processor
364
- (...plugins: AcceptedPlugin[]): Processor
150
+ declare namespace postcss {
151
+ export {
152
+ NodeErrorOptions,
153
+ DeclarationProps,
154
+ CssSyntaxError,
155
+ ContainerProps,
156
+ WarningOptions,
157
+ DocumentProps,
158
+ FilePosition,
159
+ CommentProps,
160
+ AtRuleProps,
161
+ Declaration,
162
+ ChildProps,
163
+ LazyResult,
164
+ ChildNode,
165
+ NodeProps,
166
+ Processor,
167
+ RuleProps,
168
+ RootProps,
169
+ Container,
170
+ Position,
171
+ Document,
172
+ AnyNode,
173
+ Warning,
174
+ Message,
175
+ Comment,
176
+ Source,
177
+ AtRule,
178
+ Result,
179
+ Input,
180
+ Node,
181
+ list,
182
+ Rule,
183
+ Root
184
+ }
185
+
186
+ export type SourceMap = SourceMapGenerator & {
187
+ toJSON(): RawSourceMap
188
+ }
189
+
190
+ export type Helpers = { result: Result; postcss: Postcss } & Postcss
191
+
192
+ export interface Plugin extends Processors {
193
+ postcssPlugin: string
194
+ prepare?: (result: Result) => Processors
195
+ }
196
+
197
+ export interface PluginCreator<PluginOptions> {
198
+ (opts?: PluginOptions): Plugin | Processor
199
+ postcss: true
200
+ }
201
+
202
+ export interface Transformer extends TransformCallback {
203
+ postcssPlugin: string
204
+ postcssVersion: string
205
+ }
206
+
207
+ export interface TransformCallback {
208
+ (root: Root, result: Result): Promise<void> | void
209
+ }
210
+
211
+ export interface OldPlugin<T> extends Transformer {
212
+ (opts?: T): Transformer
213
+ postcss: Transformer
214
+ }
215
+
216
+ export type AcceptedPlugin =
217
+ | Plugin
218
+ | PluginCreator<any>
219
+ | OldPlugin<any>
220
+ | TransformCallback
221
+ | {
222
+ postcss: TransformCallback | Processor
223
+ }
224
+ | Processor
225
+
226
+ export interface Parser<RootNode = Root | Document> {
227
+ (
228
+ css: string | { toString(): string },
229
+ opts?: Pick<ProcessOptions, 'map' | 'from'>
230
+ ): RootNode
231
+ }
232
+
233
+ export interface Builder {
234
+ (part: string, node?: AnyNode, type?: 'start' | 'end'): void
235
+ }
236
+
237
+ export interface Stringifier {
238
+ (node: AnyNode, builder: Builder): void
239
+ }
240
+
241
+ export interface JSONHydrator {
242
+ (data: object[]): Node[]
243
+ (data: object): Node
244
+ }
245
+
246
+ export interface Syntax {
247
+ /**
248
+ * Function to generate AST by string.
249
+ */
250
+ parse?: Parser
251
+
252
+ /**
253
+ * Class to generate string by AST.
254
+ */
255
+ stringify?: Stringifier
256
+ }
257
+
258
+ export interface SourceMapOptions {
259
+ /**
260
+ * Indicates that the source map should be embedded in the output CSS
261
+ * as a Base64-encoded comment. By default, it is `true`.
262
+ * But if all previous maps are external, not inline, PostCSS will not embed
263
+ * the map even if you do not set this option.
264
+ *
265
+ * If you have an inline source map, the result.map property will be empty,
266
+ * as the source map will be contained within the text of `result.css`.
267
+ */
268
+ inline?: boolean
269
+
270
+ /**
271
+ * Source map content from a previous processing step (e.g., Sass).
272
+ *
273
+ * PostCSS will try to read the previous source map
274
+ * automatically (based on comments within the source CSS), but you can use
275
+ * this option to identify it manually.
276
+ *
277
+ * If desired, you can omit the previous map with prev: `false`.
278
+ */
279
+ prev?: string | boolean | object | ((file: string) => string)
280
+
281
+ /**
282
+ * Indicates that PostCSS should set the origin content (e.g., Sass source)
283
+ * of the source map. By default, it is true. But if all previous maps do not
284
+ * contain sources content, PostCSS will also leave it out even if you
285
+ * do not set this option.
286
+ */
287
+ sourcesContent?: boolean
288
+
289
+ /**
290
+ * Indicates that PostCSS should add annotation comments to the CSS.
291
+ * By default, PostCSS will always add a comment with a path
292
+ * to the source map. PostCSS will not add annotations to CSS files
293
+ * that do not contain any comments.
294
+ *
295
+ * By default, PostCSS presumes that you want to save the source map as
296
+ * `opts.to + '.map'` and will use this path in the annotation comment.
297
+ * A different path can be set by providing a string value for annotation.
298
+ *
299
+ * If you have set `inline: true`, annotation cannot be disabled.
300
+ */
301
+ annotation?: string | boolean | ((file: string, root: Root) => string)
302
+
303
+ /**
304
+ * Override `from` in map’s sources.
305
+ */
306
+ from?: string
307
+
308
+ /**
309
+ * Use absolute path in generated source map.
310
+ */
311
+ absolute?: boolean
312
+ }
313
+
314
+ export interface ProcessOptions {
315
+ /**
316
+ * The path of the CSS source file. You should always set `from`,
317
+ * because it is used in source map generation and syntax error messages.
318
+ */
319
+ from?: string
320
+
321
+ /**
322
+ * The path where you'll put the output CSS file. You should always set `to`
323
+ * to generate correct source maps.
324
+ */
325
+ to?: string
326
+
327
+ /**
328
+ * Function to generate AST by string.
329
+ */
330
+ parser?: Syntax | Parser
331
+
332
+ /**
333
+ * Class to generate string by AST.
334
+ */
335
+ stringifier?: Syntax | Stringifier
336
+
337
+ /**
338
+ * Object with parse and stringify.
339
+ */
340
+ syntax?: Syntax
341
+
342
+ /**
343
+ * Source map options
344
+ */
345
+ map?: SourceMapOptions | boolean
346
+ }
347
+
348
+ export type Postcss = typeof postcss
365
349
 
366
350
  /**
367
351
  * Default function to convert a node tree into a CSS string.
368
352
  */
369
- stringify: Stringifier
353
+ export let stringify: Stringifier
370
354
 
371
355
  /**
372
356
  * Parses source css and returns a new `Root` or `Document` node,
@@ -379,7 +363,7 @@ export interface Postcss {
379
363
  * root1.append(root2).toResult().css
380
364
  * ```
381
365
  */
382
- parse: Parser<Root>
366
+ export let parse: Parser<Root>
383
367
 
384
368
  /**
385
369
  * Rehydrate a JSON AST (from `Node#toJSON`) back into the AST classes.
@@ -390,12 +374,7 @@ export interface Postcss {
390
374
  * const root2 = postcss.fromJSON(json)
391
375
  * ```
392
376
  */
393
- fromJSON: JSONHydrator
394
-
395
- /**
396
- * Contains the `list` module.
397
- */
398
- list: List
377
+ export let fromJSON: JSONHydrator
399
378
 
400
379
  /**
401
380
  * Creates a new `Comment` node.
@@ -403,7 +382,7 @@ export interface Postcss {
403
382
  * @param defaults Properties for the new node.
404
383
  * @return New comment node
405
384
  */
406
- comment(defaults?: CommentProps): Comment
385
+ export function comment(defaults?: CommentProps): Comment
407
386
 
408
387
  /**
409
388
  * Creates a new `AtRule` node.
@@ -411,7 +390,7 @@ export interface Postcss {
411
390
  * @param defaults Properties for the new node.
412
391
  * @return New at-rule node.
413
392
  */
414
- atRule(defaults?: AtRuleProps): AtRule
393
+ export function atRule(defaults?: AtRuleProps): AtRule
415
394
 
416
395
  /**
417
396
  * Creates a new `Declaration` node.
@@ -419,7 +398,7 @@ export interface Postcss {
419
398
  * @param defaults Properties for the new node.
420
399
  * @return New declaration node.
421
400
  */
422
- decl(defaults?: DeclarationProps): Declaration
401
+ export function decl(defaults?: DeclarationProps): Declaration
423
402
 
424
403
  /**
425
404
  * Creates a new `Rule` node.
@@ -427,7 +406,7 @@ export interface Postcss {
427
406
  * @param default Properties for the new node.
428
407
  * @return New rule node.
429
408
  */
430
- rule(defaults?: RuleProps): Rule
409
+ export function rule(defaults?: RuleProps): Rule
431
410
 
432
411
  /**
433
412
  * Creates a new `Root` node.
@@ -435,7 +414,7 @@ export interface Postcss {
435
414
  * @param defaults Properties for the new node.
436
415
  * @return New root node.
437
416
  */
438
- root(defaults?: RootProps): Root
417
+ export function root(defaults?: RootProps): Root
439
418
 
440
419
  /**
441
420
  * Creates a new `Document` node.
@@ -443,31 +422,27 @@ export interface Postcss {
443
422
  * @param defaults Properties for the new node.
444
423
  * @return New document node.
445
424
  */
446
- document(defaults?: DocumentProps): Document
447
-
448
- CssSyntaxError: typeof CssSyntaxError
449
- Declaration: typeof Declaration
450
- Container: typeof Container
451
- Comment: typeof Comment
452
- Warning: typeof Warning
453
- AtRule: typeof AtRule
454
- Result: typeof Result
455
- Input: typeof Input
456
- Rule: typeof Rule
457
- Root: typeof Root
458
- Node: typeof Node
459
- }
460
-
461
- export const stringify: Stringifier
462
- export const parse: Parser<Root>
463
- export const fromJSON: JSONHydrator
425
+ export function document(defaults?: DocumentProps): Document
464
426
 
465
- export const comment: Postcss['comment']
466
- export const atRule: Postcss['atRule']
467
- export const decl: Postcss['decl']
468
- export const rule: Postcss['rule']
469
- export const root: Postcss['root']
470
-
471
- declare const postcss: Postcss
427
+ export { postcss as default }
428
+ }
472
429
 
473
- export default postcss
430
+ /**
431
+ * Create a new `Processor` instance that will apply `plugins`
432
+ * as CSS processors.
433
+ *
434
+ * ```js
435
+ * let postcss = require('postcss')
436
+ *
437
+ * postcss(plugins).process(css, { from, to }).then(result => {
438
+ * console.log(result.css)
439
+ * })
440
+ * ```
441
+ *
442
+ * @param plugins PostCSS plugins.
443
+ * @return Processor to process multiple CSS.
444
+ */
445
+ declare function postcss(plugins?: postcss.AcceptedPlugin[]): Processor
446
+ declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
447
+
448
+ export = postcss
@@ -2,6 +2,11 @@ import { SourceMapConsumer } from 'source-map-js'
2
2
 
3
3
  import { ProcessOptions } from './postcss.js'
4
4
 
5
+ declare namespace PreviousMap {
6
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
7
+ export { PreviousMap_ as default }
8
+ }
9
+
5
10
  /**
6
11
  * Source map information from input CSS.
7
12
  * For example, source map after Sass compiler.
@@ -14,7 +19,7 @@ import { ProcessOptions } from './postcss.js'
14
19
  * root.input.map //=> PreviousMap
15
20
  * ```
16
21
  */
17
- export default class PreviousMap {
22
+ declare class PreviousMap_ {
18
23
  /**
19
24
  * Was source map inlined by data-uri to input CSS.
20
25
  */
@@ -70,3 +75,7 @@ export default class PreviousMap {
70
75
  */
71
76
  withContent(): boolean
72
77
  }
78
+
79
+ declare class PreviousMap extends PreviousMap_ {}
80
+
81
+ export = PreviousMap
@@ -10,6 +10,11 @@ import Result from './result.js'
10
10
  import Root from './root.js'
11
11
  import NoWorkResult from './no-work-result.js'
12
12
 
13
+ declare namespace Processor {
14
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
15
+ export { Processor_ as default }
16
+ }
17
+
13
18
  /**
14
19
  * Contains plugins to process CSS. Create one `Processor` instance,
15
20
  * initialize its plugins, and then use that instance on numerous CSS files.
@@ -20,7 +25,7 @@ import NoWorkResult from './no-work-result.js'
20
25
  * processor.process(css2).then(result => console.log(result.css))
21
26
  * ```
22
27
  */
23
- export default class Processor {
28
+ declare class Processor_ {
24
29
  /**
25
30
  * Current PostCSS version.
26
31
  *
@@ -100,3 +105,7 @@ export default class Processor {
100
105
  options?: ProcessOptions
101
106
  ): LazyResult | NoWorkResult
102
107
  }
108
+
109
+ declare class Processor extends Processor_ {}
110
+
111
+ export = Processor
package/lib/processor.js CHANGED
@@ -7,7 +7,7 @@ let Root = require('./root')
7
7
 
8
8
  class Processor {
9
9
  constructor(plugins = []) {
10
- this.version = '8.4.21'
10
+ this.version = '8.4.22'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13