@tbela99/css-parser 1.6.1 → 1.6.3
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 +119 -2
- package/README.md +1 -0
- package/dist/index-umd-web.js +1214 -247
- package/dist/index.cjs +1214 -247
- package/dist/index.d.ts +71 -6
- package/dist/lib/ast/features/prefix.js +9 -1
- package/dist/lib/ast/features/shorthand.js +1 -1
- package/dist/lib/ast/math/expression.js +156 -1
- package/dist/lib/ast/transform/compute.js +4 -8
- package/dist/lib/ast/types.js +12 -0
- package/dist/lib/parser/declaration/list.js +8 -10
- package/dist/lib/parser/parse.js +2 -9
- package/dist/lib/parser/tokenize.js +50 -18
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +1 -1
- package/dist/lib/parser/utils/at-rule-media.js +66 -0
- package/dist/lib/parser/utils/at-rule-when-else.js +2 -2
- package/dist/lib/parser/utils/base64.js +14 -0
- package/dist/lib/parser/utils/declaration.js +7 -14
- package/dist/lib/parser/utils/eq.js +6 -0
- package/dist/lib/parser/utils/hash.js +1 -0
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/parser/utils/text.js +16 -0
- package/dist/lib/renderer/render.js +18 -4
- package/dist/lib/renderer/sourcemap/lib/codec.js +5 -0
- package/dist/lib/renderer/sourcemap/sourcemap.js +35 -5
- package/dist/lib/syntax/color/alpha.js +57 -22
- package/dist/lib/syntax/color/color-mix.js +18 -18
- package/dist/lib/syntax/color/srgb.js +10 -5
- package/dist/lib/syntax/color/utils/components.js +1 -1
- package/dist/lib/syntax/color/utils/distance.js +2 -2
- package/dist/lib/syntax/color/utils/matrix.js +1 -0
- package/dist/lib/syntax/color/xyz.js +5 -0
- package/dist/lib/syntax/color/xyzd50.js +17 -0
- package/dist/lib/syntax/syntax.js +549 -13
- package/dist/lib/validation/config.js +26 -0
- package/dist/lib/validation/match.js +16 -4
- package/dist/node.js +8 -14
- package/dist/web.js +8 -14
- package/package.json +1 -1
|
@@ -29,6 +29,15 @@ function trimArray(tokens) {
|
|
|
29
29
|
}
|
|
30
30
|
return tokens;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* is a media feature
|
|
34
|
+
* @param featureName
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
// export function isMFName(featureName: string): boolean {
|
|
38
|
+
// // @ts-expect-error
|
|
39
|
+
// return featureName.startsWith("--") || config.mediaFeatures[featureName.toLowerCase()] != null;
|
|
40
|
+
// }
|
|
32
41
|
/**
|
|
33
42
|
*
|
|
34
43
|
* @param featureName
|
|
@@ -42,6 +51,7 @@ function getMFInfo(featureName) {
|
|
|
42
51
|
*
|
|
43
52
|
* @param featureName
|
|
44
53
|
* @param tokens
|
|
54
|
+
* @param isMFRange
|
|
45
55
|
* @returns object with:
|
|
46
56
|
* - valid: boolean. true the media feaure is known or is a custom property. false otherwise
|
|
47
57
|
* - success: boolean. validation result
|
|
@@ -159,9 +169,10 @@ function createValidationContext(tokens) {
|
|
|
159
169
|
},
|
|
160
170
|
/**
|
|
161
171
|
*
|
|
162
|
-
* @param stopCondition
|
|
163
|
-
* @param matchCount
|
|
164
172
|
* @returns
|
|
173
|
+
* @param open
|
|
174
|
+
* @param close
|
|
175
|
+
* @param counter
|
|
165
176
|
*/
|
|
166
177
|
peekRange(open = EnumToken.StartParensTokenType, close = EnumToken.EndParensTokenType, counter = 0) {
|
|
167
178
|
let index = this.index;
|
|
@@ -384,7 +395,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
384
395
|
case EnumToken.CDOCOMMTokenType:
|
|
385
396
|
break;
|
|
386
397
|
case EnumToken.NestingSelectorTokenType:
|
|
387
|
-
if (nested
|
|
398
|
+
if (!nested && !options.nestedRule) {
|
|
388
399
|
return {
|
|
389
400
|
success: false,
|
|
390
401
|
errors: [
|
|
@@ -1425,7 +1436,8 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1425
1436
|
errors: [],
|
|
1426
1437
|
};
|
|
1427
1438
|
case ValidationTokenEnum.FunctionDefinition:
|
|
1428
|
-
if (
|
|
1439
|
+
if (token.val &&
|
|
1440
|
+
equalsIgnoreCase(token.val, syntaxes[i].val)) {
|
|
1429
1441
|
if (tokensfuncDefMap.has(token.typ)) {
|
|
1430
1442
|
const children = trimArray(context.peekRange());
|
|
1431
1443
|
result = matchSyntax((getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, syntaxes[i].val + "()")?.[0]).chi ?? [], createValidationContext(children.slice(1, -1)), options);
|
package/dist/node.js
CHANGED
|
@@ -237,13 +237,10 @@ function transformSync(...args) {
|
|
|
237
237
|
const parseResult = parseSync(stream, options);
|
|
238
238
|
let mapping = null;
|
|
239
239
|
let importMapping = null;
|
|
240
|
-
if (typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
else if (typeof options.module == "object" &&
|
|
245
|
-
typeof options.module.scoped == "number" &&
|
|
246
|
-
options.module.scoped & ModuleScopeEnumOptions.ICSS) {
|
|
240
|
+
if ((typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS) ||
|
|
241
|
+
(typeof options.module == "object" &&
|
|
242
|
+
typeof options.module.scoped == "number" &&
|
|
243
|
+
options.module.scoped & ModuleScopeEnumOptions.ICSS)) {
|
|
247
244
|
mapping = parseResult.mapping;
|
|
248
245
|
importMapping = parseResult.importMapping;
|
|
249
246
|
}
|
|
@@ -460,13 +457,10 @@ async function transform(...args) {
|
|
|
460
457
|
return parse(stream, options).then((parseResult) => {
|
|
461
458
|
let mapping = null;
|
|
462
459
|
let importMapping = null;
|
|
463
|
-
if (typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS)
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
else if (typeof options.module == "object" &&
|
|
468
|
-
typeof options.module.scoped == "number" &&
|
|
469
|
-
options.module.scoped & ModuleScopeEnumOptions.ICSS) {
|
|
460
|
+
if ((typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS) ||
|
|
461
|
+
(typeof options.module == "object" &&
|
|
462
|
+
typeof options.module.scoped == "number" &&
|
|
463
|
+
options.module.scoped & ModuleScopeEnumOptions.ICSS)) {
|
|
470
464
|
mapping = parseResult.mapping;
|
|
471
465
|
importMapping = parseResult.importMapping;
|
|
472
466
|
}
|
package/dist/web.js
CHANGED
|
@@ -225,13 +225,10 @@ function transformSync(...args) {
|
|
|
225
225
|
const parseResult = parseSync(stream, options);
|
|
226
226
|
let mapping = null;
|
|
227
227
|
let importMapping = null;
|
|
228
|
-
if (typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
else if (typeof options.module == "object" &&
|
|
233
|
-
typeof options.module.scoped == "number" &&
|
|
234
|
-
options.module.scoped & ModuleScopeEnumOptions.ICSS) {
|
|
228
|
+
if ((typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS) ||
|
|
229
|
+
(typeof options.module == "object" &&
|
|
230
|
+
typeof options.module.scoped == "number" &&
|
|
231
|
+
options.module.scoped & ModuleScopeEnumOptions.ICSS)) {
|
|
235
232
|
mapping = parseResult.mapping;
|
|
236
233
|
importMapping = parseResult.importMapping;
|
|
237
234
|
}
|
|
@@ -403,13 +400,10 @@ async function transform(...args) {
|
|
|
403
400
|
return parse(stream, options).then((parseResult) => {
|
|
404
401
|
let mapping = null;
|
|
405
402
|
let importMapping = null;
|
|
406
|
-
if (typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
else if (typeof options.module == "object" &&
|
|
411
|
-
typeof options.module.scoped == "number" &&
|
|
412
|
-
options.module.scoped & ModuleScopeEnumOptions.ICSS) {
|
|
403
|
+
if ((typeof options.module == "number" && options.module & ModuleScopeEnumOptions.ICSS) ||
|
|
404
|
+
(typeof options.module == "object" &&
|
|
405
|
+
typeof options.module.scoped == "number" &&
|
|
406
|
+
options.module.scoped & ModuleScopeEnumOptions.ICSS)) {
|
|
413
407
|
mapping = parseResult.mapping;
|
|
414
408
|
importMapping = parseResult.importMapping;
|
|
415
409
|
}
|