@webstudio-is/css-data 0.91.0 → 0.266.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/lib/index.js +17534 -15
- package/lib/types/__generated__/animatable-properties.d.ts +1 -0
- package/lib/types/__generated__/html.d.ts +2 -0
- package/lib/types/__generated__/keyword-values.d.ts +4 -358
- package/lib/types/__generated__/properties.d.ts +10 -3674
- package/lib/types/__generated__/property-value-descriptions.d.ts +7 -5446
- package/lib/types/__generated__/pseudo-classes.d.ts +1 -0
- package/lib/types/__generated__/pseudo-elements.d.ts +1 -0
- package/lib/types/__generated__/pseudo-selector-descriptions.d.ts +2 -0
- package/lib/types/__generated__/shorthand-properties.d.ts +1 -0
- package/lib/types/css-tree.d.ts +772 -0
- package/lib/types/index.d.ts +18 -3680
- package/lib/types/media-condition-simulator.d.ts +7 -0
- package/lib/types/parse-css-value.d.ts +8 -3
- package/lib/types/parse-css.d.ts +75 -6
- package/lib/types/property-parsers/conic-gradient.d.ts +3 -0
- package/lib/types/property-parsers/gradient-utils.d.ts +20 -0
- package/lib/types/property-parsers/grid-template-areas.d.ts +21 -0
- package/lib/types/property-parsers/grid-template-tracks.d.ts +128 -0
- package/lib/types/property-parsers/index.d.ts +6 -2
- package/lib/types/property-parsers/linear-gradient.d.ts +4 -0
- package/lib/types/property-parsers/radial-gradient.d.ts +3 -0
- package/lib/types/property-parsers/types.d.ts +28 -0
- package/lib/types/selector-validation.d.ts +13 -0
- package/lib/types/shorthands.d.ts +2 -0
- package/package.json +29 -33
- package/lib/__generated__/keyword-values.js +0 -5255
- package/lib/__generated__/properties.js +0 -3697
- package/lib/__generated__/property-value-descriptions.js +0 -2740
- package/lib/__generated__/units.js +0 -65
- package/lib/cjs/__generated__/keyword-values.js +0 -5275
- package/lib/cjs/__generated__/properties.js +0 -3717
- package/lib/cjs/__generated__/property-value-descriptions.js +0 -2760
- package/lib/cjs/__generated__/units.js +0 -85
- package/lib/cjs/custom-data.js +0 -64
- package/lib/cjs/html-check.js +0 -25
- package/lib/cjs/html.js +0 -581
- package/lib/cjs/index.js +0 -48
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/parse-css-value.js +0 -152
- package/lib/cjs/parse-css.js +0 -136
- package/lib/cjs/popularity-index.js +0 -4633
- package/lib/cjs/property-parsers/background.js +0 -119
- package/lib/cjs/property-parsers/box-shadow.js +0 -129
- package/lib/cjs/property-parsers/index.js +0 -19
- package/lib/cjs/property-parsers/parsers.js +0 -26
- package/lib/cjs/property-parsers/to-longhand.js +0 -24
- package/lib/cjs/schema.js +0 -135
- package/lib/custom-data.js +0 -44
- package/lib/html-check.js +0 -2
- package/lib/html.js +0 -561
- package/lib/parse-css-value.js +0 -122
- package/lib/parse-css.js +0 -106
- package/lib/popularity-index.js +0 -4613
- package/lib/property-parsers/background.js +0 -89
- package/lib/property-parsers/box-shadow.js +0 -99
- package/lib/property-parsers/index.js +0 -2
- package/lib/property-parsers/parsers.js +0 -6
- package/lib/property-parsers/to-longhand.js +0 -4
- package/lib/schema.js +0 -115
- package/lib/types/custom-data.d.ts +0 -15
- package/lib/types/html-check.d.ts +0 -1
- package/lib/types/html.d.ts +0 -62
- package/lib/types/parse-css-value.test.d.ts +0 -1
- package/lib/types/parse-css.test.d.ts +0 -1
- package/lib/types/popularity-index.d.ts +0 -6
- package/lib/types/property-parsers/background.d.ts +0 -11
- package/lib/types/property-parsers/background.test.d.ts +0 -1
- package/lib/types/property-parsers/box-shadow.d.ts +0 -3
- package/lib/types/property-parsers/box-shadow.test.d.ts +0 -1
- package/lib/types/property-parsers/parsers.d.ts +0 -2
- package/lib/types/property-parsers/to-longhand.d.ts +0 -1
- package/lib/types/schema.d.ts +0 -3243
- package/src/__generated__/keyword-values.ts +0 -5253
- package/src/__generated__/properties.ts +0 -3696
- package/src/__generated__/property-value-descriptions.ts +0 -4008
- package/src/__generated__/units.ts +0 -63
- package/src/custom-data.ts +0 -57
- package/src/html-check.ts +0 -8
- package/src/html.ts +0 -617
- package/src/index.ts +0 -25
- package/src/parse-css-value.test.ts +0 -136
- package/src/parse-css-value.ts +0 -157
- package/src/parse-css.test.ts +0 -101
- package/src/parse-css.ts +0 -137
- package/src/popularity-index.ts +0 -4611
- package/src/property-parsers/README.md +0 -11
- package/src/property-parsers/background.test.ts +0 -184
- package/src/property-parsers/background.ts +0 -147
- package/src/property-parsers/box-shadow.test.ts +0 -294
- package/src/property-parsers/box-shadow.ts +0 -130
- package/src/property-parsers/index.ts +0 -2
- package/src/property-parsers/parsers.ts +0 -5
- package/src/property-parsers/to-longhand.ts +0 -4
- package/src/schema.ts +0 -193
package/lib/parse-css.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import * as csstree from "css-tree";
|
|
2
|
-
import { parseCssValue as parseCssValueLonghand } from "./parse-css-value";
|
|
3
|
-
import * as parsers from "./property-parsers/parsers";
|
|
4
|
-
import * as toLonghand from "./property-parsers/to-longhand";
|
|
5
|
-
import { StyleValue } from "./schema";
|
|
6
|
-
const parseCssValue = function parseCssValue2(property, value) {
|
|
7
|
-
const unwrap = toLonghand[property];
|
|
8
|
-
if (typeof unwrap === "function") {
|
|
9
|
-
const longhands = unwrap(value);
|
|
10
|
-
return Object.fromEntries(
|
|
11
|
-
Object.entries(longhands).map(([property2, value2]) => {
|
|
12
|
-
const valueParser = parsers[property2];
|
|
13
|
-
if (typeof valueParser === "function") {
|
|
14
|
-
return [property2, valueParser(value2)];
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(value2)) {
|
|
17
|
-
return [
|
|
18
|
-
property2,
|
|
19
|
-
{
|
|
20
|
-
type: "invalid",
|
|
21
|
-
value: value2.join("")
|
|
22
|
-
}
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
if (!value2) {
|
|
26
|
-
return [property2, { type: "invalid", value: "" }];
|
|
27
|
-
}
|
|
28
|
-
return [
|
|
29
|
-
property2,
|
|
30
|
-
parseCssValueLonghand(property2, value2)
|
|
31
|
-
];
|
|
32
|
-
})
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
[property]: parseCssValueLonghand(property, value)
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const cssTreeTryParse = (input) => {
|
|
40
|
-
try {
|
|
41
|
-
const ast = csstree.parse(input);
|
|
42
|
-
return ast;
|
|
43
|
-
} catch {
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const parseCss = function cssToWS(css) {
|
|
48
|
-
const ast = cssTreeTryParse(css);
|
|
49
|
-
let selectors = [];
|
|
50
|
-
const styles = {};
|
|
51
|
-
if (ast === void 0) {
|
|
52
|
-
return styles;
|
|
53
|
-
}
|
|
54
|
-
csstree.walk(ast, (node, item) => {
|
|
55
|
-
if (node.type === "SelectorList") {
|
|
56
|
-
selectors = [];
|
|
57
|
-
}
|
|
58
|
-
if (node.type === "ClassSelector") {
|
|
59
|
-
if (!item.prev && !item.next) {
|
|
60
|
-
selectors.push(node.name);
|
|
61
|
-
}
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (node.type === "Declaration") {
|
|
65
|
-
const stringValue = csstree.generate(node.value);
|
|
66
|
-
const parsedCss = parseCssValue(
|
|
67
|
-
node.property,
|
|
68
|
-
stringValue
|
|
69
|
-
);
|
|
70
|
-
Object.entries(parsedCss).forEach(
|
|
71
|
-
([property, value]) => {
|
|
72
|
-
try {
|
|
73
|
-
StyleValue.parse(value);
|
|
74
|
-
selectors.forEach((selector) => {
|
|
75
|
-
if (Array.isArray(styles[selector])) {
|
|
76
|
-
styles[selector].push({
|
|
77
|
-
property,
|
|
78
|
-
value
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
styles[selector] = [{ property, value }];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
} catch (error) {
|
|
85
|
-
if (true) {
|
|
86
|
-
console.warn(
|
|
87
|
-
true,
|
|
88
|
-
`Declaration parsing for \`${selectors.join(", ")}.${node.property}: ${stringValue}\` failed:
|
|
89
|
-
|
|
90
|
-
${JSON.stringify(
|
|
91
|
-
parsedCss,
|
|
92
|
-
null,
|
|
93
|
-
2
|
|
94
|
-
)}`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
return styles;
|
|
103
|
-
};
|
|
104
|
-
export {
|
|
105
|
-
parseCss
|
|
106
|
-
};
|