@webstudio-is/css-data 0.45.0 → 0.47.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/cjs/schema.cjs +15 -5
- package/lib/schema.js +15 -5
- package/package.json +2 -2
- package/src/schema.ts +18 -10
package/lib/cjs/schema.cjs
CHANGED
|
@@ -20,9 +20,14 @@ var schema_exports = {};
|
|
|
20
20
|
__export(schema_exports, {
|
|
21
21
|
CssRule: () => CssRule,
|
|
22
22
|
ImageValue: () => ImageValue,
|
|
23
|
+
InvalidValue: () => InvalidValue,
|
|
24
|
+
KeywordValue: () => KeywordValue,
|
|
25
|
+
LayersValue: () => LayersValue,
|
|
23
26
|
SharedStyleValue: () => SharedStyleValue,
|
|
24
27
|
TupleValue: () => TupleValue,
|
|
25
28
|
TupleValueItem: () => TupleValueItem,
|
|
29
|
+
UnitValue: () => UnitValue,
|
|
30
|
+
UnparsedValue: () => UnparsedValue,
|
|
26
31
|
validStaticValueTypes: () => validStaticValueTypes
|
|
27
32
|
});
|
|
28
33
|
module.exports = __toCommonJS(schema_exports);
|
|
@@ -69,9 +74,11 @@ const UnsetValue = import_zod.z.object({
|
|
|
69
74
|
type: import_zod.z.literal("unset"),
|
|
70
75
|
value: import_zod.z.literal("")
|
|
71
76
|
});
|
|
72
|
-
const
|
|
77
|
+
const LayersValue = import_zod.z.object({
|
|
73
78
|
type: import_zod.z.literal("layers"),
|
|
74
|
-
value: import_zod.z.array(
|
|
79
|
+
value: import_zod.z.array(
|
|
80
|
+
import_zod.z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
|
|
81
|
+
)
|
|
75
82
|
});
|
|
76
83
|
const TupleValueItem = import_zod.z.union([UnitValue, KeywordValue, UnparsedValue]);
|
|
77
84
|
const TupleValue = import_zod.z.object({
|
|
@@ -85,7 +92,7 @@ const validStaticValueTypes = [
|
|
|
85
92
|
"rgb",
|
|
86
93
|
"image",
|
|
87
94
|
"unparsed",
|
|
88
|
-
"
|
|
95
|
+
"layers",
|
|
89
96
|
"tuple"
|
|
90
97
|
];
|
|
91
98
|
const SharedStaticStyleValue = import_zod.z.union([
|
|
@@ -94,10 +101,13 @@ const SharedStaticStyleValue = import_zod.z.union([
|
|
|
94
101
|
FontFamilyValue,
|
|
95
102
|
RgbValue,
|
|
96
103
|
UnparsedValue,
|
|
97
|
-
ArrayValue,
|
|
98
104
|
TupleValue
|
|
99
105
|
]);
|
|
100
|
-
const ValidStaticStyleValue = import_zod.z.union([
|
|
106
|
+
const ValidStaticStyleValue = import_zod.z.union([
|
|
107
|
+
ImageValue,
|
|
108
|
+
LayersValue,
|
|
109
|
+
SharedStaticStyleValue
|
|
110
|
+
]);
|
|
101
111
|
const VarValue = import_zod.z.object({
|
|
102
112
|
type: import_zod.z.literal("var"),
|
|
103
113
|
value: import_zod.z.string(),
|
package/lib/schema.js
CHANGED
|
@@ -41,9 +41,11 @@ const UnsetValue = z.object({
|
|
|
41
41
|
type: z.literal("unset"),
|
|
42
42
|
value: z.literal("")
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const LayersValue = z.object({
|
|
45
45
|
type: z.literal("layers"),
|
|
46
|
-
value: z.array(
|
|
46
|
+
value: z.array(
|
|
47
|
+
z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
|
|
48
|
+
)
|
|
47
49
|
});
|
|
48
50
|
const TupleValueItem = z.union([UnitValue, KeywordValue, UnparsedValue]);
|
|
49
51
|
const TupleValue = z.object({
|
|
@@ -57,7 +59,7 @@ const validStaticValueTypes = [
|
|
|
57
59
|
"rgb",
|
|
58
60
|
"image",
|
|
59
61
|
"unparsed",
|
|
60
|
-
"
|
|
62
|
+
"layers",
|
|
61
63
|
"tuple"
|
|
62
64
|
];
|
|
63
65
|
const SharedStaticStyleValue = z.union([
|
|
@@ -66,10 +68,13 @@ const SharedStaticStyleValue = z.union([
|
|
|
66
68
|
FontFamilyValue,
|
|
67
69
|
RgbValue,
|
|
68
70
|
UnparsedValue,
|
|
69
|
-
ArrayValue,
|
|
70
71
|
TupleValue
|
|
71
72
|
]);
|
|
72
|
-
const ValidStaticStyleValue = z.union([
|
|
73
|
+
const ValidStaticStyleValue = z.union([
|
|
74
|
+
ImageValue,
|
|
75
|
+
LayersValue,
|
|
76
|
+
SharedStaticStyleValue
|
|
77
|
+
]);
|
|
73
78
|
const VarValue = z.object({
|
|
74
79
|
type: z.literal("var"),
|
|
75
80
|
value: z.string(),
|
|
@@ -95,8 +100,13 @@ const CssRule = z.object({
|
|
|
95
100
|
export {
|
|
96
101
|
CssRule,
|
|
97
102
|
ImageValue,
|
|
103
|
+
InvalidValue,
|
|
104
|
+
KeywordValue,
|
|
105
|
+
LayersValue,
|
|
98
106
|
SharedStyleValue,
|
|
99
107
|
TupleValue,
|
|
100
108
|
TupleValueItem,
|
|
109
|
+
UnitValue,
|
|
110
|
+
UnparsedValue,
|
|
101
111
|
validStaticValueTypes
|
|
102
112
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/css-data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "CSS Data",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"mdn-data": "2.0.30",
|
|
13
13
|
"typescript": "4.9.5",
|
|
14
14
|
"zod": "^3.19.1",
|
|
15
|
-
"@webstudio-is/asset-uploader": "^0.
|
|
15
|
+
"@webstudio-is/asset-uploader": "^0.47.0",
|
|
16
16
|
"@webstudio-is/scripts": "^0.0.0",
|
|
17
17
|
"@webstudio-is/tsconfig": "^1.0.1"
|
|
18
18
|
},
|
package/src/schema.ts
CHANGED
|
@@ -30,7 +30,7 @@ const Unit = z.union([
|
|
|
30
30
|
|
|
31
31
|
export type Unit = z.infer<typeof Unit>;
|
|
32
32
|
|
|
33
|
-
const UnitValue = z.object({
|
|
33
|
+
export const UnitValue = z.object({
|
|
34
34
|
type: z.literal("unit"),
|
|
35
35
|
unit: Unit,
|
|
36
36
|
value: z.number(),
|
|
@@ -38,7 +38,7 @@ const UnitValue = z.object({
|
|
|
38
38
|
|
|
39
39
|
export type UnitValue = z.infer<typeof UnitValue>;
|
|
40
40
|
|
|
41
|
-
const KeywordValue = z.object({
|
|
41
|
+
export const KeywordValue = z.object({
|
|
42
42
|
type: z.literal("keyword"),
|
|
43
43
|
// @todo use exact type
|
|
44
44
|
value: z.string(),
|
|
@@ -48,7 +48,7 @@ export type KeywordValue = z.infer<typeof KeywordValue>;
|
|
|
48
48
|
/**
|
|
49
49
|
* Valid unparsed css value
|
|
50
50
|
**/
|
|
51
|
-
const UnparsedValue = z.object({
|
|
51
|
+
export const UnparsedValue = z.object({
|
|
52
52
|
type: z.literal("unparsed"),
|
|
53
53
|
value: z.string(),
|
|
54
54
|
});
|
|
@@ -77,7 +77,7 @@ export type ImageValue = z.infer<typeof ImageValue>;
|
|
|
77
77
|
|
|
78
78
|
// We want to be able to render the invalid value
|
|
79
79
|
// and show it is invalid visually, without saving it to the db
|
|
80
|
-
const InvalidValue = z.object({
|
|
80
|
+
export const InvalidValue = z.object({
|
|
81
81
|
type: z.literal("invalid"),
|
|
82
82
|
value: z.string(),
|
|
83
83
|
});
|
|
@@ -91,11 +91,15 @@ export type UnsetValue = z.infer<typeof UnsetValue>;
|
|
|
91
91
|
|
|
92
92
|
// To support background layers https://developer.mozilla.org/en-US/docs/Web/CSS/background
|
|
93
93
|
// and similar comma separated css properties
|
|
94
|
-
|
|
94
|
+
// InvalidValue used in case of asset not found
|
|
95
|
+
export const LayersValue = z.object({
|
|
95
96
|
type: z.literal("layers"),
|
|
96
|
-
value: z.array(
|
|
97
|
+
value: z.array(
|
|
98
|
+
z.union([UnitValue, KeywordValue, UnparsedValue, ImageValue, InvalidValue])
|
|
99
|
+
),
|
|
97
100
|
});
|
|
98
|
-
|
|
101
|
+
|
|
102
|
+
export type LayersValue = z.infer<typeof LayersValue>;
|
|
99
103
|
|
|
100
104
|
export const TupleValueItem = z.union([UnitValue, KeywordValue, UnparsedValue]);
|
|
101
105
|
export type TupleValueItem = z.infer<typeof TupleValueItem>;
|
|
@@ -104,6 +108,7 @@ export const TupleValue = z.object({
|
|
|
104
108
|
type: z.literal("tuple"),
|
|
105
109
|
value: z.array(TupleValueItem),
|
|
106
110
|
});
|
|
111
|
+
|
|
107
112
|
export type TupleValue = z.infer<typeof TupleValue>;
|
|
108
113
|
|
|
109
114
|
/**
|
|
@@ -118,7 +123,7 @@ export const validStaticValueTypes = [
|
|
|
118
123
|
"rgb",
|
|
119
124
|
"image",
|
|
120
125
|
"unparsed",
|
|
121
|
-
"
|
|
126
|
+
"layers",
|
|
122
127
|
"tuple",
|
|
123
128
|
] as const;
|
|
124
129
|
|
|
@@ -132,11 +137,14 @@ const SharedStaticStyleValue = z.union([
|
|
|
132
137
|
FontFamilyValue,
|
|
133
138
|
RgbValue,
|
|
134
139
|
UnparsedValue,
|
|
135
|
-
ArrayValue,
|
|
136
140
|
TupleValue,
|
|
137
141
|
]);
|
|
138
142
|
|
|
139
|
-
const ValidStaticStyleValue = z.union([
|
|
143
|
+
const ValidStaticStyleValue = z.union([
|
|
144
|
+
ImageValue,
|
|
145
|
+
LayersValue,
|
|
146
|
+
SharedStaticStyleValue,
|
|
147
|
+
]);
|
|
140
148
|
|
|
141
149
|
export type ValidStaticStyleValue = z.infer<typeof ValidStaticStyleValue>;
|
|
142
150
|
|