@webstudio-is/sdk 0.230.0 → 0.231.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 CHANGED
@@ -1905,6 +1905,19 @@ 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
+ "at",
1913
+ "endsWith",
1914
+ "includes",
1915
+ "startsWith",
1916
+ "toUpperCase",
1917
+ "toLocaleLowerCase",
1918
+ "toLocaleUpperCase"
1919
+ ]);
1920
+ var allowedArrayMethods = /* @__PURE__ */ new Set(["at", "includes", "join", "slice"]);
1908
1921
  var lintExpression = ({
1909
1922
  expression,
1910
1923
  availableVariables = /* @__PURE__ */ new Set(),
@@ -1990,7 +2003,25 @@ var lintExpression = ({
1990
2003
  ThisExpression: addMessage(`"this" keyword is not supported`),
1991
2004
  FunctionExpression: addMessage("Functions are not supported"),
1992
2005
  UpdateExpression: addMessage("Increment and decrement are not supported"),
1993
- CallExpression: addMessage("Functions are not supported"),
2006
+ CallExpression(node) {
2007
+ let calleeName;
2008
+ if (node.callee.type === "MemberExpression") {
2009
+ if (node.callee.property.type === "Identifier") {
2010
+ const methodName = node.callee.property.name;
2011
+ if (allowedStringMethods.has(methodName) || allowedArrayMethods.has(methodName)) {
2012
+ return;
2013
+ }
2014
+ calleeName = methodName;
2015
+ }
2016
+ } else if (node.callee.type === "Identifier") {
2017
+ calleeName = node.callee.name;
2018
+ }
2019
+ if (calleeName) {
2020
+ addMessage(`"${calleeName}" function is not supported`)(node);
2021
+ } else {
2022
+ addMessage("Functions are not supported")(node);
2023
+ }
2024
+ },
1994
2025
  NewExpression: addMessage("Classes are not supported"),
1995
2026
  SequenceExpression: addMessage(`Only single expression is supported`),
1996
2027
  ArrowFunctionExpression: addMessage("Functions are not supported"),
@@ -2104,6 +2135,17 @@ var transpileExpression = ({
2104
2135
  const dotIndex = expression.indexOf("[", node.object.end);
2105
2136
  replacements.push([dotIndex, dotIndex, "?."]);
2106
2137
  }
2138
+ },
2139
+ CallExpression(node) {
2140
+ if (executable === false || node.optional) {
2141
+ return;
2142
+ }
2143
+ if (node.callee.type === "MemberExpression") {
2144
+ const openParenIndex = expression.indexOf("(", node.callee.end);
2145
+ if (openParenIndex !== -1) {
2146
+ replacements.push([openParenIndex, openParenIndex, "?."]);
2147
+ }
2148
+ }
2107
2149
  }
2108
2150
  });
2109
2151
  replacements.sort(([leftStart], [rightStart]) => rightStart - leftStart);
@@ -2895,6 +2937,8 @@ export {
2895
2937
  WebstudioFragment,
2896
2938
  WsComponentMeta,
2897
2939
  addFontRules,
2940
+ allowedArrayMethods,
2941
+ allowedStringMethods,
2898
2942
  animationActionSchema,
2899
2943
  animationKeyframeSchema,
2900
2944
  blockComponent,
@@ -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"]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk",
3
- "version": "0.230.0",
3
+ "version": "0.231.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.230.0",
45
- "@webstudio-is/fonts": "0.230.0",
46
- "@webstudio-is/icons": "0.230.0"
44
+ "@webstudio-is/css-engine": "0.231.0",
45
+ "@webstudio-is/fonts": "0.231.0",
46
+ "@webstudio-is/icons": "0.231.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.231.0",
53
53
  "@webstudio-is/tsconfig": "1.0.7"
54
54
  },
55
55
  "scripts": {