postcss 8.3.9 → 8.4.31
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/README.md +7 -23
- package/lib/at-rule.d.ts +58 -49
- package/lib/comment.d.ts +43 -32
- package/lib/container.d.ts +233 -223
- package/lib/container.js +251 -244
- package/lib/css-syntax-error.d.ts +117 -61
- package/lib/css-syntax-error.js +10 -3
- package/lib/declaration.d.ts +85 -61
- package/lib/document.d.ts +27 -16
- package/lib/fromJSON.d.ts +6 -2
- package/lib/input.d.ts +118 -54
- package/lib/input.js +87 -55
- package/lib/lazy-result.d.ts +82 -67
- package/lib/lazy-result.js +234 -232
- package/lib/list.d.ts +53 -47
- package/lib/list.js +16 -14
- package/lib/map-generator.js +231 -172
- package/lib/no-work-result.d.ts +46 -0
- package/lib/no-work-result.js +135 -0
- package/lib/node.d.ts +345 -253
- package/lib/node.js +200 -139
- package/lib/parse.d.ts +6 -2
- package/lib/parser.js +354 -309
- package/lib/postcss.d.mts +72 -0
- package/lib/postcss.d.ts +288 -319
- package/lib/postcss.js +18 -12
- package/lib/postcss.mjs +1 -0
- package/lib/previous-map.d.ts +23 -14
- package/lib/previous-map.js +37 -40
- package/lib/processor.d.ts +55 -41
- package/lib/processor.js +20 -27
- package/lib/result.d.ts +87 -76
- package/lib/root.d.ts +49 -36
- package/lib/root.js +12 -10
- package/lib/rule.d.ts +54 -45
- package/lib/stringifier.d.ts +46 -0
- package/lib/stringifier.js +140 -138
- package/lib/stringify.d.ts +6 -2
- package/lib/terminal-highlight.js +11 -11
- package/lib/tokenize.js +2 -2
- package/lib/warn-once.js +1 -0
- package/lib/warning.d.ts +79 -36
- package/lib/warning.js +6 -4
- package/package.json +20 -10
package/lib/postcss.d.ts
CHANGED
@@ -1,168 +1,59 @@
|
|
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 Root, { RootProps } from './root.js'
|
14
|
-
import Document, { DocumentProps } from './document.js'
|
15
|
-
import Comment, { CommentProps } from './comment.js'
|
16
|
-
import AtRule, { AtRuleProps } from './at-rule.js'
|
21
|
+
import Processor from './processor.js'
|
17
22
|
import Result, { Message } from './result.js'
|
18
|
-
import
|
23
|
+
import Root, { RootProps } from './root.js'
|
19
24
|
import Rule, { RuleProps } from './rule.js'
|
20
|
-
import Container, { ContainerProps } from './container.js'
|
21
25
|
import Warning, { WarningOptions } from './warning.js'
|
22
|
-
import Input, { FilePosition } from './input.js'
|
23
|
-
import CssSyntaxError from './css-syntax-error.js'
|
24
|
-
import list, { List } from './list.js'
|
25
|
-
import Processor from './processor.js'
|
26
|
-
|
27
|
-
export {
|
28
|
-
WarningOptions,
|
29
|
-
FilePosition,
|
30
|
-
Position,
|
31
|
-
Source,
|
32
|
-
ChildNode,
|
33
|
-
AnyNode,
|
34
|
-
Message,
|
35
|
-
NodeErrorOptions,
|
36
|
-
NodeProps,
|
37
|
-
DeclarationProps,
|
38
|
-
ContainerProps,
|
39
|
-
CommentProps,
|
40
|
-
RuleProps,
|
41
|
-
ChildProps,
|
42
|
-
AtRuleProps,
|
43
|
-
RootProps,
|
44
|
-
DocumentProps,
|
45
|
-
Warning,
|
46
|
-
CssSyntaxError,
|
47
|
-
Node,
|
48
|
-
Container,
|
49
|
-
list,
|
50
|
-
Declaration,
|
51
|
-
Comment,
|
52
|
-
AtRule,
|
53
|
-
Rule,
|
54
|
-
Root,
|
55
|
-
Document,
|
56
|
-
Result,
|
57
|
-
LazyResult,
|
58
|
-
Input
|
59
|
-
}
|
60
|
-
|
61
|
-
export type SourceMap = SourceMapGenerator & {
|
62
|
-
toJSON(): RawSourceMap
|
63
|
-
}
|
64
|
-
|
65
|
-
export type Helpers = { result: Result; postcss: Postcss } & Postcss
|
66
26
|
|
67
27
|
type DocumentProcessor = (
|
68
28
|
document: Document,
|
69
|
-
helper: Helpers
|
29
|
+
helper: postcss.Helpers
|
70
30
|
) => Promise<void> | void
|
71
|
-
type RootProcessor = (root: Root, helper: Helpers) => Promise<void> | void
|
31
|
+
type RootProcessor = (root: Root, helper: postcss.Helpers) => Promise<void> | void
|
72
32
|
type DeclarationProcessor = (
|
73
33
|
decl: Declaration,
|
74
|
-
helper: Helpers
|
34
|
+
helper: postcss.Helpers
|
75
35
|
) => Promise<void> | void
|
76
|
-
type RuleProcessor = (rule: Rule, helper: Helpers) => Promise<void> | void
|
77
|
-
type AtRuleProcessor = (atRule: AtRule, helper: Helpers) => Promise<void> | void
|
36
|
+
type RuleProcessor = (rule: Rule, helper: postcss.Helpers) => Promise<void> | void
|
37
|
+
type AtRuleProcessor = (atRule: AtRule, helper: postcss.Helpers) => Promise<void> | void
|
78
38
|
type CommentProcessor = (
|
79
39
|
comment: Comment,
|
80
|
-
helper: Helpers
|
40
|
+
helper: postcss.Helpers
|
81
41
|
) => Promise<void> | void
|
82
42
|
|
83
43
|
interface Processors {
|
84
|
-
/**
|
85
|
-
* Will be called on `Document` node.
|
86
|
-
*
|
87
|
-
* Will be called again on children changes.
|
88
|
-
*/
|
89
|
-
Document?: DocumentProcessor
|
90
|
-
|
91
|
-
/**
|
92
|
-
* Will be called on `Document` node, when all children will be processed.
|
93
|
-
*
|
94
|
-
* Will be called again on children changes.
|
95
|
-
*/
|
96
|
-
DocumentExit?: DocumentProcessor
|
97
|
-
|
98
|
-
/**
|
99
|
-
* Will be called on `Root` node once.
|
100
|
-
*/
|
101
|
-
Once?: RootProcessor
|
102
|
-
|
103
|
-
/**
|
104
|
-
* Will be called on `Root` node once, when all children will be processed.
|
105
|
-
*/
|
106
|
-
OnceExit?: RootProcessor
|
107
|
-
|
108
|
-
/**
|
109
|
-
* Will be called on `Root` node.
|
110
|
-
*
|
111
|
-
* Will be called again on children changes.
|
112
|
-
*/
|
113
|
-
Root?: RootProcessor
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Will be called on `Root` node, when all children will be processed.
|
117
|
-
*
|
118
|
-
* Will be called again on children changes.
|
119
|
-
*/
|
120
|
-
RootExit?: RootProcessor
|
121
|
-
|
122
|
-
/**
|
123
|
-
* Will be called on all `Declaration` nodes after listeners
|
124
|
-
* for `Declaration` event.
|
125
|
-
*
|
126
|
-
* Will be called again on node or children changes.
|
127
|
-
*/
|
128
|
-
Declaration?: DeclarationProcessor | { [prop: string]: DeclarationProcessor }
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Will be called on all `Declaration` nodes.
|
132
|
-
*
|
133
|
-
* Will be called again on node or children changes.
|
134
|
-
*/
|
135
|
-
DeclarationExit?:
|
136
|
-
| DeclarationProcessor
|
137
|
-
| { [prop: string]: DeclarationProcessor }
|
138
|
-
|
139
|
-
/**
|
140
|
-
* Will be called on all `Rule` nodes.
|
141
|
-
*
|
142
|
-
* Will be called again on node or children changes.
|
143
|
-
*/
|
144
|
-
Rule?: RuleProcessor
|
145
|
-
|
146
|
-
/**
|
147
|
-
* Will be called on all `Rule` nodes, when all children will be processed.
|
148
|
-
*
|
149
|
-
* Will be called again on node or children changes.
|
150
|
-
*/
|
151
|
-
RuleExit?: RuleProcessor
|
152
|
-
|
153
44
|
/**
|
154
45
|
* Will be called on all`AtRule` nodes.
|
155
46
|
*
|
156
47
|
* Will be called again on node or children changes.
|
157
48
|
*/
|
158
|
-
AtRule?:
|
49
|
+
AtRule?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
|
159
50
|
|
160
51
|
/**
|
161
52
|
* Will be called on all `AtRule` nodes, when all children will be processed.
|
162
53
|
*
|
163
54
|
* Will be called again on node or children changes.
|
164
55
|
*/
|
165
|
-
AtRuleExit?:
|
56
|
+
AtRuleExit?: { [name: string]: AtRuleProcessor } | AtRuleProcessor
|
166
57
|
|
167
58
|
/**
|
168
59
|
* Will be called on all `Comment` nodes.
|
@@ -180,192 +71,279 @@ interface Processors {
|
|
180
71
|
CommentExit?: CommentProcessor
|
181
72
|
|
182
73
|
/**
|
183
|
-
* Will be called
|
74
|
+
* Will be called on all `Declaration` nodes after listeners
|
75
|
+
* for `Declaration` event.
|
184
76
|
*
|
185
|
-
*
|
186
|
-
*/
|
187
|
-
Exit?: RootProcessor
|
188
|
-
}
|
189
|
-
|
190
|
-
export interface Plugin extends Processors {
|
191
|
-
postcssPlugin: string
|
192
|
-
prepare?: (result: Result) => Processors
|
193
|
-
}
|
194
|
-
|
195
|
-
export interface PluginCreator<PluginOptions> {
|
196
|
-
(opts?: PluginOptions): Plugin | Processor
|
197
|
-
postcss: true
|
198
|
-
}
|
199
|
-
|
200
|
-
export interface Transformer extends TransformCallback {
|
201
|
-
postcssPlugin: string
|
202
|
-
postcssVersion: string
|
203
|
-
}
|
204
|
-
|
205
|
-
export interface TransformCallback {
|
206
|
-
(root: Root, result: Result): Promise<void> | void
|
207
|
-
}
|
208
|
-
|
209
|
-
export interface OldPlugin<T> extends Transformer {
|
210
|
-
(opts?: T): Transformer
|
211
|
-
postcss: Transformer
|
212
|
-
}
|
213
|
-
|
214
|
-
export type AcceptedPlugin =
|
215
|
-
| Plugin
|
216
|
-
| PluginCreator<any>
|
217
|
-
| OldPlugin<any>
|
218
|
-
| TransformCallback
|
219
|
-
| {
|
220
|
-
postcss: TransformCallback | Processor
|
221
|
-
}
|
222
|
-
| Processor
|
223
|
-
|
224
|
-
export interface Parser<RootNode = Root> {
|
225
|
-
(
|
226
|
-
css: string | { toString(): string },
|
227
|
-
opts?: Pick<ProcessOptions, 'map' | 'from'>
|
228
|
-
): RootNode
|
229
|
-
}
|
230
|
-
|
231
|
-
export interface Builder {
|
232
|
-
(part: string, node?: AnyNode, type?: 'start' | 'end'): void
|
233
|
-
}
|
234
|
-
|
235
|
-
export interface Stringifier {
|
236
|
-
(node: AnyNode, builder: Builder): void
|
237
|
-
}
|
238
|
-
|
239
|
-
export interface JSONHydrator {
|
240
|
-
(data: object[]): Node[]
|
241
|
-
(data: object): Node
|
242
|
-
}
|
243
|
-
|
244
|
-
export interface Syntax {
|
245
|
-
/**
|
246
|
-
* Function to generate AST by string.
|
247
|
-
*/
|
248
|
-
parse?: Parser<Root | Document>
|
249
|
-
|
250
|
-
/**
|
251
|
-
* Class to generate string by AST.
|
77
|
+
* Will be called again on node or children changes.
|
252
78
|
*/
|
253
|
-
|
254
|
-
}
|
79
|
+
Declaration?: { [prop: string]: DeclarationProcessor } | DeclarationProcessor
|
255
80
|
|
256
|
-
export interface SourceMapOptions {
|
257
81
|
/**
|
258
|
-
*
|
259
|
-
* as a Base64-encoded comment. By default, it is `true`.
|
260
|
-
* But if all previous maps are external, not inline, PostCSS will not embed
|
261
|
-
* the map even if you do not set this option.
|
82
|
+
* Will be called on all `Declaration` nodes.
|
262
83
|
*
|
263
|
-
*
|
264
|
-
* as the source map will be contained within the text of `result.css`.
|
84
|
+
* Will be called again on node or children changes.
|
265
85
|
*/
|
266
|
-
|
86
|
+
DeclarationExit?:
|
87
|
+
| { [prop: string]: DeclarationProcessor }
|
88
|
+
| DeclarationProcessor
|
267
89
|
|
268
90
|
/**
|
269
|
-
*
|
270
|
-
*
|
271
|
-
* PostCSS will try to read the previous source map
|
272
|
-
* automatically (based on comments within the source CSS), but you can use
|
273
|
-
* this option to identify it manually.
|
91
|
+
* Will be called on `Document` node.
|
274
92
|
*
|
275
|
-
*
|
276
|
-
*/
|
277
|
-
prev?: string | boolean | object | ((file: string) => string)
|
278
|
-
|
279
|
-
/**
|
280
|
-
* Indicates that PostCSS should set the origin content (e.g., Sass source)
|
281
|
-
* of the source map. By default, it is true. But if all previous maps do not
|
282
|
-
* contain sources content, PostCSS will also leave it out even if you
|
283
|
-
* do not set this option.
|
93
|
+
* Will be called again on children changes.
|
284
94
|
*/
|
285
|
-
|
95
|
+
Document?: DocumentProcessor
|
286
96
|
|
287
97
|
/**
|
288
|
-
*
|
289
|
-
* By default, PostCSS will always add a comment with a path
|
290
|
-
* to the source map. PostCSS will not add annotations to CSS files
|
291
|
-
* that do not contain any comments.
|
292
|
-
*
|
293
|
-
* By default, PostCSS presumes that you want to save the source map as
|
294
|
-
* `opts.to + '.map'` and will use this path in the annotation comment.
|
295
|
-
* A different path can be set by providing a string value for annotation.
|
98
|
+
* Will be called on `Document` node, when all children will be processed.
|
296
99
|
*
|
297
|
-
*
|
298
|
-
*/
|
299
|
-
annotation?: string | boolean | ((file: string, root: Root) => string)
|
300
|
-
|
301
|
-
/**
|
302
|
-
* Override `from` in map’s sources.
|
303
|
-
*/
|
304
|
-
from?: string
|
305
|
-
|
306
|
-
/**
|
307
|
-
* Use absolute path in generated source map.
|
100
|
+
* Will be called again on children changes.
|
308
101
|
*/
|
309
|
-
|
310
|
-
}
|
102
|
+
DocumentExit?: DocumentProcessor
|
311
103
|
|
312
|
-
export interface ProcessOptions {
|
313
104
|
/**
|
314
|
-
*
|
315
|
-
* because it is used in source map generation and syntax error messages.
|
105
|
+
* Will be called on `Root` node once.
|
316
106
|
*/
|
317
|
-
|
107
|
+
Once?: RootProcessor
|
318
108
|
|
319
109
|
/**
|
320
|
-
*
|
321
|
-
* to generate correct source maps.
|
110
|
+
* Will be called on `Root` node once, when all children will be processed.
|
322
111
|
*/
|
323
|
-
|
112
|
+
OnceExit?: RootProcessor
|
324
113
|
|
325
114
|
/**
|
326
|
-
*
|
115
|
+
* Will be called on `Root` node.
|
116
|
+
*
|
117
|
+
* Will be called again on children changes.
|
327
118
|
*/
|
328
|
-
|
119
|
+
Root?: RootProcessor
|
329
120
|
|
330
121
|
/**
|
331
|
-
*
|
122
|
+
* Will be called on `Root` node, when all children will be processed.
|
123
|
+
*
|
124
|
+
* Will be called again on children changes.
|
332
125
|
*/
|
333
|
-
|
126
|
+
RootExit?: RootProcessor
|
334
127
|
|
335
128
|
/**
|
336
|
-
*
|
129
|
+
* Will be called on all `Rule` nodes.
|
130
|
+
*
|
131
|
+
* Will be called again on node or children changes.
|
337
132
|
*/
|
338
|
-
|
133
|
+
Rule?: RuleProcessor
|
339
134
|
|
340
135
|
/**
|
341
|
-
*
|
136
|
+
* Will be called on all `Rule` nodes, when all children will be processed.
|
137
|
+
*
|
138
|
+
* Will be called again on node or children changes.
|
342
139
|
*/
|
343
|
-
|
140
|
+
RuleExit?: RuleProcessor
|
344
141
|
}
|
345
142
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
143
|
+
declare namespace postcss {
|
144
|
+
export {
|
145
|
+
AnyNode,
|
146
|
+
AtRule,
|
147
|
+
AtRuleProps,
|
148
|
+
ChildNode,
|
149
|
+
ChildProps,
|
150
|
+
Comment,
|
151
|
+
CommentProps,
|
152
|
+
Container,
|
153
|
+
ContainerProps,
|
154
|
+
CssSyntaxError,
|
155
|
+
Declaration,
|
156
|
+
DeclarationProps,
|
157
|
+
Document,
|
158
|
+
DocumentProps,
|
159
|
+
FilePosition,
|
160
|
+
Input,
|
161
|
+
LazyResult,
|
162
|
+
list,
|
163
|
+
Message,
|
164
|
+
Node,
|
165
|
+
NodeErrorOptions,
|
166
|
+
NodeProps,
|
167
|
+
Position,
|
168
|
+
Processor,
|
169
|
+
Result,
|
170
|
+
Root,
|
171
|
+
RootProps,
|
172
|
+
Rule,
|
173
|
+
RuleProps,
|
174
|
+
Source,
|
175
|
+
Warning,
|
176
|
+
WarningOptions
|
177
|
+
}
|
178
|
+
|
179
|
+
export type SourceMap = SourceMapGenerator & {
|
180
|
+
toJSON(): RawSourceMap
|
181
|
+
}
|
182
|
+
|
183
|
+
export type Helpers = { postcss: Postcss; result: Result } & Postcss
|
184
|
+
|
185
|
+
export interface Plugin extends Processors {
|
186
|
+
postcssPlugin: string
|
187
|
+
prepare?: (result: Result) => Processors
|
188
|
+
}
|
189
|
+
|
190
|
+
export interface PluginCreator<PluginOptions> {
|
191
|
+
(opts?: PluginOptions): Plugin | Processor
|
192
|
+
postcss: true
|
193
|
+
}
|
194
|
+
|
195
|
+
export interface Transformer extends TransformCallback {
|
196
|
+
postcssPlugin: string
|
197
|
+
postcssVersion: string
|
198
|
+
}
|
199
|
+
|
200
|
+
export interface TransformCallback {
|
201
|
+
(root: Root, result: Result): Promise<void> | void
|
202
|
+
}
|
203
|
+
|
204
|
+
export interface OldPlugin<T> extends Transformer {
|
205
|
+
(opts?: T): Transformer
|
206
|
+
postcss: Transformer
|
207
|
+
}
|
208
|
+
|
209
|
+
export type AcceptedPlugin =
|
210
|
+
| {
|
211
|
+
postcss: Processor | TransformCallback
|
212
|
+
}
|
213
|
+
| OldPlugin<any>
|
214
|
+
| Plugin
|
215
|
+
| PluginCreator<any>
|
216
|
+
| Processor
|
217
|
+
| TransformCallback
|
218
|
+
|
219
|
+
export interface Parser<RootNode = Document | Root> {
|
220
|
+
(
|
221
|
+
css: { toString(): string } | string,
|
222
|
+
opts?: Pick<ProcessOptions, 'from' | 'map'>
|
223
|
+
): RootNode
|
224
|
+
}
|
225
|
+
|
226
|
+
export interface Builder {
|
227
|
+
(part: string, node?: AnyNode, type?: 'end' | 'start'): void
|
228
|
+
}
|
229
|
+
|
230
|
+
export interface Stringifier {
|
231
|
+
(node: AnyNode, builder: Builder): void
|
232
|
+
}
|
233
|
+
|
234
|
+
export interface JSONHydrator {
|
235
|
+
(data: object): Node
|
236
|
+
(data: object[]): Node[]
|
237
|
+
}
|
238
|
+
|
239
|
+
export interface Syntax<RootNode = Document | Root> {
|
240
|
+
/**
|
241
|
+
* Function to generate AST by string.
|
242
|
+
*/
|
243
|
+
parse?: Parser<RootNode>
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Class to generate string by AST.
|
247
|
+
*/
|
248
|
+
stringify?: Stringifier
|
249
|
+
}
|
250
|
+
|
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
|
+
|
276
|
+
/**
|
277
|
+
* Indicates that the source map should be embedded in the output CSS
|
278
|
+
* as a Base64-encoded comment. By default, it is `true`.
|
279
|
+
* But if all previous maps are external, not inline, PostCSS will not embed
|
280
|
+
* the map even if you do not set this option.
|
281
|
+
*
|
282
|
+
* If you have an inline source map, the result.map property will be empty,
|
283
|
+
* as the source map will be contained within the text of `result.css`.
|
284
|
+
*/
|
285
|
+
inline?: boolean
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Source map content from a previous processing step (e.g., Sass).
|
289
|
+
*
|
290
|
+
* PostCSS will try to read the previous source map
|
291
|
+
* automatically (based on comments within the source CSS), but you can use
|
292
|
+
* this option to identify it manually.
|
293
|
+
*
|
294
|
+
* If desired, you can omit the previous map with prev: `false`.
|
295
|
+
*/
|
296
|
+
prev?: ((file: string) => string) | boolean | object | string
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Indicates that PostCSS should set the origin content (e.g., Sass source)
|
300
|
+
* of the source map. By default, it is true. But if all previous maps do not
|
301
|
+
* contain sources content, PostCSS will also leave it out even if you
|
302
|
+
* do not set this option.
|
303
|
+
*/
|
304
|
+
sourcesContent?: boolean
|
305
|
+
}
|
306
|
+
|
307
|
+
export interface ProcessOptions<RootNode = Document | Root> {
|
308
|
+
/**
|
309
|
+
* The path of the CSS source file. You should always set `from`,
|
310
|
+
* because it is used in source map generation and syntax error messages.
|
311
|
+
*/
|
312
|
+
from?: string
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Source map options
|
316
|
+
*/
|
317
|
+
map?: boolean | SourceMapOptions
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Function to generate AST by string.
|
321
|
+
*/
|
322
|
+
parser?: Parser<RootNode> | Syntax<RootNode>
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Class to generate string by AST.
|
326
|
+
*/
|
327
|
+
stringifier?: Stringifier | Syntax<RootNode>
|
328
|
+
|
329
|
+
/**
|
330
|
+
* Object with parse and stringify.
|
331
|
+
*/
|
332
|
+
syntax?: Syntax<RootNode>
|
333
|
+
|
334
|
+
/**
|
335
|
+
* The path where you'll put the output CSS file. You should always set `to`
|
336
|
+
* to generate correct source maps.
|
337
|
+
*/
|
338
|
+
to?: string
|
339
|
+
}
|
340
|
+
|
341
|
+
export type Postcss = typeof postcss
|
364
342
|
|
365
343
|
/**
|
366
344
|
* Default function to convert a node tree into a CSS string.
|
367
345
|
*/
|
368
|
-
stringify: Stringifier
|
346
|
+
export let stringify: Stringifier
|
369
347
|
|
370
348
|
/**
|
371
349
|
* Parses source css and returns a new `Root` or `Document` node,
|
@@ -378,7 +356,7 @@ export interface Postcss {
|
|
378
356
|
* root1.append(root2).toResult().css
|
379
357
|
* ```
|
380
358
|
*/
|
381
|
-
parse: Parser
|
359
|
+
export let parse: Parser<Root>
|
382
360
|
|
383
361
|
/**
|
384
362
|
* Rehydrate a JSON AST (from `Node#toJSON`) back into the AST classes.
|
@@ -389,12 +367,7 @@ export interface Postcss {
|
|
389
367
|
* const root2 = postcss.fromJSON(json)
|
390
368
|
* ```
|
391
369
|
*/
|
392
|
-
fromJSON: JSONHydrator
|
393
|
-
|
394
|
-
/**
|
395
|
-
* Contains the `list` module.
|
396
|
-
*/
|
397
|
-
list: List
|
370
|
+
export let fromJSON: JSONHydrator
|
398
371
|
|
399
372
|
/**
|
400
373
|
* Creates a new `Comment` node.
|
@@ -402,7 +375,7 @@ export interface Postcss {
|
|
402
375
|
* @param defaults Properties for the new node.
|
403
376
|
* @return New comment node
|
404
377
|
*/
|
405
|
-
comment(defaults?: CommentProps): Comment
|
378
|
+
export function comment(defaults?: CommentProps): Comment
|
406
379
|
|
407
380
|
/**
|
408
381
|
* Creates a new `AtRule` node.
|
@@ -410,7 +383,7 @@ export interface Postcss {
|
|
410
383
|
* @param defaults Properties for the new node.
|
411
384
|
* @return New at-rule node.
|
412
385
|
*/
|
413
|
-
atRule(defaults?: AtRuleProps): AtRule
|
386
|
+
export function atRule(defaults?: AtRuleProps): AtRule
|
414
387
|
|
415
388
|
/**
|
416
389
|
* Creates a new `Declaration` node.
|
@@ -418,7 +391,7 @@ export interface Postcss {
|
|
418
391
|
* @param defaults Properties for the new node.
|
419
392
|
* @return New declaration node.
|
420
393
|
*/
|
421
|
-
decl(defaults?: DeclarationProps): Declaration
|
394
|
+
export function decl(defaults?: DeclarationProps): Declaration
|
422
395
|
|
423
396
|
/**
|
424
397
|
* Creates a new `Rule` node.
|
@@ -426,7 +399,7 @@ export interface Postcss {
|
|
426
399
|
* @param default Properties for the new node.
|
427
400
|
* @return New rule node.
|
428
401
|
*/
|
429
|
-
rule(defaults?: RuleProps): Rule
|
402
|
+
export function rule(defaults?: RuleProps): Rule
|
430
403
|
|
431
404
|
/**
|
432
405
|
* Creates a new `Root` node.
|
@@ -434,7 +407,7 @@ export interface Postcss {
|
|
434
407
|
* @param defaults Properties for the new node.
|
435
408
|
* @return New root node.
|
436
409
|
*/
|
437
|
-
root(defaults?: RootProps): Root
|
410
|
+
export function root(defaults?: RootProps): Root
|
438
411
|
|
439
412
|
/**
|
440
413
|
* Creates a new `Document` node.
|
@@ -442,31 +415,27 @@ export interface Postcss {
|
|
442
415
|
* @param defaults Properties for the new node.
|
443
416
|
* @return New document node.
|
444
417
|
*/
|
445
|
-
document(defaults?: DocumentProps): Document
|
446
|
-
|
447
|
-
CssSyntaxError: typeof CssSyntaxError
|
448
|
-
Declaration: typeof Declaration
|
449
|
-
Container: typeof Container
|
450
|
-
Comment: typeof Comment
|
451
|
-
Warning: typeof Warning
|
452
|
-
AtRule: typeof AtRule
|
453
|
-
Result: typeof Result
|
454
|
-
Input: typeof Input
|
455
|
-
Rule: typeof Rule
|
456
|
-
Root: typeof Root
|
457
|
-
Node: typeof Node
|
458
|
-
}
|
459
|
-
|
460
|
-
export const stringify: Stringifier
|
461
|
-
export const parse: Parser
|
462
|
-
export const fromJSON: JSONHydrator
|
418
|
+
export function document(defaults?: DocumentProps): Document
|
463
419
|
|
464
|
-
export
|
465
|
-
|
466
|
-
export const decl: Postcss['decl']
|
467
|
-
export const rule: Postcss['rule']
|
468
|
-
export const root: Postcss['root']
|
469
|
-
|
470
|
-
declare const postcss: Postcss
|
420
|
+
export { postcss as default }
|
421
|
+
}
|
471
422
|
|
472
|
-
|
423
|
+
/**
|
424
|
+
* Create a new `Processor` instance that will apply `plugins`
|
425
|
+
* as CSS processors.
|
426
|
+
*
|
427
|
+
* ```js
|
428
|
+
* let postcss = require('postcss')
|
429
|
+
*
|
430
|
+
* postcss(plugins).process(css, { from, to }).then(result => {
|
431
|
+
* console.log(result.css)
|
432
|
+
* })
|
433
|
+
* ```
|
434
|
+
*
|
435
|
+
* @param plugins PostCSS plugins.
|
436
|
+
* @return Processor to process multiple CSS.
|
437
|
+
*/
|
438
|
+
declare function postcss(plugins?: postcss.AcceptedPlugin[]): Processor
|
439
|
+
declare function postcss(...plugins: postcss.AcceptedPlugin[]): Processor
|
440
|
+
|
441
|
+
export = postcss
|