postcss 8.4.23 → 8.4.25
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/at-rule.d.ts +19 -19
- package/lib/comment.d.ts +12 -10
- package/lib/container.d.ts +212 -212
- package/lib/container.js +239 -239
- package/lib/css-syntax-error.d.ts +95 -95
- package/lib/css-syntax-error.js +1 -1
- package/lib/declaration.d.ts +55 -42
- package/lib/document.d.ts +1 -1
- package/lib/input.d.ts +70 -70
- package/lib/input.js +64 -64
- package/lib/lazy-result.d.ts +54 -54
- package/lib/lazy-result.js +226 -226
- package/lib/list.d.ts +14 -14
- package/lib/list.js +9 -9
- package/lib/map-generator.js +188 -188
- package/lib/no-work-result.d.ts +12 -12
- package/lib/no-work-result.js +30 -30
- package/lib/node.d.ts +277 -230
- package/lib/node.js +201 -199
- package/lib/parser.js +286 -286
- package/lib/postcss.d.ts +122 -129
- package/lib/previous-map.d.ts +13 -13
- package/lib/previous-map.js +33 -33
- package/lib/processor.d.ts +37 -37
- package/lib/processor.js +19 -19
- package/lib/result.d.ts +44 -44
- package/lib/result.js +4 -4
- package/lib/root.d.ts +8 -8
- package/lib/root.js +10 -10
- package/lib/rule.d.ts +16 -16
- package/lib/stringifier.d.ts +21 -21
- package/lib/stringifier.js +139 -139
- package/lib/terminal-highlight.js +11 -11
- package/lib/tokenize.js +1 -1
- package/lib/warning.d.ts +38 -38
- package/lib/warning.js +1 -1
- package/package.json +1 -1
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.
|
10
|
+
this.version = '8.4.25'
|
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
|
-
|
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
|
-
|
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
|
-
*
|
65
|
+
* A CSS string representing of `Result#root`.
|
66
66
|
*
|
67
67
|
* ```js
|
68
|
-
*
|
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
|
-
|
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
|
-
*
|
125
|
+
* The Processor instance used for this transformation.
|
118
126
|
*
|
119
127
|
* ```js
|
120
|
-
*
|
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
|
-
|
135
|
+
processor: Processor
|
124
136
|
|
125
137
|
/**
|
126
|
-
*
|
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
|
-
*
|
135
|
-
* fs.writeFileSync(result.opts.to + '.map', result.map.toString())
|
136
|
-
* }
|
141
|
+
* root.toResult().root === root
|
137
142
|
* ```
|
138
143
|
*/
|
139
|
-
|
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:
|
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
|
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
|
-
|
19
|
+
codeAfter?: string
|
20
20
|
|
21
21
|
/**
|
22
|
-
* Non-CSS code
|
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
|
-
|
27
|
+
codeBefore?: string
|
28
28
|
|
29
29
|
/**
|
30
30
|
* Is the last child has an (optional) semicolon.
|
@@ -54,10 +54,13 @@ 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)
|
60
62
|
|
63
|
+
assign(overrides: object | Root.RootProps): this
|
61
64
|
/**
|
62
65
|
* Returns a `Result` instance representing the root’s CSS.
|
63
66
|
*
|
@@ -72,9 +75,6 @@ declare class Root_ extends Container {
|
|
72
75
|
* @return Result with current root’s CSS.
|
73
76
|
*/
|
74
77
|
toResult(options?: ProcessOptions): Result
|
75
|
-
|
76
|
-
constructor(defaults?: Root.RootProps)
|
77
|
-
assign(overrides: object | Root.RootProps): this
|
78
78
|
}
|
79
79
|
|
80
80
|
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
|
11
|
+
* The space symbols before the node. It also stores `*`
|
12
|
+
* and `_` symbols before the declaration (IE hack).
|
18
13
|
*/
|
19
|
-
|
14
|
+
before?: string
|
20
15
|
|
21
16
|
/**
|
22
|
-
*
|
17
|
+
* The symbols between the selector and `{` for rules.
|
23
18
|
*/
|
24
|
-
|
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
106
|
clone(overrides?: Partial<Rule.RuleProps>): this
|
107
|
-
cloneBefore(overrides?: Partial<Rule.RuleProps>): this
|
108
107
|
cloneAfter(overrides?: Partial<Rule.RuleProps>): this
|
108
|
+
cloneBefore(overrides?: Partial<Rule.RuleProps>): this
|
109
109
|
}
|
110
110
|
|
111
111
|
declare class Rule extends Rule_ {}
|
package/lib/stringifier.d.ts
CHANGED
@@ -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
|
-
|
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
|
-
|
22
|
+
beforeAfter(node: AnyNode, detect: 'after' | 'before'): string
|
29
23
|
block(node: AnyNode, start: string): void
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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_ {}
|