| [9af201e] | 1 | import Document from './document.js'
|
|---|
| 2 | import { SourceMap } from './postcss.js'
|
|---|
| 3 | import Processor from './processor.js'
|
|---|
| 4 | import Result, { Message, ResultOptions } from './result.js'
|
|---|
| 5 | import Root from './root.js'
|
|---|
| 6 | import Warning from './warning.js'
|
|---|
| 7 |
|
|---|
| 8 | declare namespace LazyResult {
|
|---|
| 9 | export { LazyResult_ as default }
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | /**
|
|---|
| 13 | * A Promise proxy for the result of PostCSS transformations.
|
|---|
| 14 | *
|
|---|
| 15 | * A `LazyResult` instance is returned by `Processor#process`.
|
|---|
| 16 | *
|
|---|
| 17 | * ```js
|
|---|
| 18 | * const lazy = postcss([autoprefixer]).process(css)
|
|---|
| 19 | * ```
|
|---|
| 20 | */
|
|---|
| 21 | declare class LazyResult_<RootNode = Document | Root> implements PromiseLike<
|
|---|
| 22 | Result<RootNode>
|
|---|
| 23 | > {
|
|---|
| 24 | /**
|
|---|
| 25 | * Processes input CSS through synchronous and asynchronous plugins
|
|---|
| 26 | * and calls onRejected for each error thrown in any plugin.
|
|---|
| 27 | *
|
|---|
| 28 | * It implements standard Promise API.
|
|---|
| 29 | *
|
|---|
| 30 | * ```js
|
|---|
| 31 | * postcss([autoprefixer]).process(css).then(result => {
|
|---|
| 32 | * console.log(result.css)
|
|---|
| 33 | * }).catch(error => {
|
|---|
| 34 | * console.error(error)
|
|---|
| 35 | * })
|
|---|
| 36 | * ```
|
|---|
| 37 | */
|
|---|
| 38 | catch: Promise<Result<RootNode>>['catch']
|
|---|
| 39 |
|
|---|
| 40 | /**
|
|---|
| 41 | * Processes input CSS through synchronous and asynchronous plugins
|
|---|
| 42 | * and calls onFinally on any error or when all plugins will finish work.
|
|---|
| 43 | *
|
|---|
| 44 | * It implements standard Promise API.
|
|---|
| 45 | *
|
|---|
| 46 | * ```js
|
|---|
| 47 | * postcss([autoprefixer]).process(css).finally(() => {
|
|---|
| 48 | * console.log('processing ended')
|
|---|
| 49 | * })
|
|---|
| 50 | * ```
|
|---|
| 51 | */
|
|---|
| 52 | finally: Promise<Result<RootNode>>['finally']
|
|---|
| 53 |
|
|---|
| 54 | /**
|
|---|
| 55 | * Processes input CSS through synchronous and asynchronous plugins
|
|---|
| 56 | * and calls `onFulfilled` with a Result instance. If a plugin throws
|
|---|
| 57 | * an error, the `onRejected` callback will be executed.
|
|---|
| 58 | *
|
|---|
| 59 | * It implements standard Promise API.
|
|---|
| 60 | *
|
|---|
| 61 | * ```js
|
|---|
| 62 | * postcss([autoprefixer]).process(css, { from: cssPath }).then(result => {
|
|---|
| 63 | * console.log(result.css)
|
|---|
| 64 | * })
|
|---|
| 65 | * ```
|
|---|
| 66 | */
|
|---|
| 67 | then: Promise<Result<RootNode>>['then']
|
|---|
| 68 |
|
|---|
| 69 | /**
|
|---|
| 70 | * An alias for the `css` property. Use it with syntaxes
|
|---|
| 71 | * that generate non-CSS output.
|
|---|
| 72 | *
|
|---|
| 73 | * This property will only work with synchronous plugins.
|
|---|
| 74 | * If the processor contains any asynchronous plugins
|
|---|
| 75 | * it will throw an error.
|
|---|
| 76 | *
|
|---|
| 77 | * PostCSS runners should always use `LazyResult#then`.
|
|---|
| 78 | */
|
|---|
| 79 | get content(): string
|
|---|
| 80 |
|
|---|
| 81 | /**
|
|---|
| 82 | * Processes input CSS through synchronous plugins, converts `Root`
|
|---|
| 83 | * to a CSS string and returns `Result#css`.
|
|---|
| 84 | *
|
|---|
| 85 | * This property will only work with synchronous plugins.
|
|---|
| 86 | * If the processor contains any asynchronous plugins
|
|---|
| 87 | * it will throw an error.
|
|---|
| 88 | *
|
|---|
| 89 | * PostCSS runners should always use `LazyResult#then`.
|
|---|
| 90 | */
|
|---|
| 91 | get css(): string
|
|---|
| 92 |
|
|---|
| 93 | /**
|
|---|
| 94 | * Processes input CSS through synchronous plugins
|
|---|
| 95 | * and returns `Result#map`.
|
|---|
| 96 | *
|
|---|
| 97 | * This property will only work with synchronous plugins.
|
|---|
| 98 | * If the processor contains any asynchronous plugins
|
|---|
| 99 | * it will throw an error.
|
|---|
| 100 | *
|
|---|
| 101 | * PostCSS runners should always use `LazyResult#then`.
|
|---|
| 102 | */
|
|---|
| 103 | get map(): SourceMap
|
|---|
| 104 |
|
|---|
| 105 | /**
|
|---|
| 106 | * Processes input CSS through synchronous plugins
|
|---|
| 107 | * and returns `Result#messages`.
|
|---|
| 108 | *
|
|---|
| 109 | * This property will only work with synchronous plugins. If the processor
|
|---|
| 110 | * contains any asynchronous plugins it will throw an error.
|
|---|
| 111 | *
|
|---|
| 112 | * PostCSS runners should always use `LazyResult#then`.
|
|---|
| 113 | */
|
|---|
| 114 | get messages(): Message[]
|
|---|
| 115 |
|
|---|
| 116 | /**
|
|---|
| 117 | * Options from the `Processor#process` call.
|
|---|
| 118 | */
|
|---|
| 119 | get opts(): ResultOptions
|
|---|
| 120 |
|
|---|
| 121 | /**
|
|---|
| 122 | * Returns a `Processor` instance, which will be used
|
|---|
| 123 | * for CSS transformations.
|
|---|
| 124 | */
|
|---|
| 125 | get processor(): Processor
|
|---|
| 126 |
|
|---|
| 127 | /**
|
|---|
| 128 | * Processes input CSS through synchronous plugins
|
|---|
| 129 | * and returns `Result#root`.
|
|---|
| 130 | *
|
|---|
| 131 | * This property will only work with synchronous plugins. If the processor
|
|---|
| 132 | * contains any asynchronous plugins it will throw an error.
|
|---|
| 133 | *
|
|---|
| 134 | * PostCSS runners should always use `LazyResult#then`.
|
|---|
| 135 | */
|
|---|
| 136 | get root(): RootNode
|
|---|
| 137 |
|
|---|
| 138 | /**
|
|---|
| 139 | * Returns the default string description of an object.
|
|---|
| 140 | * Required to implement the Promise interface.
|
|---|
| 141 | */
|
|---|
| 142 | get [Symbol.toStringTag](): string
|
|---|
| 143 |
|
|---|
| 144 | /**
|
|---|
| 145 | * @param processor Processor used for this transformation.
|
|---|
| 146 | * @param css CSS to parse and transform.
|
|---|
| 147 | * @param opts Options from the `Processor#process` or `Root#toResult`.
|
|---|
| 148 | */
|
|---|
| 149 | constructor(processor: Processor, css: string, opts: ResultOptions)
|
|---|
| 150 |
|
|---|
| 151 | /**
|
|---|
| 152 | * Run plugin in async way and return `Result`.
|
|---|
| 153 | *
|
|---|
| 154 | * @return Result with output content.
|
|---|
| 155 | */
|
|---|
| 156 | async(): Promise<Result<RootNode>>
|
|---|
| 157 |
|
|---|
| 158 | /**
|
|---|
| 159 | * Run plugin in sync way and return `Result`.
|
|---|
| 160 | *
|
|---|
| 161 | * @return Result with output content.
|
|---|
| 162 | */
|
|---|
| 163 | sync(): Result<RootNode>
|
|---|
| 164 |
|
|---|
| 165 | /**
|
|---|
| 166 | * Alias for the `LazyResult#css` property.
|
|---|
| 167 | *
|
|---|
| 168 | * ```js
|
|---|
| 169 | * lazy + '' === lazy.css
|
|---|
| 170 | * ```
|
|---|
| 171 | *
|
|---|
| 172 | * @return Output CSS.
|
|---|
| 173 | */
|
|---|
| 174 | toString(): string
|
|---|
| 175 |
|
|---|
| 176 | /**
|
|---|
| 177 | * Processes input CSS through synchronous plugins
|
|---|
| 178 | * and calls `Result#warnings`.
|
|---|
| 179 | *
|
|---|
| 180 | * @return Warnings from plugins.
|
|---|
| 181 | */
|
|---|
| 182 | warnings(): Warning[]
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | declare class LazyResult<
|
|---|
| 186 | RootNode = Document | Root
|
|---|
| 187 | > extends LazyResult_<RootNode> {}
|
|---|
| 188 |
|
|---|
| 189 | export = LazyResult
|
|---|