@webstudio-is/sdk 0.213.0 → 0.215.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/core-templates.js +6 -8
- package/lib/index.js +35 -17
- package/lib/types/schema/component-meta.d.ts +11 -13
- package/package.json +5 -5
package/lib/core-templates.js
CHANGED
|
@@ -39,7 +39,6 @@ var html = [
|
|
|
39
39
|
// src/core-metas.ts
|
|
40
40
|
var rootComponent = "ws:root";
|
|
41
41
|
var rootMeta = {
|
|
42
|
-
type: "container",
|
|
43
42
|
label: "Global Root",
|
|
44
43
|
icon: SettingsIcon,
|
|
45
44
|
presetStyle: {
|
|
@@ -51,7 +50,6 @@ var rootPropsMeta = {
|
|
|
51
50
|
};
|
|
52
51
|
var elementComponent = "ws:element";
|
|
53
52
|
var elementMeta = {
|
|
54
|
-
type: "container",
|
|
55
53
|
label: "Element",
|
|
56
54
|
icon: HtmlElementIcon
|
|
57
55
|
};
|
|
@@ -60,9 +58,12 @@ var elementPropsMeta = {
|
|
|
60
58
|
};
|
|
61
59
|
var collectionComponent = "ws:collection";
|
|
62
60
|
var collectionMeta = {
|
|
63
|
-
type: "container",
|
|
64
61
|
label: "Collection",
|
|
65
|
-
icon: ListViewIcon
|
|
62
|
+
icon: ListViewIcon,
|
|
63
|
+
contentModel: {
|
|
64
|
+
category: "instance",
|
|
65
|
+
children: ["instance"]
|
|
66
|
+
}
|
|
66
67
|
};
|
|
67
68
|
var collectionPropsMeta = {
|
|
68
69
|
props: {
|
|
@@ -76,12 +77,11 @@ var collectionPropsMeta = {
|
|
|
76
77
|
};
|
|
77
78
|
var descendantComponent = "ws:descendant";
|
|
78
79
|
var descendantMeta = {
|
|
79
|
-
type: "control",
|
|
80
80
|
label: "Descendant",
|
|
81
81
|
icon: PaintBrushIcon,
|
|
82
82
|
contentModel: {
|
|
83
83
|
category: "none",
|
|
84
|
-
children: [
|
|
84
|
+
children: []
|
|
85
85
|
},
|
|
86
86
|
// @todo infer possible presets
|
|
87
87
|
presetStyle: {}
|
|
@@ -117,7 +117,6 @@ var descendantPropsMeta = {
|
|
|
117
117
|
var blockComponent = "ws:block";
|
|
118
118
|
var blockTemplateComponent = "ws:block-template";
|
|
119
119
|
var blockTemplateMeta = {
|
|
120
|
-
type: "container",
|
|
121
120
|
icon: AddTemplateInstanceIcon,
|
|
122
121
|
contentModel: {
|
|
123
122
|
category: "none",
|
|
@@ -128,7 +127,6 @@ var blockTemplatePropsMeta = {
|
|
|
128
127
|
props: {}
|
|
129
128
|
};
|
|
130
129
|
var blockMeta = {
|
|
131
|
-
type: "container",
|
|
132
130
|
label: "Content Block",
|
|
133
131
|
icon: ContentBlockIcon,
|
|
134
132
|
contentModel: {
|
package/lib/index.js
CHANGED
|
@@ -991,20 +991,14 @@ var ContentModel = z16.object({
|
|
|
991
991
|
* transparent - pass through possible children from parent
|
|
992
992
|
* rich-text - can be edited as rich text
|
|
993
993
|
* instance - other instances accepted
|
|
994
|
-
* empty - no children accepted
|
|
995
994
|
* ComponentName - accept specific components with none category
|
|
996
995
|
*/
|
|
997
|
-
children: z16.array(
|
|
998
|
-
z16.string()
|
|
999
|
-
)
|
|
996
|
+
children: z16.array(z16.string())
|
|
1000
997
|
});
|
|
1001
998
|
var WsComponentMeta = z16.object({
|
|
1002
999
|
category: z16.enum(componentCategories).optional(),
|
|
1003
|
-
// container - can accept other components with dnd or be edited as text
|
|
1004
|
-
|
|
1005
|
-
// embed - images, videos or other embeddable components, without children
|
|
1006
|
-
// rich-text-child - formatted text fragment, not listed in components list
|
|
1007
|
-
type: z16.enum(["container", "control", "embed", "rich-text-child"]),
|
|
1000
|
+
// container - can accept other components with dnd or be edited as text ..
|
|
1001
|
+
type: z16.enum(["container"]).optional(),
|
|
1008
1002
|
/**
|
|
1009
1003
|
* a property used as textual placeholder when no content specified while in builder
|
|
1010
1004
|
* also signals to not insert components inside unless dropped explicitly
|
|
@@ -1057,7 +1051,6 @@ var html = [
|
|
|
1057
1051
|
// src/core-metas.ts
|
|
1058
1052
|
var rootComponent = "ws:root";
|
|
1059
1053
|
var rootMeta = {
|
|
1060
|
-
type: "container",
|
|
1061
1054
|
label: "Global Root",
|
|
1062
1055
|
icon: SettingsIcon,
|
|
1063
1056
|
presetStyle: {
|
|
@@ -1069,7 +1062,6 @@ var rootPropsMeta = {
|
|
|
1069
1062
|
};
|
|
1070
1063
|
var elementComponent = "ws:element";
|
|
1071
1064
|
var elementMeta = {
|
|
1072
|
-
type: "container",
|
|
1073
1065
|
label: "Element",
|
|
1074
1066
|
icon: HtmlElementIcon
|
|
1075
1067
|
};
|
|
@@ -1079,9 +1071,12 @@ var elementPropsMeta = {
|
|
|
1079
1071
|
var portalComponent = "Slot";
|
|
1080
1072
|
var collectionComponent = "ws:collection";
|
|
1081
1073
|
var collectionMeta = {
|
|
1082
|
-
type: "container",
|
|
1083
1074
|
label: "Collection",
|
|
1084
|
-
icon: ListViewIcon
|
|
1075
|
+
icon: ListViewIcon,
|
|
1076
|
+
contentModel: {
|
|
1077
|
+
category: "instance",
|
|
1078
|
+
children: ["instance"]
|
|
1079
|
+
}
|
|
1085
1080
|
};
|
|
1086
1081
|
var collectionPropsMeta = {
|
|
1087
1082
|
props: {
|
|
@@ -1095,12 +1090,11 @@ var collectionPropsMeta = {
|
|
|
1095
1090
|
};
|
|
1096
1091
|
var descendantComponent = "ws:descendant";
|
|
1097
1092
|
var descendantMeta = {
|
|
1098
|
-
type: "control",
|
|
1099
1093
|
label: "Descendant",
|
|
1100
1094
|
icon: PaintBrushIcon,
|
|
1101
1095
|
contentModel: {
|
|
1102
1096
|
category: "none",
|
|
1103
|
-
children: [
|
|
1097
|
+
children: []
|
|
1104
1098
|
},
|
|
1105
1099
|
// @todo infer possible presets
|
|
1106
1100
|
presetStyle: {}
|
|
@@ -1136,7 +1130,6 @@ var descendantPropsMeta = {
|
|
|
1136
1130
|
var blockComponent = "ws:block";
|
|
1137
1131
|
var blockTemplateComponent = "ws:block-template";
|
|
1138
1132
|
var blockTemplateMeta = {
|
|
1139
|
-
type: "container",
|
|
1140
1133
|
icon: AddTemplateInstanceIcon,
|
|
1141
1134
|
contentModel: {
|
|
1142
1135
|
category: "none",
|
|
@@ -1147,7 +1140,6 @@ var blockTemplatePropsMeta = {
|
|
|
1147
1140
|
props: {}
|
|
1148
1141
|
};
|
|
1149
1142
|
var blockMeta = {
|
|
1150
|
-
type: "container",
|
|
1151
1143
|
label: "Content Block",
|
|
1152
1144
|
icon: ContentBlockIcon,
|
|
1153
1145
|
contentModel: {
|
|
@@ -2065,7 +2057,30 @@ var generateCss = ({
|
|
|
2065
2057
|
presetSheet.addMediaRule("presets");
|
|
2066
2058
|
const presetClasses = /* @__PURE__ */ new Map();
|
|
2067
2059
|
const scope = createScope([], normalizeClassName, "-");
|
|
2060
|
+
const tagsByComponent = /* @__PURE__ */ new Map();
|
|
2061
|
+
tagsByComponent.set(rootComponent, /* @__PURE__ */ new Set(["html"]));
|
|
2062
|
+
const tagByInstanceId = /* @__PURE__ */ new Map();
|
|
2063
|
+
for (const prop of props.values()) {
|
|
2064
|
+
if (prop.type === "string" && prop.name === "tag") {
|
|
2065
|
+
tagByInstanceId.set(prop.instanceId, prop.value);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
for (const instance of instances.values()) {
|
|
2069
|
+
const propTag = tagByInstanceId.get(instance.id);
|
|
2070
|
+
const meta = componentMetas.get(instance.component);
|
|
2071
|
+
const metaTag = Object.keys(meta?.presetStyle ?? {}).at(0);
|
|
2072
|
+
let componentTags = tagsByComponent.get(instance.component);
|
|
2073
|
+
if (componentTags === void 0) {
|
|
2074
|
+
componentTags = /* @__PURE__ */ new Set();
|
|
2075
|
+
tagsByComponent.set(instance.component, componentTags);
|
|
2076
|
+
}
|
|
2077
|
+
const tag = instance.tag ?? propTag ?? metaTag;
|
|
2078
|
+
if (tag) {
|
|
2079
|
+
componentTags.add(tag);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2068
2082
|
for (const [component, meta] of componentMetas) {
|
|
2083
|
+
const componentTags = tagsByComponent.get(component);
|
|
2069
2084
|
const [_namespace, componentName] = parseComponentName(component);
|
|
2070
2085
|
const className = `w-${scope.getName(component, meta.label ?? componentName)}`;
|
|
2071
2086
|
const presetStyle = Object.entries(meta.presetStyle ?? {});
|
|
@@ -2073,6 +2088,9 @@ var generateCss = ({
|
|
|
2073
2088
|
presetClasses.set(component, className);
|
|
2074
2089
|
}
|
|
2075
2090
|
for (const [tag, styles2] of presetStyle) {
|
|
2091
|
+
if (!componentTags?.has(tag)) {
|
|
2092
|
+
continue;
|
|
2093
|
+
}
|
|
2076
2094
|
const selector = component === rootComponent ? ":root" : `${tag}.${className}`;
|
|
2077
2095
|
const rule = presetSheet.addNestingRule(selector);
|
|
2078
2096
|
for (const declaration of styles2) {
|
|
@@ -5916,21 +5916,20 @@ export declare const ContentModel: z.ZodObject<{
|
|
|
5916
5916
|
* transparent - pass through possible children from parent
|
|
5917
5917
|
* rich-text - can be edited as rich text
|
|
5918
5918
|
* instance - other instances accepted
|
|
5919
|
-
* empty - no children accepted
|
|
5920
5919
|
* ComponentName - accept specific components with none category
|
|
5921
5920
|
*/
|
|
5922
|
-
children: z.
|
|
5921
|
+
children: z.ZodType<Array<"transparent" | "instance" | "rich-text" | (string & {})>>;
|
|
5923
5922
|
}, "strip", z.ZodTypeAny, {
|
|
5924
|
-
children: ("instance" |
|
|
5923
|
+
children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
|
|
5925
5924
|
category: "none" | "instance";
|
|
5926
5925
|
}, {
|
|
5927
|
-
children: ("instance" |
|
|
5926
|
+
children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
|
|
5928
5927
|
category: "none" | "instance";
|
|
5929
5928
|
}>;
|
|
5930
5929
|
export type ContentModel = z.infer<typeof ContentModel>;
|
|
5931
5930
|
export declare const WsComponentMeta: z.ZodObject<{
|
|
5932
5931
|
category: z.ZodOptional<z.ZodEnum<["general", "typography", "media", "animations", "data", "forms", "localization", "radix", "xml", "hidden", "internal"]>>;
|
|
5933
|
-
type: z.ZodEnum<["container"
|
|
5932
|
+
type: z.ZodOptional<z.ZodEnum<["container"]>>;
|
|
5934
5933
|
/**
|
|
5935
5934
|
* a property used as textual placeholder when no content specified while in builder
|
|
5936
5935
|
* also signals to not insert components inside unless dropped explicitly
|
|
@@ -6073,15 +6072,14 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
6073
6072
|
* transparent - pass through possible children from parent
|
|
6074
6073
|
* rich-text - can be edited as rich text
|
|
6075
6074
|
* instance - other instances accepted
|
|
6076
|
-
* empty - no children accepted
|
|
6077
6075
|
* ComponentName - accept specific components with none category
|
|
6078
6076
|
*/
|
|
6079
|
-
children: z.
|
|
6077
|
+
children: z.ZodType<Array<"transparent" | "instance" | "rich-text" | (string & {})>>;
|
|
6080
6078
|
}, "strip", z.ZodTypeAny, {
|
|
6081
|
-
children: ("instance" |
|
|
6079
|
+
children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
|
|
6082
6080
|
category: "none" | "instance";
|
|
6083
6081
|
}, {
|
|
6084
|
-
children: ("instance" |
|
|
6082
|
+
children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
|
|
6085
6083
|
category: "none" | "instance";
|
|
6086
6084
|
}>>;
|
|
6087
6085
|
indexWithinAncestor: z.ZodOptional<z.ZodString>;
|
|
@@ -11159,9 +11157,9 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
11159
11157
|
}>, "many">>;
|
|
11160
11158
|
order: z.ZodOptional<z.ZodNumber>;
|
|
11161
11159
|
}, "strip", z.ZodTypeAny, {
|
|
11162
|
-
type: "embed" | "control" | "container" | "rich-text-child";
|
|
11163
11160
|
icon: string;
|
|
11164
11161
|
order?: number | undefined;
|
|
11162
|
+
type?: "container" | undefined;
|
|
11165
11163
|
label?: string | undefined;
|
|
11166
11164
|
description?: string | undefined;
|
|
11167
11165
|
placeholder?: string | undefined;
|
|
@@ -11203,7 +11201,7 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
11203
11201
|
} | undefined;
|
|
11204
11202
|
}[] | undefined;
|
|
11205
11203
|
contentModel?: {
|
|
11206
|
-
children: ("instance" |
|
|
11204
|
+
children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
|
|
11207
11205
|
category: "none" | "instance";
|
|
11208
11206
|
} | undefined;
|
|
11209
11207
|
indexWithinAncestor?: string | undefined;
|
|
@@ -11814,9 +11812,9 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
11814
11812
|
state?: string | undefined;
|
|
11815
11813
|
}[]> | undefined;
|
|
11816
11814
|
}, {
|
|
11817
|
-
type: "embed" | "control" | "container" | "rich-text-child";
|
|
11818
11815
|
icon: string;
|
|
11819
11816
|
order?: number | undefined;
|
|
11817
|
+
type?: "container" | undefined;
|
|
11820
11818
|
label?: string | undefined;
|
|
11821
11819
|
description?: string | undefined;
|
|
11822
11820
|
placeholder?: string | undefined;
|
|
@@ -11858,7 +11856,7 @@ export declare const WsComponentMeta: z.ZodObject<{
|
|
|
11858
11856
|
} | undefined;
|
|
11859
11857
|
}[] | undefined;
|
|
11860
11858
|
contentModel?: {
|
|
11861
|
-
children: ("instance" |
|
|
11859
|
+
children: ("instance" | "transparent" | "rich-text" | (string & {}))[];
|
|
11862
11860
|
category: "none" | "instance";
|
|
11863
11861
|
} | undefined;
|
|
11864
11862
|
indexWithinAncestor?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.215.0",
|
|
4
4
|
"description": "Webstudio project data schema",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"reserved-identifiers": "^1.0.0",
|
|
41
41
|
"type-fest": "^4.37.0",
|
|
42
42
|
"zod": "^3.24.2",
|
|
43
|
-
"@webstudio-is/
|
|
44
|
-
"@webstudio-is/
|
|
45
|
-
"@webstudio-is/
|
|
43
|
+
"@webstudio-is/css-engine": "0.215.0",
|
|
44
|
+
"@webstudio-is/fonts": "0.215.0",
|
|
45
|
+
"@webstudio-is/icons": "0.215.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"html-tags": "^4.0.0",
|
|
49
49
|
"vitest": "^3.0.8",
|
|
50
50
|
"@webstudio-is/css-data": "0.0.0",
|
|
51
|
-
"@webstudio-is/template": "0.
|
|
51
|
+
"@webstudio-is/template": "0.215.0",
|
|
52
52
|
"@webstudio-is/tsconfig": "1.0.7"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|