@tbela99/css-parser 1.5.0 → 1.6.1
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 +59 -0
- package/README.md +10 -10
- package/dist/index-umd-web.js +5998 -4972
- package/dist/index.cjs +6001 -4977
- package/dist/index.d.ts +52 -38
- package/dist/lib/ast/expand.js +21 -7
- package/dist/lib/ast/features/calc.js +17 -55
- package/dist/lib/ast/features/if.js +7 -3
- package/dist/lib/ast/features/inlinecssvariables.js +6 -5
- package/dist/lib/ast/features/prefix.js +41 -44
- package/dist/lib/ast/features/shorthand.js +10 -5
- package/dist/lib/ast/features/transform.js +2 -2
- package/dist/lib/ast/math/expression.js +207 -34
- package/dist/lib/ast/minify.js +121 -24
- package/dist/lib/ast/node.js +5 -3
- package/dist/lib/ast/transform/compute.js +37 -5
- package/dist/lib/ast/transform/minify.js +7 -7
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.js +1 -1
- package/dist/lib/ast/transform/scale.js +1 -1
- package/dist/lib/ast/transform/skew.js +1 -1
- package/dist/lib/ast/transform/translate.js +1 -1
- package/dist/lib/ast/transform/utils.js +46 -18
- package/dist/lib/ast/walk.js +28 -4
- package/dist/{config.json.js → lib/data/properties.json.js} +106 -0
- package/dist/lib/{validation/config.json.js → data/validation.json.js} +14 -8
- package/dist/lib/fs/resolve.js +11 -2
- package/dist/lib/parser/declaration/list.js +22 -7
- package/dist/lib/parser/declaration/map.js +26 -8
- package/dist/lib/parser/declaration/set.js +3 -1
- package/dist/lib/parser/linesmap.js +2 -4
- package/dist/lib/parser/parse.js +393 -231
- package/dist/lib/parser/tokenize.js +1478 -819
- package/dist/lib/parser/utils/at-rule-container.js +28 -196
- package/dist/lib/parser/utils/at-rule-generic.js +6 -7
- package/dist/lib/parser/utils/at-rule-import.js +17 -13
- package/dist/lib/parser/utils/at-rule-media.js +36 -19
- package/dist/lib/parser/utils/at-rule-support.js +19 -9
- package/dist/lib/parser/utils/at-rule-when-else.js +11 -38
- package/dist/lib/parser/utils/at-rule.js +0 -18
- package/dist/lib/parser/utils/config.js +1 -1
- package/dist/lib/parser/utils/declaration.js +40 -97
- package/dist/lib/parser/utils/hash.js +4 -4
- package/dist/lib/parser/utils/selector.js +179 -224
- package/dist/lib/parser/utils/text.js +4 -2
- package/dist/lib/renderer/render.js +104 -74
- package/dist/lib/renderer/sourcemap/lib/codec.js +3 -3
- package/dist/lib/renderer/sourcemap/sourcemap.js +2 -5
- package/dist/lib/syntax/color/a98rgb.js +14 -4
- package/dist/lib/syntax/color/cmyk.js +14 -21
- package/dist/lib/syntax/color/color-mix.js +21 -34
- package/dist/lib/syntax/color/color.js +32 -49
- package/dist/lib/syntax/color/hsl.js +15 -15
- package/dist/lib/syntax/color/hwb.js +18 -17
- package/dist/lib/syntax/color/lab.js +17 -17
- package/dist/lib/syntax/color/lch.js +13 -13
- package/dist/lib/syntax/color/oklab.js +10 -11
- package/dist/lib/syntax/color/oklch.js +15 -18
- package/dist/lib/syntax/color/p3.js +18 -12
- package/dist/lib/syntax/color/prophotorgb.js +26 -28
- package/dist/lib/syntax/color/rec2020.js +8 -4
- package/dist/lib/syntax/color/relative-color.js +26 -10
- package/dist/lib/syntax/color/srgb.js +9 -7
- package/dist/lib/syntax/color/utils/distance.js +1 -1
- package/dist/lib/syntax/color/xyz.js +2 -2
- package/dist/lib/syntax/color/xyzd50.js +2 -2
- package/dist/lib/syntax/constants.js +13 -3
- package/dist/lib/syntax/syntax.js +32 -108
- package/dist/lib/validation/config.js +1 -1
- package/dist/lib/validation/match.js +29 -26
- package/dist/lib/validation/parser/parse.js +7 -3
- package/dist/node.js +16 -9
- package/dist/types.d.ts +5 -1
- package/dist/types.js +4 -0
- package/dist/utils/sync.js +22 -1
- package/dist/web.js +13 -4
- package/package.json +4 -4
- package/llms.txt +0 -80
package/dist/lib/ast/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TOKENS, ERRORS, STATE,
|
|
1
|
+
import { TOKENS, ERRORS, STATE, LOCSRCID, LOCSTA, LOCEND, PARENT } from '../syntax/constants.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -11,7 +11,7 @@ function getNodeProperty(node, key) {
|
|
|
11
11
|
case "parent":
|
|
12
12
|
return node[PARENT];
|
|
13
13
|
case "location":
|
|
14
|
-
return node[
|
|
14
|
+
return node[LOCSRCID] == null && node[LOCSTA] == null && node[LOCEND] == null ? null : { srcId: node[LOCSRCID], sta: node[LOCSTA], end: node[LOCEND] };
|
|
15
15
|
case "state":
|
|
16
16
|
return node[STATE];
|
|
17
17
|
case "errors":
|
|
@@ -33,7 +33,9 @@ function setNodeProperty(node, key, value) {
|
|
|
33
33
|
node[PARENT] = value;
|
|
34
34
|
break;
|
|
35
35
|
case "location":
|
|
36
|
-
node[
|
|
36
|
+
node[LOCSRCID] = value.srcId;
|
|
37
|
+
node[LOCSTA] = value.sta;
|
|
38
|
+
node[LOCEND] = value.end;
|
|
37
39
|
break;
|
|
38
40
|
case "state":
|
|
39
41
|
node[STATE] = value;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { multiply, toZero
|
|
1
|
+
import { identity, multiply, toZero } from './utils.js';
|
|
2
2
|
import { EnumToken } from '../types.js';
|
|
3
3
|
import { stripCommaToken } from '../../validation/utils/list.js';
|
|
4
4
|
import { translateX, translateY, translateZ, translate, translate3d } from './translate.js';
|
|
@@ -17,14 +17,45 @@ function compute(transformLists) {
|
|
|
17
17
|
stripCommaToken(transformLists);
|
|
18
18
|
let matrix = identity();
|
|
19
19
|
let mat;
|
|
20
|
+
let transforms;
|
|
21
|
+
let shouldComputeMatrix = true;
|
|
20
22
|
const cumulative = [];
|
|
23
|
+
// all transform function arguments must be 0 or scale(1)
|
|
24
|
+
for (const transform of transformLists) {
|
|
25
|
+
switch (transform.val) {
|
|
26
|
+
case "rotate":
|
|
27
|
+
case "rotateX":
|
|
28
|
+
case "rotateY":
|
|
29
|
+
case "rotateZ":
|
|
30
|
+
case "rotate3d":
|
|
31
|
+
for (const child of transform.chi) {
|
|
32
|
+
if (child.typ == EnumToken.WhitespaceTokenType || child.typ == EnumToken.CommaTokenType) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if ((child.typ != EnumToken.AngleTokenType &&
|
|
36
|
+
child.typ != EnumToken.NumberTokenType &&
|
|
37
|
+
child.typ != EnumToken.PercentageTokenType) ||
|
|
38
|
+
// angle >= 360deg, do not transform
|
|
39
|
+
Math.abs(getAngle(child)) >= 1) {
|
|
40
|
+
shouldComputeMatrix = false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
if (!shouldComputeMatrix) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
21
49
|
for (const transformList of splitTransformList(transformLists)) {
|
|
22
|
-
mat = computeMatrix(transformList, identity());
|
|
50
|
+
mat = shouldComputeMatrix ? computeMatrix(transformList, identity()) : null;
|
|
23
51
|
if (mat == null) {
|
|
24
52
|
return null;
|
|
25
53
|
}
|
|
26
54
|
matrix = multiply(matrix, mat);
|
|
27
|
-
|
|
55
|
+
transforms = minify(mat) ?? transformList;
|
|
56
|
+
for (let i = 0; i < transforms.length; i++) {
|
|
57
|
+
cumulative.push(transforms[i]);
|
|
58
|
+
}
|
|
28
59
|
}
|
|
29
60
|
const serialized = serialize(matrix);
|
|
30
61
|
if (cumulative.length > 0) {
|
|
@@ -40,11 +71,12 @@ function compute(transformLists) {
|
|
|
40
71
|
});
|
|
41
72
|
}
|
|
42
73
|
}
|
|
43
|
-
|
|
74
|
+
const result = {
|
|
44
75
|
matrix: serialize(toZero(matrix)),
|
|
45
76
|
cumulative,
|
|
46
77
|
minified: minify(matrix) ?? [serialized],
|
|
47
78
|
};
|
|
79
|
+
return result;
|
|
48
80
|
}
|
|
49
81
|
function computeMatrix(transformList, matrixVar) {
|
|
50
82
|
let values = [];
|
|
@@ -166,7 +198,7 @@ function computeMatrix(transformList, matrixVar) {
|
|
|
166
198
|
if (values.length != 3) {
|
|
167
199
|
return null;
|
|
168
200
|
}
|
|
169
|
-
matrixVar = scale3d(
|
|
201
|
+
matrixVar = scale3d(values[0], values[1], values[2], matrixVar);
|
|
170
202
|
break;
|
|
171
203
|
}
|
|
172
204
|
if (transformList[i].val == "scale") {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { multiply, decompose, round, toZero
|
|
1
|
+
import { identity, multiply, decompose, round, toZero } from './utils.js';
|
|
2
2
|
import { epsilon } from '../../syntax/constants.js';
|
|
3
3
|
import { EnumToken } from '../types.js';
|
|
4
4
|
import { computeMatrix } from './compute.js';
|
|
@@ -245,7 +245,7 @@ function minify(matrix) {
|
|
|
245
245
|
function eqMatrix(a, b) {
|
|
246
246
|
let mat = identity();
|
|
247
247
|
let tmp = identity();
|
|
248
|
-
const data = (Array.isArray(a) ? a : parseMatrix(a));
|
|
248
|
+
const data = (Array.isArray(a) || ArrayBuffer.isView(a) ? a : parseMatrix(a));
|
|
249
249
|
for (const transform of b) {
|
|
250
250
|
tmp = computeMatrix([transform], identity());
|
|
251
251
|
if (tmp == null) {
|
|
@@ -266,8 +266,8 @@ function eqMatrix(a, b) {
|
|
|
266
266
|
return true;
|
|
267
267
|
}
|
|
268
268
|
function minifyTransformFunctions(transform) {
|
|
269
|
-
const name = transform.val
|
|
270
|
-
if ("
|
|
269
|
+
const name = transform.val;
|
|
270
|
+
if ("skewX" == name) {
|
|
271
271
|
transform.val = "skew";
|
|
272
272
|
return transform;
|
|
273
273
|
}
|
|
@@ -307,10 +307,10 @@ function minifyTransformFunctions(transform) {
|
|
|
307
307
|
}
|
|
308
308
|
const ignoredValue = name.startsWith("scale") ? 1 : 0;
|
|
309
309
|
const t = new Set(["x", "y", "z"]);
|
|
310
|
-
let i = 3;
|
|
311
|
-
|
|
310
|
+
for (let i = 0; i < 3; i++) {
|
|
311
|
+
const axis = i == 0 ? "x" : i == 1 ? "y" : "z";
|
|
312
312
|
if (values.length <= i || values[i].val == ignoredValue) {
|
|
313
|
-
t.delete(
|
|
313
|
+
t.delete(axis);
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
if (name == "translate3d" || name == "translate") {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { epsilon } from '../../syntax/constants.js';
|
|
2
2
|
|
|
3
|
+
const identityMatrix = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
3
4
|
function identity() {
|
|
4
|
-
return
|
|
5
|
+
return identityMatrix.slice();
|
|
5
6
|
}
|
|
6
7
|
function normalize(point) {
|
|
7
8
|
const [x, y, z] = point;
|
|
@@ -15,37 +16,64 @@ function dot(point1, point2) {
|
|
|
15
16
|
return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
|
|
16
17
|
}
|
|
17
18
|
function multiply(matrixA, matrixB) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const result = new Float32Array(16);
|
|
20
|
+
result[0] = matrixA[0] * matrixB[0] + matrixA[4] * matrixB[1] + matrixA[8] * matrixB[2] + matrixA[12] * matrixB[3];
|
|
21
|
+
result[1] = matrixA[1] * matrixB[0] + matrixA[5] * matrixB[1] + matrixA[9] * matrixB[2] + matrixA[13] * matrixB[3];
|
|
22
|
+
result[2] = matrixA[2] * matrixB[0] + matrixA[6] * matrixB[1] + matrixA[10] * matrixB[2] + matrixA[14] * matrixB[3];
|
|
23
|
+
result[3] = matrixA[3] * matrixB[0] + matrixA[7] * matrixB[1] + matrixA[11] * matrixB[2] + matrixA[15] * matrixB[3];
|
|
24
|
+
result[4] = matrixA[0] * matrixB[4] + matrixA[4] * matrixB[5] + matrixA[8] * matrixB[6] + matrixA[12] * matrixB[7];
|
|
25
|
+
result[5] = matrixA[1] * matrixB[4] + matrixA[5] * matrixB[5] + matrixA[9] * matrixB[6] + matrixA[13] * matrixB[7];
|
|
26
|
+
result[6] = matrixA[2] * matrixB[4] + matrixA[6] * matrixB[5] + matrixA[10] * matrixB[6] + matrixA[14] * matrixB[7];
|
|
27
|
+
result[7] = matrixA[3] * matrixB[4] + matrixA[7] * matrixB[5] + matrixA[11] * matrixB[6] + matrixA[15] * matrixB[7];
|
|
28
|
+
result[8] =
|
|
29
|
+
matrixA[0] * matrixB[8] + matrixA[4] * matrixB[9] + matrixA[8] * matrixB[10] + matrixA[12] * matrixB[11];
|
|
30
|
+
result[9] =
|
|
31
|
+
matrixA[1] * matrixB[8] + matrixA[5] * matrixB[9] + matrixA[9] * matrixB[10] + matrixA[13] * matrixB[11];
|
|
32
|
+
result[10] =
|
|
33
|
+
matrixA[2] * matrixB[8] + matrixA[6] * matrixB[9] + matrixA[10] * matrixB[10] + matrixA[14] * matrixB[11];
|
|
34
|
+
result[11] =
|
|
35
|
+
matrixA[3] * matrixB[8] + matrixA[7] * matrixB[9] + matrixA[11] * matrixB[10] + matrixA[15] * matrixB[11];
|
|
36
|
+
result[12] =
|
|
37
|
+
matrixA[0] * matrixB[12] + matrixA[4] * matrixB[13] + matrixA[8] * matrixB[14] + matrixA[12] * matrixB[15];
|
|
38
|
+
result[13] =
|
|
39
|
+
matrixA[1] * matrixB[12] + matrixA[5] * matrixB[13] + matrixA[9] * matrixB[14] + matrixA[13] * matrixB[15];
|
|
40
|
+
result[14] =
|
|
41
|
+
matrixA[2] * matrixB[12] + matrixA[6] * matrixB[13] + matrixA[10] * matrixB[14] + matrixA[14] * matrixB[15];
|
|
42
|
+
result[15] =
|
|
43
|
+
matrixA[3] * matrixB[12] + matrixA[7] * matrixB[13] + matrixA[11] * matrixB[14] + matrixA[15] * matrixB[15];
|
|
28
44
|
return result;
|
|
29
45
|
}
|
|
30
46
|
function inverse(matrix) {
|
|
31
47
|
// Create augmented matrix [matrix | identity]
|
|
32
48
|
let augmented = [
|
|
33
|
-
|
|
49
|
+
matrix[0],
|
|
50
|
+
matrix[1],
|
|
51
|
+
matrix[2],
|
|
52
|
+
matrix[3],
|
|
34
53
|
1,
|
|
35
54
|
0,
|
|
36
55
|
0,
|
|
37
56
|
0,
|
|
38
|
-
|
|
57
|
+
matrix[4],
|
|
58
|
+
matrix[5],
|
|
59
|
+
matrix[6],
|
|
60
|
+
matrix[7],
|
|
39
61
|
0,
|
|
40
62
|
1,
|
|
41
63
|
0,
|
|
42
64
|
0,
|
|
43
|
-
|
|
65
|
+
matrix[8],
|
|
66
|
+
matrix[9],
|
|
67
|
+
matrix[10],
|
|
68
|
+
matrix[11],
|
|
44
69
|
0,
|
|
45
70
|
0,
|
|
46
71
|
1,
|
|
47
72
|
0,
|
|
48
|
-
|
|
73
|
+
matrix[12],
|
|
74
|
+
matrix[13],
|
|
75
|
+
matrix[14],
|
|
76
|
+
matrix[15],
|
|
49
77
|
0,
|
|
50
78
|
0,
|
|
51
79
|
0,
|
|
@@ -141,11 +169,11 @@ function decompose(original) {
|
|
|
141
169
|
row1[0] * row2[1] - row1[1] * row2[0],
|
|
142
170
|
];
|
|
143
171
|
// Compute scale
|
|
144
|
-
const scaleX = Math.hypot(
|
|
172
|
+
const scaleX = Math.hypot(row0[0], row0[1], row0[2]);
|
|
145
173
|
const row0Norm = normalize(row0);
|
|
146
174
|
const skewXY = dot(row0Norm, row1);
|
|
147
175
|
const row1Proj = [row1[0] - skewXY * row0Norm[0], row1[1] - skewXY * row0Norm[1], row1[2] - skewXY * row0Norm[2]];
|
|
148
|
-
const scaleY = Math.hypot(
|
|
176
|
+
const scaleY = Math.hypot(row1Proj[0], row1Proj[1], row1Proj[2]);
|
|
149
177
|
const row1Norm = normalize(row1Proj);
|
|
150
178
|
const skewXZ = dot(row0Norm, row2);
|
|
151
179
|
const skewYZ = dot(row1Norm, row2);
|
|
@@ -156,7 +184,7 @@ function decompose(original) {
|
|
|
156
184
|
];
|
|
157
185
|
const row2Norm = normalize(row2Proj);
|
|
158
186
|
const determinant = row0[0] * cross[0] + row0[1] * cross[1] + row0[2] * cross[2];
|
|
159
|
-
const scaleZ = Math.hypot(
|
|
187
|
+
const scaleZ = Math.hypot(row2Proj[0], row2Proj[1], row2Proj[2]) * (determinant < 0 ? -1 : 1);
|
|
160
188
|
// Build rotation matrix from orthonormalized vectors
|
|
161
189
|
const r00 = row0Norm[0], r01 = row1Norm[0], r02 = row2Norm[0];
|
|
162
190
|
const r10 = row0Norm[1], r11 = row1Norm[1], r12 = row2Norm[1];
|
package/dist/lib/ast/walk.js
CHANGED
|
@@ -259,6 +259,7 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
259
259
|
(Array.isArray(filter.type) && filter.type.includes(value.typ)) ||
|
|
260
260
|
(typeof filter.type == "function" && filter.type(value));
|
|
261
261
|
if (isValid) {
|
|
262
|
+
// @ts-ignore
|
|
262
263
|
option = filter.fn(value, map.get(value) ?? root, WalkerEvent.Enter,
|
|
263
264
|
// @ts-expect-error
|
|
264
265
|
function* () {
|
|
@@ -281,8 +282,13 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
281
282
|
const op = Array.isArray(option) ? option : [option];
|
|
282
283
|
for (const o of op) {
|
|
283
284
|
map.set(o, map.get(value) ?? root);
|
|
285
|
+
if (reverse) {
|
|
286
|
+
stack.unshift(o);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
stack.push(o);
|
|
290
|
+
}
|
|
284
291
|
}
|
|
285
|
-
stack[reverse ? "push" : "unshift"](...op);
|
|
286
292
|
}
|
|
287
293
|
}
|
|
288
294
|
}
|
|
@@ -313,8 +319,13 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
313
319
|
const sliced = value.chi.slice();
|
|
314
320
|
for (const child of sliced) {
|
|
315
321
|
map.set(child, value);
|
|
322
|
+
if (reverse) {
|
|
323
|
+
stack.unshift(child);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
stack.push(child);
|
|
327
|
+
}
|
|
316
328
|
}
|
|
317
|
-
stack[reverse ? "push" : "unshift"](...sliced);
|
|
318
329
|
}
|
|
319
330
|
else {
|
|
320
331
|
const values = [];
|
|
@@ -347,7 +358,14 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
347
358
|
}
|
|
348
359
|
}
|
|
349
360
|
if (values.length > 0) {
|
|
350
|
-
|
|
361
|
+
for (const v of values) {
|
|
362
|
+
if (reverse) {
|
|
363
|
+
stack.unshift(v);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
stack.push(v);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
351
369
|
}
|
|
352
370
|
}
|
|
353
371
|
}
|
|
@@ -357,14 +375,20 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
357
375
|
(Array.isArray(filter.type) && filter.type.includes(value.typ)) ||
|
|
358
376
|
(typeof filter.type == "function" && filter.type(value));
|
|
359
377
|
if (isValid) {
|
|
378
|
+
// @ts-ignore
|
|
360
379
|
option = filter.fn(value, map.get(value), WalkerEvent.Leave);
|
|
361
380
|
// @ts-ignore
|
|
362
381
|
if (option != null && ("typ" in option || Array.isArray(option))) {
|
|
363
382
|
const op = Array.isArray(option) ? option : [option];
|
|
364
383
|
for (const o of op) {
|
|
365
384
|
map.set(o, map.get(value) ?? root);
|
|
385
|
+
if (reverse) {
|
|
386
|
+
stack.unshift(o);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
stack.push(o);
|
|
390
|
+
}
|
|
366
391
|
}
|
|
367
|
-
stack[reverse ? "push" : "unshift"](...op);
|
|
368
392
|
}
|
|
369
393
|
}
|
|
370
394
|
}
|
|
@@ -108,6 +108,65 @@ var properties = {
|
|
|
108
108
|
"padding-left": {
|
|
109
109
|
shorthand: "padding"
|
|
110
110
|
},
|
|
111
|
+
"scroll-margin": {
|
|
112
|
+
shorthand: "scroll-margin",
|
|
113
|
+
properties: [
|
|
114
|
+
"scroll-margin-top",
|
|
115
|
+
"scroll-margin-right",
|
|
116
|
+
"scroll-margin-bottom",
|
|
117
|
+
"scroll-margin-left"
|
|
118
|
+
],
|
|
119
|
+
types: [
|
|
120
|
+
"Length",
|
|
121
|
+
"Perc"
|
|
122
|
+
],
|
|
123
|
+
"default": [
|
|
124
|
+
"0"
|
|
125
|
+
],
|
|
126
|
+
keywords: [
|
|
127
|
+
"auto"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"scroll-margin-top": {
|
|
131
|
+
shorthand: "scroll-margin"
|
|
132
|
+
},
|
|
133
|
+
"scroll-margin-right": {
|
|
134
|
+
shorthand: "scroll-margin"
|
|
135
|
+
},
|
|
136
|
+
"scroll-margin-bottom": {
|
|
137
|
+
shorthand: "scroll-margin"
|
|
138
|
+
},
|
|
139
|
+
"scroll-margin-left": {
|
|
140
|
+
shorthand: "scroll-margin"
|
|
141
|
+
},
|
|
142
|
+
"scroll-padding": {
|
|
143
|
+
shorthand: "scroll-padding",
|
|
144
|
+
properties: [
|
|
145
|
+
"scroll-padding-top",
|
|
146
|
+
"scroll-padding-right",
|
|
147
|
+
"scroll-padding-bottom",
|
|
148
|
+
"scroll-padding-left"
|
|
149
|
+
],
|
|
150
|
+
types: [
|
|
151
|
+
"Length",
|
|
152
|
+
"Perc"
|
|
153
|
+
],
|
|
154
|
+
keywords: [
|
|
155
|
+
"auto"
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
"scroll-padding-top": {
|
|
159
|
+
shorthand: "scroll-padding"
|
|
160
|
+
},
|
|
161
|
+
"scroll-padding-right": {
|
|
162
|
+
shorthand: "scroll-padding"
|
|
163
|
+
},
|
|
164
|
+
"scroll-padding-bottom": {
|
|
165
|
+
shorthand: "scroll-padding"
|
|
166
|
+
},
|
|
167
|
+
"scroll-padding-left": {
|
|
168
|
+
shorthand: "scroll-padding"
|
|
169
|
+
},
|
|
111
170
|
"border-radius": {
|
|
112
171
|
shorthand: "border-radius",
|
|
113
172
|
properties: [
|
|
@@ -329,6 +388,53 @@ var map = {
|
|
|
329
388
|
"flex-wrap": {
|
|
330
389
|
shorthand: "flex-flow"
|
|
331
390
|
},
|
|
391
|
+
"scroll-timeline": {
|
|
392
|
+
shorthand: "scroll-timeline",
|
|
393
|
+
pattern: "scroll-timeline-name scroll-timeline-axis",
|
|
394
|
+
keywords: [
|
|
395
|
+
"none",
|
|
396
|
+
"block",
|
|
397
|
+
"inline",
|
|
398
|
+
"x",
|
|
399
|
+
"y"
|
|
400
|
+
],
|
|
401
|
+
"default": [
|
|
402
|
+
"none",
|
|
403
|
+
"block"
|
|
404
|
+
],
|
|
405
|
+
properties: {
|
|
406
|
+
"scroll-timeline-name": {
|
|
407
|
+
keywords: [
|
|
408
|
+
"none"
|
|
409
|
+
],
|
|
410
|
+
"default": [
|
|
411
|
+
"none"
|
|
412
|
+
],
|
|
413
|
+
types: [
|
|
414
|
+
"DashedIden"
|
|
415
|
+
]
|
|
416
|
+
},
|
|
417
|
+
"scroll-timeline-axis": {
|
|
418
|
+
keywords: [
|
|
419
|
+
"block",
|
|
420
|
+
"inline",
|
|
421
|
+
"x",
|
|
422
|
+
"y"
|
|
423
|
+
],
|
|
424
|
+
"default": [
|
|
425
|
+
"block"
|
|
426
|
+
],
|
|
427
|
+
types: [
|
|
428
|
+
]
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
"scroll-timeline-name": {
|
|
433
|
+
shorthand: "scroll-timeline"
|
|
434
|
+
},
|
|
435
|
+
"scroll-timeline-axis": {
|
|
436
|
+
shorthand: "scroll-timeline"
|
|
437
|
+
},
|
|
332
438
|
container: {
|
|
333
439
|
shorthand: "container",
|
|
334
440
|
pattern: "container-name container-type",
|
|
@@ -1584,7 +1584,7 @@ var declarations = {
|
|
|
1584
1584
|
syntax: "none | nearest"
|
|
1585
1585
|
},
|
|
1586
1586
|
"scroll-margin": {
|
|
1587
|
-
syntax: "<length>{1,4}"
|
|
1587
|
+
syntax: " <length>{1,4}"
|
|
1588
1588
|
},
|
|
1589
1589
|
"scroll-margin-block": {
|
|
1590
1590
|
syntax: "<length>{1,2}"
|
|
@@ -1596,7 +1596,7 @@ var declarations = {
|
|
|
1596
1596
|
syntax: "<length>"
|
|
1597
1597
|
},
|
|
1598
1598
|
"scroll-margin-bottom": {
|
|
1599
|
-
syntax: "<length>"
|
|
1599
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
1600
1600
|
},
|
|
1601
1601
|
"scroll-margin-inline": {
|
|
1602
1602
|
syntax: "<length>{1,2}"
|
|
@@ -1608,13 +1608,13 @@ var declarations = {
|
|
|
1608
1608
|
syntax: "<length>"
|
|
1609
1609
|
},
|
|
1610
1610
|
"scroll-margin-left": {
|
|
1611
|
-
syntax: "<length>"
|
|
1611
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
1612
1612
|
},
|
|
1613
1613
|
"scroll-margin-right": {
|
|
1614
|
-
syntax: "<length>"
|
|
1614
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
1615
1615
|
},
|
|
1616
1616
|
"scroll-margin-top": {
|
|
1617
|
-
syntax: "<length>"
|
|
1617
|
+
syntax: " auto | <length-percentage [0,∞]>"
|
|
1618
1618
|
},
|
|
1619
1619
|
"scroll-marker-group": {
|
|
1620
1620
|
syntax: "none | before | after"
|
|
@@ -1683,13 +1683,13 @@ var declarations = {
|
|
|
1683
1683
|
syntax: "none | auto"
|
|
1684
1684
|
},
|
|
1685
1685
|
"scroll-timeline": {
|
|
1686
|
-
syntax: "[ <'scroll-timeline-name'> <'scroll-timeline-axis'>? ]#"
|
|
1686
|
+
syntax: " [ <'scroll-timeline-name'> <'scroll-timeline-axis'>? ]#"
|
|
1687
1687
|
},
|
|
1688
1688
|
"scroll-timeline-axis": {
|
|
1689
|
-
syntax: "[ block | inline | x | y ]#"
|
|
1689
|
+
syntax: " [ block | inline | x | y ]#"
|
|
1690
1690
|
},
|
|
1691
1691
|
"scroll-timeline-name": {
|
|
1692
|
-
syntax: "[ none | <dashed-ident> ]#"
|
|
1692
|
+
syntax: " [ none | <dashed-ident> ]#"
|
|
1693
1693
|
},
|
|
1694
1694
|
"scrollbar-color": {
|
|
1695
1695
|
syntax: "auto | <color>{2}"
|
|
@@ -1814,6 +1814,9 @@ var declarations = {
|
|
|
1814
1814
|
"text-emphasis-style": {
|
|
1815
1815
|
syntax: "none | [ [ filled | open ] || [ dot | circle | double-circle | triangle | sesame ] ] | <string>"
|
|
1816
1816
|
},
|
|
1817
|
+
"text-fit": {
|
|
1818
|
+
syntax: "[ none | grow | shrink ] [consistent | per-line | per-line-all]? <percentage>?"
|
|
1819
|
+
},
|
|
1817
1820
|
"text-indent": {
|
|
1818
1821
|
syntax: "<length-percentage> && hanging? && each-line?"
|
|
1819
1822
|
},
|
|
@@ -2179,6 +2182,9 @@ var functions = {
|
|
|
2179
2182
|
acos: {
|
|
2180
2183
|
syntax: "acos( <calc-sum> )"
|
|
2181
2184
|
},
|
|
2185
|
+
alpha: {
|
|
2186
|
+
syntax: "alpha( from <color> / [ <alpha-value> | none ] )"
|
|
2187
|
+
},
|
|
2182
2188
|
anchor: {
|
|
2183
2189
|
syntax: "anchor( <anchor-name>? && <anchor-side>, <length-percentage>? )"
|
|
2184
2190
|
},
|
package/dist/lib/fs/resolve.js
CHANGED
|
@@ -4,6 +4,7 @@ import { memoize } from '../parser/utils/cache.js';
|
|
|
4
4
|
* match url
|
|
5
5
|
*/
|
|
6
6
|
const matchUrl = /^(https?:)?\/\//;
|
|
7
|
+
const windowsPathnameRegexp = /^\/?[a-zA-Z]:/;
|
|
7
8
|
/**
|
|
8
9
|
* return the directory name of a path
|
|
9
10
|
* @param path
|
|
@@ -76,6 +77,9 @@ const normalize = memoize(function (path) {
|
|
|
76
77
|
if (path.includes("\\")) {
|
|
77
78
|
path = path.replace(/(\\)/g, "/");
|
|
78
79
|
}
|
|
80
|
+
if (windowsPathnameRegexp.test(path)) {
|
|
81
|
+
path = path.replace(windowsPathnameRegexp, "");
|
|
82
|
+
}
|
|
79
83
|
for (; i < path.length; i++) {
|
|
80
84
|
const chr = path.charAt(i);
|
|
81
85
|
if (chr == "/") {
|
|
@@ -148,8 +152,13 @@ const resolve = memoize(function (url, currentDirectory, cwd) {
|
|
|
148
152
|
if (currentDirectory !== "") {
|
|
149
153
|
currentDirectory = normalize(currentDirectory);
|
|
150
154
|
}
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
let dir = cwd || currentDirectory;
|
|
156
|
+
if (windowsPathnameRegexp.test(dir)) {
|
|
157
|
+
dir = dir.replace(windowsPathnameRegexp, "");
|
|
158
|
+
}
|
|
159
|
+
const absolute = dir == "" || url.startsWith("/") || url.startsWith(dir) || windowsPathnameRegexp.test(url)
|
|
160
|
+
? resolvePath(url)
|
|
161
|
+
: resolvePath(dir, url);
|
|
153
162
|
return {
|
|
154
163
|
absolute,
|
|
155
164
|
relative: dir === "" ? absolute : diff(absolute, dir),
|
|
@@ -8,11 +8,13 @@ import { ValidationSyntaxGroupEnum } from '../../validation/parser/typedef.js';
|
|
|
8
8
|
import { matchAllSyntaxes, createValidationContext } from '../../validation/match.js';
|
|
9
9
|
import { STATE } from '../../syntax/constants.js';
|
|
10
10
|
import { objectHash } from '../utils/hash.js';
|
|
11
|
+
import { equalsIgnoreCase } from '../utils/text.js';
|
|
11
12
|
|
|
12
13
|
const config = getConfig();
|
|
13
14
|
class PropertyList {
|
|
14
15
|
options = { removeDuplicateDeclarations: true, computeShorthand: true };
|
|
15
16
|
declarations;
|
|
17
|
+
// ketsey = new Map;
|
|
16
18
|
constructor(options = {}) {
|
|
17
19
|
this.options = options;
|
|
18
20
|
this.declarations = new Map();
|
|
@@ -29,15 +31,12 @@ class PropertyList {
|
|
|
29
31
|
let syntaxRules = null;
|
|
30
32
|
let result;
|
|
31
33
|
for (const declaration of declarations) {
|
|
32
|
-
name =
|
|
33
|
-
declaration.typ != EnumToken.DeclarationNodeType
|
|
34
|
-
? null
|
|
35
|
-
: declaration.nam.toLowerCase();
|
|
34
|
+
name = declaration.typ != EnumToken.DeclarationNodeType ? null : declaration.nam;
|
|
36
35
|
if (declaration[STATE] == EnumAstNodeStatus.Invalid ||
|
|
37
36
|
declaration[STATE] == EnumAstNodeStatus.Unknown ||
|
|
38
37
|
declaration[STATE] == EnumAstNodeStatus.ValidationFailed ||
|
|
39
38
|
declaration.typ != EnumToken.DeclarationNodeType ||
|
|
40
|
-
"composes"
|
|
39
|
+
equalsIgnoreCase("composes", name) ||
|
|
41
40
|
(typeof this.options.removeDuplicateDeclarations === "string" &&
|
|
42
41
|
this.options.removeDuplicateDeclarations === name) ||
|
|
43
42
|
(Array.isArray(this.options.removeDuplicateDeclarations)
|
|
@@ -65,7 +64,21 @@ class PropertyList {
|
|
|
65
64
|
}
|
|
66
65
|
// do not compute shorthand for invalid declarations
|
|
67
66
|
if (declaration[STATE] !== EnumAstNodeStatus.Validated) {
|
|
68
|
-
|
|
67
|
+
// const key = objectHash(declaration);
|
|
68
|
+
// if (!this.ketsey.has(key)) {
|
|
69
|
+
// this.ketsey.set(key, [declaration.nam]);
|
|
70
|
+
// console.error(
|
|
71
|
+
// `Adding declaration : ${(<AstDeclaration>declaration).nam} with key : ${key}`
|
|
72
|
+
// )
|
|
73
|
+
// }
|
|
74
|
+
// else {
|
|
75
|
+
// console.error(
|
|
76
|
+
// `Duplicate declaration found: ${(<AstDeclaration>declaration).nam} with key : [ ${key} => ${this.ketsey.get(key)} ]`
|
|
77
|
+
// )
|
|
78
|
+
// console.error(JSON.stringify(toSortedString(declaration)))
|
|
79
|
+
// this.ketsey.get(key).push(declaration.nam);
|
|
80
|
+
// }
|
|
81
|
+
this.declarations.set(objectHash(declaration), declaration);
|
|
69
82
|
return this;
|
|
70
83
|
}
|
|
71
84
|
let propertyName = declaration.nam;
|
|
@@ -181,7 +194,9 @@ class PropertyList {
|
|
|
181
194
|
}
|
|
182
195
|
if (values != declaration.val) {
|
|
183
196
|
declaration.val.length = 0;
|
|
184
|
-
|
|
197
|
+
for (const v of values) {
|
|
198
|
+
declaration.val.push(v);
|
|
199
|
+
}
|
|
185
200
|
}
|
|
186
201
|
}
|
|
187
202
|
[Symbol.iterator]() {
|