postcss 8.4.24 → 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 +124 -124
- 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/postcss.d.ts
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
import {
|
1
|
+
import { RawSourceMap, SourceMapGenerator } from 'source-map-js'
|
2
2
|
|
3
|
+
import AtRule, { AtRuleProps } from './at-rule.js'
|
4
|
+
import Comment, { CommentProps } from './comment.js'
|
5
|
+
import Container, { ContainerProps } from './container.js'
|
6
|
+
import CssSyntaxError from './css-syntax-error.js'
|
7
|
+
import Declaration, { DeclarationProps } from './declaration.js'
|
8
|
+
import Document, { DocumentProps } from './document.js'
|
9
|
+
import Input, { FilePosition } from './input.js'
|
10
|
+
import LazyResult from './lazy-result.js'
|
11
|
+
import list from './list.js'
|
3
12
|
import Node, {
|
4
|
-
|
5
|
-
Source,
|
13
|
+
AnyNode,
|
6
14
|
ChildNode,
|
15
|
+
ChildProps,
|
7
16
|
NodeErrorOptions,
|
8
17
|
NodeProps,
|
9
|
-
|
10
|
-
|
18
|
+
Position,
|
19
|
+
Source
|
11
20
|
} from './node.js'
|
12
|
-
import
|
13
|
-
import Container, { ContainerProps } from './container.js'
|
14
|
-
import Document, { DocumentProps } from './document.js'
|
15
|
-
import Warning, { WarningOptions } from './warning.js'
|
16
|
-
import Comment, { CommentProps } from './comment.js'
|
17
|
-
import AtRule, { AtRuleProps } from './at-rule.js'
|
18
|
-
import Input, { FilePosition } from './input.js'
|
21
|
+
import Processor from './processor.js'
|
19
22
|
import Result, { Message } from './result.js'
|
20
23
|
import Root, { RootProps } from './root.js'
|
21
24
|
import Rule, { RuleProps } from './rule.js'
|
22
|
-
import
|
23
|
-
import list from './list.js'
|
24
|
-
import LazyResult from './lazy-result.js'
|
25
|
-
import Processor from './processor.js'
|
25
|
+
import Warning, { WarningOptions } from './warning.js'
|
26
26
|
|
27
27
|
type DocumentProcessor = (
|
28
28
|
document: Document,
|
@@ -42,42 +42,33 @@ type CommentProcessor = (
|
|
42
42
|
|
43
43
|
interface Processors {
|
44
44
|
/**
|
45
|
-
* Will be called on `
|
45
|
+
* Will be called on all`AtRule` nodes.
|
46
46
|
*
|
47
|
-
* Will be called again on children changes.
|
47
|
+
* Will be called again on node or children changes.
|
48
48
|
*/
|
49
|
-
|
49
|
+
AtRule?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
|
50
50
|
|
51
51
|
/**
|
52
|
-
* Will be called on `
|
52
|
+
* Will be called on all `AtRule` nodes, when all children will be processed.
|
53
53
|
*
|
54
|
-
* Will be called again on children changes.
|
55
|
-
*/
|
56
|
-
DocumentExit?: DocumentProcessor
|
57
|
-
|
58
|
-
/**
|
59
|
-
* Will be called on `Root` node once.
|
60
|
-
*/
|
61
|
-
Once?: RootProcessor
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Will be called on `Root` node once, when all children will be processed.
|
54
|
+
* Will be called again on node or children changes.
|
65
55
|
*/
|
66
|
-
|
56
|
+
AtRuleExit?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
|
67
57
|
|
68
58
|
/**
|
69
|
-
* Will be called on `
|
59
|
+
* Will be called on all `Comment` nodes.
|
70
60
|
*
|
71
|
-
* Will be called again on children changes.
|
61
|
+
* Will be called again on node or children changes.
|
72
62
|
*/
|
73
|
-
|
63
|
+
Comment?: CommentProcessor
|
74
64
|
|
75
65
|
/**
|
76
|
-
* Will be called on `
|
66
|
+
* Will be called on all `Comment` nodes after listeners
|
67
|
+
* for `Comment` event.
|
77
68
|
*
|
78
|
-
* Will be called again on children changes.
|
69
|
+
* Will be called again on node or children changes.
|
79
70
|
*/
|
80
|
-
|
71
|
+
CommentExit?: CommentProcessor
|
81
72
|
|
82
73
|
/**
|
83
74
|
* Will be called on all `Declaration` nodes after listeners
|
@@ -85,7 +76,7 @@ interface Processors {
|
|
85
76
|
*
|
86
77
|
* Will be called again on node or children changes.
|
87
78
|
*/
|
88
|
-
Declaration?:
|
79
|
+
Declaration?: { [prop: string]: DeclarationProcessor } | DeclarationProcessor
|
89
80
|
|
90
81
|
/**
|
91
82
|
* Will be called on all `Declaration` nodes.
|
@@ -93,94 +84,103 @@ interface Processors {
|
|
93
84
|
* Will be called again on node or children changes.
|
94
85
|
*/
|
95
86
|
DeclarationExit?:
|
96
|
-
| DeclarationProcessor
|
97
87
|
| { [prop: string]: DeclarationProcessor }
|
88
|
+
| DeclarationProcessor
|
98
89
|
|
99
90
|
/**
|
100
|
-
* Will be called on
|
91
|
+
* Will be called on `Document` node.
|
101
92
|
*
|
102
|
-
* Will be called again on
|
93
|
+
* Will be called again on children changes.
|
103
94
|
*/
|
104
|
-
|
95
|
+
Document?: DocumentProcessor
|
105
96
|
|
106
97
|
/**
|
107
|
-
* Will be called on
|
98
|
+
* Will be called on `Document` node, when all children will be processed.
|
108
99
|
*
|
109
|
-
* Will be called again on
|
100
|
+
* Will be called again on children changes.
|
110
101
|
*/
|
111
|
-
|
102
|
+
DocumentExit?: DocumentProcessor
|
112
103
|
|
113
104
|
/**
|
114
|
-
* Will be called on
|
105
|
+
* Will be called on `Root` node once.
|
106
|
+
*/
|
107
|
+
Once?: RootProcessor
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Will be called on `Root` node once, when all children will be processed.
|
111
|
+
*/
|
112
|
+
OnceExit?: RootProcessor
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Will be called on `Root` node.
|
115
116
|
*
|
116
|
-
* Will be called again on
|
117
|
+
* Will be called again on children changes.
|
117
118
|
*/
|
118
|
-
|
119
|
+
Root?: RootProcessor
|
119
120
|
|
120
121
|
/**
|
121
|
-
* Will be called on
|
122
|
+
* Will be called on `Root` node, when all children will be processed.
|
122
123
|
*
|
123
|
-
* Will be called again on
|
124
|
+
* Will be called again on children changes.
|
124
125
|
*/
|
125
|
-
|
126
|
+
RootExit?: RootProcessor
|
126
127
|
|
127
128
|
/**
|
128
|
-
* Will be called on all `
|
129
|
+
* Will be called on all `Rule` nodes.
|
129
130
|
*
|
130
131
|
* Will be called again on node or children changes.
|
131
132
|
*/
|
132
|
-
|
133
|
+
Rule?: RuleProcessor
|
133
134
|
|
134
135
|
/**
|
135
|
-
* Will be called on all `
|
136
|
-
* for `Comment` event.
|
136
|
+
* Will be called on all `Rule` nodes, when all children will be processed.
|
137
137
|
*
|
138
138
|
* Will be called again on node or children changes.
|
139
139
|
*/
|
140
|
-
|
140
|
+
RuleExit?: RuleProcessor
|
141
141
|
}
|
142
142
|
|
143
143
|
declare namespace postcss {
|
144
144
|
export {
|
145
|
-
|
146
|
-
|
147
|
-
|
145
|
+
AnyNode,
|
146
|
+
AtRule,
|
147
|
+
AtRuleProps,
|
148
|
+
ChildNode,
|
149
|
+
ChildProps,
|
150
|
+
Comment,
|
151
|
+
CommentProps,
|
152
|
+
Container,
|
148
153
|
ContainerProps,
|
149
|
-
|
154
|
+
CssSyntaxError,
|
155
|
+
Declaration,
|
156
|
+
DeclarationProps,
|
157
|
+
Document,
|
150
158
|
DocumentProps,
|
151
159
|
FilePosition,
|
152
|
-
|
153
|
-
AtRuleProps,
|
154
|
-
Declaration,
|
155
|
-
ChildProps,
|
160
|
+
Input,
|
156
161
|
LazyResult,
|
157
|
-
|
162
|
+
list,
|
163
|
+
Message,
|
164
|
+
Node,
|
165
|
+
NodeErrorOptions,
|
158
166
|
NodeProps,
|
159
|
-
Processor,
|
160
|
-
RuleProps,
|
161
|
-
RootProps,
|
162
|
-
Container,
|
163
167
|
Position,
|
164
|
-
|
165
|
-
AnyNode,
|
166
|
-
Warning,
|
167
|
-
Message,
|
168
|
-
Comment,
|
169
|
-
Source,
|
170
|
-
AtRule,
|
168
|
+
Processor,
|
171
169
|
Result,
|
172
|
-
|
173
|
-
|
174
|
-
list,
|
170
|
+
Root,
|
171
|
+
RootProps,
|
175
172
|
Rule,
|
176
|
-
|
173
|
+
RuleProps,
|
174
|
+
Source,
|
175
|
+
Warning,
|
176
|
+
WarningOptions
|
177
177
|
}
|
178
178
|
|
179
179
|
export type SourceMap = SourceMapGenerator & {
|
180
180
|
toJSON(): RawSourceMap
|
181
181
|
}
|
182
182
|
|
183
|
-
export type Helpers = {
|
183
|
+
export type Helpers = { postcss: Postcss; result: Result } & Postcss
|
184
184
|
|
185
185
|
export interface Plugin extends Processors {
|
186
186
|
postcssPlugin: string
|
@@ -207,24 +207,24 @@ declare namespace postcss {
|
|
207
207
|
}
|
208
208
|
|
209
209
|
export type AcceptedPlugin =
|
210
|
-
| Plugin
|
211
|
-
| PluginCreator<any>
|
212
|
-
| OldPlugin<any>
|
213
|
-
| TransformCallback
|
214
210
|
| {
|
215
|
-
postcss:
|
211
|
+
postcss: Processor | TransformCallback
|
216
212
|
}
|
213
|
+
| OldPlugin<any>
|
214
|
+
| Plugin
|
215
|
+
| PluginCreator<any>
|
217
216
|
| Processor
|
217
|
+
| TransformCallback
|
218
218
|
|
219
|
-
export interface Parser<RootNode =
|
219
|
+
export interface Parser<RootNode = Document | Root> {
|
220
220
|
(
|
221
|
-
css:
|
222
|
-
opts?: Pick<ProcessOptions, '
|
221
|
+
css: { toString(): string } | string,
|
222
|
+
opts?: Pick<ProcessOptions, 'from' | 'map'>
|
223
223
|
): RootNode
|
224
224
|
}
|
225
225
|
|
226
226
|
export interface Builder {
|
227
|
-
(part: string, node?: AnyNode, type?: '
|
227
|
+
(part: string, node?: AnyNode, type?: 'end' | 'start'): void
|
228
228
|
}
|
229
229
|
|
230
230
|
export interface Stringifier {
|
@@ -232,8 +232,8 @@ declare namespace postcss {
|
|
232
232
|
}
|
233
233
|
|
234
234
|
export interface JSONHydrator {
|
235
|
-
(data: object[]): Node[]
|
236
235
|
(data: object): Node
|
236
|
+
(data: object[]): Node[]
|
237
237
|
}
|
238
238
|
|
239
239
|
export interface Syntax {
|
@@ -249,6 +249,30 @@ declare namespace postcss {
|
|
249
249
|
}
|
250
250
|
|
251
251
|
export interface SourceMapOptions {
|
252
|
+
/**
|
253
|
+
* Use absolute path in generated source map.
|
254
|
+
*/
|
255
|
+
absolute?: boolean
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Indicates that PostCSS should add annotation comments to the CSS.
|
259
|
+
* By default, PostCSS will always add a comment with a path
|
260
|
+
* to the source map. PostCSS will not add annotations to CSS files
|
261
|
+
* that do not contain any comments.
|
262
|
+
*
|
263
|
+
* By default, PostCSS presumes that you want to save the source map as
|
264
|
+
* `opts.to + '.map'` and will use this path in the annotation comment.
|
265
|
+
* A different path can be set by providing a string value for annotation.
|
266
|
+
*
|
267
|
+
* If you have set `inline: true`, annotation cannot be disabled.
|
268
|
+
*/
|
269
|
+
annotation?: ((file: string, root: Root) => string) | boolean | string
|
270
|
+
|
271
|
+
/**
|
272
|
+
* Override `from` in map’s sources.
|
273
|
+
*/
|
274
|
+
from?: string
|
275
|
+
|
252
276
|
/**
|
253
277
|
* Indicates that the source map should be embedded in the output CSS
|
254
278
|
* as a Base64-encoded comment. By default, it is `true`.
|
@@ -269,7 +293,7 @@ declare namespace postcss {
|
|
269
293
|
*
|
270
294
|
* If desired, you can omit the previous map with prev: `false`.
|
271
295
|
*/
|
272
|
-
prev?: string | boolean | object |
|
296
|
+
prev?: ((file: string) => string) | boolean | object | string
|
273
297
|
|
274
298
|
/**
|
275
299
|
* Indicates that PostCSS should set the origin content (e.g., Sass source)
|
@@ -278,30 +302,6 @@ declare namespace postcss {
|
|
278
302
|
* do not set this option.
|
279
303
|
*/
|
280
304
|
sourcesContent?: boolean
|
281
|
-
|
282
|
-
/**
|
283
|
-
* Indicates that PostCSS should add annotation comments to the CSS.
|
284
|
-
* By default, PostCSS will always add a comment with a path
|
285
|
-
* to the source map. PostCSS will not add annotations to CSS files
|
286
|
-
* that do not contain any comments.
|
287
|
-
*
|
288
|
-
* By default, PostCSS presumes that you want to save the source map as
|
289
|
-
* `opts.to + '.map'` and will use this path in the annotation comment.
|
290
|
-
* A different path can be set by providing a string value for annotation.
|
291
|
-
*
|
292
|
-
* If you have set `inline: true`, annotation cannot be disabled.
|
293
|
-
*/
|
294
|
-
annotation?: string | boolean | ((file: string, root: Root) => string)
|
295
|
-
|
296
|
-
/**
|
297
|
-
* Override `from` in map’s sources.
|
298
|
-
*/
|
299
|
-
from?: string
|
300
|
-
|
301
|
-
/**
|
302
|
-
* Use absolute path in generated source map.
|
303
|
-
*/
|
304
|
-
absolute?: boolean
|
305
305
|
}
|
306
306
|
|
307
307
|
export interface ProcessOptions {
|
@@ -312,20 +312,19 @@ declare namespace postcss {
|
|
312
312
|
from?: string
|
313
313
|
|
314
314
|
/**
|
315
|
-
*
|
316
|
-
* to generate correct source maps.
|
315
|
+
* Source map options
|
317
316
|
*/
|
318
|
-
|
317
|
+
map?: boolean | SourceMapOptions
|
319
318
|
|
320
319
|
/**
|
321
320
|
* Function to generate AST by string.
|
322
321
|
*/
|
323
|
-
parser?:
|
322
|
+
parser?: Parser | Syntax
|
324
323
|
|
325
324
|
/**
|
326
325
|
* Class to generate string by AST.
|
327
326
|
*/
|
328
|
-
stringifier?:
|
327
|
+
stringifier?: Stringifier | Syntax
|
329
328
|
|
330
329
|
/**
|
331
330
|
* Object with parse and stringify.
|
@@ -333,9 +332,10 @@ declare namespace postcss {
|
|
333
332
|
syntax?: Syntax
|
334
333
|
|
335
334
|
/**
|
336
|
-
*
|
335
|
+
* The path where you'll put the output CSS file. You should always set `to`
|
336
|
+
* to generate correct source maps.
|
337
337
|
*/
|
338
|
-
|
338
|
+
to?: string
|
339
339
|
}
|
340
340
|
|
341
341
|
export type Postcss = typeof postcss
|
package/lib/previous-map.d.ts
CHANGED
@@ -21,35 +21,35 @@ declare namespace PreviousMap {
|
|
21
21
|
*/
|
22
22
|
declare class PreviousMap_ {
|
23
23
|
/**
|
24
|
-
*
|
24
|
+
* `sourceMappingURL` content.
|
25
25
|
*/
|
26
|
-
|
26
|
+
annotation?: string
|
27
27
|
|
28
28
|
/**
|
29
|
-
* `
|
29
|
+
* The CSS source identifier. Contains `Input#file` if the user
|
30
|
+
* set the `from` option, or `Input#id` if they did not.
|
30
31
|
*/
|
31
|
-
|
32
|
+
file?: string
|
32
33
|
|
33
34
|
/**
|
34
|
-
*
|
35
|
+
* Was source map inlined by data-uri to input CSS.
|
35
36
|
*/
|
36
|
-
|
37
|
+
inline: boolean
|
37
38
|
|
38
39
|
/**
|
39
|
-
*
|
40
|
+
* Path to source map file.
|
40
41
|
*/
|
41
|
-
|
42
|
+
mapFile?: string
|
42
43
|
|
43
44
|
/**
|
44
|
-
* The
|
45
|
-
* set the `from` option, or `Input#id` if they did not.
|
45
|
+
* The directory with source map file, if source map is in separated file.
|
46
46
|
*/
|
47
|
-
|
47
|
+
root?: string
|
48
48
|
|
49
49
|
/**
|
50
|
-
*
|
50
|
+
* Source map file content.
|
51
51
|
*/
|
52
|
-
|
52
|
+
text?: string
|
53
53
|
|
54
54
|
/**
|
55
55
|
* @param css Input CSS source.
|
package/lib/previous-map.js
CHANGED
@@ -35,22 +35,37 @@ class PreviousMap {
|
|
35
35
|
return this.consumerCache
|
36
36
|
}
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
38
|
+
decodeInline(text) {
|
39
|
+
let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/
|
40
|
+
let baseUri = /^data:application\/json;base64,/
|
41
|
+
let charsetUri = /^data:application\/json;charset=utf-?8,/
|
42
|
+
let uri = /^data:application\/json,/
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
if (charsetUri.test(text) || uri.test(text)) {
|
45
|
+
return decodeURIComponent(text.substr(RegExp.lastMatch.length))
|
46
|
+
}
|
47
|
+
|
48
|
+
if (baseCharsetUri.test(text) || baseUri.test(text)) {
|
49
|
+
return fromBase64(text.substr(RegExp.lastMatch.length))
|
50
|
+
}
|
51
|
+
|
52
|
+
let encoding = text.match(/data:application\/json;([^,]+),/)[1]
|
53
|
+
throw new Error('Unsupported source map encoding ' + encoding)
|
48
54
|
}
|
49
55
|
|
50
56
|
getAnnotationURL(sourceMapString) {
|
51
57
|
return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
|
52
58
|
}
|
53
59
|
|
60
|
+
isMap(map) {
|
61
|
+
if (typeof map !== 'object') return false
|
62
|
+
return (
|
63
|
+
typeof map.mappings === 'string' ||
|
64
|
+
typeof map._mappings === 'string' ||
|
65
|
+
Array.isArray(map.sections)
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
54
69
|
loadAnnotation(css) {
|
55
70
|
let comments = css.match(/\/\*\s*# sourceMappingURL=/gm)
|
56
71
|
if (!comments) return
|
@@ -65,24 +80,6 @@ class PreviousMap {
|
|
65
80
|
}
|
66
81
|
}
|
67
82
|
|
68
|
-
decodeInline(text) {
|
69
|
-
let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/
|
70
|
-
let baseUri = /^data:application\/json;base64,/
|
71
|
-
let charsetUri = /^data:application\/json;charset=utf-?8,/
|
72
|
-
let uri = /^data:application\/json,/
|
73
|
-
|
74
|
-
if (charsetUri.test(text) || uri.test(text)) {
|
75
|
-
return decodeURIComponent(text.substr(RegExp.lastMatch.length))
|
76
|
-
}
|
77
|
-
|
78
|
-
if (baseCharsetUri.test(text) || baseUri.test(text)) {
|
79
|
-
return fromBase64(text.substr(RegExp.lastMatch.length))
|
80
|
-
}
|
81
|
-
|
82
|
-
let encoding = text.match(/data:application\/json;([^,]+),/)[1]
|
83
|
-
throw new Error('Unsupported source map encoding ' + encoding)
|
84
|
-
}
|
85
|
-
|
86
83
|
loadFile(path) {
|
87
84
|
this.root = dirname(path)
|
88
85
|
if (existsSync(path)) {
|
@@ -128,12 +125,15 @@ class PreviousMap {
|
|
128
125
|
}
|
129
126
|
}
|
130
127
|
|
131
|
-
|
132
|
-
if (
|
133
|
-
return (
|
134
|
-
|
135
|
-
|
136
|
-
|
128
|
+
startWith(string, start) {
|
129
|
+
if (!string) return false
|
130
|
+
return string.substr(0, start.length) === start
|
131
|
+
}
|
132
|
+
|
133
|
+
withContent() {
|
134
|
+
return !!(
|
135
|
+
this.consumer().sourcesContent &&
|
136
|
+
this.consumer().sourcesContent.length > 0
|
137
137
|
)
|
138
138
|
}
|
139
139
|
}
|
package/lib/processor.d.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
+
import LazyResult from './lazy-result.js'
|
2
|
+
import NoWorkResult from './no-work-result.js'
|
1
3
|
import {
|
2
4
|
AcceptedPlugin,
|
3
5
|
Plugin,
|
4
6
|
ProcessOptions,
|
5
|
-
|
6
|
-
|
7
|
+
TransformCallback,
|
8
|
+
Transformer
|
7
9
|
} from './postcss.js'
|
8
|
-
import LazyResult from './lazy-result.js'
|
9
10
|
import Result from './result.js'
|
10
11
|
import Root from './root.js'
|
11
|
-
import NoWorkResult from './no-work-result.js'
|
12
12
|
|
13
13
|
declare namespace Processor {
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
@@ -27,31 +27,55 @@ declare namespace Processor {
|
|
27
27
|
*/
|
28
28
|
declare class Processor_ {
|
29
29
|
/**
|
30
|
-
*
|
30
|
+
* Plugins added to this processor.
|
31
31
|
*
|
32
32
|
* ```js
|
33
|
-
*
|
34
|
-
*
|
35
|
-
* }
|
33
|
+
* const processor = postcss([autoprefixer, postcssNested])
|
34
|
+
* processor.plugins.length //=> 2
|
36
35
|
* ```
|
37
36
|
*/
|
38
|
-
|
37
|
+
plugins: (Plugin | TransformCallback | Transformer)[]
|
39
38
|
|
40
39
|
/**
|
41
|
-
*
|
40
|
+
* Current PostCSS version.
|
42
41
|
*
|
43
42
|
* ```js
|
44
|
-
*
|
45
|
-
*
|
43
|
+
* if (result.processor.version.split('.')[0] !== '6') {
|
44
|
+
* throw new Error('This plugin works only with PostCSS 6')
|
45
|
+
* }
|
46
46
|
* ```
|
47
47
|
*/
|
48
|
-
|
48
|
+
version: string
|
49
49
|
|
50
50
|
/**
|
51
51
|
* @param plugins PostCSS plugins
|
52
52
|
*/
|
53
53
|
constructor(plugins?: AcceptedPlugin[])
|
54
54
|
|
55
|
+
/**
|
56
|
+
* Parses source CSS and returns a `LazyResult` Promise proxy.
|
57
|
+
* Because some plugins can be asynchronous it doesn’t make
|
58
|
+
* any transformations. Transformations will be applied
|
59
|
+
* in the `LazyResult` methods.
|
60
|
+
*
|
61
|
+
* ```js
|
62
|
+
* processor.process(css, { from: 'a.css', to: 'a.out.css' })
|
63
|
+
* .then(result => {
|
64
|
+
* console.log(result.css)
|
65
|
+
* })
|
66
|
+
* ```
|
67
|
+
*
|
68
|
+
* @param css String with input CSS or any object with a `toString()` method,
|
69
|
+
* like a Buffer. Optionally, send a `Result` instance
|
70
|
+
* and the processor will take the `Root` from it.
|
71
|
+
* @param opts Options.
|
72
|
+
* @return Promise proxy.
|
73
|
+
*/
|
74
|
+
process(
|
75
|
+
css: { toString(): string } | LazyResult | Result | Root | string,
|
76
|
+
options?: ProcessOptions
|
77
|
+
): LazyResult | NoWorkResult
|
78
|
+
|
55
79
|
/**
|
56
80
|
* Adds a plugin to be used as a CSS processor.
|
57
81
|
*
|
@@ -80,30 +104,6 @@ declare class Processor_ {
|
|
80
104
|
* @return Current processor to make methods chain.
|
81
105
|
*/
|
82
106
|
use(plugin: AcceptedPlugin): this
|
83
|
-
|
84
|
-
/**
|
85
|
-
* Parses source CSS and returns a `LazyResult` Promise proxy.
|
86
|
-
* Because some plugins can be asynchronous it doesn’t make
|
87
|
-
* any transformations. Transformations will be applied
|
88
|
-
* in the `LazyResult` methods.
|
89
|
-
*
|
90
|
-
* ```js
|
91
|
-
* processor.process(css, { from: 'a.css', to: 'a.out.css' })
|
92
|
-
* .then(result => {
|
93
|
-
* console.log(result.css)
|
94
|
-
* })
|
95
|
-
* ```
|
96
|
-
*
|
97
|
-
* @param css String with input CSS or any object with a `toString()` method,
|
98
|
-
* like a Buffer. Optionally, send a `Result` instance
|
99
|
-
* and the processor will take the `Root` from it.
|
100
|
-
* @param opts Options.
|
101
|
-
* @return Promise proxy.
|
102
|
-
*/
|
103
|
-
process(
|
104
|
-
css: string | { toString(): string } | Result | LazyResult | Root,
|
105
|
-
options?: ProcessOptions
|
106
|
-
): LazyResult | NoWorkResult
|
107
107
|
}
|
108
108
|
|
109
109
|
declare class Processor extends Processor_ {}
|