@tbela99/css-parser 1.2.0 → 1.3.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/CHANGELOG.md +5 -0
- package/README.md +2 -2
- package/dist/index-umd-web.js +483 -849
- package/dist/index.cjs +483 -849
- package/dist/index.d.ts +107 -11
- package/dist/lib/ast/features/calc.js +1 -25
- package/dist/lib/ast/features/inlinecssvariables.js +0 -19
- package/dist/lib/ast/features/transform.js +2 -2
- package/dist/lib/ast/math/expression.js +26 -149
- package/dist/lib/ast/math/math.js +8 -8
- package/dist/lib/ast/transform/compute.js +4 -37
- package/dist/lib/ast/transform/matrix.js +33 -34
- package/dist/lib/ast/transform/minify.js +32 -51
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.js +13 -13
- package/dist/lib/ast/transform/scale.js +8 -8
- package/dist/lib/ast/transform/skew.js +4 -4
- package/dist/lib/ast/transform/translate.js +8 -8
- package/dist/lib/ast/transform/utils.js +31 -39
- package/dist/lib/ast/types.js +91 -2
- package/dist/lib/parser/declaration/set.js +2 -2
- package/dist/lib/parser/parse.js +34 -12
- package/dist/lib/parser/tokenize.js +28 -40
- package/dist/lib/parser/utils/type.js +1 -1
- package/dist/lib/renderer/render.js +36 -27
- package/dist/lib/syntax/color/cmyk.js +2 -2
- package/dist/lib/syntax/color/color-mix.js +11 -12
- package/dist/lib/syntax/color/color.js +7 -7
- package/dist/lib/syntax/color/hsl.js +4 -4
- package/dist/lib/syntax/color/hwb.js +27 -8
- package/dist/lib/syntax/color/lab.js +4 -4
- package/dist/lib/syntax/color/lch.js +4 -4
- package/dist/lib/syntax/color/oklab.js +4 -4
- package/dist/lib/syntax/color/oklch.js +4 -4
- package/dist/lib/syntax/color/relativecolor.js +1 -1
- package/dist/lib/syntax/color/rgb.js +4 -4
- package/dist/lib/syntax/color/utils/components.js +15 -3
- package/dist/lib/syntax/color/utils/distance.js +11 -1
- package/dist/lib/syntax/syntax.js +8 -17
- package/dist/lib/syntax/utils.js +1 -1
- package/dist/lib/validation/at-rules/document.js +1 -1
- package/dist/lib/validation/at-rules/import.js +4 -4
- package/dist/lib/validation/at-rules/keyframes.js +0 -11
- package/dist/lib/validation/at-rules/supports.js +6 -6
- package/dist/lib/validation/config.js +0 -4
- package/dist/lib/validation/parser/parse.js +0 -8
- package/dist/lib/validation/selector.js +0 -9
- package/dist/lib/validation/syntax.js +14 -134
- package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -11
- package/dist/lib/validation/syntaxes/family-name.js +0 -32
- package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -11
- package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -26
- package/dist/lib/validation/syntaxes/url.js +0 -33
- package/dist/lib/validation/utils/list.js +0 -8
- package/package.json +1 -1
package/dist/index-umd-web.js
CHANGED
|
@@ -4,11 +4,17 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CSSParser = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* syntax validation enum
|
|
9
|
+
*/
|
|
7
10
|
var SyntaxValidationResult;
|
|
8
11
|
(function (SyntaxValidationResult) {
|
|
12
|
+
/** valid syntax */
|
|
9
13
|
SyntaxValidationResult[SyntaxValidationResult["Valid"] = 0] = "Valid";
|
|
14
|
+
/** drop invalid syntax */
|
|
10
15
|
SyntaxValidationResult[SyntaxValidationResult["Drop"] = 1] = "Drop";
|
|
11
|
-
|
|
16
|
+
/** preserve unknown at-rules, declarations and pseudo-classes */
|
|
17
|
+
SyntaxValidationResult[SyntaxValidationResult["Lenient"] = 2] = "Lenient";
|
|
12
18
|
})(SyntaxValidationResult || (SyntaxValidationResult = {}));
|
|
13
19
|
/**
|
|
14
20
|
* validation level enum
|
|
@@ -160,35 +166,118 @@
|
|
|
160
166
|
EnumToken[EnumToken["TimingFunction"] = 17] = "TimingFunction";
|
|
161
167
|
EnumToken[EnumToken["TimelineFunction"] = 16] = "TimelineFunction";
|
|
162
168
|
})(exports.EnumToken || (exports.EnumToken = {}));
|
|
163
|
-
|
|
169
|
+
/**
|
|
170
|
+
* color types enum
|
|
171
|
+
*/
|
|
164
172
|
exports.ColorType = void 0;
|
|
165
173
|
(function (ColorType) {
|
|
174
|
+
/**
|
|
175
|
+
* system colors
|
|
176
|
+
*/
|
|
166
177
|
ColorType[ColorType["SYS"] = 0] = "SYS";
|
|
178
|
+
/**
|
|
179
|
+
* deprecated system colors
|
|
180
|
+
*/
|
|
167
181
|
ColorType[ColorType["DPSYS"] = 1] = "DPSYS";
|
|
182
|
+
/**
|
|
183
|
+
* colors as literals
|
|
184
|
+
*/
|
|
168
185
|
ColorType[ColorType["LIT"] = 2] = "LIT";
|
|
186
|
+
/**
|
|
187
|
+
* colors as hex values
|
|
188
|
+
*/
|
|
169
189
|
ColorType[ColorType["HEX"] = 3] = "HEX";
|
|
190
|
+
/**
|
|
191
|
+
* colors as rgb values
|
|
192
|
+
*/
|
|
170
193
|
ColorType[ColorType["RGBA"] = 4] = "RGBA";
|
|
194
|
+
/**
|
|
195
|
+
* colors as hsl values
|
|
196
|
+
*/
|
|
171
197
|
ColorType[ColorType["HSLA"] = 5] = "HSLA";
|
|
198
|
+
/**
|
|
199
|
+
* colors as hwb values
|
|
200
|
+
*/
|
|
172
201
|
ColorType[ColorType["HWB"] = 6] = "HWB";
|
|
202
|
+
/**
|
|
203
|
+
* colors as cmyk values
|
|
204
|
+
*/
|
|
173
205
|
ColorType[ColorType["CMYK"] = 7] = "CMYK";
|
|
206
|
+
/**
|
|
207
|
+
* colors as oklab values
|
|
208
|
+
* */
|
|
174
209
|
ColorType[ColorType["OKLAB"] = 8] = "OKLAB";
|
|
210
|
+
/**
|
|
211
|
+
* colors as oklch values
|
|
212
|
+
* */
|
|
175
213
|
ColorType[ColorType["OKLCH"] = 9] = "OKLCH";
|
|
214
|
+
/**
|
|
215
|
+
* colors as lab values
|
|
216
|
+
*/
|
|
176
217
|
ColorType[ColorType["LAB"] = 10] = "LAB";
|
|
218
|
+
/**
|
|
219
|
+
* colors as lch values
|
|
220
|
+
*/
|
|
177
221
|
ColorType[ColorType["LCH"] = 11] = "LCH";
|
|
222
|
+
/**
|
|
223
|
+
* colors using color() function
|
|
224
|
+
*/
|
|
178
225
|
ColorType[ColorType["COLOR"] = 12] = "COLOR";
|
|
226
|
+
/**
|
|
227
|
+
* color using srgb values
|
|
228
|
+
*/
|
|
179
229
|
ColorType[ColorType["SRGB"] = 13] = "SRGB";
|
|
230
|
+
/**
|
|
231
|
+
* color using prophoto-rgb values
|
|
232
|
+
*/
|
|
180
233
|
ColorType[ColorType["PROPHOTO_RGB"] = 14] = "PROPHOTO_RGB";
|
|
234
|
+
/**
|
|
235
|
+
* color using a98-rgb values
|
|
236
|
+
*/
|
|
181
237
|
ColorType[ColorType["A98_RGB"] = 15] = "A98_RGB";
|
|
238
|
+
/**
|
|
239
|
+
* color using rec2020 values
|
|
240
|
+
*/
|
|
182
241
|
ColorType[ColorType["REC2020"] = 16] = "REC2020";
|
|
242
|
+
/**
|
|
243
|
+
* color using display-p3 values
|
|
244
|
+
*/
|
|
183
245
|
ColorType[ColorType["DISPLAY_P3"] = 17] = "DISPLAY_P3";
|
|
246
|
+
/**
|
|
247
|
+
* color using srgb-linear values
|
|
248
|
+
*/
|
|
184
249
|
ColorType[ColorType["SRGB_LINEAR"] = 18] = "SRGB_LINEAR";
|
|
250
|
+
/**
|
|
251
|
+
* color using xyz-d50 values
|
|
252
|
+
*/
|
|
185
253
|
ColorType[ColorType["XYZ_D50"] = 19] = "XYZ_D50";
|
|
254
|
+
/**
|
|
255
|
+
* color using xyz-d65 values
|
|
256
|
+
*/
|
|
186
257
|
ColorType[ColorType["XYZ_D65"] = 20] = "XYZ_D65";
|
|
258
|
+
/**
|
|
259
|
+
* light-dark() color function
|
|
260
|
+
*/
|
|
187
261
|
ColorType[ColorType["LIGHT_DARK"] = 21] = "LIGHT_DARK";
|
|
262
|
+
/**
|
|
263
|
+
* color-mix() color function
|
|
264
|
+
*/
|
|
188
265
|
ColorType[ColorType["COLOR_MIX"] = 22] = "COLOR_MIX";
|
|
266
|
+
/**
|
|
267
|
+
* alias for rgba
|
|
268
|
+
*/
|
|
189
269
|
ColorType[ColorType["RGB"] = 4] = "RGB";
|
|
270
|
+
/**
|
|
271
|
+
* alias for hsl
|
|
272
|
+
*/
|
|
190
273
|
ColorType[ColorType["HSL"] = 5] = "HSL";
|
|
274
|
+
/**
|
|
275
|
+
* alias for xyz-d65
|
|
276
|
+
*/
|
|
191
277
|
ColorType[ColorType["XYZ"] = 20] = "XYZ";
|
|
278
|
+
/**
|
|
279
|
+
* alias for cmyk
|
|
280
|
+
*/
|
|
192
281
|
ColorType[ColorType["DEVICE_CMYK"] = 7] = "DEVICE_CMYK";
|
|
193
282
|
})(exports.ColorType || (exports.ColorType = {}));
|
|
194
283
|
|
|
@@ -497,12 +586,12 @@
|
|
|
497
586
|
function lchToken(values) {
|
|
498
587
|
values[2] = toPrecisionAngle(values[2]);
|
|
499
588
|
const chi = [
|
|
500
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
501
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
502
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
589
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
590
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
591
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[2] },
|
|
503
592
|
];
|
|
504
593
|
if (values.length == 4) {
|
|
505
|
-
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, { typ: exports.EnumToken.PercentageTokenType, val:
|
|
594
|
+
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, { typ: exports.EnumToken.PercentageTokenType, val: values[3] * 100 });
|
|
506
595
|
}
|
|
507
596
|
return {
|
|
508
597
|
typ: exports.EnumToken.ColorTokenType,
|
|
@@ -765,14 +854,14 @@
|
|
|
765
854
|
function oklchToken(values) {
|
|
766
855
|
values[2] = toPrecisionAngle(values[2]);
|
|
767
856
|
const chi = [
|
|
768
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
769
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
770
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
857
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
858
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
859
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[2] },
|
|
771
860
|
];
|
|
772
861
|
if (values.length == 4) {
|
|
773
862
|
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, {
|
|
774
863
|
typ: exports.EnumToken.PercentageTokenType,
|
|
775
|
-
val:
|
|
864
|
+
val: values[3] * 100
|
|
776
865
|
});
|
|
777
866
|
}
|
|
778
867
|
return {
|
|
@@ -917,14 +1006,14 @@
|
|
|
917
1006
|
}
|
|
918
1007
|
function oklabToken(values) {
|
|
919
1008
|
const chi = [
|
|
920
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
921
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
922
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
1009
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
1010
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
1011
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[2] },
|
|
923
1012
|
];
|
|
924
1013
|
if (values.length == 4) {
|
|
925
1014
|
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, {
|
|
926
1015
|
typ: exports.EnumToken.PercentageTokenType,
|
|
927
|
-
val:
|
|
1016
|
+
val: values[3] * 100
|
|
928
1017
|
});
|
|
929
1018
|
}
|
|
930
1019
|
return {
|
|
@@ -1135,14 +1224,14 @@
|
|
|
1135
1224
|
}
|
|
1136
1225
|
function labToken(values) {
|
|
1137
1226
|
const chi = [
|
|
1138
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
1139
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
1140
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
1227
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
1228
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
1229
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[2] },
|
|
1141
1230
|
];
|
|
1142
1231
|
if (values.length == 4) {
|
|
1143
1232
|
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, {
|
|
1144
1233
|
typ: exports.EnumToken.PercentageTokenType,
|
|
1145
|
-
val:
|
|
1234
|
+
val: values[3] * 100
|
|
1146
1235
|
});
|
|
1147
1236
|
}
|
|
1148
1237
|
return {
|
|
@@ -1766,7 +1855,7 @@
|
|
|
1766
1855
|
const value = expandHexValue(token.kin == exports.ColorType.LIT ? COLORS_NAMES[token.val.toLowerCase()] : token.val);
|
|
1767
1856
|
// @ts-ignore
|
|
1768
1857
|
return value.slice(1).match(/([a-fA-F0-9]{2})/g).map((t, index) => {
|
|
1769
|
-
return { typ: exports.EnumToken.Number, val:
|
|
1858
|
+
return { typ: exports.EnumToken.Number, val: index < 3 ? parseInt(t, 16) : parseInt(t, 16) / 255 };
|
|
1770
1859
|
});
|
|
1771
1860
|
}
|
|
1772
1861
|
const result = [];
|
|
@@ -1776,7 +1865,19 @@
|
|
|
1776
1865
|
].includes(child.typ)) {
|
|
1777
1866
|
continue;
|
|
1778
1867
|
}
|
|
1779
|
-
if (child.typ == exports.EnumToken.
|
|
1868
|
+
if (child.typ == exports.EnumToken.FunctionTokenType) {
|
|
1869
|
+
if ('var' == child.val.toLowerCase()) {
|
|
1870
|
+
return null;
|
|
1871
|
+
}
|
|
1872
|
+
else {
|
|
1873
|
+
for (const { value } of walkValues(child.chi)) {
|
|
1874
|
+
if (value.typ == exports.EnumToken.FunctionTokenType && 'var' === value.val.toLowerCase()) {
|
|
1875
|
+
return null;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
if (child.typ == exports.EnumToken.ColorTokenType && 'currentcolor' === child.val.toLowerCase()) {
|
|
1780
1881
|
return null;
|
|
1781
1882
|
}
|
|
1782
1883
|
result.push(child);
|
|
@@ -1784,13 +1885,23 @@
|
|
|
1784
1885
|
return result;
|
|
1785
1886
|
}
|
|
1786
1887
|
|
|
1888
|
+
/**
|
|
1889
|
+
* Calculate the distance between two okLab colors.
|
|
1890
|
+
* @param okLab1
|
|
1891
|
+
* @param okLab2
|
|
1892
|
+
*/
|
|
1787
1893
|
function okLabDistance(okLab1, okLab2) {
|
|
1788
1894
|
return Math.sqrt(Math.pow(okLab1[0] - okLab2[0], 2) + Math.pow(okLab1[1] - okLab2[1], 2) + Math.pow(okLab1[2] - okLab2[2], 2));
|
|
1789
1895
|
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Check if two colors are close.
|
|
1898
|
+
* @param color1
|
|
1899
|
+
* @param color2
|
|
1900
|
+
* @param threshold
|
|
1901
|
+
*/
|
|
1790
1902
|
function isOkLabClose(color1, color2, threshold = .01) {
|
|
1791
1903
|
color1 = convertColor(color1, exports.ColorType.OKLAB);
|
|
1792
1904
|
color2 = convertColor(color2, exports.ColorType.OKLAB);
|
|
1793
|
-
// console.error(JSON.stringify({color1, color2}, null, 1));
|
|
1794
1905
|
if (color1 == null || color2 == null) {
|
|
1795
1906
|
return false;
|
|
1796
1907
|
}
|
|
@@ -1866,12 +1977,12 @@
|
|
|
1866
1977
|
}
|
|
1867
1978
|
function rgb2RgbToken(values) {
|
|
1868
1979
|
const chi = [
|
|
1869
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
1870
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
1871
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
1980
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
1981
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
1982
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[2] },
|
|
1872
1983
|
];
|
|
1873
1984
|
if (values.length == 4) {
|
|
1874
|
-
chi.push({ typ: exports.EnumToken.PercentageTokenType, val:
|
|
1985
|
+
chi.push({ typ: exports.EnumToken.PercentageTokenType, val: values[3] * 100 });
|
|
1875
1986
|
}
|
|
1876
1987
|
return {
|
|
1877
1988
|
typ: exports.EnumToken.ColorTokenType,
|
|
@@ -2012,12 +2123,12 @@
|
|
|
2012
2123
|
function hslToken(values) {
|
|
2013
2124
|
values[0] = toPrecisionAngle(values[0] * 360);
|
|
2014
2125
|
const chi = [
|
|
2015
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
2016
|
-
{ typ: exports.EnumToken.PercentageTokenType, val:
|
|
2017
|
-
{ typ: exports.EnumToken.PercentageTokenType, val:
|
|
2126
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
2127
|
+
{ typ: exports.EnumToken.PercentageTokenType, val: values[1] * 100 },
|
|
2128
|
+
{ typ: exports.EnumToken.PercentageTokenType, val: values[2] * 100 },
|
|
2018
2129
|
];
|
|
2019
2130
|
if (values.length == 4 && values[3] != 1) {
|
|
2020
|
-
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, { typ: exports.EnumToken.PercentageTokenType, val:
|
|
2131
|
+
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, { typ: exports.EnumToken.PercentageTokenType, val: values[3] * 100 });
|
|
2021
2132
|
}
|
|
2022
2133
|
return {
|
|
2023
2134
|
typ: exports.EnumToken.ColorTokenType,
|
|
@@ -2193,12 +2304,15 @@
|
|
|
2193
2304
|
function hwbToken(values) {
|
|
2194
2305
|
values[0] = toPrecisionAngle(values[0] * 360);
|
|
2195
2306
|
const chi = [
|
|
2196
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
2197
|
-
{ typ: exports.EnumToken.PercentageTokenType, val:
|
|
2198
|
-
{ typ: exports.EnumToken.PercentageTokenType, val:
|
|
2307
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
2308
|
+
{ typ: exports.EnumToken.PercentageTokenType, val: values[1] * 100 },
|
|
2309
|
+
{ typ: exports.EnumToken.PercentageTokenType, val: values[2] * 100 },
|
|
2199
2310
|
];
|
|
2200
2311
|
if (values.length == 4) {
|
|
2201
|
-
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, {
|
|
2312
|
+
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: '/' }, {
|
|
2313
|
+
typ: exports.EnumToken.PercentageTokenType,
|
|
2314
|
+
val: values[3] * 100
|
|
2315
|
+
});
|
|
2202
2316
|
}
|
|
2203
2317
|
return {
|
|
2204
2318
|
typ: exports.EnumToken.ColorTokenType,
|
|
@@ -2233,16 +2347,28 @@
|
|
|
2233
2347
|
}));
|
|
2234
2348
|
}
|
|
2235
2349
|
function lab2hwbvalues(token) {
|
|
2350
|
+
const values = lab2srgbvalues(token);
|
|
2351
|
+
if (values == null) {
|
|
2352
|
+
return null;
|
|
2353
|
+
}
|
|
2236
2354
|
// @ts-ignore
|
|
2237
|
-
return srgb2hwb(...
|
|
2355
|
+
return srgb2hwb(...values);
|
|
2238
2356
|
}
|
|
2239
2357
|
function lch2hwbvalues(token) {
|
|
2358
|
+
const values = lch2srgbvalues(token);
|
|
2359
|
+
if (values == null) {
|
|
2360
|
+
return null;
|
|
2361
|
+
}
|
|
2240
2362
|
// @ts-ignore
|
|
2241
|
-
return srgb2hwb(...
|
|
2363
|
+
return srgb2hwb(...values);
|
|
2242
2364
|
}
|
|
2243
2365
|
function oklab2hwbvalues(token) {
|
|
2366
|
+
const values = oklab2srgbvalues(token);
|
|
2367
|
+
if (values == null) {
|
|
2368
|
+
return null;
|
|
2369
|
+
}
|
|
2244
2370
|
// @ts-ignore
|
|
2245
|
-
return srgb2hwb(...
|
|
2371
|
+
return srgb2hwb(...values);
|
|
2246
2372
|
}
|
|
2247
2373
|
function oklch2hwbvalues(token) {
|
|
2248
2374
|
const values = oklch2srgbvalues(token);
|
|
@@ -2276,8 +2402,12 @@
|
|
|
2276
2402
|
return Math.min(r, g, b);
|
|
2277
2403
|
}
|
|
2278
2404
|
function color2hwbvalues(token) {
|
|
2405
|
+
const values = color2srgbvalues(token);
|
|
2406
|
+
if (values == null) {
|
|
2407
|
+
return null;
|
|
2408
|
+
}
|
|
2279
2409
|
// @ts-ignore
|
|
2280
|
-
return srgb2hwb(...
|
|
2410
|
+
return srgb2hwb(...values);
|
|
2281
2411
|
}
|
|
2282
2412
|
function srgb2hwb(r, g, b, a = null, fallback = 0) {
|
|
2283
2413
|
r *= 100;
|
|
@@ -2498,7 +2628,7 @@
|
|
|
2498
2628
|
return [h1, h2];
|
|
2499
2629
|
}
|
|
2500
2630
|
function colorMix(colorSpace, hueInterpolationMethod, color1, percentage1, color2, percentage2) {
|
|
2501
|
-
if (color1.val == 'currentcolor' || color2.val == 'currentcolor') {
|
|
2631
|
+
if (color1.val.toLowerCase() == 'currentcolor' || color2.val == 'currentcolor'.toLowerCase()) {
|
|
2502
2632
|
return null;
|
|
2503
2633
|
}
|
|
2504
2634
|
if (hueInterpolationMethod != null && isRectangularOrthogonalColorspace(colorSpace)) {
|
|
@@ -2510,20 +2640,19 @@
|
|
|
2510
2640
|
if (percentage1 == null) {
|
|
2511
2641
|
if (percentage2 == null) {
|
|
2512
2642
|
// @ts-ignore
|
|
2513
|
-
percentage1 = { typ: exports.EnumToken.NumberTokenType, val:
|
|
2643
|
+
percentage1 = { typ: exports.EnumToken.NumberTokenType, val: .5 };
|
|
2514
2644
|
// @ts-ignore
|
|
2515
|
-
percentage2 = { typ: exports.EnumToken.NumberTokenType, val:
|
|
2645
|
+
percentage2 = { typ: exports.EnumToken.NumberTokenType, val: .5 };
|
|
2516
2646
|
}
|
|
2517
2647
|
else {
|
|
2518
2648
|
if (+percentage2.val <= 0) {
|
|
2519
2649
|
return null;
|
|
2520
2650
|
}
|
|
2521
2651
|
if (+percentage2.val >= 100) {
|
|
2522
|
-
|
|
2523
|
-
percentage2 = { typ: exports.EnumToken.NumberTokenType, val: '1' };
|
|
2652
|
+
percentage2 = { typ: exports.EnumToken.NumberTokenType, val: 1 };
|
|
2524
2653
|
}
|
|
2525
2654
|
// @ts-ignore
|
|
2526
|
-
percentage1 = { typ: exports.EnumToken.NumberTokenType, val:
|
|
2655
|
+
percentage1 = { typ: exports.EnumToken.NumberTokenType, val: 1 - percentage2.val / 100 };
|
|
2527
2656
|
}
|
|
2528
2657
|
}
|
|
2529
2658
|
else {
|
|
@@ -2535,10 +2664,10 @@
|
|
|
2535
2664
|
// @ts-ignore
|
|
2536
2665
|
if (percentage1.val >= 100) {
|
|
2537
2666
|
// @ts-ignore
|
|
2538
|
-
percentage1 = { typ: exports.EnumToken.NumberTokenType, val:
|
|
2667
|
+
percentage1 = { typ: exports.EnumToken.NumberTokenType, val: 1 };
|
|
2539
2668
|
}
|
|
2540
2669
|
// @ts-ignore
|
|
2541
|
-
percentage2 = { typ: exports.EnumToken.NumberTokenType, val:
|
|
2670
|
+
percentage2 = { typ: exports.EnumToken.NumberTokenType, val: 1 - percentage1.val / 100 };
|
|
2542
2671
|
}
|
|
2543
2672
|
else {
|
|
2544
2673
|
// @ts-ignore
|
|
@@ -2716,7 +2845,7 @@
|
|
|
2716
2845
|
chi: values.map(v => {
|
|
2717
2846
|
return {
|
|
2718
2847
|
typ: exports.EnumToken.NumberTokenType,
|
|
2719
|
-
val:
|
|
2848
|
+
val: v
|
|
2720
2849
|
};
|
|
2721
2850
|
}),
|
|
2722
2851
|
kin: exports.ColorType.LCH
|
|
@@ -2773,11 +2902,11 @@
|
|
|
2773
2902
|
};
|
|
2774
2903
|
if (colorSpace.val == 'hsl' || colorSpace.val == 'hwb') {
|
|
2775
2904
|
// @ts-ignore
|
|
2776
|
-
result.chi[0] = { typ: exports.EnumToken.AngleTokenType, val:
|
|
2905
|
+
result.chi[0] = { typ: exports.EnumToken.AngleTokenType, val: result.chi[0].val * 360 };
|
|
2777
2906
|
// @ts-ignore
|
|
2778
|
-
result.chi[1] = { typ: exports.EnumToken.PercentageTokenType, val:
|
|
2907
|
+
result.chi[1] = { typ: exports.EnumToken.PercentageTokenType, val: result.chi[1].val * 100 };
|
|
2779
2908
|
// @ts-ignore
|
|
2780
|
-
result.chi[2] = { typ: exports.EnumToken.PercentageTokenType, val:
|
|
2909
|
+
result.chi[2] = { typ: exports.EnumToken.PercentageTokenType, val: result.chi[2].val * 100 };
|
|
2781
2910
|
}
|
|
2782
2911
|
return result;
|
|
2783
2912
|
}
|
|
@@ -2828,20 +2957,20 @@
|
|
|
2828
2957
|
const r2 = minifyNumber(r[0]) + '/' + minifyNumber(r[1]);
|
|
2829
2958
|
return minifyNumber(result).length < r2.length ? result : {
|
|
2830
2959
|
typ: exports.EnumToken.FractionTokenType,
|
|
2831
|
-
l: { typ: exports.EnumToken.NumberTokenType, val:
|
|
2832
|
-
r: { typ: exports.EnumToken.NumberTokenType, val:
|
|
2960
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: r[0] },
|
|
2961
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: r[1] }
|
|
2833
2962
|
};
|
|
2834
2963
|
}
|
|
2835
2964
|
}
|
|
2836
2965
|
let l1 = typeof a == 'number' ? {
|
|
2837
2966
|
typ: exports.EnumToken.FractionTokenType,
|
|
2838
|
-
l: { typ: exports.EnumToken.NumberTokenType, val:
|
|
2839
|
-
r: { typ: exports.EnumToken.NumberTokenType, val:
|
|
2967
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: a },
|
|
2968
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: 1 }
|
|
2840
2969
|
} : a;
|
|
2841
2970
|
let r1 = typeof b == 'number' ? {
|
|
2842
2971
|
typ: exports.EnumToken.FractionTokenType,
|
|
2843
|
-
l: { typ: exports.EnumToken.NumberTokenType, val:
|
|
2844
|
-
r: { typ: exports.EnumToken.NumberTokenType, val:
|
|
2972
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: b },
|
|
2973
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: 1 }
|
|
2845
2974
|
} : b;
|
|
2846
2975
|
let l2;
|
|
2847
2976
|
let r2;
|
|
@@ -2879,8 +3008,8 @@
|
|
|
2879
3008
|
const result = a2[0] / a2[1];
|
|
2880
3009
|
return minifyNumber(result).length <= minifyNumber(a2[0]).length + 1 + minifyNumber(a2[1]).length ? result : {
|
|
2881
3010
|
typ: exports.EnumToken.FractionTokenType,
|
|
2882
|
-
l: { typ: exports.EnumToken.NumberTokenType, val:
|
|
2883
|
-
r: { typ: exports.EnumToken.NumberTokenType, val:
|
|
3011
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: a2[0] },
|
|
3012
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: a2[1] }
|
|
2884
3013
|
};
|
|
2885
3014
|
}
|
|
2886
3015
|
function rem(...a) {
|
|
@@ -2923,12 +3052,7 @@
|
|
|
2923
3052
|
});
|
|
2924
3053
|
return evaluateFunc(tokens[0]);
|
|
2925
3054
|
}
|
|
2926
|
-
// try {
|
|
2927
3055
|
nodes = inlineExpression$1(evaluateExpression(buildExpression(tokens)));
|
|
2928
|
-
// } catch (e) {
|
|
2929
|
-
//
|
|
2930
|
-
// return tokens;
|
|
2931
|
-
// }
|
|
2932
3056
|
if (nodes.length <= 1) {
|
|
2933
3057
|
if (nodes.length == 1) {
|
|
2934
3058
|
if (nodes[0].typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
@@ -2939,7 +3063,7 @@
|
|
|
2939
3063
|
return [{
|
|
2940
3064
|
...nodes[0],
|
|
2941
3065
|
// @ts-ignore
|
|
2942
|
-
val:
|
|
3066
|
+
val: Math[nodes[0].val.toUpperCase()],
|
|
2943
3067
|
typ: exports.EnumToken.NumberTokenType
|
|
2944
3068
|
}];
|
|
2945
3069
|
}
|
|
@@ -2959,7 +3083,7 @@
|
|
|
2959
3083
|
token = { typ: exports.EnumToken.ListToken, chi: [nodes[i], nodes[i + 1]] };
|
|
2960
3084
|
}
|
|
2961
3085
|
else {
|
|
2962
|
-
token = doEvaluate(nodes[i + 1], { typ: exports.EnumToken.NumberTokenType, val:
|
|
3086
|
+
token = doEvaluate(nodes[i + 1], { typ: exports.EnumToken.NumberTokenType, val: -1 }, exports.EnumToken.Mul);
|
|
2963
3087
|
}
|
|
2964
3088
|
i++;
|
|
2965
3089
|
}
|
|
@@ -2974,7 +3098,7 @@
|
|
|
2974
3098
|
const token = curr[1].reduce((acc, curr) => doEvaluate(acc, curr, exports.EnumToken.Add));
|
|
2975
3099
|
if (token.typ != exports.EnumToken.BinaryExpressionTokenType) {
|
|
2976
3100
|
if ('val' in token && +token.val < 0) {
|
|
2977
|
-
acc.push({ typ: exports.EnumToken.Sub }, { ...token, val:
|
|
3101
|
+
acc.push({ typ: exports.EnumToken.Sub }, { ...token, val: -token.val });
|
|
2978
3102
|
return acc;
|
|
2979
3103
|
}
|
|
2980
3104
|
}
|
|
@@ -3001,73 +3125,37 @@
|
|
|
3001
3125
|
if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && 'unit' in l && 'unit' in r && l.unit != r.unit)) {
|
|
3002
3126
|
return defaultReturn;
|
|
3003
3127
|
}
|
|
3004
|
-
// if (l.typ == EnumToken.FunctionTokenType) {
|
|
3005
|
-
//
|
|
3006
|
-
// const val: Token[] = evaluateFunc(l as FunctionToken);
|
|
3007
|
-
//
|
|
3008
|
-
// if (val.length == 1) {
|
|
3009
|
-
//
|
|
3010
|
-
// l = val[0];
|
|
3011
|
-
// } else {
|
|
3012
|
-
//
|
|
3013
|
-
// return defaultReturn;
|
|
3014
|
-
// }
|
|
3015
|
-
// }
|
|
3016
3128
|
if (r.typ == exports.EnumToken.FunctionTokenType) {
|
|
3017
3129
|
const val = evaluateFunc(r);
|
|
3018
3130
|
if (val.length == 1) {
|
|
3019
3131
|
r = val[0];
|
|
3020
3132
|
}
|
|
3021
|
-
// else {
|
|
3022
|
-
//
|
|
3023
|
-
// return defaultReturn;
|
|
3024
|
-
// }
|
|
3025
3133
|
}
|
|
3026
|
-
// if (l.typ == EnumToken.FunctionTokenType) {
|
|
3027
|
-
//
|
|
3028
|
-
// const val = evaluateFunc(l as FunctionToken);
|
|
3029
|
-
//
|
|
3030
|
-
// if (val.length == 1) {
|
|
3031
|
-
//
|
|
3032
|
-
// l = val[0];
|
|
3033
|
-
// }
|
|
3034
|
-
// }
|
|
3035
3134
|
if ((op == exports.EnumToken.Add || op == exports.EnumToken.Sub)) {
|
|
3036
3135
|
// @ts-ignore
|
|
3037
3136
|
if (l.typ != r.typ) {
|
|
3038
3137
|
return defaultReturn;
|
|
3039
3138
|
}
|
|
3040
3139
|
}
|
|
3041
|
-
// else if (
|
|
3042
|
-
// op == EnumToken.Mul &&
|
|
3043
|
-
// ![EnumToken.NumberTokenType, EnumToken.PercentageTokenType].includes(l.typ) &&
|
|
3044
|
-
// ![EnumToken.NumberTokenType, EnumToken.PercentageTokenType].includes(r.typ)) {
|
|
3045
|
-
//
|
|
3046
|
-
// return defaultReturn;
|
|
3047
|
-
// }
|
|
3048
3140
|
let typ = l.typ == exports.EnumToken.NumberTokenType ? r.typ : (r.typ == exports.EnumToken.NumberTokenType ? l.typ : (l.typ == exports.EnumToken.PercentageTokenType ? r.typ : l.typ));
|
|
3049
3141
|
// @ts-ignore
|
|
3050
3142
|
let v1 = l.val?.typ == exports.EnumToken.FractionTokenType ? l.val : getValue$1(l);
|
|
3051
3143
|
// @ts-ignore
|
|
3052
3144
|
let v2 = r.val?.typ == exports.EnumToken.FractionTokenType ? r.val : getValue$1(r);
|
|
3053
|
-
// if (v1 == null || v2 == null) {
|
|
3054
|
-
//
|
|
3055
|
-
// return defaultReturn;
|
|
3056
|
-
// }
|
|
3057
3145
|
if (op == exports.EnumToken.Mul) {
|
|
3058
3146
|
if (l.typ != exports.EnumToken.NumberTokenType && r.typ != exports.EnumToken.NumberTokenType) {
|
|
3059
3147
|
if (typeof v1 == 'number' && l.typ == exports.EnumToken.PercentageTokenType) {
|
|
3060
3148
|
v1 = {
|
|
3061
3149
|
typ: exports.EnumToken.FractionTokenType,
|
|
3062
|
-
l: { typ: exports.EnumToken.NumberTokenType, val:
|
|
3063
|
-
r: { typ: exports.EnumToken.NumberTokenType, val:
|
|
3150
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: v1 },
|
|
3151
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: 100 }
|
|
3064
3152
|
};
|
|
3065
3153
|
}
|
|
3066
3154
|
else if (typeof v2 == 'number' && r.typ == exports.EnumToken.PercentageTokenType) {
|
|
3067
3155
|
v2 = {
|
|
3068
3156
|
typ: exports.EnumToken.FractionTokenType,
|
|
3069
|
-
l: { typ: exports.EnumToken.NumberTokenType, val:
|
|
3070
|
-
r: { typ: exports.EnumToken.NumberTokenType, val:
|
|
3157
|
+
l: { typ: exports.EnumToken.NumberTokenType, val: v2 },
|
|
3158
|
+
r: { typ: exports.EnumToken.NumberTokenType, val: 100 }
|
|
3071
3159
|
};
|
|
3072
3160
|
}
|
|
3073
3161
|
}
|
|
@@ -3077,7 +3165,7 @@
|
|
|
3077
3165
|
const token = {
|
|
3078
3166
|
...(l.typ == exports.EnumToken.NumberTokenType ? r : l),
|
|
3079
3167
|
typ,
|
|
3080
|
-
val: typeof val == 'number' ? minifyNumber(val) : val
|
|
3168
|
+
val /* : typeof val == 'number' ? minifyNumber(val) : val */
|
|
3081
3169
|
};
|
|
3082
3170
|
if (token.typ == exports.EnumToken.IdenTokenType) {
|
|
3083
3171
|
// @ts-ignore
|
|
@@ -3086,26 +3174,10 @@
|
|
|
3086
3174
|
return token;
|
|
3087
3175
|
}
|
|
3088
3176
|
function getValue$1(t) {
|
|
3089
|
-
// if (t.typ == EnumToken.FunctionTokenType) {
|
|
3090
|
-
//
|
|
3091
|
-
// v1 = evaluateFunc(t as FunctionToken);
|
|
3092
|
-
//
|
|
3093
|
-
// if (v1.length != 1 || v1[0].typ == EnumToken.BinaryExpressionTokenType) {
|
|
3094
|
-
//
|
|
3095
|
-
// return null;
|
|
3096
|
-
// }
|
|
3097
|
-
//
|
|
3098
|
-
// t = v1[0] as NumberToken | IdentToken;
|
|
3099
|
-
// }
|
|
3100
3177
|
if (t.typ == exports.EnumToken.IdenTokenType) {
|
|
3101
3178
|
// @ts-ignore
|
|
3102
3179
|
return Math[t.val.toUpperCase()];
|
|
3103
3180
|
}
|
|
3104
|
-
// if ((t.val as FractionToken).typ == EnumToken.FractionTokenType) {
|
|
3105
|
-
//
|
|
3106
|
-
// // @ts-ignore
|
|
3107
|
-
// return (t.val as FractionToken).l.val / (t.val as FractionToken).r.val;
|
|
3108
|
-
// }
|
|
3109
3181
|
// @ts-ignore
|
|
3110
3182
|
return t.typ == exports.EnumToken.FractionTokenType ? t.l.val / t.r.val : +t.val;
|
|
3111
3183
|
}
|
|
@@ -3123,15 +3195,11 @@
|
|
|
3123
3195
|
case 'sqrt':
|
|
3124
3196
|
case 'exp': {
|
|
3125
3197
|
const value = evaluate(values);
|
|
3126
|
-
// if (value.length != 1 || (value[0].typ != EnumToken.NumberTokenType && value[0].typ != EnumToken.FractionTokenType) || (value[0].typ == EnumToken.FractionTokenType && (+(value[0] as FractionToken).r.val == 0 || !Number.isFinite(+(value[0] as FractionToken).l.val) || !Number.isFinite(+(value[0] as FractionToken).r.val)))) {
|
|
3127
|
-
//
|
|
3128
|
-
// return value;
|
|
3129
|
-
// }
|
|
3130
3198
|
// @ts-ignore
|
|
3131
3199
|
let val = value[0].typ == exports.EnumToken.NumberTokenType ? +value[0].val : value[0].l.val / value[0].r.val;
|
|
3132
3200
|
return [{
|
|
3133
3201
|
typ: exports.EnumToken.NumberTokenType,
|
|
3134
|
-
val:
|
|
3202
|
+
val: Math[token.val](val)
|
|
3135
3203
|
}];
|
|
3136
3204
|
}
|
|
3137
3205
|
case 'hypot': {
|
|
@@ -3139,29 +3207,16 @@
|
|
|
3139
3207
|
let all = [];
|
|
3140
3208
|
let ref = chi[0];
|
|
3141
3209
|
let value = 0;
|
|
3142
|
-
// if (![EnumToken.NumberTokenType, EnumToken.PercentageTokenType].includes(ref.typ) && !('unit' in ref)) {
|
|
3143
|
-
//
|
|
3144
|
-
// return [token];
|
|
3145
|
-
// }
|
|
3146
3210
|
for (let i = 0; i < chi.length; i++) {
|
|
3147
|
-
// @ts-ignore
|
|
3148
|
-
// if (chi[i].typ != ref.typ || ('unit' in chi[i] && 'unit' in ref && chi[i].unit != ref.unit)) {
|
|
3149
|
-
//
|
|
3150
|
-
// return [token];
|
|
3151
|
-
// }
|
|
3152
3211
|
// @ts-ignore
|
|
3153
3212
|
const val = getValue$1(chi[i]);
|
|
3154
|
-
// if (val == null) {
|
|
3155
|
-
//
|
|
3156
|
-
// return [token];
|
|
3157
|
-
// }
|
|
3158
3213
|
all.push(val);
|
|
3159
3214
|
value += val * val;
|
|
3160
3215
|
}
|
|
3161
3216
|
return [
|
|
3162
3217
|
{
|
|
3163
3218
|
...ref,
|
|
3164
|
-
val: Math.sqrt(value).toFixed(rem(...all))
|
|
3219
|
+
val: +(Math.sqrt(value).toFixed(rem(...all)))
|
|
3165
3220
|
}
|
|
3166
3221
|
];
|
|
3167
3222
|
}
|
|
@@ -3170,48 +3225,18 @@
|
|
|
3170
3225
|
case 'rem':
|
|
3171
3226
|
case 'mod': {
|
|
3172
3227
|
const chi = values.filter(t => ![exports.EnumToken.WhitespaceTokenType, exports.EnumToken.CommentTokenType].includes(t.typ));
|
|
3173
|
-
// if (chi.length != 3 || chi[1].typ != EnumToken.CommaTokenType) {
|
|
3174
|
-
//
|
|
3175
|
-
// return [token];
|
|
3176
|
-
// }
|
|
3177
|
-
// if (token.val == 'pow' && (chi[0].typ != EnumToken.NumberTokenType || chi[2].typ != EnumToken.NumberTokenType)) {
|
|
3178
|
-
//
|
|
3179
|
-
// return [token];
|
|
3180
|
-
// }
|
|
3181
|
-
// if (['rem', 'mod'].includes(token.val) &&
|
|
3182
|
-
// (
|
|
3183
|
-
// chi[0].typ != chi[2].typ) || (
|
|
3184
|
-
// 'unit' in chi[0] && 'unit' in chi[2] &&
|
|
3185
|
-
// chi[0].unit != chi[2].unit
|
|
3186
|
-
// )) {
|
|
3187
|
-
//
|
|
3188
|
-
// return [token];
|
|
3189
|
-
// }
|
|
3190
3228
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/mod
|
|
3191
3229
|
const v1 = evaluate([chi[0]]);
|
|
3192
3230
|
const v2 = evaluate([chi[2]]);
|
|
3193
|
-
[exports.EnumToken.PercentageTokenType, exports.EnumToken.DimensionTokenType, exports.EnumToken.AngleTokenType, exports.EnumToken.NumberTokenType, exports.EnumToken.LengthTokenType, exports.EnumToken.TimeTokenType, exports.EnumToken.FrequencyTokenType, exports.EnumToken.ResolutionTokenType];
|
|
3194
|
-
// if (v1.length != 1 || v2.length != 1 || !types.includes(v1[0].typ) || !types.includes(v2[0].typ) || (v1[0] as DimensionToken).unit != (v2[0] as DimensionToken).unit) {
|
|
3195
|
-
//
|
|
3196
|
-
// return [token];
|
|
3197
|
-
// }
|
|
3198
3231
|
// @ts-ignore
|
|
3199
3232
|
const val1 = getValue$1(v1[0]);
|
|
3200
3233
|
// @ts-ignore
|
|
3201
3234
|
const val2 = getValue$1(v2[0]);
|
|
3202
|
-
// if (val1 == null || val2 == null || (v1[0].typ != v2[0].typ && val1 != 0 && val2 != 0)) {
|
|
3203
|
-
//
|
|
3204
|
-
// return [token];
|
|
3205
|
-
// }
|
|
3206
3235
|
if (token.val == 'rem') {
|
|
3207
|
-
// if (val2 == 0) {
|
|
3208
|
-
//
|
|
3209
|
-
// return [token];
|
|
3210
|
-
// }
|
|
3211
3236
|
return [
|
|
3212
3237
|
{
|
|
3213
3238
|
...v1[0],
|
|
3214
|
-
val: (val1 % val2).toFixed(rem(val1, val2))
|
|
3239
|
+
val: +((val1 % val2).toFixed(rem(val1, val2)))
|
|
3215
3240
|
}
|
|
3216
3241
|
];
|
|
3217
3242
|
}
|
|
@@ -3219,7 +3244,7 @@
|
|
|
3219
3244
|
return [
|
|
3220
3245
|
{
|
|
3221
3246
|
...v1[0],
|
|
3222
|
-
val:
|
|
3247
|
+
val: Math.pow(val1, val2)
|
|
3223
3248
|
}
|
|
3224
3249
|
];
|
|
3225
3250
|
}
|
|
@@ -3227,14 +3252,14 @@
|
|
|
3227
3252
|
return [
|
|
3228
3253
|
{
|
|
3229
3254
|
...{}, ...v1[0],
|
|
3230
|
-
val:
|
|
3255
|
+
val: Math.atan2(val1, val2)
|
|
3231
3256
|
}
|
|
3232
3257
|
];
|
|
3233
3258
|
}
|
|
3234
3259
|
return [
|
|
3235
3260
|
{
|
|
3236
3261
|
...v1[0],
|
|
3237
|
-
val:
|
|
3262
|
+
val: val2 == 0 ? val1 : val1 - (Math.floor(val1 / val2) * val2)
|
|
3238
3263
|
}
|
|
3239
3264
|
];
|
|
3240
3265
|
}
|
|
@@ -3252,10 +3277,6 @@
|
|
|
3252
3277
|
continue;
|
|
3253
3278
|
}
|
|
3254
3279
|
const result = evaluate([curr]);
|
|
3255
|
-
// if (result.length != 1 || result[0].typ == EnumToken.FunctionTokenType) {
|
|
3256
|
-
//
|
|
3257
|
-
// return [token];
|
|
3258
|
-
// }
|
|
3259
3280
|
const key = result[0].typ + ('unit' in result[0] ? result[0].unit : '');
|
|
3260
3281
|
if (!valuesMap.has(key)) {
|
|
3261
3282
|
valuesMap.set(key, []);
|
|
@@ -3265,24 +3286,12 @@
|
|
|
3265
3286
|
if (valuesMap.size == 1) {
|
|
3266
3287
|
const values = valuesMap.values().next().value;
|
|
3267
3288
|
if (token.val == 'log') {
|
|
3268
|
-
// if (values[0].typ != EnumToken.NumberTokenType || values.length > 2) {
|
|
3269
|
-
//
|
|
3270
|
-
// return [token];
|
|
3271
|
-
// }
|
|
3272
3289
|
const val1 = getValue$1(values[0]);
|
|
3273
3290
|
const val2 = values.length == 2 ? getValue$1(values[1]) : null;
|
|
3274
|
-
// if (values.length == 1) {
|
|
3275
|
-
//
|
|
3276
|
-
// return [
|
|
3277
|
-
// {
|
|
3278
|
-
// ...values[0],
|
|
3279
|
-
// val: String(Math.log(val1))
|
|
3280
|
-
// } as DimensionToken | AngleToken | NumberToken | LengthToken | TimeToken | FrequencyToken | ResolutionToken];
|
|
3281
|
-
// }
|
|
3282
3291
|
return [
|
|
3283
3292
|
{
|
|
3284
3293
|
...values[0],
|
|
3285
|
-
val:
|
|
3294
|
+
val: Math.log(val1) / Math.log(val2)
|
|
3286
3295
|
}
|
|
3287
3296
|
];
|
|
3288
3297
|
}
|
|
@@ -3306,10 +3315,6 @@
|
|
|
3306
3315
|
if (token.val == 'round') {
|
|
3307
3316
|
let val = getValue$1(values[0]);
|
|
3308
3317
|
let val2 = getValue$1(values[1]);
|
|
3309
|
-
// if (Number.isNaN(val) || Number.isNaN(val2)) {
|
|
3310
|
-
//
|
|
3311
|
-
// return [token];
|
|
3312
|
-
// }
|
|
3313
3318
|
if (strategy == null || strategy == 'down') {
|
|
3314
3319
|
val = val - (val % val2);
|
|
3315
3320
|
}
|
|
@@ -3317,11 +3322,10 @@
|
|
|
3317
3322
|
val = strategy == 'to-zero' ? Math.trunc(val / val2) * val2 : (strategy == 'nearest' ? Math.round(val / val2) * val2 : Math.ceil(val / val2) * val2);
|
|
3318
3323
|
}
|
|
3319
3324
|
// @ts-ignore
|
|
3320
|
-
return [{ ...values[0], val
|
|
3325
|
+
return [{ ...values[0], val }];
|
|
3321
3326
|
}
|
|
3322
3327
|
}
|
|
3323
3328
|
}
|
|
3324
|
-
// return [token];
|
|
3325
3329
|
}
|
|
3326
3330
|
return [token];
|
|
3327
3331
|
}
|
|
@@ -3331,10 +3335,6 @@
|
|
|
3331
3335
|
*/
|
|
3332
3336
|
function inlineExpression$1(token) {
|
|
3333
3337
|
const result = [];
|
|
3334
|
-
// if (token.typ == EnumToken.ParensTokenType && (token as ParensToken).chi.length == 1) {
|
|
3335
|
-
//
|
|
3336
|
-
// result.push((token as ParensToken).chi[0]);
|
|
3337
|
-
// } else
|
|
3338
3338
|
if (token.typ == exports.EnumToken.BinaryExpressionTokenType) {
|
|
3339
3339
|
if ([exports.EnumToken.Mul, exports.EnumToken.Div].includes(token.op)) {
|
|
3340
3340
|
result.push(token);
|
|
@@ -3373,7 +3373,7 @@
|
|
|
3373
3373
|
}
|
|
3374
3374
|
/**
|
|
3375
3375
|
*
|
|
3376
|
-
* generate binary expression tree
|
|
3376
|
+
* generate a binary expression tree
|
|
3377
3377
|
* @param tokens
|
|
3378
3378
|
*/
|
|
3379
3379
|
function buildExpression(tokens) {
|
|
@@ -3393,7 +3393,7 @@
|
|
|
3393
3393
|
}
|
|
3394
3394
|
/**
|
|
3395
3395
|
*
|
|
3396
|
-
* generate binary expression tree
|
|
3396
|
+
* generate a binary expression tree
|
|
3397
3397
|
* @param token
|
|
3398
3398
|
*/
|
|
3399
3399
|
function factorToken(token) {
|
|
@@ -3408,7 +3408,7 @@
|
|
|
3408
3408
|
return token;
|
|
3409
3409
|
}
|
|
3410
3410
|
/**
|
|
3411
|
-
* generate binary expression tree
|
|
3411
|
+
* generate a binary expression tree
|
|
3412
3412
|
* @param tokens
|
|
3413
3413
|
* @param ops
|
|
3414
3414
|
*/
|
|
@@ -3499,7 +3499,7 @@
|
|
|
3499
3499
|
}
|
|
3500
3500
|
return {
|
|
3501
3501
|
typ: exports.EnumToken.NumberTokenType,
|
|
3502
|
-
val:
|
|
3502
|
+
val: value
|
|
3503
3503
|
};
|
|
3504
3504
|
}
|
|
3505
3505
|
return t;
|
|
@@ -3689,11 +3689,11 @@
|
|
|
3689
3689
|
chi: values.reduce((acc, curr, index) => index < 4 ? [...acc, {
|
|
3690
3690
|
typ: exports.EnumToken.PercentageTokenType,
|
|
3691
3691
|
// @ts-ignore
|
|
3692
|
-
val:
|
|
3692
|
+
val: curr * 100
|
|
3693
3693
|
}] : [...acc, {
|
|
3694
3694
|
typ: exports.EnumToken.LiteralTokenType,
|
|
3695
3695
|
val: '/'
|
|
3696
|
-
}, { typ: exports.EnumToken.PercentageTokenType, val:
|
|
3696
|
+
}, { typ: exports.EnumToken.PercentageTokenType, val: curr * 100 }], []),
|
|
3697
3697
|
kin: exports.ColorType.DEVICE_CMYK
|
|
3698
3698
|
};
|
|
3699
3699
|
}
|
|
@@ -3753,7 +3753,7 @@
|
|
|
3753
3753
|
}
|
|
3754
3754
|
|
|
3755
3755
|
/**
|
|
3756
|
-
* Converts a color
|
|
3756
|
+
* Converts a color to another color space
|
|
3757
3757
|
* @param token
|
|
3758
3758
|
* @param to
|
|
3759
3759
|
*/
|
|
@@ -3761,7 +3761,7 @@
|
|
|
3761
3761
|
if (token.kin == exports.ColorType.SYS ||
|
|
3762
3762
|
token.kin == exports.ColorType.DPSYS ||
|
|
3763
3763
|
(isIdentColor(token) &&
|
|
3764
|
-
|
|
3764
|
+
'currentcolor' == token.val.toLowerCase())) {
|
|
3765
3765
|
return token;
|
|
3766
3766
|
}
|
|
3767
3767
|
if (token.kin == exports.ColorType.COLOR_MIX && to != exports.ColorType.COLOR_MIX) {
|
|
@@ -4230,14 +4230,14 @@
|
|
|
4230
4230
|
function values2colortoken(values, to) {
|
|
4231
4231
|
values = srgb2srgbcolorspace(values, to);
|
|
4232
4232
|
const chi = [
|
|
4233
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
4234
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
4235
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
4233
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
4234
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
4235
|
+
{ typ: exports.EnumToken.NumberTokenType, val: values[2] },
|
|
4236
4236
|
];
|
|
4237
4237
|
if (values.length == 4) {
|
|
4238
4238
|
chi.push({ typ: exports.EnumToken.LiteralTokenType, val: "/" }, {
|
|
4239
4239
|
typ: exports.EnumToken.PercentageTokenType,
|
|
4240
|
-
val:
|
|
4240
|
+
val: values[3] * 100
|
|
4241
4241
|
});
|
|
4242
4242
|
}
|
|
4243
4243
|
const colorSpace = exports.ColorType[to].toLowerCase().replaceAll('_', '-');
|
|
@@ -4258,7 +4258,7 @@
|
|
|
4258
4258
|
return 0;
|
|
4259
4259
|
}
|
|
4260
4260
|
// @ts-ignore
|
|
4261
|
-
return token.typ == exports.EnumToken.PercentageTokenType ? token.val / 100 :
|
|
4261
|
+
return token.typ == exports.EnumToken.PercentageTokenType ? token.val / 100 : token.val;
|
|
4262
4262
|
}
|
|
4263
4263
|
/**
|
|
4264
4264
|
* convert angle to turn
|
|
@@ -4711,7 +4711,7 @@
|
|
|
4711
4711
|
if (Array.isArray(token.chi)) {
|
|
4712
4712
|
const isLegacy = ['rgb', 'rgba', 'hsl', 'hsla'].includes(token.val.toLowerCase());
|
|
4713
4713
|
const useAlpha = (['rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'oklab', 'oklch', 'lab', 'lch'].includes(token.val.toLowerCase()) && token.chi.length == 4) ||
|
|
4714
|
-
('color'
|
|
4714
|
+
('color' == token.val.toLowerCase() && token.chi.length == 5);
|
|
4715
4715
|
return (token.val.endsWith('a') ? token.val.slice(0, -1) : token.val) + '(' + token.chi.reduce((acc, curr, index, array) => {
|
|
4716
4716
|
if (/[,/]\s*$/.test(acc)) {
|
|
4717
4717
|
if (curr.typ == exports.EnumToken.WhitespaceTokenType) {
|
|
@@ -4908,32 +4908,41 @@
|
|
|
4908
4908
|
return token.val.slice(1);
|
|
4909
4909
|
}
|
|
4910
4910
|
case exports.EnumToken.UrlTokenTokenType:
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4911
|
+
// if (token.typ == EnumToken.UrlTokenTokenType) {
|
|
4912
|
+
//
|
|
4913
|
+
// if (options.output != null) {
|
|
4914
|
+
//
|
|
4915
|
+
// if (!('original' in token)) {
|
|
4916
|
+
//
|
|
4917
|
+
// // do not modify original token
|
|
4918
|
+
// token = {...token};
|
|
4919
|
+
// Object.defineProperty(token, 'original', {
|
|
4920
|
+
// enumerable: false,
|
|
4921
|
+
// writable: false,
|
|
4922
|
+
// value: (token as UrlToken).val
|
|
4923
|
+
// })
|
|
4924
|
+
// }
|
|
4925
|
+
//
|
|
4926
|
+
// // @ts-ignore
|
|
4927
|
+
// if (!(token.original in cache)) {
|
|
4928
|
+
//
|
|
4929
|
+
// let output: string = <string>options.output ?? '';
|
|
4930
|
+
// const key = output + 'abs';
|
|
4931
|
+
//
|
|
4932
|
+
// if (!(key in cache)) {
|
|
4933
|
+
//
|
|
4934
|
+
// // @ts-ignore
|
|
4935
|
+
// cache[key] = options.dirname(options.resolve(output, options.cwd).absolute);
|
|
4936
|
+
// }
|
|
4937
|
+
//
|
|
4938
|
+
// // @ts-ignore
|
|
4939
|
+
// cache[token.original] = options.resolve(token.original, cache[key]).relative;
|
|
4940
|
+
// }
|
|
4941
|
+
//
|
|
4942
|
+
// // @ts-ignore
|
|
4943
|
+
// token.val = cache[token.original];
|
|
4944
|
+
// }
|
|
4945
|
+
// }
|
|
4937
4946
|
case exports.EnumToken.HashTokenType:
|
|
4938
4947
|
case exports.EnumToken.IdenTokenType:
|
|
4939
4948
|
case exports.EnumToken.AtRuleTokenType:
|
|
@@ -5471,18 +5480,18 @@
|
|
|
5471
5480
|
}
|
|
5472
5481
|
function isHueInterpolationMethod(token) {
|
|
5473
5482
|
if (!Array.isArray(token)) {
|
|
5474
|
-
return token.typ == exports.EnumToken.IdenTokenType && 'hue'
|
|
5483
|
+
return token.typ == exports.EnumToken.IdenTokenType && 'hue' === token.val?.toLowerCase?.();
|
|
5475
5484
|
}
|
|
5476
5485
|
if (token.length != 2 || token[0].typ != exports.EnumToken.IdenTokenType || token[1].typ != exports.EnumToken.IdenTokenType) {
|
|
5477
5486
|
return false;
|
|
5478
5487
|
}
|
|
5479
|
-
return ['shorter', 'longer', 'increasing', 'decreasing'].includes(token[0].val) && 'hue'
|
|
5488
|
+
return ['shorter', 'longer', 'increasing', 'decreasing'].includes(token[0].val?.toLowerCase?.()) && 'hue' === token[1].val?.toLowerCase?.();
|
|
5480
5489
|
}
|
|
5481
5490
|
function isIdentColor(token) {
|
|
5482
5491
|
return token.typ == exports.EnumToken.ColorTokenType && [exports.ColorType.SYS, exports.ColorType.DPSYS, exports.ColorType.LIT].includes(token.kin) && isIdent(token.val);
|
|
5483
5492
|
}
|
|
5484
5493
|
function isPercentageToken(token) {
|
|
5485
|
-
return token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
5494
|
+
return token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0);
|
|
5486
5495
|
}
|
|
5487
5496
|
function isColor(token) {
|
|
5488
5497
|
if (token.typ == exports.EnumToken.ColorTokenType) {
|
|
@@ -5593,7 +5602,7 @@
|
|
|
5593
5602
|
if (children.length == 3) {
|
|
5594
5603
|
if (children[0].length > 4 ||
|
|
5595
5604
|
children[0][0].typ != exports.EnumToken.IdenTokenType ||
|
|
5596
|
-
'in'
|
|
5605
|
+
'in' !== children[0][0].val?.toLowerCase?.() ||
|
|
5597
5606
|
!isColorspace(children[0][1]) ||
|
|
5598
5607
|
(children[0].length >= 3 && !isHueInterpolationMethod(children[0].slice(2))) ||
|
|
5599
5608
|
children[1].length > 2 ||
|
|
@@ -5605,12 +5614,12 @@
|
|
|
5605
5614
|
return false;
|
|
5606
5615
|
}
|
|
5607
5616
|
if (children[1].length == 2) {
|
|
5608
|
-
if (!(children[1][1].typ == exports.EnumToken.PercentageTokenType || (children[1][1].typ == exports.EnumToken.NumberTokenType && children[1][1].val ==
|
|
5617
|
+
if (!(children[1][1].typ == exports.EnumToken.PercentageTokenType || (children[1][1].typ == exports.EnumToken.NumberTokenType && children[1][1].val == 0))) {
|
|
5609
5618
|
return false;
|
|
5610
5619
|
}
|
|
5611
5620
|
}
|
|
5612
5621
|
if (children[2].length == 2) {
|
|
5613
|
-
if (!(children[2][1].typ == exports.EnumToken.PercentageTokenType || (children[2][1].typ == exports.EnumToken.NumberTokenType && children[2][1].val ==
|
|
5622
|
+
if (!(children[2][1].typ == exports.EnumToken.PercentageTokenType || (children[2][1].typ == exports.EnumToken.NumberTokenType && children[2][1].val == 0))) {
|
|
5614
5623
|
return false;
|
|
5615
5624
|
}
|
|
5616
5625
|
}
|
|
@@ -5754,15 +5763,6 @@
|
|
|
5754
5763
|
}
|
|
5755
5764
|
return true;
|
|
5756
5765
|
}
|
|
5757
|
-
function isNonPrintable(codepoint) {
|
|
5758
|
-
// null -> backspace
|
|
5759
|
-
return (codepoint >= 0 && codepoint <= 0x8) ||
|
|
5760
|
-
// tab
|
|
5761
|
-
codepoint == 0xb ||
|
|
5762
|
-
// delete
|
|
5763
|
-
codepoint == 0x7f ||
|
|
5764
|
-
(codepoint >= 0xe && codepoint <= 0x1f);
|
|
5765
|
-
}
|
|
5766
5766
|
function isPseudo(name) {
|
|
5767
5767
|
return name.charAt(0) == ':' &&
|
|
5768
5768
|
((name.endsWith('(') && isIdent(name.charAt(1) == ':' ? name.slice(2, -1) : name.slice(1, -1))) ||
|
|
@@ -5869,7 +5869,7 @@
|
|
|
5869
5869
|
}
|
|
5870
5870
|
const dimension = {
|
|
5871
5871
|
typ: exports.EnumToken.DimensionTokenType,
|
|
5872
|
-
val: name.slice(0, index),
|
|
5872
|
+
val: +name.slice(0, index),
|
|
5873
5873
|
unit: name.slice(index)
|
|
5874
5874
|
};
|
|
5875
5875
|
if (isAngle(dimension)) {
|
|
@@ -5972,7 +5972,7 @@
|
|
|
5972
5972
|
* @param val
|
|
5973
5973
|
*/
|
|
5974
5974
|
function minifyNumber(val) {
|
|
5975
|
-
val = String(
|
|
5975
|
+
val = String(val);
|
|
5976
5976
|
if (val === '0') {
|
|
5977
5977
|
return '0';
|
|
5978
5978
|
}
|
|
@@ -7473,7 +7473,7 @@
|
|
|
7473
7473
|
(properties.types.some((t) => exports.EnumToken[t] == val.typ))) {
|
|
7474
7474
|
return true;
|
|
7475
7475
|
}
|
|
7476
|
-
if (val.typ == exports.EnumToken.NumberTokenType && val.val ==
|
|
7476
|
+
if (val.typ == exports.EnumToken.NumberTokenType && val.val == 0) {
|
|
7477
7477
|
// @ts-ignore
|
|
7478
7478
|
return properties.types.some((type) => {
|
|
7479
7479
|
// @ts-ignore
|
|
@@ -7966,8 +7966,6 @@
|
|
|
7966
7966
|
value = peek(parseInfo);
|
|
7967
7967
|
// let cp: number;
|
|
7968
7968
|
let whitespace = '';
|
|
7969
|
-
let hasWhiteSpace = false;
|
|
7970
|
-
let errorState = false;
|
|
7971
7969
|
if (value == '"' || value == "'") {
|
|
7972
7970
|
const quote = value;
|
|
7973
7971
|
let inquote = true;
|
|
@@ -8007,7 +8005,6 @@
|
|
|
8007
8005
|
if (isWhiteSpace(charCode)) {
|
|
8008
8006
|
whitespace += value;
|
|
8009
8007
|
while (value = peek(parseInfo)) {
|
|
8010
|
-
hasWhiteSpace = true;
|
|
8011
8008
|
if (isWhiteSpace(value?.charCodeAt(0))) {
|
|
8012
8009
|
whitespace += next(parseInfo);
|
|
8013
8010
|
continue;
|
|
@@ -8063,42 +8060,33 @@
|
|
|
8063
8060
|
buffer = '';
|
|
8064
8061
|
break;
|
|
8065
8062
|
}
|
|
8066
|
-
if (
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
if (
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
if (charCode == 0x29) {
|
|
8094
|
-
break;
|
|
8095
|
-
}
|
|
8096
|
-
buffer += next(parseInfo);
|
|
8097
|
-
}
|
|
8098
|
-
yield pushToken(buffer, parseInfo, exports.EnumToken.BadUrlTokenType);
|
|
8099
|
-
buffer = '';
|
|
8100
|
-
break;
|
|
8101
|
-
}
|
|
8063
|
+
// if (errorState) {
|
|
8064
|
+
//
|
|
8065
|
+
// buffer += whitespace + value;
|
|
8066
|
+
//
|
|
8067
|
+
// while (value = peek(parseInfo)) {
|
|
8068
|
+
//
|
|
8069
|
+
// charCode = value.charCodeAt(0);
|
|
8070
|
+
//
|
|
8071
|
+
// if (charCode == 0x5c) {
|
|
8072
|
+
//
|
|
8073
|
+
// buffer += next(parseInfo, 2);
|
|
8074
|
+
// continue;
|
|
8075
|
+
// }
|
|
8076
|
+
//
|
|
8077
|
+
// // ')'
|
|
8078
|
+
// if (charCode == 0x29) {
|
|
8079
|
+
//
|
|
8080
|
+
// break;
|
|
8081
|
+
// }
|
|
8082
|
+
//
|
|
8083
|
+
// buffer += next(parseInfo);
|
|
8084
|
+
// }
|
|
8085
|
+
//
|
|
8086
|
+
// yield pushToken(buffer, parseInfo, EnumToken.BadUrlTokenType);
|
|
8087
|
+
// buffer = '';
|
|
8088
|
+
// break;
|
|
8089
|
+
// }
|
|
8102
8090
|
buffer += value;
|
|
8103
8091
|
}
|
|
8104
8092
|
}
|
|
@@ -12608,7 +12596,6 @@
|
|
|
12608
12596
|
typ: ValidationTokenEnum.Root,
|
|
12609
12597
|
chi: []
|
|
12610
12598
|
}, 'pos', { ...objectProperties, value: { ind: 0, lin: 1, col: 0 } });
|
|
12611
|
-
// return minify(doParseSyntax(syntaxes, tokenize(syntaxes), root)) as ValidationRootToken;
|
|
12612
12599
|
return minify$2(doParseSyntax(syntax, tokenize(syntax), root));
|
|
12613
12600
|
}
|
|
12614
12601
|
function matchParens(syntax, iterator) {
|
|
@@ -12784,10 +12771,6 @@
|
|
|
12784
12771
|
token.typ = ValidationTokenEnum.AtRule;
|
|
12785
12772
|
break;
|
|
12786
12773
|
}
|
|
12787
|
-
// if (item.value.typ != ValidationTokenEnum.Whitespace) {
|
|
12788
|
-
//
|
|
12789
|
-
// console.error('unexpected token', item.value);
|
|
12790
|
-
// }
|
|
12791
12774
|
item = iterator.next();
|
|
12792
12775
|
if (item.done) {
|
|
12793
12776
|
break;
|
|
@@ -13404,9 +13387,6 @@
|
|
|
13404
13387
|
return '{' + token.chi.reduce((acc, t) => acc + renderSyntax(t), '') + '}';
|
|
13405
13388
|
case ValidationTokenEnum.DeclarationDefinitionToken:
|
|
13406
13389
|
return token.nam + ': ' + renderSyntax(token.val);
|
|
13407
|
-
// case ValidationTokenEnum.ColumnArrayToken:
|
|
13408
|
-
//
|
|
13409
|
-
// return (token as ValidationColumnArrayToken).chi.reduce((acc: string, curr: ValidationToken) => acc + (acc.trim().length > 0 ? '||' : '') + renderSyntax(curr), '');
|
|
13410
13390
|
default:
|
|
13411
13391
|
throw new Error('Unhandled token: ' + JSON.stringify({ token }, null, 1));
|
|
13412
13392
|
}
|
|
@@ -13500,10 +13480,6 @@
|
|
|
13500
13480
|
key = matches[1] + matches[3];
|
|
13501
13481
|
}
|
|
13502
13482
|
}
|
|
13503
|
-
// if (!(key in obj)) {
|
|
13504
|
-
//
|
|
13505
|
-
// return null;
|
|
13506
|
-
// }
|
|
13507
13483
|
}
|
|
13508
13484
|
// @ts-ignore
|
|
13509
13485
|
obj = obj[key];
|
|
@@ -13605,10 +13581,6 @@
|
|
|
13605
13581
|
function stripCommaToken(tokenList) {
|
|
13606
13582
|
let result = [];
|
|
13607
13583
|
for (let i = 0; i < tokenList.length; i++) {
|
|
13608
|
-
// if (tokenList[i].typ == EnumToken.CommaTokenType && last != null && last.typ == EnumToken.CommaTokenType) {
|
|
13609
|
-
//
|
|
13610
|
-
// return null;
|
|
13611
|
-
// }
|
|
13612
13584
|
if (tokenList[i].typ != exports.EnumToken.WhitespaceTokenType) {
|
|
13613
13585
|
tokenList[i];
|
|
13614
13586
|
}
|
|
@@ -13621,10 +13593,6 @@
|
|
|
13621
13593
|
}
|
|
13622
13594
|
function splitTokenList(tokenList, split = [exports.EnumToken.CommaTokenType]) {
|
|
13623
13595
|
return tokenList.reduce((acc, curr) => {
|
|
13624
|
-
// if (curr.typ == EnumToken.CommentTokenType) {
|
|
13625
|
-
//
|
|
13626
|
-
// return acc;
|
|
13627
|
-
// }
|
|
13628
13596
|
if (split.includes(curr.typ)) {
|
|
13629
13597
|
acc.push([]);
|
|
13630
13598
|
}
|
|
@@ -13639,18 +13607,6 @@
|
|
|
13639
13607
|
let node;
|
|
13640
13608
|
tokens = tokens.slice();
|
|
13641
13609
|
consumeWhitespace(tokens);
|
|
13642
|
-
// if (tokens.length == 0) {
|
|
13643
|
-
//
|
|
13644
|
-
// // @ts-ignore
|
|
13645
|
-
// return {
|
|
13646
|
-
// valid: SyntaxValidationResult.Drop,
|
|
13647
|
-
// matches: [],
|
|
13648
|
-
// node: atRule,
|
|
13649
|
-
// syntax: null,
|
|
13650
|
-
// error: 'expected at-rule prelude',
|
|
13651
|
-
// tokens
|
|
13652
|
-
// } as ValidationSyntaxResult;
|
|
13653
|
-
// }
|
|
13654
13610
|
if (tokens.length == 0 || tokens[0].typ == exports.EnumToken.CommaTokenType) {
|
|
13655
13611
|
// @ts-ignore
|
|
13656
13612
|
return {
|
|
@@ -13663,26 +13619,6 @@
|
|
|
13663
13619
|
};
|
|
13664
13620
|
}
|
|
13665
13621
|
while (tokens.length > 0) {
|
|
13666
|
-
// @ts-ignore
|
|
13667
|
-
// if (tokens[0].typ == EnumToken.CommaTokenType) {
|
|
13668
|
-
//
|
|
13669
|
-
// node = tokens.shift() as Token;
|
|
13670
|
-
//
|
|
13671
|
-
// consumeWhitespace(tokens);
|
|
13672
|
-
//
|
|
13673
|
-
// if (tokens.length == 0) {
|
|
13674
|
-
//
|
|
13675
|
-
// // @ts-ignore
|
|
13676
|
-
// return {
|
|
13677
|
-
// valid: SyntaxValidationResult.Drop,
|
|
13678
|
-
// matches: [],
|
|
13679
|
-
// node,
|
|
13680
|
-
// syntax: null,
|
|
13681
|
-
// error: 'unexpected token',
|
|
13682
|
-
// tokens
|
|
13683
|
-
// } as ValidationSyntaxResult;
|
|
13684
|
-
// }
|
|
13685
|
-
// }
|
|
13686
13622
|
node = tokens[0];
|
|
13687
13623
|
if (![exports.EnumToken.IdenTokenType, exports.EnumToken.StringTokenType].includes(node.typ)) {
|
|
13688
13624
|
// @ts-ignore
|
|
@@ -13966,33 +13902,7 @@
|
|
|
13966
13902
|
function validateRelativeSelectorList(tokens, root, options) {
|
|
13967
13903
|
tokens = tokens.slice();
|
|
13968
13904
|
consumeWhitespace(tokens);
|
|
13969
|
-
// if (tokens.length == 0) {
|
|
13970
|
-
//
|
|
13971
|
-
// return {
|
|
13972
|
-
// valid: SyntaxValidationResult.Drop,
|
|
13973
|
-
// matches: [],
|
|
13974
|
-
// // @ts-ignore
|
|
13975
|
-
// node: root,
|
|
13976
|
-
// // @ts-ignore
|
|
13977
|
-
// syntax: null,
|
|
13978
|
-
// error: 'expecting relative selector list',
|
|
13979
|
-
// tokens
|
|
13980
|
-
// }
|
|
13981
|
-
// }
|
|
13982
13905
|
for (const t of splitTokenList(tokens)) {
|
|
13983
|
-
// if (t.length == 0) {
|
|
13984
|
-
//
|
|
13985
|
-
// return {
|
|
13986
|
-
// valid: SyntaxValidationResult.Drop,
|
|
13987
|
-
// matches: [],
|
|
13988
|
-
// // @ts-ignore
|
|
13989
|
-
// node: root,
|
|
13990
|
-
// // @ts-ignore
|
|
13991
|
-
// syntax: null,
|
|
13992
|
-
// error: 'unexpected comma',
|
|
13993
|
-
// tokens
|
|
13994
|
-
// }
|
|
13995
|
-
// }
|
|
13996
13906
|
const result = validateRelativeSelector(t, root, options);
|
|
13997
13907
|
if (result.valid == SyntaxValidationResult.Drop) {
|
|
13998
13908
|
return result;
|
|
@@ -14013,17 +13923,6 @@
|
|
|
14013
13923
|
function validateComplexSelectorList(tokens, root, options) {
|
|
14014
13924
|
tokens = tokens.slice();
|
|
14015
13925
|
consumeWhitespace(tokens);
|
|
14016
|
-
// if (tokens.length == 0) {
|
|
14017
|
-
//
|
|
14018
|
-
// return {
|
|
14019
|
-
// valid: SyntaxValidationResult.Drop,
|
|
14020
|
-
// context: [],
|
|
14021
|
-
// // @ts-ignore
|
|
14022
|
-
// node: root,
|
|
14023
|
-
// syntax: null,
|
|
14024
|
-
// error: 'expecting complex selector list'
|
|
14025
|
-
// }
|
|
14026
|
-
// }
|
|
14027
13926
|
let result = null;
|
|
14028
13927
|
for (const t of splitTokenList(tokens)) {
|
|
14029
13928
|
result = validateSelector$1(t, root, options);
|
|
@@ -14037,17 +13936,6 @@
|
|
|
14037
13936
|
|
|
14038
13937
|
function validateKeyframeSelector(tokens, options) {
|
|
14039
13938
|
consumeWhitespace(tokens);
|
|
14040
|
-
// if (tokens.length == 0) {
|
|
14041
|
-
//
|
|
14042
|
-
// // @ts-ignore
|
|
14043
|
-
// return {
|
|
14044
|
-
// valid: SyntaxValidationResult.Drop,
|
|
14045
|
-
// context: [],
|
|
14046
|
-
// node: null,
|
|
14047
|
-
// syntax: null,
|
|
14048
|
-
// error: 'expected keyframe selector'
|
|
14049
|
-
// }
|
|
14050
|
-
// }
|
|
14051
13939
|
for (const t of splitTokenList(tokens)) {
|
|
14052
13940
|
if (t.length != 1 || (t[0].typ != exports.EnumToken.PercentageTokenType && !(t[0].typ == exports.EnumToken.IdenTokenType && ['from', 'to', 'cover', 'contain', 'entry', 'exit', 'entry-crossing', 'exit-crossing'].includes(t[0].val)))) {
|
|
14053
13941
|
return {
|
|
@@ -14100,15 +13988,8 @@
|
|
|
14100
13988
|
},
|
|
14101
13989
|
consume(token, howMany) {
|
|
14102
13990
|
let newIndex = result.indexOf(token, this.index + 1);
|
|
14103
|
-
// if (newIndex == -1 || newIndex < this.index) {
|
|
14104
|
-
// return false;
|
|
14105
|
-
// }
|
|
14106
13991
|
howMany ??= 0;
|
|
14107
13992
|
let splice = 1;
|
|
14108
|
-
// if (result[newIndex - 1]?.typ == EnumToken.WhitespaceTokenType) {
|
|
14109
|
-
// splice++;
|
|
14110
|
-
// newIndex--;
|
|
14111
|
-
// }
|
|
14112
13993
|
result.splice(this.index + 1, 0, ...result.splice(newIndex, splice + howMany));
|
|
14113
13994
|
this.index += howMany + splice;
|
|
14114
13995
|
return true;
|
|
@@ -14130,10 +14011,6 @@
|
|
|
14130
14011
|
this.index = index;
|
|
14131
14012
|
return result[this.index] ?? null;
|
|
14132
14013
|
},
|
|
14133
|
-
// tokens<Token>(): Token[] {
|
|
14134
|
-
//
|
|
14135
|
-
// return result as Token[];
|
|
14136
|
-
// },
|
|
14137
14014
|
slice() {
|
|
14138
14015
|
return result.slice(this.index + 1);
|
|
14139
14016
|
},
|
|
@@ -14141,16 +14018,7 @@
|
|
|
14141
14018
|
const context = createContext(result.slice());
|
|
14142
14019
|
context.index = this.index;
|
|
14143
14020
|
return context;
|
|
14144
|
-
}
|
|
14145
|
-
// @ts-ignore
|
|
14146
|
-
// toJSON(): object {
|
|
14147
|
-
//
|
|
14148
|
-
// return {
|
|
14149
|
-
// index: this.index,
|
|
14150
|
-
// slice: this.slice(),
|
|
14151
|
-
// tokens: this.tokens()
|
|
14152
|
-
// }
|
|
14153
|
-
// }
|
|
14021
|
+
}
|
|
14154
14022
|
};
|
|
14155
14023
|
}
|
|
14156
14024
|
function evaluateSyntax(node, options) {
|
|
@@ -14184,10 +14052,6 @@
|
|
|
14184
14052
|
if (result.valid == SyntaxValidationResult.Valid && !result.context.done()) {
|
|
14185
14053
|
let token = null;
|
|
14186
14054
|
if ((token = result.context.next()) != null) {
|
|
14187
|
-
// if (token.typ == EnumToken.WhitespaceTokenType || token.typ == EnumToken.CommentTokenType) {
|
|
14188
|
-
//
|
|
14189
|
-
// continue;
|
|
14190
|
-
// }
|
|
14191
14055
|
return {
|
|
14192
14056
|
...result,
|
|
14193
14057
|
valid: SyntaxValidationResult.Drop,
|
|
@@ -14203,13 +14067,6 @@
|
|
|
14203
14067
|
};
|
|
14204
14068
|
}
|
|
14205
14069
|
break;
|
|
14206
|
-
// case EnumToken.RuleNodeType:
|
|
14207
|
-
// case EnumToken.AtRuleNodeType:
|
|
14208
|
-
// case EnumToken.KeyframeAtRuleNodeType:
|
|
14209
|
-
// case EnumToken.KeyFrameRuleNodeType:
|
|
14210
|
-
// default:
|
|
14211
|
-
//
|
|
14212
|
-
// throw new Error(`Not implemented: ${node.typ}`);
|
|
14213
14070
|
}
|
|
14214
14071
|
return {
|
|
14215
14072
|
valid: SyntaxValidationResult.Valid,
|
|
@@ -14251,8 +14108,6 @@
|
|
|
14251
14108
|
context
|
|
14252
14109
|
};
|
|
14253
14110
|
}
|
|
14254
|
-
// console.error(`>> ${syntaxes.reduce((acc, curr) => acc + renderSyntax(curr), '')}\n>> ${context.slice<Token>().reduce((acc, curr) => acc + renderToken(curr), '')}`);
|
|
14255
|
-
// console.error(new Error('doEvaluateSyntax'));
|
|
14256
14111
|
for (; i < syntaxes.length; i++) {
|
|
14257
14112
|
syntax = syntaxes[i];
|
|
14258
14113
|
if (context.done()) {
|
|
@@ -14263,7 +14118,7 @@
|
|
|
14263
14118
|
}
|
|
14264
14119
|
token = context.peek();
|
|
14265
14120
|
// if var() is the last token, then match the remaining syntax and return
|
|
14266
|
-
if (context.length == 1 && token.typ == exports.EnumToken.FunctionTokenType && 'var'
|
|
14121
|
+
if (context.length == 1 && token.typ == exports.EnumToken.FunctionTokenType && 'var' === token.val?.toLowerCase?.()) {
|
|
14267
14122
|
return doEvaluateSyntax(getParsedSyntax("functions" /* ValidationSyntaxGroupEnum.Functions */, 'var')?.[0]?.chi ?? [], createContext(token.chi), options);
|
|
14268
14123
|
}
|
|
14269
14124
|
if (syntax.typ == ValidationTokenEnum.Whitespace) {
|
|
@@ -14370,16 +14225,6 @@
|
|
|
14370
14225
|
while (!con.done() && con.peek()?.typ != exports.EnumToken.CommaTokenType) {
|
|
14371
14226
|
tokens.push(con.next());
|
|
14372
14227
|
}
|
|
14373
|
-
// if (tokens.length == 0) {
|
|
14374
|
-
//
|
|
14375
|
-
// return {
|
|
14376
|
-
// valid: SyntaxValidationResult.Drop,
|
|
14377
|
-
// node: context.peek(),
|
|
14378
|
-
// syntax,
|
|
14379
|
-
// error: `could not match syntax: ${renderSyntax(syntax)}`,
|
|
14380
|
-
// context
|
|
14381
|
-
// }
|
|
14382
|
-
// }
|
|
14383
14228
|
result = doEvaluateSyntax([syntax], createContext(tokens), {
|
|
14384
14229
|
...options,
|
|
14385
14230
|
isList: false,
|
|
@@ -14464,22 +14309,6 @@
|
|
|
14464
14309
|
};
|
|
14465
14310
|
}
|
|
14466
14311
|
}
|
|
14467
|
-
// if (token.typ == EnumToken.WhitespaceTokenType) {
|
|
14468
|
-
//
|
|
14469
|
-
// context.next();
|
|
14470
|
-
//
|
|
14471
|
-
// // @ts-ignore
|
|
14472
|
-
// if (syntax?.typ == ValidationTokenEnum.Whitespace) {
|
|
14473
|
-
//
|
|
14474
|
-
// return {
|
|
14475
|
-
// valid: SyntaxValidationResult.Valid,
|
|
14476
|
-
// node: null,
|
|
14477
|
-
// syntax,
|
|
14478
|
-
// error: '',
|
|
14479
|
-
// context
|
|
14480
|
-
// }
|
|
14481
|
-
// }
|
|
14482
|
-
// }
|
|
14483
14312
|
if (syntax.typ != ValidationTokenEnum.PropertyType && (token?.typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(token.val))) {
|
|
14484
14313
|
const result = doEvaluateSyntax(getParsedSyntax("functions" /* ValidationSyntaxGroupEnum.Functions */, token.val)?.[0]?.chi ?? [], createContext(token.chi), {
|
|
14485
14314
|
...options,
|
|
@@ -14497,7 +14326,7 @@
|
|
|
14497
14326
|
case ValidationTokenEnum.Keyword:
|
|
14498
14327
|
success = (token.typ == exports.EnumToken.IdenTokenType || token.typ == exports.EnumToken.DashedIdenTokenType || isIdentColor(token)) &&
|
|
14499
14328
|
(token.val == syntax.val ||
|
|
14500
|
-
syntax.val
|
|
14329
|
+
syntax.val === token.val?.toLowerCase?.() ||
|
|
14501
14330
|
// config.declarations.all
|
|
14502
14331
|
allValues.includes(token.val.toLowerCase()));
|
|
14503
14332
|
if (success) {
|
|
@@ -14525,7 +14354,6 @@
|
|
|
14525
14354
|
};
|
|
14526
14355
|
}
|
|
14527
14356
|
result = match(getParsedSyntax("syntaxes" /* ValidationSyntaxGroupEnum.Syntaxes */, syntax.val + '()')?.[0], context, options);
|
|
14528
|
-
// console.error(`>>[]
|
|
14529
14357
|
if (result.valid == SyntaxValidationResult.Valid) {
|
|
14530
14358
|
context.next();
|
|
14531
14359
|
result.context = context;
|
|
@@ -14540,49 +14368,12 @@
|
|
|
14540
14368
|
occurence: null,
|
|
14541
14369
|
atLeastOnce: null
|
|
14542
14370
|
});
|
|
14543
|
-
// case ValidationTokenEnum.Parens:
|
|
14544
|
-
//
|
|
14545
|
-
// token = context.peek() as Token;
|
|
14546
|
-
// if (token.typ != EnumToken.ParensTokenType) {
|
|
14547
|
-
//
|
|
14548
|
-
// break;
|
|
14549
|
-
// }
|
|
14550
|
-
//
|
|
14551
|
-
// success = doEvaluateSyntax((syntax as ValidationParensToken).chi as ValidationToken[], createContext((token as ParensToken).chi), {
|
|
14552
|
-
// ...options,
|
|
14553
|
-
// isRepeatable: null,
|
|
14554
|
-
// isList: null,
|
|
14555
|
-
// occurence: null,
|
|
14556
|
-
// atLeastOnce: null
|
|
14557
|
-
// } as ValidationOptions).valid == SyntaxValidationResult.Valid;
|
|
14558
|
-
// break;
|
|
14559
14371
|
case ValidationTokenEnum.Comma:
|
|
14560
14372
|
success = context.peek()?.typ == exports.EnumToken.CommaTokenType;
|
|
14561
14373
|
if (success) {
|
|
14562
14374
|
context.next();
|
|
14563
14375
|
}
|
|
14564
14376
|
break;
|
|
14565
|
-
// case ValidationTokenEnum.Number:
|
|
14566
|
-
//
|
|
14567
|
-
// success = context.peek<Token>()?.typ == EnumToken.NumberTokenType;
|
|
14568
|
-
//
|
|
14569
|
-
// if (success) {
|
|
14570
|
-
//
|
|
14571
|
-
// context.next();
|
|
14572
|
-
// }
|
|
14573
|
-
//
|
|
14574
|
-
// break;
|
|
14575
|
-
//
|
|
14576
|
-
// case ValidationTokenEnum.Whitespace:
|
|
14577
|
-
//
|
|
14578
|
-
// success = context.peek<Token>()?.typ == EnumToken.WhitespaceTokenType;
|
|
14579
|
-
//
|
|
14580
|
-
// if (success) {
|
|
14581
|
-
//
|
|
14582
|
-
// context.next();
|
|
14583
|
-
// }
|
|
14584
|
-
//
|
|
14585
|
-
// break;
|
|
14586
14377
|
case ValidationTokenEnum.Separator:
|
|
14587
14378
|
{
|
|
14588
14379
|
const token = context.peek();
|
|
@@ -14598,14 +14389,7 @@
|
|
|
14598
14389
|
break;
|
|
14599
14390
|
}
|
|
14600
14391
|
if (syntax.typ == ValidationTokenEnum.Function) {
|
|
14601
|
-
success = funcLike.includes(token.typ) && syntax.val.
|
|
14602
|
-
// console.error(`>> match: ${JSON.stringify({
|
|
14603
|
-
// syntax,
|
|
14604
|
-
// token,
|
|
14605
|
-
// // result,
|
|
14606
|
-
// tr2: syntax,
|
|
14607
|
-
// success
|
|
14608
|
-
// }, null, 1)}`);
|
|
14392
|
+
success = funcLike.includes(token.typ) && syntax.val.toLowerCase() === token.val?.toLowerCase?.() && doEvaluateSyntax(syntax.chi, createContext(token.chi), options).valid == SyntaxValidationResult.Valid;
|
|
14609
14393
|
if (success) {
|
|
14610
14394
|
context.next();
|
|
14611
14395
|
}
|
|
@@ -14624,7 +14408,6 @@
|
|
|
14624
14408
|
}
|
|
14625
14409
|
break;
|
|
14626
14410
|
}
|
|
14627
|
-
// throw new Error(`Not implemented: ${ValidationTokenEnum[syntax.typ] ?? syntax.typ} : ${renderSyntax(syntax)} : ${renderToken(context.peek() as Token)} : ${JSON.stringify(syntax, null, 1)} | ${JSON.stringify(context.peek(), null, 1)}`);
|
|
14628
14411
|
}
|
|
14629
14412
|
if (!success && token.typ == exports.EnumToken.IdenTokenType && allValues.includes(token.val.toLowerCase())) {
|
|
14630
14413
|
success = true;
|
|
@@ -14737,7 +14520,7 @@
|
|
|
14737
14520
|
token = context.peek();
|
|
14738
14521
|
continue;
|
|
14739
14522
|
}
|
|
14740
|
-
success = token.typ == exports.EnumToken.LengthTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
14523
|
+
success = token.typ == exports.EnumToken.LengthTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0);
|
|
14741
14524
|
if (!success) {
|
|
14742
14525
|
break;
|
|
14743
14526
|
}
|
|
@@ -14787,14 +14570,14 @@
|
|
|
14787
14570
|
success = token.typ == exports.EnumToken.DashedIdenTokenType;
|
|
14788
14571
|
break;
|
|
14789
14572
|
case 'system-color':
|
|
14790
|
-
success = (token.typ == exports.EnumToken.ColorTokenType && token.kin == exports.ColorType.SYS) || (token.typ == exports.EnumToken.IdenTokenType && token.val.
|
|
14573
|
+
success = (token.typ == exports.EnumToken.ColorTokenType && token.kin == exports.ColorType.SYS) || (token.typ == exports.EnumToken.IdenTokenType && 'currentcolor' === token.val.toLowerCase()) || (token.typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(token.val));
|
|
14791
14574
|
break;
|
|
14792
14575
|
case 'deprecated-system-color':
|
|
14793
|
-
success = (token.typ == exports.EnumToken.ColorTokenType && token.kin == exports.ColorType.DPSYS) || (token.typ == exports.EnumToken.IdenTokenType && token.val.
|
|
14576
|
+
success = (token.typ == exports.EnumToken.ColorTokenType && token.kin == exports.ColorType.DPSYS) || (token.typ == exports.EnumToken.IdenTokenType && 'currentcolor' === token.val.toLowerCase()) || (token.typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(token.val));
|
|
14794
14577
|
break;
|
|
14795
14578
|
case 'color':
|
|
14796
14579
|
case 'color-base':
|
|
14797
|
-
success = token.typ == exports.EnumToken.ColorTokenType || (token.typ == exports.EnumToken.IdenTokenType && token.val.
|
|
14580
|
+
success = token.typ == exports.EnumToken.ColorTokenType || (token.typ == exports.EnumToken.IdenTokenType && 'currentcolor' === token.val.toLowerCase()) || (token.typ == exports.EnumToken.IdenTokenType && 'transparent' === token.val.toLowerCase()) || (token.typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(token.val));
|
|
14798
14581
|
if (!success && token.typ == exports.EnumToken.FunctionTokenType && colorsFunc.includes(token.val)) {
|
|
14799
14582
|
success = doEvaluateSyntax(getParsedSyntax("functions" /* ValidationSyntaxGroupEnum.Functions */, token.val)?.[0]?.chi, createContext(token.chi), {
|
|
14800
14583
|
...options,
|
|
@@ -14835,19 +14618,19 @@
|
|
|
14835
14618
|
}
|
|
14836
14619
|
break;
|
|
14837
14620
|
case 'angle':
|
|
14838
|
-
success = token.typ == exports.EnumToken.AngleTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
14621
|
+
success = token.typ == exports.EnumToken.AngleTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0) || (token.typ == exports.EnumToken.FunctionTokenType && token.val == 'calc');
|
|
14839
14622
|
break;
|
|
14840
14623
|
case 'length':
|
|
14841
|
-
success = token.typ == exports.EnumToken.LengthTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
14624
|
+
success = token.typ == exports.EnumToken.LengthTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0) || (token.typ == exports.EnumToken.FunctionTokenType && token.val == 'calc');
|
|
14842
14625
|
break;
|
|
14843
14626
|
case 'percentage':
|
|
14844
|
-
success = token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
14627
|
+
success = token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0) || (token.typ == exports.EnumToken.FunctionTokenType && token.val == 'calc');
|
|
14845
14628
|
break;
|
|
14846
14629
|
case 'length-percentage':
|
|
14847
|
-
success = token.typ == exports.EnumToken.LengthTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
14630
|
+
success = token.typ == exports.EnumToken.LengthTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0) || (token.typ == exports.EnumToken.FunctionTokenType && token.val == 'calc');
|
|
14848
14631
|
break;
|
|
14849
14632
|
case 'resolution':
|
|
14850
|
-
success = token.typ == exports.EnumToken.ResolutionTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
14633
|
+
success = token.typ == exports.EnumToken.ResolutionTokenType || token.typ == exports.EnumToken.PercentageTokenType || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0) || (token.typ == exports.EnumToken.FunctionTokenType && token.val == 'calc');
|
|
14851
14634
|
break;
|
|
14852
14635
|
case 'hash-token':
|
|
14853
14636
|
success = token.typ == exports.EnumToken.HashTokenType;
|
|
@@ -14859,7 +14642,7 @@
|
|
|
14859
14642
|
success = token.typ == exports.EnumToken.TimeTokenType || (token.typ == exports.EnumToken.FunctionTokenType && token.val == 'calc');
|
|
14860
14643
|
break;
|
|
14861
14644
|
case 'zero':
|
|
14862
|
-
success = token.val ==
|
|
14645
|
+
success = token.val == 0 || (token.typ == exports.EnumToken.FunctionTokenType && token.val == 'calc');
|
|
14863
14646
|
break;
|
|
14864
14647
|
case 'pseudo-element-selector':
|
|
14865
14648
|
success = token.typ == exports.EnumToken.PseudoElementTokenType;
|
|
@@ -14879,9 +14662,6 @@
|
|
|
14879
14662
|
}
|
|
14880
14663
|
}
|
|
14881
14664
|
break;
|
|
14882
|
-
// default:
|
|
14883
|
-
//
|
|
14884
|
-
// throw new Error(`Not implemented: ${ValidationTokenEnum[syntax.typ] ?? syntax.typ} : ${renderSyntax(syntax)}\n${JSON.stringify(syntax, null, 1)}`);
|
|
14885
14665
|
}
|
|
14886
14666
|
if (!success &&
|
|
14887
14667
|
token.typ == exports.EnumToken.FunctionTokenType &&
|
|
@@ -14917,12 +14697,7 @@
|
|
|
14917
14697
|
let success = false;
|
|
14918
14698
|
const matched = [];
|
|
14919
14699
|
for (i = 0; i < syntaxes.length; i++) {
|
|
14920
|
-
// if (context.peek<Token>()?.typ == EnumToken.WhitespaceTokenType) {
|
|
14921
|
-
//
|
|
14922
|
-
// context.next();
|
|
14923
|
-
// }
|
|
14924
14700
|
result = doEvaluateSyntax(syntaxes[i], context.clone(), options);
|
|
14925
|
-
// console.error(`>> someOf: ${JSON.stringify({result}, null, 1)}`);
|
|
14926
14701
|
if (result.valid == SyntaxValidationResult.Valid) {
|
|
14927
14702
|
success = true;
|
|
14928
14703
|
if (result.context.done()) {
|
|
@@ -14935,8 +14710,6 @@
|
|
|
14935
14710
|
// pick the best match
|
|
14936
14711
|
matched.sort((a, b) => a.context.done() ? -1 : b.context.done() ? 1 : b.context.index - a.context.index);
|
|
14937
14712
|
}
|
|
14938
|
-
// console.error(JSON.stringify({matched}, null, 1));
|
|
14939
|
-
// console.error(new Error('someOf'));
|
|
14940
14713
|
return matched[0] ?? {
|
|
14941
14714
|
valid: SyntaxValidationResult.Drop,
|
|
14942
14715
|
node: context.peek(),
|
|
@@ -14992,10 +14765,6 @@
|
|
|
14992
14765
|
for (i = 0; i < slice.length; i++) {
|
|
14993
14766
|
if (slice[i].typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(slice[i].val.toLowerCase())) {
|
|
14994
14767
|
vars.push(slice[i]);
|
|
14995
|
-
// if (slice[i + 1]?.typ == EnumToken.WhitespaceTokenType) {
|
|
14996
|
-
//
|
|
14997
|
-
// vars.push(slice[++i]);
|
|
14998
|
-
// }
|
|
14999
14768
|
continue;
|
|
15000
14769
|
}
|
|
15001
14770
|
if (slice[i].typ == exports.EnumToken.CommaTokenType || (slice[i].typ == exports.EnumToken.LiteralTokenType && slice[i].val == '/')) {
|
|
@@ -15022,7 +14791,6 @@
|
|
|
15022
14791
|
}
|
|
15023
14792
|
while (!cp.done()) {
|
|
15024
14793
|
result = doEvaluateSyntax(syntax[i], cp.clone(), { ...options, isOptional: false });
|
|
15025
|
-
// console.error(`>> allOf: syntaxes[${i}]: ${syntax[i].length} ${syntax[i].reduce((acc, curr) => acc + renderSyntax(curr), '')}\n>> ${cp.slice<Token>().reduce((acc, curr) => acc + renderToken(curr), '')}\n>> ${JSON.stringify({result}, null, 1)}`);
|
|
15026
14794
|
if (result.valid == SyntaxValidationResult.Valid) {
|
|
15027
14795
|
let end = slice.indexOf(cp.current());
|
|
15028
14796
|
if (end == -1) {
|
|
@@ -15079,43 +14847,10 @@
|
|
|
15079
14847
|
}
|
|
15080
14848
|
|
|
15081
14849
|
function validateURL(token) {
|
|
15082
|
-
// if (token.typ == EnumToken.UrlTokenTokenType) {
|
|
15083
|
-
//
|
|
15084
|
-
// // @ts-ignore
|
|
15085
|
-
// return {
|
|
15086
|
-
// valid: SyntaxValidationResult.Valid,
|
|
15087
|
-
// context: [],
|
|
15088
|
-
// node: token,
|
|
15089
|
-
// // @ts-ignore
|
|
15090
|
-
// syntax: 'url()',
|
|
15091
|
-
// error: ''
|
|
15092
|
-
// }
|
|
15093
|
-
// }
|
|
15094
|
-
// if (token.typ != EnumToken.UrlFunctionTokenType) {
|
|
15095
|
-
//
|
|
15096
|
-
// // @ts-ignore
|
|
15097
|
-
// return {
|
|
15098
|
-
// valid: SyntaxValidationResult.Drop,
|
|
15099
|
-
// context: [],
|
|
15100
|
-
// node: token,
|
|
15101
|
-
// // @ts-ignore
|
|
15102
|
-
// syntax: 'url()',
|
|
15103
|
-
// error: 'expected url()'
|
|
15104
|
-
// }
|
|
15105
|
-
// }
|
|
15106
14850
|
const children = token.chi.slice();
|
|
15107
14851
|
consumeWhitespace(children);
|
|
15108
14852
|
if (children.length > 0 && [exports.EnumToken.UrlTokenTokenType, exports.EnumToken.StringTokenType, exports.EnumToken.HashTokenType].includes(children[0].typ)) {
|
|
15109
14853
|
children.shift();
|
|
15110
|
-
// @ts-ignore
|
|
15111
|
-
// return {
|
|
15112
|
-
// valid: SyntaxValidationResult.Drop,
|
|
15113
|
-
// context: [],
|
|
15114
|
-
// node: children[0] ?? token,
|
|
15115
|
-
// // @ts-ignore
|
|
15116
|
-
// syntax: 'url()',
|
|
15117
|
-
// error: 'expected url-token'
|
|
15118
|
-
// }
|
|
15119
14854
|
}
|
|
15120
14855
|
consumeWhitespace(children);
|
|
15121
14856
|
if (children.length > 0) {
|
|
@@ -15143,15 +14878,6 @@
|
|
|
15143
14878
|
const validateSelectorList = validateComplexSelectorList;
|
|
15144
14879
|
|
|
15145
14880
|
function validateSelector(selector, options, root) {
|
|
15146
|
-
// if (root == null) {
|
|
15147
|
-
//
|
|
15148
|
-
// return validateSelectorList(selector, root, options);
|
|
15149
|
-
// }
|
|
15150
|
-
// @ts-ignore
|
|
15151
|
-
// if (root.typ == EnumToken.AtRuleNodeType && root.nam.match(/^(-[a-z]+-)?keyframes$/)) {
|
|
15152
|
-
//
|
|
15153
|
-
// return validateKeyframeBlockList(selector, root as AstAtRule, options);
|
|
15154
|
-
// }
|
|
15155
14881
|
let isNested = root.typ == exports.EnumToken.RuleNodeType ? 1 : 0;
|
|
15156
14882
|
let currentRoot = root.parent;
|
|
15157
14883
|
while (currentRoot != null && isNested == 0) {
|
|
@@ -15750,7 +15476,7 @@
|
|
|
15750
15476
|
if (token.typ == exports.EnumToken.MediaFeatureNotTokenType) {
|
|
15751
15477
|
return validateSupportCondition(atRule, token.val);
|
|
15752
15478
|
}
|
|
15753
|
-
if (token.typ == exports.EnumToken.FunctionTokenType && token.val.
|
|
15479
|
+
if (token.typ == exports.EnumToken.FunctionTokenType && 'selector' === token.val.toLowerCase()) {
|
|
15754
15480
|
return {
|
|
15755
15481
|
valid: SyntaxValidationResult.Valid,
|
|
15756
15482
|
context: [],
|
|
@@ -15807,7 +15533,7 @@
|
|
|
15807
15533
|
return validateSupportFeature(token.val);
|
|
15808
15534
|
}
|
|
15809
15535
|
if (token.typ == exports.EnumToken.FunctionTokenType) {
|
|
15810
|
-
if (token.val.
|
|
15536
|
+
if ('selector' === token.val.toLowerCase()) {
|
|
15811
15537
|
return {
|
|
15812
15538
|
valid: SyntaxValidationResult.Valid,
|
|
15813
15539
|
context: [],
|
|
@@ -15816,10 +15542,10 @@
|
|
|
15816
15542
|
error: ''
|
|
15817
15543
|
};
|
|
15818
15544
|
}
|
|
15819
|
-
if (
|
|
15545
|
+
if ('font-tech' === token.val.toLowerCase()) {
|
|
15820
15546
|
const chi = token.chi.filter((t) => ![exports.EnumToken.WhitespaceTokenType, exports.EnumToken.CommentTokenType].includes(t.typ));
|
|
15821
15547
|
// @ts-ignore
|
|
15822
|
-
return chi.length == 1 && chi[0].typ == exports.EnumToken.IdenTokenType && colorFontTech.concat(fontFeaturesTech).
|
|
15548
|
+
return chi.length == 1 && chi[0].typ == exports.EnumToken.IdenTokenType && colorFontTech.concat(fontFeaturesTech).includes(chi[0].val.toLowerCase()) ?
|
|
15823
15549
|
{
|
|
15824
15550
|
valid: SyntaxValidationResult.Valid,
|
|
15825
15551
|
context: [],
|
|
@@ -15835,10 +15561,10 @@
|
|
|
15835
15561
|
error: 'expected font-tech'
|
|
15836
15562
|
};
|
|
15837
15563
|
}
|
|
15838
|
-
if (
|
|
15564
|
+
if ('font-format' === token.val.toLowerCase()) {
|
|
15839
15565
|
const chi = token.chi.filter((t) => ![exports.EnumToken.WhitespaceTokenType, exports.EnumToken.CommentTokenType].includes(t.typ));
|
|
15840
15566
|
// @ts-ignore
|
|
15841
|
-
return chi.length == 1 && chi[0].typ == exports.EnumToken.IdenTokenType && fontFormat.
|
|
15567
|
+
return chi.length == 1 && chi[0].typ == exports.EnumToken.IdenTokenType && fontFormat.includes(chi[0].val, toLowerCase()) ?
|
|
15842
15568
|
{
|
|
15843
15569
|
valid: SyntaxValidationResult.Valid,
|
|
15844
15570
|
context: [],
|
|
@@ -15945,8 +15671,7 @@
|
|
|
15945
15671
|
if (tokens.length > 0) {
|
|
15946
15672
|
// @ts-ignore
|
|
15947
15673
|
if (tokens[0].typ == exports.EnumToken.IdenTokenType) {
|
|
15948
|
-
|
|
15949
|
-
if ('layer'.localeCompare(tokens[0].val, undefined, { sensitivity: 'base' }) == 0) {
|
|
15674
|
+
if ('layer' === tokens[0].val.toLowerCase()) {
|
|
15950
15675
|
tokens.shift();
|
|
15951
15676
|
// @ts-ignore
|
|
15952
15677
|
if (!consumeWhitespace(tokens)) {
|
|
@@ -15964,7 +15689,7 @@
|
|
|
15964
15689
|
// @ts-ignore
|
|
15965
15690
|
else if (tokens[0].typ == exports.EnumToken.FunctionTokenType) {
|
|
15966
15691
|
// @ts-ignore
|
|
15967
|
-
if ('layer'
|
|
15692
|
+
if ('layer' === tokens[0].val.toLowerCase()) {
|
|
15968
15693
|
const result = validateLayerName(tokens[0].chi);
|
|
15969
15694
|
if (result.valid == SyntaxValidationResult.Drop) {
|
|
15970
15695
|
return result;
|
|
@@ -15973,8 +15698,9 @@
|
|
|
15973
15698
|
// @ts-ignore
|
|
15974
15699
|
consumeWhitespace(tokens);
|
|
15975
15700
|
}
|
|
15701
|
+
// tokens[0]?.val
|
|
15976
15702
|
// @ts-ignore
|
|
15977
|
-
if ('supports'
|
|
15703
|
+
if ('supports' === tokens[0]?.val?.toLowerCase?.()) {
|
|
15978
15704
|
const result = validateAtRuleSupportsConditions(atRule, tokens[0].chi);
|
|
15979
15705
|
if (result.valid == SyntaxValidationResult.Drop) {
|
|
15980
15706
|
return result;
|
|
@@ -16156,7 +15882,7 @@
|
|
|
16156
15882
|
};
|
|
16157
15883
|
}
|
|
16158
15884
|
// @ts-ignore
|
|
16159
|
-
if ((t[0].typ != exports.EnumToken.FunctionTokenType && t[0].typ != exports.EnumToken.UrlFunctionTokenType) || !['url', 'url-prefix', 'domain', 'media-document', 'regexp'].
|
|
15885
|
+
if ((t[0].typ != exports.EnumToken.FunctionTokenType && t[0].typ != exports.EnumToken.UrlFunctionTokenType) || !['url', 'url-prefix', 'domain', 'media-document', 'regexp'].includes(t[0].val?.toLowerCase?.())) {
|
|
16160
15886
|
return {
|
|
16161
15887
|
valid: SyntaxValidationResult.Drop,
|
|
16162
15888
|
context: [],
|
|
@@ -16210,17 +15936,6 @@
|
|
|
16210
15936
|
}
|
|
16211
15937
|
const tokens = atRule.tokens.filter((t) => t.typ != exports.EnumToken.CommentTokenType).slice();
|
|
16212
15938
|
consumeWhitespace(tokens);
|
|
16213
|
-
// if (tokens.length == 0) {
|
|
16214
|
-
//
|
|
16215
|
-
// // @ts-ignore
|
|
16216
|
-
// return {
|
|
16217
|
-
// valid: SyntaxValidationResult.Drop,
|
|
16218
|
-
// context: [],
|
|
16219
|
-
// node: atRule,
|
|
16220
|
-
// syntax: '@keyframes',
|
|
16221
|
-
// error: 'expecting at-rule prelude'
|
|
16222
|
-
// } as ValidationSyntaxResult;
|
|
16223
|
-
// }
|
|
16224
15939
|
if (tokens.length == 0 || ![exports.EnumToken.StringTokenType, exports.EnumToken.IdenTokenType].includes(tokens[0].typ)) {
|
|
16225
15940
|
// @ts-ignore
|
|
16226
15941
|
return {
|
|
@@ -17033,6 +16748,18 @@
|
|
|
17033
16748
|
stats.bytesIn = item.bytesIn;
|
|
17034
16749
|
rawTokens.push(item);
|
|
17035
16750
|
if (item.hint != null && BadTokensTypes.includes(item.hint)) {
|
|
16751
|
+
const node = getTokenType(item.token, item.hint);
|
|
16752
|
+
errors.push({
|
|
16753
|
+
action: 'drop',
|
|
16754
|
+
message: 'Bad token',
|
|
16755
|
+
syntax: null,
|
|
16756
|
+
node,
|
|
16757
|
+
location: {
|
|
16758
|
+
src,
|
|
16759
|
+
sta: item.sta,
|
|
16760
|
+
end: item.end
|
|
16761
|
+
}
|
|
16762
|
+
});
|
|
17036
16763
|
// bad token
|
|
17037
16764
|
continue;
|
|
17038
16765
|
}
|
|
@@ -17077,7 +16804,12 @@
|
|
|
17077
16804
|
errors.push({
|
|
17078
16805
|
action: 'drop',
|
|
17079
16806
|
message: 'invalid block',
|
|
17080
|
-
rawTokens: tokens.slice()
|
|
16807
|
+
rawTokens: tokens.slice(),
|
|
16808
|
+
location: {
|
|
16809
|
+
src,
|
|
16810
|
+
sta: tokens[0].sta,
|
|
16811
|
+
end: tokens[tokens.length - 1].end
|
|
16812
|
+
}
|
|
17081
16813
|
});
|
|
17082
16814
|
}
|
|
17083
16815
|
}
|
|
@@ -17245,6 +16977,7 @@
|
|
|
17245
16977
|
errors.push({
|
|
17246
16978
|
action: 'drop',
|
|
17247
16979
|
message: `CDOCOMM not allowed here ${JSON.stringify(tokens[i], null, 1)}`,
|
|
16980
|
+
node: tokens[i],
|
|
17248
16981
|
location
|
|
17249
16982
|
});
|
|
17250
16983
|
continue;
|
|
@@ -17299,7 +17032,8 @@
|
|
|
17299
17032
|
if (!(type == exports.EnumToken.InvalidAtRuleTokenType &&
|
|
17300
17033
|
// @ts-ignore
|
|
17301
17034
|
['charset', 'layer', 'import'].includes(context.chi[i].nam))) {
|
|
17302
|
-
|
|
17035
|
+
// @ts-ignore
|
|
17036
|
+
errors.push({ action: 'drop', message: 'invalid @import', location, rawTokens: [atRule, ...tokens] });
|
|
17303
17037
|
return null;
|
|
17304
17038
|
}
|
|
17305
17039
|
}
|
|
@@ -17375,7 +17109,7 @@
|
|
|
17375
17109
|
action: 'drop',
|
|
17376
17110
|
message: '@charset must have only one space',
|
|
17377
17111
|
// @ts-ignore
|
|
17378
|
-
location
|
|
17112
|
+
location, rawTokens: [atRule, ...tokens]
|
|
17379
17113
|
});
|
|
17380
17114
|
return null;
|
|
17381
17115
|
}
|
|
@@ -17444,6 +17178,7 @@
|
|
|
17444
17178
|
errors.push({
|
|
17445
17179
|
action: 'drop',
|
|
17446
17180
|
message: valid.error + ' - "' + tokens.reduce((acc, curr) => acc + renderToken(curr, { minify: false }), '') + '"',
|
|
17181
|
+
node,
|
|
17447
17182
|
// @ts-ignore
|
|
17448
17183
|
location: { src, ...(map.get(valid.node) ?? location) }
|
|
17449
17184
|
});
|
|
@@ -17492,7 +17227,7 @@
|
|
|
17492
17227
|
if (curr.typ == exports.EnumToken.IdenTokenType && curr.val == 'from') {
|
|
17493
17228
|
Object.assign(curr, { typ: exports.EnumToken.PercentageTokenType, val: '0' });
|
|
17494
17229
|
}
|
|
17495
|
-
else if (curr.typ == exports.EnumToken.PercentageTokenType && curr.val ==
|
|
17230
|
+
else if (curr.typ == exports.EnumToken.PercentageTokenType && curr.val == 100) {
|
|
17496
17231
|
Object.assign(curr, { typ: exports.EnumToken.IdenTokenType, val: 'to' });
|
|
17497
17232
|
}
|
|
17498
17233
|
}
|
|
@@ -17545,6 +17280,7 @@
|
|
|
17545
17280
|
errors.push({
|
|
17546
17281
|
action: 'drop',
|
|
17547
17282
|
message: valid.error + ' - "' + tokens.reduce((acc, curr) => acc + renderToken(curr, { minify: false }), '') + '"',
|
|
17283
|
+
node,
|
|
17548
17284
|
// @ts-ignore
|
|
17549
17285
|
location
|
|
17550
17286
|
});
|
|
@@ -17569,7 +17305,7 @@
|
|
|
17569
17305
|
val: tokens[i].val.charAt(0)
|
|
17570
17306
|
}, {
|
|
17571
17307
|
typ: exports.EnumToken.NumberTokenType,
|
|
17572
|
-
val: tokens[i].val.slice(1)
|
|
17308
|
+
val: +tokens[i].val.slice(1)
|
|
17573
17309
|
});
|
|
17574
17310
|
}
|
|
17575
17311
|
else if (start == '/' && isFunction(val)) {
|
|
@@ -17770,9 +17506,10 @@
|
|
|
17770
17506
|
}
|
|
17771
17507
|
}
|
|
17772
17508
|
}
|
|
17509
|
+
const val = value.typ == exports.EnumToken.IdenTokenType ? value.val.toLowerCase() : null;
|
|
17773
17510
|
if (value.typ == exports.EnumToken.IdenTokenType) {
|
|
17774
17511
|
if (parent == null && mediaTypes.some((t) => {
|
|
17775
|
-
if (
|
|
17512
|
+
if (val === t) {
|
|
17776
17513
|
// @ts-ignore
|
|
17777
17514
|
value.typ = exports.EnumToken.MediaFeatureTokenType;
|
|
17778
17515
|
return true;
|
|
@@ -17781,18 +17518,18 @@
|
|
|
17781
17518
|
})) {
|
|
17782
17519
|
continue;
|
|
17783
17520
|
}
|
|
17784
|
-
if (value.typ == exports.EnumToken.IdenTokenType && 'and'
|
|
17521
|
+
if (value.typ == exports.EnumToken.IdenTokenType && 'and' === val) {
|
|
17785
17522
|
// @ts-ignore
|
|
17786
17523
|
value.typ = exports.EnumToken.MediaFeatureAndTokenType;
|
|
17787
17524
|
continue;
|
|
17788
17525
|
}
|
|
17789
|
-
if (value.typ == exports.EnumToken.IdenTokenType && 'or'
|
|
17526
|
+
if (value.typ == exports.EnumToken.IdenTokenType && 'or' === val) {
|
|
17790
17527
|
// @ts-ignore
|
|
17791
17528
|
value.typ = exports.EnumToken.MediaFeatureOrTokenType;
|
|
17792
17529
|
continue;
|
|
17793
17530
|
}
|
|
17794
17531
|
if (value.typ == exports.EnumToken.IdenTokenType &&
|
|
17795
|
-
['not', 'only'].some((t) =>
|
|
17532
|
+
['not', 'only'].some((t) => val === t)) {
|
|
17796
17533
|
// @ts-ignore
|
|
17797
17534
|
const array = parent?.chi ?? tokens;
|
|
17798
17535
|
const startIndex = array.indexOf(value);
|
|
@@ -18105,19 +17842,19 @@
|
|
|
18105
17842
|
if (isNumber(val)) {
|
|
18106
17843
|
return {
|
|
18107
17844
|
typ: exports.EnumToken.NumberTokenType,
|
|
18108
|
-
val
|
|
17845
|
+
val: +val
|
|
18109
17846
|
};
|
|
18110
17847
|
}
|
|
18111
17848
|
if (isPercentage(val)) {
|
|
18112
17849
|
return {
|
|
18113
17850
|
typ: exports.EnumToken.PercentageTokenType,
|
|
18114
|
-
val: val.slice(0, -1)
|
|
17851
|
+
val: +val.slice(0, -1)
|
|
18115
17852
|
};
|
|
18116
17853
|
}
|
|
18117
17854
|
if (isFlex(val)) {
|
|
18118
17855
|
return {
|
|
18119
17856
|
typ: exports.EnumToken.FlexTokenType,
|
|
18120
|
-
val: val.slice(0, -2)
|
|
17857
|
+
val: +val.slice(0, -2)
|
|
18121
17858
|
};
|
|
18122
17859
|
}
|
|
18123
17860
|
if (isDimension(val)) {
|
|
@@ -18911,25 +18648,6 @@
|
|
|
18911
18648
|
replace(node, variableScope);
|
|
18912
18649
|
}
|
|
18913
18650
|
}
|
|
18914
|
-
// else {
|
|
18915
|
-
//
|
|
18916
|
-
// const info: VariableScopeInfo = <VariableScopeInfo>variableScope.get((<AstDeclaration>node).nam);
|
|
18917
|
-
//
|
|
18918
|
-
// info.globalScope = isRoot;
|
|
18919
|
-
//
|
|
18920
|
-
// if (!isRoot) {
|
|
18921
|
-
//
|
|
18922
|
-
// ++info.declarationCount;
|
|
18923
|
-
// }
|
|
18924
|
-
//
|
|
18925
|
-
// if (info.replaceable) {
|
|
18926
|
-
//
|
|
18927
|
-
// info.replaceable = isRoot && info.declarationCount == 1;
|
|
18928
|
-
// }
|
|
18929
|
-
//
|
|
18930
|
-
// info.parent.add(ast);
|
|
18931
|
-
// info.node = (<AstDeclaration>node);
|
|
18932
|
-
// }
|
|
18933
18651
|
}
|
|
18934
18652
|
else {
|
|
18935
18653
|
replace(node, variableScope);
|
|
@@ -18970,7 +18688,7 @@
|
|
|
18970
18688
|
while (i-- > 1) {
|
|
18971
18689
|
const t = value[i];
|
|
18972
18690
|
const k = value[i == 1 ? 0 : i % 2];
|
|
18973
|
-
if (t.val == k.val && t.val ==
|
|
18691
|
+
if (t.val == k.val && t.val == 0) {
|
|
18974
18692
|
if ((t.typ == exports.EnumToken.NumberTokenType && isLength(k)) ||
|
|
18975
18693
|
(k.typ == exports.EnumToken.NumberTokenType && isLength(t)) ||
|
|
18976
18694
|
(isLength(k) || isLength(t))) {
|
|
@@ -19007,7 +18725,7 @@
|
|
|
19007
18725
|
// @ts-ignore
|
|
19008
18726
|
for (let token of this.declarations.get(this.config.shorthand).val) {
|
|
19009
18727
|
// @ts-ignore
|
|
19010
|
-
if (this.config.types.some(t => token.typ == exports.EnumToken[t]) || (token.typ == exports.EnumToken.NumberTokenType && token.val ==
|
|
18728
|
+
if (this.config.types.some(t => token.typ == exports.EnumToken[t]) || (token.typ == exports.EnumToken.NumberTokenType && token.val == 0 &&
|
|
19011
18729
|
(this.config.types.includes('Length') ||
|
|
19012
18730
|
this.config.types.includes('Angle') ||
|
|
19013
18731
|
this.config.types.includes('Dimension')))) {
|
|
@@ -19960,8 +19678,6 @@
|
|
|
19960
19678
|
const slice = (node.typ == exports.EnumToken.FunctionTokenType ? node.chi : (node.typ == exports.EnumToken.DeclarationNodeType ? node.val : node.chi))?.slice();
|
|
19961
19679
|
if (slice != null && node.typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(node.val)) {
|
|
19962
19680
|
// @ts-ignore
|
|
19963
|
-
const cp = (node.typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(node.val) && node.val != 'calc' ? [node] : (node.typ == exports.EnumToken.DeclarationNodeType ? node.val : node.chi)).slice();
|
|
19964
|
-
evaluate(cp);
|
|
19965
19681
|
const key = 'chi' in node ? 'chi' : 'val';
|
|
19966
19682
|
const str1 = renderToken({ ...node, [key]: slice });
|
|
19967
19683
|
const str2 = renderToken(node); // values.reduce((acc: string, curr: Token): string => acc + renderToken(curr), '');
|
|
@@ -19969,11 +19685,6 @@
|
|
|
19969
19685
|
// @ts-ignore
|
|
19970
19686
|
node[key] = slice;
|
|
19971
19687
|
}
|
|
19972
|
-
// else {
|
|
19973
|
-
//
|
|
19974
|
-
// // @ts-ignore
|
|
19975
|
-
// node[key] = values;
|
|
19976
|
-
// }
|
|
19977
19688
|
return WalkerOptionEnum.Ignore;
|
|
19978
19689
|
}
|
|
19979
19690
|
return null;
|
|
@@ -19989,20 +19700,9 @@
|
|
|
19989
19700
|
// @ts-ignore
|
|
19990
19701
|
const children = parent.typ == exports.EnumToken.DeclarationNodeType ? parent.val : parent.chi;
|
|
19991
19702
|
if (values.length == 1 && values[0].typ != exports.EnumToken.BinaryExpressionTokenType) {
|
|
19992
|
-
// if (parent.typ == EnumToken.BinaryExpressionTokenType) {
|
|
19993
|
-
//
|
|
19994
|
-
// if ((parent as BinaryExpressionToken).l == value) {
|
|
19995
|
-
//
|
|
19996
|
-
// (parent as BinaryExpressionToken).l = values[0];
|
|
19997
|
-
// } else {
|
|
19998
|
-
//
|
|
19999
|
-
// (parent as BinaryExpressionToken).r = values[0];
|
|
20000
|
-
// }
|
|
20001
|
-
// } else {
|
|
20002
19703
|
for (let i = 0; i < children.length; i++) {
|
|
20003
19704
|
if (children[i] == value) {
|
|
20004
|
-
|
|
20005
|
-
children.splice(i, 1, !(parent.typ == exports.EnumToken.FunctionTokenType && parent.val == 'calc') && typeof values[0].val != 'string' ? {
|
|
19705
|
+
children.splice(i, 1, !(parent.typ == exports.EnumToken.FunctionTokenType && parent.val == 'calc') && (typeof values[0].val != 'number' && !(values[0].typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(values[0].val))) ? {
|
|
20006
19706
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20007
19707
|
val: 'calc',
|
|
20008
19708
|
chi: values
|
|
@@ -20010,21 +19710,15 @@
|
|
|
20010
19710
|
break;
|
|
20011
19711
|
}
|
|
20012
19712
|
}
|
|
20013
|
-
// }
|
|
20014
19713
|
}
|
|
20015
19714
|
else {
|
|
20016
19715
|
for (let i = 0; i < children.length; i++) {
|
|
20017
19716
|
if (children[i] == value) {
|
|
20018
|
-
// if (parent.typ == EnumToken.FunctionTokenType && (parent as FunctionToken).val == 'calc') {
|
|
20019
|
-
//
|
|
20020
|
-
// children.splice(i, 1, ...values);
|
|
20021
|
-
// } else {
|
|
20022
19717
|
children.splice(i, 1, {
|
|
20023
19718
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20024
19719
|
val: 'calc',
|
|
20025
19720
|
chi: values
|
|
20026
19721
|
});
|
|
20027
|
-
// }
|
|
20028
19722
|
break;
|
|
20029
19723
|
}
|
|
20030
19724
|
}
|
|
@@ -20039,10 +19733,9 @@
|
|
|
20039
19733
|
|
|
20040
19734
|
const epsilon = 1e-5;
|
|
20041
19735
|
function identity() {
|
|
20042
|
-
return [
|
|
19736
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
20043
19737
|
}
|
|
20044
19738
|
function pLength(point) {
|
|
20045
|
-
// Calcul de la norme euclidienne
|
|
20046
19739
|
return Math.sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
|
|
20047
19740
|
}
|
|
20048
19741
|
function normalize(point) {
|
|
@@ -20051,23 +19744,19 @@
|
|
|
20051
19744
|
return norm === 0 ? [0, 0, 0] : [x / norm, y / norm, z / norm];
|
|
20052
19745
|
}
|
|
20053
19746
|
function dot(point1, point2) {
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
// return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2] + point1[3] * point2[3];
|
|
20057
|
-
// }
|
|
20058
|
-
let result = 0;
|
|
20059
|
-
for (let i = 0; i < point1.length; i++) {
|
|
20060
|
-
result += point1[i] * point2[i];
|
|
19747
|
+
if (point1.length === 4 && point2.length === 4) {
|
|
19748
|
+
return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2] + point1[3] * point2[3];
|
|
20061
19749
|
}
|
|
20062
|
-
return
|
|
20063
|
-
// return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
|
|
19750
|
+
return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
|
|
20064
19751
|
}
|
|
20065
19752
|
function multiply(matrixA, matrixB) {
|
|
20066
|
-
let result =
|
|
19753
|
+
let result = new Array(16).fill(0);
|
|
20067
19754
|
for (let i = 0; i < 4; i++) {
|
|
20068
19755
|
for (let j = 0; j < 4; j++) {
|
|
20069
19756
|
for (let k = 0; k < 4; k++) {
|
|
20070
|
-
|
|
19757
|
+
// Utiliser l'indexation linéaire pour accéder aux éléments
|
|
19758
|
+
// Pour une matrice 4x4, l'index est (row * 4 + col)
|
|
19759
|
+
result[j * 4 + i] += matrixA[k * 4 + i] * matrixB[j * 4 + k];
|
|
20071
19760
|
}
|
|
20072
19761
|
}
|
|
20073
19762
|
}
|
|
@@ -20075,20 +19764,17 @@
|
|
|
20075
19764
|
}
|
|
20076
19765
|
function inverse(matrix) {
|
|
20077
19766
|
// Create augmented matrix [matrix | identity]
|
|
20078
|
-
let augmented =
|
|
20079
|
-
|
|
20080
|
-
|
|
20081
|
-
|
|
20082
|
-
i === 2 ? [0, 0, 1, 0] :
|
|
20083
|
-
[0, 0, 0, 1])
|
|
20084
|
-
]);
|
|
19767
|
+
let augmented = [
|
|
19768
|
+
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
|
|
19769
|
+
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
|
|
19770
|
+
];
|
|
20085
19771
|
// Gaussian elimination with partial pivoting
|
|
20086
19772
|
for (let col = 0; col < 4; col++) {
|
|
20087
19773
|
// Find pivot row with maximum absolute value
|
|
20088
19774
|
let maxRow = col;
|
|
20089
|
-
let maxVal = Math.abs(augmented[col
|
|
19775
|
+
let maxVal = Math.abs(augmented[col * 4 + col]);
|
|
20090
19776
|
for (let row = col + 1; row < 4; row++) {
|
|
20091
|
-
let val = Math.abs(augmented[row
|
|
19777
|
+
let val = Math.abs(augmented[row * 4 + col]);
|
|
20092
19778
|
if (val > maxVal) {
|
|
20093
19779
|
maxVal = val;
|
|
20094
19780
|
maxRow = row;
|
|
@@ -20103,22 +19789,22 @@
|
|
|
20103
19789
|
[augmented[col], augmented[maxRow]] = [augmented[maxRow], augmented[col]];
|
|
20104
19790
|
}
|
|
20105
19791
|
// Scale pivot row to make pivot element 1
|
|
20106
|
-
let pivot = augmented[col
|
|
19792
|
+
let pivot = augmented[col * 4 + col];
|
|
20107
19793
|
for (let j = 0; j < 8; j++) {
|
|
20108
|
-
augmented[col
|
|
19794
|
+
augmented[col * 4 + j] /= pivot;
|
|
20109
19795
|
}
|
|
20110
19796
|
// Eliminate column in other rows
|
|
20111
19797
|
for (let row = 0; row < 4; row++) {
|
|
20112
19798
|
if (row !== col) {
|
|
20113
|
-
let factor = augmented[row
|
|
19799
|
+
let factor = augmented[row * 4 + col];
|
|
20114
19800
|
for (let j = 0; j < 8; j++) {
|
|
20115
|
-
augmented[row
|
|
19801
|
+
augmented[row * 4 + j] -= factor * augmented[col * 4 + j];
|
|
20116
19802
|
}
|
|
20117
19803
|
}
|
|
20118
19804
|
}
|
|
20119
19805
|
}
|
|
20120
19806
|
// Extract the inverse from the right side of the augmented matrix
|
|
20121
|
-
return augmented.
|
|
19807
|
+
return augmented.slice(0, 16);
|
|
20122
19808
|
}
|
|
20123
19809
|
// function transpose(matrix: Matrix): Matrix {
|
|
20124
19810
|
// // Crée une nouvelle matrice vide 4x4
|
|
@@ -20142,7 +19828,7 @@
|
|
|
20142
19828
|
// translate3d(25.9808px, 0, 15px ) rotateY(60deg) skewX(49.9999deg) scale(1, 1.2)
|
|
20143
19829
|
// translate → rotate → skew → scale
|
|
20144
19830
|
function decompose(original) {
|
|
20145
|
-
const matrix = original.
|
|
19831
|
+
const matrix = original.slice();
|
|
20146
19832
|
// Normalize last row
|
|
20147
19833
|
if (matrix[15] === 0) {
|
|
20148
19834
|
return null;
|
|
@@ -20159,7 +19845,7 @@
|
|
|
20159
19845
|
perspectiveMatrix[11] = 0;
|
|
20160
19846
|
perspectiveMatrix[15] = 1;
|
|
20161
19847
|
// @ts-ignore
|
|
20162
|
-
const inverted = inverse(original.
|
|
19848
|
+
const inverted = inverse(original.slice());
|
|
20163
19849
|
if (!inverted) {
|
|
20164
19850
|
return null;
|
|
20165
19851
|
}
|
|
@@ -20282,44 +19968,44 @@
|
|
|
20282
19968
|
// https://drafts.csswg.org/css-transforms-1/#2d-matrix
|
|
20283
19969
|
function is2DMatrix(matrix) {
|
|
20284
19970
|
// m13,m14, m23, m24, m31, m32, m34, m43 are all 0
|
|
20285
|
-
return matrix[0
|
|
20286
|
-
matrix[0
|
|
20287
|
-
matrix[1
|
|
20288
|
-
matrix[1
|
|
20289
|
-
matrix[2
|
|
20290
|
-
matrix[2
|
|
20291
|
-
matrix[2
|
|
20292
|
-
matrix[3
|
|
20293
|
-
matrix[2
|
|
20294
|
-
matrix[3
|
|
19971
|
+
return matrix[0 * 4 + 2] === 0 &&
|
|
19972
|
+
matrix[0 * 4 + 3] === 0 &&
|
|
19973
|
+
matrix[1 * 4 + 2] === 0 &&
|
|
19974
|
+
matrix[1 * 4 + 3] === 0 &&
|
|
19975
|
+
matrix[2 * 4 + 0] === 0 &&
|
|
19976
|
+
matrix[2 * 4 + 1] === 0 &&
|
|
19977
|
+
matrix[2 * 4 + 3] === 0 &&
|
|
19978
|
+
matrix[3 * 4 + 2] === 0 &&
|
|
19979
|
+
matrix[2 * 4 + 2] === 1 &&
|
|
19980
|
+
matrix[3 * 4 + 3] === 1;
|
|
20295
19981
|
}
|
|
20296
19982
|
|
|
20297
19983
|
function translateX(x, from) {
|
|
20298
19984
|
const matrix = identity();
|
|
20299
|
-
matrix[3
|
|
19985
|
+
matrix[3 * 4 + 0] = x;
|
|
20300
19986
|
return multiply(from, matrix);
|
|
20301
19987
|
}
|
|
20302
19988
|
function translateY(y, from) {
|
|
20303
19989
|
const matrix = identity();
|
|
20304
|
-
matrix[3
|
|
19990
|
+
matrix[3 * 4 + 1] = y;
|
|
20305
19991
|
return multiply(from, matrix);
|
|
20306
19992
|
}
|
|
20307
19993
|
function translateZ(z, from) {
|
|
20308
19994
|
const matrix = identity();
|
|
20309
|
-
matrix[3
|
|
19995
|
+
matrix[3 * 4 + 2] = z;
|
|
20310
19996
|
return multiply(from, matrix);
|
|
20311
19997
|
}
|
|
20312
19998
|
function translate(translate, from) {
|
|
20313
19999
|
const matrix = identity();
|
|
20314
|
-
matrix[3
|
|
20315
|
-
matrix[3
|
|
20000
|
+
matrix[3 * 4 + 0] = translate[0];
|
|
20001
|
+
matrix[3 * 4 + 1] = translate[1] ?? 0;
|
|
20316
20002
|
return multiply(from, matrix);
|
|
20317
20003
|
}
|
|
20318
20004
|
function translate3d(translate, from) {
|
|
20319
20005
|
const matrix = identity();
|
|
20320
|
-
matrix[3
|
|
20321
|
-
matrix[3
|
|
20322
|
-
matrix[3
|
|
20006
|
+
matrix[3 * 4 + 0] = translate[0];
|
|
20007
|
+
matrix[3 * 4 + 1] = translate[1];
|
|
20008
|
+
matrix[3 * 4 + 2] = translate[2];
|
|
20323
20009
|
return multiply(from, matrix);
|
|
20324
20010
|
}
|
|
20325
20011
|
|
|
@@ -20340,52 +20026,52 @@
|
|
|
20340
20026
|
x *= unit;
|
|
20341
20027
|
y *= unit;
|
|
20342
20028
|
z *= unit;
|
|
20343
|
-
matrix[0
|
|
20344
|
-
matrix[0
|
|
20345
|
-
matrix[0
|
|
20346
|
-
matrix[1
|
|
20347
|
-
matrix[1
|
|
20348
|
-
matrix[1
|
|
20349
|
-
matrix[2
|
|
20350
|
-
matrix[2
|
|
20351
|
-
matrix[2
|
|
20029
|
+
matrix[0 * 4 + 0] = 1 - 2 * (y * y + z * z) * sq;
|
|
20030
|
+
matrix[0 * 4 + 1] = 2 * (x * y * sq + z * sc);
|
|
20031
|
+
matrix[0 * 4 + 2] = 2 * (x * z * sq - y * sc);
|
|
20032
|
+
matrix[1 * 4 + 0] = 2 * (x * y * sq - z * sc);
|
|
20033
|
+
matrix[1 * 4 + 1] = 1 - 2 * (x * x + z * z) * sq;
|
|
20034
|
+
matrix[1 * 4 + 2] = 2 * (y * z * sq + x * sc);
|
|
20035
|
+
matrix[2 * 4 + 0] = 2 * (x * z * sq + y * sc);
|
|
20036
|
+
matrix[2 * 4 + 1] = 2 * (y * z * sq - x * sc);
|
|
20037
|
+
matrix[2 * 4 + 2] = 1 - 2 * (x * x + y * y) * sq;
|
|
20352
20038
|
return multiply(from, matrix);
|
|
20353
20039
|
}
|
|
20354
20040
|
function rotate(angle, from) {
|
|
20355
20041
|
const matrix = identity();
|
|
20356
|
-
matrix[0
|
|
20357
|
-
matrix[0
|
|
20358
|
-
matrix[1
|
|
20359
|
-
matrix[1
|
|
20042
|
+
matrix[0 * 4 + 0] = Math.cos(angle);
|
|
20043
|
+
matrix[0 * 4 + 1] = Math.sin(angle);
|
|
20044
|
+
matrix[1 * 4 + 0] = -Math.sin(angle);
|
|
20045
|
+
matrix[1 * 4 + 1] = Math.cos(angle);
|
|
20360
20046
|
return multiply(from, matrix);
|
|
20361
20047
|
}
|
|
20362
20048
|
|
|
20363
20049
|
function scaleX(x, from) {
|
|
20364
20050
|
const matrix = identity();
|
|
20365
|
-
matrix[0
|
|
20051
|
+
matrix[0 * 4 + 0] = x;
|
|
20366
20052
|
return multiply(from, matrix);
|
|
20367
20053
|
}
|
|
20368
20054
|
function scaleY(y, from) {
|
|
20369
20055
|
const matrix = identity();
|
|
20370
|
-
matrix[1
|
|
20056
|
+
matrix[1 * 4 + 1] = y;
|
|
20371
20057
|
return multiply(from, matrix);
|
|
20372
20058
|
}
|
|
20373
20059
|
function scaleZ(z, from) {
|
|
20374
20060
|
const matrix = identity();
|
|
20375
|
-
matrix[2
|
|
20061
|
+
matrix[2 * 4 + 2] = z;
|
|
20376
20062
|
return multiply(from, matrix);
|
|
20377
20063
|
}
|
|
20378
20064
|
function scale(x, y, from) {
|
|
20379
20065
|
const matrix = identity();
|
|
20380
|
-
matrix[0
|
|
20381
|
-
matrix[1
|
|
20066
|
+
matrix[0 * 4 + 0] = x;
|
|
20067
|
+
matrix[1 * 4 + 1] = y;
|
|
20382
20068
|
return multiply(from, matrix);
|
|
20383
20069
|
}
|
|
20384
20070
|
function scale3d(x, y, z, from) {
|
|
20385
20071
|
const matrix = identity();
|
|
20386
|
-
matrix[0
|
|
20387
|
-
matrix[1
|
|
20388
|
-
matrix[2
|
|
20072
|
+
matrix[0 * 4 + 0] = x;
|
|
20073
|
+
matrix[1 * 4 + 1] = y;
|
|
20074
|
+
matrix[2 * 4 + 2] = z;
|
|
20389
20075
|
return multiply(from, matrix);
|
|
20390
20076
|
}
|
|
20391
20077
|
|
|
@@ -20409,30 +20095,30 @@
|
|
|
20409
20095
|
function matrix(values) {
|
|
20410
20096
|
const matrix = identity();
|
|
20411
20097
|
if (values.length === 6) {
|
|
20412
|
-
matrix[0
|
|
20413
|
-
matrix[0
|
|
20414
|
-
matrix[1
|
|
20415
|
-
matrix[1
|
|
20416
|
-
matrix[3
|
|
20417
|
-
matrix[3
|
|
20098
|
+
matrix[0 * 4 + 0] = values[0];
|
|
20099
|
+
matrix[0 * 4 + 1] = values[1];
|
|
20100
|
+
matrix[1 * 4 + 0] = values[2];
|
|
20101
|
+
matrix[1 * 4 + 1] = values[3];
|
|
20102
|
+
matrix[3 * 4 + 0] = values[4];
|
|
20103
|
+
matrix[3 * 4 + 1] = values[5];
|
|
20418
20104
|
}
|
|
20419
20105
|
else if (values.length === 16) {
|
|
20420
|
-
matrix[0
|
|
20421
|
-
matrix[0
|
|
20422
|
-
matrix[0
|
|
20423
|
-
matrix[0
|
|
20424
|
-
matrix[1
|
|
20425
|
-
matrix[1
|
|
20426
|
-
matrix[1
|
|
20427
|
-
matrix[1
|
|
20428
|
-
matrix[2
|
|
20429
|
-
matrix[2
|
|
20430
|
-
matrix[2
|
|
20431
|
-
matrix[2
|
|
20432
|
-
matrix[3
|
|
20433
|
-
matrix[3
|
|
20434
|
-
matrix[3
|
|
20435
|
-
matrix[3
|
|
20106
|
+
matrix[0 * 4 + 0] = values[0];
|
|
20107
|
+
matrix[0 * 4 + 1] = values[1];
|
|
20108
|
+
matrix[0 * 4 + 2] = values[2];
|
|
20109
|
+
matrix[0 * 4 + 3] = values[3];
|
|
20110
|
+
matrix[1 * 4 + 0] = values[4];
|
|
20111
|
+
matrix[1 * 4 + 1] = values[5];
|
|
20112
|
+
matrix[1 * 4 + 2] = values[6];
|
|
20113
|
+
matrix[1 * 4 + 3] = values[7];
|
|
20114
|
+
matrix[2 * 4 + 0] = values[8];
|
|
20115
|
+
matrix[2 * 4 + 1] = values[9];
|
|
20116
|
+
matrix[2 * 4 + 2] = values[10];
|
|
20117
|
+
matrix[2 * 4 + 3] = values[11];
|
|
20118
|
+
matrix[3 * 4 + 0] = values[12];
|
|
20119
|
+
matrix[3 * 4 + 1] = values[13];
|
|
20120
|
+
matrix[3 * 4 + 2] = values[14];
|
|
20121
|
+
matrix[3 * 4 + 3] = values[15];
|
|
20436
20122
|
}
|
|
20437
20123
|
else {
|
|
20438
20124
|
return null;
|
|
@@ -20440,7 +20126,7 @@
|
|
|
20440
20126
|
return matrix;
|
|
20441
20127
|
}
|
|
20442
20128
|
function serialize(matrix) {
|
|
20443
|
-
matrix = matrix.
|
|
20129
|
+
matrix = matrix.slice();
|
|
20444
20130
|
// @ts-ignore
|
|
20445
20131
|
if (eq(matrix, identity())) {
|
|
20446
20132
|
return {
|
|
@@ -20454,19 +20140,19 @@
|
|
|
20454
20140
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20455
20141
|
val: 'matrix',
|
|
20456
20142
|
chi: [
|
|
20457
|
-
matrix[0
|
|
20458
|
-
matrix[0
|
|
20459
|
-
matrix[1
|
|
20460
|
-
matrix[1
|
|
20461
|
-
matrix[3
|
|
20462
|
-
matrix[3
|
|
20143
|
+
matrix[0 * 4 + 0],
|
|
20144
|
+
matrix[0 * 4 + 1],
|
|
20145
|
+
matrix[1 * 4 + 0],
|
|
20146
|
+
matrix[1 * 4 + 1],
|
|
20147
|
+
matrix[3 * 4 + 0],
|
|
20148
|
+
matrix[3 * 4 + 1]
|
|
20463
20149
|
].reduce((acc, t) => {
|
|
20464
20150
|
if (acc.length > 0) {
|
|
20465
20151
|
acc.push({ typ: exports.EnumToken.CommaTokenType });
|
|
20466
20152
|
}
|
|
20467
20153
|
acc.push({
|
|
20468
20154
|
typ: exports.EnumToken.NumberTokenType,
|
|
20469
|
-
val:
|
|
20155
|
+
val: t
|
|
20470
20156
|
});
|
|
20471
20157
|
return acc;
|
|
20472
20158
|
}, [])
|
|
@@ -20475,13 +20161,13 @@
|
|
|
20475
20161
|
return {
|
|
20476
20162
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20477
20163
|
val: 'matrix3d',
|
|
20478
|
-
chi: matrix.
|
|
20164
|
+
chi: matrix.reduce((acc, curr) => {
|
|
20479
20165
|
if (acc.length > 0) {
|
|
20480
20166
|
acc.push({ typ: exports.EnumToken.CommaTokenType });
|
|
20481
20167
|
}
|
|
20482
20168
|
acc.push({
|
|
20483
20169
|
typ: exports.EnumToken.NumberTokenType,
|
|
20484
|
-
val:
|
|
20170
|
+
val: curr
|
|
20485
20171
|
});
|
|
20486
20172
|
return acc;
|
|
20487
20173
|
}, [])
|
|
@@ -20521,26 +20207,12 @@
|
|
|
20521
20207
|
coordinates.delete(i == 0 ? 'x' : i == 1 ? 'y' : 'z');
|
|
20522
20208
|
}
|
|
20523
20209
|
}
|
|
20524
|
-
// if (coordinates.size == 3) {
|
|
20525
|
-
//
|
|
20526
|
-
// result.push({
|
|
20527
|
-
// typ: EnumToken.FunctionTokenType,
|
|
20528
|
-
// val: 'translate3d',
|
|
20529
|
-
// chi: [
|
|
20530
|
-
// {typ: EnumToken.LengthTokenType, val: round(decomposed.translate[0]) + '', unit: 'px'},
|
|
20531
|
-
// {typ: EnumToken.CommaTokenType},
|
|
20532
|
-
// {typ: EnumToken.LengthTokenType, val: round(decomposed.translate[1]) + '', unit: 'px'},
|
|
20533
|
-
// {typ: EnumToken.CommaTokenType},
|
|
20534
|
-
// {typ: EnumToken.LengthTokenType, val: round(decomposed.translate[2]) + '', unit: 'px'}
|
|
20535
|
-
// ]
|
|
20536
|
-
// })
|
|
20537
|
-
// } else
|
|
20538
20210
|
if (coordinates.size == 1) {
|
|
20539
20211
|
if (coordinates.has('x')) {
|
|
20540
20212
|
result.push({
|
|
20541
20213
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20542
20214
|
val: 'translate',
|
|
20543
|
-
chi: [{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[0])
|
|
20215
|
+
chi: [{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[0]), unit: 'px' }]
|
|
20544
20216
|
});
|
|
20545
20217
|
}
|
|
20546
20218
|
else {
|
|
@@ -20549,7 +20221,7 @@
|
|
|
20549
20221
|
result.push({
|
|
20550
20222
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20551
20223
|
val: 'translate' + axis.toUpperCase(),
|
|
20552
|
-
chi: [{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[index])
|
|
20224
|
+
chi: [{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[index]), unit: 'px' }]
|
|
20553
20225
|
});
|
|
20554
20226
|
}
|
|
20555
20227
|
}
|
|
@@ -20560,15 +20232,15 @@
|
|
|
20560
20232
|
chi: [
|
|
20561
20233
|
decomposed.translate[0] == 0 ? {
|
|
20562
20234
|
typ: exports.EnumToken.NumberTokenType,
|
|
20563
|
-
|
|
20564
|
-
} : { typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[0])
|
|
20235
|
+
val: 0
|
|
20236
|
+
} : { typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[0]), unit: 'px' },
|
|
20565
20237
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20566
20238
|
decomposed.translate[1] == 0 ? {
|
|
20567
20239
|
typ: exports.EnumToken.NumberTokenType,
|
|
20568
|
-
|
|
20569
|
-
} : { typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[1])
|
|
20240
|
+
val: 0
|
|
20241
|
+
} : { typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[1]), unit: 'px' },
|
|
20570
20242
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20571
|
-
{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[2])
|
|
20243
|
+
{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[2]), unit: 'px' }
|
|
20572
20244
|
]
|
|
20573
20245
|
});
|
|
20574
20246
|
}
|
|
@@ -20577,9 +20249,9 @@
|
|
|
20577
20249
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20578
20250
|
val: 'translate',
|
|
20579
20251
|
chi: [
|
|
20580
|
-
{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[0])
|
|
20252
|
+
{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[0]), unit: 'px' },
|
|
20581
20253
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20582
|
-
{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[1])
|
|
20254
|
+
{ typ: exports.EnumToken.LengthTokenType, val: round(decomposed.translate[1]), unit: 'px' }
|
|
20583
20255
|
]
|
|
20584
20256
|
});
|
|
20585
20257
|
}
|
|
@@ -20593,7 +20265,7 @@
|
|
|
20593
20265
|
chi: [
|
|
20594
20266
|
{
|
|
20595
20267
|
typ: exports.EnumToken.AngleTokenType,
|
|
20596
|
-
val:
|
|
20268
|
+
val: round(angle),
|
|
20597
20269
|
unit: 'deg'
|
|
20598
20270
|
}
|
|
20599
20271
|
]
|
|
@@ -20606,7 +20278,7 @@
|
|
|
20606
20278
|
chi: [
|
|
20607
20279
|
{
|
|
20608
20280
|
typ: exports.EnumToken.AngleTokenType,
|
|
20609
|
-
val:
|
|
20281
|
+
val: round(angle),
|
|
20610
20282
|
unit: 'deg'
|
|
20611
20283
|
}
|
|
20612
20284
|
]
|
|
@@ -20619,7 +20291,7 @@
|
|
|
20619
20291
|
chi: [
|
|
20620
20292
|
{
|
|
20621
20293
|
typ: exports.EnumToken.AngleTokenType,
|
|
20622
|
-
val:
|
|
20294
|
+
val: round(angle),
|
|
20623
20295
|
unit: 'deg'
|
|
20624
20296
|
}
|
|
20625
20297
|
]
|
|
@@ -20632,22 +20304,22 @@
|
|
|
20632
20304
|
chi: [
|
|
20633
20305
|
{
|
|
20634
20306
|
typ: exports.EnumToken.NumberTokenType,
|
|
20635
|
-
val:
|
|
20307
|
+
val: round(x)
|
|
20636
20308
|
},
|
|
20637
20309
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20638
20310
|
{
|
|
20639
20311
|
typ: exports.EnumToken.NumberTokenType,
|
|
20640
|
-
val:
|
|
20312
|
+
val: round(y)
|
|
20641
20313
|
},
|
|
20642
20314
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20643
20315
|
{
|
|
20644
20316
|
typ: exports.EnumToken.NumberTokenType,
|
|
20645
|
-
val:
|
|
20317
|
+
val: round(z)
|
|
20646
20318
|
},
|
|
20647
20319
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20648
20320
|
{
|
|
20649
20321
|
typ: exports.EnumToken.AngleTokenType,
|
|
20650
|
-
val:
|
|
20322
|
+
val: round(angle),
|
|
20651
20323
|
unit: 'deg'
|
|
20652
20324
|
}
|
|
20653
20325
|
]
|
|
@@ -20670,7 +20342,7 @@
|
|
|
20670
20342
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20671
20343
|
val: 'skew' + (skew.has('x') ? '' : 'Y'),
|
|
20672
20344
|
chi: [
|
|
20673
|
-
{ typ: exports.EnumToken.AngleTokenType, val:
|
|
20345
|
+
{ typ: exports.EnumToken.AngleTokenType, val: round(decomposed.skew[0]), unit: 'deg' }
|
|
20674
20346
|
]
|
|
20675
20347
|
});
|
|
20676
20348
|
}
|
|
@@ -20679,9 +20351,9 @@
|
|
|
20679
20351
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20680
20352
|
val: 'skew',
|
|
20681
20353
|
chi: [
|
|
20682
|
-
{ typ: exports.EnumToken.AngleTokenType, val:
|
|
20354
|
+
{ typ: exports.EnumToken.AngleTokenType, val: round(decomposed.skew[0]), unit: 'deg' },
|
|
20683
20355
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20684
|
-
{ typ: exports.EnumToken.AngleTokenType, val:
|
|
20356
|
+
{ typ: exports.EnumToken.AngleTokenType, val: round(decomposed.skew[1]), unit: 'deg' }
|
|
20685
20357
|
]
|
|
20686
20358
|
});
|
|
20687
20359
|
}
|
|
@@ -20703,7 +20375,7 @@
|
|
|
20703
20375
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20704
20376
|
val: 'scale' + prefix,
|
|
20705
20377
|
chi: [
|
|
20706
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
20378
|
+
{ typ: exports.EnumToken.NumberTokenType, val: round(prefix == 'Z' ? sz : prefix == 'Y' ? sy : sx) }
|
|
20707
20379
|
]
|
|
20708
20380
|
});
|
|
20709
20381
|
}
|
|
@@ -20712,9 +20384,9 @@
|
|
|
20712
20384
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20713
20385
|
val: 'scale',
|
|
20714
20386
|
chi: [
|
|
20715
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
20387
|
+
{ typ: exports.EnumToken.NumberTokenType, val: round(sx) },
|
|
20716
20388
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20717
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
20389
|
+
{ typ: exports.EnumToken.NumberTokenType, val: round(sy) },
|
|
20718
20390
|
]
|
|
20719
20391
|
});
|
|
20720
20392
|
}
|
|
@@ -20723,25 +20395,15 @@
|
|
|
20723
20395
|
typ: exports.EnumToken.FunctionTokenType,
|
|
20724
20396
|
val: 'scale3d',
|
|
20725
20397
|
chi: [
|
|
20726
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
20398
|
+
{ typ: exports.EnumToken.NumberTokenType, val: round(sx) },
|
|
20727
20399
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20728
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
20400
|
+
{ typ: exports.EnumToken.NumberTokenType, val: round(sy) },
|
|
20729
20401
|
{ typ: exports.EnumToken.CommaTokenType },
|
|
20730
|
-
{ typ: exports.EnumToken.NumberTokenType, val:
|
|
20402
|
+
{ typ: exports.EnumToken.NumberTokenType, val: round(sz) }
|
|
20731
20403
|
]
|
|
20732
20404
|
});
|
|
20733
20405
|
}
|
|
20734
20406
|
}
|
|
20735
|
-
// if (transforms.has('perspective')) {
|
|
20736
|
-
//
|
|
20737
|
-
// result.push({
|
|
20738
|
-
// typ: EnumToken.FunctionTokenType,
|
|
20739
|
-
// val: 'perspective',
|
|
20740
|
-
// chi: [
|
|
20741
|
-
// {typ: EnumToken.Length, val: '' + round(1 / decomposed.perspective[2]), unit: 'px'},
|
|
20742
|
-
// ]
|
|
20743
|
-
// });
|
|
20744
|
-
// }
|
|
20745
20407
|
// identity
|
|
20746
20408
|
return result.length == 0 || (result.length == 1 && eqMatrix(identity(), result)) ? [
|
|
20747
20409
|
{
|
|
@@ -20751,10 +20413,13 @@
|
|
|
20751
20413
|
] : result;
|
|
20752
20414
|
}
|
|
20753
20415
|
function eqMatrix(a, b) {
|
|
20416
|
+
// console.error(JSON.stringify({a, b}, null, 1));
|
|
20754
20417
|
let mat = identity();
|
|
20755
20418
|
let tmp = identity();
|
|
20756
20419
|
// @ts-ignore
|
|
20757
|
-
const data = Array.isArray(a) ? a : parseMatrix(a);
|
|
20420
|
+
const data = (Array.isArray(a) ? a : parseMatrix(a));
|
|
20421
|
+
// toZero(data);
|
|
20422
|
+
// console.error({data});
|
|
20758
20423
|
for (const transform of b) {
|
|
20759
20424
|
tmp = computeMatrix([transform], identity());
|
|
20760
20425
|
if (tmp == null) {
|
|
@@ -20762,12 +20427,14 @@
|
|
|
20762
20427
|
}
|
|
20763
20428
|
mat = multiply(mat, tmp);
|
|
20764
20429
|
}
|
|
20430
|
+
// toZero(mat);
|
|
20431
|
+
// console.error({mat});
|
|
20765
20432
|
if (mat == null) {
|
|
20766
20433
|
return false;
|
|
20767
20434
|
}
|
|
20768
20435
|
for (let i = 0; i < 4; i++) {
|
|
20769
20436
|
for (let j = 0; j < 4; j++) {
|
|
20770
|
-
if (Math.abs(mat[i
|
|
20437
|
+
if (Math.abs(mat[i * 4 + j] - data[i * 4 + j]) > epsilon) {
|
|
20771
20438
|
return false;
|
|
20772
20439
|
}
|
|
20773
20440
|
}
|
|
@@ -20777,20 +20444,20 @@
|
|
|
20777
20444
|
|
|
20778
20445
|
function skewX(x, from) {
|
|
20779
20446
|
const matrix = identity();
|
|
20780
|
-
matrix[1
|
|
20447
|
+
matrix[1 * 4 + 0] = Math.tan(x);
|
|
20781
20448
|
return multiply(from, matrix);
|
|
20782
20449
|
}
|
|
20783
20450
|
function skewY(y, from) {
|
|
20784
20451
|
const matrix = identity();
|
|
20785
|
-
matrix[0
|
|
20452
|
+
matrix[0 * 4 + 1] = Math.tan(y);
|
|
20786
20453
|
return multiply(from, matrix);
|
|
20787
20454
|
}
|
|
20788
20455
|
// convert angle to radian
|
|
20789
20456
|
function skew(values, from) {
|
|
20790
20457
|
const matrix = identity();
|
|
20791
|
-
matrix[1
|
|
20458
|
+
matrix[1 * 4 + 0] = Math.tan(values[0]);
|
|
20792
20459
|
if (values.length > 1) {
|
|
20793
|
-
matrix[0
|
|
20460
|
+
matrix[0 * 4 + 1] = Math.tan(values[1]);
|
|
20794
20461
|
}
|
|
20795
20462
|
return multiply(from, matrix);
|
|
20796
20463
|
}
|
|
@@ -20798,17 +20465,13 @@
|
|
|
20798
20465
|
function perspective(x, from) {
|
|
20799
20466
|
const matrix = identity();
|
|
20800
20467
|
// @ts-ignore
|
|
20801
|
-
matrix[2
|
|
20468
|
+
matrix[2 * 4 + 3] = typeof x == 'object' && x.val == 'none' ? 0 : x == 0 ? Number.NEGATIVE_INFINITY : -1 / x;
|
|
20802
20469
|
return multiply(from, matrix);
|
|
20803
20470
|
}
|
|
20804
20471
|
|
|
20805
20472
|
function compute(transformLists) {
|
|
20806
20473
|
transformLists = transformLists.slice();
|
|
20807
20474
|
stripCommaToken(transformLists);
|
|
20808
|
-
// if (transformLists.length == 0) {
|
|
20809
|
-
//
|
|
20810
|
-
// return null;
|
|
20811
|
-
// }
|
|
20812
20475
|
let matrix = identity();
|
|
20813
20476
|
let mat;
|
|
20814
20477
|
const cumulative = [];
|
|
@@ -20833,8 +20496,10 @@
|
|
|
20833
20496
|
});
|
|
20834
20497
|
}
|
|
20835
20498
|
}
|
|
20499
|
+
// console.error({matrix});
|
|
20500
|
+
// matrix = toZero(matrix) as Matrix;
|
|
20836
20501
|
return {
|
|
20837
|
-
matrix: serialize(matrix),
|
|
20502
|
+
matrix: serialize(toZero(matrix)),
|
|
20838
20503
|
cumulative,
|
|
20839
20504
|
minified: minify$1(matrix) ?? [serialized]
|
|
20840
20505
|
};
|
|
@@ -20844,10 +20509,6 @@
|
|
|
20844
20509
|
let val;
|
|
20845
20510
|
let i = 0;
|
|
20846
20511
|
for (; i < transformList.length; i++) {
|
|
20847
|
-
// if (transformList[i].typ == EnumToken.WhitespaceTokenType) {
|
|
20848
|
-
//
|
|
20849
|
-
// continue;
|
|
20850
|
-
// }
|
|
20851
20512
|
if (transformList[i].typ != exports.EnumToken.FunctionTokenType || !transformFunctions.includes(transformList[i].val)) {
|
|
20852
20513
|
return null;
|
|
20853
20514
|
}
|
|
@@ -20860,16 +20521,7 @@
|
|
|
20860
20521
|
{
|
|
20861
20522
|
values.length = 0;
|
|
20862
20523
|
const children = stripCommaToken(transformList[i].chi.slice());
|
|
20863
|
-
// if (children == null || children.length == 0) {
|
|
20864
|
-
//
|
|
20865
|
-
// return null;
|
|
20866
|
-
// }
|
|
20867
20524
|
const valCount = transformList[i].val == 'translate3d' || transformList[i].val == 'translate' ? 3 : 1;
|
|
20868
|
-
// if (children.length == 1 && children[0].typ == EnumToken.IdenTokenType && (children[0] as IdentToken).val == 'none') {
|
|
20869
|
-
//
|
|
20870
|
-
// values.fill(0, 0, valCount);
|
|
20871
|
-
//
|
|
20872
|
-
// } else {
|
|
20873
20525
|
for (let j = 0; j < children.length; j++) {
|
|
20874
20526
|
if (children[j].typ == exports.EnumToken.WhitespaceTokenType) {
|
|
20875
20527
|
continue;
|
|
@@ -20880,7 +20532,6 @@
|
|
|
20880
20532
|
}
|
|
20881
20533
|
values.push(val);
|
|
20882
20534
|
}
|
|
20883
|
-
// }
|
|
20884
20535
|
if (values.length == 0 || values.length > valCount) {
|
|
20885
20536
|
return null;
|
|
20886
20537
|
}
|
|
@@ -20915,10 +20566,6 @@
|
|
|
20915
20566
|
let values = [];
|
|
20916
20567
|
let valuesCount = transformList[i].val == 'rotate3d' ? 4 : 1;
|
|
20917
20568
|
for (const child of stripCommaToken(transformList[i].chi.slice())) {
|
|
20918
|
-
// if (child.typ == EnumToken.WhitespaceTokenType) {
|
|
20919
|
-
//
|
|
20920
|
-
// continue;
|
|
20921
|
-
// }
|
|
20922
20569
|
values.push(child);
|
|
20923
20570
|
if (transformList[i].val == 'rotateX') {
|
|
20924
20571
|
x = 1;
|
|
@@ -20961,19 +20608,11 @@
|
|
|
20961
20608
|
const children = stripCommaToken(transformList[i].chi.slice());
|
|
20962
20609
|
for (let k = 0; k < children.length; k++) {
|
|
20963
20610
|
child = children[k];
|
|
20964
|
-
// if (child.typ == EnumToken.CommentTokenType || child.typ == EnumToken.WhitespaceTokenType) {
|
|
20965
|
-
//
|
|
20966
|
-
// continue;
|
|
20967
|
-
// }
|
|
20968
20611
|
if (child.typ != exports.EnumToken.NumberTokenType) {
|
|
20969
20612
|
return null;
|
|
20970
20613
|
}
|
|
20971
20614
|
values.push(getNumber(child));
|
|
20972
20615
|
}
|
|
20973
|
-
// if (values.length == 0) {
|
|
20974
|
-
//
|
|
20975
|
-
// return null;
|
|
20976
|
-
// }
|
|
20977
20616
|
if (transformList[i].val == 'scale3d') {
|
|
20978
20617
|
if (values.length != 3) {
|
|
20979
20618
|
return null;
|
|
@@ -21017,10 +20656,6 @@
|
|
|
21017
20656
|
continue;
|
|
21018
20657
|
}
|
|
21019
20658
|
value = getAngle(child);
|
|
21020
|
-
// if (value == null) {
|
|
21021
|
-
//
|
|
21022
|
-
// return null;
|
|
21023
|
-
// }
|
|
21024
20659
|
values.push(value * 2 * Math.PI);
|
|
21025
20660
|
}
|
|
21026
20661
|
if (values.length == 0 || (values.length > (transformList[i].val == 'skew' ? 2 : 1))) {
|
|
@@ -21061,7 +20696,6 @@
|
|
|
21061
20696
|
}
|
|
21062
20697
|
break;
|
|
21063
20698
|
case 'matrix3d':
|
|
21064
|
-
// return null;
|
|
21065
20699
|
case 'matrix':
|
|
21066
20700
|
{
|
|
21067
20701
|
const values = [];
|
|
@@ -21160,11 +20794,11 @@
|
|
|
21160
20794
|
const children = node.val.reduce((acc, curr) => {
|
|
21161
20795
|
if (curr.typ == exports.EnumToken.FunctionTokenType && 'skew' == curr.val.toLowerCase()) {
|
|
21162
20796
|
if (curr.chi.length == 3) {
|
|
21163
|
-
if (curr.chi[2].val ==
|
|
20797
|
+
if (curr.chi[2].val == 0) {
|
|
21164
20798
|
curr.chi.length = 1;
|
|
21165
20799
|
curr.val = 'skew';
|
|
21166
20800
|
}
|
|
21167
|
-
else if (curr.chi[0].val ==
|
|
20801
|
+
else if (curr.chi[0].val == 0) {
|
|
21168
20802
|
curr.chi = [curr.chi[2]];
|
|
21169
20803
|
curr.val = 'skewY';
|
|
21170
20804
|
}
|