@tbela99/css-parser 1.1.1 → 1.2.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +53 -6
  3. package/dist/index-umd-web.js +4195 -3363
  4. package/dist/index.cjs +4199 -3367
  5. package/dist/index.d.ts +42 -31
  6. package/dist/lib/ast/expand.js +81 -65
  7. package/dist/lib/ast/features/calc.js +37 -35
  8. package/dist/lib/ast/features/inlinecssvariables.js +25 -17
  9. package/dist/lib/ast/features/prefix.js +22 -19
  10. package/dist/lib/ast/features/shorthand.js +1 -1
  11. package/dist/lib/ast/features/transform.js +17 -2
  12. package/dist/lib/ast/math/expression.js +184 -159
  13. package/dist/lib/ast/math/math.js +22 -20
  14. package/dist/lib/ast/minify.js +249 -199
  15. package/dist/lib/ast/transform/compute.js +48 -38
  16. package/dist/lib/ast/transform/matrix.js +6 -5
  17. package/dist/lib/ast/transform/minify.js +31 -34
  18. package/dist/lib/ast/transform/utils.js +76 -16
  19. package/dist/lib/ast/types.js +32 -1
  20. package/dist/lib/fs/resolve.js +1 -14
  21. package/dist/lib/parser/declaration/list.js +1 -1
  22. package/dist/lib/parser/declaration/map.js +1 -1
  23. package/dist/lib/parser/declaration/set.js +1 -1
  24. package/dist/lib/parser/parse.js +19 -95
  25. package/dist/lib/parser/tokenize.js +1 -13
  26. package/dist/lib/parser/utils/declaration.js +1 -1
  27. package/dist/lib/parser/utils/type.js +1 -1
  28. package/dist/lib/renderer/render.js +44 -168
  29. package/dist/lib/{renderer → syntax}/color/a98rgb.js +2 -2
  30. package/dist/lib/syntax/color/cmyk.js +104 -0
  31. package/dist/lib/{renderer → syntax}/color/color-mix.js +20 -21
  32. package/dist/lib/syntax/color/color.js +581 -0
  33. package/dist/lib/syntax/color/hex.js +179 -0
  34. package/dist/lib/syntax/color/hsl.js +201 -0
  35. package/dist/lib/syntax/color/hwb.js +185 -0
  36. package/dist/lib/syntax/color/lab.js +262 -0
  37. package/dist/lib/syntax/color/lch.js +194 -0
  38. package/dist/lib/syntax/color/oklab.js +237 -0
  39. package/dist/lib/syntax/color/oklch.js +166 -0
  40. package/dist/lib/{renderer → syntax}/color/p3.js +3 -3
  41. package/dist/lib/{renderer → syntax}/color/rec2020.js +11 -11
  42. package/dist/lib/{renderer → syntax}/color/relativecolor.js +53 -40
  43. package/dist/lib/syntax/color/rgb.js +140 -0
  44. package/dist/lib/{renderer → syntax}/color/srgb.js +58 -46
  45. package/dist/lib/{renderer → syntax}/color/utils/components.js +7 -7
  46. package/dist/lib/{renderer → syntax}/color/utils/constants.js +6 -33
  47. package/dist/lib/syntax/color/utils/distance.js +30 -0
  48. package/dist/lib/{renderer → syntax}/color/xyz.js +27 -14
  49. package/dist/lib/{renderer → syntax}/color/xyzd50.js +8 -8
  50. package/dist/lib/syntax/syntax.js +77 -67
  51. package/dist/lib/syntax/utils.js +70 -0
  52. package/dist/lib/validation/at-rules/container.js +1 -1
  53. package/dist/lib/validation/at-rules/counter-style.js +1 -1
  54. package/dist/lib/validation/at-rules/custom-media.js +1 -1
  55. package/dist/lib/validation/at-rules/document.js +1 -1
  56. package/dist/lib/validation/at-rules/font-feature-values.js +2 -2
  57. package/dist/lib/validation/at-rules/import.js +1 -1
  58. package/dist/lib/validation/at-rules/keyframes.js +14 -13
  59. package/dist/lib/validation/at-rules/layer.js +1 -1
  60. package/dist/lib/validation/at-rules/media.js +1 -1
  61. package/dist/lib/validation/at-rules/namespace.js +1 -1
  62. package/dist/lib/validation/at-rules/page-margin-box.js +1 -1
  63. package/dist/lib/validation/at-rules/page.js +1 -1
  64. package/dist/lib/validation/at-rules/supports.js +1 -1
  65. package/dist/lib/validation/at-rules/when.js +1 -1
  66. package/dist/lib/validation/atrule.js +2 -2
  67. package/dist/lib/validation/config.js +4 -3
  68. package/dist/lib/validation/config.json.js +1 -1
  69. package/dist/lib/validation/parser/parse.js +12 -7
  70. package/dist/lib/validation/selector.js +9 -8
  71. package/dist/lib/validation/syntax.js +170 -120
  72. package/dist/lib/validation/syntaxes/complex-selector-list.js +13 -19
  73. package/dist/lib/validation/syntaxes/complex-selector.js +1 -1
  74. package/dist/lib/validation/syntaxes/compound-selector.js +5 -24
  75. package/dist/lib/validation/syntaxes/family-name.js +36 -39
  76. package/dist/lib/validation/syntaxes/keyframe-selector.js +14 -22
  77. package/dist/lib/validation/syntaxes/layer-name.js +1 -1
  78. package/dist/lib/validation/syntaxes/relative-selector-list.js +27 -25
  79. package/dist/lib/validation/syntaxes/relative-selector.js +1 -1
  80. package/dist/lib/validation/syntaxes/url.js +35 -33
  81. package/dist/lib/validation/utils/list.js +10 -9
  82. package/dist/lib/validation/utils/whitespace.js +1 -1
  83. package/dist/node/index.js +4 -2
  84. package/dist/web/index.js +4 -2
  85. package/package.json +4 -4
  86. package/.editorconfig +0 -484
  87. package/dist/lib/ast/transform/convert.js +0 -33
  88. package/dist/lib/ast/utils/utils.js +0 -104
  89. package/dist/lib/renderer/color/color.js +0 -654
  90. package/dist/lib/renderer/color/hex.js +0 -105
  91. package/dist/lib/renderer/color/hsl.js +0 -125
  92. package/dist/lib/renderer/color/hwb.js +0 -103
  93. package/dist/lib/renderer/color/lab.js +0 -148
  94. package/dist/lib/renderer/color/lch.js +0 -90
  95. package/dist/lib/renderer/color/oklab.js +0 -131
  96. package/dist/lib/renderer/color/oklch.js +0 -75
  97. package/dist/lib/renderer/color/rgb.js +0 -50
  98. package/dist/lib/validation/syntaxes/keyframe-block-list.js +0 -28
  99. package/dist/lib/{renderer → syntax}/color/hsv.js +0 -0
  100. package/dist/lib/{renderer → syntax}/color/prophotorgb.js +1 -1
  101. /package/dist/lib/{renderer → syntax}/color/utils/matrix.js +0 -0
