@constela/compiler 0.15.3 → 0.15.5
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/dist/index.js +71 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -274,6 +274,16 @@ function validateExpression(expr, path, context, scope, paramScope) {
|
|
|
274
274
|
}
|
|
275
275
|
break;
|
|
276
276
|
}
|
|
277
|
+
case "concat": {
|
|
278
|
+
const concatExpr = expr;
|
|
279
|
+
for (let i = 0; i < concatExpr.items.length; i++) {
|
|
280
|
+
const item = concatExpr.items[i];
|
|
281
|
+
if (item) {
|
|
282
|
+
errors.push(...validateExpression(item, buildPath(path, "items", i), context, scope, paramScope));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
277
287
|
}
|
|
278
288
|
return errors;
|
|
279
289
|
}
|
|
@@ -642,6 +652,16 @@ function validateExpressionStateOnly(expr, path, context) {
|
|
|
642
652
|
}
|
|
643
653
|
break;
|
|
644
654
|
}
|
|
655
|
+
case "concat": {
|
|
656
|
+
const concatExpr = expr;
|
|
657
|
+
for (let i = 0; i < concatExpr.items.length; i++) {
|
|
658
|
+
const item = concatExpr.items[i];
|
|
659
|
+
if (item) {
|
|
660
|
+
errors.push(...validateExpressionStateOnly(item, buildPath(path, "items", i), context));
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
645
665
|
}
|
|
646
666
|
return errors;
|
|
647
667
|
}
|
|
@@ -788,6 +808,16 @@ function validateExpressionInEventPayload(expr, path, context, scope) {
|
|
|
788
808
|
}
|
|
789
809
|
break;
|
|
790
810
|
}
|
|
811
|
+
case "concat": {
|
|
812
|
+
const concatExpr = expr;
|
|
813
|
+
for (let i = 0; i < concatExpr.items.length; i++) {
|
|
814
|
+
const item = concatExpr.items[i];
|
|
815
|
+
if (item) {
|
|
816
|
+
errors.push(...validateExpressionInEventPayload(item, buildPath(path, "items", i), context, scope));
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
791
821
|
}
|
|
792
822
|
return errors;
|
|
793
823
|
}
|
|
@@ -980,9 +1010,31 @@ function validateComponentProps(node, componentDef, path, context, scope, paramS
|
|
|
980
1010
|
}
|
|
981
1011
|
}
|
|
982
1012
|
for (const [propName, propValue] of Object.entries(providedProps)) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1013
|
+
const propPath = buildPath(path, "props", propName);
|
|
1014
|
+
if (isEventHandler(propValue)) {
|
|
1015
|
+
const isGlobalAction = context.actionNames.has(propValue.action);
|
|
1016
|
+
const isLocalAction = paramScope?.localActionNames?.has(propValue.action) ?? false;
|
|
1017
|
+
if (!isGlobalAction && !isLocalAction) {
|
|
1018
|
+
const availableNames = /* @__PURE__ */ new Set([
|
|
1019
|
+
...context.actionNames,
|
|
1020
|
+
...paramScope?.localActionNames ?? []
|
|
1021
|
+
]);
|
|
1022
|
+
const errorOptions = createErrorOptionsWithSuggestion(propValue.action, availableNames);
|
|
1023
|
+
errors.push(createUndefinedActionError(propValue.action, propPath, errorOptions));
|
|
1024
|
+
}
|
|
1025
|
+
if (propValue.payload) {
|
|
1026
|
+
errors.push(
|
|
1027
|
+
...validateExpressionInEventPayload(
|
|
1028
|
+
propValue.payload,
|
|
1029
|
+
buildPath(propPath, "payload"),
|
|
1030
|
+
context,
|
|
1031
|
+
scope
|
|
1032
|
+
)
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
} else {
|
|
1036
|
+
errors.push(...validateExpression(propValue, propPath, context, scope, paramScope));
|
|
1037
|
+
}
|
|
986
1038
|
}
|
|
987
1039
|
return errors;
|
|
988
1040
|
}
|
|
@@ -1306,6 +1358,9 @@ function transformExpression(expr, ctx) {
|
|
|
1306
1358
|
case "param": {
|
|
1307
1359
|
const paramValue = ctx.currentParams?.[expr.name];
|
|
1308
1360
|
if (paramValue !== void 0) {
|
|
1361
|
+
if ("event" in paramValue) {
|
|
1362
|
+
return paramValue;
|
|
1363
|
+
}
|
|
1309
1364
|
if (expr.path) {
|
|
1310
1365
|
if (paramValue.expr === "var") {
|
|
1311
1366
|
const existingPath = paramValue.path;
|
|
@@ -1877,8 +1932,12 @@ function transformViewNode(node, ctx) {
|
|
|
1877
1932
|
}
|
|
1878
1933
|
const params = {};
|
|
1879
1934
|
if (node.props) {
|
|
1880
|
-
for (const [name,
|
|
1881
|
-
|
|
1935
|
+
for (const [name, propValue] of Object.entries(node.props)) {
|
|
1936
|
+
if (isEventHandler2(propValue)) {
|
|
1937
|
+
params[name] = transformEventHandler(propValue, ctx);
|
|
1938
|
+
} else {
|
|
1939
|
+
params[name] = transformExpression(propValue, ctx);
|
|
1940
|
+
}
|
|
1882
1941
|
}
|
|
1883
1942
|
}
|
|
1884
1943
|
const children = [];
|
|
@@ -2513,6 +2572,13 @@ function transformExpression2(expr, ctx) {
|
|
|
2513
2572
|
elements: arrayExpr.elements.map((elem) => transformExpression2(elem, ctx))
|
|
2514
2573
|
};
|
|
2515
2574
|
}
|
|
2575
|
+
case "concat": {
|
|
2576
|
+
const concatExpr = expr;
|
|
2577
|
+
return {
|
|
2578
|
+
expr: "concat",
|
|
2579
|
+
items: concatExpr.items.map((item) => transformExpression2(item, ctx))
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2516
2582
|
default:
|
|
2517
2583
|
return { expr: "lit", value: null };
|
|
2518
2584
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/compiler",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
4
4
|
"description": "Compiler for Constela UI framework - AST to Program transformation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@constela/core": "0.17.
|
|
18
|
+
"@constela/core": "0.17.4"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.10.0",
|