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

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • 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 export { Processor_ as default }
16}
17
18/**
19 * Contains plugins to process CSS. Create one `Processor` instance,
20 * initialize its plugins, and then use that instance on numerous CSS files.
21 *
22 * ```js
23 * const processor = postcss([autoprefixer, postcssNested])
24 * processor.process(css1).then(result => console.log(result.css))
25 * processor.process(css2).then(result => console.log(result.css))
26 * ```
27 */
28declare class Processor_ {
29 /**
30 * Plugins added to this processor.
31 *
32 * ```js
33 * const processor = postcss([autoprefixer, postcssNested])
34 * processor.plugins.length //=> 2
35 * ```
36 */
37 plugins: (Plugin | TransformCallback | Transformer)[]
38
39 /**
40 * Current PostCSS version.
41 *
42 * ```js
43 * if (result.processor.version.split('.')[0] !== '6') {
44 * throw new Error('This plugin works only with PostCSS 6')
45 * }
46 * ```
47 */
48 version: string
49
50 /**
51 * @param plugins PostCSS plugins
52 */
53 constructor(plugins?: readonly AcceptedPlugin[])
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 ): LazyResult | NoWorkResult
77 process<RootNode extends Document | Root = Root>(
78 css: { toString(): string } | LazyResult | Result | Root | string,
79 options: ProcessOptions<RootNode>
80 ): LazyResult<RootNode>
81
82 /**
83 * Adds a plugin to be used as a CSS processor.
84 *
85 * PostCSS plugin can be in 4 formats:
86 * * A plugin in `Plugin` format.
87 * * A plugin creator function with `pluginCreator.postcss = true`.
88 * PostCSS will call this function without argument to get plugin.
89 * * A function. PostCSS will pass the function a {@link Root}
90 * as the first argument and current `Result` instance
91 * as the second.
92 * * Another `Processor` instance. PostCSS will copy plugins
93 * from that instance into this one.
94 *
95 * Plugins can also be added by passing them as arguments when creating
96 * a `postcss` instance (see [`postcss(plugins)`]).
97 *
98 * Asynchronous plugins should return a `Promise` instance.
99 *
100 * ```js
101 * const processor = postcss()
102 * .use(autoprefixer)
103 * .use(postcssNested)
104 * ```
105 *
106 * @param plugin PostCSS plugin or `Processor` with plugins.
107 * @return Current processor to make methods chain.
108 */
109 use(plugin: AcceptedPlugin): this
110}
111
112declare class Processor extends Processor_ {}
113
114export = Processor
Note: See TracBrowser for help on using the repository browser.