postcss 8.4.24 → 8.4.26

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/processor.js CHANGED
@@ -7,28 +7,10 @@ let Root = require('./root')
7
7
 
8
8
  class Processor {
9
9
  constructor(plugins = []) {
10
- this.version = '8.4.24'
10
+ this.version = '8.4.26'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
14
- use(plugin) {
15
- this.plugins = this.plugins.concat(this.normalize([plugin]))
16
- return this
17
- }
18
-
19
- process(css, opts = {}) {
20
- if (
21
- this.plugins.length === 0 &&
22
- typeof opts.parser === 'undefined' &&
23
- typeof opts.stringifier === 'undefined' &&
24
- typeof opts.syntax === 'undefined'
25
- ) {
26
- return new NoWorkResult(this, css, opts)
27
- } else {
28
- return new LazyResult(this, css, opts)
29
- }
30
- }
31
-
32
14
  normalize(plugins) {
33
15
  let normalized = []
34
16
  for (let i of plugins) {
@@ -58,6 +40,24 @@ class Processor {
58
40
  }
59
41
  return normalized
60
42
  }
43
+
44
+ process(css, opts = {}) {
45
+ if (
46
+ this.plugins.length === 0 &&
47
+ typeof opts.parser === 'undefined' &&
48
+ typeof opts.stringifier === 'undefined' &&
49
+ typeof opts.syntax === 'undefined'
50
+ ) {
51
+ return new NoWorkResult(this, css, opts)
52
+ } else {
53
+ return new LazyResult(this, css, opts)
54
+ }
55
+ }
56
+
57
+ use(plugin) {
58
+ this.plugins = this.plugins.concat(this.normalize([plugin]))
59
+ return this
60
+ }
61
61
  }
62
62
 
63
63
  module.exports = Processor
package/lib/result.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
- ProcessOptions,
2
+ Document,
3
+ Node,
3
4
  Plugin,
5
+ ProcessOptions,
6
+ Root,
4
7
  SourceMap,
5
8
  TransformCallback,
6
- Root,
7
- Document,
8
- Node,
9
9
  Warning,
10
10
  WarningOptions
11
11
  } from './postcss.js'
@@ -13,17 +13,17 @@ import Processor from './processor.js'
13
13
 
14
14
  declare namespace Result {
15
15
  export interface Message {
16
- /**
17
- * Message type.
18
- */
19
- type: string
16
+ [others: string]: any
20
17
 
21
18
  /**
22
19
  * Source PostCSS plugin name.
23
20
  */
24
21
  plugin?: string
25
22
 
26
- [others: string]: any
23
+ /**
24
+ * Message type.
25
+ */
26
+ type: string
27
27
  }
28
28
 
29
29
  export interface ResultOptions extends ProcessOptions {
@@ -62,17 +62,34 @@ declare namespace Result {
62
62
  */
63
63
  declare class Result_ {
64
64
  /**
65
- * The Processor instance used for this transformation.
65
+ * A CSS string representing of `Result#root`.
66
66
  *
67
67
  * ```js
68
- * for (const plugin of result.processor.plugins) {
69
- * if (plugin.postcssPlugin === 'postcss-bad') {
70
- * throw 'postcss-good is incompatible with postcss-bad'
71
- * }
72
- * })
68
+ * postcss.parse('a{}').toResult().css //=> "a{}"
73
69
  * ```
74
70
  */
75
- processor: Processor
71
+ css: string
72
+
73
+ /**
74
+ * Last runned PostCSS plugin.
75
+ */
76
+ lastPlugin: Plugin | TransformCallback
77
+
78
+ /**
79
+ * An instance of `SourceMapGenerator` class from the `source-map` library,
80
+ * representing changes to the `Result#root` instance.
81
+ *
82
+ * ```js
83
+ * result.map.toJSON() //=> { version: 3, file: 'a.css', … }
84
+ * ```
85
+ *
86
+ * ```js
87
+ * if (result.map) {
88
+ * fs.writeFileSync(result.opts.to + '.map', result.map.toString())
89
+ * }
90
+ * ```
91
+ */
92
+ map: SourceMap
76
93
 
77
94
  /**
78
95
  * Contains messages from plugins (e.g., warnings or custom messages).
@@ -94,15 +111,6 @@ declare class Result_ {
94
111
  */
95
112
  messages: Result.Message[]
96
113
 
97
- /**
98
- * Root node after all transformations.
99
- *
100
- * ```js
101
- * root.toResult().root === root
102
- * ```
103
- */
104
- root: Root | Document
105
-
106
114
  /**
107
115
  * Options from the `Processor#process` or `Root#toResult` call
108
116
  * that produced this Result instance.]
@@ -114,41 +122,33 @@ declare class Result_ {
114
122
  opts: Result.ResultOptions
115
123
 
116
124
  /**
117
- * A CSS string representing of `Result#root`.
125
+ * The Processor instance used for this transformation.
118
126
  *
119
127
  * ```js
120
- * postcss.parse('a{}').toResult().css //=> "a{}"
128
+ * for (const plugin of result.processor.plugins) {
129
+ * if (plugin.postcssPlugin === 'postcss-bad') {
130
+ * throw 'postcss-good is incompatible with postcss-bad'
131
+ * }
132
+ * })
121
133
  * ```
122
134
  */
123
- css: string
135
+ processor: Processor
124
136
 
125
137
  /**
126
- * An instance of `SourceMapGenerator` class from the `source-map` library,
127
- * representing changes to the `Result#root` instance.
128
- *
129
- * ```js
130
- * result.map.toJSON() //=> { version: 3, file: 'a.css', … }
131
- * ```
138
+ * Root node after all transformations.
132
139
  *
133
140
  * ```js
134
- * if (result.map) {
135
- * fs.writeFileSync(result.opts.to + '.map', result.map.toString())
136
- * }
141
+ * root.toResult().root === root
137
142
  * ```
138
143
  */
139
- map: SourceMap
140
-
141
- /**
142
- * Last runned PostCSS plugin.
143
- */
144
- lastPlugin: Plugin | TransformCallback
144
+ root: Document | Root
145
145
 
146
146
  /**
147
147
  * @param processor Processor used for this transformation.
148
148
  * @param root Root node after all transformations.
149
149
  * @param opts Options from the `Processor#process` or `Root#toResult`.
150
150
  */
151
- constructor(processor: Processor, root: Root | Document, opts: Result.ResultOptions)
151
+ constructor(processor: Processor, root: Document | Root, opts: Result.ResultOptions)
152
152
 
153
153
  /**
154
154
  * An alias for the `Result#css` property.
package/lib/result.js CHANGED
@@ -12,6 +12,10 @@ class Result {
12
12
  this.map = undefined
13
13
  }
14
14
 
15
+ get content() {
16
+ return this.css
17
+ }
18
+
15
19
  toString() {
16
20
  return this.css
17
21
  }
@@ -32,10 +36,6 @@ class Result {
32
36
  warnings() {
33
37
  return this.messages.filter(i => i.type === 'warning')
34
38
  }
35
-
36
- get content() {
37
- return this.css
38
- }
39
39
  }
40
40
 
41
41
  module.exports = Result
package/lib/root.d.ts CHANGED
@@ -11,20 +11,20 @@ declare namespace Root {
11
11
  after?: string
12
12
 
13
13
  /**
14
- * Non-CSS code before `Root`, when `Root` is inside `Document`.
14
+ * Non-CSS code after `Root`, when `Root` is inside `Document`.
15
15
  *
16
16
  * **Experimental:** some aspects of this node could change within minor
17
17
  * or patch version releases.
18
18
  */
19
- codeBefore?: string
19
+ codeAfter?: string
20
20
 
21
21
  /**
22
- * Non-CSS code after `Root`, when `Root` is inside `Document`.
22
+ * Non-CSS code before `Root`, when `Root` is inside `Document`.
23
23
  *
24
24
  * **Experimental:** some aspects of this node could change within minor
25
25
  * or patch version releases.
26
26
  */
27
- codeAfter?: string
27
+ codeBefore?: string
28
28
 
29
29
  /**
30
30
  * Is the last child has an (optional) semicolon.
@@ -54,9 +54,16 @@ declare namespace Root {
54
54
  * ```
55
55
  */
56
56
  declare class Root_ extends Container {
57
- type: 'root'
58
57
  parent: Document | undefined
59
58
  raws: Root.RootRaws
59
+ type: 'root'
60
+
61
+ constructor(defaults?: Root.RootProps)
62
+
63
+ assign(overrides: object | Root.RootProps): this
64
+ clone(overrides?: Partial<Root.RootProps>): Root
65
+ cloneAfter(overrides?: Partial<Root.RootProps>): Root
66
+ cloneBefore(overrides?: Partial<Root.RootProps>): Root
60
67
 
61
68
  /**
62
69
  * Returns a `Result` instance representing the root’s CSS.
@@ -71,10 +78,7 @@ declare class Root_ extends Container {
71
78
  * @param opts Options.
72
79
  * @return Result with current root’s CSS.
73
80
  */
74
- toResult(options?: ProcessOptions): Result
75
-
76
- constructor(defaults?: Root.RootProps)
77
- assign(overrides: object | Root.RootProps): this
81
+ toResult(options?: ProcessOptions): Result
78
82
  }
79
83
 
80
84
  declare class Root extends Root_ {}
package/lib/root.js CHANGED
@@ -11,16 +11,6 @@ class Root extends Container {
11
11
  if (!this.nodes) this.nodes = []
12
12
  }
13
13
 
14
- removeChild(child, ignore) {
15
- let index = this.index(child)
16
-
17
- if (!ignore && index === 0 && this.nodes.length > 1) {
18
- this.nodes[1].raws.before = this.nodes[index].raws.before
19
- }
20
-
21
- return super.removeChild(child)
22
- }
23
-
24
14
  normalize(child, sample, type) {
25
15
  let nodes = super.normalize(child)
26
16
 
@@ -41,6 +31,16 @@ class Root extends Container {
41
31
  return nodes
42
32
  }
43
33
 
34
+ removeChild(child, ignore) {
35
+ let index = this.index(child)
36
+
37
+ if (!ignore && index === 0 && this.nodes.length > 1) {
38
+ this.nodes[1].raws.before = this.nodes[index].raws.before
39
+ }
40
+
41
+ return super.removeChild(child)
42
+ }
43
+
44
44
  toResult(opts = {}) {
45
45
  let lazy = new LazyResult(new Processor(), this, opts)
46
46
  return lazy.stringify()
package/lib/rule.d.ts CHANGED
@@ -2,26 +2,21 @@ import Container, { ContainerProps } from './container.js'
2
2
 
3
3
  declare namespace Rule {
4
4
  export interface RuleRaws extends Record<string, unknown> {
5
- /**
6
- * The space symbols before the node. It also stores `*`
7
- * and `_` symbols before the declaration (IE hack).
8
- */
9
- before?: string
10
-
11
5
  /**
12
6
  * The space symbols after the last child of the node to the end of the node.
13
7
  */
14
8
  after?: string
15
9
 
16
10
  /**
17
- * The symbols between the selector and `{` for rules.
11
+ * The space symbols before the node. It also stores `*`
12
+ * and `_` symbols before the declaration (IE hack).
18
13
  */
19
- between?: string
14
+ before?: string
20
15
 
21
16
  /**
22
- * Contains `true` if the last child has an (optional) semicolon.
17
+ * The symbols between the selector and `{` for rules.
23
18
  */
24
- semicolon?: boolean
19
+ between?: string
25
20
 
26
21
  /**
27
22
  * Contains `true` if there is semicolon after rule.
@@ -32,18 +27,23 @@ declare namespace Rule {
32
27
  * The rule’s selector with comments.
33
28
  */
34
29
  selector?: {
35
- value: string
36
30
  raw: string
31
+ value: string
37
32
  }
33
+
34
+ /**
35
+ * Contains `true` if the last child has an (optional) semicolon.
36
+ */
37
+ semicolon?: boolean
38
38
  }
39
39
 
40
40
  export interface RuleProps extends ContainerProps {
41
+ /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
42
+ raws?: RuleRaws
41
43
  /** Selector or selectors of the rule. */
42
44
  selector?: string
43
45
  /** Selectors of the rule represented as an array of strings. */
44
46
  selectors?: string[]
45
- /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
46
- raws?: RuleRaws
47
47
  }
48
48
 
49
49
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
@@ -69,10 +69,8 @@ declare namespace Rule {
69
69
  * ```
70
70
  */
71
71
  declare class Rule_ extends Container {
72
- type: 'rule'
73
72
  parent: Container | undefined
74
73
  raws: Rule.RuleRaws
75
-
76
74
  /**
77
75
  * The rule’s full selector represented as a string.
78
76
  *
@@ -101,11 +99,13 @@ declare class Rule_ extends Container {
101
99
  */
102
100
  selectors: string[]
103
101
 
102
+ type: 'rule'
103
+
104
104
  constructor(defaults?: Rule.RuleProps)
105
105
  assign(overrides: object | Rule.RuleProps): this
106
- clone(overrides?: Partial<Rule.RuleProps>): this
107
- cloneBefore(overrides?: Partial<Rule.RuleProps>): this
108
- cloneAfter(overrides?: Partial<Rule.RuleProps>): this
106
+ clone(overrides?: Partial<Rule.RuleProps>): Rule
107
+ cloneAfter(overrides?: Partial<Rule.RuleProps>): Rule
108
+ cloneBefore(overrides?: Partial<Rule.RuleProps>): Rule
109
109
  }
110
110
 
111
111
  declare class Rule extends Rule_ {}
@@ -1,13 +1,13 @@
1
1
  import {
2
- Document,
3
- Root,
4
- Comment,
5
- Declaration,
6
- Builder,
7
2
  AnyNode,
8
- Rule,
9
3
  AtRule,
10
- Container
4
+ Builder,
5
+ Comment,
6
+ Container,
7
+ Declaration,
8
+ Document,
9
+ Root,
10
+ Rule
11
11
  } from './postcss.js'
12
12
 
13
13
  declare namespace Stringifier {
@@ -18,27 +18,27 @@ declare namespace Stringifier {
18
18
  declare class Stringifier_ {
19
19
  builder: Builder
20
20
  constructor(builder: Builder)
21
- stringify(node: AnyNode, semicolon?: boolean): void
22
- document(node: Document): void
23
- root(node: Root): void
24
- comment(node: Comment): void
25
- decl(node: Declaration, semicolon?: boolean): void
26
- rule(node: Rule): void
27
21
  atrule(node: AtRule, semicolon?: boolean): void
28
- body(node: Container): void
22
+ beforeAfter(node: AnyNode, detect: 'after' | 'before'): string
29
23
  block(node: AnyNode, start: string): void
30
- raw(node: AnyNode, own: string | null, detect?: string): string
31
- rawSemicolon(root: Root): boolean | undefined
32
- rawEmptyBody(root: Root): string | undefined
33
- rawIndent(root: Root): string | undefined
24
+ body(node: Container): void
25
+ comment(node: Comment): void
26
+ decl(node: Declaration, semicolon?: boolean): void
27
+ document(node: Document): void
28
+ raw(node: AnyNode, own: null | string, detect?: string): string
29
+ rawBeforeClose(root: Root): string | undefined
34
30
  rawBeforeComment(root: Root, node: Comment): string | undefined
35
31
  rawBeforeDecl(root: Root, node: Declaration): string | undefined
36
- rawBeforeRule(root: Root): string | undefined
37
- rawBeforeClose(root: Root): string | undefined
38
32
  rawBeforeOpen(root: Root): string | undefined
33
+ rawBeforeRule(root: Root): string | undefined
39
34
  rawColon(root: Root): string | undefined
40
- beforeAfter(node: AnyNode, detect: 'before' | 'after'): string
35
+ rawEmptyBody(root: Root): string | undefined
36
+ rawIndent(root: Root): string | undefined
37
+ rawSemicolon(root: Root): boolean | undefined
41
38
  rawValue(node: AnyNode, prop: string): string
39
+ root(node: Root): void
40
+ rule(node: Rule): void
41
+ stringify(node: AnyNode, semicolon?: boolean): void
42
42
  }
43
43
 
44
44
  declare class Stringifier extends Stringifier_ {}