source: imaps-frontend/node_modules/postcss/lib/processor.d.ts

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 3.3 KB
Line 
1import Document from './document.js'
2import LazyResult from './lazy-result.js'
3import NoWorkResult from './no-work-result.js'
4import {
5 AcceptedPlugin,
6 Plugin,
7 ProcessOptions,
8 TransformCallback,
9 Transformer
10} from './postcss.js'
11import Result from './result.js'
12import Root from './root.js'
13
14declare namespace Processor {
15 // eslint-disable-next-line @typescript-eslint/no-use-before-define
16 export { Processor_ as default }
17}
18
19/**
20 * Contains plugins to process CSS. Create one `Processor` instance,
21 * initialize its plugins, and then use that instance on numerous CSS files.
22 *
23 * ```js
24 * const processor = postcss([autoprefixer, postcssNested])
25 * processor.process(css1).then(result => console.log(result.css))
26 * processor.process(css2).then(result => console.log(result.css))
27 * ```
28 */
29declare class Processor_ {
30 /**
31 * Plugins added to this processor.
32 *
33 * ```js
34 * const processor = postcss([autoprefixer, postcssNested])
35 * processor.plugins.length //=> 2
36 * ```
37 */
38 plugins: (Plugin | TransformCallback | Transformer)[]
39
40 /**
41 * Current PostCSS version.
42 *
43 * ```js
44 * if (result.processor.version.split('.')[0] !== '6') {
45 * throw new Error('This plugin works only with PostCSS 6')
46 * }
47 * ```
48 */
49 version: string
50
51 /**
52 * @param plugins PostCSS plugins
53 */
54 constructor(plugins?: 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
113declare class Processor extends Processor_ {}
114
115export = Processor
Note: See TracBrowser for help on using the repository browser.