@yannosay/sinth 0.16.1 → 0.17.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 CHANGED
@@ -146,7 +146,7 @@ var int count = 0
146
146
  Main {
147
147
  Heading(level: 1) { count }
148
148
  (alert("Fires only once!")) -- no dependencies, runs once and never again
149
- Button(onClick: count = += 1) { "Increment" }
149
+ Button(onClick: count += 1) { "Increment" }
150
150
  }
151
151
  ```
152
152
  Count updates every click because count changed. The alert fires only on page load — zero dependencies means it's cached forever. Just a meta flag.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "A declarative & reactive language that compiles to pure HTML, CSS, and JavaScript.",
5
5
  "author": "Yannosay Productions",
6
6
  "license": "AGPL-3.0",
@@ -104,9 +104,14 @@ sinthRender();`;
104
104
  continue;
105
105
  }
106
106
 
107
- // component usage
108
- this.pos = savedPos;
109
- uses.push(this.parseCompUse());
107
+ if (nextType === TT.LPAREN && identName[0] === identName[0].toLowerCase()) {
108
+ this.consume(TT.IDENT);
109
+ const expr = this.parseCallExpr({ kind: "variable", name: identName });
110
+ uses.push({ kind: "use", name: "__IF_ROOT__", attrs: [], children: [{ kind: "expr", expression: expr, loc: this.peek().loc }], loc: this.peek().loc });
111
+ } else {
112
+ this.pos = savedPos;
113
+ uses.push(this.parseCompUse());
114
+ }
110
115
  }
111
116
  else throw new SinthError(
112
117
  `Unexpected token '${this.peek().value}' (${TT[this.peek().type]}) at top level`,
@@ -809,19 +814,10 @@ private parseArrayLiteral(): Literal {
809
814
  if (identName[0] === identName[0].toUpperCase() && identName[0] !== identName[0].toLowerCase()) {
810
815
  children.push(this.parseCompUse());
811
816
  } else {
812
- this.consume(TT.IDENT);
813
- this.consume(TT.LPAREN);
814
- const args: Expression[] = [];
815
- if (!this.check(TT.RPAREN)) {
816
- args.push(this.parseExpression()!);
817
- while (this.check(TT.COMMA)) {
818
- this.consume(TT.COMMA);
819
- args.push(this.parseExpression()!);
820
- }
817
+ const expr = this.parseExpression();
818
+ if (expr) {
819
+ children.push({ kind: "expr", expression: expr, loc });
821
820
  }
822
- this.consume(TT.RPAREN);
823
- const callExpr: Expression = { kind: "call", callee: { kind: "variable", name: identName }, args };
824
- children.push({ kind: "expr", expression: callExpr, loc });
825
821
  }
826
822
  continue;
827
823
  }