@constela/compiler 0.9.0 → 0.9.1

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 CHANGED
@@ -45,6 +45,12 @@ The compiler transforms JSON programs through three passes:
45
45
  2. **Analyze** - Semantic analysis (state, actions, components, routes)
46
46
  3. **Transform** - AST to optimized runtime program
47
47
 
48
+ ## Supported Features
49
+
50
+ - **setPath** - Compiles to efficient path-based state updates
51
+ - **Key-based each** - Compiles key expressions for list diffing
52
+ - **WebSocket connections** - Compiles connection definitions and send/close actions
53
+
48
54
  ## CompiledProgram Structure
49
55
 
50
56
  ```json
@@ -63,6 +69,13 @@ The compiler transforms JSON programs through three passes:
63
69
  "state": {
64
70
  "count": { "type": "number", "initial": 0 }
65
71
  },
72
+ "connections": {
73
+ "chat": {
74
+ "type": "websocket",
75
+ "url": { ... },
76
+ "onMessage": { "action": "handleMessage" }
77
+ }
78
+ },
66
79
  "actions": {
67
80
  "increment": {
68
81
  "name": "increment",
package/dist/index.d.ts CHANGED
@@ -256,7 +256,7 @@ interface CompiledSlotNode {
256
256
  kind: 'slot';
257
257
  name?: string;
258
258
  }
259
- type CompiledExpression = CompiledLitExpr | CompiledStateExpr | CompiledVarExpr | CompiledBinExpr | CompiledNotExpr | CompiledCondExpr | CompiledGetExpr | CompiledRouteExpr | CompiledImportExpr | CompiledDataExpr | CompiledRefExpr | CompiledIndexExpr | CompiledParamExpr | CompiledStyleExpr;
259
+ type CompiledExpression = CompiledLitExpr | CompiledStateExpr | CompiledVarExpr | CompiledBinExpr | CompiledNotExpr | CompiledCondExpr | CompiledGetExpr | CompiledRouteExpr | CompiledImportExpr | CompiledDataExpr | CompiledRefExpr | CompiledIndexExpr | CompiledParamExpr | CompiledStyleExpr | CompiledConcatExpr;
260
260
  interface CompiledLitExpr {
261
261
  expr: 'lit';
262
262
  value: string | number | boolean | null | unknown[];
@@ -322,10 +322,14 @@ interface CompiledStyleExpr {
322
322
  name: string;
323
323
  variants?: Record<string, CompiledExpression>;
324
324
  }
325
+ interface CompiledConcatExpr {
326
+ expr: 'concat';
327
+ items: CompiledExpression[];
328
+ }
325
329
  interface CompiledEventHandler {
326
330
  event: string;
327
331
  action: string;
328
- payload?: CompiledExpression;
332
+ payload?: CompiledExpression | Record<string, CompiledExpression>;
329
333
  }
330
334
  /**
331
335
  * Transforms the validated and analyzed AST into a CompiledProgram
@@ -455,4 +459,4 @@ declare function transformLayoutPass(layout: LayoutProgram, _context: LayoutAnal
455
459
  */
456
460
  declare function composeLayoutWithPage(layout: CompiledProgram, page: CompiledProgram, layoutParams?: Record<string, Expression>, slots?: Record<string, ViewNode>): CompiledProgram;
457
461
 
458
- export { type AnalysisContext, type AnalyzePassFailure, type AnalyzePassResult, type AnalyzePassSuccess, type CompileFailure, type CompileResult, type CompileSuccess, type CompiledAction, type CompiledActionStep, type CompiledBinExpr, type CompiledCallStep, type CompiledClipboardStep, type CompiledCloseStep, type CompiledCodeNode, type CompiledCondExpr, type CompiledDataExpr, type CompiledDisposeStep, type CompiledDomStep, type CompiledEachNode, type CompiledElementNode, type CompiledEventHandler, type CompiledExpression, type CompiledFetchStep, type CompiledGetExpr, type CompiledIfNode, type CompiledIfStep, type CompiledImportExpr, type CompiledImportStep, type CompiledIndexExpr, type CompiledLayoutProgram, type CompiledLifecycleHooks, type CompiledLitExpr, type CompiledMarkdownNode, type CompiledNavigateStep, type CompiledNode, type CompiledNotExpr, type CompiledProgram, type CompiledRefExpr, type CompiledRouteDefinition, type CompiledRouteExpr, type CompiledSendStep, type CompiledSetPathStep, type CompiledSetStep, type CompiledSlotNode, type CompiledStateExpr, type CompiledStorageStep, type CompiledSubscribeStep, type CompiledTextNode, type CompiledUpdateStep, type CompiledVarExpr, type LayoutAnalysisContext, type LayoutAnalysisFailure, type LayoutAnalysisResult, type LayoutAnalysisSuccess, type ValidatePassFailure, type ValidatePassResult, type ValidatePassSuccess, analyzeLayoutPass, analyzePass, compile, composeLayoutWithPage, transformLayoutPass, transformPass, validatePass };
462
+ export { type AnalysisContext, type AnalyzePassFailure, type AnalyzePassResult, type AnalyzePassSuccess, type CompileFailure, type CompileResult, type CompileSuccess, type CompiledAction, type CompiledActionStep, type CompiledBinExpr, type CompiledCallStep, type CompiledClipboardStep, type CompiledCloseStep, type CompiledCodeNode, type CompiledConcatExpr, type CompiledCondExpr, type CompiledDataExpr, type CompiledDisposeStep, type CompiledDomStep, type CompiledEachNode, type CompiledElementNode, type CompiledEventHandler, type CompiledExpression, type CompiledFetchStep, type CompiledGetExpr, type CompiledIfNode, type CompiledIfStep, type CompiledImportExpr, type CompiledImportStep, type CompiledIndexExpr, type CompiledLayoutProgram, type CompiledLifecycleHooks, type CompiledLitExpr, type CompiledMarkdownNode, type CompiledNavigateStep, type CompiledNode, type CompiledNotExpr, type CompiledParamExpr, 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 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
@@ -1178,6 +1178,11 @@ function transformExpression(expr, ctx) {
1178
1178
  }
1179
1179
  return styleExpr;
1180
1180
  }
1181
+ case "concat":
1182
+ return {
1183
+ expr: "concat",
1184
+ items: expr.items.map((item) => transformExpression(item, ctx))
1185
+ };
1181
1186
  }
1182
1187
  }
1183
1188
  function transformEventHandler(handler, ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/compiler",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
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.9.0"
18
+ "@constela/core": "0.9.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^20.10.0",