@webstudio-is/sdk 0.230.0 → 0.232.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 +46 -1
- package/lib/runtime.js +2 -0
- package/lib/types/expression.d.ts +2 -0
- package/lib/types/resource-loader.d.ts +1 -0
- package/lib/types/schema/pages.d.ts +1 -0
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -1905,6 +1905,20 @@ var systemParameter = {
|
|
|
1905
1905
|
type: "parameter",
|
|
1906
1906
|
name: "system"
|
|
1907
1907
|
};
|
|
1908
|
+
var allowedStringMethods = /* @__PURE__ */ new Set([
|
|
1909
|
+
"toLowerCase",
|
|
1910
|
+
"replace",
|
|
1911
|
+
"split",
|
|
1912
|
+
"slice",
|
|
1913
|
+
"at",
|
|
1914
|
+
"endsWith",
|
|
1915
|
+
"includes",
|
|
1916
|
+
"startsWith",
|
|
1917
|
+
"toUpperCase",
|
|
1918
|
+
"toLocaleLowerCase",
|
|
1919
|
+
"toLocaleUpperCase"
|
|
1920
|
+
]);
|
|
1921
|
+
var allowedArrayMethods = /* @__PURE__ */ new Set(["at", "includes", "join", "slice"]);
|
|
1908
1922
|
var lintExpression = ({
|
|
1909
1923
|
expression,
|
|
1910
1924
|
availableVariables = /* @__PURE__ */ new Set(),
|
|
@@ -1990,7 +2004,25 @@ var lintExpression = ({
|
|
|
1990
2004
|
ThisExpression: addMessage(`"this" keyword is not supported`),
|
|
1991
2005
|
FunctionExpression: addMessage("Functions are not supported"),
|
|
1992
2006
|
UpdateExpression: addMessage("Increment and decrement are not supported"),
|
|
1993
|
-
CallExpression
|
|
2007
|
+
CallExpression(node) {
|
|
2008
|
+
let calleeName;
|
|
2009
|
+
if (node.callee.type === "MemberExpression") {
|
|
2010
|
+
if (node.callee.property.type === "Identifier") {
|
|
2011
|
+
const methodName = node.callee.property.name;
|
|
2012
|
+
if (allowedStringMethods.has(methodName) || allowedArrayMethods.has(methodName)) {
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
calleeName = methodName;
|
|
2016
|
+
}
|
|
2017
|
+
} else if (node.callee.type === "Identifier") {
|
|
2018
|
+
calleeName = node.callee.name;
|
|
2019
|
+
}
|
|
2020
|
+
if (calleeName) {
|
|
2021
|
+
addMessage(`"${calleeName}" function is not supported`)(node);
|
|
2022
|
+
} else {
|
|
2023
|
+
addMessage("Functions are not supported")(node);
|
|
2024
|
+
}
|
|
2025
|
+
},
|
|
1994
2026
|
NewExpression: addMessage("Classes are not supported"),
|
|
1995
2027
|
SequenceExpression: addMessage(`Only single expression is supported`),
|
|
1996
2028
|
ArrowFunctionExpression: addMessage("Functions are not supported"),
|
|
@@ -2104,6 +2136,17 @@ var transpileExpression = ({
|
|
|
2104
2136
|
const dotIndex = expression.indexOf("[", node.object.end);
|
|
2105
2137
|
replacements.push([dotIndex, dotIndex, "?."]);
|
|
2106
2138
|
}
|
|
2139
|
+
},
|
|
2140
|
+
CallExpression(node) {
|
|
2141
|
+
if (executable === false || node.optional) {
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
if (node.callee.type === "MemberExpression") {
|
|
2145
|
+
const openParenIndex = expression.indexOf("(", node.callee.end);
|
|
2146
|
+
if (openParenIndex !== -1) {
|
|
2147
|
+
replacements.push([openParenIndex, openParenIndex, "?."]);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2107
2150
|
}
|
|
2108
2151
|
});
|
|
2109
2152
|
replacements.sort(([leftStart], [rightStart]) => rightStart - leftStart);
|
|
@@ -2895,6 +2938,8 @@ export {
|
|
|
2895
2938
|
WebstudioFragment,
|
|
2896
2939
|
WsComponentMeta,
|
|
2897
2940
|
addFontRules,
|
|
2941
|
+
allowedArrayMethods,
|
|
2942
|
+
allowedStringMethods,
|
|
2898
2943
|
animationActionSchema,
|
|
2899
2944
|
animationKeyframeSchema,
|
|
2900
2945
|
blockComponent,
|
package/lib/runtime.js
CHANGED
|
@@ -38,6 +38,7 @@ var isLocalResource = (pathname, resourceName) => {
|
|
|
38
38
|
return segments.join("/") === `${LOCAL_RESOURCE_PREFIX}/${resourceName}`;
|
|
39
39
|
};
|
|
40
40
|
var sitemapResourceUrl = `/${LOCAL_RESOURCE_PREFIX}/sitemap.xml`;
|
|
41
|
+
var currentDateResourceUrl = `/${LOCAL_RESOURCE_PREFIX}/current-date`;
|
|
41
42
|
var loadResource = async (customFetch, resourceRequest) => {
|
|
42
43
|
try {
|
|
43
44
|
const { method, searchParams, headers, body } = resourceRequest;
|
|
@@ -155,6 +156,7 @@ export {
|
|
|
155
156
|
animationCanPlayOnCanvasProperty,
|
|
156
157
|
cachedFetch,
|
|
157
158
|
createJsonStringifyProxy,
|
|
159
|
+
currentDateResourceUrl,
|
|
158
160
|
formBotFieldName,
|
|
159
161
|
formIdFieldName,
|
|
160
162
|
getIndexWithinAncestorFromProps,
|
|
@@ -9,6 +9,8 @@ export type Diagnostic = {
|
|
|
9
9
|
severity: "error" | "hint" | "info" | "warning";
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
|
+
export declare const allowedStringMethods: Set<string>;
|
|
13
|
+
export declare const allowedArrayMethods: Set<string>;
|
|
12
14
|
export declare const lintExpression: ({ expression, availableVariables, allowAssignment, }: {
|
|
13
15
|
expression: string;
|
|
14
16
|
availableVariables?: Set<Identifier["name"]>;
|
|
@@ -4,6 +4,7 @@ import type { ResourceRequest } from "./schema/resources";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const isLocalResource: (pathname: string, resourceName?: string) => boolean;
|
|
6
6
|
export declare const sitemapResourceUrl = "/$resources/sitemap.xml";
|
|
7
|
+
export declare const currentDateResourceUrl = "/$resources/current-date";
|
|
7
8
|
export declare const loadResource: (customFetch: typeof fetch, resourceRequest: ResourceRequest) => Promise<{
|
|
8
9
|
ok: boolean;
|
|
9
10
|
status: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.232.0",
|
|
4
4
|
"description": "Webstudio project data schema",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"reserved-identifiers": "^1.0.0",
|
|
42
42
|
"type-fest": "^4.37.0",
|
|
43
43
|
"zod": "^3.24.2",
|
|
44
|
-
"@webstudio-is/css-engine": "0.
|
|
45
|
-
"@webstudio-is/fonts": "0.
|
|
46
|
-
"@webstudio-is/icons": "0.
|
|
44
|
+
"@webstudio-is/css-engine": "0.232.0",
|
|
45
|
+
"@webstudio-is/fonts": "0.232.0",
|
|
46
|
+
"@webstudio-is/icons": "0.232.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"html-tags": "^4.0.0",
|
|
50
50
|
"vitest": "^3.1.2",
|
|
51
|
-
"@webstudio-is/template": "0.230.0",
|
|
52
51
|
"@webstudio-is/css-data": "0.0.0",
|
|
52
|
+
"@webstudio-is/template": "0.232.0",
|
|
53
53
|
"@webstudio-is/tsconfig": "1.0.7"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|