source: imaps-frontend/node_modules/postcss/lib/lazy-result.d.ts

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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