sass-embedded 1.0.0-beta.4 → 1.0.0-rc.1
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/CHANGELOG.md +40 -0
- package/dist/.gitignore +1 -0
- package/dist/lib/index.js +40 -11
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/src/{embedded-compiler/compiler.js → async-compiler.js} +13 -13
- package/dist/lib/src/async-compiler.js.map +1 -0
- package/dist/lib/src/compile.js +187 -85
- package/dist/lib/src/compile.js.map +1 -1
- package/dist/lib/src/compiler-path.js +18 -0
- package/dist/lib/src/compiler-path.js.map +1 -0
- package/dist/lib/src/deprotofy-span.js +51 -0
- package/dist/lib/src/deprotofy-span.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/dispatcher.js → dispatcher.js} +47 -41
- package/dist/lib/src/dispatcher.js.map +1 -0
- package/dist/lib/src/exception.js +20 -0
- package/dist/lib/src/exception.js.map +1 -0
- package/dist/lib/src/function-registry.js +92 -0
- package/dist/lib/src/function-registry.js.map +1 -0
- package/dist/lib/src/importer-registry.js +127 -0
- package/dist/lib/src/importer-registry.js.map +1 -0
- package/dist/lib/src/legacy/importer.js +186 -0
- package/dist/lib/src/legacy/importer.js.map +1 -0
- package/dist/lib/src/legacy/index.js +261 -0
- package/dist/lib/src/legacy/index.js.map +1 -0
- package/dist/lib/src/legacy/resolve-path.js +101 -0
- package/dist/lib/src/legacy/resolve-path.js.map +1 -0
- package/dist/lib/src/legacy/value/base.js +17 -0
- package/dist/lib/src/legacy/value/base.js.map +1 -0
- package/dist/lib/src/legacy/value/color.js +64 -0
- package/dist/lib/src/legacy/value/color.js.map +1 -0
- package/dist/lib/src/legacy/value/index.js +23 -0
- package/dist/lib/src/legacy/value/index.js.map +1 -0
- package/dist/lib/src/legacy/value/list.js +50 -0
- package/dist/lib/src/legacy/value/list.js.map +1 -0
- package/dist/lib/src/legacy/value/map.js +74 -0
- package/dist/lib/src/legacy/value/map.js.map +1 -0
- package/dist/lib/src/legacy/value/number.js +60 -0
- package/dist/lib/src/legacy/value/number.js.map +1 -0
- package/dist/lib/src/legacy/value/string.js +27 -0
- package/dist/lib/src/legacy/value/string.js.map +1 -0
- package/dist/lib/src/legacy/value/wrap.js +83 -0
- package/dist/lib/src/legacy/value/wrap.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/message-transformer.js → message-transformer.js} +11 -10
- package/dist/lib/src/message-transformer.js.map +1 -0
- package/dist/lib/src/{embedded-compiler/packet-transformer.js → packet-transformer.js} +2 -1
- package/dist/lib/src/packet-transformer.js.map +1 -0
- package/dist/lib/src/protofier.js +272 -0
- package/dist/lib/src/protofier.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/request-tracker.js → request-tracker.js} +1 -0
- package/dist/lib/src/request-tracker.js.map +1 -0
- package/dist/lib/src/sync-compiler.js +52 -0
- package/dist/lib/src/sync-compiler.js.map +1 -0
- package/dist/lib/src/{exception/span.js → sync-process/event.js} +2 -2
- package/dist/lib/src/sync-process/event.js.map +1 -0
- package/dist/lib/src/sync-process/index.js +122 -0
- package/dist/lib/src/sync-process/index.js.map +1 -0
- package/dist/lib/src/sync-process/sync-message-port.js +128 -0
- package/dist/lib/src/sync-process/sync-message-port.js.map +1 -0
- package/dist/lib/src/sync-process/worker.js +51 -0
- package/dist/lib/src/sync-process/worker.js.map +1 -0
- package/dist/lib/src/utils.js +96 -1
- package/dist/lib/src/utils.js.map +1 -1
- package/dist/lib/src/value/argument-list.js +31 -0
- package/dist/lib/src/value/argument-list.js.map +1 -0
- package/dist/lib/src/value/boolean.js +22 -5
- package/dist/lib/src/value/boolean.js.map +1 -1
- package/dist/lib/src/value/color.js +258 -0
- package/dist/lib/src/value/color.js.map +1 -0
- package/dist/lib/src/value/function.js +34 -0
- package/dist/lib/src/value/function.js.map +1 -0
- package/dist/lib/src/value/{value.js → index.js} +28 -14
- package/dist/lib/src/value/index.js.map +1 -0
- package/dist/lib/src/value/list.js +99 -0
- package/dist/lib/src/value/list.js.map +1 -0
- package/dist/lib/src/value/map.js +91 -0
- package/dist/lib/src/value/map.js.map +1 -0
- package/dist/lib/src/value/null.js +16 -3
- package/dist/lib/src/value/null.js.map +1 -1
- package/dist/lib/src/value/number.js +41 -46
- package/dist/lib/src/value/number.js.map +1 -1
- package/dist/lib/src/value/string.js +18 -12
- package/dist/lib/src/value/string.js.map +1 -1
- package/dist/lib/src/value/utils.js +27 -2
- package/dist/lib/src/value/utils.js.map +1 -1
- package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js +1395 -101
- package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js.map +1 -1
- package/dist/package.json +23 -20
- package/dist/tool/utils.js +50 -18
- package/dist/tool/utils.js.map +1 -1
- package/dist/types/compile.d.ts +152 -0
- package/dist/types/exception.d.ts +41 -0
- package/dist/types/importer.d.ts +294 -0
- package/dist/types/index.d.ts +80 -0
- package/dist/types/legacy/exception.d.ts +54 -0
- package/dist/types/legacy/function.d.ts +756 -0
- package/dist/types/legacy/importer.d.ts +168 -0
- package/dist/types/legacy/options.d.ts +642 -0
- package/dist/types/legacy/plugin_this.d.ts +73 -0
- package/dist/types/legacy/render.d.ts +139 -0
- package/dist/types/logger/index.d.ts +94 -0
- package/dist/types/logger/source_location.d.ts +21 -0
- package/dist/types/logger/source_span.d.ts +34 -0
- package/dist/types/options.d.ts +418 -0
- package/dist/types/util/promise_or.d.ts +17 -0
- package/dist/types/value/argument_list.d.ts +47 -0
- package/dist/types/value/boolean.d.ts +29 -0
- package/dist/types/value/color.d.ts +107 -0
- package/dist/types/value/function.d.ts +22 -0
- package/dist/types/value/index.d.ts +173 -0
- package/dist/types/value/list.d.ts +54 -0
- package/dist/types/value/map.d.ts +41 -0
- package/dist/types/value/number.d.ts +305 -0
- package/dist/types/value/string.d.ts +84 -0
- package/package.json +23 -20
- package/dist/lib/index.d.ts +0 -7
- package/dist/lib/src/compile.d.ts +0 -20
- package/dist/lib/src/embedded-compiler/compiler.d.ts +0 -19
- package/dist/lib/src/embedded-compiler/compiler.js.map +0 -1
- package/dist/lib/src/embedded-compiler/packet-transformer.d.ts +0 -34
- package/dist/lib/src/embedded-compiler/packet-transformer.js.map +0 -1
- package/dist/lib/src/embedded-protocol/dispatcher.d.ts +0 -60
- package/dist/lib/src/embedded-protocol/dispatcher.js.map +0 -1
- package/dist/lib/src/embedded-protocol/message-transformer.d.ts +0 -47
- package/dist/lib/src/embedded-protocol/message-transformer.js.map +0 -1
- package/dist/lib/src/embedded-protocol/request-tracker.d.ts +0 -20
- package/dist/lib/src/embedded-protocol/request-tracker.js.map +0 -1
- package/dist/lib/src/embedded-protocol/utils.d.ts +0 -7
- package/dist/lib/src/embedded-protocol/utils.js +0 -52
- package/dist/lib/src/embedded-protocol/utils.js.map +0 -1
- package/dist/lib/src/exception/exception.d.ts +0 -19
- package/dist/lib/src/exception/exception.js +0 -36
- package/dist/lib/src/exception/exception.js.map +0 -1
- package/dist/lib/src/exception/location.d.ts +0 -11
- package/dist/lib/src/exception/location.js +0 -6
- package/dist/lib/src/exception/location.js.map +0 -1
- package/dist/lib/src/exception/span.d.ts +0 -29
- package/dist/lib/src/exception/span.js.map +0 -1
- package/dist/lib/src/node-sass/render.d.ts +0 -60
- package/dist/lib/src/node-sass/render.js +0 -126
- package/dist/lib/src/node-sass/render.js.map +0 -1
- package/dist/lib/src/utils.d.ts +0 -12
- package/dist/lib/src/value/boolean.d.ts +0 -25
- package/dist/lib/src/value/null.d.ts +0 -12
- package/dist/lib/src/value/number.d.ts +0 -189
- package/dist/lib/src/value/string.d.ts +0 -56
- package/dist/lib/src/value/utils.d.ts +0 -36
- package/dist/lib/src/value/value.d.ts +0 -103
- package/dist/lib/src/value/value.js.map +0 -1
- package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.d.ts +0 -1
- package/dist/tool/utils.d.ts +0 -32
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import {List} from 'immutable';
|
|
2
|
+
|
|
3
|
+
import {Value} from './index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sass's [number type](https://sass-lang.com/documentation/values/numbers).
|
|
7
|
+
*
|
|
8
|
+
* @category Custom Function
|
|
9
|
+
*/
|
|
10
|
+
export class SassNumber extends Value {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new number with more complex units than just a single numerator.
|
|
13
|
+
*
|
|
14
|
+
* Upon construction, any compatible numerator and denominator units are
|
|
15
|
+
* simplified away according to the conversion factor between them.
|
|
16
|
+
*
|
|
17
|
+
* @param value - The number's numeric value.
|
|
18
|
+
*
|
|
19
|
+
* @param unit - If this is a string, it's used as the single numerator unit
|
|
20
|
+
* for the number.
|
|
21
|
+
*
|
|
22
|
+
* @param unit.numeratorUnits - If passed, these are the numerator units to
|
|
23
|
+
* use for the number. This may be either a plain JavaScript array or an
|
|
24
|
+
* immutable [[List]] from the [`immutable`
|
|
25
|
+
* package](https://immutable-js.com/).
|
|
26
|
+
*
|
|
27
|
+
* @param unit.denominatorUnits - If passed, these are the denominator units
|
|
28
|
+
* to use for the number. This may be either a plain JavaScript array or an
|
|
29
|
+
* immutable [[List]] from the [`immutable`
|
|
30
|
+
* package](https://immutable-js.com/).
|
|
31
|
+
*/
|
|
32
|
+
constructor(
|
|
33
|
+
value: number,
|
|
34
|
+
unit?:
|
|
35
|
+
| string
|
|
36
|
+
| {
|
|
37
|
+
numeratorUnits?: string[] | List<string>;
|
|
38
|
+
denominatorUnits?: string[] | List<string>;
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
/** This number's numeric value. */
|
|
43
|
+
get value(): number;
|
|
44
|
+
|
|
45
|
+
/** Whether [[value]] is an integer according to Sass's equality logic. */
|
|
46
|
+
get isInt(): boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* If [[value]] is an integer according to [[isInt]], returns [[value]]
|
|
50
|
+
* rounded to that integer. If it's not an integer, returns `null`.
|
|
51
|
+
*/
|
|
52
|
+
get asInt(): number | null;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* This number's numerator units as an immutable [[List]] from the
|
|
56
|
+
* [`immutable` package](https://immutable-js.com/).
|
|
57
|
+
*/
|
|
58
|
+
get numeratorUnits(): List<string>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* This number's denominator units as an immutable [[List]] from the
|
|
62
|
+
* [`immutable` package](https://immutable-js.com/).
|
|
63
|
+
*/
|
|
64
|
+
get denominatorUnits(): List<string>;
|
|
65
|
+
|
|
66
|
+
/** Whether this number has any numerator or denominator units. */
|
|
67
|
+
get hasUnits(): boolean;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* If [[value]] is an integer according to [[isInt]], returns it rounded to
|
|
71
|
+
* that integer. Otherwise, throws an error.
|
|
72
|
+
*
|
|
73
|
+
* @param name - The name of the function argument `this` came from (without
|
|
74
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
75
|
+
*/
|
|
76
|
+
assertInt(name?: string): number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns [[value]] if it's within `min` and `max`. If [[value]] is equal to
|
|
80
|
+
* `min` or `max` according to Sass's equality, returns `min` or `max`
|
|
81
|
+
* respectively. Otherwise, throws an error.
|
|
82
|
+
*
|
|
83
|
+
* @param name - The name of the function argument `this` came from (without
|
|
84
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
85
|
+
*/
|
|
86
|
+
assertInRange(min: number, max: number, name?: string): number;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* If this number has no units, returns it. Otherwise, throws an error.
|
|
90
|
+
*
|
|
91
|
+
* @param name - The name of the function argument `this` came from (without
|
|
92
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
93
|
+
*/
|
|
94
|
+
assertNoUnits(name?: string): SassNumber;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* If this number has `unit` as its only unit (and as a numerator), returns
|
|
98
|
+
* this number. Otherwise, throws an error.
|
|
99
|
+
*
|
|
100
|
+
* @param name - The name of the function argument `this` came from (without
|
|
101
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
102
|
+
*/
|
|
103
|
+
assertUnit(unit: string, name?: string): SassNumber;
|
|
104
|
+
|
|
105
|
+
/** Whether this number has `unit` as its only unit (and as a numerator). */
|
|
106
|
+
hasUnit(unit: string): boolean;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Whether this has exactly one numerator unit, and that unit is compatible
|
|
110
|
+
* with `unit`.
|
|
111
|
+
*/
|
|
112
|
+
compatibleWithUnit(unit: string): boolean;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Returns a copy of this number, converted to the units represented by
|
|
116
|
+
* `newNumerators` and `newDenominators`.
|
|
117
|
+
*
|
|
118
|
+
* @throws `Error` if this number's units are incompatible with
|
|
119
|
+
* `newNumerators` and `newDenominators`; or if this number is unitless and
|
|
120
|
+
* either `newNumerators` or `newDenominators` are not empty, or vice-versa.
|
|
121
|
+
*
|
|
122
|
+
* @param newNumerators - The numerator units to convert this number to. This
|
|
123
|
+
* may be either a plain JavaScript array or an immutable [[List]] from the
|
|
124
|
+
* [`immutable` package](https://immutable-js.com/).
|
|
125
|
+
*
|
|
126
|
+
* @param newDenominators - The denominator units to convert this number to.
|
|
127
|
+
* This may be either a plain JavaScript array or an immutable [[List]] from
|
|
128
|
+
* the [`immutable` package](https://immutable-js.com/).
|
|
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
|
+
convert(
|
|
134
|
+
newNumerators: string[] | List<string>,
|
|
135
|
+
newDenominators: string[] | List<string>,
|
|
136
|
+
name?: string
|
|
137
|
+
): SassNumber;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Returns a copy of this number, converted to the same units as `other`.
|
|
141
|
+
*
|
|
142
|
+
* @throws `Error` if this number's units are incompatible with `other`'s
|
|
143
|
+
* units, or if either number is unitless but the other is not.
|
|
144
|
+
*
|
|
145
|
+
* @param name - The name of the function argument `this` came from (without
|
|
146
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
147
|
+
*
|
|
148
|
+
* @param otherName - The name of the function argument `other` came from
|
|
149
|
+
* (without the `$`) if it came from an argument. Used for error reporting.
|
|
150
|
+
*/
|
|
151
|
+
convertToMatch(
|
|
152
|
+
other: SassNumber,
|
|
153
|
+
name?: string,
|
|
154
|
+
otherName?: string
|
|
155
|
+
): SassNumber;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Returns [[value]], converted to the units represented by `newNumerators`
|
|
159
|
+
* and `newDenominators`.
|
|
160
|
+
*
|
|
161
|
+
* @throws `Error` if this number's units are incompatible with
|
|
162
|
+
* `newNumerators` and `newDenominators`; or if this number is unitless and
|
|
163
|
+
* either `newNumerators` or `newDenominators` are not empty, or vice-versa.
|
|
164
|
+
*
|
|
165
|
+
* @param newNumerators - The numerator units to convert [[value]] to. This
|
|
166
|
+
* may be either a plain JavaScript array or an immutable [[List]] from the
|
|
167
|
+
* [`immutable` package](https://immutable-js.com/).
|
|
168
|
+
*
|
|
169
|
+
* @param newDenominators - The denominator units to convert [[value]] to.
|
|
170
|
+
* This may be either a plain JavaScript array or an immutable [[List]] from
|
|
171
|
+
* the [`immutable` package](https://immutable-js.com/).
|
|
172
|
+
*
|
|
173
|
+
* @param name - The name of the function argument `this` came from (without
|
|
174
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
175
|
+
*/
|
|
176
|
+
convertValue(
|
|
177
|
+
newNumerators: string[] | List<string>,
|
|
178
|
+
newDenominators: string[] | List<string>,
|
|
179
|
+
name?: string
|
|
180
|
+
): number;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Returns [[value]], converted to the same units as `other`.
|
|
184
|
+
*
|
|
185
|
+
* @throws `Error` if this number's units are incompatible with `other`'s
|
|
186
|
+
* units, or if either number is unitless but the other is not.
|
|
187
|
+
*
|
|
188
|
+
* @param name - The name of the function argument `this` came from (without
|
|
189
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
190
|
+
*
|
|
191
|
+
* @param otherName - The name of the function argument `other` came from
|
|
192
|
+
* (without the `$`) if it came from an argument. Used for error reporting.
|
|
193
|
+
*/
|
|
194
|
+
convertValueToMatch(
|
|
195
|
+
other: SassNumber,
|
|
196
|
+
name?: string,
|
|
197
|
+
otherName?: string
|
|
198
|
+
): number;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Returns a copy of this number, converted to the units represented by
|
|
202
|
+
* `newNumerators` and `newDenominators`.
|
|
203
|
+
*
|
|
204
|
+
* Unlike [[convert]] this does *not* throw an error if this number is
|
|
205
|
+
* unitless and either `newNumerators` or `newDenominators` are not empty, or
|
|
206
|
+
* vice-versa. Instead, it treats all unitless numbers as convertible to and
|
|
207
|
+
* from all units without changing the value.
|
|
208
|
+
*
|
|
209
|
+
* @throws `Error` if this number's units are incompatible with
|
|
210
|
+
* `newNumerators` and `newDenominators`.
|
|
211
|
+
*
|
|
212
|
+
* @param newNumerators - The numerator units to convert this number to. This
|
|
213
|
+
* may be either a plain JavaScript array or an immutable [[List]] from the
|
|
214
|
+
* [`immutable` package](https://immutable-js.com/).
|
|
215
|
+
*
|
|
216
|
+
* @param newDenominators - The denominator units to convert this number to.
|
|
217
|
+
* This may be either a plain JavaScript array or an immutable [[List]] from
|
|
218
|
+
* the [`immutable` package](https://immutable-js.com/).
|
|
219
|
+
*
|
|
220
|
+
* @param name - The name of the function argument `this` came from (without
|
|
221
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
222
|
+
*/
|
|
223
|
+
coerce(
|
|
224
|
+
newNumerators: string[] | List<string>,
|
|
225
|
+
newDenominators: string[] | List<string>,
|
|
226
|
+
name?: string
|
|
227
|
+
): SassNumber;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Returns a copy of this number, converted to the units represented by
|
|
231
|
+
* `newNumerators` and `newDenominators`.
|
|
232
|
+
*
|
|
233
|
+
* Unlike [[convertToMatch]] this does *not* throw an error if this number is
|
|
234
|
+
* unitless and either `newNumerators` or `newDenominators` are not empty, or
|
|
235
|
+
* vice-versa. Instead, it treats all unitless numbers as convertible to and
|
|
236
|
+
* from all units without changing the value.
|
|
237
|
+
*
|
|
238
|
+
* @throws `Error` if this number's units are incompatible with `other`'s
|
|
239
|
+
* units.
|
|
240
|
+
*
|
|
241
|
+
* @param name - The name of the function argument `this` came from (without
|
|
242
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
243
|
+
*
|
|
244
|
+
* @param otherName - The name of the function argument `other` came from
|
|
245
|
+
* (without the `$`) if it came from an argument. Used for error reporting.
|
|
246
|
+
*/
|
|
247
|
+
coerceToMatch(
|
|
248
|
+
other: SassNumber,
|
|
249
|
+
name?: string,
|
|
250
|
+
otherName?: string
|
|
251
|
+
): SassNumber;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Returns [[value]], converted to the units represented by `newNumerators` and
|
|
255
|
+
* `newDenominators`.
|
|
256
|
+
*
|
|
257
|
+
* Unlike [[convertValue]] this does *not* throw an error if this number is
|
|
258
|
+
* unitless and either `newNumerators` or `newDenominators` are not empty, or
|
|
259
|
+
* vice-versa. Instead, it treats all unitless numbers as convertible to and
|
|
260
|
+
* from all units without changing the value.
|
|
261
|
+
*
|
|
262
|
+
* @throws `Error` if this number's units are incompatible with
|
|
263
|
+
* `newNumerators` and `newDenominators`.
|
|
264
|
+
*
|
|
265
|
+
* @param newNumerators - The numerator units to convert [[value]] to. This
|
|
266
|
+
* may be either a plain JavaScript array or an immutable [[List]] from the
|
|
267
|
+
* [`immutable` package](https://immutable-js.com/).
|
|
268
|
+
*
|
|
269
|
+
* @param newDenominators - The denominator units to convert [[value]] to.
|
|
270
|
+
* This may be either a plain JavaScript array or an immutable [[List]] from
|
|
271
|
+
* the [`immutable` package](https://immutable-js.com/).
|
|
272
|
+
*
|
|
273
|
+
* @param name - The name of the function argument `this` came from (without
|
|
274
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
275
|
+
*/
|
|
276
|
+
coerceValue(
|
|
277
|
+
newNumerators: string[] | List<string>,
|
|
278
|
+
newDenominators: string[] | List<string>,
|
|
279
|
+
name?: string
|
|
280
|
+
): number;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Returns [[value]], converted to the units represented by `newNumerators`
|
|
284
|
+
* and `newDenominators`.
|
|
285
|
+
*
|
|
286
|
+
* Unlike [[convertValueToMatch]] this does *not* throw an error if this
|
|
287
|
+
* number is unitless and either `newNumerators` or `newDenominators` are not
|
|
288
|
+
* empty, or vice-versa. Instead, it treats all unitless numbers as
|
|
289
|
+
* convertible to and from all units without changing the value.
|
|
290
|
+
*
|
|
291
|
+
* @throws `Error` if this number's units are incompatible with `other`'s
|
|
292
|
+
* units.
|
|
293
|
+
*
|
|
294
|
+
* @param name - The name of the function argument `this` came from (without
|
|
295
|
+
* the `$`) if it came from an argument. Used for error reporting.
|
|
296
|
+
*
|
|
297
|
+
* @param otherName - The name of the function argument `other` came from
|
|
298
|
+
* (without the `$`) if it came from an argument. Used for error reporting.
|
|
299
|
+
*/
|
|
300
|
+
coerceValueToMatch(
|
|
301
|
+
other: SassNumber,
|
|
302
|
+
name?: string,
|
|
303
|
+
otherName?: string
|
|
304
|
+
): number;
|
|
305
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {Value} from './index';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sass's [string type](https://sass-lang.com/documentation/values/strings).
|
|
5
|
+
*
|
|
6
|
+
* @category Custom Function
|
|
7
|
+
*/
|
|
8
|
+
export class SassString extends Value {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new string.
|
|
11
|
+
*
|
|
12
|
+
* @param text - The contents of the string. For quoted strings, this is the
|
|
13
|
+
* semantic content—any escape sequences that were been written in the source
|
|
14
|
+
* text are resolved to their Unicode values. For unquoted strings, though,
|
|
15
|
+
* escape sequences are preserved as literal backslashes.
|
|
16
|
+
*
|
|
17
|
+
* @param options.quotes - Whether the string is quoted. Defaults to `true`.
|
|
18
|
+
*/
|
|
19
|
+
constructor(
|
|
20
|
+
text: string,
|
|
21
|
+
options?: {
|
|
22
|
+
quotes?: boolean;
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates an empty string.
|
|
28
|
+
*
|
|
29
|
+
* @param options.quotes - Whether the string is quoted. Defaults to `true`.
|
|
30
|
+
*/
|
|
31
|
+
constructor(options?: {quotes?: boolean});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The contents of the string.
|
|
35
|
+
*
|
|
36
|
+
* For quoted strings, this is the semantic content—any escape sequences that
|
|
37
|
+
* were been written in the source text are resolved to their Unicode values.
|
|
38
|
+
* For unquoted strings, though, escape sequences are preserved as literal
|
|
39
|
+
* backslashes.
|
|
40
|
+
*
|
|
41
|
+
* This difference allows us to distinguish between identifiers with escapes,
|
|
42
|
+
* such as `url\u28 http://example.com\u29`, and unquoted strings that contain
|
|
43
|
+
* characters that aren't valid in identifiers, such as
|
|
44
|
+
* `url(http://example.com)`. Unfortunately, it also means that we don't
|
|
45
|
+
* consider `foo` and `f\6F\6F` the same string.
|
|
46
|
+
*/
|
|
47
|
+
get text(): string;
|
|
48
|
+
|
|
49
|
+
/** Whether this string has quotes. */
|
|
50
|
+
get hasQuotes(): boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Sass's notion of this string's length.
|
|
54
|
+
*
|
|
55
|
+
* Sass treats strings as a series of Unicode code points while JavaScript
|
|
56
|
+
* treats them as a series of UTF-16 code units. For example, the character
|
|
57
|
+
* U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
|
|
58
|
+
* is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
|
|
59
|
+
* JavaScript, `"n😊b".length` returns `4`, whereas in Sass
|
|
60
|
+
* `string.length("n😊b")` returns `3`.
|
|
61
|
+
*/
|
|
62
|
+
get sassLength(): number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Converts `sassIndex` to a JavaScript index into [[text]].
|
|
66
|
+
*
|
|
67
|
+
* Sass indices are one-based, while JavaScript indices are zero-based. Sass
|
|
68
|
+
* indices may also be negative in order to index from the end of the string.
|
|
69
|
+
*
|
|
70
|
+
* In addition, Sass indices refer to Unicode code points while JavaScript
|
|
71
|
+
* string indices refer to UTF-16 code units. For example, the character
|
|
72
|
+
* U+1F60A SMILING FACE WITH SMILING EYES is a single Unicode code point but
|
|
73
|
+
* is represented in UTF-16 as two code units (`0xD83D` and `0xDE0A`). So in
|
|
74
|
+
* JavaScript, `"n😊b".charCodeAt(1)` returns `0xD83D`, whereas in Sass
|
|
75
|
+
* `string.slice("n😊b", 1, 1)` returns `"😊"`.
|
|
76
|
+
*
|
|
77
|
+
* This function converts Sass's code point indices to JavaScript's code unit
|
|
78
|
+
* indices. This means it's O(n) in the length of `text`.
|
|
79
|
+
*
|
|
80
|
+
* @throws `Error` - If `sassIndex` isn't a number, if that number isn't an
|
|
81
|
+
* integer, or if that integer isn't a valid index for this string.
|
|
82
|
+
*/
|
|
83
|
+
sassIndexToStringIndex(sassIndex: Value, name?: string): number;
|
|
84
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-embedded",
|
|
3
|
-
"version": "1.0.0-
|
|
4
|
-
"protocol-version": "1.0.0-beta.
|
|
5
|
-
"compiler-version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"protocol-version": "1.0.0-beta.16",
|
|
5
|
+
"compiler-version": "1.0.0-beta.16",
|
|
6
6
|
"description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol",
|
|
7
7
|
"repository": "sass/embedded-host-node",
|
|
8
8
|
"author": "Google Inc.",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"main": "dist/lib/index.js",
|
|
11
|
-
"types": "dist/
|
|
11
|
+
"types": "dist/types/index.d.ts",
|
|
12
12
|
"files": [
|
|
13
13
|
"dist/**/*",
|
|
14
14
|
"download-compiler-for-end-user.js"
|
|
@@ -24,37 +24,40 @@
|
|
|
24
24
|
"fix": "gts fix",
|
|
25
25
|
"postinstall": "node ./download-compiler-for-end-user.js",
|
|
26
26
|
"prepublishOnly": "npm run clean && ts-node ./tool/prepare-release.ts",
|
|
27
|
-
"test": "
|
|
27
|
+
"test": "jest"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"buffer-builder": "^0.2.0",
|
|
31
31
|
"extract-zip": "^2.0.1",
|
|
32
32
|
"google-protobuf": "^3.11.4",
|
|
33
|
-
"immutable": "^4.0.0
|
|
33
|
+
"immutable": "^4.0.0",
|
|
34
34
|
"node-fetch": "^2.6.0",
|
|
35
|
-
"rxjs": "^
|
|
36
|
-
"semver": "^
|
|
35
|
+
"rxjs": "^7.4.0",
|
|
36
|
+
"semver": "^7.3.5",
|
|
37
37
|
"shelljs": "^0.8.4",
|
|
38
|
+
"supports-color": "^8.1.1",
|
|
38
39
|
"tar": "^6.0.5"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@types/buffer-builder": "^0.2.0",
|
|
42
43
|
"@types/google-protobuf": "^3.7.2",
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/node": "^
|
|
44
|
+
"@types/jest": "^27.0.2",
|
|
45
|
+
"@types/node": "^16.10.3",
|
|
45
46
|
"@types/node-fetch": "^2.5.7",
|
|
46
47
|
"@types/semver": "^7.3.4",
|
|
47
48
|
"@types/shelljs": "^0.8.8",
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
49
|
+
"@types/supports-color": "^8.1.1",
|
|
50
|
+
"@types/tar": "^6.1.0",
|
|
51
|
+
"@types/yargs": "^17.0.4",
|
|
52
|
+
"del": "^6.0.0",
|
|
53
|
+
"gts": "^3.1.0",
|
|
54
|
+
"jest": "^27.2.5",
|
|
53
55
|
"protoc": "^1.0.4",
|
|
54
|
-
"source-map": "^0.6.1",
|
|
55
|
-
"ts-
|
|
56
|
-
"ts-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
56
|
+
"source-map-js": "^0.6.1",
|
|
57
|
+
"ts-jest": "^27.0.5",
|
|
58
|
+
"ts-node": "^10.2.1",
|
|
59
|
+
"ts-protoc-gen": "^0.15.0",
|
|
60
|
+
"typescript": "^4.4.3",
|
|
61
|
+
"yargs": "^17.2.1"
|
|
59
62
|
}
|
|
60
63
|
}
|
package/dist/lib/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { Value } from './src/value/value';
|
|
2
|
-
export { SassBoolean, sassFalse, sassTrue } from './src/value/boolean';
|
|
3
|
-
export { sassNull } from './src/value/null';
|
|
4
|
-
export { SassNumber } from './src/value/number';
|
|
5
|
-
export { SassString } from './src/value/string';
|
|
6
|
-
export { render, RenderOptions, RenderResult, RenderError, } from './src/node-sass/render';
|
|
7
|
-
export declare const info: string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { RawSourceMap } from 'source-map';
|
|
3
|
-
import { URL } from 'url';
|
|
4
|
-
/**
|
|
5
|
-
* Compiles a path and returns the resulting css. Throws a SassException if the
|
|
6
|
-
* compilation failed.
|
|
7
|
-
*/
|
|
8
|
-
export declare function compile(options: {
|
|
9
|
-
path: string;
|
|
10
|
-
sourceMap?: (sourceMap: RawSourceMap) => void;
|
|
11
|
-
}): Promise<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Compiles a string and returns the resulting css. Throws a SassException if
|
|
14
|
-
* the compilation failed.
|
|
15
|
-
*/
|
|
16
|
-
export declare function compileString(options: {
|
|
17
|
-
source: string;
|
|
18
|
-
sourceMap?: (sourceMap: RawSourceMap) => void;
|
|
19
|
-
url?: URL | string;
|
|
20
|
-
}): Promise<string>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
/**
|
|
4
|
-
* Invokes the Embedded Sass Compiler as a Node child process, exposing its
|
|
5
|
-
* stdio as Observables.
|
|
6
|
-
*/
|
|
7
|
-
export declare class EmbeddedCompiler {
|
|
8
|
-
private readonly process;
|
|
9
|
-
/** The child process's exit event. */
|
|
10
|
-
readonly exit$: Observable<number | null>;
|
|
11
|
-
/** The buffers emitted by the child process's stdout. */
|
|
12
|
-
readonly stdout$: Observable<Buffer>;
|
|
13
|
-
/** The buffers emitted by the child process's stderr. */
|
|
14
|
-
readonly stderr$: Observable<Buffer>;
|
|
15
|
-
/** Writes `buffer` to the child process's stdin. */
|
|
16
|
-
writeStdin(buffer: Buffer): void;
|
|
17
|
-
/** Kills the child process, cleaning up all associated Observables. */
|
|
18
|
-
close(): void;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../../lib/src/embedded-compiler/compiler.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;AAEvC,iDAAoC;AACpC,+BAA6B;AAC7B,+BAAgC;AAChC,8CAAyC;AAEzC;;;GAGG;AACH,MAAa,gBAAgB;IAA7B;QACmB,YAAO,GAAG,qBAAK,CAC9B,cAAO,CACL,SAAS,EACT,kDACE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAC1C,EAAE,CACH,EACD;YACE,WAAW,EAAE,IAAI;SAClB,CACF,CAAC;QAEF,sCAAsC;QAC7B,UAAK,GAAG,IAAI,iBAAU,CAAgB,QAAQ,CAAC,EAAE;YACxD,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QAEH,yDAAyD;QAChD,YAAO,GAAG,IAAI,iBAAU,CAAS,QAAQ,CAAC,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAE/B,yDAAyD;QAChD,YAAO,GAAG,IAAI,iBAAU,CAAS,QAAQ,CAAC,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAWjC,CAAC;IATC,oDAAoD;IACpD,UAAU,CAAC,MAAc;QACvB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,uEAAuE;IACvE,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IAC3B,CAAC;CACF;AArCD,4CAqCC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
/**
|
|
4
|
-
* Decodes arbitrarily-chunked buffers, for example
|
|
5
|
-
* [ 0 1 2 3 4 5 6 7 ... ],
|
|
6
|
-
* into packets of set length in the form
|
|
7
|
-
* +---------+------------- ...
|
|
8
|
-
* | 0 1 2 3 | 4 5 6 7 ...
|
|
9
|
-
* +---------+------------- ...
|
|
10
|
-
* | HEADER | PAYLOAD (PROTOBUF)
|
|
11
|
-
* +---------+------------- ...
|
|
12
|
-
* and emits the payload of each packet.
|
|
13
|
-
*
|
|
14
|
-
* Encodes packets by attaching a header to a protobuf that describes the
|
|
15
|
-
* protobuf's length.
|
|
16
|
-
*/
|
|
17
|
-
export declare class PacketTransformer {
|
|
18
|
-
private readonly outboundBuffers$;
|
|
19
|
-
private readonly writeInboundBuffer;
|
|
20
|
-
private packet;
|
|
21
|
-
private readonly outboundProtobufsInternal$;
|
|
22
|
-
/**
|
|
23
|
-
* The fully-decoded, outbound protobufs. If any errors are encountered
|
|
24
|
-
* during encoding/decoding, this Observable will error out.
|
|
25
|
-
*/
|
|
26
|
-
readonly outboundProtobufs$: Observable<Buffer>;
|
|
27
|
-
constructor(outboundBuffers$: Observable<Buffer>, writeInboundBuffer: (buffer: Buffer) => void);
|
|
28
|
-
/**
|
|
29
|
-
* Encodes a packet by pre-fixing `protobuf` with a header that describes its
|
|
30
|
-
* length.
|
|
31
|
-
*/
|
|
32
|
-
writeInboundProtobuf(protobuf: Buffer): void;
|
|
33
|
-
private decode;
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packet-transformer.js","sourceRoot":"","sources":["../../../../lib/src/embedded-compiler/packet-transformer.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;AAEvC,+BAAyC;AACzC,8CAAwC;AACxC,gDAAiD;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAa,iBAAiB;IAc5B,YACmB,gBAAoC,EACpC,kBAA4C;QAD5C,qBAAgB,GAAhB,gBAAgB,CAAoB;QACpC,uBAAkB,GAAlB,kBAAkB,CAA0B;QAf/D,gEAAgE;QACxD,WAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAE9B,4EAA4E;QAC5E,4BAA4B;QACX,+BAA0B,GAAG,IAAI,cAAO,EAAU,CAAC;QAEpE;;;WAGG;QACM,u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js';
|
|
2
|
-
import { InboundMessage, OutboundMessage } from '../vendor/embedded-protocol/embedded_sass_pb';
|
|
3
|
-
import { InboundTypedMessage, OutboundTypedMessage } from './message-transformer';
|
|
4
|
-
import { PromiseOr } from '../utils';
|
|
5
|
-
/**
|
|
6
|
-
* Dispatches requests, responses, and events.
|
|
7
|
-
*
|
|
8
|
-
* Accepts callbacks for processing different types of outbound requests. When
|
|
9
|
-
* an outbound request arrives, this runs the appropriate callback to process
|
|
10
|
-
* it, and then sends the result inbound. A single callback must be provided for
|
|
11
|
-
* each outbound request type. The callback does not need to set the response
|
|
12
|
-
* ID; the dispatcher handles it.
|
|
13
|
-
*
|
|
14
|
-
* Consumers can send an inbound request. This returns a promise that will
|
|
15
|
-
* either resolve with the corresponding outbound response, or error if any
|
|
16
|
-
* Protocol Errors were encountered. The consumer does not need to set the
|
|
17
|
-
* request ID; the dispatcher handles it.
|
|
18
|
-
*
|
|
19
|
-
* Outbound events are exposed as Observables.
|
|
20
|
-
*
|
|
21
|
-
* Errors are not otherwise exposed to the top-level. Instead, they are surfaced
|
|
22
|
-
* as an Observable that consumers may choose to subscribe to. Subscribers must
|
|
23
|
-
* perform proper error handling.
|
|
24
|
-
*/
|
|
25
|
-
export declare class Dispatcher {
|
|
26
|
-
private readonly outboundMessages$;
|
|
27
|
-
private readonly writeInboundMessage;
|
|
28
|
-
private readonly outboundRequestHandlers;
|
|
29
|
-
private readonly pendingInboundRequests;
|
|
30
|
-
private readonly pendingOutboundRequests;
|
|
31
|
-
private readonly messages$;
|
|
32
|
-
private readonly errorInternal$;
|
|
33
|
-
/**
|
|
34
|
-
* If the dispatcher encounters an error, this errors out. Upon error, the
|
|
35
|
-
* dispatcher rejects all promises awaiting an outbound response, and silently
|
|
36
|
-
* closes all subscriptions to outbound events.
|
|
37
|
-
*/
|
|
38
|
-
readonly error$: Observable<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Outbound log events. If an error occurs, the dispatcher closes this
|
|
41
|
-
* silently.
|
|
42
|
-
*/
|
|
43
|
-
readonly logEvents$: Observable<OutboundMessage.LogEvent>;
|
|
44
|
-
constructor(outboundMessages$: Observable<OutboundTypedMessage>, writeInboundMessage: (message: InboundTypedMessage) => void, outboundRequestHandlers: {
|
|
45
|
-
handleImportRequest: (request: OutboundMessage.ImportRequest) => PromiseOr<InboundMessage.ImportResponse>;
|
|
46
|
-
handleFileImportRequest: (request: OutboundMessage.FileImportRequest) => PromiseOr<InboundMessage.FileImportResponse>;
|
|
47
|
-
handleCanonicalizeRequest: (request: OutboundMessage.CanonicalizeRequest) => PromiseOr<InboundMessage.CanonicalizeResponse>;
|
|
48
|
-
handleFunctionCallRequest: (request: OutboundMessage.FunctionCallRequest) => PromiseOr<InboundMessage.FunctionCallResponse>;
|
|
49
|
-
});
|
|
50
|
-
/**
|
|
51
|
-
* Sends a CompileRequest inbound. Returns a promise that will either resolve
|
|
52
|
-
* with the corresponding outbound CompileResponse, or error if any Protocol
|
|
53
|
-
* Errors were encountered.
|
|
54
|
-
*/
|
|
55
|
-
sendCompileRequest(request: InboundMessage.CompileRequest): Promise<OutboundMessage.CompileResponse>;
|
|
56
|
-
private throwAndClose;
|
|
57
|
-
private handleOutboundMessage;
|
|
58
|
-
private handleInboundRequest;
|
|
59
|
-
private sendInboundMessage;
|
|
60
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../../../lib/src/embedded-protocol/dispatcher.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;AAEvC,+BAAyC;AACzC,8CAAqD;AAErD,mFAGsD;AAWtD,uDAAiD;AAGjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,UAAU;IAiCrB,YACmB,iBAAmD,EACnD,mBAER,EACQ,uBAahB;QAjBgB,sBAAiB,GAAjB,iBAAiB,CAAkC;QACnD,wBAAmB,GAAnB,mBAAmB,CAE3B;QACQ,4BAAuB,GA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