@tbela99/css-parser 1.4.3 → 1.4.5
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 +196 -2
- package/README.md +68 -1120
- package/dist/config.json.js +43 -2
- package/dist/index-umd-web.js +18118 -15886
- package/dist/index.cjs +16838 -14611
- package/dist/index.d.ts +1804 -1684
- package/dist/lib/ast/clone.js +4 -3
- package/dist/lib/ast/expand.js +2 -2
- package/dist/lib/ast/features/calc.js +59 -54
- package/dist/lib/ast/features/if.js +64 -17
- package/dist/lib/ast/features/inlinecssvariables.js +2 -2
- package/dist/lib/ast/features/prefix.js +343 -6
- package/dist/lib/ast/features/transform.js +7 -4
- package/dist/lib/ast/find.js +5 -5
- package/dist/lib/ast/math/expression.js +12 -8
- package/dist/lib/ast/minify.js +28 -33
- package/dist/lib/ast/transform/minify.js +135 -131
- package/dist/lib/ast/transform/utils.js +3 -2
- package/dist/lib/ast/types.js +69 -8
- package/dist/lib/ast/walk.js +4 -5
- package/dist/lib/fs/resolve.js +71 -57
- package/dist/lib/parser/declaration/list.js +92 -3
- package/dist/lib/parser/declaration/map.js +5 -5
- package/dist/lib/parser/parse.js +530 -466
- package/dist/lib/parser/tokenize.js +110 -4
- package/dist/lib/parser/utils/angle.js +29 -0
- package/dist/lib/parser/utils/at-rule-container.js +2 -2
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +2 -2
- package/dist/lib/parser/utils/at-rule-generic.js +1 -1
- package/dist/lib/parser/utils/at-rule-media.js +2 -2
- package/dist/lib/parser/utils/at-rule-support.js +73 -8
- package/dist/lib/parser/utils/at-rule-when-else.js +2 -2
- package/dist/lib/parser/utils/at-rule.js +2 -8
- package/dist/lib/parser/utils/declaration.js +179 -76
- package/dist/lib/parser/utils/selector.js +53 -11
- package/dist/lib/parser/utils/token.js +13 -11
- package/dist/lib/renderer/render.js +501 -59
- package/dist/lib/syntax/color/alpha.js +64 -0
- package/dist/lib/syntax/color/cmyk.js +2 -2
- package/dist/lib/syntax/color/color-mix.js +283 -220
- package/dist/lib/syntax/color/color.js +37 -28
- package/dist/lib/syntax/color/hex.js +2 -2
- package/dist/lib/syntax/color/hsl.js +3 -3
- package/dist/lib/syntax/color/hwb.js +7 -7
- package/dist/lib/syntax/color/lab.js +5 -5
- package/dist/lib/syntax/color/lch.js +4 -4
- package/dist/lib/syntax/color/oklab.js +3 -3
- package/dist/lib/syntax/color/oklch.js +3 -3
- package/dist/lib/syntax/color/relativecolor.js +97 -12
- package/dist/lib/syntax/color/srgb.js +5 -5
- package/dist/lib/syntax/color/utils/color-type.js +18 -0
- package/dist/lib/syntax/color/utils/colorspace.js +46 -0
- package/dist/lib/syntax/color/utils/components.js +7 -3
- package/dist/lib/syntax/color/utils/distance.js +21 -4
- package/dist/lib/syntax/color/utils/make-color.js +56 -0
- package/dist/lib/syntax/color/xyz.js +2 -2
- package/dist/lib/syntax/constants.js +29 -1
- package/dist/lib/syntax/syntax.js +307 -39
- package/dist/lib/validation/config.js +2 -2
- package/dist/lib/validation/config.json.js +32 -17
- package/dist/lib/validation/match.js +239 -104
- package/dist/lib/validation/parser/parse.js +0 -1
- package/dist/lib/validation/parser/typedef.js +6 -0
- package/dist/node.js +64 -22
- package/dist/web.js +65 -18
- package/package.json +26 -15
- package/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +0 -1
- package/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json +0 -1
- package/.nyc_output/processinfo/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +0 -1
- package/.nyc_output/processinfo/6193bc4c-6f5f-4898-8950-c628825e6342.json +0 -1
- package/.repl_history +0 -4
- package/badges/coverage.svg +0 -20
- package/deno.lock +0 -2861
- package/dist/lib/ast/clone.d.ts +0 -10
- package/dist/lib/ast/expand.d.ts +0 -14
- package/dist/lib/ast/features/calc.d.ts +0 -10
- package/dist/lib/ast/features/if.d.ts +0 -10
- package/dist/lib/ast/features/index.d.ts +0 -6
- package/dist/lib/ast/features/inlinecssvariables.d.ts +0 -15
- package/dist/lib/ast/features/prefix.d.ts +0 -8
- package/dist/lib/ast/features/shorthand.d.ts +0 -12
- package/dist/lib/ast/features/transform.d.ts +0 -10
- package/dist/lib/ast/features/type.d.ts +0 -15
- package/dist/lib/ast/find.d.ts +0 -165
- package/dist/lib/ast/math/expression.d.ts +0 -18
- package/dist/lib/ast/math/math.d.ts +0 -6
- package/dist/lib/ast/minify.d.ts +0 -19
- package/dist/lib/ast/transform/compute.d.ts +0 -8
- package/dist/lib/ast/transform/matrix.d.ts +0 -22
- package/dist/lib/ast/transform/minify.d.ts +0 -5
- package/dist/lib/ast/transform/perspective.d.ts +0 -3
- package/dist/lib/ast/transform/rotate.d.ts +0 -12
- package/dist/lib/ast/transform/scale.d.ts +0 -6
- package/dist/lib/ast/transform/skew.d.ts +0 -4
- package/dist/lib/ast/transform/translate.d.ts +0 -6
- package/dist/lib/ast/transform/utils.d.ts +0 -9
- package/dist/lib/ast/types.d.ts +0 -903
- package/dist/lib/ast/walk.d.ts +0 -162
- package/dist/lib/fs/resolve.d.ts +0 -20
- package/dist/lib/parser/declaration/list.d.ts +0 -16
- package/dist/lib/parser/declaration/map.d.ts +0 -15
- package/dist/lib/parser/declaration/set.d.ts +0 -9
- package/dist/lib/parser/node.d.ts +0 -7
- package/dist/lib/parser/parse.d.ts +0 -107
- package/dist/lib/parser/tokenize.d.ts +0 -57
- package/dist/lib/parser/utils/at-rule-container.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-font-feature-values.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-generic.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-import.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-media.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-page.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-page.js +0 -28
- package/dist/lib/parser/utils/at-rule-support.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-token.d.ts +0 -1
- package/dist/lib/parser/utils/at-rule-when-else.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule.d.ts +0 -13
- package/dist/lib/parser/utils/cache.d.ts +0 -6
- package/dist/lib/parser/utils/config.d.ts +0 -2
- package/dist/lib/parser/utils/declaration-list.d.ts +0 -5
- package/dist/lib/parser/utils/declaration.d.ts +0 -18
- package/dist/lib/parser/utils/eq.d.ts +0 -1
- package/dist/lib/parser/utils/hash.d.ts +0 -21
- package/dist/lib/parser/utils/selector.d.ts +0 -5
- package/dist/lib/parser/utils/text.d.ts +0 -3
- package/dist/lib/parser/utils/token.d.ts +0 -14
- package/dist/lib/parser/utils/type.d.ts +0 -2
- package/dist/lib/renderer/render.d.ts +0 -28
- package/dist/lib/renderer/sourcemap/lib/encode.d.ts +0 -1
- package/dist/lib/renderer/sourcemap/sourcemap.d.ts +0 -26
- package/dist/lib/syntax/color/a98rgb.d.ts +0 -2
- package/dist/lib/syntax/color/cmyk.d.ts +0 -10
- package/dist/lib/syntax/color/color-mix.d.ts +0 -2
- package/dist/lib/syntax/color/color.d.ts +0 -42
- package/dist/lib/syntax/color/hex.d.ts +0 -16
- package/dist/lib/syntax/color/hsl.d.ts +0 -20
- package/dist/lib/syntax/color/hsv.d.ts +0 -2
- package/dist/lib/syntax/color/hwb.d.ts +0 -21
- package/dist/lib/syntax/color/lab.d.ts +0 -25
- package/dist/lib/syntax/color/lch.d.ts +0 -23
- package/dist/lib/syntax/color/oklab.d.ts +0 -22
- package/dist/lib/syntax/color/oklch.d.ts +0 -20
- package/dist/lib/syntax/color/p3.d.ts +0 -6
- package/dist/lib/syntax/color/prophotorgb.d.ts +0 -2
- package/dist/lib/syntax/color/rec2020.d.ts +0 -2
- package/dist/lib/syntax/color/relativecolor.d.ts +0 -13
- package/dist/lib/syntax/color/rgb.d.ts +0 -20
- package/dist/lib/syntax/color/srgb.d.ts +0 -23
- package/dist/lib/syntax/color/utils/components.d.ts +0 -2
- package/dist/lib/syntax/color/utils/distance.d.ts +0 -18
- package/dist/lib/syntax/color/utils/matrix.d.ts +0 -6
- package/dist/lib/syntax/color/xyz.d.ts +0 -5
- package/dist/lib/syntax/color/xyzd50.d.ts +0 -4
- package/dist/lib/syntax/constants.d.ts +0 -67
- package/dist/lib/syntax/syntax.d.ts +0 -38
- package/dist/lib/validation/config.d.ts +0 -14
- package/dist/lib/validation/json.d.ts +0 -2
- package/dist/lib/validation/match.d.ts +0 -38
- package/dist/lib/validation/parser/parse.d.ts +0 -8
- package/dist/lib/validation/parser/typedef.d.ts +0 -95
- package/dist/lib/validation/utils/list.d.ts +0 -4
- package/dist/lib/validation/utils/whitespace.d.ts +0 -2
- package/dist/node.d.ts +0 -207
- package/dist/web.d.ts +0 -169
- package/playground/index.html +0 -1328
- package/playground/sw.js +0 -55
- package/playground/tree.js +0 -176
package/dist/lib/ast/clone.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AstNode } from "../../@types/index.d.ts";
|
|
2
|
-
import type { Token } from "../../@types/token.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param node he nod to clone
|
|
6
|
-
* @param cloneChildren deep clone
|
|
7
|
-
* @param cloneMap a map of existing children as keys and their clones as values
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare function cloneNode(node: AstNode, cloneChildren?: boolean, cloneMap?: Map<Token | AstNode, Token | AstNode> | null): AstNode;
|
package/dist/lib/ast/expand.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { AstAtRule, AstNode, AstRule, AstStyleSheet } from "../../@types/index.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* expand css nesting ast nodes
|
|
4
|
-
* @param ast
|
|
5
|
-
*
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
export declare function expand(ast: AstStyleSheet | AstAtRule | AstRule): AstNode;
|
|
9
|
-
/**
|
|
10
|
-
* replace compound selector
|
|
11
|
-
* @param input
|
|
12
|
-
* @param replace
|
|
13
|
-
*/
|
|
14
|
-
export declare function replaceCompound(input: string, replace: string): string;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AstAtRule, AstNode, AstRule, ParserOptions } from "../../../@types/index.d.ts";
|
|
2
|
-
import { EnumToken } from "../types.ts";
|
|
3
|
-
import { FeatureWalkMode } from "./type.ts";
|
|
4
|
-
export declare class ComputeCalcExpressionFeature {
|
|
5
|
-
accept: Set<EnumToken>;
|
|
6
|
-
get ordering(): number;
|
|
7
|
-
get processMode(): FeatureWalkMode;
|
|
8
|
-
static register(options: ParserOptions): void;
|
|
9
|
-
run(ast: AstRule | AstAtRule): AstNode | null;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AstDeclaration, AstNode, ParserOptions } from "../../../@types/index.d.ts";
|
|
2
|
-
import { EnumToken } from "../types.ts";
|
|
3
|
-
import { FeatureWalkMode } from "./type.ts";
|
|
4
|
-
export declare class ExpandIfFeature {
|
|
5
|
-
accept: Set<EnumToken>;
|
|
6
|
-
get ordering(): number;
|
|
7
|
-
get processMode(): FeatureWalkMode;
|
|
8
|
-
static register(options: ParserOptions): void;
|
|
9
|
-
run(declaration: AstDeclaration): AstNode | null;
|
|
10
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AstAtRule, AstNode, AstRule, AstStyleSheet, ParserOptions } from "../../../@types/index.d.ts";
|
|
2
|
-
import { EnumToken } from "../types.ts";
|
|
3
|
-
import { FeatureWalkMode } from "./type.ts";
|
|
4
|
-
export declare class InlineCssVariablesFeature {
|
|
5
|
-
accept: Set<EnumToken>;
|
|
6
|
-
get ordering(): number;
|
|
7
|
-
get processMode(): FeatureWalkMode;
|
|
8
|
-
static register(options: ParserOptions): void;
|
|
9
|
-
run(ast: AstRule | AstAtRule, options: ParserOptions | undefined, parent: AstRule | AstAtRule | AstStyleSheet, context: {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}): AstNode | null;
|
|
12
|
-
cleanup(ast: AstStyleSheet, options: ParserOptions | undefined, context: {
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
}): void;
|
|
15
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AstNode, ParserOptions } from "../../../@types/index.d.ts";
|
|
2
|
-
import { FeatureWalkMode } from "./type.ts";
|
|
3
|
-
export declare class ComputePrefixFeature {
|
|
4
|
-
get ordering(): number;
|
|
5
|
-
get processMode(): FeatureWalkMode;
|
|
6
|
-
static register(options: ParserOptions): void;
|
|
7
|
-
run(node: AstNode): AstNode | null;
|
|
8
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EnumToken } from "../types.ts";
|
|
2
|
-
import type { AstAtRule, AstNode, AstRule, AstStyleSheet, ParserOptions, PropertyListOptions } from "../../../@types/index.d.ts";
|
|
3
|
-
import { FeatureWalkMode } from "./type.ts";
|
|
4
|
-
export declare class ComputeShorthandFeature {
|
|
5
|
-
accept: Set<EnumToken>;
|
|
6
|
-
get ordering(): number;
|
|
7
|
-
get processMode(): FeatureWalkMode;
|
|
8
|
-
static register(options: ParserOptions): void;
|
|
9
|
-
run(ast: AstRule | AstAtRule, options: PropertyListOptions | undefined, parent: AstRule | AstAtRule | AstStyleSheet, context: {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}): AstNode | null;
|
|
12
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AstAtRule, AstNode, AstRule, ParserOptions } from "../../../@types/index.d.ts";
|
|
2
|
-
import { EnumToken } from "../types.ts";
|
|
3
|
-
import { FeatureWalkMode } from "./type.ts";
|
|
4
|
-
export declare class TransformCssFeature {
|
|
5
|
-
accept: Set<EnumToken>;
|
|
6
|
-
get ordering(): number;
|
|
7
|
-
get processMode(): FeatureWalkMode;
|
|
8
|
-
static register(options: ParserOptions): void;
|
|
9
|
-
run(ast: AstRule | AstAtRule): AstNode | null;
|
|
10
|
-
}
|
package/dist/lib/ast/find.d.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import type { Token } from "../../@types/token.d.ts";
|
|
2
|
-
import type { AstNode, AstValueMatcher, TokenSearchResult } from "../../@types/ast.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* search the ast tree and return the first match
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* // find the first ast declaration node which name is 'aspect-ratio'
|
|
8
|
-
import { find, EnumToken, transform } from "@tbela99/css-parser";
|
|
9
|
-
import type { AstNode } from "@tbela99/css-parser";
|
|
10
|
-
|
|
11
|
-
* const css = `
|
|
12
|
-
|
|
13
|
-
button {
|
|
14
|
-
aspect-ratio: 1;
|
|
15
|
-
width: if(media(any-pointer: fine): 30px; else: 44px);
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
// find declaration which contain a '30px'
|
|
20
|
-
const nodeMatcher = (node: AstNode) =>
|
|
21
|
-
return node.typ == EnumToken.DeclarationNodeType && (node as AstDeclaration).nam == 'aspect-ratio';
|
|
22
|
-
|
|
23
|
-
const result = await transform(css);
|
|
24
|
-
const node = find(result.ast, nodeMatcher);
|
|
25
|
-
|
|
26
|
-
console.log({node});
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
*
|
|
30
|
-
* @param ast
|
|
31
|
-
* @param matcher
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
export declare function find(ast: AstNode, matcher: (node: AstNode) => boolean): AstNode | null;
|
|
35
|
-
/**
|
|
36
|
-
* search the ast tree by checking each node's value and return the first match
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* // find the first ast node which contains the length token '30px'
|
|
40
|
-
import { findByValue, EnumToken, transform } from "@tbela99/css-parser";
|
|
41
|
-
import type { AstNode } from "@tbela99/css-parser";
|
|
42
|
-
|
|
43
|
-
* const css = `
|
|
44
|
-
|
|
45
|
-
button {
|
|
46
|
-
aspect-ratio: 1;
|
|
47
|
-
width: if(media(any-pointer: fine): 30px; else: 44px);
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
// find declaration which contain a '30px'
|
|
52
|
-
const nodeMatcher = (value: Token) =>
|
|
53
|
-
return value.typ == EnumToken.LengthTokenType && (value as LengthToken).val == 30 && (value as LengthToken).unit == 'px' ;
|
|
54
|
-
|
|
55
|
-
const result = await transform(css);
|
|
56
|
-
const { node, value } = findByValue(result.ast, nodeMatcher) ?? {};
|
|
57
|
-
|
|
58
|
-
console.log({node, value});
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
*
|
|
62
|
-
* @param ast
|
|
63
|
-
* @param matcher
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
export declare function findByValue(ast: AstNode, matcher: AstValueMatcher): {
|
|
67
|
-
node: AstNode;
|
|
68
|
-
value: TokenSearchResult;
|
|
69
|
-
} | null;
|
|
70
|
-
/**
|
|
71
|
-
* search the ast tree and return all matches
|
|
72
|
-
*
|
|
73
|
-
* ```ts
|
|
74
|
-
* // find the first ast declaration node which name is 'aspect-ratio'
|
|
75
|
-
import { findAll, EnumToken, transform } from "@tbela99/css-parser";
|
|
76
|
-
import type { AstNode } from "@tbela99/css-parser";
|
|
77
|
-
|
|
78
|
-
* const css = `
|
|
79
|
-
|
|
80
|
-
button {
|
|
81
|
-
aspect-ratio: 1;
|
|
82
|
-
width: if(media(any-pointer: fine): 30px; else: 44px);
|
|
83
|
-
}
|
|
84
|
-
`;
|
|
85
|
-
|
|
86
|
-
// find declaration which contain a '30px'
|
|
87
|
-
const nodeMatcher = (node: AstNode) =>
|
|
88
|
-
return node.typ == EnumToken.DeclarationNodeType && (node as AstDeclaration).nam == 'aspect-ratio';
|
|
89
|
-
|
|
90
|
-
const result = await transform(css);
|
|
91
|
-
const nodes = findAll(result.ast, nodeMatcher);
|
|
92
|
-
|
|
93
|
-
console.log({nodes});
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
*
|
|
97
|
-
* @param ast
|
|
98
|
-
* @param matcher
|
|
99
|
-
* @returns
|
|
100
|
-
*/
|
|
101
|
-
export declare function findAll(ast: AstNode, matcher: (node: AstNode) => boolean): AstNode[];
|
|
102
|
-
/**
|
|
103
|
-
* search the ast tree and return the last match
|
|
104
|
-
*
|
|
105
|
-
* ```ts
|
|
106
|
-
* // find the first ast declaration node which name is 'aspect-ratio'
|
|
107
|
-
import { findLast, EnumToken, transform } from "@tbela99/css-parser";
|
|
108
|
-
import type { AstNode } from "@tbela99/css-parser";
|
|
109
|
-
|
|
110
|
-
* const css = `
|
|
111
|
-
|
|
112
|
-
button {
|
|
113
|
-
aspect-ratio: 1;
|
|
114
|
-
width: if(media(any-pointer: fine): 30px; else: 44px);
|
|
115
|
-
}
|
|
116
|
-
`;
|
|
117
|
-
|
|
118
|
-
// find declaration which contain a '30px'
|
|
119
|
-
const nodeMatcher = (node: AstNode) =>
|
|
120
|
-
return node.typ == EnumToken.DeclarationNodeType && (node as AstDeclaration).nam == 'aspect-ratio';
|
|
121
|
-
|
|
122
|
-
const result = await transform(css);
|
|
123
|
-
const node = findLast(result.ast, nodeMatcher);
|
|
124
|
-
|
|
125
|
-
console.log({node});
|
|
126
|
-
|
|
127
|
-
```
|
|
128
|
-
*
|
|
129
|
-
* @param ast
|
|
130
|
-
* @param matcher
|
|
131
|
-
* @returns
|
|
132
|
-
*/
|
|
133
|
-
export declare function findLast(ast: AstNode, matcher: (node: AstNode) => boolean): AstNode | null;
|
|
134
|
-
/**
|
|
135
|
-
* find the node's value token of the specified ast node
|
|
136
|
-
*
|
|
137
|
-
* ```ts
|
|
138
|
-
* // find the first ast declaration node which name is 'aspect-ratio'
|
|
139
|
-
import { findValue, EnumToken, transform } from "@tbela99/css-parser";
|
|
140
|
-
import type { AstNode } from "@tbela99/css-parser";
|
|
141
|
-
|
|
142
|
-
* const css = `
|
|
143
|
-
|
|
144
|
-
button {
|
|
145
|
-
aspect-ratio: 1;
|
|
146
|
-
width: if(media(any-pointer: fine): 30px; else: 44px);
|
|
147
|
-
}
|
|
148
|
-
`;
|
|
149
|
-
|
|
150
|
-
// find declaration which contain a '30px'
|
|
151
|
-
const nodeMatcher = (node: AstNode) =>
|
|
152
|
-
return node.typ == EnumToken.DeclarationNodeType && (node as AstDeclaration).nam == 'aspect-ratio';
|
|
153
|
-
|
|
154
|
-
const result = await transform(css);
|
|
155
|
-
const found = findValue(result.ast.chi[0], nodeMatcher);
|
|
156
|
-
|
|
157
|
-
console.log({found}); // 'button' token of the selector
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
*
|
|
161
|
-
* @param ast
|
|
162
|
-
* @param matcher
|
|
163
|
-
* @returns
|
|
164
|
-
*/
|
|
165
|
-
export declare function findValue(ast: AstNode | Token, matcher: (node: AstNode, parent?: AstNode | Token | null, root?: AstNode | null, parents?: Generator<Token> | null) => boolean): TokenSearchResult | null;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BinaryExpressionToken, FunctionToken, Token } from "../../../@types/index.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* evaluate an array of tokens
|
|
4
|
-
* @param tokens
|
|
5
|
-
*/
|
|
6
|
-
export declare function evaluate(tokens: Token[]): Token[];
|
|
7
|
-
export declare function evaluateFunc(token: FunctionToken): Token[] | null;
|
|
8
|
-
/**
|
|
9
|
-
* convert BinaryExpression into an array
|
|
10
|
-
* @param token
|
|
11
|
-
*/
|
|
12
|
-
export declare function inlineExpression(token: Token): Token[];
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* generate a binary expression tree
|
|
16
|
-
* @param tokens
|
|
17
|
-
*/
|
|
18
|
-
export declare function buildExpression(tokens: Token[]): BinaryExpressionToken;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FractionToken } from "../../../@types/index.d.ts";
|
|
2
|
-
import { EnumToken } from "../types.ts";
|
|
3
|
-
export declare function gcd(x: number, y: number): number;
|
|
4
|
-
export declare function compute(a: number | FractionToken, b: number | FractionToken, op: EnumToken.Add | EnumToken.Sub | EnumToken.Mul | EnumToken.Div): number | FractionToken;
|
|
5
|
-
export declare function rem(...a: number[]): number;
|
|
6
|
-
export declare function simplify(a: number, b: number): [number, number];
|
package/dist/lib/ast/minify.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AstNode, ErrorDescription, MinifyFeatureOptions, ParserOptions } from "../../@types/index.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* apply minification rules to the ast tree
|
|
4
|
-
* @param ast
|
|
5
|
-
* @param options
|
|
6
|
-
* @param recursive
|
|
7
|
-
* @param errors
|
|
8
|
-
* @param nestingContent
|
|
9
|
-
*
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
export declare function minify(ast: AstNode, options: ParserOptions | MinifyFeatureOptions, recursive: boolean, errors?: ErrorDescription[], nestingContent?: boolean): AstNode;
|
|
13
|
-
/**
|
|
14
|
-
* split selector string
|
|
15
|
-
* @param buffer
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare function splitRule(buffer: string): string[][];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Token } from "../../../@types/token.d.ts";
|
|
2
|
-
import type { Matrix } from "./type.d.ts";
|
|
3
|
-
export declare function compute(transformLists: Token[]): {
|
|
4
|
-
matrix: Token;
|
|
5
|
-
cumulative: Token[];
|
|
6
|
-
minified: Token[];
|
|
7
|
-
} | null;
|
|
8
|
-
export declare function computeMatrix(transformList: Token[], matrixVar: Matrix): Matrix | null;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { FunctionToken, IdentToken, Token } from "../../../@types/index.d.ts";
|
|
2
|
-
import type { Matrix } from "./type.d.ts";
|
|
3
|
-
export declare function parseMatrix(mat: FunctionToken | IdentToken): Matrix | null;
|
|
4
|
-
export declare function matrix(values: [number, number, number, number, number, number] | [
|
|
5
|
-
number,
|
|
6
|
-
number,
|
|
7
|
-
number,
|
|
8
|
-
number,
|
|
9
|
-
number,
|
|
10
|
-
number,
|
|
11
|
-
number,
|
|
12
|
-
number,
|
|
13
|
-
number,
|
|
14
|
-
number,
|
|
15
|
-
number,
|
|
16
|
-
number,
|
|
17
|
-
number,
|
|
18
|
-
number,
|
|
19
|
-
number,
|
|
20
|
-
number
|
|
21
|
-
]): Matrix | null;
|
|
22
|
-
export declare function serialize(matrix: Matrix): Token;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { FunctionToken, Token } from "../../../@types/index.d.ts";
|
|
2
|
-
import type { Matrix } from "./type.d.ts";
|
|
3
|
-
export declare function minify(matrix: Matrix): Token[] | null;
|
|
4
|
-
export declare function eqMatrix(a: FunctionToken | Matrix, b: Token[]): boolean;
|
|
5
|
-
export declare function minifyTransformFunctions(transform: FunctionToken): FunctionToken;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Matrix } from "./type.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* angle in radian
|
|
4
|
-
* @param angle
|
|
5
|
-
* @param x
|
|
6
|
-
* @param y
|
|
7
|
-
* @param z
|
|
8
|
-
* @param from
|
|
9
|
-
*/
|
|
10
|
-
export declare function rotate3D(angle: number, x: number, y: number, z: number, from: Matrix): Matrix;
|
|
11
|
-
export declare function rotate(angle: number, from: Matrix): Matrix;
|
|
12
|
-
export declare const rotateZ: typeof rotate;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Matrix } from "./type.d.ts";
|
|
2
|
-
export declare function scaleX(x: number, from: Matrix): Matrix;
|
|
3
|
-
export declare function scaleY(y: number, from: Matrix): Matrix;
|
|
4
|
-
export declare function scaleZ(z: number, from: Matrix): Matrix;
|
|
5
|
-
export declare function scale(x: number, y: number, from: Matrix): Matrix;
|
|
6
|
-
export declare function scale3d(x: number, y: number, z: number, from: Matrix): Matrix;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Matrix } from "./type.d.ts";
|
|
2
|
-
export declare function translateX(x: number, from: Matrix): Matrix;
|
|
3
|
-
export declare function translateY(y: number, from: Matrix): Matrix;
|
|
4
|
-
export declare function translateZ(z: number, from: Matrix): Matrix;
|
|
5
|
-
export declare function translate(translate: [number] | [number, number], from: Matrix): Matrix;
|
|
6
|
-
export declare function translate3d(translate: [number, number, number], from: Matrix): Matrix;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { DecomposedMatrix3D, Matrix } from "./type.d.ts";
|
|
2
|
-
export declare const epsilon = 0.00001;
|
|
3
|
-
export declare function identity(): Matrix;
|
|
4
|
-
export declare function multiply(matrixA: Matrix, matrixB: Matrix): Matrix;
|
|
5
|
-
export declare function round(number: number): number;
|
|
6
|
-
export declare function decompose(original: Matrix): DecomposedMatrix3D | null;
|
|
7
|
-
export declare function toZero(v: number[]): number[];
|
|
8
|
-
export declare function toZero(v: Matrix): Matrix;
|
|
9
|
-
export declare function is2DMatrix(matrix: Matrix): boolean;
|