@@ -5,7 +5,7 @@ import '../../parser/parse.js';
5
5
  import '../../parser/tokenize.js';
6
6
  import '../../parser/utils/config.js';
7
7
  import { mozExtensions, webkitExtensions } from '../../syntax/syntax.js';
8
- import '../../renderer/color/utils/constants.js';
8
+ import '../../syntax/color/utils/constants.js';
9
9
  import '../../renderer/sourcemap/lib/encode.js';
10
10
  import { consumeWhitespace } from '../utils/whitespace.js';
11
11
  import { getSyntaxConfig } from '../config.js';
@@ -108,17 +108,7 @@ function validateCompoundSelector(tokens, root, options) {
108
108
  while (tokens.length > 0 && tokens[0].typ == EnumToken.AttrTokenType) {
109
109
  const children = tokens[0].chi.slice();
110
110
  consumeWhitespace(children);
111
- if (children.length == 0) {
112
- // @ts-ignore
113
- return {
114
- valid: SyntaxValidationResult.Drop,
115
- context: [],
116
- node: tokens[0],
117
- syntax: null,
118
- error: 'invalid attribute selector'
119
- };
120
- }
121
- if (![
111
+ if (children.length == 0 || ![
122
112
  EnumToken.IdenTokenType,
123
113
  EnumToken.NameSpaceAttributeTokenType,
124
114
  EnumToken.MatchExpressionTokenType
@@ -151,20 +141,11 @@ function validateCompoundSelector(tokens, root, options) {
151
141
  EnumToken.StartMatchTokenType, EnumToken.ContainMatchTokenType,
152
142
  EnumToken.EndMatchTokenType, EnumToken.IncludeMatchTokenType
153
143
  ].includes(children[0].op.typ) ||
154
- !([
144
+ ![
155
145
  EnumToken.StringTokenType,
156
146
  EnumToken.IdenTokenType
157
- ].includes(children[0].r.typ))) {
158
- // @ts-ignore
159
- return {
160
- valid: SyntaxValidationResult.Drop,
161
- context: [],
162
- node: tokens[0],
163
- syntax: null,
164
- error: 'invalid attribute selector'
165
- };
166
- }
167
- if (children[0].attr != null && !['i', 's'].includes(children[0].attr)) {
147
+ ].includes(children[0].r.typ) ||
148
+ (children[0].attr != null && !['i', 's'].includes(children[0].attr))) {
168
149
  // @ts-ignore
169
150
  return {
170
151
  valid: SyntaxValidationResult.Drop,
@@ -1,10 +1,10 @@
1
- import { SyntaxValidationResult, EnumToken } from '../../ast/types.js';
1
+ import { EnumToken, SyntaxValidationResult } from '../../ast/types.js';
2
2
  import '../../ast/minify.js';
3
3
  import '../../ast/walk.js';
4
4
  import '../../parser/parse.js';
5
5
  import '../../parser/tokenize.js';
6
6
  import '../../parser/utils/config.js';
7
- import '../../renderer/color/utils/constants.js';
7
+ import '../../syntax/color/utils/constants.js';
8
8
  import '../../renderer/sourcemap/lib/encode.js';
9
9
  import { consumeWhitespace } from '../utils/whitespace.js';
10
10
 
@@ -12,18 +12,19 @@ function validateFamilyName(tokens, atRule) {
12
12
  let node;
13
13
  tokens = tokens.slice();
14
14
  consumeWhitespace(tokens);
15
- if (tokens.length == 0) {
16
- // @ts-ignore
17
- return {
18
- valid: SyntaxValidationResult.Drop,
19
- matches: [],
20
- node: atRule,
21
- syntax: null,
22
- error: 'expected at-rule prelude',
23
- tokens
24
- };
25
- }
26
- if (tokens[0].typ == EnumToken.CommaTokenType) {
15
+ // if (tokens.length == 0) {
16
+ //
17
+ // // @ts-ignore
18
+ // return {
19
+ // valid: SyntaxValidationResult.Drop,
20
+ // matches: [],
21
+ // node: atRule,
22
+ // syntax: null,
23
+ // error: 'expected at-rule prelude',
24
+ // tokens
25
+ // } as ValidationSyntaxResult;
26
+ // }
27
+ if (tokens.length == 0 || tokens[0].typ == EnumToken.CommaTokenType) {
27
28
  // @ts-ignore
28
29
  return {
29
30
  valid: SyntaxValidationResult.Drop,
@@ -36,21 +37,25 @@ function validateFamilyName(tokens, atRule) {
36
37
  }
37
38
  while (tokens.length > 0) {
38
39
  // @ts-ignore
39
- if (tokens[0].typ == EnumToken.CommaTokenType) {
40
- node = tokens.shift();
41
- consumeWhitespace(tokens);
42
- if (tokens.length == 0) {
43
- // @ts-ignore
44
- return {
45
- valid: SyntaxValidationResult.Drop,
46
- matches: [],
47
- node,
48
- syntax: null,
49
- error: 'unexpected token',
50
- tokens
51
- };
52
- }
53
- }
40
+ // if (tokens[0].typ == EnumToken.CommaTokenType) {
41
+ //
42
+ // node = tokens.shift() as Token;
43
+ //
44
+ // consumeWhitespace(tokens);
45
+ //
46
+ // if (tokens.length == 0) {
47
+ //
48
+ // // @ts-ignore
49
+ // return {
50
+ // valid: SyntaxValidationResult.Drop,
51
+ // matches: [],
52
+ // node,
53
+ // syntax: null,
54
+ // error: 'unexpected token',
55
+ // tokens
56
+ // } as ValidationSyntaxResult;
57
+ // }
58
+ // }
54
59
  node = tokens[0];
55
60
  if (![EnumToken.IdenTokenType, EnumToken.StringTokenType].includes(node.typ)) {
56
61
  // @ts-ignore
@@ -66,16 +71,8 @@ function validateFamilyName(tokens, atRule) {
66
71
  tokens.shift();
67
72
  consumeWhitespace(tokens);
68
73
  // @ts-ignore
69
- if (tokens.length > 0 && node.typ == EnumToken.BadStringTokenType && tokens[0].typ != EnumToken.CommaTokenType) {
70
- // @ts-ignore
71
- return {
72
- valid: SyntaxValidationResult.Drop,
73
- matches: [],
74
- node: tokens[0],
75
- syntax: null,
76
- error: 'expected comma token',
77
- tokens
78
- };
74
+ if (tokens.length > 0 && tokens[0].typ == EnumToken.CommaTokenType) {
75
+ tokens.shift();
79
76
  }
80
77
  }
81
78
  // @ts-ignore
@@ -1,37 +1,29 @@
1
1
  import { consumeWhitespace } from '../utils/whitespace.js';
2
2
  import { splitTokenList } from '../utils/list.js';
3
- import { SyntaxValidationResult, EnumToken } from '../../ast/types.js';
3
+ import { EnumToken, SyntaxValidationResult } from '../../ast/types.js';
4
4
  import '../../ast/minify.js';
5
5
  import '../../ast/walk.js';
6
6
  import '../../parser/parse.js';
7
7
  import '../../parser/tokenize.js';
8
8
  import '../../parser/utils/config.js';
9
- import '../../renderer/color/utils/constants.js';
9
+ import '../../syntax/color/utils/constants.js';
10
10
  import '../../renderer/sourcemap/lib/encode.js';
11
11
 
12
12
  function validateKeyframeSelector(tokens, options) {
13
13
  consumeWhitespace(tokens);
14
- if (tokens.length == 0) {
15
- // @ts-ignore
16
- return {
17
- valid: SyntaxValidationResult.Drop,
18
- context: [],
19
- node: null,
20
- syntax: null,
21
- error: 'expected keyframe selector'
22
- };
23
- }
14
+ // if (tokens.length == 0) {
15
+ //
16
+ // // @ts-ignore
17
+ // return {
18
+ // valid: SyntaxValidationResult.Drop,
19
+ // context: [],
20
+ // node: null,
21
+ // syntax: null,
22
+ // error: 'expected keyframe selector'
23
+ // }
24
+ // }
24
25
  for (const t of splitTokenList(tokens)) {
25
- if (t.length != 1) {
26
- return {
27
- valid: SyntaxValidationResult.Drop,
28
- context: [],
29
- node: t[0] ?? null,
30
- syntax: null,
31
- error: 'unexpected token'
32
- };
33
- }
34
- if (t[0].typ != EnumToken.PercentageTokenType && !(t[0].typ == EnumToken.IdenTokenType && ['from', 'to', 'cover', 'contain', 'entry', 'exit', 'entry-crossing', 'exit-crossing'].includes(t[0].val))) {
26
+ if (t.length != 1 || (t[0].typ != EnumToken.PercentageTokenType && !(t[0].typ == EnumToken.IdenTokenType && ['from', 'to', 'cover', 'contain', 'entry', 'exit', 'entry-crossing', 'exit-crossing'].includes(t[0].val)))) {
35
27
  return {
36
28
  valid: SyntaxValidationResult.Drop,
37
29
  context: [],
@@ -4,7 +4,7 @@ import '../../ast/walk.js';
4
4
  import '../../parser/parse.js';
5
5
  import '../../parser/tokenize.js';
6
6
  import '../../parser/utils/config.js';
7
- import '../../renderer/color/utils/constants.js';
7
+ import '../../syntax/color/utils/constants.js';
8
8
  import '../../renderer/sourcemap/lib/encode.js';
9
9
 
10
10
  function validateLayerName(tokens) {
@@ -4,7 +4,7 @@ import '../../ast/walk.js';
4
4
  import '../../parser/parse.js';
5
5
  import '../../parser/tokenize.js';
6
6
  import '../../parser/utils/config.js';
7
- import '../../renderer/color/utils/constants.js';
7
+ import '../../syntax/color/utils/constants.js';
8
8
  import '../../renderer/sourcemap/lib/encode.js';
9
9
  import { validateRelativeSelector } from './relative-selector.js';
10
10
  import { consumeWhitespace } from '../utils/whitespace.js';
@@ -13,31 +13,33 @@ import { splitTokenList } from '../utils/list.js';
13
13
  function validateRelativeSelectorList(tokens, root, options) {
14
14
  tokens = tokens.slice();
15
15
  consumeWhitespace(tokens);
16
- if (tokens.length == 0) {
17
- return {
18
- valid: SyntaxValidationResult.Drop,
19
- matches: [],
20
- // @ts-ignore
21
- node: root,
22
- // @ts-ignore
23
- syntax: null,
24
- error: 'expecting relative selector list',
25
- tokens
26
- };
27
- }
16
+ // if (tokens.length == 0) {
17
+ //
18
+ // return {
19
+ // valid: SyntaxValidationResult.Drop,
20
+ // matches: [],
21
+ // // @ts-ignore
22
+ // node: root,
23
+ // // @ts-ignore
24
+ // syntax: null,
25
+ // error: 'expecting relative selector list',
26
+ // tokens
27
+ // }
28
+ // }
28
29
  for (const t of splitTokenList(tokens)) {
29
- if (t.length == 0) {
30
- return {
31
- valid: SyntaxValidationResult.Drop,
32
- matches: [],
33
- // @ts-ignore
34
- node: root,
35
- // @ts-ignore
36
- syntax: null,
37
- error: 'unexpected comma',
38
- tokens
39
- };
40
- }
30
+ // if (t.length == 0) {
31
+ //
32
+ // return {
33
+ // valid: SyntaxValidationResult.Drop,
34
+ // matches: [],
35
+ // // @ts-ignore
36
+ // node: root,
37
+ // // @ts-ignore
38
+ // syntax: null,
39
+ // error: 'unexpected comma',
40
+ // tokens
41
+ // }
42
+ // }
41
43
  const result = validateRelativeSelector(t, root, options);
42
44
  if (result.valid == SyntaxValidationResult.Drop) {
43
45
  return result;
@@ -5,7 +5,7 @@ import '../../ast/walk.js';
5
5
  import '../../parser/parse.js';
6
6
  import '../../parser/tokenize.js';
7
7
  import '../../parser/utils/config.js';
8
- import '../../renderer/color/utils/constants.js';
8
+ import '../../syntax/color/utils/constants.js';
9
9
  import '../../renderer/sourcemap/lib/encode.js';
10
10
  import { validateSelector } from './selector.js';
11
11
  import { combinatorsTokens } from './complex-selector.js';
@@ -4,47 +4,49 @@ import '../../ast/walk.js';
4
4
  import '../../parser/parse.js';
5
5
  import '../../parser/tokenize.js';
6
6
  import '../../parser/utils/config.js';
7
- import '../../renderer/color/utils/constants.js';
7
+ import '../../syntax/color/utils/constants.js';
8
8
  import '../../renderer/sourcemap/lib/encode.js';
9
9
  import { consumeWhitespace } from '../utils/whitespace.js';
10
10
 
11
11
  function validateURL(token) {
12
- if (token.typ == EnumToken.UrlTokenTokenType) {
13
- // @ts-ignore
14
- return {
15
- valid: SyntaxValidationResult.Valid,
16
- context: [],
17
- node: token,
18
- // @ts-ignore
19
- syntax: 'url()',
20
- error: ''
21
- };
22
- }
23
- if (token.typ != EnumToken.UrlFunctionTokenType) {
24
- // @ts-ignore
25
- return {
26
- valid: SyntaxValidationResult.Drop,
27
- context: [],
28
- node: token,
29
- // @ts-ignore
30
- syntax: 'url()',
31
- error: 'expected url()'
32
- };
33
- }
12
+ // if (token.typ == EnumToken.UrlTokenTokenType) {
13
+ //
14
+ // // @ts-ignore
15
+ // return {
16
+ // valid: SyntaxValidationResult.Valid,
17
+ // context: [],
18
+ // node: token,
19
+ // // @ts-ignore
20
+ // syntax: 'url()',
21
+ // error: ''
22
+ // }
23
+ // }
24
+ // if (token.typ != EnumToken.UrlFunctionTokenType) {
25
+ //
26
+ // // @ts-ignore
27
+ // return {
28
+ // valid: SyntaxValidationResult.Drop,
29
+ // context: [],
30
+ // node: token,
31
+ // // @ts-ignore
32
+ // syntax: 'url()',
33
+ // error: 'expected url()'
34
+ // }
35
+ // }
34
36
  const children = token.chi.slice();
35
37
  consumeWhitespace(children);
36
- if (children.length == 0 || ![EnumToken.UrlTokenTokenType, EnumToken.StringTokenType, EnumToken.HashTokenType].includes(children[0].typ)) {
38
+ if (children.length > 0 && [EnumToken.UrlTokenTokenType, EnumToken.StringTokenType, EnumToken.HashTokenType].includes(children[0].typ)) {
39
+ children.shift();
37
40
  // @ts-ignore
38
- return {
39
- valid: SyntaxValidationResult.Drop,
40
- context: [],
41
- node: children[0] ?? token,
42
- // @ts-ignore
43
- syntax: 'url()',
44
- error: 'expected url-token'
45
- };
41
+ // return {
42
+ // valid: SyntaxValidationResult.Drop,
43
+ // context: [],
44
+ // node: children[0] ?? token,
45
+ // // @ts-ignore
46
+ // syntax: 'url()',
47
+ // error: 'expected url-token'
48
+ // }
46
49
  }
47
- children.shift();
48
50
  consumeWhitespace(children);
49
51
  if (children.length > 0) {
50
52
  // @ts-ignore
@@ -4,18 +4,18 @@ import '../../ast/walk.js';
4
4
  import '../../parser/parse.js';
5
5
  import '../../parser/tokenize.js';
6
6
  import '../../parser/utils/config.js';
7
- import '../../renderer/color/utils/constants.js';
7
+ import '../../syntax/color/utils/constants.js';
8
8
  import '../../renderer/sourcemap/lib/encode.js';
9
9
 
10
10
  function stripCommaToken(tokenList) {
11
11
  let result = [];
12
- let last = null;
13
12
  for (let i = 0; i < tokenList.length; i++) {
14
- if (tokenList[i].typ == EnumToken.CommaTokenType && last != null && last.typ == EnumToken.CommaTokenType) {
15
- return null;
16
- }
13
+ // if (tokenList[i].typ == EnumToken.CommaTokenType && last != null && last.typ == EnumToken.CommaTokenType) {
14
+ //
15
+ // return null;
16
+ // }
17
17
  if (tokenList[i].typ != EnumToken.WhitespaceTokenType) {
18
- last = tokenList[i];
18
+ tokenList[i];
19
19
  }
20
20
  if (tokenList[i].typ == EnumToken.CommentTokenType || tokenList[i].typ == EnumToken.CommaTokenType) {
21
21
  continue;
@@ -26,9 +26,10 @@ function stripCommaToken(tokenList) {
26
26
  }
27
27
  function splitTokenList(tokenList, split = [EnumToken.CommaTokenType]) {
28
28
  return tokenList.reduce((acc, curr) => {
29
- if (curr.typ == EnumToken.CommentTokenType) {
30
- return acc;
31
- }
29
+ // if (curr.typ == EnumToken.CommentTokenType) {
30
+ //
31
+ // return acc;
32
+ // }
32
33
  if (split.includes(curr.typ)) {
33
34
  acc.push([]);
34
35
  }
@@ -4,7 +4,7 @@ import '../../ast/walk.js';
4
4
  import '../../parser/parse.js';
5
5
  import '../../parser/tokenize.js';
6
6
  import '../../parser/utils/config.js';
7
- import '../../renderer/color/utils/constants.js';
7
+ import '../../syntax/color/utils/constants.js';
8
8
  import '../../renderer/sourcemap/lib/encode.js';
9
9
 
10
10
  function consumeWhitespace(tokens) {
@@ -1,11 +1,13 @@
1
1
  import process from 'node:process';
2
- export { EnumToken, ValidationLevel } from '../lib/ast/types.js';
2
+ export { ColorType, EnumToken, ValidationLevel } from '../lib/ast/types.js';
3
3
  export { minify } from '../lib/ast/minify.js';
4
4
  export { walk, walkValues } from '../lib/ast/walk.js';
5
5
  export { expand } from '../lib/ast/expand.js';
6
6
  import { doRender } from '../lib/renderer/render.js';
7
7
  export { renderToken } from '../lib/renderer/render.js';
8
- import '../lib/renderer/color/utils/constants.js';
8
+ import '../lib/syntax/color/utils/constants.js';
9
+ export { convertColor } from '../lib/syntax/color/color.js';
10
+ export { isOkLabClose, okLabDistance } from '../lib/syntax/color/utils/distance.js';
9
11
  import { doParse } from '../lib/parser/parse.js';
10
12
  export { parseString, parseTokens } from '../lib/parser/parse.js';
11
13
  import '../lib/parser/tokenize.js';
package/dist/web/index.js CHANGED
@@ -1,10 +1,12 @@
1
- export { EnumToken, ValidationLevel } from '../lib/ast/types.js';
1
+ export { ColorType, EnumToken, ValidationLevel } from '../lib/ast/types.js';
2
2
  export { minify } from '../lib/ast/minify.js';
3
3
  export { walk, walkValues } from '../lib/ast/walk.js';
4
4
  export { expand } from '../lib/ast/expand.js';
5
5
  import { doRender } from '../lib/renderer/render.js';
6
6
  export { renderToken } from '../lib/renderer/render.js';
7
- import '../lib/renderer/color/utils/constants.js';
7
+ import '../lib/syntax/color/utils/constants.js';
8
+ export { convertColor } from '../lib/syntax/color/color.js';
9
+ export { isOkLabClose, okLabDistance } from '../lib/syntax/color/utils/distance.js';
8
10
  import { doParse } from '../lib/parser/parse.js';
9
11
  export { parseString, parseTokens } from '../lib/parser/parse.js';
10
12
  import '../lib/parser/tokenize.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tbela99/css-parser",
3
3
  "description": "CSS parser for node and the browser",
4
- "version": "v1.1.1",
4
+ "version": "v1.2.0",
5
5
  "exports": {
6
6
  ".": "./dist/node/index.js",
7
7
  "./node": "./dist/node/index.js",
@@ -19,8 +19,8 @@
19
19
  "test": "web-test-runner \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.; mocha --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
20
20
  "test:web": "web-test-runner \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.",
21
21
  "test:node": "mocha --reporter-options='maxDiffSize=1801920' \"test/**/node.spec.js\"",
22
- "test:cov": "c8 -x 'test/specs/**/*.js' -x dist/lib/validation/syntax.js -x 'dist/lib/validation/parser/*.js' --reporter=html --reporter=text --reporter=json-summary mocha --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
23
- "test:web-cov": "web-test-runner -x 'test/specs/**/*.js' -x dist/lib/validation/syntax.js,dist/lib/validation/parser \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=. --coverage",
22
+ "test:cov": "c8 -x 'test/specs/**/*.js' --reporter=html --reporter=text --reporter=json-summary mocha --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
23
+ "test:web-cov": "web-test-runner -x 'test/specs/**/*.js' \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=. --coverage",
24
24
  "profile": "node --enable-source-maps --inspect-brk test/inspect.js",
25
25
  "syntax-update": "esno tools/validation.ts",
26
26
  "debug": "web-test-runner \"test/**/web.spec.js\" --manual --open --node-resolve --root-dir=."
@@ -70,4 +70,4 @@
70
70
  "rollup-plugin-dts": "^6.2.1",
71
71
  "tslib": "^2.8.1"
72
72
  }
73
- }
73
+ }