sass 1.63.5 → 1.64.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
@@ -13,6 +13,9 @@ export const compileStringAsync = _cliPkgExports.compileStringAsync;
13
13
  export const Logger = _cliPkgExports.Logger;
14
14
  export const SassArgumentList = _cliPkgExports.SassArgumentList;
15
15
  export const SassBoolean = _cliPkgExports.SassBoolean;
16
+ export const SassCalculation = _cliPkgExports.SassCalculation;
17
+ export const CalculationOperation = _cliPkgExports.CalculationOperation;
18
+ export const CalculationInterpolation = _cliPkgExports.CalculationInterpolation;
16
19
  export const SassColor = _cliPkgExports.SassColor;
17
20
  export const SassFunction = _cliPkgExports.SassFunction;
18
21
  export const SassList = _cliPkgExports.SassList;
package/sass.node.mjs CHANGED
@@ -7,6 +7,9 @@ export const compileStringAsync = cjs.compileStringAsync;
7
7
  export const Logger = cjs.Logger;
8
8
  export const SassArgumentList = cjs.SassArgumentList;
9
9
  export const SassBoolean = cjs.SassBoolean;
10
+ export const SassCalculation = cjs.SassCalculation;
11
+ export const CalculationOperation = cjs.CalculationOperation;
12
+ export const CalculationInterpolation = cjs.CalculationInterpolation;
10
13
  export const SassColor = cjs.SassColor;
11
14
  export const SassFunction = cjs.SassFunction;
12
15
  export const SassList = cjs.SassList;
