CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
processor.d.ts115 linesDownload Raw Back to lib
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  Transformer10} 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 * ```js23 * 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   * ```js33   * const processor = postcss([autoprefixer, postcssNested])34   * processor.plugins.length //=> 235   * ```36   */37  plugins: (Plugin | TransformCallback | Transformer)[]38 39  /**40   * Current PostCSS version.41   *42   * ```js43   * if (result.processor.version.split('.')[0] !== '6') {44   *   throw new Error('This plugin works only with PostCSS 6')45   * }46   * ```47   */48  version: string49 50  /**51   * @param plugins PostCSS plugins52   */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 make58   * any transformations. Transformations will be applied59   * in the `LazyResult` methods.60   *61   * ```js62   * 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` instance70   *            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 | string76  ): LazyResult | NoWorkResult77  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` instance91   *   as the second.92   * * Another `Processor` instance. PostCSS will copy plugins93   *   from that instance into this one.94   *95   * Plugins can also be added by passing them as arguments when creating96   * a `postcss` instance (see [`postcss(plugins)`]).97   *98   * Asynchronous plugins should return a `Promise` instance.99   *100   * ```js101   * 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): this110}111 112declare class Processor extends Processor_ {}113 114export = Processor115