@constela/compiler 0.15.5 → 0.15.7
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.d.ts +6 -2
- package/dist/index.js +18 -5
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -445,7 +445,7 @@ interface CompiledPortalNode {
|
|
|
445
445
|
target: 'body' | 'head' | string;
|
|
446
446
|
children: CompiledNode[];
|
|
447
447
|
}
|
|
448
|
-
type CompiledExpression = CompiledLitExpr | CompiledStateExpr | CompiledVarExpr | CompiledBinExpr | CompiledNotExpr | CompiledCondExpr | CompiledGetExpr | CompiledRouteExpr | CompiledImportExpr | CompiledDataExpr | CompiledRefExpr | CompiledIndexExpr | CompiledParamExpr | CompiledStyleExpr | CompiledConcatExpr | CompiledValidityExpr | CompiledCallExpr | CompiledLambdaExpr | CompiledArrayExpr;
|
|
448
|
+
type CompiledExpression = CompiledLitExpr | CompiledStateExpr | CompiledLocalExpr | CompiledVarExpr | CompiledBinExpr | CompiledNotExpr | CompiledCondExpr | CompiledGetExpr | CompiledRouteExpr | CompiledImportExpr | CompiledDataExpr | CompiledRefExpr | CompiledIndexExpr | CompiledParamExpr | CompiledStyleExpr | CompiledConcatExpr | CompiledValidityExpr | CompiledCallExpr | CompiledLambdaExpr | CompiledArrayExpr;
|
|
449
449
|
interface CompiledLitExpr {
|
|
450
450
|
expr: 'lit';
|
|
451
451
|
value: string | number | boolean | null | unknown[];
|
|
@@ -455,6 +455,10 @@ interface CompiledStateExpr {
|
|
|
455
455
|
name: string;
|
|
456
456
|
path?: string;
|
|
457
457
|
}
|
|
458
|
+
interface CompiledLocalExpr {
|
|
459
|
+
expr: 'local';
|
|
460
|
+
name: string;
|
|
461
|
+
}
|
|
458
462
|
interface CompiledVarExpr {
|
|
459
463
|
expr: 'var';
|
|
460
464
|
name: string;
|
|
@@ -522,7 +526,7 @@ interface CompiledValidityExpr {
|
|
|
522
526
|
}
|
|
523
527
|
interface CompiledCallExpr {
|
|
524
528
|
expr: 'call';
|
|
525
|
-
target: CompiledExpression;
|
|
529
|
+
target: CompiledExpression | null;
|
|
526
530
|
method: string;
|
|
527
531
|
args?: CompiledExpression[];
|
|
528
532
|
}
|
package/dist/index.js
CHANGED
|
@@ -243,7 +243,9 @@ function validateExpression(expr, path, context, scope, paramScope) {
|
|
|
243
243
|
break;
|
|
244
244
|
case "call": {
|
|
245
245
|
const callExpr = expr;
|
|
246
|
-
|
|
246
|
+
if (callExpr.target !== null) {
|
|
247
|
+
errors.push(...validateExpression(callExpr.target, buildPath(path, "target"), context, scope, paramScope));
|
|
248
|
+
}
|
|
247
249
|
if (callExpr.args) {
|
|
248
250
|
for (let i = 0; i < callExpr.args.length; i++) {
|
|
249
251
|
const arg = callExpr.args[i];
|
|
@@ -626,7 +628,9 @@ function validateExpressionStateOnly(expr, path, context) {
|
|
|
626
628
|
break;
|
|
627
629
|
case "call": {
|
|
628
630
|
const callExpr = expr;
|
|
629
|
-
|
|
631
|
+
if (callExpr.target !== null) {
|
|
632
|
+
errors.push(...validateExpressionStateOnly(callExpr.target, buildPath(path, "target"), context));
|
|
633
|
+
}
|
|
630
634
|
if (callExpr.args) {
|
|
631
635
|
for (let i = 0; i < callExpr.args.length; i++) {
|
|
632
636
|
const arg = callExpr.args[i];
|
|
@@ -777,7 +781,9 @@ function validateExpressionInEventPayload(expr, path, context, scope) {
|
|
|
777
781
|
break;
|
|
778
782
|
case "call": {
|
|
779
783
|
const callExpr = expr;
|
|
780
|
-
|
|
784
|
+
if (callExpr.target !== null) {
|
|
785
|
+
errors.push(...validateExpressionInEventPayload(callExpr.target, buildPath(path, "target"), context, scope));
|
|
786
|
+
}
|
|
781
787
|
if (callExpr.args) {
|
|
782
788
|
for (let i = 0; i < callExpr.args.length; i++) {
|
|
783
789
|
const arg = callExpr.args[i];
|
|
@@ -1333,6 +1339,13 @@ function transformExpression(expr, ctx) {
|
|
|
1333
1339
|
}
|
|
1334
1340
|
return stateExpr;
|
|
1335
1341
|
}
|
|
1342
|
+
case "local": {
|
|
1343
|
+
const localExpr = {
|
|
1344
|
+
expr: "local",
|
|
1345
|
+
name: expr.name
|
|
1346
|
+
};
|
|
1347
|
+
return localExpr;
|
|
1348
|
+
}
|
|
1336
1349
|
case "var": {
|
|
1337
1350
|
const varExpr = {
|
|
1338
1351
|
expr: "var",
|
|
@@ -1463,7 +1476,7 @@ function transformExpression(expr, ctx) {
|
|
|
1463
1476
|
const callExpr = expr;
|
|
1464
1477
|
const result = {
|
|
1465
1478
|
expr: "call",
|
|
1466
|
-
target: transformExpression(callExpr.target, ctx),
|
|
1479
|
+
target: callExpr.target === null ? null : transformExpression(callExpr.target, ctx),
|
|
1467
1480
|
method: callExpr.method
|
|
1468
1481
|
};
|
|
1469
1482
|
if (callExpr.args && callExpr.args.length > 0) {
|
|
@@ -2545,7 +2558,7 @@ function transformExpression2(expr, ctx) {
|
|
|
2545
2558
|
const callExpr = expr;
|
|
2546
2559
|
const result = {
|
|
2547
2560
|
expr: "call",
|
|
2548
|
-
target: transformExpression2(callExpr.target, ctx),
|
|
2561
|
+
target: callExpr.target === null ? null : transformExpression2(callExpr.target, ctx),
|
|
2549
2562
|
method: callExpr.method
|
|
2550
2563
|
};
|
|
2551
2564
|
if (callExpr.args && callExpr.args.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/compiler",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.7",
|
|
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.
|
|
18
|
+
"@constela/core": "0.18.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.10.0",
|