1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export type ImporterReturnType = { file: string } | { file?: string | undefined; contents: string } | Error | null | types.Null | types.Error;
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export interface Context {
|
19 | options: Options;
|
20 | callback: SassRenderCallback | undefined;
|
21 | [data: string]: any;
|
22 | }
|
23 |
|
24 | export interface AsyncContext extends Context {
|
25 | callback: SassRenderCallback;
|
26 | }
|
27 |
|
28 | export interface SyncContext extends Context {
|
29 | callback: undefined;
|
30 | }
|
31 |
|
32 | export type AsyncImporter = (this: AsyncContext, url: string, prev: string, done: (data: ImporterReturnType) => void) => void;
|
33 | export type SyncImporter = (this: SyncContext, url: string, prev: string) => ImporterReturnType;
|
34 | export type Importer = AsyncImporter | SyncImporter;
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | export type SyncSassFn = (this: SyncContext, ...$args: types.Value[]) => types.ReturnValue;
|
40 |
|
41 |
|
42 |
|
43 | export type SyncSassVarArgFn1 = (this: SyncContext, $arg1: types.Value[]) => types.ReturnValue;
|
44 | export type SyncSassVarArgFn2 = (this: SyncContext, $arg1: types.Value, $arg2: types.Value[]) => types.ReturnValue;
|
45 | export type SyncSassVarArgFn3 = (this: SyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value[]) => types.ReturnValue;
|
46 | export type SyncSassVarArgFn4 = (this: SyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value[]) => types.ReturnValue;
|
47 | export type SyncSassVarArgFn5 = (this: SyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value, $arg5: types.Value[]) => types.ReturnValue;
|
48 | export type SyncSassVarArgFn6 = (this: SyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value, $arg5: types.Value, $arg6: types.Value[]) => types.ReturnValue;
|
49 |
|
50 | export type SassFunctionCallback = ($result: types.ReturnValue) => void;
|
51 |
|
52 |
|
53 | export type AsyncSassFn0 = (this: AsyncContext, cb: SassFunctionCallback) => void;
|
54 | export type AsyncSassFn1 = (this: AsyncContext, $arg1: types.Value, cb: SassFunctionCallback) => void;
|
55 | export type AsyncSassFn2 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, cb: SassFunctionCallback) => void;
|
56 | export type AsyncSassFn3 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, cb: SassFunctionCallback) => void;
|
57 | export type AsyncSassFn4 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value, cb: SassFunctionCallback) => void;
|
58 | export type AsyncSassFn5 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value, $arg5: types.Value, cb: SassFunctionCallback) => void;
|
59 | export type AsyncSassFn6 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value, $arg5: types.Value, $arg6: types.Value, cb: SassFunctionCallback) => void;
|
60 |
|
61 |
|
62 | export type AsyncSassVarArgFn1 = (this: AsyncContext, $arg1: types.Value[], cb: SassFunctionCallback) => void;
|
63 | export type AsyncSassVarArgFn2 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value[], cb: SassFunctionCallback) => void;
|
64 | export type AsyncSassVarArgFn3 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value[], cb: SassFunctionCallback) => void;
|
65 | export type AsyncSassVarArgFn4 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value[], cb: SassFunctionCallback) => void;
|
66 | export type AsyncSassVarArgFn5 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value, $arg5: types.Value[], cb: SassFunctionCallback) => void;
|
67 | export type AsyncSassVarArgFn6 = (this: AsyncContext, $arg1: types.Value, $arg2: types.Value, $arg3: types.Value, $arg4: types.Value, $arg5: types.Value, $arg6: types.Value[], cb: SassFunctionCallback) => void;
|
68 |
|
69 |
|
70 | export type SyncSassFunction = SyncSassFn | SyncSassVarArgFn1 | SyncSassVarArgFn2 | SyncSassVarArgFn3 | SyncSassVarArgFn4 | SyncSassVarArgFn5 | SyncSassVarArgFn6;
|
71 |
|
72 | export type AsyncSassFunction = AsyncSassFn0 | AsyncSassFn1 | AsyncSassFn2 | AsyncSassFn3 | AsyncSassFn4 | AsyncSassFn5 | AsyncSassFn6
|
73 | | AsyncSassVarArgFn1 | AsyncSassVarArgFn2 | AsyncSassVarArgFn3 | AsyncSassVarArgFn4 | AsyncSassVarArgFn5 | AsyncSassVarArgFn6;
|
74 |
|
75 | export type SassFunction = SyncSassFunction | AsyncSassFunction;
|
76 |
|
77 | export type FunctionDeclarations<FunctionType extends SassFunction = SassFunction> = Record<string, FunctionType>;
|
78 |
|
79 | export interface Options {
|
80 | file?: string | undefined;
|
81 | data?: string | undefined;
|
82 | importer?: Importer | Importer[] | undefined;
|
83 | functions?: FunctionDeclarations | undefined;
|
84 | includePaths?: string[] | undefined;
|
85 | indentedSyntax?: boolean | undefined;
|
86 | indentType?: string | undefined;
|
87 | indentWidth?: number | undefined;
|
88 | linefeed?: string | undefined;
|
89 | omitSourceMapUrl?: boolean | undefined;
|
90 | outFile?: string | undefined;
|
91 | outputStyle?: "compact" | "compressed" | "expanded" | "nested" | undefined;
|
92 | precision?: number | undefined;
|
93 | sourceComments?: boolean | undefined;
|
94 | sourceMap?: boolean | string | undefined;
|
95 | sourceMapContents?: boolean | undefined;
|
96 | sourceMapEmbed?: boolean | undefined;
|
97 | sourceMapRoot?: string | undefined;
|
98 | [key: string]: any;
|
99 | }
|
100 |
|
101 | export interface SyncOptions extends Options {
|
102 | functions?: FunctionDeclarations<SyncSassFunction> | undefined;
|
103 | importer?: SyncImporter | SyncImporter[] | undefined;
|
104 | }
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | export interface SassError extends Error {
|
112 | message: string;
|
113 | line: number;
|
114 | column: number;
|
115 | status: number;
|
116 | file: string;
|
117 | }
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | export interface Result {
|
123 | css: Buffer;
|
124 | map: Buffer;
|
125 | stats: {
|
126 | entry: string;
|
127 | start: number;
|
128 | end: number;
|
129 | duration: number;
|
130 | includedFiles: string[];
|
131 | };
|
132 | }
|
133 | export type SassRenderCallback = (err: SassError, result: Result) => any;
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 | export namespace types {
|
142 |
|
143 |
|
144 | |
145 |
|
146 |
|
147 | export type Value = Null | Number | String | Color | Boolean | List | Map;
|
148 |
|
149 | |
150 |
|
151 |
|
152 | export type ReturnValue = Value | Error;
|
153 |
|
154 |
|
155 |
|
156 | export interface Null {
|
157 | |
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | readonly ___NULL___: unique symbol;
|
164 | }
|
165 |
|
166 | interface NullConstructor {
|
167 | (): Null;
|
168 | NULL: Null;
|
169 | }
|
170 | export const Null: NullConstructor;
|
171 |
|
172 |
|
173 |
|
174 | export interface Number {
|
175 | getValue(): number;
|
176 | setValue(n: number): void;
|
177 | getUnit(): string;
|
178 | setUnit(u: string): void;
|
179 | }
|
180 | interface NumberConstructor {
|
181 | |
182 |
|
183 |
|
184 | new(value: number, unit?: string): Number;
|
185 | |
186 |
|
187 |
|
188 | (value: number, unit?: string): Number;
|
189 | }
|
190 |
|
191 | export const Number: NumberConstructor;
|
192 |
|
193 |
|
194 |
|
195 | export interface String {
|
196 | getValue(): string;
|
197 | setValue(s: string): void;
|
198 | }
|
199 |
|
200 | interface StringConstructor {
|
201 | |
202 |
|
203 |
|
204 | new (value: string): String;
|
205 | |
206 |
|
207 |
|
208 | (value: string): String;
|
209 | }
|
210 |
|
211 | export const String: StringConstructor;
|
212 |
|
213 |
|
214 |
|
215 | export interface Color {
|
216 | |
217 |
|
218 |
|
219 |
|
220 | getR(): number;
|
221 | |
222 |
|
223 |
|
224 |
|
225 | setR(r: number): void;
|
226 | |
227 |
|
228 |
|
229 |
|
230 | getG(): number;
|
231 | |
232 |
|
233 |
|
234 |
|
235 | setG(g: number): void;
|
236 | |
237 |
|
238 |
|
239 |
|
240 | getB(): number;
|
241 | |
242 |
|
243 |
|
244 |
|
245 | setB(b: number): void;
|
246 | |
247 |
|
248 |
|
249 |
|
250 | getA(): number;
|
251 | |
252 |
|
253 |
|
254 |
|
255 | setA(a: number): void;
|
256 | }
|
257 |
|
258 | interface ColorConstructor {
|
259 | |
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 | new (r: number, g: number, b: number, a?: number): Color;
|
269 |
|
270 | |
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | new (hexN: number): Color;
|
291 |
|
292 | |
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 | (r: number, g: number, b: number, a?: number): Color;
|
302 |
|
303 | |
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 | (hexN: number): Color;
|
324 | }
|
325 |
|
326 | export const Color: ColorConstructor;
|
327 |
|
328 |
|
329 |
|
330 | export interface Boolean {
|
331 | getValue(): boolean;
|
332 | }
|
333 |
|
334 | interface BooleanConstructor {
|
335 | (bool: boolean): Boolean;
|
336 | TRUE: Boolean;
|
337 | FALSE: Boolean;
|
338 | }
|
339 |
|
340 | export const Boolean: BooleanConstructor;
|
341 |
|
342 |
|
343 |
|
344 | export interface Enumerable {
|
345 | getValue(index: number): Value;
|
346 | setValue(index: number, value: Value): void;
|
347 | getLength(): number;
|
348 | }
|
349 |
|
350 | export interface List extends Enumerable {
|
351 | getSeparator(): boolean;
|
352 | setSeparator(isComma: boolean): void;
|
353 | }
|
354 | interface ListConstructor {
|
355 | new (length: number, commaSeparator?: boolean): List;
|
356 | (length: number, commaSeparator?: boolean): List;
|
357 | }
|
358 | export const List: ListConstructor;
|
359 |
|
360 |
|
361 |
|
362 | export interface Map extends Enumerable {
|
363 | getKey(index: number): Value;
|
364 | setKey(index: number, key: Value): void;
|
365 | }
|
366 | interface MapConstructor {
|
367 | new (length: number): Map;
|
368 | (length: number): Map;
|
369 | }
|
370 | export const Map: MapConstructor;
|
371 |
|
372 |
|
373 |
|
374 | export interface Error {
|
375 | |
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 | readonly ___SASS_ERROR___: unique symbol;
|
382 |
|
383 | }
|
384 |
|
385 | interface ErrorConstructor {
|
386 | |
387 |
|
388 |
|
389 |
|
390 | new (message: string): Error;
|
391 | |
392 |
|
393 |
|
394 |
|
395 | (message: string): Error;
|
396 | }
|
397 | export const Error: ErrorConstructor;
|
398 |
|
399 |
|
400 |
|
401 | }
|
402 |
|
403 |
|
404 |
|
405 | export const NULL: types.Null;
|
406 | export const TRUE: types.Boolean;
|
407 | export const FALSE: types.Boolean;
|
408 | export const info: string;
|
409 | export function render(options: Options, callback: SassRenderCallback): void;
|
410 | export function renderSync(options: SyncOptions): Result;
|