UNPKG

postcss

Version:

Tool for transforming styles with JS plugins

91 lines (90 loc) 3.36 kB
import Processor from './processor'; import postcss from './postcss'; import Result from './result'; import Root from './root'; export default class LazyResult implements postcss.LazyResult { private stringified; private processed; private result; private error; private plugin; private processing; /** * Promise proxy for result of PostCSS transformations. */ constructor(processor: Processor, /** * String with input CSS or any object with toString() method, like file stream. * Optionally, send Result instance and the processor will take the existing * [Root] parser from it. */ css: string | { toString(): string; } | LazyResult | Result, opts?: postcss.ProcessOptions); /** * @returns A processor used for CSS transformations. */ processor: Processor; /** * @returns Options from the Processor#process(css, opts) call that produced * this Result instance. */ opts: postcss.ResultOptions; /** * Processes input CSS through synchronous plugins and converts Root to * CSS string. This property will work only with synchronous plugins. If * processor contains any asynchronous plugins it will throw a error. You * should use LazyResult#then() instead. */ css: string; /** * Alias for css property to use when syntaxes generate non-CSS output. */ content: string; /** * Processes input CSS through synchronous plugins. This property will * work only with synchronous plugins. If processor contains any * asynchronous plugins it will throw an error. You should use * LazyResult#then() instead. */ map: postcss.ResultMap; /** * Processes input CSS through synchronous plugins. This property will work * only with synchronous plugins. If processor contains any asynchronous * plugins it will throw an error. You should use LazyResult#then() instead. */ root: Root; /** * Processes input CSS through synchronous plugins. This property will work * only with synchronous plugins. If processor contains any asynchronous * plugins it will throw an error. You should use LazyResult#then() instead. */ messages: postcss.ResultMessage[]; /** * Processes input CSS through synchronous plugins and calls Result#warnings(). * This property will work only with synchronous plugins. If processor * contains any asynchronous plugins it will throw a error. You should use * LazyResult#then() instead. */ warnings(): postcss.ResultMessage[]; /** * Alias for css property. */ toString(): string; /** * Processes input CSS through synchronous and asynchronous plugins. * @param onRejected Called if any plugin throws an error. */ then(onFulfilled: (result: Result) => void, onRejected?: (error: Error) => void): Function | any; /** * Processes input CSS through synchronous and asynchronous plugins. * @param onRejected Called if any plugin throws an error. */ catch(onRejected: (error: Error) => void): Function | any; private handleError(error, plugin); private asyncTick(resolve, reject); private async(); sync(): Result; private run(plugin); stringify(): Result; }