/
render.d.ts
144 lines (134 loc) · 4.34 KB
/
render.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import {LegacyException} from './exception';
import {LegacyOptions} from './options';
/**
* The object returned by {@link render} and {@link renderSync} after a
* successful compilation.
*
* @category Legacy
* @deprecated This is only used by the legacy {@link render} and {@link
* renderSync} APIs. Use {@link compile}, {@link compileString}, {@link
* compileAsync}, and {@link compileStringAsync} instead.
*/
export interface LegacyResult {
/**
* The compiled CSS. This can be converted to a string by calling
* [Buffer.toString](https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end).
*
* @example
*
* ```js
* const result = sass.renderSync({file: "style.scss"});
*
* console.log(result.css.toString());
* ```
*/
css: Buffer;
/**
* The source map that maps the compiled CSS to the source files from which it
* was generated. This can be converted to a string by calling
* [Buffer.toString](https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end).
*
* This is `undefined` unless either
*
* * {@link LegacySharedOptions.sourceMap} is a string; or
* * {@link LegacySharedOptions.sourceMap} is `true` and
* {@link LegacySharedOptions.outFile} is set.
*
* The source map uses absolute [`file:`
* URLs](https://en.wikipedia.org/wiki/File_URI_scheme) to link to the Sass
* source files, except if the source file comes from {@link
* LegacyStringOptions.data} in which case it lists its URL as `"stdin"`.
*
* @example
*
* ```js
* const result = sass.renderSync({
* file: "style.scss",
* sourceMap: true,
* outFile: "style.css"
* })
*
* console.log(result.map.toString());
* ```
*/
map?: Buffer;
/** Additional information about the compilation. */
stats: {
/**
* The absolute path of {@link LegacyFileOptions.file} or {@link
* LegacyStringOptions.file}, or `"data"` if {@link
* LegacyStringOptions.file} wasn't set.
*/
entry: string;
/**
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and the
* time at which Sass compilation began.
*/
start: number;
/**
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and the
* time at which Sass compilation ended.
*/
end: number;
/**
* The number of milliseconds it took to compile the Sass file. This is
* always equal to `start` minus `end`.
*/
duration: number;
/**
* An array of the absolute paths of all Sass files loaded during
* compilation. If a stylesheet was loaded from a {@link LegacyImporter}
* that returned the stylesheet’s contents, the raw string of the `@use` or
* `@import` that loaded that stylesheet included in this array.
*/
includedFiles: string[];
};
}
/**
* This function synchronously compiles a Sass file to CSS. If it succeeds, it
* returns the result, and if it fails it throws an error.
*
* **Heads up!** When using the `sass-embedded` npm package, **{@link render}
* is almost always faster than {@link renderSync}**, due to the overhead of
* emulating synchronous messaging with worker threads and concurrent
* compilations being blocked on main thread.
*
* @example
*
* ```js
* const sass = require('sass'); // or require('node-sass');
*
* const result = sass.renderSync({file: "style.scss"});
* // ...
* ```
*
* @category Legacy
* @deprecated Use {@link compile} or {@link compileString} instead.
*/
export function renderSync(options: LegacyOptions<'sync'>): LegacyResult;
/**
* This function asynchronously compiles a Sass file to CSS, and calls
* `callback` with a {@link LegacyResult} if compilation succeeds or {@link
* LegacyException} if it fails.
*
* **Heads up!** When using the `sass` npm package, **{@link renderSync} is
* almost twice as fast as {@link render}** by default, due to the overhead of
* making the entire evaluation process asynchronous.
*
* ```js
* const sass = require('sass'); // or require('node-sass');
*
* sass.render({
* file: "style.scss"
* }, function(err, result) {
* // ...
* });
* ```
*
* @category Legacy
* @deprecated Use {@link compileAsync} or {@link compileStringAsync} instead.
*/
export function render(
options: LegacyOptions<'async'>,
callback: (exception?: LegacyException, result?: LegacyResult) => void
): void;