@@ -41,114 +44,126 @@ function defaultExportDeprecation() {
41
44
  export default {
42
45
  get compile() {
43
46
  defaultExportDeprecation();
44
- return _cliPkgExports.compile;
47
+ return cjs.compile;
45
48
  },
46
49
  get compileAsync() {
47
50
  defaultExportDeprecation();
48
- return _cliPkgExports.compileAsync;
51
+ return cjs.compileAsync;
49
52
  },
50
53
  get compileString() {
51
54
  defaultExportDeprecation();
52
- return _cliPkgExports.compileString;
55
+ return cjs.compileString;
53
56
  },
54
57
  get compileStringAsync() {
55
58
  defaultExportDeprecation();
56
- return _cliPkgExports.compileStringAsync;
59
+ return cjs.compileStringAsync;
57
60
  },
58
61
  get Logger() {
59
62
  defaultExportDeprecation();
60
- return _cliPkgExports.Logger;
63
+ return cjs.Logger;
61
64
  },
62
65
  get SassArgumentList() {
63
66
  defaultExportDeprecation();
64
- return _cliPkgExports.SassArgumentList;
67
+ return cjs.SassArgumentList;
65
68
  },
66
69
  get SassBoolean() {
67
70
  defaultExportDeprecation();
68
- return _cliPkgExports.SassBoolean;
71
+ return cjs.SassBoolean;
72
+ },
73
+ get SassCalculation() {
74
+ defaultExportDeprecation();
75
+ return cjs.SassCalculation;
76
+ },
77
+ get CalculationOperation() {
78
+ defaultExportDeprecation();
79
+ return cjs.CalculationOperation;
80
+ },
81
+ get CalculationInterpolation() {
82
+ defaultExportDeprecation();
83
+ return cjs.CalculationInterpolation;
69
84
  },
70
85
  get SassColor() {
71
86
  defaultExportDeprecation();
72
- return _cliPkgExports.SassColor;
87
+ return cjs.SassColor;
73
88
  },
74
89
  get SassFunction() {
75
90
  defaultExportDeprecation();
76
- return _cliPkgExports.SassFunction;
91
+ return cjs.SassFunction;
77
92
  },
78
93
  get SassList() {
79
94
  defaultExportDeprecation();
80
- return _cliPkgExports.SassList;
95
+ return cjs.SassList;
81
96
  },
82
97
  get SassMap() {
83
98
  defaultExportDeprecation();
84
- return _cliPkgExports.SassMap;
99
+ return cjs.SassMap;
85
100
  },
86
101
  get SassNumber() {
87
102
  defaultExportDeprecation();
88
- return _cliPkgExports.SassNumber;
103
+ return cjs.SassNumber;
89
104
  },
90
105
  get SassString() {
91
106
  defaultExportDeprecation();
92
- return _cliPkgExports.SassString;
107
+ return cjs.SassString;
93
108
  },
94
109
  get Value() {
95
110
  defaultExportDeprecation();
96
- return _cliPkgExports.Value;
111
+ return cjs.Value;
97
112
  },
98
113
  get CustomFunction() {
99
114
  defaultExportDeprecation();
100
- return _cliPkgExports.CustomFunction;
115
+ return cjs.CustomFunction;
101
116
  },
102
117
  get ListSeparator() {
103
118
  defaultExportDeprecation();
104
- return _cliPkgExports.ListSeparator;
119
+ return cjs.ListSeparator;
105
120
  },
106
121
  get sassFalse() {
107
122
  defaultExportDeprecation();
108
- return _cliPkgExports.sassFalse;
123
+ return cjs.sassFalse;
109
124
  },
110
125
  get sassNull() {
111
126
  defaultExportDeprecation();
112
- return _cliPkgExports.sassNull;
127
+ return cjs.sassNull;
113
128
  },
114
129
  get sassTrue() {
115
130
  defaultExportDeprecation();
116
- return _cliPkgExports.sassTrue;
131
+ return cjs.sassTrue;
117
132
  },
118
133
  get Exception() {
119
134
  defaultExportDeprecation();
120
- return _cliPkgExports.Exception;
135
+ return cjs.Exception;
121
136
  },
122
137
  get PromiseOr() {
123
138
  defaultExportDeprecation();
124
- return _cliPkgExports.PromiseOr;
139
+ return cjs.PromiseOr;
125
140
  },
126
141
  get info() {
127
142
  defaultExportDeprecation();
128
- return _cliPkgExports.info;
143
+ return cjs.info;
129
144
  },
130
145
  get render() {
131
146
  defaultExportDeprecation();
132
- return _cliPkgExports.render;
147
+ return cjs.render;
133
148
  },
134
149
  get renderSync() {
135
150
  defaultExportDeprecation();
136
- return _cliPkgExports.renderSync;
151
+ return cjs.renderSync;
137
152
  },
138
153
  get TRUE() {
139
154
  defaultExportDeprecation();
140
- return _cliPkgExports.TRUE;
155
+ return cjs.TRUE;
141
156
  },
142
157
  get FALSE() {
143
158
  defaultExportDeprecation();
144
- return _cliPkgExports.FALSE;
159
+ return cjs.FALSE;
145
160
  },
146
161
  get NULL() {
147
162
  defaultExportDeprecation();
148
- return _cliPkgExports.NULL;
163
+ return cjs.NULL;
149
164
  },
150
165
  get types() {
151
166
  defaultExportDeprecation();
152
- return _cliPkgExports.types;
167
+ return cjs.types;
153
168
  },
154
169
  };
package/types/index.d.ts CHANGED
@@ -23,9 +23,14 @@ export {
23
23
  } from './options';
24
24
  export {PromiseOr} from './util/promise_or';
25
25
  export {
26
+ CalculationInterpolation,
27
+ CalculationOperation,
28
+ CalculationOperator,
29
+ CalculationValue,
26
30
  ListSeparator,
27
31
  SassArgumentList,
28
32
  SassBoolean,
33
+ SassCalculation,
29
34
  SassColor,
30
35
  SassFunction,
31
36
  SassList,
@@ -390,9 +390,8 @@ export interface LegacySharedOptions<sync extends 'sync' | 'async'> {
390
390
  * whose values are {@link LegacyFunction}s. Each function should take the
391
391
  * same arguments as its signature.
392
392
  *
393
- * Functions are passed JavaScript representations of [Sass value
394
- * types](https://sass-lang.com/documentation/js-api#value-types), and must
395
- * return the same.
393
+ * Functions are passed subclasses of {@link LegacyValue}, and must return the
394
+ * same.
396
395
  *
397
396
  * **Heads up!** When writing custom functions, it’s important to ensure that
398
397
  * all the arguments are the types you expect. Otherwise, users’ stylesheets
@@ -129,9 +129,9 @@ export interface Options<sync extends 'sync' | 'async'> {
129
129
  * rule`](https://sass-lang.com/documentation/at-rules/function) and whose
130
130
  * values are {@link CustomFunction}s.
131
131
  *
132
- * Functions are passed JavaScript representations of [Sass value
133
- * types](https://sass-lang.com/documentation/js-api#value-types), and must
134
- * return the same.
132
+ * Functions are passed subclasses of {@link Value}, and must return the same.
133
+ * If the return value includes {@link SassCalculation}s they will be
134
+ * simplified before being returned.
135
135
  *
136
136
  * When writing custom functions, it's important to make them as user-friendly
137
137
  * and as close to the standards set by Sass's core functions as possible. Some
@@ -0,0 +1,137 @@
1
+ import {List, ValueObject} from 'immutable';
2
+ import {Value, SassNumber, SassString} from './index';
3
+
4
+ /**
5
+ * The type of values that can be arguments to a {@link SassCalculation}.
6
+ * @category Custom Function
7
+ * */
8
+ export type CalculationValue =
9
+ | SassNumber
10
+ | SassCalculation
11
+ | SassString
12
+ | CalculationOperation
13
+ | CalculationInterpolation;
14
+
15
+ /**
16
+ * Sass's [calculation
17
+ * type](https://sass-lang.com/documentation/values/calculations).
18
+ *
19
+ * Note: in the JS API calculations are not simplified eagerly. This also means
20
+ * that unsimplified calculations are not equal to the numbers they would be
21
+ * simplified to.
22
+ *
23
+ * @category Custom Function
24
+ */
25
+ export class SassCalculation extends Value {
26
+ /**
27
+ * Creates a value that represents `calc(argument)`.
28
+ *
29
+ * @throws `Error` if `argument` is a quoted {@link SassString}
30
+ * @returns A calculation with the name `calc` and `argument` as its single
31
+ * argument.
32
+ */
33
+ static calc(argument: CalculationValue): SassCalculation;
34
+
35
+ /**
36
+ * Creates a value that represents `min(arguments...)`.
37
+ *
38
+ * @throws `Error` if `arguments` contains a quoted {@link SassString}
39
+ * @returns A calculation with the name `min` and `arguments` as its
40
+ * arguments.
41
+ */
42
+ static min(
43
+ arguments: CalculationValue[] | List<CalculationValue>
44
+ ): SassCalculation;
45
+
46
+ /**
47
+ * Creates a value that represents `max(arguments...)`.
48
+ *
49
+ * @throws `Error` if `arguments` contains a quoted {@link SassString}
50
+ * @returns A calculation with the name `max` and `arguments` as its
51
+ * arguments.
52
+ */
53
+ static max(
54
+ arguments: CalculationValue[] | List<CalculationValue>
55
+ ): SassCalculation;
56
+
57
+ /**
58
+ * Creates a value that represents `clamp(value, min, max)`.
59
+ *
60
+ * @throws `Error` if any of `value`, `min`, or `max` are a quoted
61
+ * {@link SassString}.
62
+ * @throws `Error` if `value` is undefined and `max` is not undefined.
63
+ * @throws `Error` if either `value` or `max` is undefined and neither `min`
64
+ nor `value` is a {@link SassString} or {@link CalculationInterpolation}.
65
+ @returns A calculation with the name `clamp` and `min`, `value`, and `max`
66
+ as it's arguments, excluding any arguments that are undefined.
67
+ */
68
+ static clamp(
69
+ min: CalculationValue,
70
+ value?: CalculationValue,
71
+ max?: CalculationValue
72
+ ): SassCalculation;
73
+
74
+ /** Returns the calculation's `name` field. */
75
+ get name(): string;
76
+
77
+ /** Returns a list of the calculation's `arguments` */
78
+ get arguments(): List<CalculationValue>;
79
+ }
80
+
81
+ /**
82
+ * The set of possible operators in a Sass calculation.
83
+ * @category Custom Function
84
+ */
85
+ export type CalculationOperator = '+' | '-' | '*' | '/';
86
+
87
+ /**
88
+ * A binary operation that can appear in a {@link SassCalculation}.
89
+ * @category Custom Function
90
+ */
91
+ export class CalculationOperation implements ValueObject {
92
+ /**
93
+ * Creates a Sass CalculationOperation with the given `operator`, `left`, and
94
+ * `right` values.
95
+ * @throws `Error` if `left` or `right` are quoted {@link SassString}s.
96
+ */
97
+ constructor(
98
+ operator: CalculationOperator,
99
+ left: CalculationValue,
100
+ right: CalculationValue
101
+ );
102
+
103
+ /** Returns the operation's `operator` field. */
104
+ get operator(): CalculationOperator;
105
+
106
+ /** Returns the operation's `left` field. */
107
+ get left(): CalculationValue;
108
+
109
+ /** Returns the operation's `right` field. */
110
+ get right(): CalculationValue;
111
+
112
+ equals(other: unknown): boolean;
113
+
114
+ hashCode(): number;
115
+ }
116
+
117
+ /**
118
+ * A string injected into a {@link SassCalculation} using interpolation. Unlike
119
+ * unquoted strings, interpolations are always surrounded in parentheses when
120
+ * they appear in {@link CalculationOperation}s.
121
+ * @category Custom Function
122
+ */
123
+ export class CalculationInterpolation implements ValueObject {
124
+ /**
125
+ * Creates a Sass CalculationInterpolation with the given `value`.
126
+ */
127
+ constructor(value: string);
128
+
129
+ /**
130
+ * Returns the interpolation's `value` field.
131
+ */
132
+ get value(): string;
133
+
134
+ equals(other: unknown): boolean;
135
+
136
+ hashCode(): number;
137
+ }
@@ -1,6 +1,7 @@
1
1
  import {List, ValueObject} from 'immutable';
2
2
 
3
3
  import {SassBoolean} from './boolean';
4
+ import {SassCalculation} from './calculation';
4
5
  import {SassColor} from './color';
5
6
  import {SassFunction} from './function';
6
7
  import {ListSeparator} from './list';
@@ -10,6 +11,13 @@ import {SassString} from './string';
10
11
 
11
12
  export {SassArgumentList} from './argument_list';
12
13
  export {SassBoolean, sassTrue, sassFalse} from './boolean';
14
+ export {
15
+ SassCalculation,
16
+ CalculationValue,
17
+ CalculationOperator,
18
+ CalculationOperation,
19
+ CalculationInterpolation,
20
+ } from './calculation';
13
21
  export {SassColor} from './color';
14
22
  export {SassFunction} from './function';
15
23
  export {SassList, ListSeparator} from './list';
@@ -116,6 +124,14 @@ export abstract class Value implements ValueObject {
116
124
  */
117
125
  assertBoolean(name?: string): SassBoolean;
118
126
 
127
+ /**
128
+ * Throws if `this` isn't a {@link SassCalculation}.
129
+ *
130
+ * @param name - The name of the function argument `this` came from (without
131
+ * the `$`) if it came from an argument. Used for error reporting.
132
+ */
133
+ assertCalculation(name?: string): SassCalculation;
134
+
119
135
  /**
120
136
  * Throws if `this` isn't a {@link SassColor}.
121
137
  *