rip-lang 3.8.9 → 3.8.10

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/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ All notable changes to Rip will be documented in this file.
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
+ ## [3.8.10] - 2026-02-17
11
+
12
+ ### Compiler — Bug Fix
13
+
14
+ - **Fixed `or throw` variable hoisting bug** — The `x = expr or throw` pattern inside function bodies was erroneously adding the target variable to the program-level `programVars` set. This "poisoned" the variable filter for subsequent sibling functions, causing them to omit local `let` declarations and produce `ReferenceError` at runtime. Most notably, this broke `@rip-lang/api`'s `store` variable when multiple exported functions used the pattern. Fixed by removing the incorrect `programVars.add()` call from `generateAssignment`.
15
+
16
+ ### Schema — New Features
17
+
18
+ - **`Model.fromSchema()` bridge** — ORM models can now auto-configure their schema, table name, and primary key directly from a parsed `.schema` AST via `Model.fromSchema(schema, 'ModelName')`, eliminating manual field re-declaration.
19
+ - **Dependency-ordered SQL DDL** — `emit-sql.js` now topologically sorts tables so foreign key references are always defined before use.
20
+ - **`app-demo.rip` example** — Rewrote the schema demo in Rip (was JavaScript), showcasing TypeScript generation, SQL DDL, and runtime validation from a single `.schema` file.
21
+
10
22
  ## [3.8.9] - 2026-02-16
11
23
 
12
24
  ### Compiler — Grammar Desugaring & Cleanup
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.8.9-blue.svg" alt="Version"></a>
12
+ <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.8.10-blue.svg" alt="Version"></a>
13
13
  <a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
14
14
  <a href="#"><img src="https://img.shields.io/badge/tests-1%2C242%2F1%2C242-brightgreen.svg" alt="Tests"></a>
15
15
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
@@ -17,7 +17,7 @@
17
17
 
18
18
  ---
19
19
 
20
- Rip is a modern language inspired by CoffeeScript. It compiles to **ES2022** (classes, `?.`, `??`, modules), adds about a **dozen new operators**, includes **built-in reactivity**, and sports a self-hosting compiler with **zero dependencies** — all in about 11,000 lines of code.
20
+ Rip is a modern language inspired by CoffeeScript. It compiles to **ES2022** (classes, `?.`, `??`, modules), adds about a **dozen new operators**, includes **built-in reactivity**, and sports a self-hosting compiler with **zero dependencies** — all in under 10,000 lines of code.
21
21
 
22
22
  > **No imports. No hooks. No dependency arrays. Just write code.**
23
23
 
@@ -291,7 +291,7 @@ See [@rip-lang/ui](packages/ui/) for the full framework: file-based router, reac
291
291
  | **Self-hosting** | No | Yes |
292
292
  | **Lexer** | 3,558 LOC | 2,024 LOC |
293
293
  | **Compiler** | 10,346 LOC | 3,289 LOC |
294
- | **Total** | 17,760 LOC | ~11,000 LOC |
294
+ | **Total** | 17,760 LOC | ~9,500 LOC |
295
295
 
296
296
  Smaller codebase, modern output, built-in reactivity.
297
297
 
@@ -354,14 +354,14 @@ Rip includes optional packages for full-stack development:
354
354
 
355
355
  | Package | Version | Purpose |
356
356
  |---------|---------|---------|
