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 | export type Value = Null | Number | String | Color | Boolean | List | Map;
|
147 |
|
148 | |
149 |
|
150 |
|
151 | export type ReturnValue = Value | Error;
|
152 |
|
153 |
|
154 |
|
155 | export interface Null {
|
156 | |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | readonly ___NULL___: unique symbol;
|
163 | }
|
164 |
|
165 | interface NullConstructor {
|
166 | (): Null;
|
167 | NULL: Null;
|
168 | }
|
169 | export const Null: NullConstructor;
|
170 |
|
171 |
|
172 |
|
173 | export interface Number {
|
174 | getValue(): number;
|
175 | setValue(n: number): void;
|
176 | getUnit(): string;
|
177 | setUnit(u: string): void;
|
178 | }
|
179 | interface NumberConstructor {
|
180 | |
181 |
|
182 |
|
183 | new(value: number, unit?: string): Number;
|
184 | |
185 |
|
186 |
|
187 | (value: number, unit?: string): Number;
|
188 | }
|
189 |
|
190 | export const Number: NumberConstructor;
|
191 |
|
192 |
|
193 |
|
194 | export interface String {
|
195 | getValue(): string;
|
196 | setValue(s: string): void;
|
197 | }
|
198 |
|
199 | interface StringConstructor {
|
200 | |
201 |
|
202 |
|
203 | new (value: string): String;
|
204 | |
205 |
|
206 |
|
207 | (value: string): String;
|
208 | }
|
209 |
|
210 | export const String: StringConstructor;
|
211 |
|
212 |
|
213 |
|
214 | export interface Color {
|
215 | |
216 |
|
217 |
|
218 |
|
219 | getR(): number;
|
220 | |
221 |
|
222 |
|
223 |
|
224 | setR(r: number): void;
|
225 | |
226 |
|
227 |
|
228 |
|
229 | getG(): number;
|
230 | |
231 |
|
232 |
|
233 |
|
234 | setG(g: number): void;
|
235 | |
236 |
|
237 |
|
238 |
|
239 | getB(): number;
|
240 | |
241 |
|
242 |
|
243 |
|
244 | setB(b: number): void;
|
245 | |
246 |
|
247 |
|
248 |
|
249 | getA(): number;
|
250 | |
251 |
|
252 |
|
253 |
|
254 | setA(a: number): void;
|
255 | }
|
256 |
|
257 | interface ColorConstructor {
|
258 | |
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 | new (r: number, g: number, b: number, a?: number): Color;
|
268 |
|
269 | |
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 | new (hexN: number): Color;
|
290 |
|
291 | |
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | (r: number, g: number, b: number, a?: number): Color;
|
301 |
|
302 | |
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 | (hexN: number): Color;
|
323 | }
|
324 |
|
325 | export const Color: ColorConstructor;
|
326 |
|
327 |
|
328 |
|
329 | export interface Boolean {
|
330 | getValue(): boolean;
|
331 | }
|
332 |
|
333 | interface BooleanConstructor {
|
334 | (bool: boolean): Boolean;
|
335 | TRUE: Boolean;
|
336 | FALSE: Boolean;
|
337 | }
|
338 |
|
339 | export const Boolean: BooleanConstructor;
|
340 |
|
341 |
|
342 |
|
343 | export interface Enumerable {
|
344 | getValue(index: number): Value;
|
345 | setValue(index: number, value: Value): void;
|
346 | getLength(): number;
|
347 | }
|
348 |
|
349 | export interface List extends Enumerable {
|
350 | getSeparator(): boolean;
|
351 | setSeparator(isComma: boolean): void;
|
352 | }
|
353 | interface ListConstructor {
|
354 | new (length: number, commaSeparator?: boolean): List;
|
355 | (length: number, commaSeparator?: boolean): List;
|
356 | }
|
357 | export const List: ListConstructor;
|
358 |
|
359 |
|
360 |
|
361 | export interface Map extends Enumerable {
|
362 | getKey(index: number): Value;
|
363 | setKey(index: number, key: Value): void;
|
364 | }
|
365 | interface MapConstructor {
|
366 | new (length: number): Map;
|
367 | (length: number): Map;
|
368 | }
|
369 | export const Map: MapConstructor;
|
370 |
|
371 |
|
372 |
|
373 | export interface Error {
|
374 | |
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 | readonly ___SASS_ERROR___: unique symbol;
|
381 |
|
382 | }
|
383 |
|
384 | interface ErrorConstructor {
|
385 | |
386 |
|
387 |
|
388 |
|
389 | new (message: string): Error;
|
390 | |
391 |
|
392 |
|
393 |
|
394 | (message: string): Error;
|
395 | }
|
396 | export const Error: ErrorConstructor;
|
397 |
|
398 |
|
399 |
|
400 | }
|
401 |
|
402 |
|
403 |
|
404 | export const NULL: types.Null;
|
405 | export const TRUE: types.Boolean;
|
406 | export const FALSE: types.Boolean;
|
407 | export const info: string;
|
408 | export function render(options: Options, callback: SassRenderCallback): void;
|
409 | export function renderSync(options: SyncOptions): Result;
|