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/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,101 +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
|
115
|
-
*
|
116
|
-
* Will be called again on node or children changes.
|
105
|
+
* Will be called on `Root` node once.
|
117
106
|
*/
|
118
|
-
|
107
|
+
Once?: RootProcessor
|
119
108
|
|
120
109
|
/**
|
121
|
-
* Will be called on
|
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.
|
122
116
|
*
|
123
|
-
* Will be called again on
|
117
|
+
* Will be called again on children changes.
|
124
118
|
*/
|
125
|
-
|
119
|
+
Root?: RootProcessor
|
126
120
|
|
127
121
|
/**
|
128
|
-
* Will be called on
|
122
|
+
* Will be called on `Root` node, when all children will be processed.
|
129
123
|
*
|
130
|
-
* Will be called again on
|
124
|
+
* Will be called again on children changes.
|
131
125
|
*/
|
132
|
-
|
126
|
+
RootExit?: RootProcessor
|
133
127
|
|
134
128
|
/**
|
135
|
-
* Will be called on all `
|
136
|
-
* for `Comment` event.
|
129
|
+
* Will be called on all `Rule` nodes.
|
137
130
|
*
|
138
131
|
* Will be called again on node or children changes.
|
139
132
|
*/
|
140
|
-
|
133
|
+
Rule?: RuleProcessor
|
141
134
|
|
142
135
|
/**
|
143
|
-
* Will be called when all
|
136
|
+
* Will be called on all `Rule` nodes, when all children will be processed.
|
144
137
|
*
|
145
|
-
*
|
138
|
+
* Will be called again on node or children changes.
|
146
139
|
*/
|
147
|
-
|
140
|
+
RuleExit?: RuleProcessor
|
148
141
|
}
|
149
142
|
|
150
143
|
declare namespace postcss {
|
151
144
|
export {
|
152
|
-
|
153
|
-
|
154
|
-
|
145
|
+
AnyNode,
|
146
|
+
AtRule,
|
147
|
+
AtRuleProps,
|
148
|
+
ChildNode,
|
149
|
+
ChildProps,
|
150
|
+
Comment,
|
151
|
+
CommentProps,
|
152
|
+
Container,
|
155
153
|
ContainerProps,
|
156
|
-
|
154
|
+
CssSyntaxError,
|
155
|
+
Declaration,
|
156
|
+
DeclarationProps,
|
157
|
+
Document,
|
157
158
|
DocumentProps,
|
158
159
|
FilePosition,
|
159
|
-
|
160
|
-
AtRuleProps,
|
161
|
-
Declaration,
|
162
|
-
ChildProps,
|
160
|
+
Input,
|
163
161
|
LazyResult,
|
164
|
-
|
162
|
+
list,
|
163
|
+
Message,
|
164
|
+
Node,
|
165
|
+
NodeErrorOptions,
|
165
166
|
NodeProps,
|
166
|
-
Processor,
|
167
|
-
RuleProps,
|
168
|
-
RootProps,
|
169
|
-
Container,
|
170
167
|
Position,
|
171
|
-
|
172
|
-
AnyNode,
|
173
|
-
Warning,
|
174
|
-
Message,
|
175
|
-
Comment,
|
176
|
-
Source,
|
177
|
-
AtRule,
|
168
|
+
Processor,
|
178
169
|
Result,
|
179
|
-
|
180
|
-
|
181
|
-
list,
|
170
|
+
Root,
|
171
|
+
RootProps,
|
182
172
|
Rule,
|
183
|
-
|
173
|
+
RuleProps,
|
174
|
+
Source,
|
175
|
+
Warning,
|
176
|
+
WarningOptions
|
184
177
|
}
|
185
178
|
|
186
179
|
export type SourceMap = SourceMapGenerator & {
|
187
180
|
toJSON(): RawSourceMap
|
188
181
|
}
|
189
182
|
|
190
|
-
export type Helpers = {
|
183
|
+
export type Helpers = { postcss: Postcss; result: Result } & Postcss
|
191
184
|
|
192
185
|
export interface Plugin extends Processors {
|
193
186
|
postcssPlugin: string
|
@@ -214,24 +207,24 @@ declare namespace postcss {
|
|
214
207
|
}
|
215
208
|
|
216
209
|
export type AcceptedPlugin =
|
217
|
-
| Plugin
|
218
|
-
| PluginCreator<any>
|
219
|
-
| OldPlugin<any>
|
220
|
-
| TransformCallback
|
221
210
|
| {
|
222
|
-
postcss:
|
211
|
+
postcss: Processor | TransformCallback
|
223
212
|
}
|
213
|
+
| OldPlugin<any>
|
214
|
+
| Plugin
|
215
|
+
| PluginCreator<any>
|
224
216
|
| Processor
|
217
|
+
| TransformCallback
|
225
218
|
|
226
|
-
export interface Parser<RootNode =
|
219
|
+
export interface Parser<RootNode = Document | Root> {
|
227
220
|
(
|
228
|
-
css:
|
229
|
-
opts?: Pick<ProcessOptions, '
|
221
|
+
css: { toString(): string } | string,
|
222
|
+
opts?: Pick<ProcessOptions, 'from' | 'map'>
|
230
223
|
): RootNode
|
231
224
|
}
|
232
225
|
|
233
226
|
export interface Builder {
|
234
|
-
(part: string, node?: AnyNode, type?: '
|
227
|
+
(part: string, node?: AnyNode, type?: 'end' | 'start'): void
|
235
228
|
}
|
236
229
|
|
237
230
|
export interface Stringifier {
|
@@ -239,8 +232,8 @@ declare namespace postcss {
|
|
239
232
|
}
|
240
233
|
|
241
234
|
export interface JSONHydrator {
|
242
|
-
(data: object[]): Node[]
|
243
235
|
(data: object): Node
|
236
|
+
(data: object[]): Node[]
|
244
237
|
}
|
245
238
|
|
246
239
|
export interface Syntax {
|
@@ -256,6 +249,30 @@ declare namespace postcss {
|
|
256
249
|
}
|
257
250
|
|
258
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
|
+
|
259
276
|
/**
|
260
277
|
* Indicates that the source map should be embedded in the output CSS
|
261
278
|
* as a Base64-encoded comment. By default, it is `true`.
|
@@ -276,7 +293,7 @@ declare namespace postcss {
|
|
276
293
|
*
|
277
294
|
* If desired, you can omit the previous map with prev: `false`.
|
278
295
|
*/
|
279
|
-
prev?: string | boolean | object |
|
296
|
+
prev?: ((file: string) => string) | boolean | object | string
|
280
297
|
|
281
298
|
/**
|
282
299
|
* Indicates that PostCSS should set the origin content (e.g., Sass source)
|
@@ -285,30 +302,6 @@ declare namespace postcss {
|
|
285
302
|
* do not set this option.
|
286
303
|
*/
|
287
304
|
sourcesContent?: boolean
|
288
|
-
|
289
|
-
/**
|
290
|
-
* Indicates that PostCSS should add annotation comments to the CSS.
|
291
|
-
* By default, PostCSS will always add a comment with a path
|
292
|
-
* to the source map. PostCSS will not add annotations to CSS files
|
293
|
-
* that do not contain any comments.
|
294
|
-
*
|
295
|
-
* By default, PostCSS presumes that you want to save the source map as
|
296
|
-
* `opts.to + '.map'` and will use this path in the annotation comment.
|
297
|
-
* A different path can be set by providing a string value for annotation.
|
298
|
-
*
|
299
|
-
* If you have set `inline: true`, annotation cannot be disabled.
|
300
|
-
*/
|
301
|
-
annotation?: string | boolean | ((file: string, root: Root) => string)
|
302
|
-
|
303
|
-
/**
|
304
|
-
* Override `from` in map’s sources.
|
305
|
-
*/
|
306
|
-
from?: string
|
307
|
-
|
308
|
-
/**
|
309
|
-
* Use absolute path in generated source map.
|
310
|
-
*/
|
311
|
-
absolute?: boolean
|
312
305
|
}
|
313
306
|
|
314
307
|
export interface ProcessOptions {
|
@@ -319,20 +312,19 @@ declare namespace postcss {
|
|
319
312
|
from?: string
|
320
313
|
|
321
314
|
/**
|
322
|
-
*
|
323
|
-
* to generate correct source maps.
|
315
|
+
* Source map options
|
324
316
|
*/
|
325
|
-
|
317
|
+
map?: boolean | SourceMapOptions
|
326
318
|
|
327
319
|
/**
|
328
320
|
* Function to generate AST by string.
|
329
321
|
*/
|
330
|
-
parser?:
|
322
|
+
parser?: Parser | Syntax
|
331
323
|
|
332
324
|
/**
|
333
325
|
* Class to generate string by AST.
|
334
326
|
*/
|
335
|
-
stringifier?:
|
327
|
+
stringifier?: Stringifier | Syntax
|
336
328
|
|
337
329
|
/**
|
338
330
|
* Object with parse and stringify.
|
@@ -340,9 +332,10 @@ declare namespace postcss {
|
|
340
332
|
syntax?: Syntax
|
341
333
|
|
342
334
|
/**
|
343
|
-
*
|
335
|
+
* The path where you'll put the output CSS file. You should always set `to`
|
336
|
+
* to generate correct source maps.
|
344
337
|
*/
|
345
|
-
|
338
|
+
to?: string
|
346
339
|
}
|
347
340
|
|
348
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_ {}
|