sass 1.67.0 → 1.69.0

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/sass.default.js CHANGED
@@ -20,6 +20,7 @@ export const SassColor = _cliPkgExports.SassColor;
20
20
  export const SassFunction = _cliPkgExports.SassFunction;
21
21
  export const SassList = _cliPkgExports.SassList;
22
22
  export const SassMap = _cliPkgExports.SassMap;
23
+ export const SassMixin = _cliPkgExports.SassMixin;
23
24
  export const SassNumber = _cliPkgExports.SassNumber;
24
25
  export const SassString = _cliPkgExports.SassString;
25
26
  export const Value = _cliPkgExports.Value;
package/sass.node.mjs CHANGED
@@ -14,6 +14,7 @@ export const SassColor = cjs.SassColor;
14
14
  export const SassFunction = cjs.SassFunction;
15
15
  export const SassList = cjs.SassList;
16
16
  export const SassMap = cjs.SassMap;
17
+ export const SassMixin = cjs.SassMixin;
17
18
  export const SassNumber = cjs.SassNumber;
18
19
  export const SassString = cjs.SassString;
19
20
  export const Value = cjs.Value;
@@ -98,6 +99,10 @@ export default {
98
99
  defaultExportDeprecation();
99
100
  return cjs.SassMap;
100
101
  },