357
- | [rip-lang](https://www.npmjs.com/package/rip-lang) | 3.8.9 | Core language compiler |
357
+ | [rip-lang](https://www.npmjs.com/package/rip-lang) | 3.8.10 | Core language compiler |
358
358
  | [@rip-lang/api](packages/api/) | 1.1.6 | HTTP framework (Sinatra-style routing, 37 validators) |
359
359
  | [@rip-lang/server](packages/server/) | 1.1.5 | Multi-worker app server (hot reload, HTTPS, mDNS) |
360
360
  | [@rip-lang/db](packages/db/) | 1.1.4 | DuckDB server with official UI (pure Bun FFI) |
361
361
  | [@rip-lang/ui](packages/ui/) | 0.3.2 | Zero-build reactive web framework (stash, router, hash routing) |
362
362
  | [@rip-lang/swarm](packages/swarm/) | 1.1.3 | Parallel job runner with worker pool |
363
363
  | [@rip-lang/csv](packages/csv/) | 1.1.3 | CSV parser + writer |
364
- | [@rip-lang/schema](packages/schema/) | 0.1.1 | ORM + validation |
364
+ | [@rip-lang/schema](packages/schema/) | 0.2.0 | Unified schema → TypeScript types, SQL DDL, validation, ORM |
365
365
  | [VS Code Extension](packages/vscode/) | 0.3.1 | Syntax highlighting, type intelligence, source maps |
366
366
 
367
367
  ```bash
@@ -145,7 +145,7 @@ _setDataSection();
145
145
 
146
146
  function _setDataSection() {
147
147
  DATA = ${JSON.stringify(this.dataSection)};
148
- }`;return u}generateBinaryOp($,U,A,W){if(($==="+"||$==="-")&&U.length===1)return`(${$}${this.generate(U[0],"value")})`;let[u,f]=U;if($==="*"){let R=u?.valueOf?.()??u;if(typeof R==="string"&&/^["']/.test(R))return`${this.generate(u,"value")}.repeat(${this.generate(f,"value")})`}let Y=new Set(["<",">","<=",">="]);if(Y.has($)&&Array.isArray(u)){let R=u[0]?.valueOf?.()??u[0];if(Y.has(R)){let F=this.generate(u[1],"value"),_=this.generate(u[2],"value"),Z=this.generate(f,"value");return`((${F} ${R} ${_}) && (${_} ${$} ${Z}))`}}if($==="!?"){let R=this.generate(u,"value"),F=this.generate(f,"value");return`(${R} !== undefined ? ${R} : ${F})`}if($==="==")$="===";if($==="!=")$="!==";return`(${this.generate(u,"value")} ${$} ${this.generate(f,"value")})`}generateModulo($,U){let[A,W]=U;return this.helpers.add("modulo"),`modulo(${this.generate(A,"value")}, ${this.generate(W,"value")})`}generateModuloAssign($,U){let[A,W]=U;this.helpers.add("modulo");let u=this.generate(A,"value"),f=this.generate(W,"value");return`${u} = modulo(${u}, ${f})`}generateFloorDiv($,U){let[A,W]=U;return`Math.floor(${this.generate(A,"value")} / ${this.generate(W,"value")})`}generateFloorDivAssign($,U){let[A,W]=U,u=this.generate(A,"value"),f=this.generate(W,"value");return`${u} = Math.floor(${u} / ${f})`}generateAssignment($,U,A,W){let[u,f]=U,Y=$==="?="?"??=":$,R=this.is(f,"->")||this.is(f,"=>")||this.is(f,"def");if(u instanceof String&&j(u,"await")!==void 0&&!R){let X=j(u,"await")===!0?"!":"&";throw Error(`Cannot use ${X} sigil in variable declaration '${S(u)}'.`)}if(u instanceof String&&j(u,"await")===!0&&R)this.nextFunctionIsVoid=!0;let F=this.is(u,"array",0),_=this.is(u,"object",0);if(F||_){let X=this.generate(f,"value");return _&&A==="statement"?`(${X})`:X}if(Array.isArray(f)&&Y==="="&&f[0]==="control"){let[,X,z,w]=f,G=S(X),H=w[0]==="return",q=this.generate(u,"value");if(typeof u==="string")this.programVars.add(u);let O=this.generate(z,"value"),P=w.length>1?w[1]:null,D=H?P?`return ${this.generate(P,"value")}`:"return":P?`throw ${this.generate(P,"value")}`:"throw new Error()";if(A==="value"){if(G==="??")return`(() => { const __v = ${O}; if (__v == null) ${D}; return (${q} = __v); })()`;if(G==="||")return`(() => { const __v = ${O}; if (!__v) ${D}; return (${q} = __v); })()`;return`(() => { const __v = ${O}; if (__v) ${D}; return (${q} = __v); })()`}if(G==="??")return`if ((${q} = ${O}) == null) ${D}`;if(G==="||")return`if (!(${q} = ${O})) ${D}`;return`if ((${q} = ${O})) ${D}`}if(this.is(u,"array")){let X=u.slice(1).findIndex((z)=>this.is(z,"...")||z==="...");if(X!==-1&&X<u.length-2){let z=u.slice(1),w=z.slice(X+1),G=w.length;if(G>0){let H=this.generate(f,"value"),O=z.slice(0,X).map((B)=>B===","?"":typeof B==="string"?B:this.generate(B,"value")).join(", "),P=w.map((B)=>B===","?"":typeof B==="string"?B:this.generate(B,"value")).join(", ");this.helpers.add("slice"),z.forEach((B)=>{if(B===","||B==="...")return;if(typeof B==="string")this.programVars.add(B);else if(this.is(B,"...")&&typeof B[1]==="string")this.programVars.add(B[1])});let D=z[X],I=this.is(D,"...")?D[1]:null,E=[];if(O)E.push(`[${O}] = ${H}`);if(I)E.push(`[...${I}] = ${H}.slice(${X}, -${G})`);return E.push(`[${P}] = slice.call(${H}, -${G})`),E.join(", ")}}}if(A==="statement"&&$==="="&&Array.isArray(f)&&(f[0]==="||"||f[0]==="&&")&&f.length===3){let[X,z,w]=f;if(this.is(w,"if")&&w.length===3){let[,G,H]=w,q=Array.isArray(H)&&H.length===1?H[0]:H,O=[X,z,q],P=this.generate(u,"value"),D=this.generate(G,"value"),I=this.generate(O,"value");return`if (${D}) ${P} = ${I}`}}if(A==="statement"&&$==="="&&Array.isArray(f)&&f.length===3){let[X,z,w]=f,G=Array.isArray(w)&&w.length===1&&(!Array.isArray(w[0])||w[0][0]!=="block");if(X==="if"&&G){let H=Array.isArray(w)&&w.length===1?w[0]:w,q=this.generate(u,"value"),O=this.unwrapLogical(this.generate(z,"value")),P=this.generate(H,"value");return`if (${O}) ${q} = ${P}`}}let Z;if(u instanceof String&&j(u,"await")!==void 0)Z=S(u);else if(typeof u==="string"&&this.reactiveVars?.has(u))Z=`${u}.value`;else this.suppressReactiveUnwrap=!0,Z=this.generate(u,"value"),this.suppressReactiveUnwrap=!1;let Q=this.generate(f,"value");if(!this.is(f,"object"))Q=this.unwrap(Q);let J=A==="value",M=A==="statement"&&this.is(u,"object");if(J||M)return`(${Z} ${Y} ${Q})`;return`${Z} ${Y} ${Q}`}generatePropertyAccess($,U,A,W){let[u,f]=U;if(this._atParamMap&&u==="this"){let _=this._atParamMap.get(S(f));if(_)return _}this.suppressReactiveUnwrap=!0;let Y=this.generate(u,"value");this.suppressReactiveUnwrap=!1;let F=y.NUMBER_LITERAL_RE.test(Y)||Y.startsWith("await ")||(this.is(u,"object")||this.is(u,"yield"))?`(${Y})`:Y;if(j(f,"await")===!0)return`await ${F}.${S(f)}()`;if(j(f,"predicate"))return`(${F}.${S(f)} != null)`;return`${F}.${S(f)}`}generateOptionalProperty($,U){let[A,W]=U;return`${this.generate(A,"value")}?.${W}`}generateRegexIndex($,U){let[A,W,u]=U;this.helpers.add("toMatchable"),this.programVars.add("_");let f=this.generate(A,"value"),Y=this.generate(W,"value"),R=u!==null?this.generate(u,"value"):"0",F=Y.includes("/m")?", true":"";return`(_ = toMatchable(${f}${F}).match(${Y})) && _[${R}]`}generateIndexAccess($,U){let[A,W]=U;if(this.is(W,"..")||this.is(W,"...")){let u=W[0]==="..",f=this.generate(A,"value"),[Y,R]=W.slice(1);if(Y===null&&R===null)return`${f}.slice()`;if(Y===null){if(u&&this.is(R,"-",1)&&(S(R[1])??R[1])==1)return`${f}.slice(0)`;let Z=this.generate(R,"value");return u?`${f}.slice(0, +${Z} + 1 || 9e9)`:`${f}.slice(0, ${Z})`}if(R===null)return`${f}.slice(${this.generate(Y,"value")})`;let F=this.generate(Y,"value");if(u&&this.is(R,"-",1)&&(S(R[1])??R[1])==1)return`${f}.slice(${F})`;let _=this.generate(R,"value");return u?`${f}.slice(${F}, +${_} + 1 || 9e9)`:`${f}.slice(${F}, ${_})`}if(this.is(W,"-",1)){let u=S(W[1])??W[1];if(typeof u==="number"||typeof u==="string"&&/^\d+$/.test(u))return`${this.generate(A,"value")}.at(-${u})`}return`${this.generate(A,"value")}[${this.unwrap(this.generate(W,"value"))}]`}generateOptIndex($,U){let[A,W]=U;if(this.is(W,"-",1)){let u=S(W[1])??W[1];if(typeof u==="number"||typeof u==="string"&&/^\d+$/.test(u))return`${this.generate(A,"value")}?.at(-${u})`}return`${this.generate(A,"value")}?.[${this.generate(W,"value")}]`}generateOptCall($,U){let[A,...W]=U;return`${this.generate(A,"value")}?.(${W.map((u)=>this.generate(u,"value")).join(", ")})`}generateDef($,U,A,W){let[u,f,Y]=U,R=j(u,"await")===!0,F=S(u),_=this.generateParamList(f),Z=this.generateFunctionBody(Y,f,R),Q=this.containsAwait(Y),K=this.containsYield(Y);return`${Q?"async ":""}function${K?"*":""} ${F}(${_}) ${Z}`}generateThinArrow($,U,A,W){let[u,f]=U;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let R=this.generateParamList(u),F=this.generateFunctionBody(f,u,Y),_=this.containsAwait(f),Z=this.containsYield(f),Q=`${_?"async ":""}function${Z?"*":""}(${R}) ${F}`;return A==="value"?`(${Q})`:Q}generateFatArrow($,U,A,W){let[u,f]=U;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let R=this.generateParamList(u),_=u.length===1&&typeof u[0]==="string"&&!R.includes("=")&&!R.includes("...")&&!R.includes("[")&&!R.includes("{")?R:`(${R})`,Q=this.containsAwait(f)?"async ":"";if(!Y){if(this.is(f,"block")&&f.length===2){let J=f[1];if(!Array.isArray(J)||J[0]!=="return")return`${Q}${_} => ${this.generate(J,"value")}`}if(!Array.isArray(f)||f[0]!=="block")return`${Q}${_} => ${this.generate(f,"value")}`}let K=this.generateFunctionBody(f,u,Y);return`${Q}${_} => ${K}`}generateReturn($,U,A,W){if(U.length===0)return"return";let[u]=U;if(this.sideEffectOnly)return"return";if(this.is(u,"if")){let[,f,Y,...R]=u;if(R.length===0){let F=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(F,"value")}`}}if(this.is(u,"new")&&Array.isArray(u[1])&&u[1][0]==="if"){let[,f,Y]=u[1],R=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(["new",R],"value")}`}return`return ${this.generate(u,"value")}`}generateState($,U){let[A,W]=U;this.usesReactivity=!0;let u=S(A)??A;if(!this.reactiveVars)this.reactiveVars=new Set;return this.reactiveVars.add(u),`const ${u} = __state(${this.generate(W,"value")})`}generateComputed($,U){let[A,W]=U;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let u=S(A)??A;return this.reactiveVars.add(u),`const ${u} = __computed(() => ${this.generate(W,"value")})`}generateReadonly($,U){let[A,W]=U;return`const ${S(A)??A} = ${this.generate(W,"value")}`}generateEffect($,U){let[A,W]=U;this.usesReactivity=!0;let u;if(this.is(W,"block"))u=`{
148
+ }`;return u}generateBinaryOp($,U,A,W){if(($==="+"||$==="-")&&U.length===1)return`(${$}${this.generate(U[0],"value")})`;let[u,f]=U;if($==="*"){let R=u?.valueOf?.()??u;if(typeof R==="string"&&/^["']/.test(R))return`${this.generate(u,"value")}.repeat(${this.generate(f,"value")})`}let Y=new Set(["<",">","<=",">="]);if(Y.has($)&&Array.isArray(u)){let R=u[0]?.valueOf?.()??u[0];if(Y.has(R)){let F=this.generate(u[1],"value"),_=this.generate(u[2],"value"),Z=this.generate(f,"value");return`((${F} ${R} ${_}) && (${_} ${$} ${Z}))`}}if($==="!?"){let R=this.generate(u,"value"),F=this.generate(f,"value");return`(${R} !== undefined ? ${R} : ${F})`}if($==="==")$="===";if($==="!=")$="!==";return`(${this.generate(u,"value")} ${$} ${this.generate(f,"value")})`}generateModulo($,U){let[A,W]=U;return this.helpers.add("modulo"),`modulo(${this.generate(A,"value")}, ${this.generate(W,"value")})`}generateModuloAssign($,U){let[A,W]=U;this.helpers.add("modulo");let u=this.generate(A,"value"),f=this.generate(W,"value");return`${u} = modulo(${u}, ${f})`}generateFloorDiv($,U){let[A,W]=U;return`Math.floor(${this.generate(A,"value")} / ${this.generate(W,"value")})`}generateFloorDivAssign($,U){let[A,W]=U,u=this.generate(A,"value"),f=this.generate(W,"value");return`${u} = Math.floor(${u} / ${f})`}generateAssignment($,U,A,W){let[u,f]=U,Y=$==="?="?"??=":$,R=this.is(f,"->")||this.is(f,"=>")||this.is(f,"def");if(u instanceof String&&j(u,"await")!==void 0&&!R){let X=j(u,"await")===!0?"!":"&";throw Error(`Cannot use ${X} sigil in variable declaration '${S(u)}'.`)}if(u instanceof String&&j(u,"await")===!0&&R)this.nextFunctionIsVoid=!0;let F=this.is(u,"array",0),_=this.is(u,"object",0);if(F||_){let X=this.generate(f,"value");return _&&A==="statement"?`(${X})`:X}if(Array.isArray(f)&&Y==="="&&f[0]==="control"){let[,X,z,w]=f,G=S(X),H=w[0]==="return",q=this.generate(u,"value"),O=this.generate(z,"value"),P=w.length>1?w[1]:null,D=H?P?`return ${this.generate(P,"value")}`:"return":P?`throw ${this.generate(P,"value")}`:"throw new Error()";if(A==="value"){if(G==="??")return`(() => { const __v = ${O}; if (__v == null) ${D}; return (${q} = __v); })()`;if(G==="||")return`(() => { const __v = ${O}; if (!__v) ${D}; return (${q} = __v); })()`;return`(() => { const __v = ${O}; if (__v) ${D}; return (${q} = __v); })()`}if(G==="??")return`if ((${q} = ${O}) == null) ${D}`;if(G==="||")return`if (!(${q} = ${O})) ${D}`;return`if ((${q} = ${O})) ${D}`}if(this.is(u,"array")){let X=u.slice(1).findIndex((z)=>this.is(z,"...")||z==="...");if(X!==-1&&X<u.length-2){let z=u.slice(1),w=z.slice(X+1),G=w.length;if(G>0){let H=this.generate(f,"value"),O=z.slice(0,X).map((B)=>B===","?"":typeof B==="string"?B:this.generate(B,"value")).join(", "),P=w.map((B)=>B===","?"":typeof B==="string"?B:this.generate(B,"value")).join(", ");this.helpers.add("slice"),z.forEach((B)=>{if(B===","||B==="...")return;if(typeof B==="string")this.programVars.add(B);else if(this.is(B,"...")&&typeof B[1]==="string")this.programVars.add(B[1])});let D=z[X],I=this.is(D,"...")?D[1]:null,E=[];if(O)E.push(`[${O}] = ${H}`);if(I)E.push(`[...${I}] = ${H}.slice(${X}, -${G})`);return E.push(`[${P}] = slice.call(${H}, -${G})`),E.join(", ")}}}if(A==="statement"&&$==="="&&Array.isArray(f)&&(f[0]==="||"||f[0]==="&&")&&f.length===3){let[X,z,w]=f;if(this.is(w,"if")&&w.length===3){let[,G,H]=w,q=Array.isArray(H)&&H.length===1?H[0]:H,O=[X,z,q],P=this.generate(u,"value"),D=this.generate(G,"value"),I=this.generate(O,"value");return`if (${D}) ${P} = ${I}`}}if(A==="statement"&&$==="="&&Array.isArray(f)&&f.length===3){let[X,z,w]=f,G=Array.isArray(w)&&w.length===1&&(!Array.isArray(w[0])||w[0][0]!=="block");if(X==="if"&&G){let H=Array.isArray(w)&&w.length===1?w[0]:w,q=this.generate(u,"value"),O=this.unwrapLogical(this.generate(z,"value")),P=this.generate(H,"value");return`if (${O}) ${q} = ${P}`}}let Z;if(u instanceof String&&j(u,"await")!==void 0)Z=S(u);else if(typeof u==="string"&&this.reactiveVars?.has(u))Z=`${u}.value`;else this.suppressReactiveUnwrap=!0,Z=this.generate(u,"value"),this.suppressReactiveUnwrap=!1;let Q=this.generate(f,"value");if(!this.is(f,"object"))Q=this.unwrap(Q);let J=A==="value",M=A==="statement"&&this.is(u,"object");if(J||M)return`(${Z} ${Y} ${Q})`;return`${Z} ${Y} ${Q}`}generatePropertyAccess($,U,A,W){let[u,f]=U;if(this._atParamMap&&u==="this"){let _=this._atParamMap.get(S(f));if(_)return _}this.suppressReactiveUnwrap=!0;let Y=this.generate(u,"value");this.suppressReactiveUnwrap=!1;let F=y.NUMBER_LITERAL_RE.test(Y)||Y.startsWith("await ")||(this.is(u,"object")||this.is(u,"yield"))?`(${Y})`:Y;if(j(f,"await")===!0)return`await ${F}.${S(f)}()`;if(j(f,"predicate"))return`(${F}.${S(f)} != null)`;return`${F}.${S(f)}`}generateOptionalProperty($,U){let[A,W]=U;return`${this.generate(A,"value")}?.${W}`}generateRegexIndex($,U){let[A,W,u]=U;this.helpers.add("toMatchable"),this.programVars.add("_");let f=this.generate(A,"value"),Y=this.generate(W,"value"),R=u!==null?this.generate(u,"value"):"0",F=Y.includes("/m")?", true":"";return`(_ = toMatchable(${f}${F}).match(${Y})) && _[${R}]`}generateIndexAccess($,U){let[A,W]=U;if(this.is(W,"..")||this.is(W,"...")){let u=W[0]==="..",f=this.generate(A,"value"),[Y,R]=W.slice(1);if(Y===null&&R===null)return`${f}.slice()`;if(Y===null){if(u&&this.is(R,"-",1)&&(S(R[1])??R[1])==1)return`${f}.slice(0)`;let Z=this.generate(R,"value");return u?`${f}.slice(0, +${Z} + 1 || 9e9)`:`${f}.slice(0, ${Z})`}if(R===null)return`${f}.slice(${this.generate(Y,"value")})`;let F=this.generate(Y,"value");if(u&&this.is(R,"-",1)&&(S(R[1])??R[1])==1)return`${f}.slice(${F})`;let _=this.generate(R,"value");return u?`${f}.slice(${F}, +${_} + 1 || 9e9)`:`${f}.slice(${F}, ${_})`}if(this.is(W,"-",1)){let u=S(W[1])??W[1];if(typeof u==="number"||typeof u==="string"&&/^\d+$/.test(u))return`${this.generate(A,"value")}.at(-${u})`}return`${this.generate(A,"value")}[${this.unwrap(this.generate(W,"value"))}]`}generateOptIndex($,U){let[A,W]=U;if(this.is(W,"-",1)){let u=S(W[1])??W[1];if(typeof u==="number"||typeof u==="string"&&/^\d+$/.test(u))return`${this.generate(A,"value")}?.at(-${u})`}return`${this.generate(A,"value")}?.[${this.generate(W,"value")}]`}generateOptCall($,U){let[A,...W]=U;return`${this.generate(A,"value")}?.(${W.map((u)=>this.generate(u,"value")).join(", ")})`}generateDef($,U,A,W){let[u,f,Y]=U,R=j(u,"await")===!0,F=S(u),_=this.generateParamList(f),Z=this.generateFunctionBody(Y,f,R),Q=this.containsAwait(Y),K=this.containsYield(Y);return`${Q?"async ":""}function${K?"*":""} ${F}(${_}) ${Z}`}generateThinArrow($,U,A,W){let[u,f]=U;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let R=this.generateParamList(u),F=this.generateFunctionBody(f,u,Y),_=this.containsAwait(f),Z=this.containsYield(f),Q=`${_?"async ":""}function${Z?"*":""}(${R}) ${F}`;return A==="value"?`(${Q})`:Q}generateFatArrow($,U,A,W){let[u,f]=U;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let R=this.generateParamList(u),_=u.length===1&&typeof u[0]==="string"&&!R.includes("=")&&!R.includes("...")&&!R.includes("[")&&!R.includes("{")?R:`(${R})`,Q=this.containsAwait(f)?"async ":"";if(!Y){if(this.is(f,"block")&&f.length===2){let J=f[1];if(!Array.isArray(J)||J[0]!=="return")return`${Q}${_} => ${this.generate(J,"value")}`}if(!Array.isArray(f)||f[0]!=="block")return`${Q}${_} => ${this.generate(f,"value")}`}let K=this.generateFunctionBody(f,u,Y);return`${Q}${_} => ${K}`}generateReturn($,U,A,W){if(U.length===0)return"return";let[u]=U;if(this.sideEffectOnly)return"return";if(this.is(u,"if")){let[,f,Y,...R]=u;if(R.length===0){let F=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(F,"value")}`}}if(this.is(u,"new")&&Array.isArray(u[1])&&u[1][0]==="if"){let[,f,Y]=u[1],R=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(["new",R],"value")}`}return`return ${this.generate(u,"value")}`}generateState($,U){let[A,W]=U;this.usesReactivity=!0;let u=S(A)??A;if(!this.reactiveVars)this.reactiveVars=new Set;return this.reactiveVars.add(u),`const ${u} = __state(${this.generate(W,"value")})`}generateComputed($,U){let[A,W]=U;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let u=S(A)??A;return this.reactiveVars.add(u),`const ${u} = __computed(() => ${this.generate(W,"value")})`}generateReadonly($,U){let[A,W]=U;return`const ${S(A)??A} = ${this.generate(W,"value")}`}generateEffect($,U){let[A,W]=U;this.usesReactivity=!0;let u;if(this.is(W,"block"))u=`{
149
149
  ${this.withIndent(()=>this.formatStatements(W.slice(1))).join(`
150
150
  `)}
151
151
  ${this.indent()}}`;else if(this.is(W,"->")||this.is(W,"=>")){let Y=this.generate(W,"value");if(A)return`const ${S(A)??this.generate(A,"value")} = __effect(${Y})`;return`__effect(${Y})`}else u=`{ ${this.generate(W,"value")}; }`;let f=`__effect(() => ${u})`;if(A)return`const ${S(A)??this.generate(A,"value")} = ${f}`;return f}generateBreak(){return"break"}generateContinue(){return"continue"}generateExistential($,U){return`(${this.generate(U[0],"value")} != null)`}generateTernary($,U,A){let[W,u,f]=U;if((u?.[0]?.valueOf?.()??u?.[0])==="="&&Array.isArray(u)){let R=this.generate(u[1],"value"),F=this.generate(u[2],"value"),_=this.generate(f,"value");return`${R} = (${this.unwrap(this.generate(W,"value"))} ? ${F} : ${_})`}return`(${this.unwrap(this.generate(W,"value"))} ? ${this.generate(u,"value")} : ${this.generate(f,"value")})`}generatePipe($,U){let[A,W]=U,u=this.generate(A,"value");if(Array.isArray(W)&&W.length>1){let f=W[0];if(Array.isArray(f)||typeof f==="string"&&/^[a-zA-Z_$]/.test(f)){let R=this.generate(f,"value"),F=W.slice(1).map((_)=>this.generate(_,"value"));return`${R}(${u}, ${F.join(", ")})`}}return`${this.generate(W,"value")}(${u})`}generateLoop($,U){return`while (true) ${this.generateLoopBody(U[0])}`}generateLoopN($,U){let[A,W]=U;return`for (let it = 0; it < ${this.generate(A,"value")}; it++) ${this.generateLoopBody(W)}`}generateAwait($,U){return`await ${this.generate(U[0],"value")}`}generateYield($,U){return U.length===0?"yield":`yield ${this.generate(U[0],"value")}`}generateYieldFrom($,U){return`yield* ${this.generate(U[0],"value")}`}generateIf($,U,A,W){let[u,f,...Y]=U;return A==="value"?this.generateIfAsExpression(u,f,Y):this.generateIfAsStatement(u,f,Y)}generateForIn($,U,A,W){let[u,f,Y,R,F]=U;if(A==="value"&&this.comprehensionDepth===0){let z=["for-in",u,f,Y];return this.generate(["comprehension",F,[z],R?[R]:[]],A)}let _=Array.isArray(u)?u:[u],Z=_.length===0,[Q,K]=Z?["_i",null]:_,J=this.is(Q,"array")||this.is(Q,"object")?this.generateDestructuringPattern(Q):Q;if(Y&&Y!==null){let z=this.generate(f,"value"),w=K||"_i",G=this.generate(Y,"value"),H=this.is(Y,"-",1),q=H&&(Y[1]==="1"||Y[1]===1||S(Y[1])==="1"),O=!H&&(Y==="1"||Y===1||S(Y)==="1"),P;if(q)P=`for (let ${w} = ${z}.length - 1; ${w} >= 0; ${w}--) `;else if(O)P=`for (let ${w} = 0; ${w} < ${z}.length; ${w}++) `;else if(H)P=`for (let ${w} = ${z}.length - 1; ${w} >= 0; ${w} += ${G}) `;else P=`for (let ${w} = 0; ${w} < ${z}.length; ${w} += ${G}) `;if(this.is(F,"block")){let D=F.slice(1);this.indentLevel++;let I=[];if(!Z)I.push(`const ${J} = ${z}[${w}];`);if(R)I.push(`if (${this.generate(R,"value")}) {`),this.indentLevel++,I.push(...this.formatStatements(D)),this.indentLevel--,I.push(this.indent()+"}");else I.push(...D.map((E)=>this.addSemicolon(E,this.generate(E,"statement"))));return this.indentLevel--,P+`{
@@ -507,7 +507,7 @@ if (typeof globalThis !== 'undefined') {
507
507
  `:"",$=A.slice(0,W).join(`
508
508
  `)}let f=new r().tokenize($);if(this.options.showTokens)f.forEach((M)=>console.log(`${M[0].padEnd(12)} ${JSON.stringify(M[1])}`)),console.log();let Y=null,R=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)R=[...f];f=f.filter((M)=>M[0]!=="TYPE_DECL");while(f.length>0&&f[0][0]==="TERMINATOR")f.shift();if(f.every((M)=>M[0]==="TERMINATOR")){if(R)Y=B1(R,["program"]);return{tokens:f,sexpr:["program"],code:"",dts:Y,data:U,reactiveVars:{}}}a.lexer={tokens:f,pos:0,setInput:function(){},lex:function(){if(this.pos>=this.tokens.length)return 1;let M=this.tokens[this.pos++],X=M[1];if(M.data)X=new String(X),Object.assign(X,M.data);return this.text=X,this.loc=M.loc,M[0]}};let F;try{F=a.parse($)}catch(M){if(/\?\s*\([^)]*\?[^)]*:[^)]*\)\s*:/.test($)||/\?\s+\w+\s+\?\s+/.test($))throw Error("Nested ternary operators are not supported. Use if/else statements instead.");throw M}if(this.options.showSExpr)console.log(l(F,0,!0)),console.log();let _=null;if(this.options.sourceMap){let M=(this.options.filename||"output")+".js",X=this.options.filename||"input.rip";_=new S1(M,X,$)}let Z=new y({dataSection:U,skipPreamble:this.options.skipPreamble,reactiveVars:this.options.reactiveVars,sourceMap:_}),Q=Z.compile(F),K=_?_.toJSON():null,J=_?_.toReverseMap():null;if(K&&this.options.sourceMap==="inline"){let M=typeof Buffer<"u"?Buffer.from(K).toString("base64"):btoa(K);Q+=`
509
509
  //# sourceMappingURL=data:application/json;base64,${M}`}else if(K&&this.options.filename)Q+=`
510
- //# sourceMappingURL=${this.options.filename}.js.map`;if(R)Y=B1(R,F);return{tokens:f,sexpr:F,code:Q,dts:Y,map:K,reverseMap:J,data:U,reactiveVars:Z.reactiveVars}}compileToJS($){return this.compile($).code}compileToSExpr($){return this.compile($).sexpr}}_2(y);y.prototype.generateEnum=r1;function L1($,U={}){return new X1(U).compile($)}function i($,U={}){return new X1(U).compileToJS($)}function D1(){return new y({}).getReactiveRuntime()}function V1(){return new y({}).getComponentRuntime()}var N3="3.8.9",T3="2026-02-16@20:02:36GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(D1())();var S3=($)=>{let U=$.match(/^[ \t]*(?=\S)/gm),A=Math.min(...(U||[]).map((W)=>W.length));return $.replace(RegExp(`^[ ]{${A}}`,"gm"),"").trim()};async function J2(){let $=document.querySelectorAll('script[type="text/rip"]');for(let U of $){if(U.hasAttribute("data-rip-processed"))continue;try{let A;if(U.src){let u=await fetch(U.src);if(!u.ok){console.error(`Rip: failed to fetch ${U.src} (${u.status})`);continue}A=await u.text()}else A=S3(U.textContent);let W;try{W=i(A)}catch(u){console.error("Rip compile error:",u.message),console.error("Source:",A);continue}await(0,eval)(`(async()=>{
510
+ //# sourceMappingURL=${this.options.filename}.js.map`;if(R)Y=B1(R,F);return{tokens:f,sexpr:F,code:Q,dts:Y,map:K,reverseMap:J,data:U,reactiveVars:Z.reactiveVars}}compileToJS($){return this.compile($).code}compileToSExpr($){return this.compile($).sexpr}}_2(y);y.prototype.generateEnum=r1;function L1($,U={}){return new X1(U).compile($)}function i($,U={}){return new X1(U).compileToJS($)}function D1(){return new y({}).getReactiveRuntime()}function V1(){return new y({}).getComponentRuntime()}var N3="3.8.10",T3="2026-02-17@02:53:39GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(D1())();var S3=($)=>{let U=$.match(/^[ \t]*(?=\S)/gm),A=Math.min(...(U||[]).map((W)=>W.length));return $.replace(RegExp(`^[ ]{${A}}`,"gm"),"").trim()};async function J2(){let $=document.querySelectorAll('script[type="text/rip"]');for(let U of $){if(U.hasAttribute("data-rip-processed"))continue;try{let A;if(U.src){let u=await fetch(U.src);if(!u.ok){console.error(`Rip: failed to fetch ${U.src} (${u.status})`);continue}A=await u.text()}else A=S3(U.textContent);let W;try{W=i(A)}catch(u){console.error("Rip compile error:",u.message),console.error("Source:",A);continue}await(0,eval)(`(async()=>{
511
511
  ${W}
512
512
  })()`),U.setAttribute("data-rip-processed","true")}catch(A){console.error("Rip runtime error:",A)}}}async function L3($){let U=await fetch($).then((f)=>{if(!f.ok)throw Error(`importRip: ${$} (${f.status})`);return f.text()}),A=i(U),W=new Blob([A],{type:"application/javascript"}),u=URL.createObjectURL(W);try{return await import(u)}finally{URL.revokeObjectURL(u)}}function V3($){try{let U=$.replace(/^/gm," "),W=i(`do ->
513
513
  ${U}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");W=W.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let u=(0,eval)(W);if(u&&typeof u.then==="function")return u.then((f)=>{if(f!==void 0)globalThis._=f;return f});if(u!==void 0)globalThis._=u;return u}catch(U){console.error("Rip compilation error:",U.message);return}}if(typeof globalThis<"u")globalThis.rip=V3,globalThis.importRip=L3,globalThis.compileToJS=i,globalThis.__ripExports={compile:L1,compileToJS:i,formatSExpr:l,VERSION:N3,BUILD_DATE:T3,getReactiveRuntime:D1,getComponentRuntime:V1};if(typeof document<"u")if(document.readyState==="loading")globalThis.__ripScriptsReady=new Promise(($)=>{document.addEventListener("DOMContentLoaded",()=>J2().then($))});else globalThis.__ripScriptsReady=J2();var l1={};b2(l1,{throttle:()=>y3,stash:()=>T2,setContext:()=>E2,raw:()=>S2,launch:()=>c3,isStash:()=>j3,hold:()=>b3,hasContext:()=>O2,getContext:()=>P2,delay:()=>L2,debounce:()=>C3,createRouter:()=>j2,createResource:()=>h3,createRenderer:()=>h2,createComponents:()=>V2});var Q2,y1,s,k,P1,K2,p,h,j1,U1,W1,b1,M2,X2,z1,w1,D2,z2,w2,h1,C1,P2,H2,c1,O2,A1,v1,q2,G2,E2,I2,B2,g1,N2;({__state:h,__effect:p,__batch:K2}=globalThis.__rip);({setContext:E2,getContext:P2,hasContext:O2}=globalThis.__ripComponent||{});P1=Symbol("stash");k=Symbol("signals");s=Symbol("raw");y1=new WeakMap;j1=0;b1=h(0);c1=function($,U){let A;if(!$[k])Object.defineProperty($,k,{value:new Map,enumerable:!1});if(A=$[k].get(U),!A)A=h($[U]),$[k].set(U,A);return A};A1=function($){return c1($,Symbol.for("keys"))};N2=function($){let U;if(!($!=null&&typeof $==="object"))return $;if($[P1])return $;if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Promise)return $;if(U=y1.get($),U)return U;return v1($)};v1=function($){let U,A;return A=null,U={get:function(W,u){let f,Y;if(u===P1)return!0;if(u===s)return W;if(typeof u==="symbol")return Reflect.get(W,u);if(u==="length"&&Array.isArray(W))return A1(W).value,W.length;if(u==="get")return function(R){return I2(A,R)};if(u==="set")return function(R,F){return B2(A,R,F)};if(f=c1(W,u),Y=f.value,Y!=null&&typeof Y==="object")return N2(Y);return Y},set:function(W,u,f){let Y,R;if(Y=W[u],R=f?.[s]?f[s]:f,R===Y)return!0;if(W[u]=R,W[k]?.has(u))W[k].get(u).value=R;if(Y===void 0&&R!==void 0)A1(W).value=++j1;return b1.value++,!0},deleteProperty:function(W,u){let f;if(delete W[u],f=W[k]?.get(u),f)f.value=void 0;return A1(W).value=++j1,!0},ownKeys:function(W){return A1(W).value,Reflect.ownKeys(W)}},A=new Proxy($,U),y1.set($,A),A};Q2=/([./][^./\[\s]+|\[[-+]?\d+\]|\[(?:"[^"]+"|'[^']+')\])/;g1=function($){let U,A,W,u,f;W=("."+$).split(Q2),W.shift(),f=[],A=0;while(A<W.length){if(u=W[A],U=u[0],U==="."||U==="/")f.push(u.slice(1));else if(U==="[")if(u[1]==='"'||u[1]==="'")f.push(u.slice(2,-2));else f.push(+u.slice(1,-1));A+=2}return f};I2=function($,U){let A,W;W=g1(U),A=$;for(let u of W){if(A==null)return;A=A[u]}return A};B2=function($,U,A){let W,u;u=g1(U),W=$;for(let f=0;f<u.length;f++){let Y=u[f];if(f===u.length-1)W[Y]=A;else{if(W[Y]==null)W[Y]={};W=W[Y]}}return A};W1=function($){return typeof $==="function"?$:function(){return $.value}};U1=function($,U){let A;return A={read:function(){return $.read()}},Object.defineProperty(A,"value",{get:function(){return $.value},set:function(W){return U.value=W}}),A};w2=function($){let U;if(U=$.replace(/\.rip$/,""),U=U.replace(/\[\.\.\.(\w+)\]/g,"*$1"),U=U.replace(/\[(\w+)\]/g,":$1"),U==="index")return"/";return U=U.replace(/\/index$/,""),"/"+U};G2=function($){let U,A;return U=[],A=$.replace(/\*(\w+)/g,function(W,u){return U.push(u),"(.+)"}).replace(/:(\w+)/g,function(W,u){return U.push(u),"([^/]+)"}),{regex:new RegExp("^"+A+"$"),names:U}};q2=function($,U){let A,W;for(let u of U)if(A=$.match(u.regex.regex),A){W={};for(let f=0;f<u.regex.names.length;f++){let Y=u.regex.names[f];W[Y]=decodeURIComponent(A[f+1])}return{route:u,params:W}}return null};z1=function($,U="components"){let A,W,u,f,Y,R,F,_;F=[],u=new Map,A=$.listAll(U);for(let Z of A){if(R=Z.slice(U.length+1),!R.endsWith(".rip"))continue;if(f=R.split("/").pop(),f==="_layout.rip"){W=R==="_layout.rip"?"":R.slice(0,-12),u.set(W,Z);continue}if(f.startsWith("_"))continue;_=w2(R),Y=G2(_),F.push({pattern:_,regex:Y,file:Z,rel:R})}return F.sort(function(Z,Q){let K,J,M,X;if(J=(Z.pattern.match(/:/g)||[]).length,X=(Q.pattern.match(/:/g)||[]).length,K=Z.pattern.includes("*")?1:0,M=Q.pattern.includes("*")?1:0,K!==M)return K-M;if(J!==X)return J-X;return Z.pattern.localeCompare(Q.pattern)}),{routes:F,layouts:u}};H2=function($,U,A){let W,u,f,Y;if(W=[],f=$.slice(U.length+1),Y=f.split("/"),u="",A.has(""))W.push(A.get(""));for(let R=0;R<Y.length;R++){let F=Y[R];if(R===Y.length-1)break;if(u=u?u+"/"+F:F,A.has(u))W.push(A.get(u))}return W};M2=function($,U){if($.length!==U.length)return!1;for(let A=0;A<$.length;A++)if($[A]!==U[A])return!1;return!0};C1=function($){for(let U in $){let A=$[U];if(typeof A==="function"&&(A.prototype?.mount||A.prototype?._create))return A}return typeof $.default==="function"?$.default:void 0};h1=function($){let U;U={};for(let A in $){let W=$[A];if(typeof W==="function"&&(W.prototype?.mount||W.prototype?._create))U[A]=W}return U};z2=function($){let U;return U=$.split("/").pop().replace(/\.rip$/,""),U.replace(/(^|[-_])([a-z])/g,function(A,W,u){return u.toUpperCase()})};X2=function($,U="components"){let A,W,u;W={};for(let f of $.listAll(U)){if(!f.endsWith(".rip"))continue;if(A=f.split("/").pop(),A.startsWith("_"))continue;if(u=z2(f),W[u])console.warn(`[Rip] Component name collision: ${u} (${W[u]} vs ${f})`);W[u]=f}return W};w1=async function($,U,A=null,W=null,u=null){let f,Y,R,F,_,Z,Q,K,J,M,X;if(A&&W){if(Y=A.getCompiled(W),Y)return Y}if(Z=U($),u){J={};for(let z in u.map){let w=u.map[z];if(w!==W&&Z.includes(`new ${z}(`)){if(!u.classes[z]){if(F=A.read(w),F){R=await w1(F,U,A,w,u),_=h1(R);for(let G in _){let H=_[G];u.classes[G]=H}}}if(u.classes[z])J[z]=!0}}if(K=Object.keys(J),K.length>0)M=`const {${K.join(", ")}} = globalThis['${u.key}'];
Binary file
@@ -5370,8 +5370,6 @@ function _setDataSection() {
5370
5370
  let ctrlOp = str(rawCtrlOp);
5371
5371
  let isReturn = ctrlSexpr[0] === "return";
5372
5372
  let targetCode2 = this.generate(target, "value");
5373
- if (typeof target === "string")
5374
- this.programVars.add(target);
5375
5373
  let exprCode = this.generate(expr, "value");
5376
5374
  let ctrlValue = ctrlSexpr.length > 1 ? ctrlSexpr[1] : null;
5377
5375
  let ctrlCode = isReturn ? ctrlValue ? `return ${this.generate(ctrlValue, "value")}` : "return" : ctrlValue ? `throw ${this.generate(ctrlValue, "value")}` : "throw new Error()";
@@ -7910,8 +7908,8 @@ function getComponentRuntime() {
7910
7908
  return new CodeGenerator({}).getComponentRuntime();
7911
7909
  }
7912
7910
  // src/browser.js
7913
- var VERSION = "3.8.9";
7914
- var BUILD_DATE = "2026-02-16@20:02:36GMT";
7911
+ var VERSION = "3.8.10";
7912
+ var BUILD_DATE = "2026-02-17@02:53:39GMT";
7915
7913
  if (typeof globalThis !== "undefined" && !globalThis.__rip) {
7916
7914
  new Function(getReactiveRuntime())();
7917
7915
  }
@@ -145,7 +145,7 @@ _setDataSection();
145
145
 
146
146
  function _setDataSection() {
147
147
  DATA = ${JSON.stringify(this.dataSection)};
148
- }`;return A}generateBinaryOp(Y,U,W,F){if((Y==="+"||Y==="-")&&U.length===1)return`(${Y}${this.generate(U[0],"value")})`;let[A,$]=U;if(Y==="*"){let J=A?.valueOf?.()??A;if(typeof J==="string"&&/^["']/.test(J))return`${this.generate(A,"value")}.repeat(${this.generate($,"value")})`}let Z=new Set(["<",">","<=",">="]);if(Z.has(Y)&&Array.isArray(A)){let J=A[0]?.valueOf?.()??A[0];if(Z.has(J)){let Q=this.generate(A[1],"value"),K=this.generate(A[2],"value"),X=this.generate($,"value");return`((${Q} ${J} ${K}) && (${K} ${Y} ${X}))`}}if(Y==="!?"){let J=this.generate(A,"value"),Q=this.generate($,"value");return`(${J} !== undefined ? ${J} : ${Q})`}if(Y==="==")Y="===";if(Y==="!=")Y="!==";return`(${this.generate(A,"value")} ${Y} ${this.generate($,"value")})`}generateModulo(Y,U){let[W,F]=U;return this.helpers.add("modulo"),`modulo(${this.generate(W,"value")}, ${this.generate(F,"value")})`}generateModuloAssign(Y,U){let[W,F]=U;this.helpers.add("modulo");let A=this.generate(W,"value"),$=this.generate(F,"value");return`${A} = modulo(${A}, ${$})`}generateFloorDiv(Y,U){let[W,F]=U;return`Math.floor(${this.generate(W,"value")} / ${this.generate(F,"value")})`}generateFloorDivAssign(Y,U){let[W,F]=U,A=this.generate(W,"value"),$=this.generate(F,"value");return`${A} = Math.floor(${A} / ${$})`}generateAssignment(Y,U,W,F){let[A,$]=U,Z=Y==="?="?"??=":Y,J=this.is($,"->")||this.is($,"=>")||this.is($,"def");if(A instanceof String&&u(A,"await")!==void 0&&!J){let G=u(A,"await")===!0?"!":"&";throw Error(`Cannot use ${G} sigil in variable declaration '${L(A)}'.`)}if(A instanceof String&&u(A,"await")===!0&&J)this.nextFunctionIsVoid=!0;let Q=this.is(A,"array",0),K=this.is(A,"object",0);if(Q||K){let G=this.generate($,"value");return K&&W==="statement"?`(${G})`:G}if(Array.isArray($)&&Z==="="&&$[0]==="control"){let[,G,R,q]=$,B=L(G),I=q[0]==="return",_=this.generate(A,"value");if(typeof A==="string")this.programVars.add(A);let w=this.generate(R,"value"),P=q.length>1?q[1]:null,O=I?P?`return ${this.generate(P,"value")}`:"return":P?`throw ${this.generate(P,"value")}`:"throw new Error()";if(W==="value"){if(B==="??")return`(() => { const __v = ${w}; if (__v == null) ${O}; return (${_} = __v); })()`;if(B==="||")return`(() => { const __v = ${w}; if (!__v) ${O}; return (${_} = __v); })()`;return`(() => { const __v = ${w}; if (__v) ${O}; return (${_} = __v); })()`}if(B==="??")return`if ((${_} = ${w}) == null) ${O}`;if(B==="||")return`if (!(${_} = ${w})) ${O}`;return`if ((${_} = ${w})) ${O}`}if(this.is(A,"array")){let G=A.slice(1).findIndex((R)=>this.is(R,"...")||R==="...");if(G!==-1&&G<A.length-2){let R=A.slice(1),q=R.slice(G+1),B=q.length;if(B>0){let I=this.generate($,"value"),w=R.slice(0,G).map((T)=>T===","?"":typeof T==="string"?T:this.generate(T,"value")).join(", "),P=q.map((T)=>T===","?"":typeof T==="string"?T:this.generate(T,"value")).join(", ");this.helpers.add("slice"),R.forEach((T)=>{if(T===","||T==="...")return;if(typeof T==="string")this.programVars.add(T);else if(this.is(T,"...")&&typeof T[1]==="string")this.programVars.add(T[1])});let O=R[G],N=this.is(O,"...")?O[1]:null,E=[];if(w)E.push(`[${w}] = ${I}`);if(N)E.push(`[...${N}] = ${I}.slice(${G}, -${B})`);return E.push(`[${P}] = slice.call(${I}, -${B})`),E.join(", ")}}}if(W==="statement"&&Y==="="&&Array.isArray($)&&($[0]==="||"||$[0]==="&&")&&$.length===3){let[G,R,q]=$;if(this.is(q,"if")&&q.length===3){let[,B,I]=q,_=Array.isArray(I)&&I.length===1?I[0]:I,w=[G,R,_],P=this.generate(A,"value"),O=this.generate(B,"value"),N=this.generate(w,"value");return`if (${O}) ${P} = ${N}`}}if(W==="statement"&&Y==="="&&Array.isArray($)&&$.length===3){let[G,R,q]=$,B=Array.isArray(q)&&q.length===1&&(!Array.isArray(q[0])||q[0][0]!=="block");if(G==="if"&&B){let I=Array.isArray(q)&&q.length===1?q[0]:q,_=this.generate(A,"value"),w=this.unwrapLogical(this.generate(R,"value")),P=this.generate(I,"value");return`if (${w}) ${_} = ${P}`}}let X;if(A instanceof String&&u(A,"await")!==void 0)X=L(A);else if(typeof A==="string"&&this.reactiveVars?.has(A))X=`${A}.value`;else this.suppressReactiveUnwrap=!0,X=this.generate(A,"value"),this.suppressReactiveUnwrap=!1;let z=this.generate($,"value");if(!this.is($,"object"))z=this.unwrap(z);let D=W==="value",M=W==="statement"&&this.is(A,"object");if(D||M)return`(${X} ${Z} ${z})`;return`${X} ${Z} ${z}`}generatePropertyAccess(Y,U,W,F){let[A,$]=U;if(this._atParamMap&&A==="this"){let K=this._atParamMap.get(L($));if(K)return K}this.suppressReactiveUnwrap=!0;let Z=this.generate(A,"value");this.suppressReactiveUnwrap=!1;let Q=C.NUMBER_LITERAL_RE.test(Z)||Z.startsWith("await ")||(this.is(A,"object")||this.is(A,"yield"))?`(${Z})`:Z;if(u($,"await")===!0)return`await ${Q}.${L($)}()`;if(u($,"predicate"))return`(${Q}.${L($)} != null)`;return`${Q}.${L($)}`}generateOptionalProperty(Y,U){let[W,F]=U;return`${this.generate(W,"value")}?.${F}`}generateRegexIndex(Y,U){let[W,F,A]=U;this.helpers.add("toMatchable"),this.programVars.add("_");let $=this.generate(W,"value"),Z=this.generate(F,"value"),J=A!==null?this.generate(A,"value"):"0",Q=Z.includes("/m")?", true":"";return`(_ = toMatchable(${$}${Q}).match(${Z})) && _[${J}]`}generateIndexAccess(Y,U){let[W,F]=U;if(this.is(F,"..")||this.is(F,"...")){let A=F[0]==="..",$=this.generate(W,"value"),[Z,J]=F.slice(1);if(Z===null&&J===null)return`${$}.slice()`;if(Z===null){if(A&&this.is(J,"-",1)&&(L(J[1])??J[1])==1)return`${$}.slice(0)`;let X=this.generate(J,"value");return A?`${$}.slice(0, +${X} + 1 || 9e9)`:`${$}.slice(0, ${X})`}if(J===null)return`${$}.slice(${this.generate(Z,"value")})`;let Q=this.generate(Z,"value");if(A&&this.is(J,"-",1)&&(L(J[1])??J[1])==1)return`${$}.slice(${Q})`;let K=this.generate(J,"value");return A?`${$}.slice(${Q}, +${K} + 1 || 9e9)`:`${$}.slice(${Q}, ${K})`}if(this.is(F,"-",1)){let A=L(F[1])??F[1];if(typeof A==="number"||typeof A==="string"&&/^\d+$/.test(A))return`${this.generate(W,"value")}.at(-${A})`}return`${this.generate(W,"value")}[${this.unwrap(this.generate(F,"value"))}]`}generateOptIndex(Y,U){let[W,F]=U;if(this.is(F,"-",1)){let A=L(F[1])??F[1];if(typeof A==="number"||typeof A==="string"&&/^\d+$/.test(A))return`${this.generate(W,"value")}?.at(-${A})`}return`${this.generate(W,"value")}?.[${this.generate(F,"value")}]`}generateOptCall(Y,U){let[W,...F]=U;return`${this.generate(W,"value")}?.(${F.map((A)=>this.generate(A,"value")).join(", ")})`}generateDef(Y,U,W,F){let[A,$,Z]=U,J=u(A,"await")===!0,Q=L(A),K=this.generateParamList($),X=this.generateFunctionBody(Z,$,J),z=this.containsAwait(Z),H=this.containsYield(Z);return`${z?"async ":""}function${H?"*":""} ${Q}(${K}) ${X}`}generateThinArrow(Y,U,W,F){let[A,$]=U;if((!A||Array.isArray(A)&&A.length===0)&&this.containsIt($))A=["it"];let Z=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let J=this.generateParamList(A),Q=this.generateFunctionBody($,A,Z),K=this.containsAwait($),X=this.containsYield($),z=`${K?"async ":""}function${X?"*":""}(${J}) ${Q}`;return W==="value"?`(${z})`:z}generateFatArrow(Y,U,W,F){let[A,$]=U;if((!A||Array.isArray(A)&&A.length===0)&&this.containsIt($))A=["it"];let Z=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let J=this.generateParamList(A),K=A.length===1&&typeof A[0]==="string"&&!J.includes("=")&&!J.includes("...")&&!J.includes("[")&&!J.includes("{")?J:`(${J})`,z=this.containsAwait($)?"async ":"";if(!Z){if(this.is($,"block")&&$.length===2){let D=$[1];if(!Array.isArray(D)||D[0]!=="return")return`${z}${K} => ${this.generate(D,"value")}`}if(!Array.isArray($)||$[0]!=="block")return`${z}${K} => ${this.generate($,"value")}`}let H=this.generateFunctionBody($,A,Z);return`${z}${K} => ${H}`}generateReturn(Y,U,W,F){if(U.length===0)return"return";let[A]=U;if(this.sideEffectOnly)return"return";if(this.is(A,"if")){let[,$,Z,...J]=A;if(J.length===0){let Q=Array.isArray(Z)&&Z.length===1?Z[0]:Z;return`if (${this.generate($,"value")}) return ${this.generate(Q,"value")}`}}if(this.is(A,"new")&&Array.isArray(A[1])&&A[1][0]==="if"){let[,$,Z]=A[1],J=Array.isArray(Z)&&Z.length===1?Z[0]:Z;return`if (${this.generate($,"value")}) return ${this.generate(["new",J],"value")}`}return`return ${this.generate(A,"value")}`}generateState(Y,U){let[W,F]=U;this.usesReactivity=!0;let A=L(W)??W;if(!this.reactiveVars)this.reactiveVars=new Set;return this.reactiveVars.add(A),`const ${A} = __state(${this.generate(F,"value")})`}generateComputed(Y,U){let[W,F]=U;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let A=L(W)??W;return this.reactiveVars.add(A),`const ${A} = __computed(() => ${this.generate(F,"value")})`}generateReadonly(Y,U){let[W,F]=U;return`const ${L(W)??W} = ${this.generate(F,"value")}`}generateEffect(Y,U){let[W,F]=U;this.usesReactivity=!0;let A;if(this.is(F,"block"))A=`{
148
+ }`;return A}generateBinaryOp(Y,U,W,F){if((Y==="+"||Y==="-")&&U.length===1)return`(${Y}${this.generate(U[0],"value")})`;let[A,$]=U;if(Y==="*"){let J=A?.valueOf?.()??A;if(typeof J==="string"&&/^["']/.test(J))return`${this.generate(A,"value")}.repeat(${this.generate($,"value")})`}let Z=new Set(["<",">","<=",">="]);if(Z.has(Y)&&Array.isArray(A)){let J=A[0]?.valueOf?.()??A[0];if(Z.has(J)){let Q=this.generate(A[1],"value"),K=this.generate(A[2],"value"),X=this.generate($,"value");return`((${Q} ${J} ${K}) && (${K} ${Y} ${X}))`}}if(Y==="!?"){let J=this.generate(A,"value"),Q=this.generate($,"value");return`(${J} !== undefined ? ${J} : ${Q})`}if(Y==="==")Y="===";if(Y==="!=")Y="!==";return`(${this.generate(A,"value")} ${Y} ${this.generate($,"value")})`}generateModulo(Y,U){let[W,F]=U;return this.helpers.add("modulo"),`modulo(${this.generate(W,"value")}, ${this.generate(F,"value")})`}generateModuloAssign(Y,U){let[W,F]=U;this.helpers.add("modulo");let A=this.generate(W,"value"),$=this.generate(F,"value");return`${A} = modulo(${A}, ${$})`}generateFloorDiv(Y,U){let[W,F]=U;return`Math.floor(${this.generate(W,"value")} / ${this.generate(F,"value")})`}generateFloorDivAssign(Y,U){let[W,F]=U,A=this.generate(W,"value"),$=this.generate(F,"value");return`${A} = Math.floor(${A} / ${$})`}generateAssignment(Y,U,W,F){let[A,$]=U,Z=Y==="?="?"??=":Y,J=this.is($,"->")||this.is($,"=>")||this.is($,"def");if(A instanceof String&&u(A,"await")!==void 0&&!J){let G=u(A,"await")===!0?"!":"&";throw Error(`Cannot use ${G} sigil in variable declaration '${L(A)}'.`)}if(A instanceof String&&u(A,"await")===!0&&J)this.nextFunctionIsVoid=!0;let Q=this.is(A,"array",0),K=this.is(A,"object",0);if(Q||K){let G=this.generate($,"value");return K&&W==="statement"?`(${G})`:G}if(Array.isArray($)&&Z==="="&&$[0]==="control"){let[,G,R,q]=$,B=L(G),I=q[0]==="return",_=this.generate(A,"value"),w=this.generate(R,"value"),P=q.length>1?q[1]:null,O=I?P?`return ${this.generate(P,"value")}`:"return":P?`throw ${this.generate(P,"value")}`:"throw new Error()";if(W==="value"){if(B==="??")return`(() => { const __v = ${w}; if (__v == null) ${O}; return (${_} = __v); })()`;if(B==="||")return`(() => { const __v = ${w}; if (!__v) ${O}; return (${_} = __v); })()`;return`(() => { const __v = ${w}; if (__v) ${O}; return (${_} = __v); })()`}if(B==="??")return`if ((${_} = ${w}) == null) ${O}`;if(B==="||")return`if (!(${_} = ${w})) ${O}`;return`if ((${_} = ${w})) ${O}`}if(this.is(A,"array")){let G=A.slice(1).findIndex((R)=>this.is(R,"...")||R==="...");if(G!==-1&&G<A.length-2){let R=A.slice(1),q=R.slice(G+1),B=q.length;if(B>0){let I=this.generate($,"value"),w=R.slice(0,G).map((T)=>T===","?"":typeof T==="string"?T:this.generate(T,"value")).join(", "),P=q.map((T)=>T===","?"":typeof T==="string"?T:this.generate(T,"value")).join(", ");this.helpers.add("slice"),R.forEach((T)=>{if(T===","||T==="...")return;if(typeof T==="string")this.programVars.add(T);else if(this.is(T,"...")&&typeof T[1]==="string")this.programVars.add(T[1])});let O=R[G],N=this.is(O,"...")?O[1]:null,E=[];if(w)E.push(`[${w}] = ${I}`);if(N)E.push(`[...${N}] = ${I}.slice(${G}, -${B})`);return E.push(`[${P}] = slice.call(${I}, -${B})`),E.join(", ")}}}if(W==="statement"&&Y==="="&&Array.isArray($)&&($[0]==="||"||$[0]==="&&")&&$.length===3){let[G,R,q]=$;if(this.is(q,"if")&&q.length===3){let[,B,I]=q,_=Array.isArray(I)&&I.length===1?I[0]:I,w=[G,R,_],P=this.generate(A,"value"),O=this.generate(B,"value"),N=this.generate(w,"value");return`if (${O}) ${P} = ${N}`}}if(W==="statement"&&Y==="="&&Array.isArray($)&&$.length===3){let[G,R,q]=$,B=Array.isArray(q)&&q.length===1&&(!Array.isArray(q[0])||q[0][0]!=="block");if(G==="if"&&B){let I=Array.isArray(q)&&q.length===1?q[0]:q,_=this.generate(A,"value"),w=this.unwrapLogical(this.generate(R,"value")),P=this.generate(I,"value");return`if (${w}) ${_} = ${P}`}}let X;if(A instanceof String&&u(A,"await")!==void 0)X=L(A);else if(typeof A==="string"&&this.reactiveVars?.has(A))X=`${A}.value`;else this.suppressReactiveUnwrap=!0,X=this.generate(A,"value"),this.suppressReactiveUnwrap=!1;let z=this.generate($,"value");if(!this.is($,"object"))z=this.unwrap(z);let D=W==="value",M=W==="statement"&&this.is(A,"object");if(D||M)return`(${X} ${Z} ${z})`;return`${X} ${Z} ${z}`}generatePropertyAccess(Y,U,W,F){let[A,$]=U;if(this._atParamMap&&A==="this"){let K=this._atParamMap.get(L($));if(K)return K}this.suppressReactiveUnwrap=!0;let Z=this.generate(A,"value");this.suppressReactiveUnwrap=!1;let Q=C.NUMBER_LITERAL_RE.test(Z)||Z.startsWith("await ")||(this.is(A,"object")||this.is(A,"yield"))?`(${Z})`:Z;if(u($,"await")===!0)return`await ${Q}.${L($)}()`;if(u($,"predicate"))return`(${Q}.${L($)} != null)`;return`${Q}.${L($)}`}generateOptionalProperty(Y,U){let[W,F]=U;return`${this.generate(W,"value")}?.${F}`}generateRegexIndex(Y,U){let[W,F,A]=U;this.helpers.add("toMatchable"),this.programVars.add("_");let $=this.generate(W,"value"),Z=this.generate(F,"value"),J=A!==null?this.generate(A,"value"):"0",Q=Z.includes("/m")?", true":"";return`(_ = toMatchable(${$}${Q}).match(${Z})) && _[${J}]`}generateIndexAccess(Y,U){let[W,F]=U;if(this.is(F,"..")||this.is(F,"...")){let A=F[0]==="..",$=this.generate(W,"value"),[Z,J]=F.slice(1);if(Z===null&&J===null)return`${$}.slice()`;if(Z===null){if(A&&this.is(J,"-",1)&&(L(J[1])??J[1])==1)return`${$}.slice(0)`;let X=this.generate(J,"value");return A?`${$}.slice(0, +${X} + 1 || 9e9)`:`${$}.slice(0, ${X})`}if(J===null)return`${$}.slice(${this.generate(Z,"value")})`;let Q=this.generate(Z,"value");if(A&&this.is(J,"-",1)&&(L(J[1])??J[1])==1)return`${$}.slice(${Q})`;let K=this.generate(J,"value");return A?`${$}.slice(${Q}, +${K} + 1 || 9e9)`:`${$}.slice(${Q}, ${K})`}if(this.is(F,"-",1)){let A=L(F[1])??F[1];if(typeof A==="number"||typeof A==="string"&&/^\d+$/.test(A))return`${this.generate(W,"value")}.at(-${A})`}return`${this.generate(W,"value")}[${this.unwrap(this.generate(F,"value"))}]`}generateOptIndex(Y,U){let[W,F]=U;if(this.is(F,"-",1)){let A=L(F[1])??F[1];if(typeof A==="number"||typeof A==="string"&&/^\d+$/.test(A))return`${this.generate(W,"value")}?.at(-${A})`}return`${this.generate(W,"value")}?.[${this.generate(F,"value")}]`}generateOptCall(Y,U){let[W,...F]=U;return`${this.generate(W,"value")}?.(${F.map((A)=>this.generate(A,"value")).join(", ")})`}generateDef(Y,U,W,F){let[A,$,Z]=U,J=u(A,"await")===!0,Q=L(A),K=this.generateParamList($),X=this.generateFunctionBody(Z,$,J),z=this.containsAwait(Z),H=this.containsYield(Z);return`${z?"async ":""}function${H?"*":""} ${Q}(${K}) ${X}`}generateThinArrow(Y,U,W,F){let[A,$]=U;if((!A||Array.isArray(A)&&A.length===0)&&this.containsIt($))A=["it"];let Z=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let J=this.generateParamList(A),Q=this.generateFunctionBody($,A,Z),K=this.containsAwait($),X=this.containsYield($),z=`${K?"async ":""}function${X?"*":""}(${J}) ${Q}`;return W==="value"?`(${z})`:z}generateFatArrow(Y,U,W,F){let[A,$]=U;if((!A||Array.isArray(A)&&A.length===0)&&this.containsIt($))A=["it"];let Z=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let J=this.generateParamList(A),K=A.length===1&&typeof A[0]==="string"&&!J.includes("=")&&!J.includes("...")&&!J.includes("[")&&!J.includes("{")?J:`(${J})`,z=this.containsAwait($)?"async ":"";if(!Z){if(this.is($,"block")&&$.length===2){let D=$[1];if(!Array.isArray(D)||D[0]!=="return")return`${z}${K} => ${this.generate(D,"value")}`}if(!Array.isArray($)||$[0]!=="block")return`${z}${K} => ${this.generate($,"value")}`}let H=this.generateFunctionBody($,A,Z);return`${z}${K} => ${H}`}generateReturn(Y,U,W,F){if(U.length===0)return"return";let[A]=U;if(this.sideEffectOnly)return"return";if(this.is(A,"if")){let[,$,Z,...J]=A;if(J.length===0){let Q=Array.isArray(Z)&&Z.length===1?Z[0]:Z;return`if (${this.generate($,"value")}) return ${this.generate(Q,"value")}`}}if(this.is(A,"new")&&Array.isArray(A[1])&&A[1][0]==="if"){let[,$,Z]=A[1],J=Array.isArray(Z)&&Z.length===1?Z[0]:Z;return`if (${this.generate($,"value")}) return ${this.generate(["new",J],"value")}`}return`return ${this.generate(A,"value")}`}generateState(Y,U){let[W,F]=U;this.usesReactivity=!0;let A=L(W)??W;if(!this.reactiveVars)this.reactiveVars=new Set;return this.reactiveVars.add(A),`const ${A} = __state(${this.generate(F,"value")})`}generateComputed(Y,U){let[W,F]=U;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let A=L(W)??W;return this.reactiveVars.add(A),`const ${A} = __computed(() => ${this.generate(F,"value")})`}generateReadonly(Y,U){let[W,F]=U;return`const ${L(W)??W} = ${this.generate(F,"value")}`}generateEffect(Y,U){let[W,F]=U;this.usesReactivity=!0;let A;if(this.is(F,"block"))A=`{
149
149
  ${this.withIndent(()=>this.formatStatements(F.slice(1))).join(`
150
150
  `)}
151
151
  ${this.indent()}}`;else if(this.is(F,"->")||this.is(F,"=>")){let Z=this.generate(F,"value");if(W)return`const ${L(W)??this.generate(W,"value")} = __effect(${Z})`;return`__effect(${Z})`}else A=`{ ${this.generate(F,"value")}; }`;let $=`__effect(() => ${A})`;if(W)return`const ${L(W)??this.generate(W,"value")} = ${$}`;return $}generateBreak(){return"break"}generateContinue(){return"continue"}generateExistential(Y,U){return`(${this.generate(U[0],"value")} != null)`}generateTernary(Y,U,W){let[F,A,$]=U;if((A?.[0]?.valueOf?.()??A?.[0])==="="&&Array.isArray(A)){let J=this.generate(A[1],"value"),Q=this.generate(A[2],"value"),K=this.generate($,"value");return`${J} = (${this.unwrap(this.generate(F,"value"))} ? ${Q} : ${K})`}return`(${this.unwrap(this.generate(F,"value"))} ? ${this.generate(A,"value")} : ${this.generate($,"value")})`}generatePipe(Y,U){let[W,F]=U,A=this.generate(W,"value");if(Array.isArray(F)&&F.length>1){let $=F[0];if(Array.isArray($)||typeof $==="string"&&/^[a-zA-Z_$]/.test($)){let J=this.generate($,"value"),Q=F.slice(1).map((K)=>this.generate(K,"value"));return`${J}(${A}, ${Q.join(", ")})`}}return`${this.generate(F,"value")}(${A})`}generateLoop(Y,U){return`while (true) ${this.generateLoopBody(U[0])}`}generateLoopN(Y,U){let[W,F]=U;return`for (let it = 0; it < ${this.generate(W,"value")}; it++) ${this.generateLoopBody(F)}`}generateAwait(Y,U){return`await ${this.generate(U[0],"value")}`}generateYield(Y,U){return U.length===0?"yield":`yield ${this.generate(U[0],"value")}`}generateYieldFrom(Y,U){return`yield* ${this.generate(U[0],"value")}`}generateIf(Y,U,W,F){let[A,$,...Z]=U;return W==="value"?this.generateIfAsExpression(A,$,Z):this.generateIfAsStatement(A,$,Z)}generateForIn(Y,U,W,F){let[A,$,Z,J,Q]=U;if(W==="value"&&this.comprehensionDepth===0){let R=["for-in",A,$,Z];return this.generate(["comprehension",Q,[R],J?[J]:[]],W)}let K=Array.isArray(A)?A:[A],X=K.length===0,[z,H]=X?["_i",null]:K,D=this.is(z,"array")||this.is(z,"object")?this.generateDestructuringPattern(z):z;if(Z&&Z!==null){let R=this.generate($,"value"),q=H||"_i",B=this.generate(Z,"value"),I=this.is(Z,"-",1),_=I&&(Z[1]==="1"||Z[1]===1||L(Z[1])==="1"),w=!I&&(Z==="1"||Z===1||L(Z)==="1"),P;if(_)P=`for (let ${q} = ${R}.length - 1; ${q} >= 0; ${q}--) `;else if(w)P=`for (let ${q} = 0; ${q} < ${R}.length; ${q}++) `;else if(I)P=`for (let ${q} = ${R}.length - 1; ${q} >= 0; ${q} += ${B}) `;else P=`for (let ${q} = 0; ${q} < ${R}.length; ${q} += ${B}) `;if(this.is(Q,"block")){let O=Q.slice(1);this.indentLevel++;let N=[];if(!X)N.push(`const ${D} = ${R}[${q}];`);if(J)N.push(`if (${this.generate(J,"value")}) {`),this.indentLevel++,N.push(...this.formatStatements(O)),this.indentLevel--,N.push(this.indent()+"}");else N.push(...O.map((E)=>this.addSemicolon(E,this.generate(E,"statement"))));return this.indentLevel--,P+`{
@@ -507,7 +507,7 @@ if (typeof globalThis !== 'undefined') {
507
507
  `:"",Y=W.slice(0,F).join(`
508
508
  `)}let $=new c().tokenize(Y);if(this.options.showTokens)$.forEach((M)=>console.log(`${M[0].padEnd(12)} ${JSON.stringify(M[1])}`)),console.log();let Z=null,J=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)J=[...$];$=$.filter((M)=>M[0]!=="TYPE_DECL");while($.length>0&&$[0][0]==="TERMINATOR")$.shift();if($.every((M)=>M[0]==="TERMINATOR")){if(J)Z=W1(J,["program"]);return{tokens:$,sexpr:["program"],code:"",dts:Z,data:U,reactiveVars:{}}}k.lexer={tokens:$,pos:0,setInput:function(){},lex:function(){if(this.pos>=this.tokens.length)return 1;let M=this.tokens[this.pos++],G=M[1];if(M.data)G=new String(G),Object.assign(G,M.data);return this.text=G,this.loc=M.loc,M[0]}};let Q;try{Q=k.parse(Y)}catch(M){if(/\?\s*\([^)]*\?[^)]*:[^)]*\)\s*:/.test(Y)||/\?\s+\w+\s+\?\s+/.test(Y))throw Error("Nested ternary operators are not supported. Use if/else statements instead.");throw M}if(this.options.showSExpr)console.log(y(Q,0,!0)),console.log();let K=null;if(this.options.sourceMap){let M=(this.options.filename||"output")+".js",G=this.options.filename||"input.rip";K=new Z1(M,G,Y)}let X=new C({dataSection:U,skipPreamble:this.options.skipPreamble,reactiveVars:this.options.reactiveVars,sourceMap:K}),z=X.compile(Q),H=K?K.toJSON():null,D=K?K.toReverseMap():null;if(H&&this.options.sourceMap==="inline"){let M=typeof Buffer<"u"?Buffer.from(H).toString("base64"):btoa(H);z+=`
509
509
  //# sourceMappingURL=data:application/json;base64,${M}`}else if(H&&this.options.filename)z+=`
510
- //# sourceMappingURL=${this.options.filename}.js.map`;if(J)Z=W1(J,Q);return{tokens:$,sexpr:Q,code:z,dts:Z,map:H,reverseMap:D,data:U,reactiveVars:X.reactiveVars}}compileToJS(Y){return this.compile(Y).code}compileToSExpr(Y){return this.compile(Y).sexpr}}V1(C);C.prototype.generateEnum=H1;function Q1(Y,U={}){return new e(U).compile(Y)}function x(Y,U={}){return new e(U).compileToJS(Y)}function $1(){return new C({}).getReactiveRuntime()}function J1(){return new C({}).getComponentRuntime()}var w2="3.8.9",I2="2026-02-16@20:02:36GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function($1())();var B2=(Y)=>{let U=Y.match(/^[ \t]*(?=\S)/gm),W=Math.min(...(U||[]).map((F)=>F.length));return Y.replace(RegExp(`^[ ]{${W}}`,"gm"),"").trim()};async function f1(){let Y=document.querySelectorAll('script[type="text/rip"]');for(let U of Y){if(U.hasAttribute("data-rip-processed"))continue;try{let W;if(U.src){let A=await fetch(U.src);if(!A.ok){console.error(`Rip: failed to fetch ${U.src} (${A.status})`);continue}W=await A.text()}else W=B2(U.textContent);let F;try{F=x(W)}catch(A){console.error("Rip compile error:",A.message),console.error("Source:",W);continue}await(0,eval)(`(async()=>{
510
+ //# sourceMappingURL=${this.options.filename}.js.map`;if(J)Z=W1(J,Q);return{tokens:$,sexpr:Q,code:z,dts:Z,map:H,reverseMap:D,data:U,reactiveVars:X.reactiveVars}}compileToJS(Y){return this.compile(Y).code}compileToSExpr(Y){return this.compile(Y).sexpr}}V1(C);C.prototype.generateEnum=H1;function Q1(Y,U={}){return new e(U).compile(Y)}function x(Y,U={}){return new e(U).compileToJS(Y)}function $1(){return new C({}).getReactiveRuntime()}function J1(){return new C({}).getComponentRuntime()}var w2="3.8.10",I2="2026-02-17@02:53:39GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function($1())();var B2=(Y)=>{let U=Y.match(/^[ \t]*(?=\S)/gm),W=Math.min(...(U||[]).map((F)=>F.length));return Y.replace(RegExp(`^[ ]{${W}}`,"gm"),"").trim()};async function f1(){let Y=document.querySelectorAll('script[type="text/rip"]');for(let U of Y){if(U.hasAttribute("data-rip-processed"))continue;try{let W;if(U.src){let A=await fetch(U.src);if(!A.ok){console.error(`Rip: failed to fetch ${U.src} (${A.status})`);continue}W=await A.text()}else W=B2(U.textContent);let F;try{F=x(W)}catch(A){console.error("Rip compile error:",A.message),console.error("Source:",W);continue}await(0,eval)(`(async()=>{
511
511
  ${F}
512
512
  })()`),U.setAttribute("data-rip-processed","true")}catch(W){console.error("Rip runtime error:",W)}}}async function E2(Y){let U=await fetch(Y).then(($)=>{if(!$.ok)throw Error(`importRip: ${Y} (${$.status})`);return $.text()}),W=x(U),F=new Blob([W],{type:"application/javascript"}),A=URL.createObjectURL(F);try{return await import(A)}finally{URL.revokeObjectURL(A)}}function N2(Y){try{let U=Y.replace(/^/gm," "),F=x(`do ->
513
513
  ${U}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");F=F.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let A=(0,eval)(F);if(A&&typeof A.then==="function")return A.then(($)=>{if($!==void 0)globalThis._=$;return $});if(A!==void 0)globalThis._=A;return A}catch(U){console.error("Rip compilation error:",U.message);return}}if(typeof globalThis<"u")globalThis.rip=N2,globalThis.importRip=E2,globalThis.compileToJS=x,globalThis.__ripExports={compile:Q1,compileToJS:x,formatSExpr:y,VERSION:w2,BUILD_DATE:I2,getReactiveRuntime:$1,getComponentRuntime:J1};if(typeof document<"u")if(document.readyState==="loading")globalThis.__ripScriptsReady=new Promise((Y)=>{document.addEventListener("DOMContentLoaded",()=>f1().then(Y))});else globalThis.__ripScriptsReady=f1();export{N2 as rip,f1 as processRipScripts,k as parser,E2 as importRip,$1 as getReactiveRuntime,J1 as getComponentRuntime,y as formatSExpr,x as compileToJS,Q1 as compile,w2 as VERSION,c as Lexer,e as Compiler,C as CodeGenerator,I2 as BUILD_DATE};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.8.9",
3
+ "version": "3.8.10",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/compiler.js CHANGED
@@ -822,7 +822,6 @@ export class CodeGenerator {
822
822
  let ctrlOp = str(rawCtrlOp);
823
823
  let isReturn = ctrlSexpr[0] === 'return';
824
824
  let targetCode = this.generate(target, 'value');
825
- if (typeof target === 'string') this.programVars.add(target);
826
825
  let exprCode = this.generate(expr, 'value');
827
826
  let ctrlValue = ctrlSexpr.length > 1 ? ctrlSexpr[1] : null;
828
827
  let ctrlCode = isReturn