postcss 8.5.2 → 8.5.3
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/at-rule.d.ts +9 -9
- package/lib/comment.d.ts +7 -7
- package/lib/container.d.ts +45 -48
- package/lib/container.js +10 -10
- package/lib/declaration.d.ts +9 -9
- package/lib/declaration.js +4 -4
- package/lib/input.d.ts +15 -17
- package/lib/input.js +4 -4
- package/lib/lazy-result.d.ts +40 -40
- package/lib/lazy-result.js +32 -32
- package/lib/no-work-result.d.ts +5 -5
- package/lib/no-work-result.js +50 -50
- package/lib/node.d.ts +8 -8
- package/lib/node.js +4 -4
- package/lib/parser.js +1 -1
- package/lib/postcss.d.mts +33 -33
- package/lib/processor.js +1 -1
- package/lib/result.d.ts +10 -10
- package/lib/result.js +4 -4
- package/lib/rule.d.ts +8 -8
- package/lib/rule.js +6 -6
- package/package.json +1 -1
package/lib/at-rule.d.ts
CHANGED
@@ -97,19 +97,11 @@ declare class AtRule_ extends Container {
|
|
97
97
|
* layer.nodes //=> undefined
|
98
98
|
* ```
|
99
99
|
*/
|
100
|
-
nodes: Container['nodes']
|
100
|
+
nodes: Container['nodes'] | undefined
|
101
101
|
parent: ContainerWithChildren | undefined
|
102
102
|
|
103
103
|
raws: AtRule.AtRuleRaws
|
104
104
|
type: 'atrule'
|
105
|
-
constructor(defaults?: AtRule.AtRuleProps)
|
106
|
-
assign(overrides: AtRule.AtRuleProps | object): this
|
107
|
-
|
108
|
-
clone(overrides?: Partial<AtRule.AtRuleProps>): this
|
109
|
-
|
110
|
-
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
|
111
|
-
|
112
|
-
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
|
113
105
|
/**
|
114
106
|
* The at-rule’s name immediately follows the `@`.
|
115
107
|
*
|
@@ -121,6 +113,7 @@ declare class AtRule_ extends Container {
|
|
121
113
|
*/
|
122
114
|
get name(): string
|
123
115
|
set name(value: string)
|
116
|
+
|
124
117
|
/**
|
125
118
|
* The at-rule’s parameters, the values that follow the at-rule’s name
|
126
119
|
* but precede any `{}` block.
|
@@ -132,7 +125,14 @@ declare class AtRule_ extends Container {
|
|
132
125
|
* ```
|
133
126
|
*/
|
134
127
|
get params(): string
|
128
|
+
|
135
129
|
set params(value: string)
|
130
|
+
|
131
|
+
constructor(defaults?: AtRule.AtRuleProps)
|
132
|
+
assign(overrides: AtRule.AtRuleProps | object): this
|
133
|
+
clone(overrides?: Partial<AtRule.AtRuleProps>): this
|
134
|
+
cloneAfter(overrides?: Partial<AtRule.AtRuleProps>): this
|
135
|
+
cloneBefore(overrides?: Partial<AtRule.AtRuleProps>): this
|
136
136
|
}
|
137
137
|
|
138
138
|
declare class AtRule extends AtRule_ {}
|
package/lib/comment.d.ts
CHANGED
@@ -49,18 +49,18 @@ declare class Comment_ extends Node {
|
|
49
49
|
parent: Container | undefined
|
50
50
|
raws: Comment.CommentRaws
|
51
51
|
type: 'comment'
|
52
|
-
constructor(defaults?: Comment.CommentProps)
|
53
|
-
|
54
|
-
assign(overrides: Comment.CommentProps | object): this
|
55
|
-
|
56
|
-
clone(overrides?: Partial<Comment.CommentProps>): this
|
57
|
-
cloneAfter(overrides?: Partial<Comment.CommentProps>): this
|
58
|
-
cloneBefore(overrides?: Partial<Comment.CommentProps>): this
|
59
52
|
/**
|
60
53
|
* The comment's text.
|
61
54
|
*/
|
62
55
|
get text(): string
|
56
|
+
|
63
57
|
set text(value: string)
|
58
|
+
|
59
|
+
constructor(defaults?: Comment.CommentProps)
|
60
|
+
assign(overrides: Comment.CommentProps | object): this
|
61
|
+
clone(overrides?: Partial<Comment.CommentProps>): this
|
62
|
+
cloneAfter(overrides?: Partial<Comment.CommentProps>): this
|
63
|
+
cloneBefore(overrides?: Partial<Comment.CommentProps>): this
|
64
64
|
}
|
65
65
|
|
66
66
|
declare class Comment extends Comment_ {}
|
package/lib/container.d.ts
CHANGED
@@ -65,25 +65,22 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
65
65
|
nodes: Child[] | undefined
|
66
66
|
|
67
67
|
/**
|
68
|
-
*
|
69
|
-
* child nodes that can then be added to this container.
|
70
|
-
*
|
71
|
-
* This ensures that the nodes' parent is set to this container, that they use
|
72
|
-
* the correct prototype chain, and that they're marked as dirty.
|
68
|
+
* The container’s first child.
|
73
69
|
*
|
74
|
-
*
|
75
|
-
*
|
76
|
-
*
|
77
|
-
* @param type This should be set to `'prepend'` if the new nodes will be
|
78
|
-
* inserted at the beginning of the container.
|
79
|
-
* @hidden
|
70
|
+
* ```js
|
71
|
+
* rule.first === rules.nodes[0]
|
72
|
+
* ```
|
80
73
|
*/
|
81
|
-
|
82
|
-
nodes: Container.NewChild,
|
83
|
-
sample: Node | undefined,
|
84
|
-
type?: 'prepend' | false
|
85
|
-
): Child[]
|
74
|
+
get first(): Child | undefined
|
86
75
|
|
76
|
+
/**
|
77
|
+
* The container’s last child.
|
78
|
+
*
|
79
|
+
* ```js
|
80
|
+
* rule.last === rule.nodes[rule.nodes.length - 1]
|
81
|
+
* ```
|
82
|
+
*/
|
83
|
+
get last(): Child | undefined
|
87
84
|
/**
|
88
85
|
* Inserts new nodes to the end of the container.
|
89
86
|
*
|
@@ -107,10 +104,10 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
107
104
|
append(...nodes: Container.NewChild[]): this
|
108
105
|
assign(overrides: Container.ContainerProps | object): this
|
109
106
|
clone(overrides?: Partial<Container.ContainerProps>): this
|
107
|
+
|
110
108
|
cloneAfter(overrides?: Partial<Container.ContainerProps>): this
|
111
109
|
|
112
110
|
cloneBefore(overrides?: Partial<Container.ContainerProps>): this
|
113
|
-
|
114
111
|
/**
|
115
112
|
* Iterates through the container’s immediate children,
|
116
113
|
* calling `callback` for each child.
|
@@ -147,6 +144,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
147
144
|
each(
|
148
145
|
callback: (node: Child, index: number) => false | void
|
149
146
|
): false | undefined
|
147
|
+
|
150
148
|
/**
|
151
149
|
* Returns `true` if callback returns `true`
|
152
150
|
* for all of the container’s children.
|
@@ -161,7 +159,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
161
159
|
every(
|
162
160
|
condition: (node: Child, index: number, nodes: Child[]) => boolean
|
163
161
|
): boolean
|
164
|
-
|
165
162
|
/**
|
166
163
|
* Returns a `child`’s index within the `Container#nodes` array.
|
167
164
|
*
|
@@ -173,6 +170,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
173
170
|
* @return Child index.
|
174
171
|
*/
|
175
172
|
index(child: Child | number): number
|
173
|
+
|
176
174
|
/**
|
177
175
|
* Insert new node after old node within the container.
|
178
176
|
*
|
@@ -182,19 +180,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
182
180
|
*/
|
183
181
|
insertAfter(oldNode: Child | number, newNode: Container.NewChild): this
|
184
182
|
|
185
|
-
/**
|
186
|
-
* Insert new node before old node within the container.
|
187
|
-
*
|
188
|
-
* ```js
|
189
|
-
* rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
|
190
|
-
* ```
|
191
|
-
*
|
192
|
-
* @param oldNode Child or child’s index.
|
193
|
-
* @param newNode New node.
|
194
|
-
* @return This node for methods chain.
|
195
|
-
*/
|
196
|
-
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this
|
197
|
-
|
198
183
|
/**
|
199
184
|
* Traverses the container’s descendant nodes, calling callback
|
200
185
|
* for each comment node.
|
@@ -212,6 +197,18 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
212
197
|
* @return Returns `false` if iteration was broke.
|
213
198
|
*/
|
214
199
|
|
200
|
+
/**
|
201
|
+
* Insert new node before old node within the container.
|
202
|
+
*
|
203
|
+
* ```js
|
204
|
+
* rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
|
205
|
+
* ```
|
206
|
+
*
|
207
|
+
* @param oldNode Child or child’s index.
|
208
|
+
* @param newNode New node.
|
209
|
+
* @return This node for methods chain.
|
210
|
+
*/
|
211
|
+
insertBefore(oldNode: Child | number, newNode: Container.NewChild): this
|
215
212
|
/**
|
216
213
|
* Inserts new nodes to the start of the container.
|
217
214
|
*
|
@@ -233,6 +230,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
233
230
|
* @return This node for methods chain.
|
234
231
|
*/
|
235
232
|
prepend(...nodes: Container.NewChild[]): this
|
233
|
+
|
236
234
|
/**
|
237
235
|
* Add child to the end of the node.
|
238
236
|
*
|
@@ -278,7 +276,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
278
276
|
pattern: RegExp | string,
|
279
277
|
replaced: { (substring: string, ...args: any[]): string } | string
|
280
278
|
): this
|
281
|
-
|
282
279
|
/**
|
283
280
|
* Passes all declaration values within the container that match pattern
|
284
281
|
* through callback, replacing those values with the returned result
|
@@ -379,14 +376,13 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
379
376
|
nameFilter: RegExp | string,
|
380
377
|
callback: (atRule: AtRule, index: number) => false | void
|
381
378
|
): false | undefined
|
382
|
-
|
383
379
|
walkAtRules(
|
384
380
|
callback: (atRule: AtRule, index: number) => false | void
|
385
381
|
): false | undefined
|
382
|
+
|
386
383
|
walkComments(
|
387
384
|
callback: (comment: Comment, indexed: number) => false | void
|
388
385
|
): false | undefined
|
389
|
-
|
390
386
|
walkComments(
|
391
387
|
callback: (comment: Comment, indexed: number) => false | void
|
392
388
|
): false | undefined
|
@@ -424,11 +420,9 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
424
420
|
propFilter: RegExp | string,
|
425
421
|
callback: (decl: Declaration, index: number) => false | void
|
426
422
|
): false | undefined
|
427
|
-
|
428
423
|
walkDecls(
|
429
424
|
callback: (decl: Declaration, index: number) => false | void
|
430
425
|
): false | undefined
|
431
|
-
|
432
426
|
/**
|
433
427
|
* Traverses the container’s descendant nodes, calling callback
|
434
428
|
* for each rule node.
|
@@ -459,21 +453,24 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
|
459
453
|
callback: (rule: Rule, index: number) => false | void
|
460
454
|
): false | undefined
|
461
455
|
/**
|
462
|
-
*
|
456
|
+
* An internal method that converts a {@link NewChild} into a list of actual
|
457
|
+
* child nodes that can then be added to this container.
|
463
458
|
*
|
464
|
-
*
|
465
|
-
*
|
466
|
-
* ```
|
467
|
-
*/
|
468
|
-
get first(): Child | undefined
|
469
|
-
/**
|
470
|
-
* The container’s last child.
|
459
|
+
* This ensures that the nodes' parent is set to this container, that they use
|
460
|
+
* the correct prototype chain, and that they're marked as dirty.
|
471
461
|
*
|
472
|
-
*
|
473
|
-
*
|
474
|
-
*
|
462
|
+
* @param mnodes The new node or nodes to add.
|
463
|
+
* @param sample A node from whose raws the new node's `before` raw should be
|
464
|
+
* taken.
|
465
|
+
* @param type This should be set to `'prepend'` if the new nodes will be
|
466
|
+
* inserted at the beginning of the container.
|
467
|
+
* @hidden
|
475
468
|
*/
|
476
|
-
|
469
|
+
protected normalize(
|
470
|
+
nodes: Container.NewChild,
|
471
|
+
sample: Node | undefined,
|
472
|
+
type?: 'prepend' | false
|
473
|
+
): Child[]
|
477
474
|
}
|
478
475
|
|
479
476
|
declare class Container<
|
package/lib/container.js
CHANGED
@@ -25,6 +25,16 @@ function markTreeDirty(node) {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
class Container extends Node {
|
28
|
+
get first() {
|
29
|
+
if (!this.proxyOf.nodes) return undefined
|
30
|
+
return this.proxyOf.nodes[0]
|
31
|
+
}
|
32
|
+
|
33
|
+
get last() {
|
34
|
+
if (!this.proxyOf.nodes) return undefined
|
35
|
+
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
|
36
|
+
}
|
37
|
+
|
28
38
|
append(...children) {
|
29
39
|
for (let child of children) {
|
30
40
|
let nodes = this.normalize(child, this.last)
|
@@ -391,16 +401,6 @@ class Container extends Node {
|
|
391
401
|
}
|
392
402
|
})
|
393
403
|
}
|
394
|
-
|
395
|
-
get first() {
|
396
|
-
if (!this.proxyOf.nodes) return undefined
|
397
|
-
return this.proxyOf.nodes[0]
|
398
|
-
}
|
399
|
-
|
400
|
-
get last() {
|
401
|
-
if (!this.proxyOf.nodes) return undefined
|
402
|
-
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
|
403
|
-
}
|
404
404
|
}
|
405
405
|
|
406
406
|
Container.registerParse = dependant => {
|
package/lib/declaration.d.ts
CHANGED
@@ -68,14 +68,6 @@ declare class Declaration_ extends Node {
|
|
68
68
|
|
69
69
|
type: 'decl'
|
70
70
|
|
71
|
-
constructor(defaults?: Declaration.DeclarationProps)
|
72
|
-
assign(overrides: Declaration.DeclarationProps | object): this
|
73
|
-
|
74
|
-
clone(overrides?: Partial<Declaration.DeclarationProps>): this
|
75
|
-
|
76
|
-
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
|
77
|
-
|
78
|
-
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
|
79
71
|
/**
|
80
72
|
* It represents a specificity of the declaration.
|
81
73
|
*
|
@@ -91,8 +83,8 @@ declare class Declaration_ extends Node {
|
|
91
83
|
* ```
|
92
84
|
*/
|
93
85
|
get important(): boolean
|
94
|
-
|
95
86
|
set important(value: boolean)
|
87
|
+
|
96
88
|
/**
|
97
89
|
* The property name for a CSS declaration.
|
98
90
|
*
|
@@ -106,6 +98,7 @@ declare class Declaration_ extends Node {
|
|
106
98
|
get prop(): string
|
107
99
|
|
108
100
|
set prop(value: string)
|
101
|
+
|
109
102
|
/**
|
110
103
|
* The property value for a CSS declaration.
|
111
104
|
*
|
@@ -125,6 +118,7 @@ declare class Declaration_ extends Node {
|
|
125
118
|
*/
|
126
119
|
get value(): string
|
127
120
|
set value(value: string)
|
121
|
+
|
128
122
|
/**
|
129
123
|
* It represents a getter that returns `true` if a declaration starts with
|
130
124
|
* `--` or `$`, which are used to declare variables in CSS and SASS/SCSS.
|
@@ -144,6 +138,12 @@ declare class Declaration_ extends Node {
|
|
144
138
|
* ```
|
145
139
|
*/
|
146
140
|
get variable(): boolean
|
141
|
+
constructor(defaults?: Declaration.DeclarationProps)
|
142
|
+
|
143
|
+
assign(overrides: Declaration.DeclarationProps | object): this
|
144
|
+
clone(overrides?: Partial<Declaration.DeclarationProps>): this
|
145
|
+
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
|
146
|
+
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
|
147
147
|
}
|
148
148
|
|
149
149
|
declare class Declaration extends Declaration_ {}
|
package/lib/declaration.js
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
let Node = require('./node')
|
4
4
|
|
5
5
|
class Declaration extends Node {
|
6
|
+
get variable() {
|
7
|
+
return this.prop.startsWith('--') || this.prop[0] === '$'
|
8
|
+
}
|
9
|
+
|
6
10
|
constructor(defaults) {
|
7
11
|
if (
|
8
12
|
defaults &&
|
@@ -14,10 +18,6 @@ class Declaration extends Node {
|
|
14
18
|
super(defaults)
|
15
19
|
this.type = 'decl'
|
16
20
|
}
|
17
|
-
|
18
|
-
get variable() {
|
19
|
-
return this.prop.startsWith('--') || this.prop[0] === '$'
|
20
|
-
}
|
21
21
|
}
|
22
22
|
|
23
23
|
module.exports = Declaration
|
package/lib/input.d.ts
CHANGED
@@ -111,6 +111,20 @@ declare class Input_ {
|
|
111
111
|
*/
|
112
112
|
map: PreviousMap
|
113
113
|
|
114
|
+
/**
|
115
|
+
* The CSS source identifier. Contains `Input#file` if the user
|
116
|
+
* set the `from` option, or `Input#id` if they did not.
|
117
|
+
*
|
118
|
+
* ```js
|
119
|
+
* const root = postcss.parse(css, { from: 'a.css' })
|
120
|
+
* root.source.input.from //=> "/home/ai/a.css"
|
121
|
+
*
|
122
|
+
* const root = postcss.parse(css)
|
123
|
+
* root.source.input.from //=> "<input css 1>"
|
124
|
+
* ```
|
125
|
+
*/
|
126
|
+
get from(): string
|
127
|
+
|
114
128
|
/**
|
115
129
|
* @param css Input CSS source.
|
116
130
|
* @param opts Process options.
|
@@ -137,7 +151,6 @@ declare class Input_ {
|
|
137
151
|
},
|
138
152
|
opts?: { plugin?: CssSyntaxError['plugin'] }
|
139
153
|
): CssSyntaxError
|
140
|
-
|
141
154
|
/**
|
142
155
|
* Returns `CssSyntaxError` with information about the error and its position.
|
143
156
|
*/
|
@@ -147,13 +160,11 @@ declare class Input_ {
|
|
147
160
|
column: number,
|
148
161
|
opts?: { plugin?: CssSyntaxError['plugin'] }
|
149
162
|
): CssSyntaxError
|
150
|
-
|
151
163
|
error(
|
152
164
|
message: string,
|
153
165
|
offset: number,
|
154
166
|
opts?: { plugin?: CssSyntaxError['plugin'] }
|
155
167
|
): CssSyntaxError
|
156
|
-
|
157
168
|
/**
|
158
169
|
* Converts source offset to line and column.
|
159
170
|
*
|
@@ -185,22 +196,9 @@ declare class Input_ {
|
|
185
196
|
endLine?: number,
|
186
197
|
endColumn?: number
|
187
198
|
): false | Input.FilePosition
|
199
|
+
|
188
200
|
/** Converts this to a JSON-friendly object representation. */
|
189
201
|
toJSON(): object
|
190
|
-
|
191
|
-
/**
|
192
|
-
* The CSS source identifier. Contains `Input#file` if the user
|
193
|
-
* set the `from` option, or `Input#id` if they did not.
|
194
|
-
*
|
195
|
-
* ```js
|
196
|
-
* const root = postcss.parse(css, { from: 'a.css' })
|
197
|
-
* root.source.input.from //=> "/home/ai/a.css"
|
198
|
-
*
|
199
|
-
* const root = postcss.parse(css)
|
200
|
-
* root.source.input.from //=> "<input css 1>"
|
201
|
-
* ```
|
202
|
-
*/
|
203
|
-
get from(): string
|
204
202
|
}
|
205
203
|
|
206
204
|
declare class Input extends Input_ {}
|
package/lib/input.js
CHANGED
@@ -15,6 +15,10 @@ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator)
|
|
15
15
|
let pathAvailable = Boolean(resolve && isAbsolute)
|
16
16
|
|
17
17
|
class Input {
|
18
|
+
get from() {
|
19
|
+
return this.file || this.id
|
20
|
+
}
|
21
|
+
|
18
22
|
constructor(css, opts = {}) {
|
19
23
|
if (
|
20
24
|
css === null ||
|
@@ -237,10 +241,6 @@ class Input {
|
|
237
241
|
}
|
238
242
|
return json
|
239
243
|
}
|
240
|
-
|
241
|
-
get from() {
|
242
|
-
return this.file || this.id
|
243
|
-
}
|
244
244
|
}
|
245
245
|
|
246
246
|
module.exports = Input
|
package/lib/lazy-result.d.ts
CHANGED
@@ -67,46 +67,6 @@ declare class LazyResult_<RootNode = Document | Root>
|
|
67
67
|
*/
|
68
68
|
then: Promise<Result<RootNode>>['then']
|
69
69
|
|
70
|
-
/**
|
71
|
-
* @param processor Processor used for this transformation.
|
72
|
-
* @param css CSS to parse and transform.
|
73
|
-
* @param opts Options from the `Processor#process` or `Root#toResult`.
|
74
|
-
*/
|
75
|
-
constructor(processor: Processor, css: string, opts: ResultOptions)
|
76
|
-
|
77
|
-
/**
|
78
|
-
* Run plugin in async way and return `Result`.
|
79
|
-
*
|
80
|
-
* @return Result with output content.
|
81
|
-
*/
|
82
|
-
async(): Promise<Result<RootNode>>
|
83
|
-
|
84
|
-
/**
|
85
|
-
* Run plugin in sync way and return `Result`.
|
86
|
-
*
|
87
|
-
* @return Result with output content.
|
88
|
-
*/
|
89
|
-
sync(): Result<RootNode>
|
90
|
-
|
91
|
-
/**
|
92
|
-
* Alias for the `LazyResult#css` property.
|
93
|
-
*
|
94
|
-
* ```js
|
95
|
-
* lazy + '' === lazy.css
|
96
|
-
* ```
|
97
|
-
*
|
98
|
-
* @return Output CSS.
|
99
|
-
*/
|
100
|
-
toString(): string
|
101
|
-
|
102
|
-
/**
|
103
|
-
* Processes input CSS through synchronous plugins
|
104
|
-
* and calls `Result#warnings`.
|
105
|
-
*
|
106
|
-
* @return Warnings from plugins.
|
107
|
-
*/
|
108
|
-
warnings(): Warning[]
|
109
|
-
|
110
70
|
/**
|
111
71
|
* An alias for the `css` property. Use it with syntaxes
|
112
72
|
* that generate non-CSS output.
|
@@ -181,6 +141,46 @@ declare class LazyResult_<RootNode = Document | Root>
|
|
181
141
|
* Required to implement the Promise interface.
|
182
142
|
*/
|
183
143
|
get [Symbol.toStringTag](): string
|
144
|
+
|
145
|
+
/**
|
146
|
+
* @param processor Processor used for this transformation.
|
147
|
+
* @param css CSS to parse and transform.
|
148
|
+
* @param opts Options from the `Processor#process` or `Root#toResult`.
|
149
|
+
*/
|
150
|
+
constructor(processor: Processor, css: string, opts: ResultOptions)
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Run plugin in async way and return `Result`.
|
154
|
+
*
|
155
|
+
* @return Result with output content.
|
156
|
+
*/
|
157
|
+
async(): Promise<Result<RootNode>>
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Run plugin in sync way and return `Result`.
|
161
|
+
*
|
162
|
+
* @return Result with output content.
|
163
|
+
*/
|
164
|
+
sync(): Result<RootNode>
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Alias for the `LazyResult#css` property.
|
168
|
+
*
|
169
|
+
* ```js
|
170
|
+
* lazy + '' === lazy.css
|
171
|
+
* ```
|
172
|
+
*
|
173
|
+
* @return Output CSS.
|
174
|
+
*/
|
175
|
+
toString(): string
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Processes input CSS through synchronous plugins
|
179
|
+
* and calls `Result#warnings`.
|
180
|
+
*
|
181
|
+
* @return Warnings from plugins.
|
182
|
+
*/
|
183
|
+
warnings(): Warning[]
|
184
184
|
}
|
185
185
|
|
186
186
|
declare class LazyResult<
|
package/lib/lazy-result.js
CHANGED
@@ -105,6 +105,38 @@ function cleanMarks(node) {
|
|
105
105
|
let postcss = {}
|
106
106
|
|
107
107
|
class LazyResult {
|
108
|
+
get content() {
|
109
|
+
return this.stringify().content
|
110
|
+
}
|
111
|
+
|
112
|
+
get css() {
|
113
|
+
return this.stringify().css
|
114
|
+
}
|
115
|
+
|
116
|
+
get map() {
|
117
|
+
return this.stringify().map
|
118
|
+
}
|
119
|
+
|
120
|
+
get messages() {
|
121
|
+
return this.sync().messages
|
122
|
+
}
|
123
|
+
|
124
|
+
get opts() {
|
125
|
+
return this.result.opts
|
126
|
+
}
|
127
|
+
|
128
|
+
get processor() {
|
129
|
+
return this.result.processor
|
130
|
+
}
|
131
|
+
|
132
|
+
get root() {
|
133
|
+
return this.sync().root
|
134
|
+
}
|
135
|
+
|
136
|
+
get [Symbol.toStringTag]() {
|
137
|
+
return 'LazyResult'
|
138
|
+
}
|
139
|
+
|
108
140
|
constructor(processor, css, opts) {
|
109
141
|
this.stringified = false
|
110
142
|
this.processed = false
|
@@ -505,38 +537,6 @@ class LazyResult {
|
|
505
537
|
warnings() {
|
506
538
|
return this.sync().warnings()
|
507
539
|
}
|
508
|
-
|
509
|
-
get content() {
|
510
|
-
return this.stringify().content
|
511
|
-
}
|
512
|
-
|
513
|
-
get css() {
|
514
|
-
return this.stringify().css
|
515
|
-
}
|
516
|
-
|
517
|
-
get map() {
|
518
|
-
return this.stringify().map
|
519
|
-
}
|
520
|
-
|
521
|
-
get messages() {
|
522
|
-
return this.sync().messages
|
523
|
-
}
|
524
|
-
|
525
|
-
get opts() {
|
526
|
-
return this.result.opts
|
527
|
-
}
|
528
|
-
|
529
|
-
get processor() {
|
530
|
-
return this.result.processor
|
531
|
-
}
|
532
|
-
|
533
|
-
get root() {
|
534
|
-
return this.sync().root
|
535
|
-
}
|
536
|
-
|
537
|
-
get [Symbol.toStringTag]() {
|
538
|
-
return 'LazyResult'
|
539
|
-
}
|
540
540
|
}
|
541
541
|
|
542
542
|
LazyResult.registerPostcss = dependant => {
|
package/lib/no-work-result.d.ts
CHANGED
@@ -26,11 +26,6 @@ declare class NoWorkResult_ implements LazyResult<Root> {
|
|
26
26
|
catch: Promise<Result<Root>>['catch']
|
27
27
|
finally: Promise<Result<Root>>['finally']
|
28
28
|
then: Promise<Result<Root>>['then']
|
29
|
-
constructor(processor: Processor, css: string, opts: ResultOptions)
|
30
|
-
async(): Promise<Result<Root>>
|
31
|
-
sync(): Result<Root>
|
32
|
-
toString(): string
|
33
|
-
warnings(): Warning[]
|
34
29
|
get content(): string
|
35
30
|
get css(): string
|
36
31
|
get map(): SourceMap
|
@@ -39,6 +34,11 @@ declare class NoWorkResult_ implements LazyResult<Root> {
|
|
39
34
|
get processor(): Processor
|
40
35
|
get root(): Root
|
41
36
|
get [Symbol.toStringTag](): string
|
37
|
+
constructor(processor: Processor, css: string, opts: ResultOptions)
|
38
|
+
async(): Promise<Result<Root>>
|
39
|
+
sync(): Result<Root>
|
40
|
+
toString(): string
|
41
|
+
warnings(): Warning[]
|
42
42
|
}
|
43
43
|
|
44
44
|
declare class NoWorkResult extends NoWorkResult_ {}
|
package/lib/no-work-result.js
CHANGED
@@ -7,6 +7,56 @@ let stringify = require('./stringify')
|
|
7
7
|
let warnOnce = require('./warn-once')
|
8
8
|
|
9
9
|
class NoWorkResult {
|
10
|
+
get content() {
|
11
|
+
return this.result.css
|
12
|
+
}
|
13
|
+
|
14
|
+
get css() {
|
15
|
+
return this.result.css
|
16
|
+
}
|
17
|
+
|
18
|
+
get map() {
|
19
|
+
return this.result.map
|
20
|
+
}
|
21
|
+
|
22
|
+
get messages() {
|
23
|
+
return []
|
24
|
+
}
|
25
|
+
|
26
|
+
get opts() {
|
27
|
+
return this.result.opts
|
28
|
+
}
|
29
|
+
|
30
|
+
get processor() {
|
31
|
+
return this.result.processor
|
32
|
+
}
|
33
|
+
|
34
|
+
get root() {
|
35
|
+
if (this._root) {
|
36
|
+
return this._root
|
37
|
+
}
|
38
|
+
|
39
|
+
let root
|
40
|
+
let parser = parse
|
41
|
+
|
42
|
+
try {
|
43
|
+
root = parser(this._css, this._opts)
|
44
|
+
} catch (error) {
|
45
|
+
this.error = error
|
46
|
+
}
|
47
|
+
|
48
|
+
if (this.error) {
|
49
|
+
throw this.error
|
50
|
+
} else {
|
51
|
+
this._root = root
|
52
|
+
return root
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
get [Symbol.toStringTag]() {
|
57
|
+
return 'NoWorkResult'
|
58
|
+
}
|
59
|
+
|
10
60
|
constructor(processor, css, opts) {
|
11
61
|
css = css.toString()
|
12
62
|
this.stringified = false
|
@@ -82,56 +132,6 @@ class NoWorkResult {
|
|
82
132
|
warnings() {
|
83
133
|
return []
|
84
134
|
}
|
85
|
-
|
86
|
-
get content() {
|
87
|
-
return this.result.css
|
88
|
-
}
|
89
|
-
|
90
|
-
get css() {
|
91
|
-
return this.result.css
|
92
|
-
}
|
93
|
-
|
94
|
-
get map() {
|
95
|
-
return this.result.map
|
96
|
-
}
|
97
|
-
|
98
|
-
get messages() {
|
99
|
-
return []
|
100
|
-
}
|
101
|
-
|
102
|
-
get opts() {
|
103
|
-
return this.result.opts
|
104
|
-
}
|
105
|
-
|
106
|
-
get processor() {
|
107
|
-
return this.result.processor
|
108
|
-
}
|
109
|
-
|
110
|
-
get root() {
|
111
|
-
if (this._root) {
|
112
|
-
return this._root
|
113
|
-
}
|
114
|
-
|
115
|
-
let root
|
116
|
-
let parser = parse
|
117
|
-
|
118
|
-
try {
|
119
|
-
root = parser(this._css, this._opts)
|
120
|
-
} catch (error) {
|
121
|
-
this.error = error
|
122
|
-
}
|
123
|
-
|
124
|
-
if (this.error) {
|
125
|
-
throw this.error
|
126
|
-
} else {
|
127
|
-
this._root = root
|
128
|
-
return root
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
get [Symbol.toStringTag]() {
|
133
|
-
return 'NoWorkResult'
|
134
|
-
}
|
135
135
|
}
|
136
136
|
|
137
137
|
module.exports = NoWorkResult
|
package/lib/node.d.ts
CHANGED
@@ -234,14 +234,6 @@ declare abstract class Node_ {
|
|
234
234
|
|
235
235
|
constructor(defaults?: object)
|
236
236
|
|
237
|
-
/**
|
238
|
-
* If this node isn't already dirty, marks it and its ancestors as such. This
|
239
|
-
* indicates to the LazyResult processor that the {@link Root} has been
|
240
|
-
* modified by the current plugin and may need to be processed again by other
|
241
|
-
* plugins.
|
242
|
-
*/
|
243
|
-
protected markDirty(): void
|
244
|
-
|
245
237
|
/**
|
246
238
|
* Insert new node after current node to current node’s parent.
|
247
239
|
*
|
@@ -534,6 +526,14 @@ declare abstract class Node_ {
|
|
534
526
|
* @return `Warning` instance is returned
|
535
527
|
*/
|
536
528
|
warn(result: Result, message: string, options?: WarningOptions): Warning
|
529
|
+
|
530
|
+
/**
|
531
|
+
* If this node isn't already dirty, marks it and its ancestors as such. This
|
532
|
+
* indicates to the LazyResult processor that the {@link Root} has been
|
533
|
+
* modified by the current plugin and may need to be processed again by other
|
534
|
+
* plugins.
|
535
|
+
*/
|
536
|
+
protected markDirty(): void
|
537
537
|
}
|
538
538
|
|
539
539
|
declare class Node extends Node_ {}
|
package/lib/node.js
CHANGED
@@ -63,6 +63,10 @@ function sourceOffset(inputCSS, position) {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
class Node {
|
66
|
+
get proxyOf() {
|
67
|
+
return this
|
68
|
+
}
|
69
|
+
|
66
70
|
constructor(defaults = {}) {
|
67
71
|
this.raws = {}
|
68
72
|
this[isClean] = false
|
@@ -424,10 +428,6 @@ class Node {
|
|
424
428
|
for (let i in opts) data[i] = opts[i]
|
425
429
|
return result.warn(text, data)
|
426
430
|
}
|
427
|
-
|
428
|
-
get proxyOf() {
|
429
|
-
return this
|
430
|
-
}
|
431
431
|
}
|
432
432
|
|
433
433
|
module.exports = Node
|
package/lib/parser.js
CHANGED
package/lib/postcss.d.mts
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
export {
|
2
|
-
// postcss function / namespace
|
3
|
-
default,
|
4
|
-
|
5
|
-
// Value exports from postcss.mjs
|
6
|
-
stringify,
|
7
|
-
fromJSON,
|
8
|
-
// @ts-expect-error This value exists, but it’s untyped.
|
9
|
-
plugin,
|
10
|
-
parse,
|
11
|
-
list,
|
12
|
-
document,
|
13
|
-
comment,
|
14
|
-
atRule,
|
15
|
-
rule,
|
16
|
-
decl,
|
17
|
-
root,
|
18
|
-
CssSyntaxError,
|
19
|
-
Declaration,
|
20
|
-
Container,
|
21
|
-
Processor,
|
22
|
-
Document,
|
23
|
-
Comment,
|
24
|
-
Warning,
|
25
|
-
AtRule,
|
26
|
-
Result,
|
27
|
-
Input,
|
28
|
-
Rule,
|
29
|
-
Root,
|
30
|
-
Node,
|
31
|
-
|
32
2
|
// Type-only exports
|
33
3
|
AcceptedPlugin,
|
4
|
+
|
34
5
|
AnyNode,
|
6
|
+
atRule,
|
7
|
+
AtRule,
|
35
8
|
AtRuleProps,
|
36
9
|
Builder,
|
37
10
|
ChildNode,
|
38
11
|
ChildProps,
|
12
|
+
comment,
|
13
|
+
Comment,
|
39
14
|
CommentProps,
|
15
|
+
Container,
|
40
16
|
ContainerProps,
|
17
|
+
CssSyntaxError,
|
18
|
+
decl,
|
19
|
+
Declaration,
|
41
20
|
DeclarationProps,
|
21
|
+
// postcss function / namespace
|
22
|
+
default,
|
23
|
+
document,
|
24
|
+
Document,
|
42
25
|
DocumentProps,
|
43
26
|
FilePosition,
|
27
|
+
fromJSON,
|
44
28
|
Helpers,
|
29
|
+
Input,
|
30
|
+
|
45
31
|
JSONHydrator,
|
32
|
+
// This is a class, but it’s not re-exported. That’s why it’s exported as type-only here.
|
33
|
+
type LazyResult,
|
34
|
+
list,
|
46
35
|
Message,
|
36
|
+
Node,
|
47
37
|
NodeErrorOptions,
|
48
38
|
NodeProps,
|
49
39
|
OldPlugin,
|
40
|
+
parse,
|
50
41
|
Parser,
|
42
|
+
// @ts-expect-error This value exists, but it’s untyped.
|
43
|
+
plugin,
|
51
44
|
Plugin,
|
52
45
|
PluginCreator,
|
53
46
|
Position,
|
54
47
|
Postcss,
|
55
48
|
ProcessOptions,
|
49
|
+
Processor,
|
50
|
+
Result,
|
51
|
+
root,
|
52
|
+
Root,
|
56
53
|
RootProps,
|
54
|
+
rule,
|
55
|
+
Rule,
|
57
56
|
RuleProps,
|
58
57
|
Source,
|
59
58
|
SourceMap,
|
60
59
|
SourceMapOptions,
|
61
60
|
Stringifier,
|
61
|
+
// Value exports from postcss.mjs
|
62
|
+
stringify,
|
62
63
|
Syntax,
|
63
64
|
TransformCallback,
|
64
65
|
Transformer,
|
65
|
-
|
66
|
+
Warning,
|
66
67
|
|
67
|
-
|
68
|
-
type LazyResult
|
68
|
+
WarningOptions
|
69
69
|
} from './postcss.js'
|
package/lib/processor.js
CHANGED
package/lib/result.d.ts
CHANGED
@@ -142,6 +142,16 @@ declare class Result_<RootNode = Document | Root> {
|
|
142
142
|
*/
|
143
143
|
root: RootNode
|
144
144
|
|
145
|
+
/**
|
146
|
+
* An alias for the `Result#css` property.
|
147
|
+
* Use it with syntaxes that generate non-CSS output.
|
148
|
+
*
|
149
|
+
* ```js
|
150
|
+
* result.css === result.content
|
151
|
+
* ```
|
152
|
+
*/
|
153
|
+
get content(): string
|
154
|
+
|
145
155
|
/**
|
146
156
|
* @param processor Processor used for this transformation.
|
147
157
|
* @param root Root node after all transformations.
|
@@ -188,16 +198,6 @@ declare class Result_<RootNode = Document | Root> {
|
|
188
198
|
* @return Warnings from plugins.
|
189
199
|
*/
|
190
200
|
warnings(): Warning[]
|
191
|
-
|
192
|
-
/**
|
193
|
-
* An alias for the `Result#css` property.
|
194
|
-
* Use it with syntaxes that generate non-CSS output.
|
195
|
-
*
|
196
|
-
* ```js
|
197
|
-
* result.css === result.content
|
198
|
-
* ```
|
199
|
-
*/
|
200
|
-
get content(): string
|
201
201
|
}
|
202
202
|
|
203
203
|
declare class Result<RootNode = Document | Root> extends Result_<RootNode> {}
|
package/lib/result.js
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
let Warning = require('./warning')
|
4
4
|
|
5
5
|
class Result {
|
6
|
+
get content() {
|
7
|
+
return this.css
|
8
|
+
}
|
9
|
+
|
6
10
|
constructor(processor, root, opts) {
|
7
11
|
this.processor = processor
|
8
12
|
this.messages = []
|
@@ -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/rule.d.ts
CHANGED
@@ -83,14 +83,6 @@ declare class Rule_ extends Container {
|
|
83
83
|
parent: ContainerWithChildren | undefined
|
84
84
|
raws: Rule.RuleRaws
|
85
85
|
type: 'rule'
|
86
|
-
constructor(defaults?: Rule.RuleProps)
|
87
|
-
|
88
|
-
assign(overrides: object | Rule.RuleProps): this
|
89
|
-
clone(overrides?: Partial<Rule.RuleProps>): this
|
90
|
-
|
91
|
-
cloneAfter(overrides?: Partial<Rule.RuleProps>): this
|
92
|
-
|
93
|
-
cloneBefore(overrides?: Partial<Rule.RuleProps>): this
|
94
86
|
/**
|
95
87
|
* The rule’s full selector represented as a string.
|
96
88
|
*
|
@@ -101,6 +93,7 @@ declare class Rule_ extends Container {
|
|
101
93
|
* ```
|
102
94
|
*/
|
103
95
|
get selector(): string
|
96
|
+
|
104
97
|
set selector(value: string)
|
105
98
|
/**
|
106
99
|
* An array containing the rule’s individual selectors.
|
@@ -118,7 +111,14 @@ declare class Rule_ extends Container {
|
|
118
111
|
* ```
|
119
112
|
*/
|
120
113
|
get selectors(): string[]
|
114
|
+
|
121
115
|
set selectors(values: string[])
|
116
|
+
|
117
|
+
constructor(defaults?: Rule.RuleProps)
|
118
|
+
assign(overrides: object | Rule.RuleProps): this
|
119
|
+
clone(overrides?: Partial<Rule.RuleProps>): this
|
120
|
+
cloneAfter(overrides?: Partial<Rule.RuleProps>): this
|
121
|
+
cloneBefore(overrides?: Partial<Rule.RuleProps>): this
|
122
122
|
}
|
123
123
|
|
124
124
|
declare class Rule extends Rule_ {}
|
package/lib/rule.js
CHANGED
@@ -4,12 +4,6 @@ let Container = require('./container')
|
|
4
4
|
let list = require('./list')
|
5
5
|
|
6
6
|
class Rule extends Container {
|
7
|
-
constructor(defaults) {
|
8
|
-
super(defaults)
|
9
|
-
this.type = 'rule'
|
10
|
-
if (!this.nodes) this.nodes = []
|
11
|
-
}
|
12
|
-
|
13
7
|
get selectors() {
|
14
8
|
return list.comma(this.selector)
|
15
9
|
}
|
@@ -19,6 +13,12 @@ class Rule extends Container {
|
|
19
13
|
let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen')
|
20
14
|
this.selector = values.join(sep)
|
21
15
|
}
|
16
|
+
|
17
|
+
constructor(defaults) {
|
18
|
+
super(defaults)
|
19
|
+
this.type = 'rule'
|
20
|
+
if (!this.nodes) this.nodes = []
|
21
|
+
}
|
22
22
|
}
|
23
23
|
|
24
24
|
module.exports = Rule
|