@tbela99/css-parser 1.4.2 → 1.4.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/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
- package/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
- package/.nyc_output/processinfo/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
- package/.nyc_output/processinfo/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
- package/.repl_history +4 -0
- package/CHANGELOG.md +164 -4
- package/README.md +43 -0
- package/badges/coverage.svg +20 -0
- package/deno.lock +2861 -0
- package/dist/config.json.js +33 -1
- package/dist/index-umd-web.js +24382 -18476
- package/dist/index.cjs +24522 -18618
- package/dist/index.d.ts +1396 -929
- package/dist/lib/ast/clone.d.ts +10 -0
- package/dist/lib/ast/clone.js +45 -0
- package/dist/lib/ast/expand.d.ts +14 -0
- package/dist/lib/ast/expand.js +89 -64
- package/dist/lib/ast/features/calc.d.ts +10 -0
- package/dist/lib/ast/features/calc.js +62 -24
- package/dist/lib/ast/features/if.d.ts +10 -0
- package/dist/lib/ast/features/if.js +215 -0
- package/dist/lib/ast/features/index.d.ts +6 -0
- package/dist/lib/ast/features/index.js +1 -0
- package/dist/lib/ast/features/inlinecssvariables.d.ts +15 -0
- package/dist/lib/ast/features/inlinecssvariables.js +32 -27
- package/dist/lib/ast/features/prefix.d.ts +8 -0
- package/dist/lib/ast/features/prefix.js +68 -43
- package/dist/lib/ast/features/shorthand.d.ts +12 -0
- package/dist/lib/ast/features/shorthand.js +6 -9
- package/dist/lib/ast/features/transform.d.ts +10 -0
- package/dist/lib/ast/features/transform.js +9 -13
- package/dist/lib/ast/features/type.d.ts +15 -0
- package/dist/lib/ast/find.d.ts +165 -0
- package/dist/lib/ast/find.js +175 -0
- package/dist/lib/ast/math/expression.d.ts +18 -0
- package/dist/lib/ast/math/expression.js +140 -98
- package/dist/lib/ast/math/math.d.ts +6 -0
- package/dist/lib/ast/math/math.js +30 -41
- package/dist/lib/ast/minify.d.ts +19 -0
- package/dist/lib/ast/minify.js +541 -217
- package/dist/lib/ast/transform/compute.d.ts +8 -0
- package/dist/lib/ast/transform/compute.js +82 -69
- package/dist/lib/ast/transform/matrix.d.ts +22 -0
- package/dist/lib/ast/transform/matrix.js +12 -26
- package/dist/lib/ast/transform/minify.d.ts +5 -0
- package/dist/lib/ast/transform/minify.js +20 -20
- package/dist/lib/ast/transform/perspective.d.ts +3 -0
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.d.ts +12 -0
- package/dist/lib/ast/transform/rotate.js +1 -1
- package/dist/lib/ast/transform/scale.d.ts +6 -0
- package/dist/lib/ast/transform/scale.js +1 -1
- package/dist/lib/ast/transform/skew.d.ts +4 -0
- package/dist/lib/ast/transform/skew.js +1 -1
- package/dist/lib/ast/transform/translate.d.ts +6 -0
- package/dist/lib/ast/transform/translate.js +1 -1
- package/dist/lib/ast/transform/utils.d.ts +9 -0
- package/dist/lib/ast/types.d.ts +903 -0
- package/dist/lib/ast/types.js +277 -23
- package/dist/lib/ast/walk.d.ts +162 -0
- package/dist/lib/ast/walk.js +116 -60
- package/dist/lib/fs/resolve.d.ts +20 -0
- package/dist/lib/fs/resolve.js +37 -45
- package/dist/lib/parser/declaration/list.d.ts +16 -0
- package/dist/lib/parser/declaration/list.js +26 -24
- package/dist/lib/parser/declaration/map.d.ts +15 -0
- package/dist/lib/parser/declaration/map.js +140 -95
- package/dist/lib/parser/declaration/set.d.ts +9 -0
- package/dist/lib/parser/declaration/set.js +30 -25
- package/dist/lib/parser/node.d.ts +7 -0
- package/dist/lib/parser/parse.d.ts +107 -0
- package/dist/lib/parser/parse.js +1454 -1445
- package/dist/lib/parser/tokenize.d.ts +57 -0
- package/dist/lib/parser/tokenize.js +557 -404
- package/dist/lib/parser/utils/at-rule-container.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-container.js +486 -0
- package/dist/lib/parser/utils/at-rule-font-feature-values.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +13 -0
- package/dist/lib/parser/utils/at-rule-generic.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-generic.js +118 -0
- package/dist/lib/parser/utils/at-rule-import.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-import.js +393 -0
- package/dist/lib/parser/utils/at-rule-media.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-media.js +603 -0
- package/dist/lib/parser/utils/at-rule-page.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-page.js +28 -0
- package/dist/lib/parser/utils/at-rule-support.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-support.js +366 -0
- package/dist/lib/parser/utils/at-rule-token.d.ts +1 -0
- package/dist/lib/parser/utils/at-rule-when-else.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-when-else.js +363 -0
- package/dist/lib/parser/utils/at-rule.d.ts +13 -0
- package/dist/lib/parser/utils/at-rule.js +37 -0
- package/dist/lib/parser/utils/cache.d.ts +6 -0
- package/dist/lib/parser/utils/cache.js +19 -0
- package/dist/lib/parser/utils/config.d.ts +2 -0
- package/dist/lib/parser/utils/config.js +1 -0
- package/dist/lib/parser/utils/declaration-list.d.ts +5 -0
- package/dist/lib/parser/utils/declaration.d.ts +18 -0
- package/dist/lib/parser/utils/declaration.js +569 -91
- package/dist/lib/parser/utils/eq.d.ts +1 -0
- package/dist/lib/parser/utils/hash.d.ts +21 -0
- package/dist/lib/parser/utils/hash.js +1 -1
- package/dist/lib/parser/utils/selector.d.ts +5 -0
- package/dist/lib/parser/utils/selector.js +476 -0
- package/dist/lib/parser/utils/text.d.ts +3 -0
- package/dist/lib/parser/utils/text.js +17 -1
- package/dist/lib/parser/utils/token.d.ts +14 -0
- package/dist/lib/parser/utils/token.js +102 -0
- package/dist/lib/parser/utils/type.d.ts +2 -0
- package/dist/lib/parser/utils/type.js +29 -18
- package/dist/lib/renderer/render.d.ts +28 -0
- package/dist/lib/renderer/render.js +421 -262
- package/dist/lib/renderer/sourcemap/lib/encode.d.ts +1 -0
- package/dist/lib/renderer/sourcemap/sourcemap.d.ts +26 -0
- package/dist/lib/renderer/sourcemap/sourcemap.js +17 -7
- package/dist/lib/syntax/color/a98rgb.d.ts +2 -0
- package/dist/lib/syntax/color/a98rgb.js +8 -12
- package/dist/lib/syntax/color/cmyk.d.ts +10 -0
- package/dist/lib/syntax/color/cmyk.js +23 -21
- package/dist/lib/syntax/color/color-mix.d.ts +2 -0
- package/dist/lib/syntax/color/color-mix.js +88 -77
- package/dist/lib/syntax/color/color.d.ts +42 -0
- package/dist/lib/syntax/color/color.js +65 -68
- package/dist/lib/syntax/color/hex.d.ts +16 -0
- package/dist/lib/syntax/color/hex.js +27 -31
- package/dist/lib/syntax/color/hsl.d.ts +20 -0
- package/dist/lib/syntax/color/hsl.js +5 -12
- package/dist/lib/syntax/color/hsv.d.ts +2 -0
- package/dist/lib/syntax/color/hwb.d.ts +21 -0
- package/dist/lib/syntax/color/hwb.js +8 -21
- package/dist/lib/syntax/color/lab.d.ts +25 -0
- package/dist/lib/syntax/color/lab.js +20 -21
- package/dist/lib/syntax/color/lch.d.ts +23 -0
- package/dist/lib/syntax/color/lch.js +13 -15
- package/dist/lib/syntax/color/oklab.d.ts +22 -0
- package/dist/lib/syntax/color/oklab.js +20 -39
- package/dist/lib/syntax/color/oklch.d.ts +20 -0
- package/dist/lib/syntax/color/oklch.js +14 -16
- package/dist/lib/syntax/color/p3.d.ts +6 -0
- package/dist/lib/syntax/color/p3.js +0 -8
- package/dist/lib/syntax/color/prophotorgb.d.ts +2 -0
- package/dist/lib/syntax/color/rec2020.d.ts +2 -0
- package/dist/lib/syntax/color/rec2020.js +9 -13
- package/dist/lib/syntax/color/relativecolor.d.ts +13 -0
- package/dist/lib/syntax/color/relativecolor.js +68 -41
- package/dist/lib/syntax/color/rgb.d.ts +20 -0
- package/dist/lib/syntax/color/rgb.js +14 -18
- package/dist/lib/syntax/color/srgb.d.ts +23 -0
- package/dist/lib/syntax/color/srgb.js +27 -26
- package/dist/lib/syntax/color/utils/components.d.ts +2 -0
- package/dist/lib/syntax/color/utils/components.js +30 -14
- package/dist/lib/syntax/color/utils/distance.d.ts +18 -0
- package/dist/lib/syntax/color/utils/distance.js +1 -8
- package/dist/lib/syntax/color/utils/matrix.d.ts +6 -0
- package/dist/lib/syntax/color/xyz.d.ts +5 -0
- package/dist/lib/syntax/color/xyz.js +8 -20
- package/dist/lib/syntax/color/xyzd50.d.ts +4 -0
- package/dist/lib/syntax/color/xyzd50.js +6 -20
- package/dist/lib/syntax/constants.d.ts +67 -0
- package/dist/lib/syntax/constants.js +436 -0
- package/dist/lib/syntax/syntax.d.ts +38 -0
- package/dist/lib/syntax/syntax.js +533 -568
- package/dist/lib/validation/config.d.ts +14 -0
- package/dist/lib/validation/config.js +72 -33
- package/dist/lib/validation/config.json.js +1159 -74
- package/dist/lib/validation/json.d.ts +2 -0
- package/dist/lib/validation/match.d.ts +38 -0
- package/dist/lib/validation/match.js +2985 -0
- package/dist/lib/validation/parser/parse.d.ts +8 -0
- package/dist/lib/validation/parser/parse.js +684 -935
- package/dist/lib/validation/parser/typedef.d.ts +95 -0
- package/dist/lib/validation/parser/typedef.js +100 -0
- package/dist/lib/validation/utils/list.d.ts +4 -0
- package/dist/lib/validation/utils/list.js +4 -11
- package/dist/lib/validation/utils/whitespace.d.ts +2 -0
- package/dist/lib/validation/utils/whitespace.js +2 -8
- package/dist/node.d.ts +207 -0
- package/dist/node.js +42 -39
- package/dist/web.d.ts +169 -0
- package/dist/web.js +38 -33
- package/package.json +15 -12
- package/playground/index.html +1328 -0
- package/playground/sw.js +55 -0
- package/playground/tree.js +176 -0
- package/dist/lib/syntax/color/utils/constants.js +0 -214
- package/dist/lib/syntax/utils.js +0 -70
- package/dist/lib/validation/at-rules/container.js +0 -342
- package/dist/lib/validation/at-rules/counter-style.js +0 -90
- package/dist/lib/validation/at-rules/custom-media.js +0 -50
- package/dist/lib/validation/at-rules/document.js +0 -89
- package/dist/lib/validation/at-rules/else.js +0 -5
- package/dist/lib/validation/at-rules/font-feature-values.js +0 -63
- package/dist/lib/validation/at-rules/import.js +0 -150
- package/dist/lib/validation/at-rules/keyframes.js +0 -67
- package/dist/lib/validation/at-rules/layer.js +0 -41
- package/dist/lib/validation/at-rules/media.js +0 -255
- package/dist/lib/validation/at-rules/namespace.js +0 -81
- package/dist/lib/validation/at-rules/page-margin-box.js +0 -64
- package/dist/lib/validation/at-rules/page.js +0 -100
- package/dist/lib/validation/at-rules/supports.js +0 -295
- package/dist/lib/validation/at-rules/when.js +0 -185
- package/dist/lib/validation/atrule.js +0 -184
- package/dist/lib/validation/selector.js +0 -36
- package/dist/lib/validation/syntax.js +0 -1073
- package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -27
- package/dist/lib/validation/syntaxes/complex-selector.js +0 -52
- package/dist/lib/validation/syntaxes/compound-selector.js +0 -196
- package/dist/lib/validation/syntaxes/family-name.js +0 -57
- package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -36
- package/dist/lib/validation/syntaxes/layer-name.js +0 -57
- package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -31
- package/dist/lib/validation/syntaxes/relative-selector.js +0 -38
- package/dist/lib/validation/syntaxes/selector-list.js +0 -5
- package/dist/lib/validation/syntaxes/selector.js +0 -5
- package/dist/lib/validation/syntaxes/url.js +0 -40
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"/Users/thierrybela/web/WebstormProjects/css/src/lib/validation/json.ts":{"path":"/Users/thierrybela/web/WebstormProjects/css/src/lib/validation/json.ts","statementMap":{},"fnMap":{},"branchMap":{},"s":{},"f":{},"b":{},"all":true},"/Users/thierrybela/web/WebstormProjects/css/src/lib/parser/utils/at-rule-token.ts":{"path":"/Users/thierrybela/web/WebstormProjects/css/src/lib/parser/utils/at-rule-token.ts","statementMap":{},"fnMap":{"0":{"name":"parseAtRuleToken","decl":{"start":{"line":3,"column":16},"end":{"line":3,"column":32}},"loc":{"start":{"line":3,"column":35},"end":{"line":5,"column":1}},"line":3}},"branchMap":{},"s":{},"f":{"0":0},"b":{},"all":true},"/Users/thierrybela/web/WebstormProjects/css/src/lib/ast/features/index.ts":{"path":"/Users/thierrybela/web/WebstormProjects/css/src/lib/ast/features/index.ts","statementMap":{},"fnMap":{},"branchMap":{},"s":{},"f":{},"b":{},"all":true}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":null,"pid":30852,"argv":["/Users/thierrybela/.nvm/versions/node/v25.9.0/bin/node","/Users/thierrybela/web/WebstormProjects/css/node_modules/.bin/nyc","test/specs/node.spec.js"],"execArgv":[],"cwd":"/Users/thierrybela/web/WebstormProjects/css","time":1778344578772,"ppid":30830,"coverageFilename":"/Users/thierrybela/web/WebstormProjects/css/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json","externalId":"","uuid":"4874b20e-6f53-4d7a-be5a-cf68316925f2","files":["/Users/thierrybela/web/WebstormProjects/css/src/lib/validation/json.ts","/Users/thierrybela/web/WebstormProjects/css/src/lib/parser/utils/at-rule-token.ts","/Users/thierrybela/web/WebstormProjects/css/src/lib/ast/features/index.ts"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":null,"pid":30856,"argv":["/Users/thierrybela/.nvm/versions/node/v25.9.0/bin/node","undefined"],"execArgv":["-e","\nconst pid = parseInt(process.argv[1], 10)\nprocess.title = 'node (foreground-child watchdog pid=' + pid + ')'\nif (!isNaN(pid)) {\n let barked = false\n // keepalive\n const interval = setInterval(() => {}, 60000)\n const bark = () => {\n clearInterval(interval)\n if (barked) return\n barked = true\n process.removeListener('SIGHUP', bark)\n setTimeout(() => {\n try {\n process.kill(pid, 'SIGKILL')\n setTimeout(() => process.exit(), 200)\n } catch (_) {}\n }, 500)\n })\n process.on('SIGHUP', bark)\n}\n"],"cwd":"/Users/thierrybela/web/WebstormProjects/css","time":1778344579338,"ppid":1,"coverageFilename":"/Users/thierrybela/web/WebstormProjects/css/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json","externalId":"","uuid":"6193bc4c-6f5f-4898-8950-c628825e6342","files":[]}
|
package/.repl_history
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,167 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.4.3
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### CSS Modules
|
|
7
|
+
|
|
8
|
+
- [x] Add css module scope 'shortest' to produce short scoped names
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
|
|
12
|
+
result = await transform(css, {
|
|
13
|
+
|
|
14
|
+
beautify: true,
|
|
15
|
+
module: {scoped: ModuleScopeEnumOptions.Shortest
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log(result.code);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
output
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
.a {
|
|
27
|
+
background: red;
|
|
28
|
+
color: #ff0
|
|
29
|
+
}
|
|
30
|
+
.b {
|
|
31
|
+
background: blue
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### CSS if() function
|
|
36
|
+
|
|
37
|
+
- [x] support if() css function syntax https://drafts.csswg.org/css-values-5/#if-notation
|
|
38
|
+
- [x] convert css if() function into legacy syntax
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
|
|
42
|
+
const css = `
|
|
43
|
+
button {
|
|
44
|
+
background: linear-gradient(
|
|
45
|
+
if(media(min-width: 768px): to right; else: to bottom),
|
|
46
|
+
if(style(--dark-mode): #333; else: #fff),
|
|
47
|
+
if(style(--dark-mode): #000; else: #ccc)
|
|
48
|
+
);
|
|
49
|
+
}`;
|
|
50
|
+
|
|
51
|
+
result = await transform(css, {
|
|
52
|
+
|
|
53
|
+
beautify: true,
|
|
54
|
+
expandIfSyntax: true
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
console.log(result.code);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
output
|
|
63
|
+
|
|
64
|
+
```css
|
|
65
|
+
button {
|
|
66
|
+
background: linear-gradient(to bottom,#fff,#ccc);
|
|
67
|
+
@media (min-width:768px) {
|
|
68
|
+
background: linear-gradient(to right,#fff,#ccc);
|
|
69
|
+
@container style(--dark-mode) {
|
|
70
|
+
background: linear-gradient(to right,#333,#000)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
@container style(--dark-mode) {
|
|
74
|
+
background: linear-gradient(to bottom,#333,#000)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
### CSS Color Module Level 5 (Draft)
|
|
81
|
+
- [x] support contrast-color() https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/contrast-color
|
|
82
|
+
- [x] custom color space in color() https://drafts.csswg.org/css-color-5/#custom-color
|
|
83
|
+
- [x] relative color syntax
|
|
84
|
+
- [x] color syntax
|
|
85
|
+
|
|
86
|
+
### Media Queries
|
|
87
|
+
- [x] media queries validation
|
|
88
|
+
- [x] automatically generate range media query
|
|
89
|
+
- [x] add at-rule() and named-feature() to @support-condition syntax https://drafts.csswg.org/css-conditional-5/#changes-from-L4
|
|
90
|
+
- [x] support calc() in media features
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
|
|
95
|
+
const css = `
|
|
96
|
+
|
|
97
|
+
@media (width >= calc(1024px + 50px)) {
|
|
98
|
+
h1 {
|
|
99
|
+
color: Highlight;
|
|
100
|
+
}
|
|
101
|
+
}`;
|
|
102
|
+
|
|
103
|
+
result = await transform(css, {
|
|
104
|
+
|
|
105
|
+
beautify: true,
|
|
106
|
+
validation: true
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
console.log(result.code);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
output
|
|
115
|
+
|
|
116
|
+
```css
|
|
117
|
+
@media (width>=1074px) {
|
|
118
|
+
h1 {
|
|
119
|
+
color: Highlight
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Ast
|
|
125
|
+
|
|
126
|
+
- [x] add ast search functions
|
|
127
|
+
- [x] find() search the ast tree and return the first match
|
|
128
|
+
- [x] findAll() search the ast tree and return all matches
|
|
129
|
+
- [x] findLast() search the ast tree and return the last match
|
|
130
|
+
- [x] findByValue() search the ast tree by checking each node's value and return the first match
|
|
131
|
+
|
|
132
|
+
### Other Changes
|
|
133
|
+
- [x] fix parsing bugs
|
|
134
|
+
- [x] automatically rename standard declaration names : color-adjust => print-color-adjust
|
|
135
|
+
- [x] rewrite parsing and validation logic
|
|
136
|
+
- [x] selector
|
|
137
|
+
- [x] declaration
|
|
138
|
+
- [x] at-rules
|
|
139
|
+
- [x] @charset
|
|
140
|
+
- [x] @color-profile
|
|
141
|
+
- [x] @container
|
|
142
|
+
- [x] @counter-style
|
|
143
|
+
- [x] @custom-media
|
|
144
|
+
- [x] @document
|
|
145
|
+
- [x] @font-face
|
|
146
|
+
- [x] @font-feature-values
|
|
147
|
+
- [x] @font-palette-values
|
|
148
|
+
- [x] @import
|
|
149
|
+
- [x] @keyframes
|
|
150
|
+
- [x] @layer
|
|
151
|
+
- [x] @media
|
|
152
|
+
- [x] @namespace
|
|
153
|
+
- [x] @page
|
|
154
|
+
- [x] @position-try
|
|
155
|
+
- [x] @property
|
|
156
|
+
- [x] @scope
|
|
157
|
+
- [x] @starting-style
|
|
158
|
+
- [x] @supports
|
|
159
|
+
- [x] @view-transition
|
|
160
|
+
- [x] introduce rawToken type to capture unparseable tokens
|
|
161
|
+
|
|
3
162
|
## v1.4.2
|
|
4
163
|
|
|
164
|
+
- [x] add css-conditional-5 @support at-rule(<at-keyword-token>) function
|
|
5
165
|
- [x] fix bug when using remove prefix #120
|
|
6
166
|
|
|
7
167
|
## v1.4.0
|
|
@@ -9,7 +169,7 @@
|
|
|
9
169
|
### CSS Module support
|
|
10
170
|
|
|
11
171
|
- [x] scoped name generation
|
|
12
|
-
- composes:
|
|
172
|
+
- [x] composes:
|
|
13
173
|
- [x] compose from local selector
|
|
14
174
|
- [x] compose from other files
|
|
15
175
|
- [x] compose from global selector
|
|
@@ -24,17 +184,17 @@
|
|
|
24
184
|
- [x] css at-rule value
|
|
25
185
|
- [x] keyframe animations
|
|
26
186
|
- [x] grid
|
|
27
|
-
- naming
|
|
187
|
+
- [x] naming
|
|
28
188
|
- [x] ignore
|
|
29
189
|
- [x] camelCase
|
|
30
190
|
- [x] camelCaseOnly
|
|
31
191
|
- [x] dashCase
|
|
32
192
|
- [x] dashCaseOnly
|
|
33
|
-
- default mode
|
|
193
|
+
- [x] default mode
|
|
34
194
|
- [x] global
|
|
35
195
|
- [x] local
|
|
36
196
|
- [x] pure(at least one class or id)
|
|
37
|
-
- icss
|
|
197
|
+
- [x] icss
|
|
38
198
|
- [x] :import
|
|
39
199
|
- [x] :export
|
|
40
200
|
|
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ $ deno add @tbela99/css-parser
|
|
|
33
33
|
- color conversion to any supported color format
|
|
34
34
|
- automatic nested css rules generation
|
|
35
35
|
- nested css rules conversion to legacy syntax
|
|
36
|
+
- convert css if() function to legacy syntax
|
|
36
37
|
- sourcemap generation
|
|
37
38
|
- css shorthands computation. see the supported properties list below
|
|
38
39
|
- css transform functions minification
|
|
@@ -221,6 +222,7 @@ Include ParseOptions and RenderOptions
|
|
|
221
222
|
- nestingRules: boolean, optional. automatically generated nested rules.
|
|
222
223
|
- expandNestingRules: boolean, optional. convert nesting rules into separate rules. will automatically set nestingRules
|
|
223
224
|
to false.
|
|
225
|
+
- expandIfSyntax: experimental, convert css if() function into legacy syntax.
|
|
224
226
|
- removeDuplicateDeclarations: boolean, optional. remove duplicate declarations.
|
|
225
227
|
- computeTransform: boolean, optional. compute css transform functions.
|
|
226
228
|
- computeShorthand: boolean, optional. compute shorthand properties.
|
|
@@ -688,6 +690,47 @@ table.colortable th {
|
|
|
688
690
|
}
|
|
689
691
|
```
|
|
690
692
|
|
|
693
|
+
### CSS if() function expansion
|
|
694
|
+
|
|
695
|
+
```typescript
|
|
696
|
+
|
|
697
|
+
const css = `
|
|
698
|
+
button {
|
|
699
|
+
background: linear-gradient(
|
|
700
|
+
if(media(min-width: 768px): to right; else: to bottom),
|
|
701
|
+
if(style(--dark-mode): #333; else: #fff),
|
|
702
|
+
if(style(--dark-mode): #000; else: #ccc)
|
|
703
|
+
);
|
|
704
|
+
}`;
|
|
705
|
+
|
|
706
|
+
result = await transform(css, {
|
|
707
|
+
|
|
708
|
+
beautify: true,
|
|
709
|
+
expandIfSyntax: true
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
console.log(result.code);
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
output
|
|
718
|
+
|
|
719
|
+
```css
|
|
720
|
+
button {
|
|
721
|
+
background: linear-gradient(to bottom,#fff,#ccc);
|
|
722
|
+
@media (min-width:768px) {
|
|
723
|
+
background: linear-gradient(to right,#fff,#ccc);
|
|
724
|
+
@container style(--dark-mode) {
|
|
725
|
+
background: linear-gradient(to right,#333,#000)
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
@container style(--dark-mode) {
|
|
729
|
+
background: linear-gradient(to bottom,#333,#000)
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
```
|
|
733
|
+
|
|
691
734
|
### Calc() resolution
|
|
692
735
|
|
|
693
736
|
```javascript
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<svg width="114.3" height="20" viewBox="0 0 1143 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="coverage: 85.25%">
|
|
2
|
+
<title>coverage: 85.25%</title>
|
|
3
|
+
<linearGradient id="AQOpN" x2="0" y2="100%">
|
|
4
|
+
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
|
5
|
+
<stop offset="1" stop-opacity=".1"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<mask id="sgbWQ"><rect width="1143" height="200" rx="30" fill="#FFF"/></mask>
|
|
8
|
+
<g mask="url(#sgbWQ)">
|
|
9
|
+
<rect width="603" height="200" fill="#555"/>
|
|
10
|
+
<rect width="540" height="200" fill="#F73" x="603"/>
|
|
11
|
+
<rect width="1143" height="200" fill="url(#AQOpN)"/>
|
|
12
|
+
</g>
|
|
13
|
+
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
|
14
|
+
<text x="60" y="148" textLength="503" fill="#000" opacity="0.25">coverage</text>
|
|
15
|
+
<text x="50" y="138" textLength="503">coverage</text>
|
|
16
|
+
<text x="658" y="148" textLength="440" fill="#000" opacity="0.25">85.25%</text>
|
|
17
|
+
<text x="648" y="138" textLength="440">85.25%</text>
|
|
18
|
+
</g>
|
|
19
|
+
|
|
20
|
+
</svg>
|