@tbela99/css-parser 1.4.7 → 1.4.9
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 +33 -2
- package/dist/index-umd-web.js +12953 -13248
- package/dist/index.cjs +10358 -10655
- package/dist/index.d.ts +820 -89
- package/dist/lib/ast/features/calc.js +3 -1
- package/dist/lib/ast/features/if.js +2 -96
- package/dist/lib/ast/features/prefix.js +7 -2
- package/dist/lib/ast/features/shorthand.js +1 -1
- package/dist/lib/ast/features/transform.js +1 -1
- package/dist/lib/ast/find.js +6 -6
- package/dist/lib/ast/math/expression.js +30 -12
- package/dist/lib/ast/minify.js +34 -5
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/utils.js +29 -21
- package/dist/lib/ast/types.js +12 -0
- package/dist/lib/fs/resolve.js +2 -17
- package/dist/lib/parser/declaration/list.js +6 -1
- package/dist/lib/parser/linesmap.js +78 -0
- package/dist/lib/parser/parse.js +1264 -151
- package/dist/lib/parser/source.js +103 -0
- package/dist/lib/parser/tokenize.js +112 -133
- package/dist/lib/parser/utils/at-rule-container.js +12 -44
- package/dist/lib/parser/utils/at-rule-generic.js +12 -24
- package/dist/lib/parser/utils/at-rule-import.js +4 -172
- package/dist/lib/parser/utils/at-rule-media.js +27 -263
- package/dist/lib/parser/utils/at-rule-support.js +8 -258
- package/dist/lib/parser/utils/at-rule-when-else.js +4 -214
- package/dist/lib/parser/utils/declaration.js +5 -95
- package/dist/lib/parser/utils/hash.js +54 -1
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/parser/utils/token.js +1 -0
- package/dist/lib/renderer/render.js +79 -45
- package/dist/lib/renderer/sourcemap/sourcemap.js +47 -43
- package/dist/lib/syntax/color/cmyk.js +3 -3
- package/dist/lib/syntax/color/color-mix.js +15 -8
- package/dist/lib/syntax/color/color.js +19 -11
- package/dist/lib/syntax/color/hex.js +1 -1
- package/dist/lib/syntax/color/hsl.js +6 -6
- package/dist/lib/syntax/color/hwb.js +6 -6
- package/dist/lib/syntax/color/lab.js +5 -5
- package/dist/lib/syntax/color/lch.js +6 -6
- package/dist/lib/syntax/color/oklab.js +5 -5
- package/dist/lib/syntax/color/oklch.js +5 -5
- package/dist/lib/syntax/color/p3.js +9 -1
- package/dist/lib/syntax/color/{relativecolor.js → relative-color.js} +8 -1
- package/dist/lib/syntax/color/utils/distance.js +7 -2
- package/dist/lib/syntax/constants.js +5 -1
- package/dist/lib/syntax/syntax.js +12 -21
- package/dist/lib/validation/config.json.js +27 -6
- package/dist/lib/validation/match.js +42 -845
- package/dist/node.js +136 -11
- package/dist/web.js +135 -8
- package/llms.txt +73 -0
- package/package.json +14 -17
|
@@ -51,65 +51,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
51
51
|
if (i < stream.length) {
|
|
52
52
|
if (stream[i].typ === EnumToken.IdenTokenType) {
|
|
53
53
|
const val = stream[i].val.toLowerCase();
|
|
54
|
-
// if ("not" === val || "only" === val) {
|
|
55
|
-
// tokens.push(stream[i]);
|
|
56
|
-
// stack.push(stream[i]);
|
|
57
|
-
// i++;
|
|
58
|
-
// while (
|
|
59
|
-
// i < stream.length &&
|
|
60
|
-
// (stream[i]?.typ === EnumToken.WhitespaceTokenType ||
|
|
61
|
-
// stream[i]?.typ === EnumToken.CommentTokenType)
|
|
62
|
-
// ) {
|
|
63
|
-
// tokens.push(stream[i]);
|
|
64
|
-
// i++;
|
|
65
|
-
// }
|
|
66
|
-
// if (
|
|
67
|
-
// stream[i]?.typ !== EnumToken.IdenTokenType ||
|
|
68
|
-
// !mediaTypes.includes((stream[i] as IdentToken).val.toLowerCase())
|
|
69
|
-
// ) {
|
|
70
|
-
// errors.push({
|
|
71
|
-
// action: "drop",
|
|
72
|
-
// node: stream[i],
|
|
73
|
-
// message: `expecting '<media-type>' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
|
|
74
|
-
// });
|
|
75
|
-
// continue;
|
|
76
|
-
// }
|
|
77
|
-
// const index: number = tokens.indexOf(stack[stack.length - 1]);
|
|
78
|
-
// tokens[index][LOC] = { ...tokens[index][LOC]!, end: stream[i][LOC]!.end };
|
|
79
|
-
// tokens[index] = Object.assign(tokens[index], {
|
|
80
|
-
// typ: val === "not" ? EnumToken.NotTokenType : EnumToken.OnlyTokenType,
|
|
81
|
-
// val: stream[i],
|
|
82
|
-
// });
|
|
83
|
-
// tokens.length = index + 1;
|
|
84
|
-
// i++;
|
|
85
|
-
// // expect end of stream | and | or | not
|
|
86
|
-
// while (
|
|
87
|
-
// i < stream.length &&
|
|
88
|
-
// (stream[i]?.typ === EnumToken.WhitespaceTokenType ||
|
|
89
|
-
// stream[i]?.typ === EnumToken.CommentTokenType)
|
|
90
|
-
// ) {
|
|
91
|
-
// tokens.push(stream[i]);
|
|
92
|
-
// i++;
|
|
93
|
-
// }
|
|
94
|
-
// if (i < stream.length) {
|
|
95
|
-
// if (stream[i].typ === EnumToken.AndTokenType) {
|
|
96
|
-
// tokens.push(Object.assign(stream[i], { typ: EnumToken.AndTokenType }));
|
|
97
|
-
// stack.push(stream[i]);
|
|
98
|
-
// i++;
|
|
99
|
-
// } else if (stream[i].typ === EnumToken.OrTokenType) {
|
|
100
|
-
// tokens.push(Object.assign(stream[i], { typ: EnumToken.OrTokenType }));
|
|
101
|
-
// stack.push(stream[i]);
|
|
102
|
-
// i++;
|
|
103
|
-
// } else {
|
|
104
|
-
// success = false;
|
|
105
|
-
// errors.push({
|
|
106
|
-
// action: "drop",
|
|
107
|
-
// node: stream[i],
|
|
108
|
-
// message: `expecting 'and' or 'or' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
|
|
109
|
-
// });
|
|
110
|
-
// }
|
|
111
|
-
// }
|
|
112
|
-
// } else
|
|
113
54
|
if (mediaTypes.includes(val)) {
|
|
114
55
|
tokens.push(stream[i]);
|
|
115
56
|
i++;
|
|
@@ -118,9 +59,9 @@ function parseMediaqueryList(stream, options) {
|
|
|
118
59
|
success = false;
|
|
119
60
|
errors.push({
|
|
120
61
|
action: "drop",
|
|
121
|
-
message: `expecting '<media-type>'
|
|
62
|
+
message: `expecting '<media-type>'`,
|
|
122
63
|
node: stream[i],
|
|
123
|
-
location: stream[i][LOC],
|
|
64
|
+
location: options.source.getSourceLocation(stream[i][LOC].sta),
|
|
124
65
|
});
|
|
125
66
|
}
|
|
126
67
|
}
|
|
@@ -128,9 +69,9 @@ function parseMediaqueryList(stream, options) {
|
|
|
128
69
|
success = false;
|
|
129
70
|
errors.push({
|
|
130
71
|
action: "drop",
|
|
131
|
-
message: `expecting '('
|
|
72
|
+
message: `expecting '('`,
|
|
132
73
|
node: stream[i],
|
|
133
|
-
location: stream[i][LOC],
|
|
74
|
+
location: options.source.getSourceLocation(stream[i][LOC].sta),
|
|
134
75
|
});
|
|
135
76
|
}
|
|
136
77
|
}
|
|
@@ -143,15 +84,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
143
84
|
if (stream[i].typ === EnumToken.IdenTokenType) {
|
|
144
85
|
stream[i].val.toLowerCase();
|
|
145
86
|
}
|
|
146
|
-
// if (!valid) {
|
|
147
|
-
// success = false;
|
|
148
|
-
// errors.push({
|
|
149
|
-
// action: "drop",
|
|
150
|
-
// node: stream[i],
|
|
151
|
-
// message: `expecting <and>, <or> or comma at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
|
|
152
|
-
// });
|
|
153
|
-
// break;
|
|
154
|
-
// }
|
|
155
87
|
expectAndOrComma = false;
|
|
156
88
|
}
|
|
157
89
|
if (stream[i].typ === EnumToken.StartParensTokenType || tokensfuncDefMap.has(stream[i].typ)) {
|
|
@@ -160,14 +92,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
160
92
|
continue;
|
|
161
93
|
}
|
|
162
94
|
switch (stream[i].typ) {
|
|
163
|
-
// case EnumToken.LiteralTokenType:
|
|
164
|
-
// if ((stream[i] as LiteralToken).val === "<") {
|
|
165
|
-
// stack.push(Object.assign(stream[i], { typ: EnumToken.LtTokenType }));
|
|
166
|
-
// }
|
|
167
|
-
// if ((stream[i] as LiteralToken).val === ">") {
|
|
168
|
-
// stack.push(Object.assign(stream[i], { typ: EnumToken.GtTokenType }));
|
|
169
|
-
// }
|
|
170
|
-
// break;
|
|
171
95
|
case EnumToken.ColonTokenType:
|
|
172
96
|
case EnumToken.LtTokenType:
|
|
173
97
|
case EnumToken.LteTokenType:
|
|
@@ -179,12 +103,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
179
103
|
case EnumToken.IdenTokenType:
|
|
180
104
|
{
|
|
181
105
|
const val = stream[i].val.toLowerCase();
|
|
182
|
-
// if (val === "not" || val === "only") {
|
|
183
|
-
// Object.assign(stream[i], {
|
|
184
|
-
// typ: val === "not" ? EnumToken.NotTokenType : EnumToken.OnlyTokenType,
|
|
185
|
-
// });
|
|
186
|
-
// stack.push(stream[i]);
|
|
187
|
-
// } else
|
|
188
106
|
if (val === "and" || val === "or") {
|
|
189
107
|
Object.assign(stream[i], {
|
|
190
108
|
typ: val === "and" ? EnumToken.AndTokenType : EnumToken.OrTokenType,
|
|
@@ -194,7 +112,8 @@ function parseMediaqueryList(stream, options) {
|
|
|
194
112
|
errors.push({
|
|
195
113
|
action: "drop",
|
|
196
114
|
node: stream[i],
|
|
197
|
-
message: `<or> is not allowed outside of parentheses
|
|
115
|
+
message: `<or> is not allowed outside of parentheses`,
|
|
116
|
+
location: options.source.getSourceLocation(stream[i][LOC].sta),
|
|
198
117
|
});
|
|
199
118
|
break;
|
|
200
119
|
}
|
|
@@ -203,7 +122,8 @@ function parseMediaqueryList(stream, options) {
|
|
|
203
122
|
errors.push({
|
|
204
123
|
action: "drop",
|
|
205
124
|
node: stream[i],
|
|
206
|
-
message: `cannot mix <and> and <or> at the same level
|
|
125
|
+
message: `cannot mix <and> and <or> at the same level`,
|
|
126
|
+
location: options.source.getSourceLocation(stream[i][LOC].sta),
|
|
207
127
|
});
|
|
208
128
|
}
|
|
209
129
|
currentScope.add(stream[i].typ);
|
|
@@ -236,32 +156,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
236
156
|
const index = tokens.indexOf(stack.at(-1));
|
|
237
157
|
const prevToken = stack[stack.length - 2];
|
|
238
158
|
if (mFLT.has(prevToken?.typ) || mFGT.has(prevToken?.typ)) {
|
|
239
|
-
// if (stack[stack.length - 3]?.typ !== EnumToken.StartParensTokenType) {
|
|
240
|
-
// success = false;
|
|
241
|
-
// errors.push({
|
|
242
|
-
// action: "drop",
|
|
243
|
-
// node: stream[i],
|
|
244
|
-
// message: `unmatched '(' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
|
|
245
|
-
// });
|
|
246
|
-
// break;
|
|
247
|
-
// }
|
|
248
|
-
// if (!mFLT.has(stack.at(-1)?.typ) && mFLT.has(prevToken?.typ)) {
|
|
249
|
-
// success = false;
|
|
250
|
-
// errors.push({
|
|
251
|
-
// action: "drop",
|
|
252
|
-
// node: stack.at(-1),
|
|
253
|
-
// message: `expected <mf-lt> at ${stack.at(-1)?.[LOC]?.src}:${stack.at(-1)?.[LOC]?.sta.lin}:${stack.at(-1)?.[LOC]?.sta.col}`,
|
|
254
|
-
// });
|
|
255
|
-
// break;
|
|
256
|
-
// } else if (!mFGT.has(stack.at(-1)?.typ) && mFGT.has(prevToken?.typ)) {
|
|
257
|
-
// success = false;
|
|
258
|
-
// errors.push({
|
|
259
|
-
// action: "drop",
|
|
260
|
-
// node: stream[i],
|
|
261
|
-
// message: `expected <mf-gt> at ${stack.at(-1)?.[LOC]?.src}:${stack.at(-1)?.[LOC]?.sta.lin}:${stack.at(-1)?.[LOC]?.sta.col}`,
|
|
262
|
-
// });
|
|
263
|
-
// break;
|
|
264
|
-
// }
|
|
265
159
|
// const index: number = tokens.indexOf(stack.at(-1)!);
|
|
266
160
|
// <mf-lt> | <mf-name>
|
|
267
161
|
const index2 = tokens.indexOf(prevToken);
|
|
@@ -271,15 +165,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
271
165
|
const right = trimArray(tokens.slice(index + 1, tokens.length - 1));
|
|
272
166
|
const names = trimArray(tokens.slice(index2 + 1, index));
|
|
273
167
|
const filteredNames = names.filter((n) => n.typ !== EnumToken.WhitespaceTokenType && n.typ !== EnumToken.CommentTokenType);
|
|
274
|
-
// if (filteredNames.length !== 1 || filteredNames[0].typ !== EnumToken.IdenTokenType) {
|
|
275
|
-
// success = false;
|
|
276
|
-
// errors.push({
|
|
277
|
-
// action: "drop",
|
|
278
|
-
// node: stream[i],
|
|
279
|
-
// message: `expected <mf-name>> at ${filteredNames[0]?.[LOC]?.src}:${filteredNames[0]?.[LOC]?.sta.lin}:${filteredNames[0]?.[LOC]?.sta.col}`,
|
|
280
|
-
// });
|
|
281
|
-
// break;
|
|
282
|
-
// }
|
|
283
168
|
const name = filteredNames[0].val;
|
|
284
169
|
const mfInfo = getMFInfo(name);
|
|
285
170
|
for (const val of [left, right]) {
|
|
@@ -292,17 +177,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
292
177
|
val[l].val === "calc") {
|
|
293
178
|
const value = evaluate([val[l]]);
|
|
294
179
|
if (value.length == 1) {
|
|
295
|
-
// if (mfInfo?.type === MediaFeatureType.RatioType) {
|
|
296
|
-
// if (
|
|
297
|
-
// value[0].typ !== EnumToken.NumberTokenType ||
|
|
298
|
-
// !(
|
|
299
|
-
// ((value[0] as NumberToken).val as FractionToken)
|
|
300
|
-
// ?.typ === EnumToken.FractionTokenType
|
|
301
|
-
// )
|
|
302
|
-
// ) {
|
|
303
|
-
// continue;
|
|
304
|
-
// }
|
|
305
|
-
// }
|
|
306
180
|
value[0][LOC] = val[l][LOC];
|
|
307
181
|
val[l] = value[0];
|
|
308
182
|
}
|
|
@@ -311,27 +185,8 @@ function parseMediaqueryList(stream, options) {
|
|
|
311
185
|
}
|
|
312
186
|
}
|
|
313
187
|
}
|
|
314
|
-
isMFValue(name, left, true);
|
|
315
|
-
//
|
|
316
|
-
// success = false;
|
|
317
|
-
// errors.push({
|
|
318
|
-
// action: "drop",
|
|
319
|
-
// node: left[0] ?? prevToken,
|
|
320
|
-
// message: `${isValidMFValue.isValueAllowed === false ? "invalid <mf-name>" : "expected <mf-value>"} at ${(left[0] ?? prevToken)?.[LOC]?.src}:${(left[0] ?? prevToken)?.[LOC]?.sta.lin}:${(left[0] ?? prevToken)?.[LOC]?.sta.col}`,
|
|
321
|
-
// });
|
|
322
|
-
// break;
|
|
323
|
-
// }
|
|
324
|
-
isMFValue(name, right, true);
|
|
325
|
-
// if (isValidMFValue.valid && !isValidMFValue.success) {
|
|
326
|
-
// success = false;
|
|
327
|
-
// errors.push({
|
|
328
|
-
// action: "drop",
|
|
329
|
-
// node: right[0] ?? stream[i],
|
|
330
|
-
// location: (right[0] ?? stream[i])?.[LOC],
|
|
331
|
-
// message: `${isValidMFValue.isValueAllowed === false ? "invalid <mf-name>" : "expected <mf-value>"} at ${(right[0] ?? stream[i])?.[LOC]?.src}:${(right[0] ?? stream[i])?.[LOC]?.sta.lin}:${(left[0] ?? stream[i])?.[LOC]?.sta.col}`,
|
|
332
|
-
// });
|
|
333
|
-
// break;
|
|
334
|
-
// }
|
|
188
|
+
// let isValidMFValue = isMFValue(name, left, true);
|
|
189
|
+
// isValidMFValue = isMFValue(name, right, true);
|
|
335
190
|
for (const val of [left, right]) {
|
|
336
191
|
if (mfInfo?.type === MediaFeatureType.RatioType) {
|
|
337
192
|
const filteredValues = val.filter((n) => n.typ !== EnumToken.WhitespaceTokenType &&
|
|
@@ -362,74 +217,18 @@ function parseMediaqueryList(stream, options) {
|
|
|
362
217
|
stack.pop();
|
|
363
218
|
stack.pop();
|
|
364
219
|
}
|
|
365
|
-
// else if (stack[stack.length - 2]?.typ !== EnumToken.StartParensTokenType) {
|
|
366
|
-
// success = false;
|
|
367
|
-
// errors.push({
|
|
368
|
-
// action: "drop",
|
|
369
|
-
// node: stream[i],
|
|
370
|
-
// location: stream[i]?.[LOC],
|
|
371
|
-
// message: `expected '(' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
|
|
372
|
-
// });
|
|
373
|
-
// break;
|
|
374
|
-
// }
|
|
375
220
|
}
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
// success = false;
|
|
382
|
-
// errors.push({
|
|
383
|
-
// action: "drop",
|
|
384
|
-
// node: stream[i],
|
|
385
|
-
// location: stream[i]?.[LOC],
|
|
386
|
-
// message: `expected '(' at ${(stack[stack.length - 2] ?? tokens[0])?.[LOC]?.src}:${(stack[stack.length - 2] ?? tokens[0])?.[LOC]?.sta.lin}:${(stack[stack.length - 2] ?? tokens[0])?.[LOC]?.sta.col}`,
|
|
387
|
-
// });
|
|
388
|
-
// break;
|
|
389
|
-
// }
|
|
221
|
+
if (stack.length > 0 &&
|
|
222
|
+
(mFGT.has(stack.at(-1)?.typ) ||
|
|
223
|
+
mFLT.has(stack.at(-1)?.typ) ||
|
|
224
|
+
stack.at(-1)?.typ === EnumToken.DelimTokenType ||
|
|
225
|
+
stack.at(-1)?.typ === EnumToken.ColonTokenType)) {
|
|
390
226
|
const index2 = tokens.indexOf(stack.at(-1));
|
|
391
227
|
const index3 = tokens.indexOf(stack.at(-2));
|
|
392
228
|
let names = trimArray(tokens.slice(index3 + 1, index2));
|
|
393
229
|
let values = trimArray(tokens.slice(index2 + 1, tokens.length - 1));
|
|
394
|
-
// if (stack.at(-1)?.typ !== EnumToken.ColonTokenType) {
|
|
395
|
-
// const filteredNames = names.filter(
|
|
396
|
-
// (n) =>
|
|
397
|
-
// n.typ !== EnumToken.WhitespaceTokenType && n.typ !== EnumToken.CommentTokenType,
|
|
398
|
-
// );
|
|
399
|
-
// if (
|
|
400
|
-
// filteredNames.length !== 1 ||
|
|
401
|
-
// (filteredNames[0].typ !== EnumToken.IdenTokenType &&
|
|
402
|
-
// filteredNames[0].typ !== EnumToken.DashedIdenTokenType)
|
|
403
|
-
// ) {
|
|
404
|
-
// swapped = true;
|
|
405
|
-
// }
|
|
406
|
-
// }
|
|
407
230
|
const filteredNames = (names).filter((n) => n.typ !== EnumToken.WhitespaceTokenType && n.typ !== EnumToken.CommentTokenType);
|
|
408
|
-
// if (
|
|
409
|
-
// filteredNames.length !== 1 ||
|
|
410
|
-
// (filteredNames[0].typ !== EnumToken.IdenTokenType &&
|
|
411
|
-
// filteredNames[0].typ !== EnumToken.DashedIdenTokenType)
|
|
412
|
-
// ) {
|
|
413
|
-
// success = false;
|
|
414
|
-
// errors.push({
|
|
415
|
-
// action: "drop",
|
|
416
|
-
// node: names[0] ?? stack.at(-1),
|
|
417
|
-
// location: names[0]?.[LOC],
|
|
418
|
-
// message: `expected <mf-name> at ${(names[0] ?? stack.at(-1))?.[LOC]?.src}:${(names[0] ?? stack.at(-1))?.[LOC]?.sta.lin}:${(names[0] ?? stack.at(-1))?.[LOC]?.sta.col}`,
|
|
419
|
-
// });
|
|
420
|
-
// break;
|
|
421
|
-
// }
|
|
422
231
|
const name = filteredNames[0].val;
|
|
423
|
-
// if (!isMFName(name)) {
|
|
424
|
-
// success = false;
|
|
425
|
-
// errors.push({
|
|
426
|
-
// action: "drop",
|
|
427
|
-
// node: names[0] ?? stack.at(-1),
|
|
428
|
-
// location: names[0]?.[LOC] ?? stack.at(-1)?.[LOC],
|
|
429
|
-
// message: `expected <mf-name> at ${names[0]?.[LOC]?.src}:${names[0]?.[LOC]?.sta.lin}:${names[0]?.[LOC]?.sta.col}`,
|
|
430
|
-
// });
|
|
431
|
-
// break;
|
|
432
|
-
// }
|
|
433
232
|
const mfInfo = getMFInfo(name);
|
|
434
233
|
if (options.computeCalcExpression) {
|
|
435
234
|
if (mfInfo == null ||
|
|
@@ -441,17 +240,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
441
240
|
val[l].val === "calc") {
|
|
442
241
|
const value = evaluate([val[l]]);
|
|
443
242
|
if (value.length == 1) {
|
|
444
|
-
// if (mfInfo?.type === MediaFeatureType.RatioType) {
|
|
445
|
-
// if (
|
|
446
|
-
// value[0].typ !== EnumToken.NumberTokenType ||
|
|
447
|
-
// !(
|
|
448
|
-
// ((value[0] as NumberToken).val as FractionToken)?.typ ===
|
|
449
|
-
// EnumToken.FractionTokenType
|
|
450
|
-
// )
|
|
451
|
-
// ) {
|
|
452
|
-
// continue;
|
|
453
|
-
// }
|
|
454
|
-
// }
|
|
455
243
|
value[0][LOC] = val[l][LOC];
|
|
456
244
|
val[l] = value[0];
|
|
457
245
|
}
|
|
@@ -468,8 +256,8 @@ function parseMediaqueryList(stream, options) {
|
|
|
468
256
|
errors.push({
|
|
469
257
|
action: "drop",
|
|
470
258
|
node: arr[0],
|
|
471
|
-
location: arr[0]?.[LOC],
|
|
472
|
-
message: `${mfValue.isValueAllowed === false ? "invalid <mf-name>" : "expected <mf-value>"}
|
|
259
|
+
location: options.source.getSourceLocation(arr[0]?.[LOC].sta),
|
|
260
|
+
message: `${mfValue.isValueAllowed === false ? "invalid <mf-name>" : "expected <mf-value>"}`,
|
|
473
261
|
});
|
|
474
262
|
break;
|
|
475
263
|
}
|
|
@@ -498,16 +286,16 @@ function parseMediaqueryList(stream, options) {
|
|
|
498
286
|
[LOC]: { ...names[0][LOC], end: values.at(-1)[LOC].end },
|
|
499
287
|
});
|
|
500
288
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
289
|
+
if (stack.length === 0) {
|
|
290
|
+
success = false;
|
|
291
|
+
errors.push({
|
|
292
|
+
action: "drop",
|
|
293
|
+
node: stream[i],
|
|
294
|
+
location: options.source.getSourceLocation(stream[i]?.[LOC].sta),
|
|
295
|
+
message: `unmatched ')'`,
|
|
296
|
+
});
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
511
299
|
{
|
|
512
300
|
const index = tokens.indexOf(stack.at(-1));
|
|
513
301
|
tokens[index] = {
|
|
@@ -520,21 +308,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
520
308
|
scopes.pop();
|
|
521
309
|
currentScope = scopes.at(-1);
|
|
522
310
|
stack.pop();
|
|
523
|
-
// if (
|
|
524
|
-
// stack.at(-1)?.typ === EnumToken.NotTokenType ||
|
|
525
|
-
// stack.at(-1)?.typ === EnumToken.OnlyTokenType
|
|
526
|
-
// ) {
|
|
527
|
-
// const index = tokens.indexOf(stack.at(-1)!);
|
|
528
|
-
// const slice = trimArray(tokens.slice(index + 1));
|
|
529
|
-
// tokens[index] = {
|
|
530
|
-
// typ: EnumToken.MediaQueryUnaryFeatureTokenType,
|
|
531
|
-
// l: stack.pop()!,
|
|
532
|
-
// r: slice,
|
|
533
|
-
// // @ts-expect-error
|
|
534
|
-
// [LOC]: { ...tokens[index][LOC]!, end: slice.at(-1)![LOC]!.end } as Location,
|
|
535
|
-
// };
|
|
536
|
-
// tokens.length = index + 1;
|
|
537
|
-
// }
|
|
538
311
|
if (stack.at(-1)?.typ === EnumToken.AndTokenType ||
|
|
539
312
|
stack.at(-1)?.typ === EnumToken.OrTokenType) {
|
|
540
313
|
const index = tokens.indexOf(stack.at(-1));
|
|
@@ -563,15 +336,6 @@ function parseMediaqueryList(stream, options) {
|
|
|
563
336
|
break;
|
|
564
337
|
}
|
|
565
338
|
}
|
|
566
|
-
// if (success && stack.length > 0) {
|
|
567
|
-
// success = false;
|
|
568
|
-
// errors.push({
|
|
569
|
-
// action: "drop",
|
|
570
|
-
// node: stack.at(-1),
|
|
571
|
-
// location: stack.at(-1)?.[LOC],
|
|
572
|
-
// message: `unmatched token '${EnumToken[stack.at(-1)?.typ]}' at ${stack.at(-1)?.[LOC]?.src}:${stack.at(-1)?.[LOC]?.sta.lin}:${stack.at(-1)?.[LOC]?.sta.col}`,
|
|
573
|
-
// });
|
|
574
|
-
// }
|
|
575
339
|
if (!success) {
|
|
576
340
|
hasErrors = true;
|
|
577
341
|
parts.splice(parts.indexOf(stream), 1);
|