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