sass 1.72.0 → 1.75.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
@@ -43,3 +43,5 @@ export const FALSE = _cliPkgExports.FALSE;
43
43
  export const NULL = _cliPkgExports.NULL;
44
44
  export const types = _cliPkgExports.types;
45
45
  export const NodePackageImporter = _cliPkgExports.NodePackageImporter;
46
+ export const deprecations = _cliPkgExports.deprecations;
47
+ export const Version = _cliPkgExports.Version;
package/sass.node.mjs CHANGED
@@ -37,6 +37,8 @@ export const FALSE = cjs.FALSE;
37
37
  export const NULL = cjs.NULL;
38
38
  export const types = cjs.types;
39
39
  export const NodePackageImporter = cjs.NodePackageImporter;
40
+ export const deprecations = cjs.deprecations;
41
+ export const Version = cjs.Version;
40
42
 
41
43
  let printedDefaultExportDeprecation = false;
42
44
  function defaultExportDeprecation() {
@@ -196,4 +198,12 @@ export default {
196
198
  defaultExportDeprecation();
197
199
  return cjs.NodePackageImporter;
198
200
  },
201
+ get deprecations() {
202
+ defaultExportDeprecation();
203
+ return cjs.deprecations;
204
+ },
205
+ get Version() {
206
+ defaultExportDeprecation();
207
+ return cjs.Version;
208
+ },
199
209
  };
