sass 1.45.0-rc.1 → 1.45.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.
@@ -0,0 +1,139 @@
1
+ import {LegacyException} from './exception';
2
+ import {LegacyOptions} from './options';
3
+
4
+ /**
5
+ * The object returned by [[render]] and [[renderSync]] after a successful
6
+ * compilation.
7
+ *
8
+ * @category Legacy
9
+ * @deprecated This is only used by the legacy [[render]] and [[renderSync]]
10
+ * APIs. Use [[compile]], [[compileString]], [[compileAsync]], and
11
+ * [[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
+ * * [[LegacySharedOptions.sourceMap]] is a string; or
36
+ * * [[LegacySharedOptions.sourceMap]] is `true` and
37
+ * [[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
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 [[LegacyFileOptions.file]] or
62
+ * [[LegacyStringOptions.file]], or `"data"` if [[LegacyStringOptions.file]]
63
+ * 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 [[LegacyImporter]] that
88
+ * 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
+ * @example
100
+ *
101
+ * ```js
102
+ * const sass = require('sass'); // or require('node-sass');
103
+ *
104
+ * const result = sass.renderSync({file: "style.scss"});
105
+ * // ...
106
+ * ```
107
+ *
108
+ * @category Legacy
109
+ * @deprecated Use [[compile]] or [[compileString]] instead.
110
+ */
111
+ export function renderSync(options: LegacyOptions<'sync'>): LegacyResult;
112
+
113
+ /**
114
+
115
+ * This function asynchronously compiles a Sass file to CSS, and calls
116
+ * `callback` with a [[LegacyResult]] if compilation succeeds or
117
+ * [[LegacyException]] if it fails.
118
+ *
119
+ * **Heads up!** When using Dart Sass, **[[renderSync]] is almost twice as fast
120
+ * as [[render]]** by default, due to the overhead of making the entire
121
+ * evaluation process asynchronous.
122
+ *
123
+ * ```js
124
+ * const sass = require('sass'); // or require('node-sass');
125
+ *
126
+ * sass.render({
127
+ * file: "style.scss"
128
+ * }, function(err, result) {
129
+ * // ...
130
+ * });
131
+ * ```
132
+ *
133
+ * @category Legacy
134
+ * @deprecated Use [[compileAsync]] or [[compileStringAsync]] instead.
135
+ */
136
+ export function render(
137
+ options: LegacyOptions<'async'>,
138
+ callback: (exception?: LegacyException, result?: LegacyResult) => void
139
+ ): void;
@@ -0,0 +1,94 @@
1
+ import {SourceSpan} from './source_span';
2
+
3
+ export {SourceLocation} from './source_location';
4
+ export {SourceSpan} from './source_span';
5
+
6
+ /**
7
+ * An object that can be passed to [[LegacySharedOptions.logger]] to control how
8
+ * Sass emits warnings and debug messages.
9
+ *
10
+ * @example
11
+ *
12
+ * ```js
13
+ * const fs = require('fs');
14
+ * const sass = require('sass');
15
+ *
16
+ * let log = "";
17
+ * sass.renderSync({
18
+ * file: 'input.scss',
19
+ * logger: {
20
+ * warn(message, options) {
21
+ * if (options.span) {
22
+ * log += `${span.url}:${span.start.line}:${span.start.column}: ` +
23
+ * `${message}\n`;
24
+ * } else {
25
+ * log += `::: ${message}\n`;
26
+ * }
27
+ * }
28
+ * }
29
+ * });
30
+ *
31
+ * fs.writeFileSync('log.txt', log);
32
+ * ```
33
+ *
34
+ * @category Logger
35
+ */
36
+ export interface Logger {
37
+ /**
38
+ * This method is called when Sass emits a warning, whether due to a [`@warn`
39
+ * rule](https://sass-lang.com/documentation/at-rules/warn) or a warning
40
+ * generated by the Sass compiler.
41
+ *
42
+ * If this is `undefined`, Sass will print warnings to standard error.
43
+ *
44
+ * @param message - The warning message.
45
+ * @param options.deprecation - Whether this is a deprecation warning.
46
+ * @param options.span - The location in the Sass source code that generated this
47
+ * warning.
48
+ * @param options.stack - The Sass stack trace at the point the warning was issued.
49
+ */
50
+ warn?(
51
+ message: string,
52
+ options: {
53
+ deprecation: boolean;
54
+ span?: SourceSpan;
55
+ stack?: string;
56
+ }
57
+ ): void;
58
+
59
+ /**
60
+ * This method is called when Sass emits a debug message due to a [`@debug`
61
+ * rule](https://sass-lang.com/documentation/at-rules/debug).
62
+ *
63
+ * If this is `undefined`, Sass will print debug messages to standard error.
64
+ *
65
+ * @param message - The debug message.
66
+ * @param options.span - The location in the Sass source code that generated this
67
+ * debug message.
68
+ */
69
+ debug?(message: string, options: {span: SourceSpan}): void;
70
+ }
71
+
72
+ /**
73
+ * A namespace for built-in [[Logger]]s.
74
+ *
75
+ * @category Logger
76
+ * @compatibility dart: "1.43.0", node: false
77
+ */
78
+ export namespace Logger {
79
+ /**
80
+ * A [[Logger]] that silently ignores all warnings and debug messages.
81
+ *
82
+ * @example
83
+ *
84
+ * ```js
85
+ * const sass = require('sass');
86
+ *
87
+ * const result = sass.renderSync({
88
+ * file: 'input.scss',
89
+ * logger: sass.Logger.silent,
90
+ * });
91
+ * ```
92
+ */
93
+ export const silent: Logger;
94
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A specific location within a source file.
3
+ *
4
+ * This is always associated with a [[SourceSpan]] which indicates *which* file
5
+ * 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 [[start]] and [[end]] refer to the same location, the span has zero
16
+ * length and refers to the point immediately after [[start]] and before the
17
+ * 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
+ }
@@ -0,0 +1,408 @@
1
+ import {FileImporter, Importer} from './importer';
2
+ import {Logger} from './logger';
3
+ import {Value} from './value';
4
+ import {PromiseOr} from './util/promise_or';
5
+
6
+ /**
7
+ * Syntaxes supported by Sass:
8
+ *
9
+ * - `'scss'` is the [SCSS
10
+ * syntax](https://sass-lang.com/documentation/syntax#scss).
11
+ * - `'indented'` is the [indented
12
+ * syntax](https://sass-lang.com/documentation/syntax#the-indented-syntax)
13
+ * - `'css'` is plain CSS, which is parsed like SCSS but forbids the use of any
14
+ * special Sass features.
15
+ *
16
+ * @category Options
17
+ */
18
+ export type Syntax = 'scss' | 'indented' | 'css';
19
+
20
+ /**
21
+ * Possible output styles for the compiled CSS:
22
+ *
23
+ * - `"expanded"` (the default for Dart Sass) writes each selector and
24
+ * declaration on its own line.
25
+ *
26
+ * - `"compressed"` removes as many extra characters as possible, and writes
27
+ * the entire stylesheet on a single line.
28
+ *
29
+ * @category Options
30
+ */
31
+ export type OutputStyle = 'expanded' | 'compressed';
32
+
33
+ /**
34
+ * A callback that implements a custom Sass function. This can be passed to
35
+ * [[Options.functions]].
36
+ *
37
+ * ```js
38
+ * const result = sass.compile('style.scss', {
39
+ * functions: {
40
+ * "sum($arg1, $arg2)": (args) => {
41
+ * const value1 = args[0].assertNumber('arg1').value;
42
+ * const value2 = args[1].assertNumber('arg2')
43
+ * .convertValueToMatch(arg1, 'arg2', 'arg1');
44
+ * return new sass.SassNumber(value1 + value2).coerceToMatch(arg1);
45
+ * }
46
+ * }
47
+ * });
48
+ * ```
49
+ *
50
+ * @typeParam sync - A `CustomFunction<'sync'>` must return synchronously, but
51
+ * in return it can be passed to [[compile]] and [[compileString]] in addition
52
+ * to [[compileAsync]] and [[compileStringAsync]].
53
+ *
54
+ * A `CustomFunction<'async'>` may either return synchronously or
55
+ * asynchronously, but it can only be used with [[compileAsync]] and
56
+ * [[compileStringAsync]].
57
+ *
58
+ * @param args - An array of arguments passed by the function's caller. If the
59
+ * function takes [arbitrary
60
+ * arguments](https://sass-lang.com/documentation/at-rules/function#taking-arbitrary-arguments),
61
+ * the last element will be a [[SassArgumentList]].
62
+ *
63
+ * @returns The function's result. This may be in the form of a `Promise`, but
64
+ * if it is the function may only be passed to [[compileAsync]] and
65
+ * [[compileStringAsync]], not [[compile]] or [[compileString]].
66
+ *
67
+ * @throws any - This function may throw an error, which the Sass compiler will
68
+ * treat as the function call failing. If the exception object has a `message`
69
+ * property, it will be used as the wrapped exception's message; otherwise, the
70
+ * exception object's `toString()` will be used. This means it's safe for custom
71
+ * functions to throw plain strings.
72
+ *
73
+ * @category Custom Function
74
+ */
75
+ export type CustomFunction<sync extends 'sync' | 'async'> = (
76
+ args: Value[]
77
+ ) => PromiseOr<Value, sync>;
78
+
79
+ /**
80
+ * Options that can be passed to [[compile]], [[compileAsync]],
81
+ * [[compileString]], or [[compileStringAsync]].
82
+ *
83
+ * @typeParam sync - This lets the TypeScript checker verify that asynchronous
84
+ * [[Importer]]s, [[FileImporter]]s, and [[CustomFunction]]s aren't passed to
85
+ * [[compile]] or [[compileString]].
86
+ *
87
+ * @category Options
88
+ */
89
+ export interface Options<sync extends 'sync' | 'async'> {
90
+ /**
91
+ * If this is `true`, the compiler will exclusively use ASCII characters in
92
+ * its error and warning messages. Otherwise, it may use non-ASCII Unicode
93
+ * characters as well.
94
+ *
95
+ * @defaultValue `false`
96
+ * @category Messages
97
+ */
98
+ alertAscii?: boolean;
99
+
100
+ /**
101
+ * If this is `true`, the compiler will use ANSI color escape codes in its
102
+ * error and warning messages. If it's `false`, it won't use these. If it's
103
+ * undefined, the compiler will determine whether or not to use colors
104
+ * depending on whether the user is using an interactive terminal.
105
+ *
106
+ * @category Messages
107
+ */
108
+ alertColor?: boolean;
109
+
110
+ /**
111
+ * Additional built-in Sass functions that are available in all stylesheets.
112
+ * This option takes an object whose keys are Sass function signatures like
113
+ * you'd write for the [`@function
114
+ * rule`](https://sass-lang.com/documentation/at-rules/function) and whose
115
+ * values are [[CustomFunction]]s.
116
+ *
117
+ * Functions are passed JavaScript representations of [Sass value
118
+ * types](https://sass-lang.com/documentation/js-api#value-types), and must
119
+ * return the same.
120
+ *
121
+ * When writing custom functions, it's important to make them as user-friendly
122
+ * and as close to the standards set by Sass's core functions as possible. Some
123
+ * good guidelines to follow include:
124
+ *
125
+ * * Use `Value.assert*` methods, like [[Value.assertString]], to cast untyped
126
+ * `Value` objects to more specific types. For values that were passed
127
+ * directly as arguments, pass in the argument name as well. This ensures
128
+ * that the user gets good error messages when they pass in the wrong type
129
+ * to your function.
130
+ *
131
+ * * Individual classes may have more specific `assert*` methods, like
132
+ * [[SassNumber.assertInt]], which should be used when possible.
133
+ *
134
+ * * In Sass, every value counts as a list. Rather than trying to detect the
135
+ * [[SassList]] type, you should use [[Value.asList]] to treat all values as
136
+ * lists.
137
+ *
138
+ * * When manipulating values like lists, strings, and numbers that have
139
+ * metadata (comma versus space separated, bracketed versus unbracketed,
140
+ * quoted versus unquoted, units), the output metadata should match the
141
+ * input metadata.
142
+ *
143
+ * * When in doubt, lists should default to comma-separated, strings should
144
+ * default to quoted, and numbers should default to unitless.
145
+ *
146
+ * * In Sass, lists and strings use one-based indexing and use negative
147
+ * indices to index from the end of value. Functions should follow these
148
+ * conventions. [[Value.sassIndexToListIndex]] and
149
+ * [[SassString.sassIndexToStringIndex]] can be used to do this
150
+ * automatically.
151
+ *
152
+ * * String indexes in Sass refer to Unicode code points while JavaScript
153
+ * string indices refer to UTF-16 code units. For example, the character
154
+ * U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
155
+ * is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
156
+ * JavaScript, `"a😊b".charCodeAt(1)` returns `0xD83D`, whereas in Sass
157
+ * `str-slice("a😊b", 1, 1)` returns `"😊"`. Functions should follow Sass's
158
+ * convention. [[SassString.sassIndexToStringIndex]] can be used to do this
159
+ * automatically, and the [[SassString.sassLength]] getter can be used to
160
+ * access a string's length in code points.
161
+ *
162
+ * @example
163
+ *
164
+ * ```js
165
+ * sass.compileString(`
166
+ * h1 {
167
+ * font-size: pow(2, 5) * 1px;
168
+ * }`, {
169
+ * functions: {
170
+ * // Note: in real code, you should use `math.pow()` from the built-in
171
+ * // `sass:math` module.
172
+ * 'pow($base, $exponent)': function(args) {
173
+ * const base = args[0].assertNumber('base').assertNoUnits('base');
174
+ * const exponent =
175
+ * args[1].assertNumber('exponent').assertNoUnits('exponent');
176
+ *
177
+ * return new sass.SassNumber(Math.pow(base.value, exponent.value));
178
+ * }
179
+ * }
180
+ * });
181
+ * ```
182
+ *
183
+ * @category Plugins
184
+ */
185
+ functions?: Record<string, CustomFunction<sync>>;
186
+
187
+ /**
188
+ * Custom importers that control how Sass resolves loads from rules like
189
+ * [`@use`](https://sass-lang.com/documentation/at-rules/use) and
190
+ * [`@import`](https://sass-lang.com/documentation/at-rules/import).
191
+ *
192
+ * Loads are resolved by trying, in order:
193
+ *
194
+ * - The importer that was used to load the current stylesheet, with the
195
+ * loaded URL resolved relative to the current stylesheet's canonical URL.
196
+ *
197
+ * - Each [[Importer]] or [[FileImporter]] in [[importers]], in order.
198
+ *
199
+ * - Each load path in [[loadPaths]], in order.
200
+ *
201
+ * If none of these return a Sass file, the load fails and Sass throws an
202
+ * error.
203
+ *
204
+ * @category Plugins
205
+ */
206
+ importers?: (Importer<sync> | FileImporter<sync>)[];
207
+
208
+ /**
209
+ * Paths in which to look for stylesheets loaded by rules like
210
+ * [`@use`](https://sass-lang.com/documentation/at-rules/use) and
211
+ * [`@import`](https://sass-lang.com/documentation/at-rules/import).
212
+ *
213
+ * A load path `loadPath` is equivalent to the following [[FileImporter]]:
214
+ *
215
+ * ```js
216
+ * {
217
+ * findFileUrl(url) {
218
+ * // Load paths only support relative URLs.
219
+ * if (/^[a-z]+:/i.test(url)) return null;
220
+ * return new URL(url, pathToFileURL(loadPath));
221
+ * }
222
+ * }
223
+ * ```
224
+ *
225
+ * @category Input
226
+ */
227
+ loadPaths?: string[];
228
+
229
+ /**
230
+ * An object to use to handle warnings and/or debug messages from Sass.
231
+ *
232
+ * By default, Sass emits warnings and debug messages to standard error, but
233
+ * if [[Logger.warn]] or [[Logger.debug]] is set, this will invoke them
234
+ * instead.
235
+ *
236
+ * The special value [[Logger.silent]] can be used to easily silence all
237
+ * messages.
238
+ *
239
+ * @category Messages
240
+ */
241
+ logger?: Logger;
242
+
243
+ /**
244
+ * If this option is set to `true`, Sass won’t print warnings that are caused
245
+ * by dependencies. A “dependency” is defined as any file that’s loaded
246
+ * through [[loadPaths]] or [[importer]]. Stylesheets that are imported
247
+ * relative to the entrypoint are not considered dependencies.
248
+ *
249
+ * This is useful for silencing deprecation warnings that you can’t fix on
250
+ * your own. However, please <em>also</em> notify your dependencies of the deprecations
251
+ * so that they can get fixed as soon as possible!
252
+ *
253
+ * **Heads up!** If [[compileString]] or [[compileStringAsync]] is called
254
+ * without [[StringWithoutImporter.url]], <em>all</em> stylesheets it loads
255
+ * will be considered dependencies. Since it doesn’t have a path of its own,
256
+ * everything it loads is coming from a load path rather than a relative
257
+ * import.
258
+ *
259
+ * @defaultValue `false`
260
+ * @category Messages
261
+ */
262
+ quietDeps?: boolean;
263
+
264
+ /**
265
+ * Whether or not Sass should generate a source map. If it does, the source
266
+ * map will be available as [[CompileResult.sourceMap]].
267
+ *
268
+ * **Heads up!** Sass doesn't automatically add a `sourceMappingURL` comment
269
+ * to the generated CSS. It's up to callers to do that, since callers have
270
+ * full knowledge of where the CSS and the source map will exist in relation
271
+ * to one another and how they'll be served to the browser.
272
+ *
273
+ * @defaultValue `false`
274
+ * @category Output
275
+ */
276
+ sourceMap?: boolean;
277
+
278
+ /**
279
+ * The [[OutputStyle]] of the compiled CSS.
280
+ *
281
+ * @example
282
+ *
283
+ * ```js
284
+ * const source = `
285
+ * h1 {
286
+ * font-size: 40px;
287
+ * code {
288
+ * font-face: Roboto Mono;
289
+ * }
290
+ * }`;
291
+ *
292
+ * let result = sass.compileString(source, {style: "expanded"});
293
+ * console.log(result.css.toString());
294
+ * // h1 {
295
+ * // font-size: 40px;
296
+ * // }
297
+ * // h1 code {
298
+ * // font-face: Roboto Mono;
299
+ * // }
300
+ *
301
+ * result = sass.compileString(source, {style: "compressed"})
302
+ * console.log(result.css.toString());
303
+ * // h1{font-size:40px}h1 code{font-face:Roboto Mono}
304
+ * ```
305
+ *
306
+ * @category Output
307
+ */
308
+ style?: OutputStyle;
309
+
310
+ /**
311
+ * By default, Dart Sass will print only five instances of the same
312
+ * deprecation warning per compilation to avoid deluging users in console
313
+ * noise. If you set `verbose` to `true`, it will instead print every
314
+ * deprecation warning it encounters.
315
+ *
316
+ * @defaultValue `false`
317
+ * @category Messages
318
+ */
319
+ verbose?: boolean;
320
+ }
321
+
322
+ /**
323
+ * Options that can be passed to [[compileString]] or [[compileStringAsync]].
324
+ *
325
+ * If the [[StringOptionsWithImporter.importer]] field isn't passed, the
326
+ * entrypoint file can't load files relative to itself and the [[url]] field is
327
+ * optional.
328
+ *
329
+ * @typeParam sync - This lets the TypeScript checker verify that asynchronous
330
+ * [[Importer]]s, [[FileImporter]]s, and [[CustomFunction]]s aren't passed to
331
+ * [[compile]] or [[compileString]].
332
+ *
333
+ * @category Options
334
+ */
335
+ export interface StringOptionsWithoutImporter<sync extends 'sync' | 'async'>
336
+ extends Options<sync> {
337
+ /**
338
+ * The [[Syntax]] to use to parse the entrypoint stylesheet.
339
+ *
340
+ * @default `'scss'`
341
+ *
342
+ * @category Input
343
+ */
344
+ syntax?: Syntax;
345
+
346
+ /**
347
+ * The canonical URL of the entrypoint stylesheet. If this isn't passed along
348
+ * with [[StringOptionsWithoutImporter.importer]], it's optional and only used
349
+ * for error reporting.
350
+ *
351
+ * @category Input
352
+ */
353
+ url?: URL;
354
+ }
355
+
356
+ /**
357
+ * Options that can be passed to [[compileString]] or [[compileStringAsync]].
358
+ *
359
+ * If the [[StringOptionsWithImporter.importer]] field is passed, the entrypoint
360
+ * file uses it to load files relative to itself and the [[url]] field is
361
+ * mandatory.
362
+ *
363
+ * @typeParam sync - This lets the TypeScript checker verify that asynchronous
364
+ * [[Importer]]s, [[FileImporter]]s, and [[CustomFunction]]s aren't passed to
365
+ * [[compile]] or [[compileString]].
366
+ *
367
+ * @category Options
368
+ */
369
+ export interface StringOptionsWithImporter<sync extends 'sync' | 'async'>
370
+ extends StringOptionsWithoutImporter<sync> {
371
+ /**
372
+ * The importer to use to handle loads that are relative to the entrypoint
373
+ * stylesheet.
374
+ *
375
+ * A relative load's URL is first resolved relative to [[url]], then passed to
376
+ * [[importer]]. If the importer doesn't recognize it, it's then passed to
377
+ * [[importers]] and [[loadPaths]].
378
+ *
379
+ * @category Input
380
+ */
381
+ importer: Importer<sync> | FileImporter<sync>;
382
+
383
+ /**
384
+ * The canonical URL of the entrypoint stylesheet. If this is passed along
385
+ * with [[importer]], it's used to resolve relative loads in the entrypoint
386
+ * stylesheet.
387
+ *
388
+ * @category Input
389
+ */
390
+ url: URL;
391
+ }
392
+
393
+ /**
394
+ * Options that can be passed to [[compileString]] or [[compileStringAsync]].
395
+ *
396
+ * This is a [[StringOptionsWithImporter]] if it has a
397
+ * [[StringOptionsWithImporter.importer]] field, and a
398
+ * [[StringOptionsWithoutImporter]] otherwise.
399
+ *
400
+ * @typeParam sync - This lets the TypeScript checker verify that asynchronous
401
+ * [[Importer]]s, [[FileImporter]]s, and [[CustomFunction]]s aren't passed to
402
+ * [[compile]] or [[compileString]].
403
+ *
404
+ * @category Options
405
+ */
406
+ export type StringOptions<sync extends 'sync' | 'async'> =
407
+ | StringOptionsWithImporter<sync>
408
+ | StringOptionsWithoutImporter<sync>;