@webstudio-is/sdk 0.201.0 → 0.202.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 +24 -17
- package/lib/types/expression.d.ts +3 -0
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -975,13 +975,13 @@ var lintExpression = ({
|
|
|
975
975
|
allowAssignment = false
|
|
976
976
|
}) => {
|
|
977
977
|
const diagnostics = [];
|
|
978
|
-
const
|
|
978
|
+
const addMessage = (message, severity = "error") => {
|
|
979
979
|
return (node) => {
|
|
980
980
|
diagnostics.push({
|
|
981
981
|
// tune error position after wrapping expression with parentheses
|
|
982
982
|
from: node.start - 1,
|
|
983
983
|
to: node.end - 1,
|
|
984
|
-
severity
|
|
984
|
+
severity,
|
|
985
985
|
message
|
|
986
986
|
});
|
|
987
987
|
};
|
|
@@ -1004,7 +1004,10 @@ var lintExpression = ({
|
|
|
1004
1004
|
simple(root, {
|
|
1005
1005
|
Identifier(node) {
|
|
1006
1006
|
if (availableVariables.has(node.name) === false) {
|
|
1007
|
-
|
|
1007
|
+
addMessage(
|
|
1008
|
+
`"${node.name}" is not defined in the scope`,
|
|
1009
|
+
"warning"
|
|
1010
|
+
)(node);
|
|
1008
1011
|
}
|
|
1009
1012
|
},
|
|
1010
1013
|
Literal() {
|
|
@@ -1031,13 +1034,16 @@ var lintExpression = ({
|
|
|
1031
1034
|
},
|
|
1032
1035
|
AssignmentExpression(node) {
|
|
1033
1036
|
if (allowAssignment === false) {
|
|
1034
|
-
|
|
1037
|
+
addMessage("Assignment is supported only inside actions")(node);
|
|
1035
1038
|
return;
|
|
1036
1039
|
}
|
|
1037
1040
|
simple(node.left, {
|
|
1038
1041
|
Identifier(node2) {
|
|
1039
1042
|
if (availableVariables.has(node2.name) === false) {
|
|
1040
|
-
|
|
1043
|
+
addMessage(
|
|
1044
|
+
`"${node2.name}" is not defined in the scope`,
|
|
1045
|
+
"warning"
|
|
1046
|
+
)(node2);
|
|
1041
1047
|
}
|
|
1042
1048
|
}
|
|
1043
1049
|
});
|
|
@@ -1045,18 +1051,18 @@ var lintExpression = ({
|
|
|
1045
1051
|
// parser forbids to yield inside module
|
|
1046
1052
|
YieldExpression() {
|
|
1047
1053
|
},
|
|
1048
|
-
ThisExpression:
|
|
1049
|
-
FunctionExpression:
|
|
1050
|
-
UpdateExpression:
|
|
1051
|
-
CallExpression:
|
|
1052
|
-
NewExpression:
|
|
1053
|
-
SequenceExpression:
|
|
1054
|
-
ArrowFunctionExpression:
|
|
1055
|
-
TaggedTemplateExpression:
|
|
1056
|
-
ClassExpression:
|
|
1057
|
-
MetaProperty:
|
|
1058
|
-
AwaitExpression:
|
|
1059
|
-
ImportExpression:
|
|
1054
|
+
ThisExpression: addMessage(`"this" keyword is not supported`),
|
|
1055
|
+
FunctionExpression: addMessage("Functions are not supported"),
|
|
1056
|
+
UpdateExpression: addMessage("Increment and decrement are not supported"),
|
|
1057
|
+
CallExpression: addMessage("Functions are not supported"),
|
|
1058
|
+
NewExpression: addMessage("Classes are not supported"),
|
|
1059
|
+
SequenceExpression: addMessage(`Only single expression is supported`),
|
|
1060
|
+
ArrowFunctionExpression: addMessage("Functions are not supported"),
|
|
1061
|
+
TaggedTemplateExpression: addMessage("Tagged template is not supported"),
|
|
1062
|
+
ClassExpression: addMessage("Classes are not supported"),
|
|
1063
|
+
MetaProperty: addMessage("Imports are not supported"),
|
|
1064
|
+
AwaitExpression: addMessage(`"await" keyword is not supported`),
|
|
1065
|
+
ImportExpression: addMessage("Imports are not supported")
|
|
1060
1066
|
});
|
|
1061
1067
|
} catch (error) {
|
|
1062
1068
|
const castedError = error;
|
|
@@ -1241,6 +1247,7 @@ var generateExpression = ({
|
|
|
1241
1247
|
usedDataSources?.set(dep.id, dep);
|
|
1242
1248
|
return scope.getName(dep.id, dep.name);
|
|
1243
1249
|
}
|
|
1250
|
+
return "undefined";
|
|
1244
1251
|
}
|
|
1245
1252
|
});
|
|
1246
1253
|
};
|
|
@@ -52,4 +52,7 @@ export declare const generateExpression: ({ expression, dataSources, usedDataSou
|
|
|
52
52
|
usedDataSources: DataSources;
|
|
53
53
|
scope: Scope;
|
|
54
54
|
}) => string;
|
|
55
|
+
/**
|
|
56
|
+
* edge case utility for "statoc" expression without variables
|
|
57
|
+
*/
|
|
55
58
|
export declare const executeExpression: (expression: undefined | string) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.202.0",
|
|
4
4
|
"description": "Webstudio project data schema",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"reserved-identifiers": "^1.0.0",
|
|
40
40
|
"type-fest": "^4.32.0",
|
|
41
41
|
"zod": "^3.22.4",
|
|
42
|
-
"@webstudio-is/
|
|
43
|
-
"@webstudio-is/
|
|
44
|
-
"@webstudio-is/
|
|
42
|
+
"@webstudio-is/css-engine": "0.202.0",
|
|
43
|
+
"@webstudio-is/icons": "0.202.0",
|
|
44
|
+
"@webstudio-is/fonts": "0.202.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"html-tags": "^4.0.0",
|
|
48
48
|
"vitest": "^3.0.2",
|
|
49
49
|
"@webstudio-is/css-data": "0.0.0",
|
|
50
50
|
"@webstudio-is/tsconfig": "1.0.7",
|
|
51
|
-
"@webstudio-is/template": "0.
|
|
51
|
+
"@webstudio-is/template": "0.202.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"typecheck": "tsc",
|