2023-08-17 09:47:40 +00:00
|
|
|
import Document from './document.js'
|
2022-06-08 10:36:39 +00:00
|
|
|
import { SourceMap } from './postcss.js'
|
|
|
|
import Processor from './processor.js'
|
2023-08-17 09:47:40 +00:00
|
|
|
import Result, { Message, ResultOptions } from './result.js'
|
2022-06-08 10:36:39 +00:00
|
|
|
import Root from './root.js'
|
2023-08-17 09:47:40 +00:00
|
|
|
import Warning from './warning.js'
|
|
|
|
|
|
|
|
declare namespace LazyResult {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
|
|
export { LazyResult_ as default }
|
|
|
|
}
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A Promise proxy for the result of PostCSS transformations.
|
|
|
|
*
|
|
|
|
* A `LazyResult` instance is returned by `Processor#process`.
|
|
|
|
*
|
|
|
|
* ```js
|
|
|
|
* const lazy = postcss([autoprefixer]).process(css)
|
|
|
|
* ```
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
declare class LazyResult_<RootNode = Document | Root>
|
|
|
|
implements PromiseLike<Result<RootNode>>
|
|
|
|
{
|
2022-06-08 10:36:39 +00:00
|
|
|
/**
|
|
|
|
* Processes input CSS through synchronous and asynchronous plugins
|
2023-08-17 09:47:40 +00:00
|
|
|
* and calls onRejected for each error thrown in any plugin.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
|
|
|
* It implements standard Promise API.
|
|
|
|
*
|
|
|
|
* ```js
|
2023-08-17 09:47:40 +00:00
|
|
|
* postcss([autoprefixer]).process(css).then(result => {
|
2022-06-08 10:36:39 +00:00
|
|
|
* console.log(result.css)
|
2023-08-17 09:47:40 +00:00
|
|
|
* }).catch(error => {
|
|
|
|
* console.error(error)
|
2022-06-08 10:36:39 +00:00
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
catch: Promise<Result<RootNode>>['catch']
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes input CSS through synchronous and asynchronous plugins
|
2023-08-17 09:47:40 +00:00
|
|
|
* and calls onFinally on any error or when all plugins will finish work.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
|
|
|
* It implements standard Promise API.
|
|
|
|
*
|
|
|
|
* ```js
|
2023-08-17 09:47:40 +00:00
|
|
|
* postcss([autoprefixer]).process(css).finally(() => {
|
|
|
|
* console.log('processing ended')
|
2022-06-08 10:36:39 +00:00
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
finally: Promise<Result<RootNode>>['finally']
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes input CSS through synchronous and asynchronous plugins
|
2023-08-17 09:47:40 +00:00
|
|
|
* and calls `onFulfilled` with a Result instance. If a plugin throws
|
|
|
|
* an error, the `onRejected` callback will be executed.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
|
|
|
* It implements standard Promise API.
|
|
|
|
*
|
|
|
|
* ```js
|
2023-08-17 09:47:40 +00:00
|
|
|
* postcss([autoprefixer]).process(css, { from: cssPath }).then(result => {
|
|
|
|
* console.log(result.css)
|
2022-06-08 10:36:39 +00:00
|
|
|
* })
|
|
|
|
* ```
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
then: Promise<Result<RootNode>>['then']
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param processor Processor used for this transformation.
|
|
|
|
* @param css CSS to parse and transform.
|
|
|
|
* @param opts Options from the `Processor#process` or `Root#toResult`.
|
|
|
|
*/
|
|
|
|
constructor(processor: Processor, css: string, opts: ResultOptions)
|
|
|
|
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
* Run plugin in async way and return `Result`.
|
|
|
|
*
|
|
|
|
* @return Result with output content.
|
2022-06-08 10:36:39 +00:00
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
async(): Promise<Result<RootNode>>
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
* An alias for the `css` property. Use it with syntaxes
|
|
|
|
* that generate non-CSS output.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
|
|
|
* This property will only work with synchronous plugins.
|
|
|
|
* If the processor contains any asynchronous plugins
|
|
|
|
* it will throw an error.
|
|
|
|
*
|
|
|
|
* PostCSS runners should always use `LazyResult#then`.
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
get content(): string
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
* Processes input CSS through synchronous plugins, converts `Root`
|
|
|
|
* to a CSS string and returns `Result#css`.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
|
|
|
* This property will only work with synchronous plugins.
|
|
|
|
* If the processor contains any asynchronous plugins
|
|
|
|
* it will throw an error.
|
|
|
|
*
|
|
|
|
* PostCSS runners should always use `LazyResult#then`.
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
get css(): string
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes input CSS through synchronous plugins
|
|
|
|
* and returns `Result#map`.
|
|
|
|
*
|
|
|
|
* This property will only work with synchronous plugins.
|
|
|
|
* If the processor contains any asynchronous plugins
|
|
|
|
* it will throw an error.
|
|
|
|
*
|
|
|
|
* PostCSS runners should always use `LazyResult#then`.
|
|
|
|
*/
|
|
|
|
get map(): SourceMap
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes input CSS through synchronous plugins
|
2023-08-17 09:47:40 +00:00
|
|
|
* and returns `Result#messages`.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
|
|
|
* This property will only work with synchronous plugins. If the processor
|
|
|
|
* contains any asynchronous plugins it will throw an error.
|
|
|
|
*
|
|
|
|
* PostCSS runners should always use `LazyResult#then`.
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
get messages(): Message[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Options from the `Processor#process` call.
|
|
|
|
*/
|
|
|
|
get opts(): ResultOptions
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a `Processor` instance, which will be used
|
|
|
|
* for CSS transformations.
|
|
|
|
*/
|
|
|
|
get processor(): Processor
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes input CSS through synchronous plugins
|
2023-08-17 09:47:40 +00:00
|
|
|
* and returns `Result#root`.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
|
|
|
* This property will only work with synchronous plugins. If the processor
|
|
|
|
* contains any asynchronous plugins it will throw an error.
|
|
|
|
*
|
|
|
|
* PostCSS runners should always use `LazyResult#then`.
|
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
get root(): RootNode
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
* Returns the default string description of an object.
|
|
|
|
* Required to implement the Promise interface.
|
|
|
|
*/
|
|
|
|
get [Symbol.toStringTag](): string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run plugin in sync way and return `Result`.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
2023-08-17 09:47:40 +00:00
|
|
|
* @return Result with output content.
|
2022-06-08 10:36:39 +00:00
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
sync(): Result<RootNode>
|
2022-06-08 10:36:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias for the `LazyResult#css` property.
|
|
|
|
*
|
|
|
|
* ```js
|
|
|
|
* lazy + '' === lazy.css
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* @return Output CSS.
|
|
|
|
*/
|
|
|
|
toString(): string
|
|
|
|
|
|
|
|
/**
|
2023-08-17 09:47:40 +00:00
|
|
|
* Processes input CSS through synchronous plugins
|
|
|
|
* and calls `Result#warnings`.
|
2022-06-08 10:36:39 +00:00
|
|
|
*
|
2023-08-17 09:47:40 +00:00
|
|
|
* @return Warnings from plugins.
|
2022-06-08 10:36:39 +00:00
|
|
|
*/
|
2023-08-17 09:47:40 +00:00
|
|
|
warnings(): Warning[]
|
2022-06-08 10:36:39 +00:00
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
|
|
|
|
declare class LazyResult<
|
|
|
|
RootNode = Document | Root
|
|
|
|
> extends LazyResult_<RootNode> {}
|
|
|
|
|
|
|
|
export = LazyResult
|