1 | import Document from './document.js'
|
2 | import LazyResult from './lazy-result.js'
|
3 | import NoWorkResult from './no-work-result.js'
|
4 | import {
|
5 | AcceptedPlugin,
|
6 | Plugin,
|
7 | ProcessOptions,
|
8 | TransformCallback,
|
9 | Transformer
|
10 | } from './postcss.js'
|
11 | import Result from './result.js'
|
12 | import Root from './root.js'
|
13 |
|
14 | declare namespace Processor {
|
15 |
|
16 | export { Processor_ as default }
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | declare class Processor_ {
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | plugins: (Plugin | TransformCallback | Transformer)[]
|
39 |
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | version: string
|
50 |
|
51 | |
52 |
|
53 |
|
54 | constructor(plugins?: readonly AcceptedPlugin[])
|
55 |
|
56 | /**
|
57 | * Parses source CSS and returns a `LazyResult` Promise proxy.
|
58 | * Because some plugins can be asynchronous it doesn’t make
|
59 | * any transformations. Transformations will be applied
|
60 | * in the `LazyResult` methods.
|
61 | *
|
62 | * ```js
|
63 | * processor.process(css, { from: 'a.css', to: 'a.out.css' })
|
64 | * .then(result => {
|
65 | * console.log(result.css)
|
66 | * })
|
67 | * ```
|
68 | *
|
69 | * @param css String with input CSS or any object with a `toString()` method,
|
70 | * like a Buffer. Optionally, send a `Result` instance
|
71 | * and the processor will take the `Root` from it.
|
72 | * @param opts Options.
|
73 | * @return Promise proxy.
|
74 | */
|
75 | process(
|
76 | css: { toString(): string } | LazyResult | Result | Root | string
|
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>
|
82 |
|
83 | /**
|
84 | * Adds a plugin to be used as a CSS processor.
|
85 | *
|
86 | * PostCSS plugin can be in 4 formats:
|
87 | * * A plugin in `Plugin` format.
|
88 | * * A plugin creator function with `pluginCreator.postcss = true`.
|
89 | * PostCSS will call this function without argument to get plugin.
|
90 | * * A function. PostCSS will pass the function a {@link Root}
|
91 | * as the first argument and current `Result` instance
|
92 | * as the second.
|
93 | * * Another `Processor` instance. PostCSS will copy plugins
|
94 | * from that instance into this one.
|
95 | *
|
96 | * Plugins can also be added by passing them as arguments when creating
|
97 | * a `postcss` instance (see [`postcss(plugins)`]).
|
98 | *
|
99 | * Asynchronous plugins should return a `Promise` instance.
|
100 | *
|
101 | * ```js
|
102 | * const processor = postcss()
|
103 | * .use(autoprefixer)
|
104 | * .use(postcssNested)
|
105 | * ```
|
106 | *
|
107 | * @param plugin PostCSS plugin or `Processor` with plugins.
|
108 | * @return Current processor to make methods chain.
|
109 | */
|
110 | use(plugin: AcceptedPlugin): this
|
111 | }
|
112 |
|
113 | declare class Processor extends Processor_ {}
|
114 |
|
115 | export = Processor
|