@sass/types 1.93.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +6 -0
- package/package.json +18 -0
- package/types/compile.d.ts +342 -0
- package/types/deprecations.d.ts +290 -0
- package/types/exception.d.ts +41 -0
- package/types/importer.d.ts +471 -0
- package/types/index.d.ts +122 -0
- package/types/legacy/exception.d.ts +55 -0
- package/types/legacy/function.d.ts +757 -0
- package/types/legacy/importer.d.ts +169 -0
- package/types/legacy/options.d.ts +700 -0
- package/types/legacy/plugin_this.d.ts +74 -0
- package/types/legacy/render.d.ts +144 -0
- package/types/logger/index.d.ts +115 -0
- package/types/logger/source_location.d.ts +21 -0
- package/types/logger/source_span.d.ts +34 -0
- package/types/options.d.ts +468 -0
- package/types/util/promise_or.d.ts +17 -0
- package/types/value/argument_list.d.ts +47 -0
- package/types/value/boolean.d.ts +29 -0
- package/types/value/calculation.d.ts +137 -0
- package/types/value/color.d.ts +566 -0
- package/types/value/function.d.ts +22 -0
- package/types/value/index.d.ts +219 -0
- package/types/value/list.d.ts +54 -0
- package/types/value/map.d.ts +41 -0
- package/types/value/mixin.d.ts +14 -0
- package/types/value/number.d.ts +305 -0
- package/types/value/string.d.ts +84 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value of `this` in the context of a {@link LegacyImporter} or {@link
|
|
3
|
+
* LegacyFunction} callback.
|
|
4
|
+
*
|
|
5
|
+
* @category Legacy
|
|
6
|
+
* @deprecated This is only used by the legacy {@link render} and {@link
|
|
7
|
+
* renderSync} APIs. Use {@link compile}, {@link compileString}, {@link
|
|
8
|
+
* compileAsync}, and {@link compileStringAsync} instead.
|
|
9
|
+
*/
|
|
10
|
+
export interface LegacyPluginThis {
|
|
11
|
+
/**
|
|
12
|
+
* A partial representation of the options passed to {@link render} or {@link
|
|
13
|
+
* renderSync}.
|
|
14
|
+
*/
|
|
15
|
+
options: {
|
|
16
|
+
/** The same {@link LegacyPluginThis} instance that contains this object. */
|
|
17
|
+
context: LegacyPluginThis;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The value passed to {@link LegacyFileOptions.file} or {@link
|
|
21
|
+
* LegacyStringOptions.file}.
|
|
22
|
+
*/
|
|
23
|
+
file?: string;
|
|
24
|
+
|
|
25
|
+
/** The value passed to {@link LegacyStringOptions.data}. */
|
|
26
|
+
data?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The value passed to {@link LegacySharedOptions.includePaths} separated by
|
|
30
|
+
* `";"` on Windows or `":"` on other operating systems. This always
|
|
31
|
+
* includes the current working directory as the first entry.
|
|
32
|
+
*/
|
|
33
|
+
includePaths: string;
|
|
34
|
+
|
|
35
|
+
/** Always the number 10. */
|
|
36
|
+
precision: 10;
|
|
37
|
+
|
|
38
|
+
/** Always the number 1. */
|
|
39
|
+
style: 1;
|
|
40
|
+
|
|
41
|
+
/** 1 if {@link LegacySharedOptions.indentType} was `"tab"`, 0 otherwise. */
|
|
42
|
+
indentType: 1 | 0;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The value passed to {@link LegacySharedOptions.indentWidth}, or `2`
|
|
46
|
+
* otherwise.
|
|
47
|
+
*/
|
|
48
|
+
indentWidth: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The value passed to {@link LegacySharedOptions.linefeed}, or `"\n"`
|
|
52
|
+
* otherwise.
|
|
53
|
+
*/
|
|
54
|
+
linefeed: '\r' | '\r\n' | '\n' | '\n\r';
|
|
55
|
+
|
|
56
|
+
/** A partially-constructed {@link LegacyResult} object. */
|
|
57
|
+
result: {
|
|
58
|
+
/** Partial information about the compilation in progress. */
|
|
59
|
+
stats: {
|
|
60
|
+
/**
|
|
61
|
+
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and
|
|
62
|
+
* the time at which Sass compilation began.
|
|
63
|
+
*/
|
|
64
|
+
start: number;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* {@link LegacyFileOptions.file} if it was passed, otherwise the string
|
|
68
|
+
* `"data"`.
|
|
69
|
+
*/
|
|
70
|
+
entry: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {LegacyException} from './exception';
|
|
2
|
+
import {LegacyOptions} from './options';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The object returned by {@link render} and {@link renderSync} after a
|
|
6
|
+
* successful compilation.
|
|
7
|
+
*
|
|
8
|
+
* @category Legacy
|
|
9
|
+
* @deprecated This is only used by the legacy {@link render} and {@link
|
|
10
|
+
* renderSync} APIs. Use {@link compile}, {@link compileString}, {@link
|
|
11
|
+
* compileAsync}, and {@link compileStringAsync} instead.
|
|
12
|
+
*/
|
|
13
|
+
export interface LegacyResult {
|
|
14
|
+
/**
|
|
15
|
+
* The compiled CSS. This can be converted to a string by calling
|
|
16
|
+
* [Buffer.toString](https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* const result = sass.renderSync({file: "style.scss"});
|
|
22
|
+
*
|
|
23
|
+
* console.log(result.css.toString());
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
css: Buffer;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The source map that maps the compiled CSS to the source files from which it
|
|
30
|
+
* was generated. This can be converted to a string by calling
|
|
31
|
+
* [Buffer.toString](https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end).
|
|
32
|
+
*
|
|
33
|
+
* This is `undefined` unless either
|
|
34
|
+
*
|
|
35
|
+
* * {@link LegacySharedOptions.sourceMap} is a string; or
|
|
36
|
+
* * {@link LegacySharedOptions.sourceMap} is `true` and
|
|
37
|
+
* {@link LegacySharedOptions.outFile} is set.
|
|
38
|
+
*
|
|
39
|
+
* The source map uses absolute [`file:`
|
|
40
|
+
* URLs](https://en.wikipedia.org/wiki/File_URI_scheme) to link to the Sass
|
|
41
|
+
* source files, except if the source file comes from {@link
|
|
42
|
+
* LegacyStringOptions.data} in which case it lists its URL as `"stdin"`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* ```js
|
|
47
|
+
* const result = sass.renderSync({
|
|
48
|
+
* file: "style.scss",
|
|
49
|
+
* sourceMap: true,
|
|
50
|
+
* outFile: "style.css"
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* console.log(result.map.toString());
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
map?: Buffer;
|
|
57
|
+
|
|
58
|
+
/** Additional information about the compilation. */
|
|
59
|
+
stats: {
|
|
60
|
+
/**
|
|
61
|
+
* The absolute path of {@link LegacyFileOptions.file} or {@link
|
|
62
|
+
* LegacyStringOptions.file}, or `"data"` if {@link
|
|
63
|
+
* LegacyStringOptions.file} wasn't set.
|
|
64
|
+
*/
|
|
65
|
+
entry: string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and the
|
|
69
|
+
* time at which Sass compilation began.
|
|
70
|
+
*/
|
|
71
|
+
start: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The number of milliseconds between 1 January 1970 at 00:00:00 UTC and the
|
|
75
|
+
* time at which Sass compilation ended.
|
|
76
|
+
*/
|
|
77
|
+
end: number;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The number of milliseconds it took to compile the Sass file. This is
|
|
81
|
+
* always equal to `start` minus `end`.
|
|
82
|
+
*/
|
|
83
|
+
duration: number;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* An array of the absolute paths of all Sass files loaded during
|
|
87
|
+
* compilation. If a stylesheet was loaded from a {@link LegacyImporter}
|
|
88
|
+
* that returned the stylesheet’s contents, the raw string of the `@use` or
|
|
89
|
+
* `@import` that loaded that stylesheet included in this array.
|
|
90
|
+
*/
|
|
91
|
+
includedFiles: string[];
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This function synchronously compiles a Sass file to CSS. If it succeeds, it
|
|
97
|
+
* returns the result, and if it fails it throws an error.
|
|
98
|
+
*
|
|
99
|
+
* **Heads up!** When using the `sass-embedded` npm package, **{@link render}
|
|
100
|
+
* is almost always faster than {@link renderSync}**, due to the overhead of
|
|
101
|
+
* emulating synchronous messaging with worker threads and concurrent
|
|
102
|
+
* compilations being blocked on main thread.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
*
|
|
106
|
+
* ```js
|
|
107
|
+
* const sass = require('sass'); // or require('node-sass');
|
|
108
|
+
*
|
|
109
|
+
* const result = sass.renderSync({file: "style.scss"});
|
|
110
|
+
* // ...
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @category Legacy
|
|
114
|
+
* @deprecated Use {@link compile} or {@link compileString} instead.
|
|
115
|
+
*/
|
|
116
|
+
export function renderSync(options: LegacyOptions<'sync'>): LegacyResult;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
|
|
120
|
+
* This function asynchronously compiles a Sass file to CSS, and calls
|
|
121
|
+
* `callback` with a {@link LegacyResult} if compilation succeeds or {@link
|
|
122
|
+
* LegacyException} if it fails.
|
|
123
|
+
*
|
|
124
|
+
* **Heads up!** When using the `sass` npm package, **{@link renderSync} is
|
|
125
|
+
* almost twice as fast as {@link render}** by default, due to the overhead of
|
|
126
|
+
* making the entire evaluation process asynchronous.
|
|
127
|
+
*
|
|
128
|
+
* ```js
|
|
129
|
+
* const sass = require('sass'); // or require('node-sass');
|
|
130
|
+
*
|
|
131
|
+
* sass.render({
|
|
132
|
+
* file: "style.scss"
|
|
133
|
+
* }, function(err, result) {
|
|
134
|
+
* // ...
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @category Legacy
|
|
139
|
+
* @deprecated Use {@link compileAsync} or {@link compileStringAsync} instead.
|
|
140
|
+
*/
|
|
141
|
+
export function render(
|
|
142
|
+
options: LegacyOptions<'async'>,
|
|
143
|
+
callback: (exception?: LegacyException, result?: LegacyResult) => void
|
|
144
|
+
): void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {Deprecation} from '../deprecations';
|
|
2
|
+
import {SourceSpan} from './source_span';
|
|
3
|
+
|
|
4
|
+
export {SourceLocation} from './source_location';
|
|
5
|
+
export {SourceSpan} from './source_span';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The options passed to {@link Logger.warn}.
|
|
9
|
+
*
|
|
10
|
+
* * `deprecation`: Whether this is a deprecation warning.
|
|
11
|
+
*
|
|
12
|
+
* * `deprecationType`: The type of deprecation. Only set if `deprecation` is
|
|
13
|
+
* true.
|
|
14
|
+
*
|
|
15
|
+
* * `span`: The location in the Sass source code that generated this warning.
|
|
16
|
+
* This may be unset if the warning didn't come from Sass source, for
|
|
17
|
+
* example if it's from a deprecated JavaScript option.
|
|
18
|
+
*
|
|
19
|
+
* * `stack`: The Sass stack trace at the point the warning was issued. This may
|
|
20
|
+
* be unset if the warning didn't come from Sass source, for example if it's
|
|
21
|
+
* from a deprecated JavaScript option.
|
|
22
|
+
*
|
|
23
|
+
* @category Logger
|
|
24
|
+
*/
|
|
25
|
+
export type LoggerWarnOptions = (
|
|
26
|
+
| {
|
|
27
|
+
deprecation: true;
|
|
28
|
+
deprecationType: Deprecation;
|
|
29
|
+
}
|
|
30
|
+
| {deprecation: false}
|
|
31
|
+
) & {
|
|
32
|
+
span?: SourceSpan;
|
|
33
|
+
stack?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An object that can be passed to {@link LegacySharedOptions.logger} to control
|
|
38
|
+
* how Sass emits warnings and debug messages.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
*
|
|
42
|
+
* ```js
|
|
43
|
+
* const fs = require('fs');
|
|
44
|
+
* const sass = require('sass');
|
|
45
|
+
*
|
|
46
|
+
* let log = "";
|
|
47
|
+
* sass.renderSync({
|
|
48
|
+
* file: 'input.scss',
|
|
49
|
+
* logger: {
|
|
50
|
+
* warn(message, options) {
|
|
51
|
+
* if (options.span) {
|
|
52
|
+
* log += `${span.url}:${span.start.line}:${span.start.column}: ` +
|
|
53
|
+
* `${message}\n`;
|
|
54
|
+
* } else {
|
|
55
|
+
* log += `::: ${message}\n`;
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* fs.writeFileSync('log.txt', log);
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @category Logger
|
|
65
|
+
*/
|
|
66
|
+
export interface Logger {
|
|
67
|
+
/**
|
|
68
|
+
* This method is called when Sass emits a warning, whether due to a [`@warn`
|
|
69
|
+
* rule](https://sass-lang.com/documentation/at-rules/warn) or a warning
|
|
70
|
+
* generated by the Sass compiler.
|
|
71
|
+
*
|
|
72
|
+
* If this is `undefined`, Sass will print warnings to standard error.
|
|
73
|
+
*
|
|
74
|
+
* `options` may contain the following fields:
|
|
75
|
+
*
|
|
76
|
+
* @param message - The warning message.
|
|
77
|
+
*/
|
|
78
|
+
warn?(message: string, options: LoggerWarnOptions): void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* This method is called when Sass emits a debug message due to a [`@debug`
|
|
82
|
+
* rule](https://sass-lang.com/documentation/at-rules/debug).
|
|
83
|
+
*
|
|
84
|
+
* If this is `undefined`, Sass will print debug messages to standard error.
|
|
85
|
+
*
|
|
86
|
+
* @param message - The debug message.
|
|
87
|
+
* @param options.span - The location in the Sass source code that generated this
|
|
88
|
+
* debug message.
|
|
89
|
+
*/
|
|
90
|
+
debug?(message: string, options: {span: SourceSpan}): void;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A namespace for built-in {@link Logger}s.
|
|
95
|
+
*
|
|
96
|
+
* @category Logger
|
|
97
|
+
* @compatibility dart: "1.43.0", node: false
|
|
98
|
+
*/
|
|
99
|
+
export namespace Logger {
|
|
100
|
+
/**
|
|
101
|
+
* A {@link Logger} that silently ignores all warnings and debug messages.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
*
|
|
105
|
+
* ```js
|
|
106
|
+
* const sass = require('sass');
|
|
107
|
+
*
|
|
108
|
+
* const result = sass.renderSync({
|
|
109
|
+
* file: 'input.scss',
|
|
110
|
+
* logger: sass.Logger.silent,
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export const silent: Logger;
|
|
115
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A specific location within a source file.
|
|
3
|
+
*
|
|
4
|
+
* This is always associated with a {@link SourceSpan} which indicates *which*
|
|
5
|
+
* file it refers to.
|
|
6
|
+
*
|
|
7
|
+
* @category Logger
|
|
8
|
+
*/
|
|
9
|
+
export interface SourceLocation {
|
|
10
|
+
/**
|
|
11
|
+
* The 0-based index of this location within its source file, in terms of
|
|
12
|
+
* UTF-16 code units.
|
|
13
|
+
*/
|
|
14
|
+
offset: number;
|
|
15
|
+
|
|
16
|
+
/** The 0-based line number of this location. */
|
|
17
|
+
line: number;
|
|
18
|
+
|
|
19
|
+
/** The 0-based column number of this location. */
|
|
20
|
+
column: number;
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {SourceLocation} from './source_location';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A span of text within a source file.
|
|
5
|
+
*
|
|
6
|
+
* @category Logger
|
|
7
|
+
*/
|
|
8
|
+
export interface SourceSpan {
|
|
9
|
+
/** The beginning of this span, inclusive. */
|
|
10
|
+
start: SourceLocation;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The end of this span, exclusive.
|
|
14
|
+
*
|
|
15
|
+
* If {@link start} and {@link end} refer to the same location, the span has
|
|
16
|
+
* zero length and refers to the point immediately after {@link start} and
|
|
17
|
+
* before the next character.
|
|
18
|
+
*/
|
|
19
|
+
end: SourceLocation;
|
|
20
|
+
|
|
21
|
+
/** The canonical URL of the file this span refers to. */
|
|
22
|
+
url?: URL;
|
|
23
|
+
|
|
24
|
+
/** The text covered by the span. */
|
|
25
|
+
text: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Text surrounding the span.
|
|
29
|
+
*
|
|
30
|
+
* If this is set, it must include only whole lines, and it must include at
|
|
31
|
+
* least all line(s) which are partially covered by this span.
|
|
32
|
+
*/
|
|
33
|
+
context?: string;
|
|
34
|
+
}
|