postcss 8.4.26 → 8.4.28
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/container.d.ts +39 -38
- package/lib/lazy-result.d.ts +13 -8
- package/lib/no-work-result.d.ts +6 -6
- package/lib/parser.js +1 -0
- package/lib/postcss.d.ts +6 -6
- package/lib/processor.d.ts +6 -2
- package/lib/processor.js +1 -1
- package/lib/result.d.ts +4 -4
- package/package.json +1 -1
package/lib/container.d.ts
CHANGED
@@ -32,9 +32,7 @@ declare namespace Container {
|
|
32
32
|
* Note that all containers can store any content. If you write a rule inside
|
33
33
|
* a rule, PostCSS will parse it.
|
34
34
|
*/
|
35
|
-
declare abstract class Container_<
|
36
|
-
Child extends Node = ChildNode
|
37
|
-
> extends Node {
|
35
|
+
declare abstract class Container_<Child extends Node = ChildNode> extends Node {
|
38
36
|
/**
|
39
37
|
* An array containing the container’s children.
|
40
38
|
*
|
@@ -71,6 +69,11 @@ declare abstract class Container_<
|
|
71
69
|
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
|
72
70
|
): this
|
73
71
|
|
72
|
+
assign(overrides: Container.ContainerProps | object): this
|
73
|
+
clone(overrides?: Partial<Container.ContainerProps>): Container<Child>
|
74
|
+
cloneAfter(overrides?: Partial<Container.ContainerProps>): Container<Child>
|
75
|
+
cloneBefore(overrides?: Partial<Container.ContainerProps>): Container<Child>
|
76
|
+
|
74
77
|
/**
|
75
78
|
* Iterates through the container’s immediate children,
|
76
79
|
* calling `callback` for each child.
|
@@ -122,7 +125,6 @@ declare abstract class Container_<
|
|
122
125
|
every(
|
123
126
|
condition: (node: Child, index: number, nodes: Child[]) => boolean
|
124
127
|
): boolean
|
125
|
-
|
126
128
|
/**
|
127
129
|
* The container’s first child.
|
128
130
|
*
|
@@ -155,6 +157,23 @@ declare abstract class Container_<
|
|
155
157
|
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
|
156
158
|
): this
|
157
159
|
|
160
|
+
/**
|
161
|
+
* Traverses the container’s descendant nodes, calling callback
|
162
|
+
* for each comment node.
|
163
|
+
*
|
164
|
+
* Like `Container#each`, this method is safe
|
165
|
+
* to use if you are mutating arrays during iteration.
|
166
|
+
*
|
167
|
+
* ```js
|
168
|
+
* root.walkComments(comment => {
|
169
|
+
* comment.remove()
|
170
|
+
* })
|
171
|
+
* ```
|
172
|
+
*
|
173
|
+
* @param callback Iterator receives each node and index.
|
174
|
+
* @return Returns `false` if iteration was broke.
|
175
|
+
*/
|
176
|
+
|
158
177
|
/**
|
159
178
|
* Insert new node before old node within the container.
|
160
179
|
*
|
@@ -202,6 +221,7 @@ declare abstract class Container_<
|
|
202
221
|
prepend(
|
203
222
|
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
|
204
223
|
): this
|
224
|
+
|
205
225
|
/**
|
206
226
|
* Add child to the end of the node.
|
207
227
|
*
|
@@ -214,23 +234,6 @@ declare abstract class Container_<
|
|
214
234
|
*/
|
215
235
|
push(child: Child): this
|
216
236
|
|
217
|
-
/**
|
218
|
-
* Traverses the container’s descendant nodes, calling callback
|
219
|
-
* for each comment node.
|
220
|
-
*
|
221
|
-
* Like `Container#each`, this method is safe
|
222
|
-
* to use if you are mutating arrays during iteration.
|
223
|
-
*
|
224
|
-
* ```js
|
225
|
-
* root.walkComments(comment => {
|
226
|
-
* comment.remove()
|
227
|
-
* })
|
228
|
-
* ```
|
229
|
-
*
|
230
|
-
* @param callback Iterator receives each node and index.
|
231
|
-
* @return Returns `false` if iteration was broke.
|
232
|
-
*/
|
233
|
-
|
234
237
|
/**
|
235
238
|
* Removes all children from the container
|
236
239
|
* and cleans their parent properties.
|
@@ -243,6 +246,7 @@ declare abstract class Container_<
|
|
243
246
|
* @return This node for methods chain.
|
244
247
|
*/
|
245
248
|
removeAll(): this
|
249
|
+
|
246
250
|
/**
|
247
251
|
* Removes node from the container and cleans the parent properties
|
248
252
|
* from the node and its children.
|
@@ -259,6 +263,11 @@ declare abstract class Container_<
|
|
259
263
|
*/
|
260
264
|
removeChild(child: Child | number): this
|
261
265
|
|
266
|
+
replaceValues(
|
267
|
+
pattern: RegExp | string,
|
268
|
+
replaced: { (substring: string, ...args: any[]): string } | string
|
269
|
+
): this
|
270
|
+
|
262
271
|
/**
|
263
272
|
* Passes all declaration values within the container that match pattern
|
264
273
|
* through callback, replacing those values with the returned result
|
@@ -288,11 +297,6 @@ declare abstract class Container_<
|
|
288
297
|
replaced: { (substring: string, ...args: any[]): string } | string
|
289
298
|
): this
|
290
299
|
|
291
|
-
replaceValues(
|
292
|
-
pattern: RegExp | string,
|
293
|
-
replaced: { (substring: string, ...args: any[]): string } | string
|
294
|
-
): this
|
295
|
-
|
296
300
|
/**
|
297
301
|
* Returns `true` if callback returns `true` for (at least) one
|
298
302
|
* of the container’s children.
|
@@ -330,11 +334,6 @@ declare abstract class Container_<
|
|
330
334
|
walk(
|
331
335
|
callback: (node: ChildNode, index: number) => false | void
|
332
336
|
): false | undefined
|
333
|
-
|
334
|
-
walkAtRules(
|
335
|
-
callback: (atRule: AtRule, index: number) => false | void
|
336
|
-
): false | undefined
|
337
|
-
|
338
337
|
/**
|
339
338
|
* Traverses the container’s descendant nodes, calling callback
|
340
339
|
* for each at-rule node.
|
@@ -369,6 +368,10 @@ declare abstract class Container_<
|
|
369
368
|
callback: (atRule: AtRule, index: number) => false | void
|
370
369
|
): false | undefined
|
371
370
|
|
371
|
+
walkAtRules(
|
372
|
+
callback: (atRule: AtRule, index: number) => false | void
|
373
|
+
): false | undefined
|
374
|
+
|
372
375
|
walkComments(
|
373
376
|
callback: (comment: Comment, indexed: number) => false | void
|
374
377
|
): false | undefined
|
@@ -376,9 +379,6 @@ declare abstract class Container_<
|
|
376
379
|
walkComments(
|
377
380
|
callback: (comment: Comment, indexed: number) => false | void
|
378
381
|
): false | undefined
|
379
|
-
walkDecls(
|
380
|
-
callback: (decl: Declaration, index: number) => false | void
|
381
|
-
): false | undefined
|
382
382
|
|
383
383
|
/**
|
384
384
|
* Traverses the container’s descendant nodes, calling callback
|
@@ -413,11 +413,9 @@ declare abstract class Container_<
|
|
413
413
|
propFilter: RegExp | string,
|
414
414
|
callback: (decl: Declaration, index: number) => false | void
|
415
415
|
): false | undefined
|
416
|
-
|
417
|
-
|
418
|
-
callback: (rule: Rule, index: number) => false | void
|
416
|
+
walkDecls(
|
417
|
+
callback: (decl: Declaration, index: number) => false | void
|
419
418
|
): false | undefined
|
420
|
-
|
421
419
|
/**
|
422
420
|
* Traverses the container’s descendant nodes, calling callback
|
423
421
|
* for each rule node.
|
@@ -444,6 +442,9 @@ declare abstract class Container_<
|
|
444
442
|
selectorFilter: RegExp | string,
|
445
443
|
callback: (rule: Rule, index: number) => false | void
|
446
444
|
): false | undefined
|
445
|
+
walkRules(
|
446
|
+
callback: (rule: Rule, index: number) => false | void
|
447
|
+
): false | undefined
|
447
448
|
}
|
448
449
|
|
449
450
|
declare class Container<Child extends Node = ChildNode> extends Container_<Child> {}
|
package/lib/lazy-result.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import Document from './document.js'
|
1
2
|
import { SourceMap } from './postcss.js'
|
2
3
|
import Processor from './processor.js'
|
3
4
|
import Result, { Message, ResultOptions } from './result.js'
|
@@ -18,7 +19,9 @@ declare namespace LazyResult {
|
|
18
19
|
* const lazy = postcss([autoprefixer]).process(css)
|
19
20
|
* ```
|
20
21
|
*/
|
21
|
-
declare class LazyResult_
|
22
|
+
declare class LazyResult_<RootNode = Document | Root>
|
23
|
+
implements PromiseLike<Result<RootNode>>
|
24
|
+
{
|
22
25
|
/**
|
23
26
|
* Processes input CSS through synchronous and asynchronous plugins
|
24
27
|
* and calls onRejected for each error thrown in any plugin.
|
@@ -33,7 +36,7 @@ declare class LazyResult_ implements PromiseLike<Result> {
|
|
33
36
|
* })
|
34
37
|
* ```
|
35
38
|
*/
|
36
|
-
catch: Promise<Result
|
39
|
+
catch: Promise<Result<RootNode>>['catch']
|
37
40
|
|
38
41
|
/**
|
39
42
|
* Processes input CSS through synchronous and asynchronous plugins
|
@@ -47,7 +50,7 @@ declare class LazyResult_ implements PromiseLike<Result> {
|
|
47
50
|
* })
|
48
51
|
* ```
|
49
52
|
*/
|
50
|
-
finally: Promise<Result
|
53
|
+
finally: Promise<Result<RootNode>>['finally']
|
51
54
|
|
52
55
|
/**
|
53
56
|
* Processes input CSS through synchronous and asynchronous plugins
|
@@ -62,7 +65,7 @@ declare class LazyResult_ implements PromiseLike<Result> {
|
|
62
65
|
* })
|
63
66
|
* ```
|
64
67
|
*/
|
65
|
-
then: Promise<Result
|
68
|
+
then: Promise<Result<RootNode>>['then']
|
66
69
|
|
67
70
|
/**
|
68
71
|
* @param processor Processor used for this transformation.
|
@@ -76,7 +79,7 @@ declare class LazyResult_ implements PromiseLike<Result> {
|
|
76
79
|
*
|
77
80
|
* @return Result with output content.
|
78
81
|
*/
|
79
|
-
async(): Promise<Result
|
82
|
+
async(): Promise<Result<RootNode>>
|
80
83
|
|
81
84
|
/**
|
82
85
|
* An alias for the `css` property. Use it with syntaxes
|
@@ -145,7 +148,7 @@ declare class LazyResult_ implements PromiseLike<Result> {
|
|
145
148
|
*
|
146
149
|
* PostCSS runners should always use `LazyResult#then`.
|
147
150
|
*/
|
148
|
-
get root():
|
151
|
+
get root(): RootNode
|
149
152
|
|
150
153
|
/**
|
151
154
|
* Returns the default string description of an object.
|
@@ -158,7 +161,7 @@ declare class LazyResult_ implements PromiseLike<Result> {
|
|
158
161
|
*
|
159
162
|
* @return Result with output content.
|
160
163
|
*/
|
161
|
-
sync(): Result
|
164
|
+
sync(): Result<RootNode>
|
162
165
|
|
163
166
|
/**
|
164
167
|
* Alias for the `LazyResult#css` property.
|
@@ -180,6 +183,8 @@ declare class LazyResult_ implements PromiseLike<Result> {
|
|
180
183
|
warnings(): Warning[]
|
181
184
|
}
|
182
185
|
|
183
|
-
declare class LazyResult
|
186
|
+
declare class LazyResult<
|
187
|
+
RootNode = Document | Root
|
188
|
+
> extends LazyResult_<RootNode> {}
|
184
189
|
|
185
190
|
export = LazyResult
|
package/lib/no-work-result.d.ts
CHANGED
@@ -22,12 +22,12 @@ declare namespace NoWorkResult {
|
|
22
22
|
* let root = noWorkResult.root // now css is parsed because we accessed the root
|
23
23
|
* ```
|
24
24
|
*/
|
25
|
-
declare class NoWorkResult_ implements LazyResult {
|
26
|
-
catch: Promise<Result
|
27
|
-
finally: Promise<Result
|
28
|
-
then: Promise<Result
|
25
|
+
declare class NoWorkResult_ implements LazyResult<Root> {
|
26
|
+
catch: Promise<Result<Root>>['catch']
|
27
|
+
finally: Promise<Result<Root>>['finally']
|
28
|
+
then: Promise<Result<Root>>['then']
|
29
29
|
constructor(processor: Processor, css: string, opts: ResultOptions)
|
30
|
-
async(): Promise<Result
|
30
|
+
async(): Promise<Result<Root>>
|
31
31
|
get content(): string
|
32
32
|
get css(): string
|
33
33
|
get map(): SourceMap
|
@@ -36,7 +36,7 @@ declare class NoWorkResult_ implements LazyResult {
|
|
36
36
|
get processor(): Processor
|
37
37
|
get root(): Root
|
38
38
|
get [Symbol.toStringTag](): string
|
39
|
-
sync(): Result
|
39
|
+
sync(): Result<Root>
|
40
40
|
toString(): string
|
41
41
|
warnings(): Warning[]
|
42
42
|
}
|
package/lib/parser.js
CHANGED
package/lib/postcss.d.ts
CHANGED
@@ -236,11 +236,11 @@ declare namespace postcss {
|
|
236
236
|
(data: object[]): Node[]
|
237
237
|
}
|
238
238
|
|
239
|
-
export interface Syntax {
|
239
|
+
export interface Syntax<RootNode = Document | Root> {
|
240
240
|
/**
|
241
241
|
* Function to generate AST by string.
|
242
242
|
*/
|
243
|
-
parse?: Parser
|
243
|
+
parse?: Parser<RootNode>
|
244
244
|
|
245
245
|
/**
|
246
246
|
* Class to generate string by AST.
|
@@ -304,7 +304,7 @@ declare namespace postcss {
|
|
304
304
|
sourcesContent?: boolean
|
305
305
|
}
|
306
306
|
|
307
|
-
export interface ProcessOptions {
|
307
|
+
export interface ProcessOptions<RootNode = Document | Root> {
|
308
308
|
/**
|
309
309
|
* The path of the CSS source file. You should always set `from`,
|
310
310
|
* because it is used in source map generation and syntax error messages.
|
@@ -319,17 +319,17 @@ declare namespace postcss {
|
|
319
319
|
/**
|
320
320
|
* Function to generate AST by string.
|
321
321
|
*/
|
322
|
-
parser?: Parser | Syntax
|
322
|
+
parser?: Parser<RootNode> | Syntax<RootNode>
|
323
323
|
|
324
324
|
/**
|
325
325
|
* Class to generate string by AST.
|
326
326
|
*/
|
327
|
-
stringifier?: Stringifier | Syntax
|
327
|
+
stringifier?: Stringifier | Syntax<RootNode>
|
328
328
|
|
329
329
|
/**
|
330
330
|
* Object with parse and stringify.
|
331
331
|
*/
|
332
|
-
syntax?: Syntax
|
332
|
+
syntax?: Syntax<RootNode>
|
333
333
|
|
334
334
|
/**
|
335
335
|
* The path where you'll put the output CSS file. You should always set `to`
|
package/lib/processor.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import Document from './document.js'
|
1
2
|
import LazyResult from './lazy-result.js'
|
2
3
|
import NoWorkResult from './no-work-result.js'
|
3
4
|
import {
|
@@ -72,9 +73,12 @@ declare class Processor_ {
|
|
72
73
|
* @return Promise proxy.
|
73
74
|
*/
|
74
75
|
process(
|
75
|
-
css: { toString(): string } | LazyResult | Result | Root | string
|
76
|
-
options?: ProcessOptions
|
76
|
+
css: { toString(): string } | LazyResult | Result | Root | string
|
77
77
|
): LazyResult | NoWorkResult
|
78
|
+
process<RootNode extends Document | Root = Root>(
|
79
|
+
css: { toString(): string } | LazyResult | Result | Root | string,
|
80
|
+
options: ProcessOptions<RootNode>
|
81
|
+
): LazyResult<RootNode>
|
78
82
|
|
79
83
|
/**
|
80
84
|
* Adds a plugin to be used as a CSS processor.
|
package/lib/processor.js
CHANGED
package/lib/result.d.ts
CHANGED
@@ -60,7 +60,7 @@ declare namespace Result {
|
|
60
60
|
* const result2 = postcss.parse(css).toResult()
|
61
61
|
* ```
|
62
62
|
*/
|
63
|
-
declare class Result_ {
|
63
|
+
declare class Result_<RootNode = Document | Root> {
|
64
64
|
/**
|
65
65
|
* A CSS string representing of `Result#root`.
|
66
66
|
*
|
@@ -141,14 +141,14 @@ declare class Result_ {
|
|
141
141
|
* root.toResult().root === root
|
142
142
|
* ```
|
143
143
|
*/
|
144
|
-
root:
|
144
|
+
root: RootNode
|
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: RootNode, opts: Result.ResultOptions)
|
152
152
|
|
153
153
|
/**
|
154
154
|
* An alias for the `Result#css` property.
|
@@ -201,6 +201,6 @@ declare class Result_ {
|
|
201
201
|
warnings(): Warning[]
|
202
202
|
}
|
203
203
|
|
204
|
-
declare class Result extends Result_ {}
|
204
|
+
declare class Result<RootNode = Document | Root> extends Result_<RootNode> {}
|
205
205
|
|
206
206
|
export = Result
|