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