102
+ get SassMixin() {
103
+ defaultExportDeprecation();
104
+ return cjs.SassMixin;
105
+ },
101
106
  get SassNumber() {
102
107
  defaultExportDeprecation();
103
108
  return cjs.SassNumber;
@@ -1,6 +1,38 @@
1
1
  import {Syntax} from './options';
2
2
  import {PromiseOr} from './util/promise_or';
3
3
 
4
+ /**
5
+ * Contextual information passed to {@link Importer.canonicalize} and {@link
6
+ * FileImporter.findFileUrl}. Not all importers will need this information to
7
+ * resolve loads, but some may find it useful.
8
+ */
9
+ export interface CanonicalizeContext {
10
+ /**
11
+ * Whether this is being invoked because of a Sass
12
+ * `@import` rule, as opposed to a `@use` or `@forward` rule.
13
+ *
14
+ * This should *only* be used for determining whether or not to load
15
+ * [import-only files](https://sass-lang.com/documentation/at-rules/import#import-only-files).
16
+ */
17
+ fromImport: boolean;
18
+
19
+ /**
20
+ * The canonical URL of the file that contains the load, if that information
21
+ * is available.
22
+ *
23
+ * For an {@link Importer}, this is only passed when the `url` parameter is a
24
+ * relative URL _or_ when its [URL scheme] is included in {@link
25
+ * Importer.nonCanonicalScheme}. This ensures that canonical URLs are always
26
+ * resolved the same way regardless of context.
27
+ *
28
+ * [URL scheme]: https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#scheme
29
+ *
30
+ * For a {@link FileImporter}, this is always available as long as Sass knows
31
+ * the canonical URL of the containing file.
32
+ */
33
+ containingUrl: URL | null;
34
+ }
35
+
4
36
  /**
5
37
  * A special type of importer that redirects all loads to existing files on
6
38
  * disk. Although this is less powerful than a full {@link Importer}, it
@@ -56,12 +88,6 @@ export interface FileImporter<
56
88
  * @param url - The loaded URL. Since this might be relative, it's represented
57
89
  * as a string rather than a {@link URL} object.
58
90
  *
59
- * @param options.fromImport - Whether this is being invoked because of a Sass
60
- * `@import` rule, as opposed to a `@use` or `@forward` rule.
61
- *
62
- * This should *only* be used for determining whether or not to load
63
- * [import-only files](https://sass-lang.com/documentation/at-rules/import#import-only-files).
64
- *
65
91
  * @returns An absolute `file:` URL if this importer recognizes the `url`.
66
92
  * This may be only partially resolved: the compiler will automatically look
67
93
  * for [partials](https://sass-lang.com/documentation/at-rules/use#partials),
@@ -85,7 +111,7 @@ export interface FileImporter<
85
111
  */
86
112
  findFileUrl(
87
113
  url: string,
88
- options: {fromImport: boolean}
114
+ context: CanonicalizeContext
89
115
  ): PromiseOr<URL | null, sync>;
90
116
 
91
117
  /** @hidden */
@@ -220,12 +246,6 @@ export interface Importer<sync extends 'sync' | 'async' = 'sync' | 'async'> {
220
246
  * @param url - The loaded URL. Since this might be relative, it's represented
221
247
  * as a string rather than a {@link URL} object.
222
248
  *
223
- * @param options.fromImport - Whether this is being invoked because of a Sass
224
- * `@import` rule, as opposed to a `@use` or `@forward` rule.
225
- *
226
- * This should *only* be used for determining whether or not to load
227
- * [import-only files](https://sass-lang.com/documentation/at-rules/import#import-only-files).
228
- *
229
249
  * @returns An absolute URL if this importer recognizes the `url`, or `null`
230
250
  * if it doesn't. If this returns `null`, other importers or {@link
231
251
  * Options.loadPaths | load paths} may handle the load.
@@ -242,7 +262,7 @@ export interface Importer<sync extends 'sync' | 'async' = 'sync' | 'async'> {
242
262
  */
243
263
  canonicalize(
244
264
  url: string,
245
- options: {fromImport: boolean}
265
+ context: CanonicalizeContext
246
266
  ): PromiseOr<URL | null, sync>;
247
267
 
248
268
  /**
@@ -272,6 +292,20 @@ export interface Importer<sync extends 'sync' | 'async' = 'sync' | 'async'> {
272
292
 
273
293
  /** @hidden */
274
294
  findFileUrl?: never;
295
+
296
+ /**
297
+ * A URL scheme or set of schemes (without the `:`) that this importer
298
+ * promises never to use for URLs returned by {@link canonicalize}. If it does
299
+ * return a URL with one of these schemes, that's an error.
300
+ *
301
+ * If this is set, any call to canonicalize for a URL with a non-canonical
302
+ * scheme will be passed {@link CanonicalizeContext.containingUrl} if it's
303
+ * known.
304
+ *
305
+ * These schemes may only contain lowercase ASCII letters, ASCII numerals,
306
+ * `+`, `-`, and `.`. They may not be empty.
307
+ */
308
+ nonCanonicalScheme?: string | string[];
275
309
  }
276
310
 
277
311
  /**
package/types/index.d.ts CHANGED
@@ -10,7 +10,12 @@ export {
10
10
  compileStringAsync,
11
11
  } from './compile';
12
12
  export {Exception} from './exception';
13
- export {FileImporter, Importer, ImporterResult} from './importer';
13
+ export {
14
+ CanonicalizeContext,
15
+ FileImporter,
16
+ Importer,
17
+ ImporterResult,
18
+ } from './importer';
14
19
  export {Logger, SourceSpan, SourceLocation} from './logger';
15
20
  export {
16
21
  CustomFunction,
@@ -35,6 +40,7 @@ export {
35
40
  SassFunction,
36
41
  SassList,
37
42
  SassMap,
43
+ SassMixin,
38
44
  SassNumber,
39
45
  SassString,
40
46
  Value,
@@ -6,6 +6,7 @@ import {SassColor} from './color';
6
6
  import {SassFunction} from './function';
7
7
  import {ListSeparator} from './list';
8
8
  import {SassMap} from './map';
9
+ import {SassMixin} from './mixin';
9
10
  import {SassNumber} from './number';
10
11
  import {SassString} from './string';
11
12
 
@@ -22,6 +23,7 @@ export {SassColor} from './color';
22
23
  export {SassFunction} from './function';
23
24
  export {SassList, ListSeparator} from './list';
24
25
  export {SassMap} from './map';
26
+ export {SassMixin} from './mixin';
25
27
  export {SassNumber} from './number';
26
28
  export {SassString} from './string';
27
29
 
@@ -156,6 +158,14 @@ export abstract class Value implements ValueObject {
156
158
  */
157
159
  assertMap(name?: string): SassMap;
158
160
 
161
+ /**
162
+ * Throws if `this` isn't a {@link SassMixin}.
163
+ *
164
+ * @param name - The name of the function argument `this` came from (without
165
+ * the `$`) if it came from an argument. Used for error reporting.
166
+ */
167
+ assertMixin(name?: string): SassMixin;
168
+
159
169
  /**
160
170
  * Throws if `this` isn't a {@link SassNumber}.
161
171
  *
@@ -0,0 +1,14 @@
1
+ import {Value} from './index';
2
+
3
+ /**
4
+ * Sass's [mixin type](https://sass-lang.com/documentation/values/mixins).
5
+ *
6
+ * @category Custom Function
7
+ */
8
+ export class SassMixin extends Value {
9
+ /**
10
+ * It is not possible to construct a Sass mixin outside of Sass. Attempting to
11
+ * construct one will throw an exception.
12
+ */
13
+ constructor();
14
+ }