@@ -0,0 +1,209 @@
1
+ /**
2
+ * All of the deprecation types currently used by Sass.
3
+ *
4
+ * Any of these IDs or the deprecation objects they point to can be passed to
5
+ * `fatalDeprecations`, `futureDeprecations`, or `silenceDeprecations`.
6
+ */
7
+ export interface Deprecations {
8
+ /**
9
+ * Deprecation for passing a string to `call` instead of using `get-function`.
10
+ *
11
+ * This deprecation has been active in all versions of Dart Sass.
12
+ */
13
+ 'call-string': Deprecation<'call-string'>;
14
+
15
+ /**
16
+ * Deprecation for `@elseif`.
17
+ *
18
+ * This deprecation became active in Dart Sass 1.3.2.
19
+ */
20
+ elseif: Deprecation<'elseif'>;
21
+
22
+ /**
23
+ * Deprecation for parsing `@-moz-document`.
24
+ *
25
+ * This deprecation became active in Dart Sass 1.7.2.
26
+ */
27
+ 'moz-document': Deprecation<'moz-document'>;
28
+
29
+ /**
30
+ * Deprecation for imports using relative canonical URLs.
31
+ *
32
+ * This deprecation became active in Dart Sass 1.17.2.
33
+ */
34
+ 'relative-canonical': Deprecation<'relative-canonical'>;
35
+
36
+ /**
37
+ * Deprecation for declaring new variables with `!global`.
38
+ *
39
+ * This deprecation became active in Dart Sass 1.17.2.
40
+ */
41
+ 'new-global': Deprecation<'new-global'>;
42
+
43
+ /**
44
+ * Deprecation for using color module functions in place of plain CSS
45
+ * functions.
46
+ *
47
+ * This deprecation became active in Dart Sass 1.23.0.
48
+ */
49
+ 'color-module-compat': Deprecation<'color-module-compat'>;
50
+
51
+ /**
52
+ * Deprecation for treating `/` as division.
53
+ *
54
+ * This deprecation became active in Dart Sass 1.33.0.
55
+ */
56
+ 'slash-div': Deprecation<'slash-div'>;
57
+
58
+ /**
59
+ * Deprecation for leading, trailing, and repeated combinators.
60
+ *
61
+ * This deprecation became active in Dart Sass 1.54.0.
62
+ */
63
+ 'bogus-combinators': Deprecation<'bogus-combinators'>;
64
+
65
+ /**
66
+ * Deprecation for ambiguous `+` and `-` operators.
67
+ *
68
+ * This deprecation became active in Dart Sass 1.55.0.
69
+ */
70
+ 'strict-unary': Deprecation<'strict-unary'>;
71
+
72
+ /**
73
+ * Deprecation for passing invalid units to certain built-in functions.
74
+ *
75
+ * This deprecation became active in Dart Sass 1.56.0.
76
+ */
77
+ 'function-units': Deprecation<'function-units'>;
78
+
79
+ /**
80
+ * Deprecation for using `!default` or `!global` multiple times for one
81
+ * variable.
82
+ *
83
+ * This deprecation became active in Dart Sass 1.62.0.
84
+ */
85
+ 'duplicate-var-flags': Deprecation<'duplicate-var-flags'>;
86
+
87
+ /**
88
+ * Deprecation for passing null as alpha in the JS API.
89
+ *
90
+ * This deprecation became active in Dart Sass 1.62.3.
91
+ */
92
+ 'null-alpha': Deprecation<'null-alpha'>;
93
+
94
+ /**
95
+ * Deprecation for passing percentages to the Sass `abs()` function.
96
+ *
97
+ * This deprecation became active in Dart Sass 1.65.0.
98
+ */
99
+ 'abs-percent': Deprecation<'abs-percent'>;
100
+
101
+ /**
102
+ * Deprecation for using the current working directory as an implicit load
103
+ * path.
104
+ *
105
+ * This deprecation became active in Dart Sass 1.73.0.
106
+ */
107
+ 'fs-importer-cwd': Deprecation<'fs-importer-cwd'>;
108
+
109
+ /**
110
+ * Deprecation for `@import` rules.
111
+ *
112
+ * This deprecation is not yet active, but will be soon.
113
+ */
114
+ import: Deprecation<'import'>;
115
+
116
+ /**
117
+ * Used for any user-emitted deprecation warnings.
118
+ */
119
+ 'user-authored': Deprecation<'user-authored', 'user'>;
120
+ }
121
+
122
+ /**
123
+ * Either a deprecation or its ID, either of which can be passed to any of
124
+ * the relevant compiler options.
125
+ *
126
+ * @category Messages
127
+ * @compatibility dart: "1.74.0", node: false
128
+ */
129
+ export type DeprecationOrId = Deprecation | keyof Deprecations;
130
+
131
+ /**
132
+ * The possible statuses that each deprecation can have.
133
+ *
134
+ * "active" deprecations are currently emitting deprecation warnings.
135
+ * "future" deprecations are not yet active, but will be in the future.
136
+ * "obsolete" deprecations were once active, but no longer are.
137
+ *
138
+ * The only "user" deprecation is "user-authored", which is used for deprecation
139
+ * warnings coming from user code.
140
+ *
141
+ * @category Messages
142
+ * @compatibility dart: "1.74.0", node: false
143
+ */
144
+ export type DeprecationStatus = 'active' | 'user' | 'future' | 'obsolete';
145
+
146
+ /**
147
+ * A deprecated feature in the language.
148
+ *
149
+ * @category Messages
150
+ * @compatibility dart: "1.74.0", node: false
151
+ */
152
+ export interface Deprecation<
153
+ id extends keyof Deprecations = keyof Deprecations,
154
+ status extends DeprecationStatus = DeprecationStatus
155
+ > {
156
+ /** The unique ID of this deprecation. */
157
+ id: id;
158
+
159
+ /** The current status of this deprecation. */
160
+ status: status;
161
+
162
+ /** A human-readable description of this deprecation. */
163
+ description?: string;
164
+
165
+ /** The version this deprecation first became active in. */
166
+ deprecatedIn: status extends 'future' | 'user' ? null : Version;
167
+
168
+ /** The version this deprecation became obsolete in. */
169
+ obsoleteIn: status extends 'obsolete' ? Version : null;
170
+ }
171
+
172
+ /**
173
+ * A semantic version of the compiler.
174
+ *
175
+ * @category Messages
176
+ * @compatibility dart: "1.74.0", node: false
177
+ */
178
+ export class Version {
179
+ /**
180
+ * Constructs a new version.
181
+ *
182
+ * All components must be non-negative integers.
183
+ *
184
+ * @param major - The major version.
185
+ * @param minor - The minor version.
186
+ * @param patch - The patch version.
187
+ */
188
+ constructor(major: number, minor: number, patch: number);
189
+ readonly major: number;
190
+ readonly minor: number;
191
+ readonly patch: number;
192
+
193
+ /**
194
+ * Parses a version from a string.
195
+ *
196
+ * This throws an error if a valid version can't be parsed.
197
+ *
198
+ * @param version - A string in the form "major.minor.patch".
199
+ */
200
+ static parse(version: string): Version;
201
+ }
202
+
203
+ /**
204
+ * An object containing all deprecation types.
205
+ *
206
+ * @category Messages
207
+ * @compatibility dart: "1.74.0", node: false
208
+ */
209
+ export const deprecations: Deprecations;
@@ -42,7 +42,7 @@ export interface CanonicalizeContext {
42
42
  * Like all importers, this implements custom Sass loading logic for [`@use`
43
43
  * rules](https://sass-lang.com/documentation/at-rules/use) and [`@import`
44
44
  * rules](https://sass-lang.com/documentation/at-rules/import). It can be passed
45
- * to {@link Options.importers} or {@link StringOptionsWithImporter.importer}.
45
+ * to {@link Options.importers} or {@link StringOptions.importer}.
46
46
  *
47
47
  * @typeParam sync - A `FileImporter<'sync'>`'s {@link findFileUrl} must return
48
48
  * synchronously, but in return it can be passed to {@link compile} and {@link
@@ -122,7 +122,7 @@ export interface FileImporter<
122
122
  * An object that implements custom Sass loading logic for [`@use`
123
123
  * rules](https://sass-lang.com/documentation/at-rules/use) and [`@import`
124
124
  * rules](https://sass-lang.com/documentation/at-rules/import). It can be passed
125
- * to {@link Options.importers} or {@link StringOptionsWithImporter.importer}.
125
+ * to {@link Options.importers} or {@link StringOptions.importer}.
126
126
  *
127
127
  * Importers that simply redirect to files on disk are encouraged to use the
128
128
  * {@link FileImporter} interface instead.
package/types/index.d.ts CHANGED
@@ -13,6 +13,14 @@ export {
13
13
  initCompiler,
14
14
  initAsyncCompiler,
15
15
  } from './compile';
16
+ export {
17
+ deprecations,
18
+ Deprecation,
19
+ Deprecations,
20
+ DeprecationOrId,
21
+ DeprecationStatus,
22
+ Version,
23
+ } from './deprecations';
16
24
  export {Exception} from './exception';
17
25
  export {
18
26
  CanonicalizeContext,
@@ -1,3 +1,4 @@
1
+ import {Deprecation} from '../deprecations';
1
2
  import {SourceSpan} from './source_span';
2
3
 
3
4
  export {SourceLocation} from './source_location';
@@ -43,17 +44,21 @@ export interface Logger {
43
44
  *
44
45
  * @param message - The warning message.
45
46
  * @param options.deprecation - Whether this is a deprecation warning.
47
+ * @param options.deprecationType - The type of deprecation this warning is
48
+ * for, if any.
46
49
  * @param options.span - The location in the Sass source code that generated this
47
50
  * warning.
48
51
  * @param options.stack - The Sass stack trace at the point the warning was issued.
49
52
  */
50
53
  warn?(
51
54
  message: string,
52
- options: {
53
- deprecation: boolean;
54
- span?: SourceSpan;
55
- stack?: string;
56
- }
55
+ options: (
56
+ | {
57
+ deprecation: true;
58
+ deprecationType: Deprecation;
59
+ }
60
+ | {deprecation: false}
61
+ ) & {span?: SourceSpan; stack?: string}
57
62
  ): void;
58
63
 
59
64
  /**
@@ -1,3 +1,4 @@
1
+ import {DeprecationOrId, Version} from './deprecations';
1
2
  import {FileImporter, Importer, NodePackageImporter} from './importer';
2
3
  import {Logger} from './logger';
3
4
  import {Value} from './value';
@@ -122,6 +123,20 @@ export interface Options<sync extends 'sync' | 'async'> {
122
123
  */
123
124
  charset?: boolean;
124
125
 
126
+ /**
127
+ * A set of deprecations to treat as fatal.
128
+ *
129
+ * If a deprecation warning of any provided type is encountered during
130
+ * compilation, the compiler will error instead.
131
+ *
132
+ * If a `Version` is provided, then all deprecations that were active in that
133
+ * compiler version will be treated as fatal.
134
+ *
135
+ * @category Messages
136
+ * @compatiblity dart: "1.74.0", node: false
137
+ */
138
+ fatalDeprecations?: (DeprecationOrId | Version)[];
139
+
125
140
  /**
126
141
  * Additional built-in Sass functions that are available in all stylesheets.
127
142
  * This option takes an object whose keys are Sass function signatures like
@@ -198,6 +213,17 @@ export interface Options<sync extends 'sync' | 'async'> {
198
213
  */
199
214
  functions?: Record<string, CustomFunction<sync>>;
200
215
 
216
+ /**
217
+ * A set of future deprecations to opt into early.
218
+ *
219
+ * Future deprecations passed here will be treated as active by the compiler,
220
+ * emitting warnings as necessary.
221
+ *
222
+ * @category Messages
223
+ * @compatiblity dart: "1.74.0", node: false
224
+ */
225
+ futureDeprecations?: DeprecationOrId[];
226
+
201
227
  /**
202
228
  * Custom importers that control how Sass resolves loads from rules like
203
229
  * [`@use`](https://sass-lang.com/documentation/at-rules/use) and
@@ -266,16 +292,30 @@ export interface Options<sync extends 'sync' | 'async'> {
266
292
  * so that they can get fixed as soon as possible!
267
293
  *
268
294
  * **Heads up!** If {@link compileString} or {@link compileStringAsync} is
269
- * called without {@link StringOptionsWithoutImporter.url}, <em>all</em>
270
- * stylesheets it loads will be considered dependencies. Since it doesn’t have
271
- * a path of its own, everything it loads is coming from a load path rather
272
- * than a relative import.
295
+ * called without {@link StringOptions.url}, <em>all</em> stylesheets it loads
296
+ * will be considered dependencies. Since it doesn’t have a path of its own,
297
+ * everything it loads is coming from a load path rather than a relative
298
+ * import.
273
299
  *
274
300
  * @defaultValue `false`
275
301
  * @category Messages
276
302
  */
277
303
  quietDeps?: boolean;
278
304
 
305
+ /**
306
+ * A set of active deprecations to ignore.
307
+ *
308
+ * If a deprecation warning of any provided type is encountered during
309
+ * compilation, the compiler will ignore it instead.
310
+ *
311
+ * **Heads up!** The deprecated functionality you're depending on will
312
+ * eventually break.
313
+ *
314
+ * @category Messages
315
+ * @compatiblity dart: "1.74.0", node: false
316
+ */
317
+ silenceDeprecations?: DeprecationOrId[];
318
+
279
319
  /**
280
320
  * Whether or not Sass should generate a source map. If it does, the source
281
321
  * map will be available as {@link CompileResult.sourceMap}.
@@ -348,9 +388,10 @@ export interface Options<sync extends 'sync' | 'async'> {
348
388
  * Options that can be passed to {@link compileString} or {@link
349
389
  * compileStringAsync}.
350
390
  *
351
- * If the {@link StringOptionsWithImporter.importer} field isn't passed, the
352
- * entrypoint file can load files relative to itself if a `file://` URL is
353
- * passed to the {@link url} field.
391
+ * If the {@link StringOptions.importer} field isn't passed, the entrypoint file
392
+ * can load files relative to itself if a `file://` URL is passed to the {@link
393
+ * url} field. If it is passed, the entrypoint file uses it to load files
394
+ * relative to itself.
354
395
  *
355
396
  * @typeParam sync - This lets the TypeScript checker verify that asynchronous
356
397
  * {@link Importer}s, {@link FileImporter}s, and {@link CustomFunction}s aren't
@@ -358,7 +399,7 @@ export interface Options<sync extends 'sync' | 'async'> {
358
399
  *
359
400
  * @category Options
360
401
  */
361
- export interface StringOptionsWithoutImporter<sync extends 'sync' | 'async'>
402
+ export interface StringOptions<sync extends 'sync' | 'async'>
362
403
  extends Options<sync> {
363
404
  /**
364
405
  * The {@link Syntax} to use to parse the entrypoint stylesheet.
@@ -369,6 +410,19 @@ export interface StringOptionsWithoutImporter<sync extends 'sync' | 'async'>
369
410
  */
370
411
  syntax?: Syntax;
371
412
 
413
+ /**
414
+ * The importer to use to handle loads that are relative to the entrypoint
415
+ * stylesheet.
416
+ *
417
+ * A relative load's URL is first resolved relative to {@link url}, then
418
+ * passed to {@link importer}. (It's passed as-is if {@link url} isn't
419
+ * passed.) If the importer doesn't recognize it, it's then passed to {@link
420
+ * importers} and {@link loadPaths}.
421
+ *
422
+ * @category Input
423
+ */
424
+ importer?: Importer<sync> | FileImporter<sync>;
425
+
372
426
  /**
373
427
  * The canonical URL of the entrypoint stylesheet.
374
428
  *
@@ -378,62 +432,24 @@ export interface StringOptionsWithoutImporter<sync extends 'sync' | 'async'>
378
432
  * loadPaths}.
379
433
  *
380
434
  * @category Input
435
+ * @compatibility feature: "Undefined URL with importer", dart: "1.75.0", node: false
436
+ *
437
+ * Earlier versions of Dart Sass required {@link url} to be defined when
438
+ * passing {@link StringOptions.importer}.
381
439
  */
382
440
  url?: URL;
383
441
  }
384
442
 
385
443
  /**
386
- * Options that can be passed to {@link compileString} or {@link
387
- * compileStringAsync}.
388
- *
389
- * If the {@link StringOptionsWithImporter.importer} field is passed, the
390
- * entrypoint file uses it to load files relative to itself and the {@link url}
391
- * field is mandatory.
392
- *
393
- * @typeParam sync - This lets the TypeScript checker verify that asynchronous
394
- * {@link Importer}s, {@link FileImporter}s, and {@link CustomFunction}s aren't
395
- * passed to {@link compile} or {@link compileString}.
396
- *
397
444
  * @category Options
445
+ * @deprecated Use {@link StringOptions} instead.
398
446
  */
399
- export interface StringOptionsWithImporter<sync extends 'sync' | 'async'>
400
- extends StringOptionsWithoutImporter<sync> {
401
- /**
402
- * The importer to use to handle loads that are relative to the entrypoint
403
- * stylesheet.
404
- *
405
- * A relative load's URL is first resolved relative to {@link url}, then
406
- * passed to {@link importer}. If the importer doesn't recognize it, it's then
407
- * passed to {@link importers} and {@link loadPaths}.
408
- *
409
- * @category Input
410
- */
411
- importer: Importer<sync> | FileImporter<sync>;
412
-
413
- /**
414
- * The canonical URL of the entrypoint stylesheet. If this is passed along
415
- * with {@link importer}, it's used to resolve relative loads in the
416
- * entrypoint stylesheet.
417
- *
418
- * @category Input
419
- */
420
- url: URL;
421
- }
447
+ type StringOptionsWithoutImporter<sync extends 'sync' | 'async'> =
448
+ StringOptions<sync>;
422
449
 
423
450
  /**
424
- * Options that can be passed to {@link compileString} or {@link
425
- * compileStringAsync}.
426
- *
427
- * This is a {@link StringOptionsWithImporter} if it has a {@link
428
- * StringOptionsWithImporter.importer} field, and a {@link
429
- * StringOptionsWithoutImporter} otherwise.
430
- *
431
- * @typeParam sync - This lets the TypeScript checker verify that asynchronous
432
- * {@link Importer}s, {@link FileImporter}s, and {@link CustomFunction}s aren't
433
- * passed to {@link compile} or {@link compileString}.
434
- *
435
451
  * @category Options
452
+ * @deprecated Use {@link StringOptions} instead.
436
453
  */
437
- export type StringOptions<sync extends 'sync' | 'async'> =
438
- | StringOptionsWithImporter<sync>
439
- | StringOptionsWithoutImporter<sync>;
454
+ type StringOptionsWithImporter<sync extends 'sync' | 'async'> =
455
+ StringOptions<sync>;