@webstudio-is/sdk 0.274.5 → 0.276.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 +1 -1
- package/lib/index.js +510 -18
- package/lib/runtime.js +290 -2
- package/lib/schema-org.js +5703 -0
- package/lib/schema.js +33 -8
- package/lib/types/core-metas.d.ts +1 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/input-json-schema.d.ts +15 -0
- package/lib/types/json-ld-utils.d.ts +3 -0
- package/lib/types/json-ld.d.ts +31 -0
- package/lib/types/runtime.d.ts +1 -0
- package/lib/types/schema/animation-schema.d.ts +1768 -50560
- package/lib/types/schema/assets.d.ts +126 -479
- package/lib/types/schema/breakpoints.d.ts +6 -54
- package/lib/types/schema/component-meta.d.ts +464 -11361
- package/lib/types/schema/data-sources.d.ts +38 -238
- package/lib/types/schema/deployment.d.ts +20 -31
- package/lib/types/schema/instances.d.ts +34 -165
- package/lib/types/schema/pages.d.ts +109 -1211
- package/lib/types/schema/prop-meta.d.ts +48 -435
- package/lib/types/schema/props.d.ts +937 -35745
- package/lib/types/schema/resources.d.ts +15 -136
- package/lib/types/schema/style-source-selections.d.ts +4 -16
- package/lib/types/schema/style-sources.d.ts +7 -49
- package/lib/types/schema/styles.d.ts +804 -5240
- package/lib/types/schema/webstudio.d.ts +1259 -23420
- package/lib/types/scope.d.ts +3 -1
- package/package.json +20 -11
package/lib/index.js
CHANGED
|
@@ -185,6 +185,7 @@ var projectMeta = z2.object({
|
|
|
185
185
|
contactEmail: z2.string().optional(),
|
|
186
186
|
faviconAssetId: z2.string().optional(),
|
|
187
187
|
code: z2.string().optional(),
|
|
188
|
+
agentInstructions: z2.string().optional(),
|
|
188
189
|
auth: z2.string().optional()
|
|
189
190
|
});
|
|
190
191
|
var projectNewRedirectPath = z2.string().min(1, "Path is required").refine((data) => {
|
|
@@ -346,12 +347,29 @@ var pages = z2.object({
|
|
|
346
347
|
|
|
347
348
|
// src/schema/instances.ts
|
|
348
349
|
import { z as z3 } from "zod";
|
|
350
|
+
var textChildValue = z3.string();
|
|
349
351
|
var textChild = z3.object({
|
|
350
352
|
type: z3.literal("text"),
|
|
351
|
-
value:
|
|
353
|
+
value: textChildValue,
|
|
352
354
|
placeholder: z3.boolean().optional()
|
|
353
355
|
});
|
|
354
356
|
var instanceId = z3.string();
|
|
357
|
+
var instanceComponent = z3.string().min(1);
|
|
358
|
+
var instanceTag = z3.string().min(1, "Tag cannot be empty").describe(
|
|
359
|
+
"Optional HTML tag override for component rendering. Omit for component defaults; never pass an empty string."
|
|
360
|
+
);
|
|
361
|
+
var instanceAttributes = z3.object({
|
|
362
|
+
component: instanceComponent,
|
|
363
|
+
tag: instanceTag.optional(),
|
|
364
|
+
label: z3.string().optional()
|
|
365
|
+
});
|
|
366
|
+
var instanceCreateInput = instanceAttributes.partial({
|
|
367
|
+
component: true
|
|
368
|
+
});
|
|
369
|
+
var instanceFilterInput = instanceAttributes.pick({
|
|
370
|
+
component: true,
|
|
371
|
+
tag: true
|
|
372
|
+
}).partial();
|
|
355
373
|
var idChild = z3.object({
|
|
356
374
|
type: z3.literal("id"),
|
|
357
375
|
value: instanceId
|
|
@@ -364,9 +382,9 @@ var instanceChild = z3.union([idChild, textChild, expressionChild]);
|
|
|
364
382
|
var instance = z3.object({
|
|
365
383
|
type: z3.literal("instance"),
|
|
366
384
|
id: instanceId,
|
|
367
|
-
component:
|
|
368
|
-
tag:
|
|
369
|
-
label:
|
|
385
|
+
component: instanceAttributes.shape.component,
|
|
386
|
+
tag: instanceAttributes.shape.tag,
|
|
387
|
+
label: instanceAttributes.shape.label,
|
|
370
388
|
children: z3.array(instanceChild)
|
|
371
389
|
});
|
|
372
390
|
var instances = z3.map(instanceId, instance);
|
|
@@ -394,8 +412,8 @@ var dataSourceVariableValue = z4.union([
|
|
|
394
412
|
}),
|
|
395
413
|
z4.object({
|
|
396
414
|
type: z4.literal("json"),
|
|
397
|
-
value: z4.unknown()
|
|
398
|
-
})
|
|
415
|
+
value: z4.unknown().optional()
|
|
416
|
+
}).transform((value) => ({ ...value, value: value.value ?? null }))
|
|
399
417
|
]);
|
|
400
418
|
var dataSource = z4.union([
|
|
401
419
|
z4.object({
|
|
@@ -461,6 +479,7 @@ var resource = z5.object({
|
|
|
461
479
|
});
|
|
462
480
|
var resourceRequest = z5.object({
|
|
463
481
|
name: z5.string(),
|
|
482
|
+
control: z5.optional(z5.union([z5.literal("system"), z5.literal("graphql")])),
|
|
464
483
|
method,
|
|
465
484
|
url: z5.string(),
|
|
466
485
|
searchParams: z5.array(
|
|
@@ -571,7 +590,7 @@ var insetUnitValue = z6.union([
|
|
|
571
590
|
value: z6.literal("auto")
|
|
572
591
|
})
|
|
573
592
|
]);
|
|
574
|
-
var keyframeStyles = z6.record(styleValue);
|
|
593
|
+
var keyframeStyles = z6.record(z6.string(), styleValue);
|
|
575
594
|
var animationKeyframe = z6.object({
|
|
576
595
|
offset: z6.number().optional(),
|
|
577
596
|
styles: keyframeStyles
|
|
@@ -910,7 +929,11 @@ var code = z14.object({
|
|
|
910
929
|
...common,
|
|
911
930
|
control: z14.literal("code"),
|
|
912
931
|
type: z14.literal("string"),
|
|
913
|
-
language: z14.union([
|
|
932
|
+
language: z14.union([
|
|
933
|
+
z14.literal("html"),
|
|
934
|
+
z14.literal("json"),
|
|
935
|
+
z14.literal("markdown")
|
|
936
|
+
]),
|
|
914
937
|
defaultValue: z14.string().optional()
|
|
915
938
|
});
|
|
916
939
|
var codeText = z14.object({
|
|
@@ -919,6 +942,12 @@ var codeText = z14.object({
|
|
|
919
942
|
type: z14.literal("string"),
|
|
920
943
|
defaultValue: z14.string().optional()
|
|
921
944
|
});
|
|
945
|
+
var jsonCode = z14.object({
|
|
946
|
+
...common,
|
|
947
|
+
control: z14.literal("json-code"),
|
|
948
|
+
type: z14.literal("string"),
|
|
949
|
+
defaultValue: z14.string().optional()
|
|
950
|
+
});
|
|
922
951
|
var color = z14.object({
|
|
923
952
|
...common,
|
|
924
953
|
control: z14.literal("color"),
|
|
@@ -1034,6 +1063,7 @@ var propMeta = z14.union([
|
|
|
1034
1063
|
resource2,
|
|
1035
1064
|
code,
|
|
1036
1065
|
codeText,
|
|
1066
|
+
jsonCode,
|
|
1037
1067
|
color,
|
|
1038
1068
|
boolean,
|
|
1039
1069
|
radio,
|
|
@@ -1076,6 +1106,13 @@ var componentCategories = [
|
|
|
1076
1106
|
"hidden",
|
|
1077
1107
|
"internal"
|
|
1078
1108
|
];
|
|
1109
|
+
var normalizeComponentCategory = (category) => {
|
|
1110
|
+
return category ?? "hidden";
|
|
1111
|
+
};
|
|
1112
|
+
var shouldFilterComponentCategory = (category) => {
|
|
1113
|
+
const normalized = normalizeComponentCategory(category);
|
|
1114
|
+
return normalized === "hidden" || normalized === "internal";
|
|
1115
|
+
};
|
|
1079
1116
|
var componentState = z15.object({
|
|
1080
1117
|
selector: z15.string(),
|
|
1081
1118
|
label: z15.string()
|
|
@@ -1106,13 +1143,14 @@ var wsComponentMeta = z15.object({
|
|
|
1106
1143
|
indexWithinAncestor: z15.optional(z15.string()),
|
|
1107
1144
|
label: z15.optional(z15.string()),
|
|
1108
1145
|
description: z15.string().optional(),
|
|
1146
|
+
deprecated: z15.boolean().optional(),
|
|
1109
1147
|
icon: z15.string().optional(),
|
|
1110
1148
|
presetStyle: z15.optional(z15.record(z15.string(), z15.array(presetStyleDecl))),
|
|
1111
1149
|
states: z15.optional(z15.array(componentState)),
|
|
1112
1150
|
order: z15.number().optional(),
|
|
1113
1151
|
// properties and html attributes that will be always visible in properties panel
|
|
1114
1152
|
initialProps: z15.array(z15.string()).optional(),
|
|
1115
|
-
props: z15.record(propMeta).optional()
|
|
1153
|
+
props: z15.record(z15.string(), propMeta).optional()
|
|
1116
1154
|
});
|
|
1117
1155
|
|
|
1118
1156
|
// src/assets.ts
|
|
@@ -1787,6 +1825,289 @@ var summary = [
|
|
|
1787
1825
|
{ property: "box-sizing", value: { type: "keyword", value: "border-box" } }
|
|
1788
1826
|
];
|
|
1789
1827
|
|
|
1828
|
+
// src/json-ld-utils.ts
|
|
1829
|
+
var isJsonObject = (value) => typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
1830
|
+
var appendJsonPath = (path, key) => typeof key === "number" ? `${path}[${key}]` : /^[A-Za-z_$][\w$]*$/.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
|
|
1831
|
+
var getJsonLdTypes = (value) => typeof value === "string" ? [value] : Array.isArray(value) && value.every((item) => typeof item === "string") ? value : [];
|
|
1832
|
+
|
|
1833
|
+
// src/json-ld.ts
|
|
1834
|
+
var pushKeywordTypeError = (diagnostics, path, message) => {
|
|
1835
|
+
diagnostics.push({
|
|
1836
|
+
severity: "error",
|
|
1837
|
+
code: "invalid-keyword-value",
|
|
1838
|
+
path,
|
|
1839
|
+
message
|
|
1840
|
+
});
|
|
1841
|
+
};
|
|
1842
|
+
var escapeJsonLdScriptText = (value) => value.replace(/</g, "\\u003c");
|
|
1843
|
+
var validateContextTermDefinition = (definition, path, diagnostics) => {
|
|
1844
|
+
if (definition === null || typeof definition === "string" || isJsonObject(definition)) {
|
|
1845
|
+
if (isJsonObject(definition) && definition["@context"] !== void 0) {
|
|
1846
|
+
validateContext(
|
|
1847
|
+
definition["@context"],
|
|
1848
|
+
appendJsonPath(path, "@context"),
|
|
1849
|
+
diagnostics
|
|
1850
|
+
);
|
|
1851
|
+
}
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
diagnostics.push({
|
|
1855
|
+
severity: "error",
|
|
1856
|
+
code: "invalid-context",
|
|
1857
|
+
path,
|
|
1858
|
+
message: "JSON-LD context terms must map to a string, object, or null."
|
|
1859
|
+
});
|
|
1860
|
+
};
|
|
1861
|
+
var validateContext = (context, path, diagnostics) => {
|
|
1862
|
+
if (context === null || typeof context === "string") {
|
|
1863
|
+
return;
|
|
1864
|
+
}
|
|
1865
|
+
if (Array.isArray(context)) {
|
|
1866
|
+
context.forEach(
|
|
1867
|
+
(item, index) => validateContext(item, appendJsonPath(path, index), diagnostics)
|
|
1868
|
+
);
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
if (isJsonObject(context) === false) {
|
|
1872
|
+
diagnostics.push({
|
|
1873
|
+
severity: "error",
|
|
1874
|
+
code: "invalid-context",
|
|
1875
|
+
path,
|
|
1876
|
+
message: "@context must be a string, object, array of contexts, or null."
|
|
1877
|
+
});
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
for (const keyword of ["@base", "@vocab", "@language"]) {
|
|
1881
|
+
if (context[keyword] !== void 0 && context[keyword] !== null && typeof context[keyword] !== "string") {
|
|
1882
|
+
diagnostics.push({
|
|
1883
|
+
severity: "error",
|
|
1884
|
+
code: "invalid-context",
|
|
1885
|
+
path: appendJsonPath(path, keyword),
|
|
1886
|
+
message: `${keyword} must be a string or null.`
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
if (context["@direction"] !== void 0 && context["@direction"] !== null && context["@direction"] !== "ltr" && context["@direction"] !== "rtl") {
|
|
1891
|
+
diagnostics.push({
|
|
1892
|
+
severity: "error",
|
|
1893
|
+
code: "invalid-context",
|
|
1894
|
+
path: appendJsonPath(path, "@direction"),
|
|
1895
|
+
message: '@direction must be "ltr", "rtl", or null.'
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
if (context["@propagate"] !== void 0 && typeof context["@propagate"] !== "boolean") {
|
|
1899
|
+
diagnostics.push({
|
|
1900
|
+
severity: "error",
|
|
1901
|
+
code: "invalid-context",
|
|
1902
|
+
path: appendJsonPath(path, "@propagate"),
|
|
1903
|
+
message: "@propagate must be a boolean."
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
if (context["@version"] !== void 0 && context["@version"] !== 1.1) {
|
|
1907
|
+
diagnostics.push({
|
|
1908
|
+
severity: "error",
|
|
1909
|
+
code: "invalid-context",
|
|
1910
|
+
path: appendJsonPath(path, "@version"),
|
|
1911
|
+
message: "@version must be 1.1."
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
for (const [term, definition] of Object.entries(context)) {
|
|
1915
|
+
if (term.startsWith("@")) {
|
|
1916
|
+
continue;
|
|
1917
|
+
}
|
|
1918
|
+
validateContextTermDefinition(
|
|
1919
|
+
definition,
|
|
1920
|
+
appendJsonPath(path, term),
|
|
1921
|
+
diagnostics
|
|
1922
|
+
);
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
var validateNestedValues = (value, path, diagnostics) => {
|
|
1926
|
+
if (isJsonObject(value)) {
|
|
1927
|
+
validateNode(value, path, diagnostics);
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
if (Array.isArray(value)) {
|
|
1931
|
+
value.forEach((item, index) => {
|
|
1932
|
+
if (isJsonObject(item) || Array.isArray(item)) {
|
|
1933
|
+
validateNestedValues(item, appendJsonPath(path, index), diagnostics);
|
|
1934
|
+
}
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
var validateNode = (value, path, diagnostics) => {
|
|
1939
|
+
if (Array.isArray(value)) {
|
|
1940
|
+
value.forEach(
|
|
1941
|
+
(item, index) => validateNode(item, appendJsonPath(path, index), diagnostics)
|
|
1942
|
+
);
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1945
|
+
if (isJsonObject(value) === false) {
|
|
1946
|
+
diagnostics.push({
|
|
1947
|
+
severity: "error",
|
|
1948
|
+
code: "invalid-root",
|
|
1949
|
+
path,
|
|
1950
|
+
message: "JSON-LD nodes must be objects."
|
|
1951
|
+
});
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
if (value["@context"] !== void 0) {
|
|
1955
|
+
validateContext(
|
|
1956
|
+
value["@context"],
|
|
1957
|
+
appendJsonPath(path, "@context"),
|
|
1958
|
+
diagnostics
|
|
1959
|
+
);
|
|
1960
|
+
}
|
|
1961
|
+
const typeValue = value["@type"];
|
|
1962
|
+
if (typeValue !== void 0 && (getJsonLdTypes(typeValue).length === 0 || Array.isArray(typeValue) && typeValue.length === 0)) {
|
|
1963
|
+
pushKeywordTypeError(
|
|
1964
|
+
diagnostics,
|
|
1965
|
+
appendJsonPath(path, "@type"),
|
|
1966
|
+
"@type must be a non-empty string or array of strings."
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
if (value["@id"] !== void 0 && typeof value["@id"] !== "string") {
|
|
1970
|
+
pushKeywordTypeError(
|
|
1971
|
+
diagnostics,
|
|
1972
|
+
appendJsonPath(path, "@id"),
|
|
1973
|
+
"@id must be a string."
|
|
1974
|
+
);
|
|
1975
|
+
}
|
|
1976
|
+
if (value["@graph"] !== void 0 && isJsonObject(value["@graph"]) === false && Array.isArray(value["@graph"]) === false) {
|
|
1977
|
+
pushKeywordTypeError(
|
|
1978
|
+
diagnostics,
|
|
1979
|
+
appendJsonPath(path, "@graph"),
|
|
1980
|
+
"@graph must be an object or array of objects."
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1983
|
+
if (value["@language"] !== void 0 && value["@language"] !== null && typeof value["@language"] !== "string") {
|
|
1984
|
+
pushKeywordTypeError(
|
|
1985
|
+
diagnostics,
|
|
1986
|
+
appendJsonPath(path, "@language"),
|
|
1987
|
+
"@language must be a string or null."
|
|
1988
|
+
);
|
|
1989
|
+
}
|
|
1990
|
+
if (value["@nest"] !== void 0 && isJsonObject(value["@nest"]) === false && (Array.isArray(value["@nest"]) === false || value["@nest"].every(isJsonObject) === false)) {
|
|
1991
|
+
pushKeywordTypeError(
|
|
1992
|
+
diagnostics,
|
|
1993
|
+
appendJsonPath(path, "@nest"),
|
|
1994
|
+
"@nest must be an object or array of objects."
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
if (value["@reverse"] !== void 0 && isJsonObject(value["@reverse"]) === false) {
|
|
1998
|
+
pushKeywordTypeError(
|
|
1999
|
+
diagnostics,
|
|
2000
|
+
appendJsonPath(path, "@reverse"),
|
|
2001
|
+
"@reverse must be an object."
|
|
2002
|
+
);
|
|
2003
|
+
}
|
|
2004
|
+
for (const keyword of ["@index"]) {
|
|
2005
|
+
if (value[keyword] !== void 0 && typeof value[keyword] !== "string") {
|
|
2006
|
+
pushKeywordTypeError(
|
|
2007
|
+
diagnostics,
|
|
2008
|
+
appendJsonPath(path, keyword),
|
|
2009
|
+
`${keyword} must be a string.`
|
|
2010
|
+
);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
if (value["@direction"] !== void 0 && value["@direction"] !== "ltr" && value["@direction"] !== "rtl" && value["@direction"] !== null) {
|
|
2014
|
+
pushKeywordTypeError(
|
|
2015
|
+
diagnostics,
|
|
2016
|
+
appendJsonPath(path, "@direction"),
|
|
2017
|
+
'@direction must be "ltr", "rtl", or null.'
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
if ("@value" in value) {
|
|
2021
|
+
const invalidKeys = ["@id", "@graph", "@list", "@set", "@reverse"].filter(
|
|
2022
|
+
(key) => key in value
|
|
2023
|
+
);
|
|
2024
|
+
const isJsonLiteral = value["@type"] === "@json";
|
|
2025
|
+
const hasStructuredValue = typeof value["@value"] === "object" && value["@value"] !== null;
|
|
2026
|
+
if (invalidKeys.length > 0 || hasStructuredValue && isJsonLiteral === false || "@type" in value && value["@type"] !== "@json" && ("@language" in value || "@direction" in value)) {
|
|
2027
|
+
diagnostics.push({
|
|
2028
|
+
severity: "error",
|
|
2029
|
+
code: "invalid-value-object",
|
|
2030
|
+
path,
|
|
2031
|
+
message: "A JSON-LD value object has an incompatible keyword or @value shape."
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
for (const [property, propertyValue] of Object.entries(value)) {
|
|
2036
|
+
const propertyPath = appendJsonPath(path, property);
|
|
2037
|
+
if (property === "@context") {
|
|
2038
|
+
continue;
|
|
2039
|
+
}
|
|
2040
|
+
if (["@graph", "@included", "@nest", "@reverse"].includes(property)) {
|
|
2041
|
+
validateNode(propertyValue, propertyPath, diagnostics);
|
|
2042
|
+
continue;
|
|
2043
|
+
}
|
|
2044
|
+
if (property.startsWith("@")) {
|
|
2045
|
+
if (["@list", "@set"].includes(property)) {
|
|
2046
|
+
validateNestedValues(propertyValue, propertyPath, diagnostics);
|
|
2047
|
+
}
|
|
2048
|
+
continue;
|
|
2049
|
+
}
|
|
2050
|
+
validateNestedValues(propertyValue, propertyPath, diagnostics);
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
var isJsonLdData = (value, ancestors) => {
|
|
2054
|
+
if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) {
|
|
2055
|
+
return true;
|
|
2056
|
+
}
|
|
2057
|
+
if (typeof value !== "object" || value === null || ancestors.has(value)) {
|
|
2058
|
+
return false;
|
|
2059
|
+
}
|
|
2060
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2061
|
+
if (Array.isArray(value) === false && prototype !== Object.prototype) {
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
2064
|
+
ancestors.add(value);
|
|
2065
|
+
const isValid = Array.isArray(value) ? value.every((item) => isJsonLdData(item, ancestors)) : Object.values(value).every((item) => isJsonLdData(item, ancestors));
|
|
2066
|
+
ancestors.delete(value);
|
|
2067
|
+
return isValid;
|
|
2068
|
+
};
|
|
2069
|
+
var isJsonLdValue = (value) => (Array.isArray(value) || isJsonObject(value)) && isJsonLdData(value, /* @__PURE__ */ new Set());
|
|
2070
|
+
var parseJsonLd = (input2) => {
|
|
2071
|
+
try {
|
|
2072
|
+
const value = typeof input2 === "string" ? JSON.parse(input2) : input2;
|
|
2073
|
+
if (isJsonLdValue(value)) {
|
|
2074
|
+
return { success: true, value };
|
|
2075
|
+
}
|
|
2076
|
+
} catch {
|
|
2077
|
+
}
|
|
2078
|
+
return { success: false };
|
|
2079
|
+
};
|
|
2080
|
+
var validateJsonLd = (input2) => {
|
|
2081
|
+
const parsed = parseJsonLd(input2);
|
|
2082
|
+
if (parsed.success === false) {
|
|
2083
|
+
return {
|
|
2084
|
+
success: false,
|
|
2085
|
+
diagnostics: [
|
|
2086
|
+
{
|
|
2087
|
+
severity: "error",
|
|
2088
|
+
code: typeof input2 === "string" ? "invalid-json" : "invalid-root",
|
|
2089
|
+
path: "$",
|
|
2090
|
+
message: "JSON-LD must be a valid JSON object or array."
|
|
2091
|
+
}
|
|
2092
|
+
]
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
const diagnostics = [];
|
|
2096
|
+
validateNode(parsed.value, "$", diagnostics);
|
|
2097
|
+
if (diagnostics.length > 0) {
|
|
2098
|
+
return { success: false, value: parsed.value, diagnostics };
|
|
2099
|
+
}
|
|
2100
|
+
return { success: true, value: parsed.value, diagnostics };
|
|
2101
|
+
};
|
|
2102
|
+
var hasTopLevelJsonLdContext = (value) => {
|
|
2103
|
+
if (Array.isArray(value)) {
|
|
2104
|
+
return value.some(
|
|
2105
|
+
(item) => typeof item === "object" && item !== null && "@context" in item
|
|
2106
|
+
);
|
|
2107
|
+
}
|
|
2108
|
+
return "@context" in value;
|
|
2109
|
+
};
|
|
2110
|
+
|
|
1790
2111
|
// src/runtime.ts
|
|
1791
2112
|
var tagProperty = "data-ws-tag";
|
|
1792
2113
|
|
|
@@ -2898,14 +3219,20 @@ var generateResources = ({
|
|
|
2898
3219
|
resources: resources2
|
|
2899
3220
|
}) => {
|
|
2900
3221
|
const usedDataSources = /* @__PURE__ */ new Map();
|
|
3222
|
+
const generatedResourceIds = /* @__PURE__ */ new Set();
|
|
2901
3223
|
let generatedRequests = "";
|
|
2902
3224
|
for (const resource3 of resources2.values()) {
|
|
3225
|
+
generatedResourceIds.add(resource3.id);
|
|
2903
3226
|
let generatedRequest = "";
|
|
2904
3227
|
const resourceName = scope.getName(resource3.id, resource3.name);
|
|
2905
3228
|
generatedRequest += ` const ${resourceName}: ResourceRequest = {
|
|
2906
3229
|
`;
|
|
2907
3230
|
generatedRequest += ` name: ${JSON.stringify(resource3.name)},
|
|
2908
3231
|
`;
|
|
3232
|
+
if (resource3.control !== void 0) {
|
|
3233
|
+
generatedRequest += ` control: "${resource3.control}",
|
|
3234
|
+
`;
|
|
3235
|
+
}
|
|
2909
3236
|
const url2 = generateExpression({
|
|
2910
3237
|
expression: resource3.url,
|
|
2911
3238
|
dataSources: dataSources2,
|
|
@@ -2984,7 +3311,7 @@ var generateResources = ({
|
|
|
2984
3311
|
generated += ` const _data = new Map<string, ResourceRequest>([
|
|
2985
3312
|
`;
|
|
2986
3313
|
for (const dataSource2 of dataSources2.values()) {
|
|
2987
|
-
if (dataSource2.type === "resource") {
|
|
3314
|
+
if (dataSource2.type === "resource" && generatedResourceIds.has(dataSource2.resourceId)) {
|
|
2988
3315
|
const name = scope.getName(dataSource2.resourceId, dataSource2.name);
|
|
2989
3316
|
generated += ` ["${name}", ${name}],
|
|
2990
3317
|
`;
|
|
@@ -2995,7 +3322,7 @@ var generateResources = ({
|
|
|
2995
3322
|
generated += ` const _action = new Map<string, ResourceRequest>([
|
|
2996
3323
|
`;
|
|
2997
3324
|
for (const prop2 of props2.values()) {
|
|
2998
|
-
if (prop2.type === "resource") {
|
|
3325
|
+
if (prop2.type === "resource" && generatedResourceIds.has(prop2.value)) {
|
|
2999
3326
|
const name = scope.getName(prop2.value, prop2.name);
|
|
3000
3327
|
generated += ` ["${name}", ${name}],
|
|
3001
3328
|
`;
|
|
@@ -3069,6 +3396,26 @@ var replaceFormActionsWithResources = ({
|
|
|
3069
3396
|
};
|
|
3070
3397
|
|
|
3071
3398
|
// src/page-meta-generator.ts
|
|
3399
|
+
import { parseExpressionAt as parseExpressionAt2 } from "acorn";
|
|
3400
|
+
var normalizeStringExpression = (expression) => {
|
|
3401
|
+
const trimmedExpression = expression.trim();
|
|
3402
|
+
try {
|
|
3403
|
+
const parsedExpression = parseExpressionAt2(trimmedExpression, 0, {
|
|
3404
|
+
ecmaVersion: "latest"
|
|
3405
|
+
});
|
|
3406
|
+
if (parsedExpression.end === trimmedExpression.length) {
|
|
3407
|
+
if (parsedExpression.type === "Identifier" && trimmedExpression !== "undefined" && trimmedExpression.includes("$ws$") === false) {
|
|
3408
|
+
return JSON.stringify(expression);
|
|
3409
|
+
}
|
|
3410
|
+
return expression;
|
|
3411
|
+
}
|
|
3412
|
+
} catch {
|
|
3413
|
+
}
|
|
3414
|
+
if (trimmedExpression.includes("$ws$")) {
|
|
3415
|
+
return expression;
|
|
3416
|
+
}
|
|
3417
|
+
return JSON.stringify(expression);
|
|
3418
|
+
};
|
|
3072
3419
|
var generatePageMeta = ({
|
|
3073
3420
|
globalScope,
|
|
3074
3421
|
page: page2,
|
|
@@ -3078,13 +3425,13 @@ var generatePageMeta = ({
|
|
|
3078
3425
|
const localScope = createScope(["system", "resources"]);
|
|
3079
3426
|
const usedDataSources = /* @__PURE__ */ new Map();
|
|
3080
3427
|
const titleExpression = generateExpression({
|
|
3081
|
-
expression: page2.title,
|
|
3428
|
+
expression: normalizeStringExpression(page2.title),
|
|
3082
3429
|
dataSources: dataSources2,
|
|
3083
3430
|
usedDataSources,
|
|
3084
3431
|
scope: localScope
|
|
3085
3432
|
});
|
|
3086
3433
|
const descriptionExpression = generateExpression({
|
|
3087
|
-
expression: page2.meta.description ?? "undefined",
|
|
3434
|
+
expression: normalizeStringExpression(page2.meta.description ?? "undefined"),
|
|
3088
3435
|
dataSources: dataSources2,
|
|
3089
3436
|
usedDataSources,
|
|
3090
3437
|
scope: localScope
|
|
@@ -3096,7 +3443,7 @@ var generatePageMeta = ({
|
|
|
3096
3443
|
scope: localScope
|
|
3097
3444
|
});
|
|
3098
3445
|
const languageExpression = generateExpression({
|
|
3099
|
-
expression: page2.meta.language ?? "undefined",
|
|
3446
|
+
expression: normalizeStringExpression(page2.meta.language ?? "undefined"),
|
|
3100
3447
|
dataSources: dataSources2,
|
|
3101
3448
|
usedDataSources,
|
|
3102
3449
|
scope: localScope
|
|
@@ -3105,7 +3452,9 @@ var generatePageMeta = ({
|
|
|
3105
3452
|
page2.meta.socialImageAssetId ? assets2.get(page2.meta.socialImageAssetId)?.name : void 0
|
|
3106
3453
|
);
|
|
3107
3454
|
const socialImageUrlExpression = generateExpression({
|
|
3108
|
-
expression:
|
|
3455
|
+
expression: normalizeStringExpression(
|
|
3456
|
+
page2.meta.socialImageUrl ?? "undefined"
|
|
3457
|
+
),
|
|
3109
3458
|
dataSources: dataSources2,
|
|
3110
3459
|
usedDataSources,
|
|
3111
3460
|
scope: localScope
|
|
@@ -3117,13 +3466,13 @@ var generatePageMeta = ({
|
|
|
3117
3466
|
scope: localScope
|
|
3118
3467
|
});
|
|
3119
3468
|
const redirectExpression = generateExpression({
|
|
3120
|
-
expression: page2.meta.redirect ?? "undefined",
|
|
3469
|
+
expression: normalizeStringExpression(page2.meta.redirect ?? "undefined"),
|
|
3121
3470
|
dataSources: dataSources2,
|
|
3122
3471
|
usedDataSources,
|
|
3123
3472
|
scope: localScope
|
|
3124
3473
|
});
|
|
3125
3474
|
const contentExpression = generateExpression({
|
|
3126
|
-
expression: page2.meta.content ?? "undefined",
|
|
3475
|
+
expression: normalizeStringExpression(page2.meta.content ?? "undefined"),
|
|
3127
3476
|
dataSources: dataSources2,
|
|
3128
3477
|
usedDataSources,
|
|
3129
3478
|
scope: localScope
|
|
@@ -3137,7 +3486,7 @@ var generatePageMeta = ({
|
|
|
3137
3486
|
}
|
|
3138
3487
|
const propertyExpression = JSON.stringify(customMeta.property);
|
|
3139
3488
|
const contentExpression2 = generateExpression({
|
|
3140
|
-
expression: customMeta.content,
|
|
3489
|
+
expression: normalizeStringExpression(customMeta.content),
|
|
3141
3490
|
dataSources: dataSources2,
|
|
3142
3491
|
usedDataSources,
|
|
3143
3492
|
scope: localScope
|
|
@@ -3444,6 +3793,132 @@ ${userSheet.cssText}`,
|
|
|
3444
3793
|
classes
|
|
3445
3794
|
};
|
|
3446
3795
|
};
|
|
3796
|
+
|
|
3797
|
+
// src/input-json-schema.ts
|
|
3798
|
+
var unique = (values) => [...new Set(values)];
|
|
3799
|
+
var toInputJsonSchemaObject = (schema) => {
|
|
3800
|
+
if (schema === void 0) {
|
|
3801
|
+
return;
|
|
3802
|
+
}
|
|
3803
|
+
if (schema === true) {
|
|
3804
|
+
return {};
|
|
3805
|
+
}
|
|
3806
|
+
if (schema === false) {
|
|
3807
|
+
return { not: {} };
|
|
3808
|
+
}
|
|
3809
|
+
return schema;
|
|
3810
|
+
};
|
|
3811
|
+
var annotationInputJsonSchemaFields = /* @__PURE__ */ new Set(["description", "default"]);
|
|
3812
|
+
var isUnconstrainedInputJsonSchema = (schema) => Object.entries(schema).every(
|
|
3813
|
+
([field, value]) => value === void 0 || annotationInputJsonSchemaFields.has(field)
|
|
3814
|
+
);
|
|
3815
|
+
var inputJsonSchemaAcceptsType = (schema, type, options = {}) => {
|
|
3816
|
+
if (options.treatUnconstrainedAsAny === true && isUnconstrainedInputJsonSchema(schema)) {
|
|
3817
|
+
return true;
|
|
3818
|
+
}
|
|
3819
|
+
const schemaObject = toInputJsonSchemaObject(schema);
|
|
3820
|
+
if (schemaObject === void 0) {
|
|
3821
|
+
return false;
|
|
3822
|
+
}
|
|
3823
|
+
const types = schemaObject.type === void 0 ? [] : Array.isArray(schemaObject.type) ? schemaObject.type : [schemaObject.type];
|
|
3824
|
+
if (types.includes(type)) {
|
|
3825
|
+
return true;
|
|
3826
|
+
}
|
|
3827
|
+
if (type === "object" && (schemaObject.properties !== void 0 || schemaObject.required !== void 0 || schemaObject.additionalProperties !== void 0)) {
|
|
3828
|
+
return true;
|
|
3829
|
+
}
|
|
3830
|
+
if (type === "array" && (schemaObject.items !== void 0 || schemaObject.prefixItems !== void 0 || schemaObject.minItems !== void 0 || schemaObject.maxItems !== void 0)) {
|
|
3831
|
+
return true;
|
|
3832
|
+
}
|
|
3833
|
+
for (const combinator of ["anyOf", "oneOf"]) {
|
|
3834
|
+
if (schemaObject[combinator] !== void 0) {
|
|
3835
|
+
return schemaObject[combinator].some((item) => {
|
|
3836
|
+
const itemSchema = toInputJsonSchemaObject(item);
|
|
3837
|
+
return itemSchema === void 0 ? false : inputJsonSchemaAcceptsType(itemSchema, type, options);
|
|
3838
|
+
});
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3841
|
+
if (schemaObject.allOf !== void 0) {
|
|
3842
|
+
return schemaObject.allOf.length > 0 && schemaObject.allOf.every((item) => {
|
|
3843
|
+
const itemSchema = toInputJsonSchemaObject(item);
|
|
3844
|
+
return itemSchema === void 0 ? false : inputJsonSchemaAcceptsType(itemSchema, type, options);
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3847
|
+
return false;
|
|
3848
|
+
};
|
|
3849
|
+
var combineInputJsonSchemas = (left, right, combinator) => ({ [combinator]: [left, right] });
|
|
3850
|
+
var inputJsonSchemaCombinators = ["anyOf", "oneOf", "allOf"];
|
|
3851
|
+
var collectInputJsonSchemaBranchValue = (schema, readValue, combineValues) => {
|
|
3852
|
+
let value = readValue(schema);
|
|
3853
|
+
for (const combinator of inputJsonSchemaCombinators) {
|
|
3854
|
+
for (const item of schema?.[combinator] ?? []) {
|
|
3855
|
+
const itemSchema = toInputJsonSchemaObject(item);
|
|
3856
|
+
const itemValue = collectInputJsonSchemaBranchValue(
|
|
3857
|
+
itemSchema,
|
|
3858
|
+
readValue,
|
|
3859
|
+
combineValues
|
|
3860
|
+
);
|
|
3861
|
+
if (itemValue !== void 0) {
|
|
3862
|
+
value = value === void 0 ? itemValue : combineValues(value, itemValue, combinator);
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
return value;
|
|
3867
|
+
};
|
|
3868
|
+
var mergeInputJsonSchemaProperties = (left, right, combinator) => {
|
|
3869
|
+
const result = { ...left };
|
|
3870
|
+
for (const [field, schema] of Object.entries(right)) {
|
|
3871
|
+
const current = result[field];
|
|
3872
|
+
result[field] = current === void 0 ? schema : combineInputJsonSchemas(current, schema, combinator);
|
|
3873
|
+
}
|
|
3874
|
+
return result;
|
|
3875
|
+
};
|
|
3876
|
+
var getInputJsonSchemaProperties = (schema) => collectInputJsonSchemaBranchValue(
|
|
3877
|
+
schema,
|
|
3878
|
+
(schema2) => {
|
|
3879
|
+
const properties = Object.entries(schema2?.properties ?? {}).flatMap(
|
|
3880
|
+
([field, value]) => {
|
|
3881
|
+
const valueSchema = toInputJsonSchemaObject(value);
|
|
3882
|
+
return valueSchema === void 0 ? [] : [[field, valueSchema]];
|
|
3883
|
+
}
|
|
3884
|
+
);
|
|
3885
|
+
return properties.length === 0 ? void 0 : Object.fromEntries(properties);
|
|
3886
|
+
},
|
|
3887
|
+
mergeInputJsonSchemaProperties
|
|
3888
|
+
);
|
|
3889
|
+
var getInputJsonSchemaAdditionalProperties = (schema) => collectInputJsonSchemaBranchValue(
|
|
3890
|
+
schema,
|
|
3891
|
+
(schema2) => typeof schema2?.additionalProperties === "object" ? schema2.additionalProperties : schema2?.additionalProperties === true ? {} : void 0,
|
|
3892
|
+
combineInputJsonSchemas
|
|
3893
|
+
);
|
|
3894
|
+
var intersectStrings = (left, right) => left.filter((value) => right.includes(value));
|
|
3895
|
+
var getInputJsonSchemaRequiredFields = (schema) => {
|
|
3896
|
+
if (schema === void 0) {
|
|
3897
|
+
return [];
|
|
3898
|
+
}
|
|
3899
|
+
const allOfRequired = schema.allOf?.map(toInputJsonSchemaObject).filter((schema2) => schema2 !== void 0).flatMap(getInputJsonSchemaRequiredFields);
|
|
3900
|
+
const anyBranchSchemas = [...schema.anyOf ?? [], ...schema.oneOf ?? []].map(toInputJsonSchemaObject).filter((schema2) => schema2 !== void 0);
|
|
3901
|
+
const anyOfRequired = anyBranchSchemas.length === 0 ? void 0 : anyBranchSchemas.map(getInputJsonSchemaRequiredFields).reduce(intersectStrings);
|
|
3902
|
+
return unique([
|
|
3903
|
+
...schema.required ?? [],
|
|
3904
|
+
...allOfRequired ?? [],
|
|
3905
|
+
...anyOfRequired ?? []
|
|
3906
|
+
]);
|
|
3907
|
+
};
|
|
3908
|
+
var getInputJsonSchemaMetadata = (inputSchema) => {
|
|
3909
|
+
const properties = getInputJsonSchemaProperties(inputSchema) ?? {};
|
|
3910
|
+
return {
|
|
3911
|
+
inputFields: Object.keys(properties),
|
|
3912
|
+
requiredInputFields: getInputJsonSchemaRequiredFields(inputSchema).filter(
|
|
3913
|
+
(field) => field in properties
|
|
3914
|
+
),
|
|
3915
|
+
inputFieldTypes: Object.fromEntries(
|
|
3916
|
+
Object.entries(properties).flatMap(
|
|
3917
|
+
([field, schema]) => inputJsonSchemaAcceptsType(schema, "array") ? [[field, "array"]] : []
|
|
3918
|
+
)
|
|
3919
|
+
)
|
|
3920
|
+
};
|
|
3921
|
+
};
|
|
3447
3922
|
export {
|
|
3448
3923
|
ALLOWED_FILE_EXTENSIONS,
|
|
3449
3924
|
ALLOWED_FILE_TYPES,
|
|
@@ -3497,6 +3972,7 @@ export {
|
|
|
3497
3972
|
elementComponent,
|
|
3498
3973
|
encodeDataVariableId as encodeDataSourceVariable,
|
|
3499
3974
|
encodeDataVariableId,
|
|
3975
|
+
escapeJsonLdScriptText,
|
|
3500
3976
|
executeExpression,
|
|
3501
3977
|
expressionChild,
|
|
3502
3978
|
fileAsset,
|
|
@@ -3524,20 +4000,30 @@ export {
|
|
|
3524
4000
|
getHtmlTagFromInstance,
|
|
3525
4001
|
getHtmlTagsFromProps,
|
|
3526
4002
|
getIndexesWithinAncestors,
|
|
4003
|
+
getInputJsonSchemaAdditionalProperties,
|
|
4004
|
+
getInputJsonSchemaMetadata,
|
|
4005
|
+
getInputJsonSchemaProperties,
|
|
3527
4006
|
getMimeTypeByExtension,
|
|
3528
4007
|
getMimeTypeByFilename,
|
|
3529
4008
|
getPageById,
|
|
3530
4009
|
getPagePath,
|
|
3531
4010
|
getStaticSiteMapXml,
|
|
3532
4011
|
getStyleDeclKey,
|
|
4012
|
+
hasTopLevelJsonLdContext,
|
|
3533
4013
|
homePagePath,
|
|
3534
4014
|
idChild,
|
|
3535
4015
|
imageAsset,
|
|
3536
4016
|
imageMeta,
|
|
3537
4017
|
initialBreakpoints,
|
|
4018
|
+
inputJsonSchemaAcceptsType,
|
|
3538
4019
|
insetUnitValue,
|
|
3539
4020
|
instance,
|
|
4021
|
+
instanceAttributes,
|
|
3540
4022
|
instanceChild,
|
|
4023
|
+
instanceComponent,
|
|
4024
|
+
instanceCreateInput,
|
|
4025
|
+
instanceFilterInput,
|
|
4026
|
+
instanceTag,
|
|
3541
4027
|
instances,
|
|
3542
4028
|
isAbsoluteUrl,
|
|
3543
4029
|
isAllowedExtension,
|
|
@@ -3553,6 +4039,7 @@ export {
|
|
|
3553
4039
|
isRootFolder,
|
|
3554
4040
|
lintExpression,
|
|
3555
4041
|
matchPathnameParams,
|
|
4042
|
+
normalizeComponentCategory,
|
|
3556
4043
|
page,
|
|
3557
4044
|
pageAuth,
|
|
3558
4045
|
pageId,
|
|
@@ -3563,6 +4050,7 @@ export {
|
|
|
3563
4050
|
pageTitle,
|
|
3564
4051
|
pages,
|
|
3565
4052
|
parseComponentName,
|
|
4053
|
+
parseJsonLd,
|
|
3566
4054
|
parseObjectExpression,
|
|
3567
4055
|
portalComponent,
|
|
3568
4056
|
presetStyleDecl,
|
|
@@ -3580,6 +4068,7 @@ export {
|
|
|
3580
4068
|
resources,
|
|
3581
4069
|
rootComponent,
|
|
3582
4070
|
scrollAnimation,
|
|
4071
|
+
shouldFilterComponentCategory,
|
|
3583
4072
|
styleDecl,
|
|
3584
4073
|
styleSource,
|
|
3585
4074
|
styleSourceSelection,
|
|
@@ -3590,9 +4079,12 @@ export {
|
|
|
3590
4079
|
tags,
|
|
3591
4080
|
templates,
|
|
3592
4081
|
textChild,
|
|
4082
|
+
textChildValue,
|
|
4083
|
+
toInputJsonSchemaObject,
|
|
3593
4084
|
toRuntimeAsset,
|
|
3594
4085
|
transpileExpression,
|
|
3595
4086
|
validateFileName,
|
|
4087
|
+
validateJsonLd,
|
|
3596
4088
|
viewAnimation,
|
|
3597
4089
|
webstudioFragment,
|
|
3598
4090
|
wsComponentMeta
|