@tbela99/css-parser 0.9.1 → 1.0.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/LICENSE.md +1 -1
- package/README.md +15 -8
- package/dist/index-umd-web.js +1815 -498
- package/dist/index.cjs +1816 -499
- package/dist/index.d.ts +46 -14
- package/dist/lib/ast/features/calc.js +7 -10
- package/dist/lib/ast/features/index.js +1 -0
- package/dist/lib/ast/features/inlinecssvariables.js +0 -5
- package/dist/lib/ast/features/prefix.js +2 -7
- package/dist/lib/ast/features/shorthand.js +6 -9
- package/dist/lib/ast/features/transform.js +60 -0
- package/dist/lib/ast/math/expression.js +14 -10
- package/dist/lib/ast/math/math.js +14 -2
- package/dist/lib/ast/minify.js +46 -5
- package/dist/lib/ast/transform/compute.js +336 -0
- package/dist/lib/ast/transform/convert.js +33 -0
- package/dist/lib/ast/transform/matrix.js +111 -0
- package/dist/lib/ast/transform/minify.js +296 -0
- package/dist/lib/ast/transform/perspective.js +10 -0
- package/dist/lib/ast/transform/rotate.js +40 -0
- package/dist/lib/ast/transform/scale.js +32 -0
- package/dist/lib/ast/transform/skew.js +23 -0
- package/dist/lib/ast/transform/translate.js +32 -0
- package/dist/lib/ast/transform/utils.js +198 -0
- package/dist/lib/ast/types.js +1 -0
- package/dist/lib/ast/walk.js +23 -17
- package/dist/lib/parser/parse.js +109 -88
- package/dist/lib/parser/utils/declaration.js +1 -1
- package/dist/lib/renderer/color/{colormix.js → color-mix.js} +6 -0
- package/dist/lib/renderer/color/color.js +94 -18
- package/dist/lib/renderer/color/hex.js +17 -7
- package/dist/lib/renderer/color/hsl.js +7 -2
- package/dist/lib/renderer/color/lab.js +8 -0
- package/dist/lib/renderer/color/lch.js +8 -0
- package/dist/lib/renderer/color/oklab.js +8 -0
- package/dist/lib/renderer/color/oklch.js +8 -0
- package/dist/lib/renderer/color/relativecolor.js +10 -21
- package/dist/lib/renderer/color/rgb.js +10 -7
- package/dist/lib/renderer/color/srgb.js +30 -6
- package/dist/lib/renderer/color/utils/components.js +13 -2
- package/dist/lib/renderer/render.js +67 -30
- package/dist/lib/syntax/syntax.js +74 -56
- package/dist/lib/validation/at-rules/container.js +6 -6
- package/dist/lib/validation/at-rules/document.js +1 -1
- package/dist/lib/validation/at-rules/keyframes.js +1 -1
- package/dist/lib/validation/at-rules/media.js +0 -1
- package/dist/lib/validation/atrule.js +0 -4
- package/dist/lib/validation/selector.js +5 -2
- package/dist/lib/validation/syntaxes/keyframe-block-list.js +2 -2
- package/dist/lib/validation/syntaxes/keyframe-selector.js +11 -90
- package/dist/lib/validation/syntaxes/relative-selector.js +15 -14
- package/dist/lib/validation/utils/list.js +18 -1
- package/dist/node/load.js +1 -1
- package/package.json +12 -12
- package/dist/lib/renderer/color/prophotoRgb.js +0 -56
- package/dist/lib/validation/declaration.js +0 -94
- package/dist/lib/validation/syntax.js +0 -1509
- package/dist/lib/validation/syntaxes/image.js +0 -29
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -27,15 +27,14 @@ $ deno add @tbela99/css-parser
|
|
|
27
27
|
- fault-tolerant parser, will try to fix invalid tokens according to the CSS syntax module 3 recommendations.
|
|
28
28
|
- fast and efficient minification without unsafe transforms,
|
|
29
29
|
see [benchmark](https://tbela99.github.io/css-parser/benchmark/index.html)
|
|
30
|
-
- minify colors
|
|
31
|
-
- support css color level 4 & 5: color(), lab(), lch(), oklab(), oklch(), color-mix(), light-dark(), system colors and
|
|
30
|
+
- minify colors: color(), lab(), lch(), oklab(), oklch(), color-mix(), light-dark(), system colors and
|
|
32
31
|
relative color
|
|
33
32
|
- generate nested css rules
|
|
34
33
|
- convert nested css rules to legacy syntax
|
|
35
34
|
- generate sourcemap
|
|
36
35
|
- compute css shorthands. see supported properties list below
|
|
37
|
-
-
|
|
38
|
-
|
|
36
|
+
- css transform functions minification
|
|
37
|
+
- evaluate math functions: calc(), clamp(), min(), max(), etc.
|
|
39
38
|
- inline css variables
|
|
40
39
|
- remove duplicate properties
|
|
41
40
|
- flatten @import rules
|
|
@@ -96,7 +95,7 @@ Javascript module from cdn
|
|
|
96
95
|
|
|
97
96
|
<script type="module">
|
|
98
97
|
|
|
99
|
-
import {transform} from 'https://esm.sh/@tbela99/css-parser@0.
|
|
98
|
+
import {transform} from 'https://esm.sh/@tbela99/css-parser@1.0.0/web';
|
|
100
99
|
|
|
101
100
|
|
|
102
101
|
const css = `
|
|
@@ -159,6 +158,7 @@ Include ParseOptions and RenderOptions
|
|
|
159
158
|
- expandNestingRules: boolean, optional. convert nesting rules into separate rules. will automatically set nestingRules
|
|
160
159
|
to false.
|
|
161
160
|
- removeDuplicateDeclarations: boolean, optional. remove duplicate declarations.
|
|
161
|
+
- computeTransform: boolean, optional. compute css transform functions.
|
|
162
162
|
- computeShorthand: boolean, optional. compute shorthand properties.
|
|
163
163
|
- computeCalcExpression: boolean, optional. evaluate calc() expression
|
|
164
164
|
- inlineCssVariables: boolean, optional. replace some css variables with their actual value. they must be declared once
|
|
@@ -176,13 +176,18 @@ Include ParseOptions and RenderOptions
|
|
|
176
176
|
- src: string, optional. original css file location to be used with sourcemap, also used to resolve url().
|
|
177
177
|
- sourcemap: boolean, optional. preserve node location data.
|
|
178
178
|
|
|
179
|
-
>
|
|
179
|
+
> Ast Traversal Options
|
|
180
|
+
|
|
181
|
+
- visitor: VisitorNodeMap, optional. node visitor used to transform the ast.
|
|
182
|
+
|
|
183
|
+
> Urls and \@import Options
|
|
180
184
|
|
|
185
|
+
- resolveImport: boolean, optional. replace @import rule by the content of the referenced stylesheet.
|
|
181
186
|
- resolveUrls: boolean, optional. resolve css 'url()' according to the parameters 'src' and 'cwd'
|
|
182
|
-
|
|
187
|
+
|
|
188
|
+
> Misc Options
|
|
183
189
|
- removeCharset: boolean, optional. remove @charset.
|
|
184
190
|
- cwd: string, optional. destination directory used to resolve url().
|
|
185
|
-
- visitor: VisitorNodeMap, optional. node visitor used to transform the ast.
|
|
186
191
|
- signal: AbortSignal, optional. abort parsing.
|
|
187
192
|
|
|
188
193
|
#### RenderOptions
|
|
@@ -701,6 +706,8 @@ for (const {node, parent, root} of walk(ast)) {
|
|
|
701
706
|
|
|
702
707
|
## Minification
|
|
703
708
|
|
|
709
|
+
- [x] minify keyframs
|
|
710
|
+
- [x] minify transform
|
|
704
711
|
- [x] evaluate math functions calc(), clamp(), min(), max(), round(), mod(), rem(), sin(), cos(), tan(), asin(),
|
|
705
712
|
acos(), atan(), atan2(), pow(), sqrt(), hypot(), log(), exp(), abs(), sign()
|
|
706
713
|
- [x] multi-pass minification
|