@constela/compiler 0.13.0 → 0.14.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/README.md +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +37 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ The compiler transforms JSON programs through three passes:
|
|
|
52
52
|
- **WebSocket connections** - Compiles connection definitions and send/close actions
|
|
53
53
|
- **concat expression** - Compiles string concatenation expressions
|
|
54
54
|
- **Object payloads** - Supports object-shaped event handler payloads with expression fields
|
|
55
|
+
- **call/lambda expressions** - Compiles method calls and anonymous functions for array/string/Math/Date operations
|
|
55
56
|
|
|
56
57
|
## CompiledProgram Structure
|
|
57
58
|
|
package/dist/index.d.ts
CHANGED
|
@@ -328,7 +328,7 @@ interface CompiledPortalNode {
|
|
|
328
328
|
target: 'body' | 'head' | string;
|
|
329
329
|
children: CompiledNode[];
|
|
330
330
|
}
|
|
331
|
-
type CompiledExpression = CompiledLitExpr | CompiledStateExpr | CompiledVarExpr | CompiledBinExpr | CompiledNotExpr | CompiledCondExpr | CompiledGetExpr | CompiledRouteExpr | CompiledImportExpr | CompiledDataExpr | CompiledRefExpr | CompiledIndexExpr | CompiledParamExpr | CompiledStyleExpr | CompiledConcatExpr | CompiledValidityExpr | CompiledCallExpr | CompiledLambdaExpr;
|
|
331
|
+
type CompiledExpression = CompiledLitExpr | CompiledStateExpr | CompiledVarExpr | CompiledBinExpr | CompiledNotExpr | CompiledCondExpr | CompiledGetExpr | CompiledRouteExpr | CompiledImportExpr | CompiledDataExpr | CompiledRefExpr | CompiledIndexExpr | CompiledParamExpr | CompiledStyleExpr | CompiledConcatExpr | CompiledValidityExpr | CompiledCallExpr | CompiledLambdaExpr | CompiledArrayExpr;
|
|
332
332
|
interface CompiledLitExpr {
|
|
333
333
|
expr: 'lit';
|
|
334
334
|
value: string | number | boolean | null | unknown[];
|
|
@@ -415,6 +415,10 @@ interface CompiledLambdaExpr {
|
|
|
415
415
|
index?: string;
|
|
416
416
|
body: CompiledExpression;
|
|
417
417
|
}
|
|
418
|
+
interface CompiledArrayExpr {
|
|
419
|
+
expr: 'array';
|
|
420
|
+
elements: CompiledExpression[];
|
|
421
|
+
}
|
|
418
422
|
/**
|
|
419
423
|
* Compiled event handler options for special events like intersect
|
|
420
424
|
*/
|
|
@@ -559,4 +563,4 @@ declare function transformLayoutPass(layout: LayoutProgram, _context: LayoutAnal
|
|
|
559
563
|
*/
|
|
560
564
|
declare function composeLayoutWithPage(layout: CompiledProgram, page: CompiledProgram, layoutParams?: Record<string, Expression>, slots?: Record<string, ViewNode>): CompiledProgram;
|
|
561
565
|
|
|
562
|
-
export { type AnalysisContext, type AnalyzePassFailure, type AnalyzePassResult, type AnalyzePassSuccess, type CompileFailure, type CompileResult, type CompileSuccess, type CompiledAction, type CompiledActionStep, type CompiledBinExpr, type CompiledCallExpr, type CompiledCallStep, type CompiledClearTimerStep, type CompiledClipboardStep, type CompiledCloseStep, type CompiledCodeNode, type CompiledConcatExpr, type CompiledCondExpr, type CompiledDataExpr, type CompiledDelayStep, type CompiledDisposeStep, type CompiledDomStep, type CompiledEachNode, type CompiledElementNode, type CompiledEventHandler, type CompiledEventHandlerOptions, type CompiledExpression, type CompiledFetchStep, type CompiledFocusStep, type CompiledGetExpr, type CompiledIfNode, type CompiledIfStep, type CompiledImportExpr, type CompiledImportStep, type CompiledIndexExpr, type CompiledIntervalStep, type CompiledLambdaExpr, type CompiledLayoutProgram, type CompiledLifecycleHooks, type CompiledLitExpr, type CompiledLocalAction, type CompiledLocalStateNode, type CompiledMarkdownNode, type CompiledNavigateStep, type CompiledNode, type CompiledNotExpr, type CompiledParamExpr, type CompiledPortalNode, type CompiledProgram, type CompiledRefExpr, type CompiledRouteDefinition, type CompiledRouteExpr, type CompiledSendStep, type CompiledSetPathStep, type CompiledSetStep, type CompiledSlotNode, type CompiledStateExpr, type CompiledStorageStep, type CompiledStyleExpr, type CompiledSubscribeStep, type CompiledTextNode, type CompiledUpdateStep, type CompiledValidityExpr, type CompiledVarExpr, type LayoutAnalysisContext, type LayoutAnalysisFailure, type LayoutAnalysisResult, type LayoutAnalysisSuccess, type ValidatePassFailure, type ValidatePassResult, type ValidatePassSuccess, analyzeLayoutPass, analyzePass, compile, composeLayoutWithPage, transformLayoutPass, transformPass, validatePass };
|
|
566
|
+
export { type AnalysisContext, type AnalyzePassFailure, type AnalyzePassResult, type AnalyzePassSuccess, type CompileFailure, type CompileResult, type CompileSuccess, type CompiledAction, type CompiledActionStep, type CompiledArrayExpr, type CompiledBinExpr, type CompiledCallExpr, type CompiledCallStep, type CompiledClearTimerStep, type CompiledClipboardStep, type CompiledCloseStep, type CompiledCodeNode, type CompiledConcatExpr, type CompiledCondExpr, type CompiledDataExpr, type CompiledDelayStep, type CompiledDisposeStep, type CompiledDomStep, type CompiledEachNode, type CompiledElementNode, type CompiledEventHandler, type CompiledEventHandlerOptions, type CompiledExpression, type CompiledFetchStep, type CompiledFocusStep, type CompiledGetExpr, type CompiledIfNode, type CompiledIfStep, type CompiledImportExpr, type CompiledImportStep, type CompiledIndexExpr, type CompiledIntervalStep, type CompiledLambdaExpr, type CompiledLayoutProgram, type CompiledLifecycleHooks, type CompiledLitExpr, type CompiledLocalAction, type CompiledLocalStateNode, type CompiledMarkdownNode, type CompiledNavigateStep, type CompiledNode, type CompiledNotExpr, type CompiledParamExpr, type CompiledPortalNode, type CompiledProgram, type CompiledRefExpr, type CompiledRouteDefinition, type CompiledRouteExpr, type CompiledSendStep, type CompiledSetPathStep, type CompiledSetStep, type CompiledSlotNode, type CompiledStateExpr, type CompiledStorageStep, type CompiledStyleExpr, type CompiledSubscribeStep, type CompiledTextNode, type CompiledUpdateStep, type CompiledValidityExpr, type CompiledVarExpr, type LayoutAnalysisContext, type LayoutAnalysisFailure, type LayoutAnalysisResult, type LayoutAnalysisSuccess, type ValidatePassFailure, type ValidatePassResult, type ValidatePassSuccess, analyzeLayoutPass, analyzePass, compile, composeLayoutWithPage, transformLayoutPass, transformPass, validatePass };
|
package/dist/index.js
CHANGED
|
@@ -262,6 +262,16 @@ function validateExpression(expr, path, context, scope, paramScope) {
|
|
|
262
262
|
errors.push(...validateExpression(lambdaExpr.body, buildPath(path, "body"), context, lambdaScope, paramScope));
|
|
263
263
|
break;
|
|
264
264
|
}
|
|
265
|
+
case "array": {
|
|
266
|
+
const arrayExpr = expr;
|
|
267
|
+
for (let i = 0; i < arrayExpr.elements.length; i++) {
|
|
268
|
+
const elem = arrayExpr.elements[i];
|
|
269
|
+
if (elem) {
|
|
270
|
+
errors.push(...validateExpression(elem, buildPath(path, "elements", i), context, scope, paramScope));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
265
275
|
}
|
|
266
276
|
return errors;
|
|
267
277
|
}
|
|
@@ -620,6 +630,16 @@ function validateExpressionStateOnly(expr, path, context) {
|
|
|
620
630
|
errors.push(...validateExpressionStateOnly(lambdaExpr.body, buildPath(path, "body"), context));
|
|
621
631
|
break;
|
|
622
632
|
}
|
|
633
|
+
case "array": {
|
|
634
|
+
const arrayExpr = expr;
|
|
635
|
+
for (let i = 0; i < arrayExpr.elements.length; i++) {
|
|
636
|
+
const elem = arrayExpr.elements[i];
|
|
637
|
+
if (elem) {
|
|
638
|
+
errors.push(...validateExpressionStateOnly(elem, buildPath(path, "elements", i), context));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
623
643
|
}
|
|
624
644
|
return errors;
|
|
625
645
|
}
|
|
@@ -756,6 +776,16 @@ function validateExpressionInEventPayload(expr, path, context, scope) {
|
|
|
756
776
|
errors.push(...validateExpressionInEventPayload(lambdaExpr.body, buildPath(path, "body"), context, lambdaScope));
|
|
757
777
|
break;
|
|
758
778
|
}
|
|
779
|
+
case "array": {
|
|
780
|
+
const arrayExpr = expr;
|
|
781
|
+
for (let i = 0; i < arrayExpr.elements.length; i++) {
|
|
782
|
+
const elem = arrayExpr.elements[i];
|
|
783
|
+
if (elem) {
|
|
784
|
+
errors.push(...validateExpressionInEventPayload(elem, buildPath(path, "elements", i), context, scope));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
759
789
|
}
|
|
760
790
|
return errors;
|
|
761
791
|
}
|
|
@@ -1345,6 +1375,13 @@ function transformExpression(expr, ctx) {
|
|
|
1345
1375
|
}
|
|
1346
1376
|
return result;
|
|
1347
1377
|
}
|
|
1378
|
+
case "array": {
|
|
1379
|
+
const arrayExpr = expr;
|
|
1380
|
+
return {
|
|
1381
|
+
expr: "array",
|
|
1382
|
+
elements: arrayExpr.elements.map((elem) => transformExpression(elem, ctx))
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1348
1385
|
}
|
|
1349
1386
|
}
|
|
1350
1387
|
function transformEventHandler(handler, ctx) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
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.15.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.10.0",
|