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