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 Promise<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. This is why this method is only
|
93 | * for debug purpose, you should always use `LazyResult#then`.
|
94 | */
|
95 | get css (): string
|
96 |
|
97 | /**
|
98 | * An alias for the `css` property. Use it with syntaxes
|
99 | * that generate non-CSS output.
|
100 | *
|
101 | * This property will only work with synchronous plugins.
|
102 | * If the processor contains any asynchronous plugins
|
103 | * it will throw an error. This is why this method is only
|
104 | * for debug purpose, you should always use `LazyResult#then`.
|
105 | */
|
106 | get content (): string
|
107 |
|
108 | /**
|
109 | * Processes input CSS through synchronous plugins
|
110 | * and returns `Result#map`.
|
111 | *
|
112 | * This property will only work with synchronous plugins.
|
113 | * If the processor contains any asynchronous plugins
|
114 | * it will throw an error. This is why this method is only
|
115 | * for debug purpose, you should always use `LazyResult#then`.
|
116 | */
|
117 | get map (): SourceMap
|
118 |
|
119 | /**
|
120 | * Processes input CSS through synchronous plugins
|
121 | * and returns `Result#root`.
|
122 | *
|
123 | * This property will only work with synchronous plugins. If the processor
|
124 | * contains any asynchronous plugins it will throw an error.
|
125 | *
|
126 | * This is why this method is only for debug purpose,
|
127 | * you should always use `LazyResult#then`.
|
128 | */
|
129 | get root (): Root
|
130 |
|
131 | /**
|
132 | * Processes input CSS through synchronous plugins
|
133 | * and returns `Result#messages`.
|
134 | *
|
135 | * This property will only work with synchronous plugins. If the processor
|
136 | * contains any asynchronous plugins it will throw an error.
|
137 | *
|
138 | * This is why this method is only for debug purpose,
|
139 | * you should always use `LazyResult#then`.
|
140 | */
|
141 | get messages (): Message[]
|
142 |
|
143 | /**
|
144 | * Processes input CSS through synchronous plugins
|
145 | * and calls `Result#warnings`.
|
146 | *
|
147 | * @return Warnings from plugins.
|
148 | */
|
149 | warnings (): Warning[]
|
150 |
|
151 | /**
|
152 | * Alias for the `LazyResult#css` property.
|
153 | *
|
154 | * ```js
|
155 | * lazy + '' === lazy.css
|
156 | * ```
|
157 | *
|
158 | * @return Output CSS.
|
159 | */
|
160 | toString (): string
|
161 |
|
162 | /**
|
163 | * Run plugin in sync way and return `Result`.
|
164 | *
|
165 | * @return Result with output content.
|
166 | */
|
167 | sync (): Result
|
168 |
|
169 | /**
|
170 | * Run plugin in async way and return `Result`.
|
171 | *
|
172 | * @return Result with output content.
|
173 | */
|
174 | async (): Promise<Result>
|
175 | }
|