@tbela99/css-parser 1.6.3 → 1.6.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 +56 -0
- package/README.md +112 -8
- package/dist/{lib/data → data}/properties.json.js +296 -29
- package/dist/{lib/data → data}/validation.json.js +6 -0
- package/dist/index-umd-web.js +962 -744
- package/dist/index.cjs +961 -744
- package/dist/index.d.ts +24 -6
- package/dist/lib/ast/expand.js +1 -1
- package/dist/lib/ast/features/calc.js +16 -4
- package/dist/lib/ast/features/if.js +2 -2
- package/dist/lib/ast/features/inlinecssvariables.js +3 -3
- package/dist/lib/ast/features/prefix.js +2 -2
- package/dist/lib/ast/features/shorthand.js +8 -6
- package/dist/lib/ast/features/transform.js +2 -2
- package/dist/lib/ast/math/expression.js +24 -1
- package/dist/lib/ast/minify.js +3 -2
- package/dist/lib/ast/transform/utils.js +2 -2
- package/dist/lib/ast/walk.js +108 -90
- package/dist/lib/parser/declaration/list.js +29 -26
- package/dist/lib/parser/declaration/map.js +186 -54
- package/dist/lib/parser/parse.js +11 -9
- package/dist/lib/parser/source.js +2 -2
- package/dist/lib/parser/tokenize.js +99 -124
- package/dist/lib/parser/utils/config.js +1 -1
- package/dist/lib/parser/utils/declaration.js +0 -18
- package/dist/lib/parser/utils/hash.js +10 -5
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/{renderer → printer}/render.js +29 -53
- package/dist/lib/syntax/color/a98rgb.js +1 -1
- package/dist/lib/syntax/color/alpha.js +19 -20
- package/dist/lib/syntax/color/color-mix.js +15 -14
- package/dist/lib/syntax/color/hex.js +4 -1
- package/dist/lib/syntax/color/lch.js +0 -1
- package/dist/lib/syntax/color/oklch.js +0 -1
- package/dist/lib/syntax/color/relative-color.js +11 -11
- package/dist/lib/syntax/color/utils/components.js +0 -20
- package/dist/lib/syntax/color/xyzd50.js +0 -17
- package/dist/lib/syntax/constants.js +6 -1
- package/dist/lib/syntax/syntax.js +2 -2
- package/dist/lib/validation/config.js +5 -33
- package/dist/lib/validation/match.js +52 -181
- package/dist/node.js +3 -3
- package/dist/web.js +4 -3
- package/package.json +6 -5
- /package/dist/lib/{renderer → printer}/sourcemap/lib/codec.js +0 -0
- /package/dist/lib/{renderer → printer}/sourcemap/sourcemap.js +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -4132,7 +4132,6 @@ declare class LineMap {
|
|
|
4132
4132
|
* Source file helper class
|
|
4133
4133
|
*/
|
|
4134
4134
|
declare class SourceFile {
|
|
4135
|
-
private inputSourceMap;
|
|
4136
4135
|
/**
|
|
4137
4136
|
* Source file ID
|
|
4138
4137
|
*/
|
|
@@ -4149,6 +4148,7 @@ declare class SourceFile {
|
|
|
4149
4148
|
* Source file content
|
|
4150
4149
|
*/
|
|
4151
4150
|
content: string;
|
|
4151
|
+
private inputSourceMap;
|
|
4152
4152
|
/**
|
|
4153
4153
|
* Constructor
|
|
4154
4154
|
* @param content
|
|
@@ -4495,8 +4495,8 @@ interface PropertyType {
|
|
|
4495
4495
|
}
|
|
4496
4496
|
|
|
4497
4497
|
interface SinglePropertyType {
|
|
4498
|
-
|
|
4499
|
-
|
|
4498
|
+
typ: keyof EnumToken;
|
|
4499
|
+
val: string | number;
|
|
4500
4500
|
}
|
|
4501
4501
|
|
|
4502
4502
|
interface SinglePropertyTypeMapping {
|
|
@@ -5011,10 +5011,15 @@ export declare interface WalkerOptions {
|
|
|
5011
5011
|
*/
|
|
5012
5012
|
reverse?: boolean;
|
|
5013
5013
|
|
|
5014
|
+
/**
|
|
5015
|
+
* traverse node children
|
|
5016
|
+
*/
|
|
5017
|
+
children?: boolean;
|
|
5018
|
+
|
|
5014
5019
|
/**
|
|
5015
5020
|
* Traverse node value tokens. If false, only traverse node children
|
|
5016
5021
|
*/
|
|
5017
|
-
|
|
5022
|
+
attributes?: boolean;
|
|
5018
5023
|
/**
|
|
5019
5024
|
* filter function to control the walk
|
|
5020
5025
|
*/
|
|
@@ -5212,6 +5217,12 @@ interface MinifyOptions {
|
|
|
5212
5217
|
* Enable minification
|
|
5213
5218
|
*/
|
|
5214
5219
|
minify?: boolean;
|
|
5220
|
+
|
|
5221
|
+
/**
|
|
5222
|
+
* enable ast minification
|
|
5223
|
+
*/
|
|
5224
|
+
minifyAST?: boolean;
|
|
5225
|
+
|
|
5215
5226
|
/**
|
|
5216
5227
|
* Parse color tokens
|
|
5217
5228
|
*/
|
|
@@ -5289,7 +5300,8 @@ export declare type LoadResult =
|
|
|
5289
5300
|
| Promise<ReadableStream<Uint8Array>>
|
|
5290
5301
|
| ReadableStream<Uint8Array>
|
|
5291
5302
|
| string
|
|
5292
|
-
| Promise<string>
|
|
5303
|
+
| Promise<string>
|
|
5304
|
+
| object;
|
|
5293
5305
|
|
|
5294
5306
|
/**
|
|
5295
5307
|
* CSS module parser options
|
|
@@ -5787,9 +5799,15 @@ export declare interface RenderOptions {
|
|
|
5787
5799
|
src?: string;
|
|
5788
5800
|
|
|
5789
5801
|
/**
|
|
5790
|
-
*
|
|
5802
|
+
* strip comments and whitespace.
|
|
5791
5803
|
*/
|
|
5792
5804
|
minify?: boolean;
|
|
5805
|
+
|
|
5806
|
+
/**
|
|
5807
|
+
* Minify values
|
|
5808
|
+
*/
|
|
5809
|
+
minifyValues?: boolean;
|
|
5810
|
+
|
|
5793
5811
|
/**
|
|
5794
5812
|
* Pretty print css
|
|
5795
5813
|
*
|
package/dist/lib/ast/expand.js
CHANGED
|
@@ -2,7 +2,7 @@ import { splitRule } from './minify.js';
|
|
|
2
2
|
import { STATE, PARENT, combinators, RAW } from '../syntax/constants.js';
|
|
3
3
|
import { parseString } from '../parser/parse.js';
|
|
4
4
|
import { walkValues } from './walk.js';
|
|
5
|
-
import { renderValue } from '../
|
|
5
|
+
import { renderValue } from '../printer/render.js';
|
|
6
6
|
import { EnumAstNodeStatus, EnumToken } from './types.js';
|
|
7
7
|
import { cloneNode } from './clone.js';
|
|
8
8
|
|
|
@@ -8,7 +8,7 @@ import { replaceNodeOrValue } from '../../parser/utils/token.js';
|
|
|
8
8
|
class ComputeCalcExpressionFeature {
|
|
9
9
|
accept = new Set([EnumToken.RuleNodeType, EnumToken.AtRuleNodeType]);
|
|
10
10
|
get ordering() {
|
|
11
|
-
return
|
|
11
|
+
return 3;
|
|
12
12
|
}
|
|
13
13
|
get processMode() {
|
|
14
14
|
return FeatureWalkMode.Post;
|
|
@@ -33,8 +33,20 @@ class ComputeCalcExpressionFeature {
|
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
35
|
if (value.typ == EnumToken.BinaryExpressionTokenType) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const result = evaluate([value]);
|
|
37
|
+
try {
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
replaceNodeOrValue(parent, value, result);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
if (Array.isArray(parent.chi)) {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
parent.chi.length = 0;
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
parent.chi.push(...result);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
38
50
|
continue;
|
|
39
51
|
}
|
|
40
52
|
if (value != null && tokensfuncSet.has(value.typ)) {
|
|
@@ -52,7 +64,7 @@ class ComputeCalcExpressionFeature {
|
|
|
52
64
|
? value.val
|
|
53
65
|
: value.chi;
|
|
54
66
|
const values = evaluate(cp);
|
|
55
|
-
// fix a + -b
|
|
67
|
+
// fix a + -b into a - b
|
|
56
68
|
for (const { value, parent: p } of walkValues(values)) {
|
|
57
69
|
if (value.typ === EnumToken.BinaryExpressionTokenType) {
|
|
58
70
|
if (value.op === EnumToken.Add &&
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnumToken } from '../types.js';
|
|
2
|
-
import { renderValue } from '../../
|
|
2
|
+
import { renderValue } from '../../printer/render.js';
|
|
3
3
|
import { FeatureWalkMode } from './type.js';
|
|
4
4
|
import { PARENT, LOCSRCID, LOCSTA, LOCEND, TOKENS } from '../../syntax/constants.js';
|
|
5
5
|
import { equalsIgnoreCase } from '../../parser/utils/text.js';
|
|
@@ -174,7 +174,7 @@ function processNode(declarationNode, cache) {
|
|
|
174
174
|
class ExpandIfFeature {
|
|
175
175
|
accept = new Set([EnumToken.DeclarationNodeType]);
|
|
176
176
|
get ordering() {
|
|
177
|
-
return
|
|
177
|
+
return 1;
|
|
178
178
|
}
|
|
179
179
|
get processMode() {
|
|
180
180
|
return FeatureWalkMode.Pre;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnumToken } from '../types.js';
|
|
2
2
|
import { walkValues } from '../walk.js';
|
|
3
|
-
import { renderValue } from '../../
|
|
3
|
+
import { renderValue } from '../../printer/render.js';
|
|
4
4
|
import { splitRule } from '../minify.js';
|
|
5
5
|
import { FeatureWalkMode } from './type.js';
|
|
6
6
|
import { RAW, mathFuncs } from '../../syntax/constants.js';
|
|
@@ -57,10 +57,10 @@ function replace(node, variableScope) {
|
|
|
57
57
|
class InlineCssVariablesFeature {
|
|
58
58
|
accept = new Set([EnumToken.RuleNodeType, EnumToken.AtRuleNodeType]);
|
|
59
59
|
get ordering() {
|
|
60
|
-
return
|
|
60
|
+
return 2;
|
|
61
61
|
}
|
|
62
62
|
get processMode() {
|
|
63
|
-
return FeatureWalkMode.
|
|
63
|
+
return FeatureWalkMode.Post;
|
|
64
64
|
}
|
|
65
65
|
static register(options) {
|
|
66
66
|
if (options.inlineCssVariables) {
|
|
@@ -2,7 +2,7 @@ import { EnumAstNodeStatus, EnumToken } from '../types.js';
|
|
|
2
2
|
import { walkValues } from '../walk.js';
|
|
3
3
|
import { pseudoAliasMap } from '../../syntax/syntax.js';
|
|
4
4
|
import { splitRule } from '../minify.js';
|
|
5
|
-
import { renderValue } from '../../
|
|
5
|
+
import { renderValue } from '../../printer/render.js';
|
|
6
6
|
import { STATE, TOKENS, funcLike, regMatchLinearGradient, regMatchRadialGradient } from '../../syntax/constants.js';
|
|
7
7
|
import { FeatureWalkMode } from './type.js';
|
|
8
8
|
import { ValidationSyntaxGroupEnum } from '../../validation/parser/typedef.js';
|
|
@@ -109,7 +109,7 @@ function replaceAstNodes(tokens, root) {
|
|
|
109
109
|
}
|
|
110
110
|
class ComputePrefixFeature {
|
|
111
111
|
get ordering() {
|
|
112
|
-
return
|
|
112
|
+
return 0;
|
|
113
113
|
}
|
|
114
114
|
get processMode() {
|
|
115
115
|
return FeatureWalkMode.Pre;
|
|
@@ -9,7 +9,7 @@ class ComputeShorthandFeature {
|
|
|
9
9
|
EnumToken.KeyframesRuleNodeType,
|
|
10
10
|
]);
|
|
11
11
|
get ordering() {
|
|
12
|
-
return
|
|
12
|
+
return 5;
|
|
13
13
|
}
|
|
14
14
|
get processMode() {
|
|
15
15
|
return FeatureWalkMode.Post;
|
|
@@ -28,8 +28,8 @@ class ComputeShorthandFeature {
|
|
|
28
28
|
const j = ast.chi.length;
|
|
29
29
|
let k = 0;
|
|
30
30
|
let l;
|
|
31
|
-
let properties = new PropertyList(options);
|
|
32
31
|
const rules = [];
|
|
32
|
+
const declarations = [];
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
for (; k < j; k++) {
|
|
35
35
|
l = k;
|
|
@@ -47,7 +47,7 @@ class ComputeShorthandFeature {
|
|
|
47
47
|
const node = ast.chi[l];
|
|
48
48
|
if (node.typ == EnumToken.DeclarationNodeType) {
|
|
49
49
|
for (let m = k; m <= l; m++) {
|
|
50
|
-
|
|
50
|
+
declarations.push(ast.chi[m]);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
@@ -57,9 +57,11 @@ class ComputeShorthandFeature {
|
|
|
57
57
|
}
|
|
58
58
|
k = l;
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if (declarations.length > 0) {
|
|
61
|
+
ast.chi.length = 0;
|
|
62
|
+
// @ts-expect-error
|
|
63
|
+
ast.chi.push(...new PropertyList(options).add(declarations), ...rules);
|
|
64
|
+
}
|
|
63
65
|
return ast;
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnumToken, EnumAstNodeStatus } from '../types.js';
|
|
2
2
|
import { compute } from '../transform/compute.js';
|
|
3
|
-
import { filterValues, renderValue } from '../../
|
|
3
|
+
import { filterValues, renderValue } from '../../printer/render.js';
|
|
4
4
|
import { minifyTransformFunctions, eqMatrix } from '../transform/minify.js';
|
|
5
5
|
import { FeatureWalkMode } from './type.js';
|
|
6
6
|
import { STATE } from '../../syntax/constants.js';
|
|
@@ -12,7 +12,7 @@ class TransformCssFeature {
|
|
|
12
12
|
EnumToken.KeyframesRuleNodeType,
|
|
13
13
|
]);
|
|
14
14
|
get ordering() {
|
|
15
|
-
return
|
|
15
|
+
return 4;
|
|
16
16
|
}
|
|
17
17
|
get processMode() {
|
|
18
18
|
return FeatureWalkMode.Post;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { equalsIgnoreCase } from '../../parser/utils/text.js';
|
|
2
|
-
import { mathFuncs, LOCEND, LOCSTA, LOCSRCID } from '../../syntax/constants.js';
|
|
2
|
+
import { mathFuncs, PARENT, LOCEND, LOCSTA, LOCSRCID } from '../../syntax/constants.js';
|
|
3
3
|
import { EnumToken } from '../types.js';
|
|
4
4
|
import { rem, compute } from './math.js';
|
|
5
5
|
|
|
@@ -64,6 +64,7 @@ function evaluate(tokens) {
|
|
|
64
64
|
[LOCSRCID]: nodes[0][LOCSRCID],
|
|
65
65
|
[LOCSTA]: nodes[0][LOCSTA],
|
|
66
66
|
[LOCEND]: nodes[0][LOCEND],
|
|
67
|
+
[PARENT]: nodes[0][PARENT],
|
|
67
68
|
},
|
|
68
69
|
];
|
|
69
70
|
}
|
|
@@ -86,6 +87,7 @@ function evaluate(tokens) {
|
|
|
86
87
|
[LOCSRCID]: nodes[i][LOCSRCID],
|
|
87
88
|
[LOCSTA]: nodes[i][LOCSTA],
|
|
88
89
|
[LOCEND]: nodes[i + 1][LOCEND],
|
|
90
|
+
[PARENT]: nodes[i + 1][PARENT],
|
|
89
91
|
};
|
|
90
92
|
}
|
|
91
93
|
else {
|
|
@@ -95,6 +97,7 @@ function evaluate(tokens) {
|
|
|
95
97
|
[LOCSRCID]: nodes[i + 1][LOCSRCID],
|
|
96
98
|
[LOCSTA]: nodes[i + 1][LOCSTA],
|
|
97
99
|
[LOCEND]: nodes[i + 1][LOCEND],
|
|
100
|
+
[PARENT]: nodes[i + 1][PARENT],
|
|
98
101
|
}, EnumToken.Mul);
|
|
99
102
|
}
|
|
100
103
|
i++;
|
|
@@ -115,12 +118,14 @@ function evaluate(tokens) {
|
|
|
115
118
|
[LOCSRCID]: token[LOCSRCID],
|
|
116
119
|
[LOCSTA]: token[LOCSTA],
|
|
117
120
|
[LOCEND]: token[LOCEND],
|
|
121
|
+
[PARENT]: token[PARENT],
|
|
118
122
|
}, {
|
|
119
123
|
...token,
|
|
120
124
|
val: -token.val,
|
|
121
125
|
[LOCSRCID]: token[LOCSRCID],
|
|
122
126
|
[LOCSTA]: token[LOCSTA],
|
|
123
127
|
[LOCEND]: token[LOCEND],
|
|
128
|
+
[PARENT]: token[PARENT],
|
|
124
129
|
});
|
|
125
130
|
return acc;
|
|
126
131
|
}
|
|
@@ -131,6 +136,7 @@ function evaluate(tokens) {
|
|
|
131
136
|
[LOCSRCID]: token[LOCSRCID],
|
|
132
137
|
[LOCSTA]: token[LOCSTA],
|
|
133
138
|
[LOCEND]: token[LOCEND],
|
|
139
|
+
[PARENT]: token[PARENT],
|
|
134
140
|
});
|
|
135
141
|
}
|
|
136
142
|
acc.push(token);
|
|
@@ -152,6 +158,7 @@ function doEvaluate(l, r, op) {
|
|
|
152
158
|
[LOCSRCID]: l[LOCSRCID],
|
|
153
159
|
[LOCSTA]: l[LOCSTA],
|
|
154
160
|
[LOCEND]: r?.[LOCEND] ?? l[LOCEND],
|
|
161
|
+
[PARENT]: l[PARENT],
|
|
155
162
|
};
|
|
156
163
|
if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
|
|
157
164
|
return defaultReturn;
|
|
@@ -224,6 +231,7 @@ function doEvaluate(l, r, op) {
|
|
|
224
231
|
[LOCSRCID]: l[LOCSRCID],
|
|
225
232
|
[LOCSTA]: l[LOCSTA],
|
|
226
233
|
[LOCEND]: l[LOCEND],
|
|
234
|
+
[PARENT]: l[PARENT],
|
|
227
235
|
},
|
|
228
236
|
r: {
|
|
229
237
|
typ: EnumToken.NumberTokenType,
|
|
@@ -231,6 +239,7 @@ function doEvaluate(l, r, op) {
|
|
|
231
239
|
[LOCSRCID]: r[LOCSRCID],
|
|
232
240
|
[LOCSTA]: r[LOCSTA],
|
|
233
241
|
[LOCEND]: r[LOCEND],
|
|
242
|
+
[PARENT]: r[PARENT],
|
|
234
243
|
},
|
|
235
244
|
};
|
|
236
245
|
}
|
|
@@ -243,6 +252,7 @@ function doEvaluate(l, r, op) {
|
|
|
243
252
|
[LOCSRCID]: l[LOCSRCID],
|
|
244
253
|
[LOCSTA]: l[LOCSTA],
|
|
245
254
|
[LOCEND]: l[LOCEND],
|
|
255
|
+
[PARENT]: l[PARENT],
|
|
246
256
|
},
|
|
247
257
|
r: {
|
|
248
258
|
typ: EnumToken.NumberTokenType,
|
|
@@ -250,6 +260,7 @@ function doEvaluate(l, r, op) {
|
|
|
250
260
|
[LOCSRCID]: r[LOCSRCID],
|
|
251
261
|
[LOCSTA]: r[LOCSTA],
|
|
252
262
|
[LOCEND]: r[LOCEND],
|
|
263
|
+
[PARENT]: r[PARENT],
|
|
253
264
|
},
|
|
254
265
|
};
|
|
255
266
|
}
|
|
@@ -276,6 +287,7 @@ function doEvaluate(l, r, op) {
|
|
|
276
287
|
[LOCSRCID]: l[LOCSRCID],
|
|
277
288
|
[LOCSTA]: l[LOCSTA],
|
|
278
289
|
[LOCEND]: r?.[LOCEND] ?? l[LOCEND],
|
|
290
|
+
[PARENT]: l[PARENT],
|
|
279
291
|
};
|
|
280
292
|
if (token.typ == EnumToken.IdenTokenType) {
|
|
281
293
|
// @ts-ignore
|
|
@@ -456,6 +468,7 @@ function evaluateFunc(token) {
|
|
|
456
468
|
[LOCSRCID]: value[0][LOCSRCID],
|
|
457
469
|
[LOCSTA]: value[0][LOCSTA],
|
|
458
470
|
[LOCEND]: value[0][LOCEND],
|
|
471
|
+
[PARENT]: value[0][PARENT],
|
|
459
472
|
}
|
|
460
473
|
: {
|
|
461
474
|
typ: token.val == "sign" ? EnumToken.NumberTokenType : value[0].typ,
|
|
@@ -463,6 +476,7 @@ function evaluateFunc(token) {
|
|
|
463
476
|
[LOCSRCID]: value[0][LOCSRCID],
|
|
464
477
|
[LOCSTA]: value[0][LOCSTA],
|
|
465
478
|
[LOCEND]: value[0][LOCEND],
|
|
479
|
+
[PARENT]: value[0][PARENT],
|
|
466
480
|
},
|
|
467
481
|
];
|
|
468
482
|
}
|
|
@@ -485,6 +499,7 @@ function evaluateFunc(token) {
|
|
|
485
499
|
[LOCSRCID]: token[LOCSRCID],
|
|
486
500
|
[LOCSTA]: token[LOCSTA],
|
|
487
501
|
[LOCEND]: token[LOCEND],
|
|
502
|
+
[PARENT]: token[PARENT],
|
|
488
503
|
},
|
|
489
504
|
];
|
|
490
505
|
}
|
|
@@ -558,6 +573,7 @@ function evaluateFunc(token) {
|
|
|
558
573
|
[LOCSRCID]: token[LOCSRCID],
|
|
559
574
|
[LOCSTA]: token[LOCSTA],
|
|
560
575
|
[LOCEND]: token[LOCEND],
|
|
576
|
+
[PARENT]: token[PARENT],
|
|
561
577
|
},
|
|
562
578
|
];
|
|
563
579
|
}
|
|
@@ -572,6 +588,7 @@ function evaluateFunc(token) {
|
|
|
572
588
|
[LOCSRCID]: token[LOCSRCID],
|
|
573
589
|
[LOCSTA]: token[LOCSTA],
|
|
574
590
|
[LOCEND]: token[LOCEND],
|
|
591
|
+
[PARENT]: token[PARENT],
|
|
575
592
|
},
|
|
576
593
|
];
|
|
577
594
|
}
|
|
@@ -582,6 +599,7 @@ function evaluateFunc(token) {
|
|
|
582
599
|
[LOCSRCID]: token[LOCSRCID],
|
|
583
600
|
[LOCSTA]: token[LOCSTA],
|
|
584
601
|
[LOCEND]: token[LOCEND],
|
|
602
|
+
[PARENT]: token[PARENT],
|
|
585
603
|
},
|
|
586
604
|
];
|
|
587
605
|
}
|
|
@@ -621,6 +639,7 @@ function evaluateFunc(token) {
|
|
|
621
639
|
[LOCSRCID]: token[LOCSRCID],
|
|
622
640
|
[LOCSTA]: token[LOCSTA],
|
|
623
641
|
[LOCEND]: token[LOCEND],
|
|
642
|
+
[PARENT]: token[PARENT],
|
|
624
643
|
},
|
|
625
644
|
];
|
|
626
645
|
}
|
|
@@ -663,6 +682,7 @@ function evaluateFunc(token) {
|
|
|
663
682
|
[LOCSRCID]: token[LOCSRCID],
|
|
664
683
|
[LOCSTA]: token[LOCSTA],
|
|
665
684
|
[LOCEND]: token[LOCEND],
|
|
685
|
+
[PARENT]: token[PARENT],
|
|
666
686
|
},
|
|
667
687
|
];
|
|
668
688
|
}
|
|
@@ -690,6 +710,7 @@ function inlineExpression(token) {
|
|
|
690
710
|
[LOCSRCID]: token[LOCSRCID],
|
|
691
711
|
[LOCSTA]: token[LOCSTA],
|
|
692
712
|
[LOCEND]: token[LOCEND],
|
|
713
|
+
[PARENT]: token[PARENT],
|
|
693
714
|
});
|
|
694
715
|
for (const child of inlineExpression(token.r)) {
|
|
695
716
|
result.push(child);
|
|
@@ -769,6 +790,7 @@ function factorToken(token) {
|
|
|
769
790
|
[LOCSRCID]: token[LOCSRCID],
|
|
770
791
|
[LOCSTA]: token[LOCSTA],
|
|
771
792
|
[LOCEND]: token[LOCEND],
|
|
793
|
+
[PARENT]: token[PARENT],
|
|
772
794
|
};
|
|
773
795
|
// @ts-ignore
|
|
774
796
|
delete token.val;
|
|
@@ -810,6 +832,7 @@ function factor(tokens, ops) {
|
|
|
810
832
|
[LOCSRCID]: tokens[i - 1][LOCSRCID],
|
|
811
833
|
[LOCSTA]: tokens[i - 1][LOCSTA],
|
|
812
834
|
[LOCEND]: tokens[i + 1][LOCEND],
|
|
835
|
+
[PARENT]: tokens[i + 1][PARENT],
|
|
813
836
|
});
|
|
814
837
|
i--;
|
|
815
838
|
}
|
package/dist/lib/ast/minify.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { eq } from '../parser/utils/eq.js';
|
|
2
|
-
import { renderValue, doRender } from '../
|
|
2
|
+
import { renderValue, doRender } from '../printer/render.js';
|
|
3
3
|
import * as index from './features/index.js';
|
|
4
4
|
import { walkValues } from './walk.js';
|
|
5
5
|
import { EnumToken } from './types.js';
|
|
@@ -787,7 +787,8 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
|
|
|
787
787
|
previous = node;
|
|
788
788
|
nodeIndex = i;
|
|
789
789
|
}
|
|
790
|
-
|
|
790
|
+
// @ts-ignore
|
|
791
|
+
if (recursive && node != null && node.chi != null) {
|
|
791
792
|
if (node.typ == EnumToken.KeyframesAtRuleNodeType ||
|
|
792
793
|
!node.chi.some((n) => n.typ == EnumToken.DeclarationNodeType)) {
|
|
793
794
|
if (!(node.typ == EnumToken.AtRuleNodeType && node.nam != "font-face")) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { epsilon } from '../../syntax/constants.js';
|
|
2
2
|
|
|
3
|
-
const identityMatrix = new
|
|
3
|
+
const identityMatrix = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
4
4
|
function identity() {
|
|
5
5
|
return identityMatrix.slice();
|
|
6
6
|
}
|
|
@@ -16,7 +16,7 @@ function dot(point1, point2) {
|
|
|
16
16
|
return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
|
|
17
17
|
}
|
|
18
18
|
function multiply(matrixA, matrixB) {
|
|
19
|
-
const result = new
|
|
19
|
+
const result = new Float64Array(16);
|
|
20
20
|
result[0] = matrixA[0] * matrixB[0] + matrixA[4] * matrixB[1] + matrixA[8] * matrixB[2] + matrixA[12] * matrixB[3];
|
|
21
21
|
result[1] = matrixA[1] * matrixB[0] + matrixA[5] * matrixB[1] + matrixA[9] * matrixB[2] + matrixA[13] * matrixB[3];
|
|
22
22
|
result[2] = matrixA[2] * matrixB[0] + matrixA[6] * matrixB[1] + matrixA[10] * matrixB[2] + matrixA[14] * matrixB[3];
|