rip-lang 3.10.9 → 3.10.11

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,12 @@ 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.10.11] - 2026-02-20
11
+
12
+ ### Compiler — Fix Variable Scoping in Effect Blocks
13
+
14
+ - **Effect block bodies now scope variables correctly** — Variables assigned inside `~>` block bodies (e.g., `prev = document.querySelector(...)`) were being hoisted to the enclosing function scope instead of staying local to the effect's arrow function. This caused `ReferenceError` in strict mode. Fixed by treating effect blocks as proper function boundaries in both `collectProgramVariables` and `collectFunctionVariables`, and using `generateFunctionBody` (matching how `generateComputed` already handles blocks) instead of raw `formatStatements`.
15
+
10
16
  ## [3.10.6] - 2026-02-20
11
17
 
12
18
  ### CLI — Fix Multiline Argument Corruption
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.10.9-blue.svg" alt="Version"></a>
12
+ <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.10.11-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%2C243%2F1%2C243-brightgreen.svg" alt="Tests"></a>
15
15
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
@@ -262,20 +262,23 @@ Rip's reactivity is framework-agnostic — use it with React, Vue, Svelte, or va
262
262
 
263
263
  ## Rip UI
264
264
 
265
- Load `rip-ui.min.js` (~52KB Brotli) — the Rip compiler and pre-compiled UI framework in one file. Components are `.rip` source files, compiled on demand, rendered with fine-grained reactivity. No build step. No bundler.
265
+ Load `rip-ui.min.js` (~53KB Brotli) — the Rip compiler and pre-compiled UI framework in one file. Components are `.rip` source files, compiled on demand, rendered with fine-grained reactivity. No build step. No bundler.
266
266
 
267
- ```coffee
268
- Counter = component
269
- @count := 0
267
+ ```html
268
+ <script type="module" src="rip-ui.min.js"></script>
270
269
 
270
+ <script type="text/rip" data-name="index">
271
+ export Home = component
272
+ @count := 0
271
273
  render
272
274
  div.counter
273
275
  h1 "Count: #{@count}"
274
276
  button @click: (-> @count++), "+"
275
277
  button @click: (-> @count--), "-"
278
+ </script>
276
279
  ```
277
280
 
278
- Two keywords `component` and `render` are all the language adds. Everything else (`:=` state, `~=` computed, methods, lifecycle) is standard Rip.
281
+ That's it. The runtime auto-detects inline `data-name` components, compiles them, and launches the app with hash routing — no bootstrap script needed. Two keywords (`component` and `render`) are all the language adds. Everything else (`:=` state, `~=` computed, methods, lifecycle) is standard Rip.
279
282
 
280
283
  See [@rip-lang/ui](packages/ui/) for the full framework: file-based router, reactive stash, component store, and renderer. **[Try the demo](https://shreeve.github.io/rip-lang/demo.html)** — a complete app in one HTML file.
281
284
 
@@ -291,7 +294,7 @@ See [@rip-lang/ui](packages/ui/) for the full framework: file-based router, reac
291
294
  | **Self-hosting** | No | Yes |
292
295
  | **Lexer** | 3,558 LOC | 2,024 LOC |
293
296
  | **Compiler** | 10,346 LOC | 3,293 LOC |
294
- | **Total** | 17,760 LOC | ~11,100 LOC |
297
+ | **Total** | 17,760 LOC | ~11,300 LOC |
295
298
 
296
299
  Smaller codebase, modern output, built-in reactivity.
297
300
 
@@ -302,7 +305,7 @@ Smaller codebase, modern output, built-in reactivity.
302
305
  Run Rip directly in the browser — inline scripts and the console REPL both support `await` via the `!` operator:
303
306
 
304
307
  ```html
305
- <script type="module" src="/rip/browser.js"></script>
308
+ <script type="module" src="rip-ui.min.js"></script>
306
309
  <script type="text/rip">
307
310
  res = fetch! 'https://api.example.com/data'
308
311
  data = res.json!
@@ -334,17 +337,17 @@ Simple arrays (with `.loc`) instead of AST node classes. The compiler is self-ho
334
337
  | Component | File | Lines |
335
338
  |-----------|------|-------|
336
339
  | Lexer + Rewriter | `src/lexer.js` | 1,761 |
337
- | Compiler + Codegen | `src/compiler.js` | 3,293 |
340
+ | Compiler + Codegen | `src/compiler.js` | 3,303 |
338
341
  | Type System | `src/types.js` | 1,099 |
339
- | Component System | `src/components.js` | 1,750 |
342
+ | Component System | `src/components.js` | 1,877 |
340
343
  | Source Maps | `src/sourcemaps.js` | 189 |
341
- | Parser (generated) | `src/parser.js` | 359 |
344
+ | Parser (generated) | `src/parser.js` | 357 |
342
345
  | Grammar | `src/grammar/grammar.rip` | 944 |
343
346
  | Parser Generator | `src/grammar/solar.rip` | 929 |
344
347
  | REPL | `src/repl.js` | 601 |
345
- | Browser Entry | `src/browser.js` | 151 |
348
+ | Browser Entry | `src/browser.js` | 167 |
346
349
  | Tags | `src/tags.js` | 62 |
347
- | **Total** | | **~11,138** |
350
+ | **Total** | | **~11,289** |
348
351
 
349
352
  ---
350
353
 
@@ -354,11 +357,11 @@ Rip includes optional packages for full-stack development:
354
357
 
355
358
  | Package | Version | Purpose |
356
359
  |---------|---------|---------|
357
- | [rip-lang](https://www.npmjs.com/package/rip-lang) | 3.10.6 | Core language compiler |
360
+ | [rip-lang](https://www.npmjs.com/package/rip-lang) | 3.10.10 | Core language compiler |
358
361
  | [@rip-lang/api](packages/api/) | 1.1.10 | HTTP framework (Sinatra-style routing, 37 validators) |
359
362
  | [@rip-lang/server](packages/server/) | 1.1.19 | Multi-worker app server (hot reload, HTTPS, mDNS) |
360
363
  | [@rip-lang/db](packages/db/) | 1.2.0 | DuckDB server with official UI + ActiveRecord-style client |
361
- | [@rip-lang/ui](packages/ui/) | 0.3.14 | Zero-build reactive web framework (stash, router, hash routing) |
364
+ | [@rip-lang/ui](packages/ui/) | 0.3.19 | Zero-build reactive web framework (auto-launch, stash, router) |
362
365
  | [@rip-lang/swarm](packages/swarm/) | 1.1.4 | Parallel job runner with worker pool |
363
366
  | [@rip-lang/csv](packages/csv/) | 1.1.4 | CSV parser + writer |
364
367
  | [@rip-lang/schema](packages/schema/) | 0.2.1 | Unified schema → TypeScript types, SQL DDL, validation, ORM |
@@ -400,7 +403,7 @@ rip file.rip # Run
400
403
  rip -c file.rip # Compile
401
404
  rip -t file.rip # Tokens
402
405
  rip -s file.rip # S-expressions
403
- bun run test # 1241 tests
406
+ bun run test # 1243 tests
404
407
  bun run parser # Rebuild parser
405
408
  bun run browser # Build browser bundle
406
409
  ```
@@ -113,7 +113,7 @@ if (typeof globalThis !== 'undefined') {
113
113
  `)}else Y=A1(U);let F=[`${f}(${Y}`],Z=U==="block";for(let Q=1;Q<$.length;Q++){let R=$[Q];if(!Array.isArray(R))F[F.length-1]+=" "+A1(R);else{let w=M1(R)&&R.every((K)=>!Array.isArray(K)||M1(K));if(!Z&&w){let K=x(R,0,!1);if(!K.includes(`
114
114
  `)){F[F.length-1]+=" "+K;continue}}F.push(x(R,W+2,!1))}}return F[F.length-1]+=")",F.join(`
115
115
  `)}class y{static ASSIGNMENT_OPS=new Set(["=","+=","-=","*=","/=","?=","&=","|=","^=","%=","**=","??=","&&=","||=","<<=",">>=",">>>="]);static NUMBER_LITERAL_RE=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;static NUMBER_START_RE=/^-?\d/;static GENERATORS={program:"generateProgram","&&":"generateLogicalAnd","||":"generateLogicalOr","+":"generateBinaryOp","-":"generateBinaryOp","*":"generateBinaryOp","/":"generateBinaryOp","%":"generateBinaryOp","**":"generateBinaryOp","==":"generateBinaryOp","===":"generateBinaryOp","!=":"generateBinaryOp","!==":"generateBinaryOp","<":"generateBinaryOp",">":"generateBinaryOp","<=":"generateBinaryOp",">=":"generateBinaryOp","??":"generateBinaryOp","!?":"generateBinaryOp","&":"generateBinaryOp","|":"generateBinaryOp","^":"generateBinaryOp","<<":"generateBinaryOp",">>":"generateBinaryOp",">>>":"generateBinaryOp","%%":"generateModulo","%%=":"generateModuloAssign","//":"generateFloorDiv","//=":"generateFloorDivAssign","..":"generateRange","=":"generateAssignment","+=":"generateAssignment","-=":"generateAssignment","*=":"generateAssignment","/=":"generateAssignment","%=":"generateAssignment","**=":"generateAssignment","&&=":"generateAssignment","||=":"generateAssignment","??=":"generateAssignment","?=":"generateAssignment","&=":"generateAssignment","|=":"generateAssignment","^=":"generateAssignment","<<=":"generateAssignment",">>=":"generateAssignment",">>>=":"generateAssignment","...":"generateRange","!":"generateNot","~":"generateBitwiseNot","++":"generateIncDec","--":"generateIncDec","=~":"generateRegexMatch",instanceof:"generateInstanceof",in:"generateIn",of:"generateOf",typeof:"generateTypeof",delete:"generateDelete",new:"generateNew",array:"generateArray",object:"generateObject",block:"generateBlock",".":"generatePropertyAccess","?.":"generateOptionalProperty","[]":"generateIndexAccess",optindex:"generateOptIndex",optcall:"generateOptCall","regex-index":"generateRegexIndex",def:"generateDef","->":"generateThinArrow","=>":"generateFatArrow",return:"generateReturn",state:"generateState",computed:"generateComputed",readonly:"generateReadonly",effect:"generateEffect",break:"generateBreak",continue:"generateContinue","?":"generateExistential","?:":"generateTernary","|>":"generatePipe",loop:"generateLoop","loop-n":"generateLoopN",await:"generateAwait",yield:"generateYield","yield-from":"generateYieldFrom",if:"generateIf","for-in":"generateForIn","for-of":"generateForOf","for-as":"generateForAs",while:"generateWhile",try:"generateTry",throw:"generateThrow",control:"generateControl",switch:"generateSwitch",when:"generateWhen",comprehension:"generateComprehension","object-comprehension":"generateObjectComprehension",class:"generateClass",super:"generateSuper",component:"generateComponent",render:"generateRender",enum:"generateEnum",import:"generateImport",export:"generateExport","export-default":"generateExportDefault","export-all":"generateExportAll","export-from":"generateExportFrom","do-iife":"generateDoIIFE",regex:"generateRegex","tagged-template":"generateTaggedTemplate",str:"generateString"};constructor($={}){if(this.options=$,this.indentLevel=0,this.indentString=" ",this.comprehensionDepth=0,this.dataSection=$.dataSection,this.sourceMap=$.sourceMap||null,$.reactiveVars)this.reactiveVars=new Set($.reactiveVars)}compile($){this.programVars=new Set,this.functionVars=new Map,this.helpers=new Set,this.scopeStack=[],this.collectProgramVariables($);let W=this.generate($);if(this.sourceMap)this.buildMappings(W,$);return W}buildMappings($,W){if(!W||W[0]!=="program")return;let A=[],U=(Y)=>{if(!Array.isArray(Y))return;let F=Y[0];if(F==="program"||F==="block")for(let Z=1;Z<Y.length;Z++){let Q=Y[Z];if(Array.isArray(Q)&&Q.loc)A.push(Q.loc);U(Q)}else for(let Z=1;Z<Y.length;Z++)U(Y[Z])};U(W);let u=$.split(`
116
- `),f=0;for(let Y=0;Y<u.length;Y++){let F=u[Y],Z=F.trim();if(!Z||Z==="}"||Z==="});")continue;if(Z.startsWith("let ")||Z.startsWith("var "))continue;if(Z.startsWith("const slice")||Z.startsWith("const modulo")||Z.startsWith("const toMatchable"))continue;if(Z.startsWith("const {")&&Z.includes("__"))continue;if(Z.startsWith("} else"))continue;if(Z.startsWith("//# source"))continue;if(f<A.length){let Q=F.length-Z.length;this.sourceMap.addMapping(Y,Q,A[f].r,A[f].c),f++}}}collectProgramVariables($){if(!Array.isArray($))return;let[W,...A]=$;if(W=S(W),Array.isArray(W)){$.forEach((U)=>this.collectProgramVariables(U));return}if(W==="export"||W==="export-default"||W==="export-all"||W==="export-from")return;if(W==="state"||W==="computed"){let[U]=A,u=S(U)??U;if(!this.reactiveVars)this.reactiveVars=new Set;this.reactiveVars.add(u);return}if(W==="readonly")return;if(W==="component")return;if(y.ASSIGNMENT_OPS.has(W)){let[U,u]=A;if(typeof U==="string"||U instanceof String){let f=S(U);if(!this.reactiveVars?.has(f))this.programVars.add(f)}else if(this.is(U,"array"))this.collectVarsFromArray(U,this.programVars);else if(this.is(U,"object"))this.collectVarsFromObject(U,this.programVars);this.collectProgramVariables(u);return}if(W==="def"||W==="->"||W==="=>")return;if(W==="if"){let[U,u,f]=A;if(this.collectProgramVariables(U),this.collectProgramVariables(u),f)this.collectProgramVariables(f);return}if(W==="try"){if(this.collectProgramVariables(A[0]),A.length>=2&&Array.isArray(A[1])&&A[1].length===2&&A[1][0]!=="block"){let[U,u]=A[1];if(U&&this.is(U,"object"))U.slice(1).forEach((f)=>{if(Array.isArray(f)&&f.length===2&&typeof f[1]==="string")this.programVars.add(f[1])});else if(U&&this.is(U,"array"))U.slice(1).forEach((f)=>{if(typeof f==="string")this.programVars.add(f)});this.collectProgramVariables(u)}if(A.length===3)this.collectProgramVariables(A[2]);else if(A.length===2&&(!Array.isArray(A[1])||A[1][0]==="block"))this.collectProgramVariables(A[1]);return}A.forEach((U)=>this.collectProgramVariables(U))}collectFunctionVariables($){let W=new Set,A=(U)=>{if(!Array.isArray(U))return;let[u,...f]=U;if(u=S(u),Array.isArray(u)){U.forEach((Y)=>A(Y));return}if(y.ASSIGNMENT_OPS.has(u)){let[Y,F]=f;if(typeof Y==="string")W.add(Y);else if(this.is(Y,"array"))this.collectVarsFromArray(Y,W);else if(this.is(Y,"object"))this.collectVarsFromObject(Y,W);A(F);return}if(u==="def"||u==="->"||u==="=>")return;if(u==="try"){if(A(f[0]),f.length>=2&&Array.isArray(f[1])&&f[1].length===2&&f[1][0]!=="block"){let[Y,F]=f[1];if(Y&&this.is(Y,"object"))Y.slice(1).forEach((Z)=>{if(Array.isArray(Z)&&Z.length===2&&typeof Z[1]==="string")W.add(Z[1])});else if(Y&&this.is(Y,"array"))Y.slice(1).forEach((Z)=>{if(typeof Z==="string")W.add(Z)});A(F)}if(f.length===3)A(f[2]);else if(f.length===2&&(!Array.isArray(f[1])||f[1][0]==="block"))A(f[1]);return}f.forEach((Y)=>A(Y))};return A($),W}generate($,W="statement"){if($ instanceof String){if(V($,"await")===!0)return`await ${S($)}()`;if(V($,"predicate"))return`(${S($)} != null)`;if(V($,"delimiter")==="///"&&V($,"heregex")){let F=S($),Z=F.match(/^\/(.*)\/([gimsuvy]*)$/s);if(Z){let[,Q,R]=Z;return`/${this.processHeregex(Q)}/${R}`}return F}let Y=V($,"quote");if(Y){let F=S($);if(Y==='"""'||Y==="'''"){let Q=this.extractStringContent($);return Q=Q.replace(/`/g,"\\`").replace(/\${/g,"\\${"),`\`${Q}\``}if(F[0]===Y)return F;let Z=F.slice(1,-1);return`${Y}${Z}${Y}`}$=S($)}if(typeof $==="string"){if($.startsWith('"')||$.startsWith("'")||$.startsWith("`")){if(this.options.debug)console.warn("[Rip] Unexpected quoted primitive:",$);let Y=$.slice(1,-1);if(Y.includes(`
116
+ `),f=0;for(let Y=0;Y<u.length;Y++){let F=u[Y],Z=F.trim();if(!Z||Z==="}"||Z==="});")continue;if(Z.startsWith("let ")||Z.startsWith("var "))continue;if(Z.startsWith("const slice")||Z.startsWith("const modulo")||Z.startsWith("const toMatchable"))continue;if(Z.startsWith("const {")&&Z.includes("__"))continue;if(Z.startsWith("} else"))continue;if(Z.startsWith("//# source"))continue;if(f<A.length){let Q=F.length-Z.length;this.sourceMap.addMapping(Y,Q,A[f].r,A[f].c),f++}}}collectProgramVariables($){if(!Array.isArray($))return;let[W,...A]=$;if(W=S(W),Array.isArray(W)){$.forEach((U)=>this.collectProgramVariables(U));return}if(W==="export"||W==="export-default"||W==="export-all"||W==="export-from")return;if(W==="state"||W==="computed"){let[U]=A,u=S(U)??U;if(!this.reactiveVars)this.reactiveVars=new Set;this.reactiveVars.add(u);return}if(W==="readonly")return;if(W==="component")return;if(y.ASSIGNMENT_OPS.has(W)){let[U,u]=A;if(typeof U==="string"||U instanceof String){let f=S(U);if(!this.reactiveVars?.has(f))this.programVars.add(f)}else if(this.is(U,"array"))this.collectVarsFromArray(U,this.programVars);else if(this.is(U,"object"))this.collectVarsFromObject(U,this.programVars);this.collectProgramVariables(u);return}if(W==="def"||W==="->"||W==="=>"||W==="effect")return;if(W==="if"){let[U,u,f]=A;if(this.collectProgramVariables(U),this.collectProgramVariables(u),f)this.collectProgramVariables(f);return}if(W==="try"){if(this.collectProgramVariables(A[0]),A.length>=2&&Array.isArray(A[1])&&A[1].length===2&&A[1][0]!=="block"){let[U,u]=A[1];if(U&&this.is(U,"object"))U.slice(1).forEach((f)=>{if(Array.isArray(f)&&f.length===2&&typeof f[1]==="string")this.programVars.add(f[1])});else if(U&&this.is(U,"array"))U.slice(1).forEach((f)=>{if(typeof f==="string")this.programVars.add(f)});this.collectProgramVariables(u)}if(A.length===3)this.collectProgramVariables(A[2]);else if(A.length===2&&(!Array.isArray(A[1])||A[1][0]==="block"))this.collectProgramVariables(A[1]);return}A.forEach((U)=>this.collectProgramVariables(U))}collectFunctionVariables($){let W=new Set,A=(U)=>{if(!Array.isArray(U))return;let[u,...f]=U;if(u=S(u),Array.isArray(u)){U.forEach((Y)=>A(Y));return}if(y.ASSIGNMENT_OPS.has(u)){let[Y,F]=f;if(typeof Y==="string")W.add(Y);else if(this.is(Y,"array"))this.collectVarsFromArray(Y,W);else if(this.is(Y,"object"))this.collectVarsFromObject(Y,W);A(F);return}if(u==="def"||u==="->"||u==="=>"||u==="effect")return;if(u==="try"){if(A(f[0]),f.length>=2&&Array.isArray(f[1])&&f[1].length===2&&f[1][0]!=="block"){let[Y,F]=f[1];if(Y&&this.is(Y,"object"))Y.slice(1).forEach((Z)=>{if(Array.isArray(Z)&&Z.length===2&&typeof Z[1]==="string")W.add(Z[1])});else if(Y&&this.is(Y,"array"))Y.slice(1).forEach((Z)=>{if(typeof Z==="string")W.add(Z)});A(F)}if(f.length===3)A(f[2]);else if(f.length===2&&(!Array.isArray(f[1])||f[1][0]==="block"))A(f[1]);return}f.forEach((Y)=>A(Y))};return A($),W}generate($,W="statement"){if($ instanceof String){if(V($,"await")===!0)return`await ${S($)}()`;if(V($,"predicate"))return`(${S($)} != null)`;if(V($,"delimiter")==="///"&&V($,"heregex")){let F=S($),Z=F.match(/^\/(.*)\/([gimsuvy]*)$/s);if(Z){let[,Q,R]=Z;return`/${this.processHeregex(Q)}/${R}`}return F}let Y=V($,"quote");if(Y){let F=S($);if(Y==='"""'||Y==="'''"){let Q=this.extractStringContent($);return Q=Q.replace(/`/g,"\\`").replace(/\${/g,"\\${"),`\`${Q}\``}if(F[0]===Y)return F;let Z=F.slice(1,-1);return`${Y}${Z}${Y}`}$=S($)}if(typeof $==="string"){if($.startsWith('"')||$.startsWith("'")||$.startsWith("`")){if(this.options.debug)console.warn("[Rip] Unexpected quoted primitive:",$);let Y=$.slice(1,-1);if(Y.includes(`
117
117
  `))return`\`${Y.replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}\``;let F=Y.includes("'")&&!Y.includes('"')?'"':"'",Z=Y.replace(new RegExp(F,"g"),`\\${F}`);return`${F}${Z}${F}`}if(this.reactiveVars?.has($)&&!this.suppressReactiveUnwrap)return`${$}.value`;return $}if(typeof $==="number")return String($);if($===null||$===void 0)return"null";if(!Array.isArray($))throw Error(`Invalid s-expression: ${JSON.stringify($)}`);let[A,...U]=$,u=V(A,"await");A=S(A);let f=y.GENERATORS[A];if(f)return this[f](A,U,W,$);if(typeof A==="string"&&!A.startsWith('"')&&!A.startsWith("'")){if(y.NUMBER_START_RE.test(A))return A;if(A==="super"&&this.currentMethodName&&this.currentMethodName!=="constructor"){let R=U.map((w)=>this.unwrap(this.generate(w,"value"))).join(", ");return`super.${this.currentMethodName}(${R})`}if(W==="statement"&&U.length===1){let R=this.findPostfixConditional(U[0]);if(R){let w=this.rebuildWithoutConditional(R),K=this.generate(A,"value"),_=this.generate(R.condition,"value"),J=this.generate(w,"value"),X=`${K}(${J})`;return`if (${_}) ${X}`}}let Y=u===!0,F=this.generate(A,"value"),Z=U.map((R)=>this.unwrap(this.generate(R,"value"))).join(", "),Q=`${F}(${Z})`;return Y?`await ${Q}`:Q}if(Array.isArray(A)&&typeof A[0]==="string"){if(["=","+=","-=","*=","/=","%=","**=","&&=","||=","??=","if","return","throw"].includes(A[0]))return`(${$.map((Z)=>this.generate(Z,"value")).join(", ")})`}if(Array.isArray(A)){if(A[0]==="."&&(A[2]==="new"||S(A[2])==="new")){let R=A[1],w=this.generate(R,"value"),K=U.map((J)=>this.unwrap(this.generate(J,"value"))).join(", ");return`new ${Array.isArray(R)?`(${w})`:w}(${K})`}if(W==="statement"&&U.length===1){let R=this.findPostfixConditional(U[0]);if(R){let w=this.rebuildWithoutConditional(R),K=this.generate(A,"value"),_=this.generate(R.condition,"value"),J=this.generate(w,"value"),X=`${K}(${J})`;return`if (${_}) ${X}`}}let Y=!1,F;if(A[0]==="."&&V(A[2],"await")===!0){Y=!0;let[R,w]=A.slice(1),K=this.generate(R,"value");F=`${y.NUMBER_LITERAL_RE.test(K)||(this.is(R,"object")||this.is(R,"await")||this.is(R,"yield"))?`(${K})`:K}.${S(w)}`}else F=this.generate(A,"value");let Z=U.map((R)=>this.unwrap(this.generate(R,"value"))).join(", "),Q=`${F}(${Z})`;return Y?`await ${Q}`:Q}throw Error(`Unknown s-expression type: ${A}`)}generateProgram($,W,A,U){let u="",f=[],Y=[],F=[];for(let _ of W){if(!Array.isArray(_)){F.push(_);continue}let J=_[0];if(J==="import")f.push(_);else if(J==="export"||J==="export-default"||J==="export-all"||J==="export-from")Y.push(_);else F.push(_)}let Z=["def","class","if","for-in","for-of","for-as","while","loop","switch","try"],Q=F.map((_,J)=>{let X=F.length===1&&f.length===0&&Y.length===0,z=this.is(_,"object"),M=z&&_.length===2&&Array.isArray(_[1])&&Array.isArray(_[1][1])&&_[1][1][0]==="comprehension",O=this.is(_,"comprehension")||this.is(_,"object-comprehension")||this.is(_,"do-iife"),P=this.programVars.size===0,q=X&&z&&P&&!O&&!M,H=J===F.length-1&&O,D;if(q)D=`(${this.generate(_,"value")})`;else if(H)D=this.generate(_,"value");else D=this.generate(_,"statement");if(D&&!D.endsWith(";")){let G=Array.isArray(_)?_[0]:null;if(!Z.includes(G)||!D.endsWith("}"))return D+";"}return D}).join(`
118
118
  `),R=!1;if(f.length>0)u+=f.map((_)=>this.addSemicolon(_,this.generate(_,"statement"))).join(`
119
119
  `),R=!0;if(this.programVars.size>0){let _=Array.from(this.programVars).sort().join(", ");if(R)u+=`
@@ -145,10 +145,7 @@ _setDataSection();
145
145
 
146
146
  function _setDataSection() {
147
147
  DATA = ${JSON.stringify(this.dataSection)};
148
- }`;return u}generateBinaryOp($,W,A,U){if(($==="+"||$==="-")&&W.length===1)return`(${$}${this.generate(W[0],"value")})`;let[u,f]=W;if($==="*"){let F=u?.valueOf?.()??u;if(typeof F==="string"&&/^["']/.test(F))return`${this.generate(u,"value")}.repeat(${this.generate(f,"value")})`}let Y=new Set(["<",">","<=",">="]);if(Y.has($)&&Array.isArray(u)){let F=u[0]?.valueOf?.()??u[0];if(Y.has(F)){let Z=this.generate(u[1],"value"),Q=this.generate(u[2],"value"),R=this.generate(f,"value");return`((${Z} ${F} ${Q}) && (${Q} ${$} ${R}))`}}if($==="!?"){let F=this.generate(u,"value"),Z=this.generate(f,"value");return`(${F} !== undefined ? ${F} : ${Z})`}if($==="==")$="===";if($==="!=")$="!==";return`(${this.generate(u,"value")} ${$} ${this.generate(f,"value")})`}generateModulo($,W){let[A,U]=W;return this.helpers.add("modulo"),`modulo(${this.generate(A,"value")}, ${this.generate(U,"value")})`}generateModuloAssign($,W){let[A,U]=W;this.helpers.add("modulo");let u=this.generate(A,"value"),f=this.generate(U,"value");return`${u} = modulo(${u}, ${f})`}generateFloorDiv($,W){let[A,U]=W;return`Math.floor(${this.generate(A,"value")} / ${this.generate(U,"value")})`}generateFloorDivAssign($,W){let[A,U]=W,u=this.generate(A,"value"),f=this.generate(U,"value");return`${u} = Math.floor(${u} / ${f})`}generateAssignment($,W,A,U){let[u,f]=W,Y=$==="?="?"??=":$,F=this.is(f,"->")||this.is(f,"=>")||this.is(f,"def");if(u instanceof String&&V(u,"await")!==void 0&&!F){let X=V(u,"await")===!0?"!":"&";throw Error(`Cannot use ${X} sigil in variable declaration '${S(u)}'.`)}if(u instanceof String&&V(u,"await")===!0&&F)this.nextFunctionIsVoid=!0;let Z=this.is(u,"array",0),Q=this.is(u,"object",0);if(Z||Q){let X=this.generate(f,"value");return Q&&A==="statement"?`(${X})`:X}if(Array.isArray(f)&&Y==="="&&f[0]==="control"){let[,X,z,M]=f,O=S(X),P=M[0]==="return",q=this.generate(u,"value"),E=this.generate(z,"value"),H=M.length>1?M[1]:null,D=P?H?`return ${this.generate(H,"value")}`:"return":H?`throw ${this.generate(H,"value")}`:"throw new Error()";if(A==="value"){if(O==="??")return`(() => { const __v = ${E}; if (__v == null) ${D}; return (${q} = __v); })()`;if(O==="||")return`(() => { const __v = ${E}; if (!__v) ${D}; return (${q} = __v); })()`;return`(() => { const __v = ${E}; if (__v) ${D}; return (${q} = __v); })()`}if(O==="??")return`if ((${q} = ${E}) == null) ${D}`;if(O==="||")return`if (!(${q} = ${E})) ${D}`;return`if ((${q} = ${E})) ${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),M=z.slice(X+1),O=M.length;if(O>0){let P=this.generate(f,"value"),E=z.slice(0,X).map((B)=>B===","?"":typeof B==="string"?B:this.generate(B,"value")).join(", "),H=M.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],G=this.is(D,"...")?D[1]:null,I=[];if(E)I.push(`[${E}] = ${P}`);if(G)I.push(`[...${G}] = ${P}.slice(${X}, -${O})`);return I.push(`[${H}] = slice.call(${P}, -${O})`),I.join(", ")}}}if(A==="statement"&&$==="="&&Array.isArray(f)&&(f[0]==="||"||f[0]==="&&")&&f.length===3){let[X,z,M]=f;if(this.is(M,"if")&&M.length===3){let[,O,P]=M,q=Array.isArray(P)&&P.length===1?P[0]:P,E=[X,z,q],H=this.generate(u,"value"),D=this.generate(O,"value"),G=this.generate(E,"value");return`if (${D}) ${H} = ${G}`}}if(A==="statement"&&$==="="&&Array.isArray(f)&&f.length===3){let[X,z,M]=f,O=Array.isArray(M)&&M.length===1&&(!Array.isArray(M[0])||M[0][0]!=="block");if(X==="if"&&O){let P=Array.isArray(M)&&M.length===1?M[0]:M,q=this.generate(u,"value"),E=this.unwrapLogical(this.generate(z,"value")),H=this.generate(P,"value");return`if (${E}) ${q} = ${H}`}}let R;if(u instanceof String&&V(u,"await")!==void 0)R=S(u);else if(typeof u==="string"&&this.reactiveVars?.has(u))R=`${u}.value`;else this.suppressReactiveUnwrap=!0,R=this.generate(u,"value"),this.suppressReactiveUnwrap=!1;let w=this.generate(f,"value");if(!this.is(f,"object"))w=this.unwrap(w);let _=A==="value",J=A==="statement"&&this.is(u,"object");if(_||J)return`(${R} ${Y} ${w})`;return`${R} ${Y} ${w}`}generatePropertyAccess($,W,A,U){let[u,f]=W;if(this._atParamMap&&u==="this"){let Q=this._atParamMap.get(S(f));if(Q)return Q}this.suppressReactiveUnwrap=!0;let Y=this.generate(u,"value");this.suppressReactiveUnwrap=!1;let Z=y.NUMBER_LITERAL_RE.test(Y)||Y.startsWith("await ")||(this.is(u,"object")||this.is(u,"yield"))?`(${Y})`:Y;if(V(f,"await")===!0)return`await ${Z}.${S(f)}()`;if(V(f,"predicate"))return`(${Z}.${S(f)} != null)`;return`${Z}.${S(f)}`}generateOptionalProperty($,W){let[A,U]=W;return`${this.generate(A,"value")}?.${U}`}generateRegexIndex($,W){let[A,U,u]=W;this.helpers.add("toMatchable"),this.programVars.add("_");let f=this.generate(A,"value"),Y=this.generate(U,"value"),F=u!==null?this.generate(u,"value"):"0",Z=Y.includes("/m")?", true":"";return`(_ = toMatchable(${f}${Z}).match(${Y})) && _[${F}]`}generateIndexAccess($,W){let[A,U]=W;if(this.is(U,"..")||this.is(U,"...")){let u=U[0]==="..",f=this.generate(A,"value"),[Y,F]=U.slice(1);if(Y===null&&F===null)return`${f}.slice()`;if(Y===null){if(u&&this.is(F,"-",1)&&(S(F[1])??F[1])==1)return`${f}.slice(0)`;let R=this.generate(F,"value");return u?`${f}.slice(0, +${R} + 1 || 9e9)`:`${f}.slice(0, ${R})`}if(F===null)return`${f}.slice(${this.generate(Y,"value")})`;let Z=this.generate(Y,"value");if(u&&this.is(F,"-",1)&&(S(F[1])??F[1])==1)return`${f}.slice(${Z})`;let Q=this.generate(F,"value");return u?`${f}.slice(${Z}, +${Q} + 1 || 9e9)`:`${f}.slice(${Z}, ${Q})`}if(this.is(U,"-",1)){let u=S(U[1])??U[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(U,"value"))}]`}generateOptIndex($,W){let[A,U]=W;if(this.is(U,"-",1)){let u=S(U[1])??U[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(U,"value")}]`}generateOptCall($,W){let[A,...U]=W;return`${this.generate(A,"value")}?.(${U.map((u)=>this.generate(u,"value")).join(", ")})`}generateDef($,W,A,U){let[u,f,Y]=W,F=V(u,"await")===!0,Z=S(u),Q=this.generateParamList(f),R=this.generateFunctionBody(Y,f,F),w=this.containsAwait(Y),K=this.containsYield(Y);return`${w?"async ":""}function${K?"*":""} ${Z}(${Q}) ${R}`}generateThinArrow($,W,A,U){let[u,f]=W;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let F=this.generateParamList(u),Z=this.generateFunctionBody(f,u,Y),Q=this.containsAwait(f),R=this.containsYield(f),w=`${Q?"async ":""}function${R?"*":""}(${F}) ${Z}`;return A==="value"?`(${w})`:w}generateFatArrow($,W,A,U){let[u,f]=W;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let F=this.generateParamList(u),Q=u.length===1&&typeof u[0]==="string"&&!F.includes("=")&&!F.includes("...")&&!F.includes("[")&&!F.includes("{")?F:`(${F})`,w=this.containsAwait(f)?"async ":"";if(!Y){if(this.is(f,"block")&&f.length===2){let _=f[1];if(!Array.isArray(_)||_[0]!=="return")return`${w}${Q} => ${this.generate(_,"value")}`}if(!Array.isArray(f)||f[0]!=="block")return`${w}${Q} => ${this.generate(f,"value")}`}let K=this.generateFunctionBody(f,u,Y);return`${w}${Q} => ${K}`}generateReturn($,W,A,U){if(W.length===0)return"return";let[u]=W;if(this.sideEffectOnly)return"return";if(this.is(u,"if")){let[,f,Y,...F]=u;if(F.length===0){let Z=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(Z,"value")}`}}if(this.is(u,"new")&&Array.isArray(u[1])&&u[1][0]==="if"){let[,f,Y]=u[1],F=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(["new",F],"value")}`}return`return ${this.generate(u,"value")}`}generateState($,W){let[A,U]=W;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(U,"value")})`}generateComputed($,W){let[A,U]=W;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let u=S(A)??A;if(this.reactiveVars.add(u),this.is(U,"block")&&U.length>2)return`const ${u} = __computed(() => ${this.generateFunctionBody(U)})`;return`const ${u} = __computed(() => ${this.generate(U,"value")})`}generateReadonly($,W){let[A,U]=W;return`const ${S(A)??A} = ${this.generate(U,"value")}`}generateEffect($,W){let[A,U]=W;this.usesReactivity=!0;let u;if(this.is(U,"block"))u=`{
149
- ${this.withIndent(()=>this.formatStatements(U.slice(1))).join(`
150
- `)}
151
- ${this.indent()}}`;else if(this.is(U,"->")||this.is(U,"=>")){let Y=this.generate(U,"value");if(A)return`const ${S(A)??this.generate(A,"value")} = __effect(${Y})`;return`__effect(${Y})`}else u=`{ ${this.generate(U,"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($,W){return`(${this.generate(W[0],"value")} != null)`}generateTernary($,W,A){let[U,u,f]=W;if((u?.[0]?.valueOf?.()??u?.[0])==="="&&Array.isArray(u)){let F=this.generate(u[1],"value"),Z=this.generate(u[2],"value"),Q=this.generate(f,"value");return`${F} = (${this.unwrap(this.generate(U,"value"))} ? ${Z} : ${Q})`}return`(${this.unwrap(this.generate(U,"value"))} ? ${this.generate(u,"value")} : ${this.generate(f,"value")})`}generatePipe($,W){let[A,U]=W,u=this.generate(A,"value");if(Array.isArray(U)&&U.length>1){let f=U[0];if(Array.isArray(f)||typeof f==="string"&&/^[a-zA-Z_$]/.test(f)){let F=this.generate(f,"value"),Z=U.slice(1).map((Q)=>this.generate(Q,"value"));return`${F}(${u}, ${Z.join(", ")})`}}return`${this.generate(U,"value")}(${u})`}generateLoop($,W){return`while (true) ${this.generateLoopBody(W[0])}`}generateLoopN($,W){let[A,U]=W;return`for (let it = 0; it < ${this.generate(A,"value")}; it++) ${this.generateLoopBody(U)}`}generateAwait($,W){return`await ${this.generate(W[0],"value")}`}generateYield($,W){return W.length===0?"yield":`yield ${this.generate(W[0],"value")}`}generateYieldFrom($,W){return`yield* ${this.generate(W[0],"value")}`}generateIf($,W,A,U){let[u,f,...Y]=W;return A==="value"?this.generateIfAsExpression(u,f,Y):this.generateIfAsStatement(u,f,Y)}generateForIn($,W,A,U){let[u,f,Y,F,Z]=W;if(A==="value"&&this.comprehensionDepth===0){let z=["for-in",u,f,Y];return this.generate(["comprehension",Z,[z],F?[F]:[]],A)}let Q=Array.isArray(u)?u:[u],R=Q.length===0,[w,K]=R?["_i",null]:Q,_=this.is(w,"array")||this.is(w,"object")?this.generateDestructuringPattern(w):w;if(Y&&Y!==null){let z=this.generate(f,"value"),M=K||"_i",O=this.generate(Y,"value"),P=this.is(Y,"-",1),q=P&&(Y[1]==="1"||Y[1]===1||S(Y[1])==="1"),E=!P&&(Y==="1"||Y===1||S(Y)==="1"),H;if(q)H=`for (let ${M} = ${z}.length - 1; ${M} >= 0; ${M}--) `;else if(E)H=`for (let ${M} = 0; ${M} < ${z}.length; ${M}++) `;else if(P)H=`for (let ${M} = ${z}.length - 1; ${M} >= 0; ${M} += ${O}) `;else H=`for (let ${M} = 0; ${M} < ${z}.length; ${M} += ${O}) `;if(this.is(Z,"block")){let D=Z.slice(1);this.indentLevel++;let G=[];if(!R)G.push(`const ${_} = ${z}[${M}];`);if(F)G.push(`if (${this.generate(F,"value")}) {`),this.indentLevel++,G.push(...this.formatStatements(D)),this.indentLevel--,G.push(this.indent()+"}");else G.push(...D.map((I)=>this.addSemicolon(I,this.generate(I,"statement"))));return this.indentLevel--,H+`{
148
+ }`;return u}generateBinaryOp($,W,A,U){if(($==="+"||$==="-")&&W.length===1)return`(${$}${this.generate(W[0],"value")})`;let[u,f]=W;if($==="*"){let F=u?.valueOf?.()??u;if(typeof F==="string"&&/^["']/.test(F))return`${this.generate(u,"value")}.repeat(${this.generate(f,"value")})`}let Y=new Set(["<",">","<=",">="]);if(Y.has($)&&Array.isArray(u)){let F=u[0]?.valueOf?.()??u[0];if(Y.has(F)){let Z=this.generate(u[1],"value"),Q=this.generate(u[2],"value"),R=this.generate(f,"value");return`((${Z} ${F} ${Q}) && (${Q} ${$} ${R}))`}}if($==="!?"){let F=this.generate(u,"value"),Z=this.generate(f,"value");return`(${F} !== undefined ? ${F} : ${Z})`}if($==="==")$="===";if($==="!=")$="!==";return`(${this.generate(u,"value")} ${$} ${this.generate(f,"value")})`}generateModulo($,W){let[A,U]=W;return this.helpers.add("modulo"),`modulo(${this.generate(A,"value")}, ${this.generate(U,"value")})`}generateModuloAssign($,W){let[A,U]=W;this.helpers.add("modulo");let u=this.generate(A,"value"),f=this.generate(U,"value");return`${u} = modulo(${u}, ${f})`}generateFloorDiv($,W){let[A,U]=W;return`Math.floor(${this.generate(A,"value")} / ${this.generate(U,"value")})`}generateFloorDivAssign($,W){let[A,U]=W,u=this.generate(A,"value"),f=this.generate(U,"value");return`${u} = Math.floor(${u} / ${f})`}generateAssignment($,W,A,U){let[u,f]=W,Y=$==="?="?"??=":$,F=this.is(f,"->")||this.is(f,"=>")||this.is(f,"def");if(u instanceof String&&V(u,"await")!==void 0&&!F){let X=V(u,"await")===!0?"!":"&";throw Error(`Cannot use ${X} sigil in variable declaration '${S(u)}'.`)}if(u instanceof String&&V(u,"await")===!0&&F)this.nextFunctionIsVoid=!0;let Z=this.is(u,"array",0),Q=this.is(u,"object",0);if(Z||Q){let X=this.generate(f,"value");return Q&&A==="statement"?`(${X})`:X}if(Array.isArray(f)&&Y==="="&&f[0]==="control"){let[,X,z,M]=f,O=S(X),P=M[0]==="return",q=this.generate(u,"value"),E=this.generate(z,"value"),H=M.length>1?M[1]:null,D=P?H?`return ${this.generate(H,"value")}`:"return":H?`throw ${this.generate(H,"value")}`:"throw new Error()";if(A==="value"){if(O==="??")return`(() => { const __v = ${E}; if (__v == null) ${D}; return (${q} = __v); })()`;if(O==="||")return`(() => { const __v = ${E}; if (!__v) ${D}; return (${q} = __v); })()`;return`(() => { const __v = ${E}; if (__v) ${D}; return (${q} = __v); })()`}if(O==="??")return`if ((${q} = ${E}) == null) ${D}`;if(O==="||")return`if (!(${q} = ${E})) ${D}`;return`if ((${q} = ${E})) ${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),M=z.slice(X+1),O=M.length;if(O>0){let P=this.generate(f,"value"),E=z.slice(0,X).map((B)=>B===","?"":typeof B==="string"?B:this.generate(B,"value")).join(", "),H=M.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],G=this.is(D,"...")?D[1]:null,I=[];if(E)I.push(`[${E}] = ${P}`);if(G)I.push(`[...${G}] = ${P}.slice(${X}, -${O})`);return I.push(`[${H}] = slice.call(${P}, -${O})`),I.join(", ")}}}if(A==="statement"&&$==="="&&Array.isArray(f)&&(f[0]==="||"||f[0]==="&&")&&f.length===3){let[X,z,M]=f;if(this.is(M,"if")&&M.length===3){let[,O,P]=M,q=Array.isArray(P)&&P.length===1?P[0]:P,E=[X,z,q],H=this.generate(u,"value"),D=this.generate(O,"value"),G=this.generate(E,"value");return`if (${D}) ${H} = ${G}`}}if(A==="statement"&&$==="="&&Array.isArray(f)&&f.length===3){let[X,z,M]=f,O=Array.isArray(M)&&M.length===1&&(!Array.isArray(M[0])||M[0][0]!=="block");if(X==="if"&&O){let P=Array.isArray(M)&&M.length===1?M[0]:M,q=this.generate(u,"value"),E=this.unwrapLogical(this.generate(z,"value")),H=this.generate(P,"value");return`if (${E}) ${q} = ${H}`}}let R;if(u instanceof String&&V(u,"await")!==void 0)R=S(u);else if(typeof u==="string"&&this.reactiveVars?.has(u))R=`${u}.value`;else this.suppressReactiveUnwrap=!0,R=this.generate(u,"value"),this.suppressReactiveUnwrap=!1;let w=this.generate(f,"value");if(!this.is(f,"object"))w=this.unwrap(w);let _=A==="value",J=A==="statement"&&this.is(u,"object");if(_||J)return`(${R} ${Y} ${w})`;return`${R} ${Y} ${w}`}generatePropertyAccess($,W,A,U){let[u,f]=W;if(this._atParamMap&&u==="this"){let Q=this._atParamMap.get(S(f));if(Q)return Q}this.suppressReactiveUnwrap=!0;let Y=this.generate(u,"value");this.suppressReactiveUnwrap=!1;let Z=y.NUMBER_LITERAL_RE.test(Y)||Y.startsWith("await ")||(this.is(u,"object")||this.is(u,"yield"))?`(${Y})`:Y;if(V(f,"await")===!0)return`await ${Z}.${S(f)}()`;if(V(f,"predicate"))return`(${Z}.${S(f)} != null)`;return`${Z}.${S(f)}`}generateOptionalProperty($,W){let[A,U]=W;return`${this.generate(A,"value")}?.${U}`}generateRegexIndex($,W){let[A,U,u]=W;this.helpers.add("toMatchable"),this.programVars.add("_");let f=this.generate(A,"value"),Y=this.generate(U,"value"),F=u!==null?this.generate(u,"value"):"0",Z=Y.includes("/m")?", true":"";return`(_ = toMatchable(${f}${Z}).match(${Y})) && _[${F}]`}generateIndexAccess($,W){let[A,U]=W;if(this.is(U,"..")||this.is(U,"...")){let u=U[0]==="..",f=this.generate(A,"value"),[Y,F]=U.slice(1);if(Y===null&&F===null)return`${f}.slice()`;if(Y===null){if(u&&this.is(F,"-",1)&&(S(F[1])??F[1])==1)return`${f}.slice(0)`;let R=this.generate(F,"value");return u?`${f}.slice(0, +${R} + 1 || 9e9)`:`${f}.slice(0, ${R})`}if(F===null)return`${f}.slice(${this.generate(Y,"value")})`;let Z=this.generate(Y,"value");if(u&&this.is(F,"-",1)&&(S(F[1])??F[1])==1)return`${f}.slice(${Z})`;let Q=this.generate(F,"value");return u?`${f}.slice(${Z}, +${Q} + 1 || 9e9)`:`${f}.slice(${Z}, ${Q})`}if(this.is(U,"-",1)){let u=S(U[1])??U[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(U,"value"))}]`}generateOptIndex($,W){let[A,U]=W;if(this.is(U,"-",1)){let u=S(U[1])??U[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(U,"value")}]`}generateOptCall($,W){let[A,...U]=W;return`${this.generate(A,"value")}?.(${U.map((u)=>this.generate(u,"value")).join(", ")})`}generateDef($,W,A,U){let[u,f,Y]=W,F=V(u,"await")===!0,Z=S(u),Q=this.generateParamList(f),R=this.generateFunctionBody(Y,f,F),w=this.containsAwait(Y),K=this.containsYield(Y);return`${w?"async ":""}function${K?"*":""} ${Z}(${Q}) ${R}`}generateThinArrow($,W,A,U){let[u,f]=W;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let F=this.generateParamList(u),Z=this.generateFunctionBody(f,u,Y),Q=this.containsAwait(f),R=this.containsYield(f),w=`${Q?"async ":""}function${R?"*":""}(${F}) ${Z}`;return A==="value"?`(${w})`:w}generateFatArrow($,W,A,U){let[u,f]=W;if((!u||Array.isArray(u)&&u.length===0)&&this.containsIt(f))u=["it"];let Y=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let F=this.generateParamList(u),Q=u.length===1&&typeof u[0]==="string"&&!F.includes("=")&&!F.includes("...")&&!F.includes("[")&&!F.includes("{")?F:`(${F})`,w=this.containsAwait(f)?"async ":"";if(!Y){if(this.is(f,"block")&&f.length===2){let _=f[1];if(!Array.isArray(_)||_[0]!=="return")return`${w}${Q} => ${this.generate(_,"value")}`}if(!Array.isArray(f)||f[0]!=="block")return`${w}${Q} => ${this.generate(f,"value")}`}let K=this.generateFunctionBody(f,u,Y);return`${w}${Q} => ${K}`}generateReturn($,W,A,U){if(W.length===0)return"return";let[u]=W;if(this.sideEffectOnly)return"return";if(this.is(u,"if")){let[,f,Y,...F]=u;if(F.length===0){let Z=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(Z,"value")}`}}if(this.is(u,"new")&&Array.isArray(u[1])&&u[1][0]==="if"){let[,f,Y]=u[1],F=Array.isArray(Y)&&Y.length===1?Y[0]:Y;return`if (${this.generate(f,"value")}) return ${this.generate(["new",F],"value")}`}return`return ${this.generate(u,"value")}`}generateState($,W){let[A,U]=W;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(U,"value")})`}generateComputed($,W){let[A,U]=W;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let u=S(A)??A;if(this.reactiveVars.add(u),this.is(U,"block")&&U.length>2)return`const ${u} = __computed(() => ${this.generateFunctionBody(U)})`;return`const ${u} = __computed(() => ${this.generate(U,"value")})`}generateReadonly($,W){let[A,U]=W;return`const ${S(A)??A} = ${this.generate(U,"value")}`}generateEffect($,W){let[A,U]=W;this.usesReactivity=!0;let u;if(this.is(U,"block"))u=this.generateFunctionBody(U);else if(this.is(U,"->")||this.is(U,"=>")){let Y=this.generate(U,"value");if(A)return`const ${S(A)??this.generate(A,"value")} = __effect(${Y})`;return`__effect(${Y})`}else u=`{ ${this.generate(U,"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($,W){return`(${this.generate(W[0],"value")} != null)`}generateTernary($,W,A){let[U,u,f]=W;if((u?.[0]?.valueOf?.()??u?.[0])==="="&&Array.isArray(u)){let F=this.generate(u[1],"value"),Z=this.generate(u[2],"value"),Q=this.generate(f,"value");return`${F} = (${this.unwrap(this.generate(U,"value"))} ? ${Z} : ${Q})`}return`(${this.unwrap(this.generate(U,"value"))} ? ${this.generate(u,"value")} : ${this.generate(f,"value")})`}generatePipe($,W){let[A,U]=W,u=this.generate(A,"value");if(Array.isArray(U)&&U.length>1){let f=U[0];if(Array.isArray(f)||typeof f==="string"&&/^[a-zA-Z_$]/.test(f)){let F=this.generate(f,"value"),Z=U.slice(1).map((Q)=>this.generate(Q,"value"));return`${F}(${u}, ${Z.join(", ")})`}}return`${this.generate(U,"value")}(${u})`}generateLoop($,W){return`while (true) ${this.generateLoopBody(W[0])}`}generateLoopN($,W){let[A,U]=W;return`for (let it = 0; it < ${this.generate(A,"value")}; it++) ${this.generateLoopBody(U)}`}generateAwait($,W){return`await ${this.generate(W[0],"value")}`}generateYield($,W){return W.length===0?"yield":`yield ${this.generate(W[0],"value")}`}generateYieldFrom($,W){return`yield* ${this.generate(W[0],"value")}`}generateIf($,W,A,U){let[u,f,...Y]=W;return A==="value"?this.generateIfAsExpression(u,f,Y):this.generateIfAsStatement(u,f,Y)}generateForIn($,W,A,U){let[u,f,Y,F,Z]=W;if(A==="value"&&this.comprehensionDepth===0){let z=["for-in",u,f,Y];return this.generate(["comprehension",Z,[z],F?[F]:[]],A)}let Q=Array.isArray(u)?u:[u],R=Q.length===0,[w,K]=R?["_i",null]:Q,_=this.is(w,"array")||this.is(w,"object")?this.generateDestructuringPattern(w):w;if(Y&&Y!==null){let z=this.generate(f,"value"),M=K||"_i",O=this.generate(Y,"value"),P=this.is(Y,"-",1),q=P&&(Y[1]==="1"||Y[1]===1||S(Y[1])==="1"),E=!P&&(Y==="1"||Y===1||S(Y)==="1"),H;if(q)H=`for (let ${M} = ${z}.length - 1; ${M} >= 0; ${M}--) `;else if(E)H=`for (let ${M} = 0; ${M} < ${z}.length; ${M}++) `;else if(P)H=`for (let ${M} = ${z}.length - 1; ${M} >= 0; ${M} += ${O}) `;else H=`for (let ${M} = 0; ${M} < ${z}.length; ${M} += ${O}) `;if(this.is(Z,"block")){let D=Z.slice(1);this.indentLevel++;let G=[];if(!R)G.push(`const ${_} = ${z}[${M}];`);if(F)G.push(`if (${this.generate(F,"value")}) {`),this.indentLevel++,G.push(...this.formatStatements(D)),this.indentLevel--,G.push(this.indent()+"}");else G.push(...D.map((I)=>this.addSemicolon(I,this.generate(I,"statement"))));return this.indentLevel--,H+`{
152
149
  ${G.map((I)=>this.indent()+I).join(`
153
150
  `)}
154
151
  ${this.indent()}}`}if(R)return F?H+`{ if (${this.generate(F,"value")}) ${this.generate(Z,"statement")}; }`:H+`{ ${this.generate(Z,"statement")}; }`;return F?H+`{ const ${_} = ${z}[${M}]; if (${this.generate(F,"value")}) ${this.generate(Z,"statement")}; }`:H+`{ const ${_} = ${z}[${M}]; ${this.generate(Z,"statement")}; }`}if(K){let z=this.generate(f,"value"),M=`for (let ${K} = 0; ${K} < ${z}.length; ${K}++) `;if(this.is(Z,"block")){if(M+=`{
@@ -517,8 +514,8 @@ if (typeof globalThis !== 'undefined') {
517
514
  `:"",$=U.slice(0,u).join(`
518
515
  `)}let Y=new p().tokenize($);if(this.options.showTokens)Y.forEach((X)=>console.log(`${X[0].padEnd(12)} ${JSON.stringify(X[1])}`)),console.log();let F=null,Z=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)Z=[...Y];Y=Y.filter((X)=>X[0]!=="TYPE_DECL");while(Y.length>0&&Y[0][0]==="TERMINATOR")Y.shift();if(Y.every((X)=>X[0]==="TERMINATOR")){if(Z)F=N1(Z,["program"]);return{tokens:Y,sexpr:["program"],code:"",dts:F,data:A,reactiveVars:{}}}s.lexer={tokens:Y,pos:0,setInput:function(){},lex:function(){if(this.pos>=this.tokens.length)return 1;let X=this.tokens[this.pos++],z=X[1];if(X.data)z=new String(z),Object.assign(z,X.data);return this.text=z,this.loc=X.loc,X[0]}};let Q;try{Q=s.parse($)}catch(X){if(/\?\s*\([^)]*\?[^)]*:[^)]*\)\s*:/.test($)||/\?\s+\w+\s+\?\s+/.test($))throw Error("Nested ternary operators are not supported. Use if/else statements instead.");throw X}if(this.options.showSExpr)console.log(x(Q,0,!0)),console.log();let R=null;if(this.options.sourceMap){let X=(this.options.filename||"output")+".js",z=this.options.filename||"input.rip";R=new h1(X,z,$)}let w=new y({dataSection:A,skipPreamble:this.options.skipPreamble,reactiveVars:this.options.reactiveVars,sourceMap:R}),K=w.compile(Q),_=R?R.toJSON():null,J=R?R.toReverseMap():null;if(_&&this.options.sourceMap==="inline"){let X=typeof Buffer<"u"?Buffer.from(_).toString("base64"):btoa(_);K+=`
519
516
  //# sourceMappingURL=data:application/json;base64,${X}`}else if(_&&this.options.filename)K+=`
520
- //# sourceMappingURL=${this.options.filename}.js.map`;if(Z)F=N1(Z,Q);return{tokens:Y,sexpr:Q,code:K,dts:F,map:_,reverseMap:J,data:A,reactiveVars:w.reactiveVars}}compileToJS($){return this.compile($).code}compileToSExpr($){return this.compile($).sexpr}}D2(y,p);y.prototype.generateEnum=t1;function C1($,W={}){return new w1(W).compile($)}function r($,W={}){return new w1(W).compileToJS($)}function z1(){return new y({}).getReactiveRuntime()}function y1(){return new y({}).getComponentRuntime()}var V3="3.10.9",j3="2026-02-20@07:22:34GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(z1())();var h3=($)=>{let W=$.match(/^[ \t]*(?=\S)/gm),A=Math.min(...(W||[]).map((U)=>U.length));return $.replace(RegExp(`^[ ]{${A}}`,"gm"),"").trim()};async function C3(){let $=document.querySelectorAll('script[type="text/rip"]');for(let W of $){if(W.hasAttribute("data-rip-processed"))continue;if(W.hasAttribute("data-name"))continue;try{let A;if(W.src){let u=await fetch(W.src);if(!u.ok){console.error(`Rip: failed to fetch ${W.src} (${u.status})`);continue}A=await u.text()}else A=h3(W.textContent);let U;try{U=r(A)}catch(u){console.error("Rip compile error:",u.message),console.error("Source:",A);continue}await(0,eval)(`(async()=>{
517
+ //# sourceMappingURL=${this.options.filename}.js.map`;if(Z)F=N1(Z,Q);return{tokens:Y,sexpr:Q,code:K,dts:F,map:_,reverseMap:J,data:A,reactiveVars:w.reactiveVars}}compileToJS($){return this.compile($).code}compileToSExpr($){return this.compile($).sexpr}}D2(y,p);y.prototype.generateEnum=t1;function C1($,W={}){return new w1(W).compile($)}function r($,W={}){return new w1(W).compileToJS($)}function z1(){return new y({}).getReactiveRuntime()}function y1(){return new y({}).getComponentRuntime()}var V3="3.10.11",j3="2026-02-20@13:12:39GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(z1())();var h3=($)=>{let W=$.match(/^[ \t]*(?=\S)/gm),A=Math.min(...(W||[]).map((U)=>U.length));return $.replace(RegExp(`^[ ]{${A}}`,"gm"),"").trim()};async function C3(){let $=document.querySelectorAll('script[type="text/rip"]');for(let W of $){if(W.hasAttribute("data-rip-processed"))continue;if(W.hasAttribute("data-name"))continue;try{let A;if(W.src){let u=await fetch(W.src);if(!u.ok){console.error(`Rip: failed to fetch ${W.src} (${u.status})`);continue}A=await u.text()}else A=h3(W.textContent);let U;try{U=r(A)}catch(u){console.error("Rip compile error:",u.message),console.error("Source:",A);continue}await(0,eval)(`(async()=>{
521
518
  ${U}
522
519
  })()`),W.setAttribute("data-rip-processed","true")}catch(A){console.error("Rip runtime error:",A)}}}async function e($){for(let[f,Y]of Object.entries(e.modules))if($.includes(f))return Y;let W=await fetch($).then((f)=>{if(!f.ok)throw Error(`importRip: ${$} (${f.status})`);return f.text()}),A=r(W),U=new Blob([A],{type:"application/javascript"}),u=URL.createObjectURL(U);try{return await import(u)}finally{URL.revokeObjectURL(u)}}e.modules={};function y3($){try{let W=$.replace(/^/gm," "),U=r(`do ->
523
- ${W}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let u=(0,eval)(U);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(W){console.error("Rip compilation error:",W.message);return}}if(typeof globalThis<"u")globalThis.rip=y3,globalThis.importRip=e,globalThis.compileToJS=r,globalThis.__ripExports={compile:C1,compileToJS:r,formatSExpr:x,VERSION:V3,BUILD_DATE:j3,getReactiveRuntime:z1,getComponentRuntime:y1};async function b3(){if(globalThis.__ripLaunched)return;let $=e.modules?.["ui.rip"];if(!$?.launch)return;let W=document.querySelector("script[data-hash], script[data-url]"),A=W?.getAttribute("data-url")||"";if(!(document.querySelectorAll('script[type="text/rip"][data-name]').length>0)&&!A)return;let u={};if(W?.hasAttribute("data-hash"))u.hash=W.getAttribute("data-hash")!=="false";await $.launch(A,u)}if(typeof document<"u")globalThis.__ripScriptsReady=new Promise(($)=>{let W=()=>C3().then(b3).then($);if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>queueMicrotask(W));else queueMicrotask(W)});var n1={};x2(n1,{throttle:()=>x3,stash:()=>j2,setContext:()=>T2,raw:()=>h2,launch:()=>k3,isStash:()=>c3,hold:()=>l3,hasContext:()=>I2,getContext:()=>G2,delay:()=>C2,debounce:()=>g3,createRouter:()=>b2,createResource:()=>v3,createRenderer:()=>c2,createComponents:()=>y2});var M2,g1,u1,k,O1,w2,o,j,b1,F1,Z1,x1,z2,H2,H1,q1,q2,O2,P2,c1,v1,G2,E2,l1,I2,Y1,k1,B2,N2,T2,S2,L2,m1,V2;({__state:j,__effect:o,__batch:w2}=globalThis.__rip);({setContext:T2,getContext:G2,hasContext:I2}=globalThis.__ripComponent||{});O1=Symbol("stash");k=Symbol("signals");u1=Symbol("raw");g1=new WeakMap;b1=0;x1=j(0);l1=function($,W){let A;if(!$[k])Object.defineProperty($,k,{value:new Map,enumerable:!1});if(A=$[k].get(W),!A)A=j($[W]),$[k].set(W,A);return A};Y1=function($){return l1($,Symbol.for("keys"))};V2=function($){let W;if(!($!=null&&typeof $==="object"))return $;if($[O1])return $;if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Promise)return $;if(W=g1.get($),W)return W;return k1($)};k1=function($){let W,A;return A=null,W={get:function(U,u){let f,Y;if(u===O1)return!0;if(u===u1)return U;if(typeof u==="symbol")return Reflect.get(U,u);if(u==="length"&&Array.isArray(U))return Y1(U).value,U.length;if(u==="get")return function(F){return S2(A,F)};if(u==="set")return function(F,Z){return L2(A,F,Z)};if(f=l1(U,u),Y=f.value,Y!=null&&typeof Y==="object")return V2(Y);return Y},set:function(U,u,f){let Y,F;if(Y=U[u],F=f?.[u1]?f[u1]:f,F===Y)return!0;if(U[u]=F,U[k]?.has(u))U[k].get(u).value=F;if(Y===void 0&&F!==void 0)Y1(U).value=++b1;return x1.value++,!0},deleteProperty:function(U,u){let f;if(delete U[u],f=U[k]?.get(u),f)f.value=void 0;return Y1(U).value=++b1,!0},ownKeys:function(U){return Y1(U).value,Reflect.ownKeys(U)}},A=new Proxy($,W),g1.set($,A),A};M2=/([./][^./\[\s]+|\[[-+]?\d+\]|\[(?:"[^"]+"|'[^']+')\])/;m1=function($){let W,A,U,u,f;U=("."+$).split(M2),U.shift(),f=[],A=0;while(A<U.length){if(u=U[A],W=u[0],W==="."||W==="/")f.push(u.slice(1));else if(W==="[")if(u[1]==='"'||u[1]==="'")f.push(u.slice(2,-2));else f.push(+u.slice(1,-1));A+=2}return f};S2=function($,W){let A,U;U=m1(W),A=$;for(let u of U){if(A==null)return;A=A[u]}return A};L2=function($,W,A){let U,u;u=m1(W),U=$;for(let f=0;f<u.length;f++){let Y=u[f];if(f===u.length-1)U[Y]=A;else{if(U[Y]==null)U[Y]={};U=U[Y]}}return A};Z1=function($){return typeof $==="function"?$:function(){return $.value}};F1=function($,W){let A;return A={read:function(){return $.read()}},Object.defineProperty(A,"value",{get:function(){return $.value},set:function(U){return W.value=U}}),A};P2=function($){let W;if(W=$.replace(/\.rip$/,""),W=W.replace(/\[\.\.\.(\w+)\]/g,"*$1"),W=W.replace(/\[(\w+)\]/g,":$1"),W==="index")return"/";return W=W.replace(/\/index$/,""),"/"+W};N2=function($){let W,A;return W=[],A=$.replace(/\*(\w+)/g,function(U,u){return W.push(u),"(.+)"}).replace(/:(\w+)/g,function(U,u){return W.push(u),"([^/]+)"}),{regex:new RegExp("^"+A+"$"),names:W}};B2=function($,W){let A,U;for(let u of W)if(A=$.match(u.regex.regex),A){U={};for(let f=0;f<u.regex.names.length;f++){let Y=u.regex.names[f];U[Y]=decodeURIComponent(A[f+1])}return{route:u,params:U}}return null};H1=function($,W="components"){let A,U,u,f,Y,F,Z,Q,R;Z=[],u=new Map,A=$.listAll(W);for(let w of A){if(F=w.slice(W.length+1),!F.endsWith(".rip"))continue;if(f=F.split("/").pop(),f==="_layout.rip"){U=F==="_layout.rip"?"":F.slice(0,-12),u.set(U,w);continue}if(f.startsWith("_"))continue;if(Q=F.split("/"),Q.length>1&&Q.some(function(K,_){return _<Q.length-1&&K.startsWith("_")}))continue;R=P2(F),Y=N2(R),Z.push({pattern:R,regex:Y,file:w,rel:F})}return Z.sort(function(w,K){let _,J,X,z;if(J=(w.pattern.match(/:/g)||[]).length,z=(K.pattern.match(/:/g)||[]).length,_=w.pattern.includes("*")?1:0,X=K.pattern.includes("*")?1:0,_!==X)return _-X;if(J!==z)return J-z;return w.pattern.localeCompare(K.pattern)}),{routes:Z,layouts:u}};E2=function($,W,A){let U,u,f,Y;if(U=[],f=$.slice(W.length+1),Y=f.split("/"),u="",A.has(""))U.push(A.get(""));for(let F=0;F<Y.length;F++){let Z=Y[F];if(F===Y.length-1)break;if(u=u?u+"/"+Z:Z,A.has(u))U.push(A.get(u))}return U};z2=function($,W){if($.length!==W.length)return!1;for(let A=0;A<$.length;A++)if($[A]!==W[A])return!1;return!0};v1=function($){for(let W in $){let A=$[W];if(typeof A==="function"&&(A.prototype?.mount||A.prototype?._create))return A}return typeof $.default==="function"?$.default:void 0};c1=function($){let W;W={};for(let A in $){let U=$[A];if(typeof U==="function"&&(U.prototype?.mount||U.prototype?._create))W[A]=U}return W};O2=function($){let W;return W=$.split("/").pop().replace(/\.rip$/,""),W.replace(/(^|[-_])([a-z])/g,function(A,U,u){return u.toUpperCase()})};H2=function($,W="components"){let A,U,u;U={};for(let f of $.listAll(W)){if(!f.endsWith(".rip"))continue;if(A=f.split("/").pop(),A.startsWith("_"))continue;if(u=O2(f),U[u])console.warn(`[Rip] Component name collision: ${u} (${U[u]} vs ${f})`);U[u]=f}return U};q1=async function($,W,A=null,U=null,u=null){let f,Y,F,Z,Q,R,w,K,_,J,X;if(A&&U){if(Y=A.getCompiled(U),Y)return Y}if(R=W($),u){_={};for(let z in u.map){let M=u.map[z];if(M!==U&&R.includes(`new ${z}(`)){if(!u.classes[z]){if(Z=A.read(M),Z){F=await q1(Z,W,A,M,u),Q=c1(F);for(let O in Q){let P=Q[O];u.classes[O]=P}}}if(u.classes[z])_[z]=!0}}if(K=Object.keys(_),K.length>0)J=`const {${K.join(", ")}} = globalThis['${u.key}'];
520
+ ${W}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let u=(0,eval)(U);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(W){console.error("Rip compilation error:",W.message);return}}if(typeof globalThis<"u")globalThis.rip=y3,globalThis.importRip=e,globalThis.compileToJS=r,globalThis.__ripExports={compile:C1,compileToJS:r,formatSExpr:x,VERSION:V3,BUILD_DATE:j3,getReactiveRuntime:z1,getComponentRuntime:y1};async function b3(){if(globalThis.__ripLaunched)return;let $=e.modules?.["ui.rip"];if(!$?.launch)return;let W=document.querySelector("script[data-hash], script[data-url]"),A=W?.getAttribute("data-url")||"";if(!(document.querySelectorAll('script[type="text/rip"][data-name]').length>0)&&!A)return;let f={hash:W?.getAttribute("data-hash")!=="false"};await $.launch(A,f)}if(typeof document<"u")globalThis.__ripScriptsReady=new Promise(($)=>{let W=()=>C3().then(b3).then($);if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>queueMicrotask(W));else queueMicrotask(W)});var n1={};x2(n1,{throttle:()=>x3,stash:()=>j2,setContext:()=>T2,raw:()=>h2,launch:()=>k3,isStash:()=>c3,hold:()=>l3,hasContext:()=>I2,getContext:()=>G2,delay:()=>C2,debounce:()=>g3,createRouter:()=>b2,createResource:()=>v3,createRenderer:()=>c2,createComponents:()=>y2});var M2,g1,u1,k,O1,w2,o,j,b1,F1,Z1,x1,z2,H2,H1,q1,q2,O2,P2,c1,v1,G2,E2,l1,I2,Y1,k1,B2,N2,T2,S2,L2,m1,V2;({__state:j,__effect:o,__batch:w2}=globalThis.__rip);({setContext:T2,getContext:G2,hasContext:I2}=globalThis.__ripComponent||{});O1=Symbol("stash");k=Symbol("signals");u1=Symbol("raw");g1=new WeakMap;b1=0;x1=j(0);l1=function($,W){let A;if(!$[k])Object.defineProperty($,k,{value:new Map,enumerable:!1});if(A=$[k].get(W),!A)A=j($[W]),$[k].set(W,A);return A};Y1=function($){return l1($,Symbol.for("keys"))};V2=function($){let W;if(!($!=null&&typeof $==="object"))return $;if($[O1])return $;if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Promise)return $;if(W=g1.get($),W)return W;return k1($)};k1=function($){let W,A;return A=null,W={get:function(U,u){let f,Y;if(u===O1)return!0;if(u===u1)return U;if(typeof u==="symbol")return Reflect.get(U,u);if(u==="length"&&Array.isArray(U))return Y1(U).value,U.length;if(u==="get")return function(F){return S2(A,F)};if(u==="set")return function(F,Z){return L2(A,F,Z)};if(f=l1(U,u),Y=f.value,Y!=null&&typeof Y==="object")return V2(Y);return Y},set:function(U,u,f){let Y,F;if(Y=U[u],F=f?.[u1]?f[u1]:f,F===Y)return!0;if(U[u]=F,U[k]?.has(u))U[k].get(u).value=F;if(Y===void 0&&F!==void 0)Y1(U).value=++b1;return x1.value++,!0},deleteProperty:function(U,u){let f;if(delete U[u],f=U[k]?.get(u),f)f.value=void 0;return Y1(U).value=++b1,!0},ownKeys:function(U){return Y1(U).value,Reflect.ownKeys(U)}},A=new Proxy($,W),g1.set($,A),A};M2=/([./][^./\[\s]+|\[[-+]?\d+\]|\[(?:"[^"]+"|'[^']+')\])/;m1=function($){let W,A,U,u,f;U=("."+$).split(M2),U.shift(),f=[],A=0;while(A<U.length){if(u=U[A],W=u[0],W==="."||W==="/")f.push(u.slice(1));else if(W==="[")if(u[1]==='"'||u[1]==="'")f.push(u.slice(2,-2));else f.push(+u.slice(1,-1));A+=2}return f};S2=function($,W){let A,U;U=m1(W),A=$;for(let u of U){if(A==null)return;A=A[u]}return A};L2=function($,W,A){let U,u;u=m1(W),U=$;for(let f=0;f<u.length;f++){let Y=u[f];if(f===u.length-1)U[Y]=A;else{if(U[Y]==null)U[Y]={};U=U[Y]}}return A};Z1=function($){return typeof $==="function"?$:function(){return $.value}};F1=function($,W){let A;return A={read:function(){return $.read()}},Object.defineProperty(A,"value",{get:function(){return $.value},set:function(U){return W.value=U}}),A};P2=function($){let W;if(W=$.replace(/\.rip$/,""),W=W.replace(/\[\.\.\.(\w+)\]/g,"*$1"),W=W.replace(/\[(\w+)\]/g,":$1"),W==="index")return"/";return W=W.replace(/\/index$/,""),"/"+W};N2=function($){let W,A;return W=[],A=$.replace(/\*(\w+)/g,function(U,u){return W.push(u),"(.+)"}).replace(/:(\w+)/g,function(U,u){return W.push(u),"([^/]+)"}),{regex:new RegExp("^"+A+"$"),names:W}};B2=function($,W){let A,U;for(let u of W)if(A=$.match(u.regex.regex),A){U={};for(let f=0;f<u.regex.names.length;f++){let Y=u.regex.names[f];U[Y]=decodeURIComponent(A[f+1])}return{route:u,params:U}}return null};H1=function($,W="components"){let A,U,u,f,Y,F,Z,Q,R;Z=[],u=new Map,A=$.listAll(W);for(let w of A){if(F=w.slice(W.length+1),!F.endsWith(".rip"))continue;if(f=F.split("/").pop(),f==="_layout.rip"){U=F==="_layout.rip"?"":F.slice(0,-12),u.set(U,w);continue}if(f.startsWith("_"))continue;if(Q=F.split("/"),Q.length>1&&Q.some(function(K,_){return _<Q.length-1&&K.startsWith("_")}))continue;R=P2(F),Y=N2(R),Z.push({pattern:R,regex:Y,file:w,rel:F})}return Z.sort(function(w,K){let _,J,X,z;if(J=(w.pattern.match(/:/g)||[]).length,z=(K.pattern.match(/:/g)||[]).length,_=w.pattern.includes("*")?1:0,X=K.pattern.includes("*")?1:0,_!==X)return _-X;if(J!==z)return J-z;return w.pattern.localeCompare(K.pattern)}),{routes:Z,layouts:u}};E2=function($,W,A){let U,u,f,Y;if(U=[],f=$.slice(W.length+1),Y=f.split("/"),u="",A.has(""))U.push(A.get(""));for(let F=0;F<Y.length;F++){let Z=Y[F];if(F===Y.length-1)break;if(u=u?u+"/"+Z:Z,A.has(u))U.push(A.get(u))}return U};z2=function($,W){if($.length!==W.length)return!1;for(let A=0;A<$.length;A++)if($[A]!==W[A])return!1;return!0};v1=function($){for(let W in $){let A=$[W];if(typeof A==="function"&&(A.prototype?.mount||A.prototype?._create))return A}return typeof $.default==="function"?$.default:void 0};c1=function($){let W;W={};for(let A in $){let U=$[A];if(typeof U==="function"&&(U.prototype?.mount||U.prototype?._create))W[A]=U}return W};O2=function($){let W;return W=$.split("/").pop().replace(/\.rip$/,""),W.replace(/(^|[-_])([a-z])/g,function(A,U,u){return u.toUpperCase()})};H2=function($,W="components"){let A,U,u;U={};for(let f of $.listAll(W)){if(!f.endsWith(".rip"))continue;if(A=f.split("/").pop(),A.startsWith("_"))continue;if(u=O2(f),U[u])console.warn(`[Rip] Component name collision: ${u} (${U[u]} vs ${f})`);U[u]=f}return U};q1=async function($,W,A=null,U=null,u=null){let f,Y,F,Z,Q,R,w,K,_,J,X;if(A&&U){if(Y=A.getCompiled(U),Y)return Y}if(R=W($),u){_={};for(let z in u.map){let M=u.map[z];if(M!==U&&R.includes(`new ${z}(`)){if(!u.classes[z]){if(Z=A.read(M),Z){F=await q1(Z,W,A,M,u),Q=c1(F);for(let O in Q){let P=Q[O];u.classes[O]=P}}}if(u.classes[z])_[z]=!0}}if(K=Object.keys(_),K.length>0)J=`const {${K.join(", ")}} = globalThis['${u.key}'];
524
521
  `,R=J+R}f=new Blob([R],{type:"application/javascript"}),X=URL.createObjectURL(f);try{w=await import(X)}finally{URL.revokeObjectURL(X)}if(u){Q=c1(w);for(let z in Q){let M=Q[z];u.classes[z]=M}}if(A&&U)A.setCompiled(U,w);return w};q2=function($){let W,A,U;return U=1000,A=30000,W=function(){let u;return u=new EventSource($),u.addEventListener("connected",function(){return U=1000,console.log("[Rip] Hot reload connected")}),u.addEventListener("reload",function(){return console.log("[Rip] Reloading..."),location.reload()}),u.onerror=function(){return u.close(),setTimeout(W,U),U=Math.min(U*2,A)}},W()};var j2=function($={}){return k1($)},h2=function($){return $?.[u1]?$[u1]:$},c3=function($){return $?.[O1]===!0},v3=function($,W={}){let A,U,u,f,Y;if(A=j(W.initial||null),u=j(!1),U=j(null),f=async function(){let F;return u.value=!0,U.value=null,(async()=>{try{return F=await $(),A.value=F}catch(Z){return U.value=Z}finally{u.value=!1}})()},Y={data:void 0,loading:void 0,error:void 0,refetch:f},Object.defineProperty(Y,"data",{get:function(){return A.value}}),Object.defineProperty(Y,"loading",{get:function(){return u.value}}),Object.defineProperty(Y,"error",{get:function(){return U.value}}),!W.lazy)f();return Y},C2=function($,W){let A,U;return A=Z1(W),U=j(!!A()),o(function(){let u;if(A())return u=setTimeout(function(){return U.value=!0},$),function(){return clearTimeout(u)};else return U.value=!1}),typeof W!=="function"?F1(U,W):U},g3=function($,W){let A,U;return A=Z1(W),U=j(A()),o(function(){let u,f;return f=A(),u=setTimeout(function(){return U.value=f},$),function(){return clearTimeout(u)}}),typeof W!=="function"?F1(U,W):U},x3=function($,W){let A,U,u;return A=Z1(W),u=j(A()),U=0,o(function(){let f,Y,F,Z;if(Z=A(),f=Date.now(),Y=$-(f-U),Y<=0)return u.value=Z,U=f;else return F=setTimeout(function(){return u.value=A(),U=Date.now()},Y),function(){return clearTimeout(F)}}),typeof W!=="function"?F1(u,W):u},l3=function($,W){let A,U;return A=Z1(W),U=j(!!A()),o(function(){let u;if(A())return U.value=!0;else return u=setTimeout(function(){return U.value=!1},$),function(){return clearTimeout(u)}}),typeof W!=="function"?F1(U,W):U},y2=function(){let $,W,A,U;return W=new Map,U=[],$=new Map,A=function(u,f){for(let Y of U)Y(u,f)},{read:function(u){return W.get(u)},write:function(u,f){let Y;return Y=!W.has(u),W.set(u,f),$.delete(u),A(Y?"create":"change",u)},del:function(u){return W.delete(u),$.delete(u),A("delete",u)},exists:function(u){return W.has(u)},size:function(){return W.size},list:function(u=""){let f,Y,F;F=[],f=u?u+"/":"";for(let[Z]of W)if(Z.startsWith(f)){if(Y=Z.slice(f.length),Y.includes("/"))continue;F.push(Z)}return F},listAll:function(u=""){let f,Y;Y=[],f=u?u+"/":"";for(let[F]of W)if(F.startsWith(f))Y.push(F);return Y},load:function(u){for(let f in u){let Y=u[f];W.set(f,Y)}},watch:function(u){return U.push(u),function(){return U.splice(U.indexOf(u),1)}},getCompiled:function(u){return $.get(u)},setCompiled:function(u,f){return $.set(u,f)}}},b2=function($,W={}){let A,U,u,f,Y,F,Z,Q,R,w,K,_,J,X,z,M,O,P,q,E,H;if(O=W.root||"components",R=W.base||"",w=W.hash||!1,J=W.onError||null,q=function(D){return R&&D.startsWith(R)?D.slice(R.length)||"/":D},Q=function(D){return R?R+D:D},z=function(){let D;if(w){if(D=location.hash.slice(1),!D)return"/";return D[0]==="/"?D:"/"+D}else return location.pathname+location.search+location.hash},H=function(D){return w?D==="/"?location.pathname:"#"+D.slice(1):Q(D)},Y=j(q(w?z():location.pathname)),f=j({}),Z=j(null),U=j([]),F=j({}),A=j(""),u=C2(100,j(!1)),E=H1($,O),K=new Set,$.watch(function(D,G){if(!G.startsWith(O+"/"))return;return E=H1($,O)}),M=function(D){let G,I,B,N,T;if(N=D.split("?")[0].split("#")[0],I=q(N),I=I[0]==="/"?I:"/"+I,B=D.split("?")[1]?.split("#")[0]||"",G=D.includes("#")?D.split("#")[1]:"",T=B2(I,E.routes),T){w2(function(){return Y.value=I,f.value=T.params,Z.value=T.route,U.value=E2(T.route.file,O,E.layouts),F.value=Object.fromEntries(new URLSearchParams(B)),A.value=G});for(let L of K)L(P.current);return!0}if(J)J({status:404,path:I});return!1},X=function(){return M(z())},typeof window<"u")window.addEventListener("popstate",X);if(_=function(D){let G,I,B;if(D.button!==0||D.metaKey||D.ctrlKey||D.shiftKey||D.altKey)return;I=D.target;while(I&&I.tagName!=="A")I=I.parentElement;if(!I?.href)return;if(B=new URL(I.href,location.origin),B.origin!==location.origin)return;if(I.target==="_blank"||I.hasAttribute("data-external"))return;return D.preventDefault(),G=w&&B.hash?B.hash.slice(1)||"/":B.pathname+B.search+B.hash,P.push(G)},typeof document<"u")document.addEventListener("click",_);return P={push:function(D){return M(D)?history.pushState(null,"",H(Y.read())):void 0},replace:function(D){return M(D)?history.replaceState(null,"",H(Y.read())):void 0},back:function(){return history.back()},forward:function(){return history.forward()},current:void 0,path:void 0,params:void 0,route:void 0,layouts:void 0,query:void 0,hash:void 0,navigating:void 0,onNavigate:function(D){return K.add(D),function(){return K.delete(D)}},rebuild:function(){return E=H1($,O)},routes:void 0,init:function(){return M(z()),P},destroy:function(){if(typeof window<"u")window.removeEventListener("popstate",X);if(typeof document<"u")document.removeEventListener("click",_);return K.clear()}},Object.defineProperty(P,"current",{get:function(){return{path:Y.value,params:f.value,route:Z.value,layouts:U.value,query:F.value,hash:A.value}}}),Object.defineProperty(P,"path",{get:function(){return Y.value}}),Object.defineProperty(P,"params",{get:function(){return f.value}}),Object.defineProperty(P,"route",{get:function(){return Z.value}}),Object.defineProperty(P,"layouts",{get:function(){return U.value}}),Object.defineProperty(P,"query",{get:function(){return F.value}}),Object.defineProperty(P,"hash",{get:function(){return A.value}}),Object.defineProperty(P,"navigating",{get:function(){return u.value},set:function(D){return u.value=D}}),Object.defineProperty(P,"routes",{get:function(){return E.routes}}),P},c2=function($={}){let W,A,U,u,f,Y,F,Z,Q,R,w,K,_,J,X,z,M,O,P,q,E;if({router:P,app:W,components:f,resolver:O,compile:U,target:q,onError:z}=$,Y=typeof q==="string"?document.querySelector(q):q||document.getElementById("app"),!Y)Y=document.createElement("div"),Y.id="app",document.body.appendChild(Y);return Y.style.opacity="0",F=null,Q=null,Z=[],K=[],J=Y,w=0,R=null,u=new Map,_=$.cacheSize||10,A=function(){let H,D;if(F&&Q){if(F.beforeUnmount)F.beforeUnmount();if(u.set(Q,F),u.size>_){if(D=u.keys().next().value,H=u.get(D),H.unmounted)H.unmounted();u.delete(D)}return F=null,Q=null}},E=function(){A();for(let H=K.length-1;H>=0;H--){let D=K[H];if(D.beforeUnmount)D.beforeUnmount();if(D.unmounted)D.unmounted();D._root?.remove()}return K=[],J=Y},f.watch(function(H,D){let G;if(u.has(D)){if(G=u.get(D),G.unmounted)G.unmounted();return u.delete(D)}}),X=async function(H){let D,G,I,B,N,T,L,h,m,f1,$1,i1,n,p1,_1,R1,Q1,P1,C,d1,G1,a;if({route:C,params:R1,layouts:h,query:P1}=H,!C)return;if(C.file===Q)return;return B=++w,P.navigating=!0,(async()=>{try{if(G1=f.read(C.file),!G1){if(z)z({status:404,message:`File not found: ${C.file}`});P.navigating=!1;return}if(i1=await q1(G1,U,f,C.file,O),B!==w){P.navigating=!1;return}if(D=v1(i1),!D){if(z)z({status:500,message:`No component found in ${C.file}`});P.navigating=!1;return}if($1=!z2(h,Z),p1=F?._root,$1)E();else A();if(n=$1?Y:J,$1&&h.length>0){Y.innerHTML="",n=Y;for(let c of h){if(f1=f.read(c),!f1)continue;if(m=await q1(f1,U,f,c,O),B!==w){P.navigating=!1;return}if(G=v1(m),!G)continue;if(T=new G({app:W,params:R1,router:P}),T.beforeMount)T.beforeMount();a=document.createElement("div"),a.setAttribute("data-layout",c),n.appendChild(a),T.mount(a),K.push(T),d1=a.querySelector("#content")||a,n=d1}Z=[...h],J=n}else if($1)Y.innerHTML="",Z=[],J=Y;if(I=u.get(C.file),I)u.delete(C.file),n.appendChild(I._root),F=I,Q=C.file;else{if(_1=document.createElement("div"),_1.setAttribute("data-component",C.file),n.appendChild(_1),L=new D({app:W,params:R1,query:P1,router:P}),L.beforeMount)L.beforeMount();if(L.mount(_1),F=L,Q=C.file,L.load)await L.load(R1,P1)}return p1?.remove(),P.navigating=!1,Y.style.opacity==="0"?document.fonts.ready.then(function(){return requestAnimationFrame(function(){return Y.style.transition="opacity 150ms ease-in",Y.style.opacity="1"})}):void 0}catch(c){if(P.navigating=!1,Y.style.opacity="1",console.error(`Renderer: error mounting ${C.file}:`,c),z)z({status:500,message:c.message,error:c});N=!1;for(let E1=K.length-1;E1>=0;E1--){let r1=K[E1];if(r1.onError)try{r1.onError(c),N=!0;break}catch(v2){console.error("Renderer: error boundary failed:",v2)}}return(()=>{if(!N)return Q1=document.createElement("pre"),Q1.style.cssText="color:red;padding:1em",Q1.textContent=c.stack||c.message,Y.innerHTML="",Y.appendChild(Q1)})()}})()},M={start:function(){return R=o(function(){let H;return H=P.current,H.route?X(H):void 0}),P.init(),M},stop:function(){if(E(),R)R(),R=null;return Y.innerHTML=""},remount:function(){let H;return H=P.current,H.route?X(H):void 0},cache:u},M},k3=async function($="",W={}){let A,U,u,f,Y,F,Z,Q,R,w,K,_,J,X,z,M,O,P,q,E,H;if(globalThis.__ripLaunched=!0,typeof $==="object")W=$,$="";if($=$.replace(/\/+$/,""),H=W.target||"#app",R=W.compile||null,X=W.persist||!1,_=W.hash||!1,!R)R=globalThis?.compileToJS||null;if(typeof document<"u"&&!document.querySelector(H))K=document.createElement("div"),K.id=H.replace(/^#/,""),document.body.prepend(K);if(W.bundle)F=W.bundle;else if(W.components&&Array.isArray(W.components)){w={};for(let D of W.components)if(M=await fetch(D),M.ok)J=D.split("/").pop(),w[`components/${J}`]=await M.text();F={components:w,data:{}}}else if(typeof document<"u"&&document.querySelectorAll('script[type="text/rip"][data-name]').length>0){w={};for(let D of document.querySelectorAll('script[type="text/rip"][data-name]'))J=D.getAttribute("data-name"),J+=!J.endsWith(".rip")?".rip":void 0,w[`components/${J}`]=D.textContent;F={components:w,data:{}}}else{if(Z=`${$}/bundle`,M=await fetch(Z),!M.ok)throw Error(`launch: ${Z} (${M.status})`);F=await M.json()}if(f=j2({components:{},routes:{},data:{}}),F.data)f.data=F.data;if(F.routes)f.routes=F.routes;if(X&&typeof sessionStorage<"u"){u=`__rip_${$}`,U=X==="local"?localStorage:sessionStorage;try{if(q=U.getItem(u),q){E=JSON.parse(q);for(let D in E){let G=E[D];f.data[D]=G}}}catch{}A=function(){return(()=>{try{return U.setItem(u,JSON.stringify(h2(f.data)))}catch{return null}})()},o(function(){let D;return x1.value,D=setTimeout(A,2000),function(){return clearTimeout(D)}}),window.addEventListener("beforeunload",A)}if(Y=y2(),F.components)Y.load(F.components);if(Q=`__rip_${$.replace(/\//g,"_")||"app"}`,O={map:H2(Y),classes:{},key:Q},typeof globalThis<"u")globalThis[Q]=O.classes;if(f.data.title&&typeof document<"u")document.title=f.data.title;if(P=b2(Y,{root:"components",base:$,hash:_,onError:function(D){return console.error(`[Rip] Error ${D.status}: ${D.message||D.path}`)}}),z=c2({router:P,app:f,components:Y,resolver:O,compile:R,target:H,onError:function(D){return console.error(`[Rip] ${D.message}`,D.error)}}),z.start(),F.data?.watch)q2(`${$}/watch`);if(typeof window<"u")window.app=f,window.__RIP__={app:f,components:Y,router:P,renderer:z,cache:z.cache,version:"0.3.0"};return{app:f,components:Y,router:P,renderer:z}};e.modules["ui.rip"]=n1;export{y3 as rip,C3 as processRipScripts,s as parser,e as importRip,z1 as getReactiveRuntime,y1 as getComponentRuntime,x as formatSExpr,r as compileToJS,C1 as compile,V3 as VERSION,p as Lexer,w1 as Compiler,y as CodeGenerator,j3 as BUILD_DATE};
Binary file
@@ -113,7 +113,7 @@ if (typeof globalThis !== 'undefined') {
113
113
  `)}else A=n(U);let Q=[`${Y}(${A}`],X=U==="block";for(let D=1;D<W.length;D++){let K=W[D];if(!Array.isArray(K))Q[Q.length-1]+=" "+n(K);else{let M=e(K)&&K.every((H)=>!Array.isArray(H)||e(H));if(!X&&M){let H=v(K,0,!1);if(!H.includes(`
114
114
  `)){Q[Q.length-1]+=" "+H;continue}}Q.push(v(K,Z+2,!1))}}return Q[Q.length-1]+=")",Q.join(`
115
115
  `)}class u{static ASSIGNMENT_OPS=new Set(["=","+=","-=","*=","/=","?=","&=","|=","^=","%=","**=","??=","&&=","||=","<<=",">>=",">>>="]);static NUMBER_LITERAL_RE=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;static NUMBER_START_RE=/^-?\d/;static GENERATORS={program:"generateProgram","&&":"generateLogicalAnd","||":"generateLogicalOr","+":"generateBinaryOp","-":"generateBinaryOp","*":"generateBinaryOp","/":"generateBinaryOp","%":"generateBinaryOp","**":"generateBinaryOp","==":"generateBinaryOp","===":"generateBinaryOp","!=":"generateBinaryOp","!==":"generateBinaryOp","<":"generateBinaryOp",">":"generateBinaryOp","<=":"generateBinaryOp",">=":"generateBinaryOp","??":"generateBinaryOp","!?":"generateBinaryOp","&":"generateBinaryOp","|":"generateBinaryOp","^":"generateBinaryOp","<<":"generateBinaryOp",">>":"generateBinaryOp",">>>":"generateBinaryOp","%%":"generateModulo","%%=":"generateModuloAssign","//":"generateFloorDiv","//=":"generateFloorDivAssign","..":"generateRange","=":"generateAssignment","+=":"generateAssignment","-=":"generateAssignment","*=":"generateAssignment","/=":"generateAssignment","%=":"generateAssignment","**=":"generateAssignment","&&=":"generateAssignment","||=":"generateAssignment","??=":"generateAssignment","?=":"generateAssignment","&=":"generateAssignment","|=":"generateAssignment","^=":"generateAssignment","<<=":"generateAssignment",">>=":"generateAssignment",">>>=":"generateAssignment","...":"generateRange","!":"generateNot","~":"generateBitwiseNot","++":"generateIncDec","--":"generateIncDec","=~":"generateRegexMatch",instanceof:"generateInstanceof",in:"generateIn",of:"generateOf",typeof:"generateTypeof",delete:"generateDelete",new:"generateNew",array:"generateArray",object:"generateObject",block:"generateBlock",".":"generatePropertyAccess","?.":"generateOptionalProperty","[]":"generateIndexAccess",optindex:"generateOptIndex",optcall:"generateOptCall","regex-index":"generateRegexIndex",def:"generateDef","->":"generateThinArrow","=>":"generateFatArrow",return:"generateReturn",state:"generateState",computed:"generateComputed",readonly:"generateReadonly",effect:"generateEffect",break:"generateBreak",continue:"generateContinue","?":"generateExistential","?:":"generateTernary","|>":"generatePipe",loop:"generateLoop","loop-n":"generateLoopN",await:"generateAwait",yield:"generateYield","yield-from":"generateYieldFrom",if:"generateIf","for-in":"generateForIn","for-of":"generateForOf","for-as":"generateForAs",while:"generateWhile",try:"generateTry",throw:"generateThrow",control:"generateControl",switch:"generateSwitch",when:"generateWhen",comprehension:"generateComprehension","object-comprehension":"generateObjectComprehension",class:"generateClass",super:"generateSuper",component:"generateComponent",render:"generateRender",enum:"generateEnum",import:"generateImport",export:"generateExport","export-default":"generateExportDefault","export-all":"generateExportAll","export-from":"generateExportFrom","do-iife":"generateDoIIFE",regex:"generateRegex","tagged-template":"generateTaggedTemplate",str:"generateString"};constructor(W={}){if(this.options=W,this.indentLevel=0,this.indentString=" ",this.comprehensionDepth=0,this.dataSection=W.dataSection,this.sourceMap=W.sourceMap||null,W.reactiveVars)this.reactiveVars=new Set(W.reactiveVars)}compile(W){this.programVars=new Set,this.functionVars=new Map,this.helpers=new Set,this.scopeStack=[],this.collectProgramVariables(W);let Z=this.generate(W);if(this.sourceMap)this.buildMappings(Z,W);return Z}buildMappings(W,Z){if(!Z||Z[0]!=="program")return;let F=[],U=(A)=>{if(!Array.isArray(A))return;let Q=A[0];if(Q==="program"||Q==="block")for(let X=1;X<A.length;X++){let D=A[X];if(Array.isArray(D)&&D.loc)F.push(D.loc);U(D)}else for(let X=1;X<A.length;X++)U(A[X])};U(Z);let $=W.split(`
116
- `),Y=0;for(let A=0;A<$.length;A++){let Q=$[A],X=Q.trim();if(!X||X==="}"||X==="});")continue;if(X.startsWith("let ")||X.startsWith("var "))continue;if(X.startsWith("const slice")||X.startsWith("const modulo")||X.startsWith("const toMatchable"))continue;if(X.startsWith("const {")&&X.includes("__"))continue;if(X.startsWith("} else"))continue;if(X.startsWith("//# source"))continue;if(Y<F.length){let D=Q.length-X.length;this.sourceMap.addMapping(A,D,F[Y].r,F[Y].c),Y++}}}collectProgramVariables(W){if(!Array.isArray(W))return;let[Z,...F]=W;if(Z=L(Z),Array.isArray(Z)){W.forEach((U)=>this.collectProgramVariables(U));return}if(Z==="export"||Z==="export-default"||Z==="export-all"||Z==="export-from")return;if(Z==="state"||Z==="computed"){let[U]=F,$=L(U)??U;if(!this.reactiveVars)this.reactiveVars=new Set;this.reactiveVars.add($);return}if(Z==="readonly")return;if(Z==="component")return;if(u.ASSIGNMENT_OPS.has(Z)){let[U,$]=F;if(typeof U==="string"||U instanceof String){let Y=L(U);if(!this.reactiveVars?.has(Y))this.programVars.add(Y)}else if(this.is(U,"array"))this.collectVarsFromArray(U,this.programVars);else if(this.is(U,"object"))this.collectVarsFromObject(U,this.programVars);this.collectProgramVariables($);return}if(Z==="def"||Z==="->"||Z==="=>")return;if(Z==="if"){let[U,$,Y]=F;if(this.collectProgramVariables(U),this.collectProgramVariables($),Y)this.collectProgramVariables(Y);return}if(Z==="try"){if(this.collectProgramVariables(F[0]),F.length>=2&&Array.isArray(F[1])&&F[1].length===2&&F[1][0]!=="block"){let[U,$]=F[1];if(U&&this.is(U,"object"))U.slice(1).forEach((Y)=>{if(Array.isArray(Y)&&Y.length===2&&typeof Y[1]==="string")this.programVars.add(Y[1])});else if(U&&this.is(U,"array"))U.slice(1).forEach((Y)=>{if(typeof Y==="string")this.programVars.add(Y)});this.collectProgramVariables($)}if(F.length===3)this.collectProgramVariables(F[2]);else if(F.length===2&&(!Array.isArray(F[1])||F[1][0]==="block"))this.collectProgramVariables(F[1]);return}F.forEach((U)=>this.collectProgramVariables(U))}collectFunctionVariables(W){let Z=new Set,F=(U)=>{if(!Array.isArray(U))return;let[$,...Y]=U;if($=L($),Array.isArray($)){U.forEach((A)=>F(A));return}if(u.ASSIGNMENT_OPS.has($)){let[A,Q]=Y;if(typeof A==="string")Z.add(A);else if(this.is(A,"array"))this.collectVarsFromArray(A,Z);else if(this.is(A,"object"))this.collectVarsFromObject(A,Z);F(Q);return}if($==="def"||$==="->"||$==="=>")return;if($==="try"){if(F(Y[0]),Y.length>=2&&Array.isArray(Y[1])&&Y[1].length===2&&Y[1][0]!=="block"){let[A,Q]=Y[1];if(A&&this.is(A,"object"))A.slice(1).forEach((X)=>{if(Array.isArray(X)&&X.length===2&&typeof X[1]==="string")Z.add(X[1])});else if(A&&this.is(A,"array"))A.slice(1).forEach((X)=>{if(typeof X==="string")Z.add(X)});F(Q)}if(Y.length===3)F(Y[2]);else if(Y.length===2&&(!Array.isArray(Y[1])||Y[1][0]==="block"))F(Y[1]);return}Y.forEach((A)=>F(A))};return F(W),Z}generate(W,Z="statement"){if(W instanceof String){if(j(W,"await")===!0)return`await ${L(W)}()`;if(j(W,"predicate"))return`(${L(W)} != null)`;if(j(W,"delimiter")==="///"&&j(W,"heregex")){let Q=L(W),X=Q.match(/^\/(.*)\/([gimsuvy]*)$/s);if(X){let[,D,K]=X;return`/${this.processHeregex(D)}/${K}`}return Q}let A=j(W,"quote");if(A){let Q=L(W);if(A==='"""'||A==="'''"){let D=this.extractStringContent(W);return D=D.replace(/`/g,"\\`").replace(/\${/g,"\\${"),`\`${D}\``}if(Q[0]===A)return Q;let X=Q.slice(1,-1);return`${A}${X}${A}`}W=L(W)}if(typeof W==="string"){if(W.startsWith('"')||W.startsWith("'")||W.startsWith("`")){if(this.options.debug)console.warn("[Rip] Unexpected quoted primitive:",W);let A=W.slice(1,-1);if(A.includes(`
116
+ `),Y=0;for(let A=0;A<$.length;A++){let Q=$[A],X=Q.trim();if(!X||X==="}"||X==="});")continue;if(X.startsWith("let ")||X.startsWith("var "))continue;if(X.startsWith("const slice")||X.startsWith("const modulo")||X.startsWith("const toMatchable"))continue;if(X.startsWith("const {")&&X.includes("__"))continue;if(X.startsWith("} else"))continue;if(X.startsWith("//# source"))continue;if(Y<F.length){let D=Q.length-X.length;this.sourceMap.addMapping(A,D,F[Y].r,F[Y].c),Y++}}}collectProgramVariables(W){if(!Array.isArray(W))return;let[Z,...F]=W;if(Z=L(Z),Array.isArray(Z)){W.forEach((U)=>this.collectProgramVariables(U));return}if(Z==="export"||Z==="export-default"||Z==="export-all"||Z==="export-from")return;if(Z==="state"||Z==="computed"){let[U]=F,$=L(U)??U;if(!this.reactiveVars)this.reactiveVars=new Set;this.reactiveVars.add($);return}if(Z==="readonly")return;if(Z==="component")return;if(u.ASSIGNMENT_OPS.has(Z)){let[U,$]=F;if(typeof U==="string"||U instanceof String){let Y=L(U);if(!this.reactiveVars?.has(Y))this.programVars.add(Y)}else if(this.is(U,"array"))this.collectVarsFromArray(U,this.programVars);else if(this.is(U,"object"))this.collectVarsFromObject(U,this.programVars);this.collectProgramVariables($);return}if(Z==="def"||Z==="->"||Z==="=>"||Z==="effect")return;if(Z==="if"){let[U,$,Y]=F;if(this.collectProgramVariables(U),this.collectProgramVariables($),Y)this.collectProgramVariables(Y);return}if(Z==="try"){if(this.collectProgramVariables(F[0]),F.length>=2&&Array.isArray(F[1])&&F[1].length===2&&F[1][0]!=="block"){let[U,$]=F[1];if(U&&this.is(U,"object"))U.slice(1).forEach((Y)=>{if(Array.isArray(Y)&&Y.length===2&&typeof Y[1]==="string")this.programVars.add(Y[1])});else if(U&&this.is(U,"array"))U.slice(1).forEach((Y)=>{if(typeof Y==="string")this.programVars.add(Y)});this.collectProgramVariables($)}if(F.length===3)this.collectProgramVariables(F[2]);else if(F.length===2&&(!Array.isArray(F[1])||F[1][0]==="block"))this.collectProgramVariables(F[1]);return}F.forEach((U)=>this.collectProgramVariables(U))}collectFunctionVariables(W){let Z=new Set,F=(U)=>{if(!Array.isArray(U))return;let[$,...Y]=U;if($=L($),Array.isArray($)){U.forEach((A)=>F(A));return}if(u.ASSIGNMENT_OPS.has($)){let[A,Q]=Y;if(typeof A==="string")Z.add(A);else if(this.is(A,"array"))this.collectVarsFromArray(A,Z);else if(this.is(A,"object"))this.collectVarsFromObject(A,Z);F(Q);return}if($==="def"||$==="->"||$==="=>"||$==="effect")return;if($==="try"){if(F(Y[0]),Y.length>=2&&Array.isArray(Y[1])&&Y[1].length===2&&Y[1][0]!=="block"){let[A,Q]=Y[1];if(A&&this.is(A,"object"))A.slice(1).forEach((X)=>{if(Array.isArray(X)&&X.length===2&&typeof X[1]==="string")Z.add(X[1])});else if(A&&this.is(A,"array"))A.slice(1).forEach((X)=>{if(typeof X==="string")Z.add(X)});F(Q)}if(Y.length===3)F(Y[2]);else if(Y.length===2&&(!Array.isArray(Y[1])||Y[1][0]==="block"))F(Y[1]);return}Y.forEach((A)=>F(A))};return F(W),Z}generate(W,Z="statement"){if(W instanceof String){if(j(W,"await")===!0)return`await ${L(W)}()`;if(j(W,"predicate"))return`(${L(W)} != null)`;if(j(W,"delimiter")==="///"&&j(W,"heregex")){let Q=L(W),X=Q.match(/^\/(.*)\/([gimsuvy]*)$/s);if(X){let[,D,K]=X;return`/${this.processHeregex(D)}/${K}`}return Q}let A=j(W,"quote");if(A){let Q=L(W);if(A==='"""'||A==="'''"){let D=this.extractStringContent(W);return D=D.replace(/`/g,"\\`").replace(/\${/g,"\\${"),`\`${D}\``}if(Q[0]===A)return Q;let X=Q.slice(1,-1);return`${A}${X}${A}`}W=L(W)}if(typeof W==="string"){if(W.startsWith('"')||W.startsWith("'")||W.startsWith("`")){if(this.options.debug)console.warn("[Rip] Unexpected quoted primitive:",W);let A=W.slice(1,-1);if(A.includes(`
117
117
  `))return`\`${A.replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}\``;let Q=A.includes("'")&&!A.includes('"')?'"':"'",X=A.replace(new RegExp(Q,"g"),`\\${Q}`);return`${Q}${X}${Q}`}if(this.reactiveVars?.has(W)&&!this.suppressReactiveUnwrap)return`${W}.value`;return W}if(typeof W==="number")return String(W);if(W===null||W===void 0)return"null";if(!Array.isArray(W))throw Error(`Invalid s-expression: ${JSON.stringify(W)}`);let[F,...U]=W,$=j(F,"await");F=L(F);let Y=u.GENERATORS[F];if(Y)return this[Y](F,U,Z,W);if(typeof F==="string"&&!F.startsWith('"')&&!F.startsWith("'")){if(u.NUMBER_START_RE.test(F))return F;if(F==="super"&&this.currentMethodName&&this.currentMethodName!=="constructor"){let K=U.map((M)=>this.unwrap(this.generate(M,"value"))).join(", ");return`super.${this.currentMethodName}(${K})`}if(Z==="statement"&&U.length===1){let K=this.findPostfixConditional(U[0]);if(K){let M=this.rebuildWithoutConditional(K),H=this.generate(F,"value"),J=this.generate(K.condition,"value"),R=this.generate(M,"value"),z=`${H}(${R})`;return`if (${J}) ${z}`}}let A=$===!0,Q=this.generate(F,"value"),X=U.map((K)=>this.unwrap(this.generate(K,"value"))).join(", "),D=`${Q}(${X})`;return A?`await ${D}`:D}if(Array.isArray(F)&&typeof F[0]==="string"){if(["=","+=","-=","*=","/=","%=","**=","&&=","||=","??=","if","return","throw"].includes(F[0]))return`(${W.map((X)=>this.generate(X,"value")).join(", ")})`}if(Array.isArray(F)){if(F[0]==="."&&(F[2]==="new"||L(F[2])==="new")){let K=F[1],M=this.generate(K,"value"),H=U.map((R)=>this.unwrap(this.generate(R,"value"))).join(", ");return`new ${Array.isArray(K)?`(${M})`:M}(${H})`}if(Z==="statement"&&U.length===1){let K=this.findPostfixConditional(U[0]);if(K){let M=this.rebuildWithoutConditional(K),H=this.generate(F,"value"),J=this.generate(K.condition,"value"),R=this.generate(M,"value"),z=`${H}(${R})`;return`if (${J}) ${z}`}}let A=!1,Q;if(F[0]==="."&&j(F[2],"await")===!0){A=!0;let[K,M]=F.slice(1),H=this.generate(K,"value");Q=`${u.NUMBER_LITERAL_RE.test(H)||(this.is(K,"object")||this.is(K,"await")||this.is(K,"yield"))?`(${H})`:H}.${L(M)}`}else Q=this.generate(F,"value");let X=U.map((K)=>this.unwrap(this.generate(K,"value"))).join(", "),D=`${Q}(${X})`;return A?`await ${D}`:D}throw Error(`Unknown s-expression type: ${F}`)}generateProgram(W,Z,F,U){let $="",Y=[],A=[],Q=[];for(let J of Z){if(!Array.isArray(J)){Q.push(J);continue}let R=J[0];if(R==="import")Y.push(J);else if(R==="export"||R==="export-default"||R==="export-all"||R==="export-from")A.push(J);else Q.push(J)}let X=["def","class","if","for-in","for-of","for-as","while","loop","switch","try"],D=Q.map((J,R)=>{let z=Q.length===1&&Y.length===0&&A.length===0,G=this.is(J,"object"),q=G&&J.length===2&&Array.isArray(J[1])&&Array.isArray(J[1][1])&&J[1][1][0]==="comprehension",w=this.is(J,"comprehension")||this.is(J,"object-comprehension")||this.is(J,"do-iife"),B=this.programVars.size===0,_=z&&G&&B&&!w&&!q,P=R===Q.length-1&&w,O;if(_)O=`(${this.generate(J,"value")})`;else if(P)O=this.generate(J,"value");else O=this.generate(J,"statement");if(O&&!O.endsWith(";")){let I=Array.isArray(J)?J[0]:null;if(!X.includes(I)||!O.endsWith("}"))return O+";"}return O}).join(`
118
118
  `),K=!1;if(Y.length>0)$+=Y.map((J)=>this.addSemicolon(J,this.generate(J,"statement"))).join(`
119
119
  `),K=!0;if(this.programVars.size>0){let J=Array.from(this.programVars).sort().join(", ");if(K)$+=`
@@ -145,10 +145,7 @@ _setDataSection();
145
145
 
146
146
  function _setDataSection() {
147
147
  DATA = ${JSON.stringify(this.dataSection)};
148
- }`;return $}generateBinaryOp(W,Z,F,U){if((W==="+"||W==="-")&&Z.length===1)return`(${W}${this.generate(Z[0],"value")})`;let[$,Y]=Z;if(W==="*"){let Q=$?.valueOf?.()??$;if(typeof Q==="string"&&/^["']/.test(Q))return`${this.generate($,"value")}.repeat(${this.generate(Y,"value")})`}let A=new Set(["<",">","<=",">="]);if(A.has(W)&&Array.isArray($)){let Q=$[0]?.valueOf?.()??$[0];if(A.has(Q)){let X=this.generate($[1],"value"),D=this.generate($[2],"value"),K=this.generate(Y,"value");return`((${X} ${Q} ${D}) && (${D} ${W} ${K}))`}}if(W==="!?"){let Q=this.generate($,"value"),X=this.generate(Y,"value");return`(${Q} !== undefined ? ${Q} : ${X})`}if(W==="==")W="===";if(W==="!=")W="!==";return`(${this.generate($,"value")} ${W} ${this.generate(Y,"value")})`}generateModulo(W,Z){let[F,U]=Z;return this.helpers.add("modulo"),`modulo(${this.generate(F,"value")}, ${this.generate(U,"value")})`}generateModuloAssign(W,Z){let[F,U]=Z;this.helpers.add("modulo");let $=this.generate(F,"value"),Y=this.generate(U,"value");return`${$} = modulo(${$}, ${Y})`}generateFloorDiv(W,Z){let[F,U]=Z;return`Math.floor(${this.generate(F,"value")} / ${this.generate(U,"value")})`}generateFloorDivAssign(W,Z){let[F,U]=Z,$=this.generate(F,"value"),Y=this.generate(U,"value");return`${$} = Math.floor(${$} / ${Y})`}generateAssignment(W,Z,F,U){let[$,Y]=Z,A=W==="?="?"??=":W,Q=this.is(Y,"->")||this.is(Y,"=>")||this.is(Y,"def");if($ instanceof String&&j($,"await")!==void 0&&!Q){let z=j($,"await")===!0?"!":"&";throw Error(`Cannot use ${z} sigil in variable declaration '${L($)}'.`)}if($ instanceof String&&j($,"await")===!0&&Q)this.nextFunctionIsVoid=!0;let X=this.is($,"array",0),D=this.is($,"object",0);if(X||D){let z=this.generate(Y,"value");return D&&F==="statement"?`(${z})`:z}if(Array.isArray(Y)&&A==="="&&Y[0]==="control"){let[,z,G,q]=Y,w=L(z),B=q[0]==="return",_=this.generate($,"value"),E=this.generate(G,"value"),P=q.length>1?q[1]:null,O=B?P?`return ${this.generate(P,"value")}`:"return":P?`throw ${this.generate(P,"value")}`:"throw new Error()";if(F==="value"){if(w==="??")return`(() => { const __v = ${E}; if (__v == null) ${O}; return (${_} = __v); })()`;if(w==="||")return`(() => { const __v = ${E}; if (!__v) ${O}; return (${_} = __v); })()`;return`(() => { const __v = ${E}; if (__v) ${O}; return (${_} = __v); })()`}if(w==="??")return`if ((${_} = ${E}) == null) ${O}`;if(w==="||")return`if (!(${_} = ${E})) ${O}`;return`if ((${_} = ${E})) ${O}`}if(this.is($,"array")){let z=$.slice(1).findIndex((G)=>this.is(G,"...")||G==="...");if(z!==-1&&z<$.length-2){let G=$.slice(1),q=G.slice(z+1),w=q.length;if(w>0){let B=this.generate(Y,"value"),E=G.slice(0,z).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"),G.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=G[z],I=this.is(O,"...")?O[1]:null,N=[];if(E)N.push(`[${E}] = ${B}`);if(I)N.push(`[...${I}] = ${B}.slice(${z}, -${w})`);return N.push(`[${P}] = slice.call(${B}, -${w})`),N.join(", ")}}}if(F==="statement"&&W==="="&&Array.isArray(Y)&&(Y[0]==="||"||Y[0]==="&&")&&Y.length===3){let[z,G,q]=Y;if(this.is(q,"if")&&q.length===3){let[,w,B]=q,_=Array.isArray(B)&&B.length===1?B[0]:B,E=[z,G,_],P=this.generate($,"value"),O=this.generate(w,"value"),I=this.generate(E,"value");return`if (${O}) ${P} = ${I}`}}if(F==="statement"&&W==="="&&Array.isArray(Y)&&Y.length===3){let[z,G,q]=Y,w=Array.isArray(q)&&q.length===1&&(!Array.isArray(q[0])||q[0][0]!=="block");if(z==="if"&&w){let B=Array.isArray(q)&&q.length===1?q[0]:q,_=this.generate($,"value"),E=this.unwrapLogical(this.generate(G,"value")),P=this.generate(B,"value");return`if (${E}) ${_} = ${P}`}}let K;if($ instanceof String&&j($,"await")!==void 0)K=L($);else if(typeof $==="string"&&this.reactiveVars?.has($))K=`${$}.value`;else this.suppressReactiveUnwrap=!0,K=this.generate($,"value"),this.suppressReactiveUnwrap=!1;let M=this.generate(Y,"value");if(!this.is(Y,"object"))M=this.unwrap(M);let J=F==="value",R=F==="statement"&&this.is($,"object");if(J||R)return`(${K} ${A} ${M})`;return`${K} ${A} ${M}`}generatePropertyAccess(W,Z,F,U){let[$,Y]=Z;if(this._atParamMap&&$==="this"){let D=this._atParamMap.get(L(Y));if(D)return D}this.suppressReactiveUnwrap=!0;let A=this.generate($,"value");this.suppressReactiveUnwrap=!1;let X=u.NUMBER_LITERAL_RE.test(A)||A.startsWith("await ")||(this.is($,"object")||this.is($,"yield"))?`(${A})`:A;if(j(Y,"await")===!0)return`await ${X}.${L(Y)}()`;if(j(Y,"predicate"))return`(${X}.${L(Y)} != null)`;return`${X}.${L(Y)}`}generateOptionalProperty(W,Z){let[F,U]=Z;return`${this.generate(F,"value")}?.${U}`}generateRegexIndex(W,Z){let[F,U,$]=Z;this.helpers.add("toMatchable"),this.programVars.add("_");let Y=this.generate(F,"value"),A=this.generate(U,"value"),Q=$!==null?this.generate($,"value"):"0",X=A.includes("/m")?", true":"";return`(_ = toMatchable(${Y}${X}).match(${A})) && _[${Q}]`}generateIndexAccess(W,Z){let[F,U]=Z;if(this.is(U,"..")||this.is(U,"...")){let $=U[0]==="..",Y=this.generate(F,"value"),[A,Q]=U.slice(1);if(A===null&&Q===null)return`${Y}.slice()`;if(A===null){if($&&this.is(Q,"-",1)&&(L(Q[1])??Q[1])==1)return`${Y}.slice(0)`;let K=this.generate(Q,"value");return $?`${Y}.slice(0, +${K} + 1 || 9e9)`:`${Y}.slice(0, ${K})`}if(Q===null)return`${Y}.slice(${this.generate(A,"value")})`;let X=this.generate(A,"value");if($&&this.is(Q,"-",1)&&(L(Q[1])??Q[1])==1)return`${Y}.slice(${X})`;let D=this.generate(Q,"value");return $?`${Y}.slice(${X}, +${D} + 1 || 9e9)`:`${Y}.slice(${X}, ${D})`}if(this.is(U,"-",1)){let $=L(U[1])??U[1];if(typeof $==="number"||typeof $==="string"&&/^\d+$/.test($))return`${this.generate(F,"value")}.at(-${$})`}return`${this.generate(F,"value")}[${this.unwrap(this.generate(U,"value"))}]`}generateOptIndex(W,Z){let[F,U]=Z;if(this.is(U,"-",1)){let $=L(U[1])??U[1];if(typeof $==="number"||typeof $==="string"&&/^\d+$/.test($))return`${this.generate(F,"value")}?.at(-${$})`}return`${this.generate(F,"value")}?.[${this.generate(U,"value")}]`}generateOptCall(W,Z){let[F,...U]=Z;return`${this.generate(F,"value")}?.(${U.map(($)=>this.generate($,"value")).join(", ")})`}generateDef(W,Z,F,U){let[$,Y,A]=Z,Q=j($,"await")===!0,X=L($),D=this.generateParamList(Y),K=this.generateFunctionBody(A,Y,Q),M=this.containsAwait(A),H=this.containsYield(A);return`${M?"async ":""}function${H?"*":""} ${X}(${D}) ${K}`}generateThinArrow(W,Z,F,U){let[$,Y]=Z;if((!$||Array.isArray($)&&$.length===0)&&this.containsIt(Y))$=["it"];let A=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let Q=this.generateParamList($),X=this.generateFunctionBody(Y,$,A),D=this.containsAwait(Y),K=this.containsYield(Y),M=`${D?"async ":""}function${K?"*":""}(${Q}) ${X}`;return F==="value"?`(${M})`:M}generateFatArrow(W,Z,F,U){let[$,Y]=Z;if((!$||Array.isArray($)&&$.length===0)&&this.containsIt(Y))$=["it"];let A=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let Q=this.generateParamList($),D=$.length===1&&typeof $[0]==="string"&&!Q.includes("=")&&!Q.includes("...")&&!Q.includes("[")&&!Q.includes("{")?Q:`(${Q})`,M=this.containsAwait(Y)?"async ":"";if(!A){if(this.is(Y,"block")&&Y.length===2){let J=Y[1];if(!Array.isArray(J)||J[0]!=="return")return`${M}${D} => ${this.generate(J,"value")}`}if(!Array.isArray(Y)||Y[0]!=="block")return`${M}${D} => ${this.generate(Y,"value")}`}let H=this.generateFunctionBody(Y,$,A);return`${M}${D} => ${H}`}generateReturn(W,Z,F,U){if(Z.length===0)return"return";let[$]=Z;if(this.sideEffectOnly)return"return";if(this.is($,"if")){let[,Y,A,...Q]=$;if(Q.length===0){let X=Array.isArray(A)&&A.length===1?A[0]:A;return`if (${this.generate(Y,"value")}) return ${this.generate(X,"value")}`}}if(this.is($,"new")&&Array.isArray($[1])&&$[1][0]==="if"){let[,Y,A]=$[1],Q=Array.isArray(A)&&A.length===1?A[0]:A;return`if (${this.generate(Y,"value")}) return ${this.generate(["new",Q],"value")}`}return`return ${this.generate($,"value")}`}generateState(W,Z){let[F,U]=Z;this.usesReactivity=!0;let $=L(F)??F;if(!this.reactiveVars)this.reactiveVars=new Set;return this.reactiveVars.add($),`const ${$} = __state(${this.generate(U,"value")})`}generateComputed(W,Z){let[F,U]=Z;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let $=L(F)??F;if(this.reactiveVars.add($),this.is(U,"block")&&U.length>2)return`const ${$} = __computed(() => ${this.generateFunctionBody(U)})`;return`const ${$} = __computed(() => ${this.generate(U,"value")})`}generateReadonly(W,Z){let[F,U]=Z;return`const ${L(F)??F} = ${this.generate(U,"value")}`}generateEffect(W,Z){let[F,U]=Z;this.usesReactivity=!0;let $;if(this.is(U,"block"))$=`{
149
- ${this.withIndent(()=>this.formatStatements(U.slice(1))).join(`
150
- `)}
151
- ${this.indent()}}`;else if(this.is(U,"->")||this.is(U,"=>")){let A=this.generate(U,"value");if(F)return`const ${L(F)??this.generate(F,"value")} = __effect(${A})`;return`__effect(${A})`}else $=`{ ${this.generate(U,"value")}; }`;let Y=`__effect(() => ${$})`;if(F)return`const ${L(F)??this.generate(F,"value")} = ${Y}`;return Y}generateBreak(){return"break"}generateContinue(){return"continue"}generateExistential(W,Z){return`(${this.generate(Z[0],"value")} != null)`}generateTernary(W,Z,F){let[U,$,Y]=Z;if(($?.[0]?.valueOf?.()??$?.[0])==="="&&Array.isArray($)){let Q=this.generate($[1],"value"),X=this.generate($[2],"value"),D=this.generate(Y,"value");return`${Q} = (${this.unwrap(this.generate(U,"value"))} ? ${X} : ${D})`}return`(${this.unwrap(this.generate(U,"value"))} ? ${this.generate($,"value")} : ${this.generate(Y,"value")})`}generatePipe(W,Z){let[F,U]=Z,$=this.generate(F,"value");if(Array.isArray(U)&&U.length>1){let Y=U[0];if(Array.isArray(Y)||typeof Y==="string"&&/^[a-zA-Z_$]/.test(Y)){let Q=this.generate(Y,"value"),X=U.slice(1).map((D)=>this.generate(D,"value"));return`${Q}(${$}, ${X.join(", ")})`}}return`${this.generate(U,"value")}(${$})`}generateLoop(W,Z){return`while (true) ${this.generateLoopBody(Z[0])}`}generateLoopN(W,Z){let[F,U]=Z;return`for (let it = 0; it < ${this.generate(F,"value")}; it++) ${this.generateLoopBody(U)}`}generateAwait(W,Z){return`await ${this.generate(Z[0],"value")}`}generateYield(W,Z){return Z.length===0?"yield":`yield ${this.generate(Z[0],"value")}`}generateYieldFrom(W,Z){return`yield* ${this.generate(Z[0],"value")}`}generateIf(W,Z,F,U){let[$,Y,...A]=Z;return F==="value"?this.generateIfAsExpression($,Y,A):this.generateIfAsStatement($,Y,A)}generateForIn(W,Z,F,U){let[$,Y,A,Q,X]=Z;if(F==="value"&&this.comprehensionDepth===0){let G=["for-in",$,Y,A];return this.generate(["comprehension",X,[G],Q?[Q]:[]],F)}let D=Array.isArray($)?$:[$],K=D.length===0,[M,H]=K?["_i",null]:D,J=this.is(M,"array")||this.is(M,"object")?this.generateDestructuringPattern(M):M;if(A&&A!==null){let G=this.generate(Y,"value"),q=H||"_i",w=this.generate(A,"value"),B=this.is(A,"-",1),_=B&&(A[1]==="1"||A[1]===1||L(A[1])==="1"),E=!B&&(A==="1"||A===1||L(A)==="1"),P;if(_)P=`for (let ${q} = ${G}.length - 1; ${q} >= 0; ${q}--) `;else if(E)P=`for (let ${q} = 0; ${q} < ${G}.length; ${q}++) `;else if(B)P=`for (let ${q} = ${G}.length - 1; ${q} >= 0; ${q} += ${w}) `;else P=`for (let ${q} = 0; ${q} < ${G}.length; ${q} += ${w}) `;if(this.is(X,"block")){let O=X.slice(1);this.indentLevel++;let I=[];if(!K)I.push(`const ${J} = ${G}[${q}];`);if(Q)I.push(`if (${this.generate(Q,"value")}) {`),this.indentLevel++,I.push(...this.formatStatements(O)),this.indentLevel--,I.push(this.indent()+"}");else I.push(...O.map((N)=>this.addSemicolon(N,this.generate(N,"statement"))));return this.indentLevel--,P+`{
148
+ }`;return $}generateBinaryOp(W,Z,F,U){if((W==="+"||W==="-")&&Z.length===1)return`(${W}${this.generate(Z[0],"value")})`;let[$,Y]=Z;if(W==="*"){let Q=$?.valueOf?.()??$;if(typeof Q==="string"&&/^["']/.test(Q))return`${this.generate($,"value")}.repeat(${this.generate(Y,"value")})`}let A=new Set(["<",">","<=",">="]);if(A.has(W)&&Array.isArray($)){let Q=$[0]?.valueOf?.()??$[0];if(A.has(Q)){let X=this.generate($[1],"value"),D=this.generate($[2],"value"),K=this.generate(Y,"value");return`((${X} ${Q} ${D}) && (${D} ${W} ${K}))`}}if(W==="!?"){let Q=this.generate($,"value"),X=this.generate(Y,"value");return`(${Q} !== undefined ? ${Q} : ${X})`}if(W==="==")W="===";if(W==="!=")W="!==";return`(${this.generate($,"value")} ${W} ${this.generate(Y,"value")})`}generateModulo(W,Z){let[F,U]=Z;return this.helpers.add("modulo"),`modulo(${this.generate(F,"value")}, ${this.generate(U,"value")})`}generateModuloAssign(W,Z){let[F,U]=Z;this.helpers.add("modulo");let $=this.generate(F,"value"),Y=this.generate(U,"value");return`${$} = modulo(${$}, ${Y})`}generateFloorDiv(W,Z){let[F,U]=Z;return`Math.floor(${this.generate(F,"value")} / ${this.generate(U,"value")})`}generateFloorDivAssign(W,Z){let[F,U]=Z,$=this.generate(F,"value"),Y=this.generate(U,"value");return`${$} = Math.floor(${$} / ${Y})`}generateAssignment(W,Z,F,U){let[$,Y]=Z,A=W==="?="?"??=":W,Q=this.is(Y,"->")||this.is(Y,"=>")||this.is(Y,"def");if($ instanceof String&&j($,"await")!==void 0&&!Q){let z=j($,"await")===!0?"!":"&";throw Error(`Cannot use ${z} sigil in variable declaration '${L($)}'.`)}if($ instanceof String&&j($,"await")===!0&&Q)this.nextFunctionIsVoid=!0;let X=this.is($,"array",0),D=this.is($,"object",0);if(X||D){let z=this.generate(Y,"value");return D&&F==="statement"?`(${z})`:z}if(Array.isArray(Y)&&A==="="&&Y[0]==="control"){let[,z,G,q]=Y,w=L(z),B=q[0]==="return",_=this.generate($,"value"),E=this.generate(G,"value"),P=q.length>1?q[1]:null,O=B?P?`return ${this.generate(P,"value")}`:"return":P?`throw ${this.generate(P,"value")}`:"throw new Error()";if(F==="value"){if(w==="??")return`(() => { const __v = ${E}; if (__v == null) ${O}; return (${_} = __v); })()`;if(w==="||")return`(() => { const __v = ${E}; if (!__v) ${O}; return (${_} = __v); })()`;return`(() => { const __v = ${E}; if (__v) ${O}; return (${_} = __v); })()`}if(w==="??")return`if ((${_} = ${E}) == null) ${O}`;if(w==="||")return`if (!(${_} = ${E})) ${O}`;return`if ((${_} = ${E})) ${O}`}if(this.is($,"array")){let z=$.slice(1).findIndex((G)=>this.is(G,"...")||G==="...");if(z!==-1&&z<$.length-2){let G=$.slice(1),q=G.slice(z+1),w=q.length;if(w>0){let B=this.generate(Y,"value"),E=G.slice(0,z).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"),G.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=G[z],I=this.is(O,"...")?O[1]:null,N=[];if(E)N.push(`[${E}] = ${B}`);if(I)N.push(`[...${I}] = ${B}.slice(${z}, -${w})`);return N.push(`[${P}] = slice.call(${B}, -${w})`),N.join(", ")}}}if(F==="statement"&&W==="="&&Array.isArray(Y)&&(Y[0]==="||"||Y[0]==="&&")&&Y.length===3){let[z,G,q]=Y;if(this.is(q,"if")&&q.length===3){let[,w,B]=q,_=Array.isArray(B)&&B.length===1?B[0]:B,E=[z,G,_],P=this.generate($,"value"),O=this.generate(w,"value"),I=this.generate(E,"value");return`if (${O}) ${P} = ${I}`}}if(F==="statement"&&W==="="&&Array.isArray(Y)&&Y.length===3){let[z,G,q]=Y,w=Array.isArray(q)&&q.length===1&&(!Array.isArray(q[0])||q[0][0]!=="block");if(z==="if"&&w){let B=Array.isArray(q)&&q.length===1?q[0]:q,_=this.generate($,"value"),E=this.unwrapLogical(this.generate(G,"value")),P=this.generate(B,"value");return`if (${E}) ${_} = ${P}`}}let K;if($ instanceof String&&j($,"await")!==void 0)K=L($);else if(typeof $==="string"&&this.reactiveVars?.has($))K=`${$}.value`;else this.suppressReactiveUnwrap=!0,K=this.generate($,"value"),this.suppressReactiveUnwrap=!1;let M=this.generate(Y,"value");if(!this.is(Y,"object"))M=this.unwrap(M);let J=F==="value",R=F==="statement"&&this.is($,"object");if(J||R)return`(${K} ${A} ${M})`;return`${K} ${A} ${M}`}generatePropertyAccess(W,Z,F,U){let[$,Y]=Z;if(this._atParamMap&&$==="this"){let D=this._atParamMap.get(L(Y));if(D)return D}this.suppressReactiveUnwrap=!0;let A=this.generate($,"value");this.suppressReactiveUnwrap=!1;let X=u.NUMBER_LITERAL_RE.test(A)||A.startsWith("await ")||(this.is($,"object")||this.is($,"yield"))?`(${A})`:A;if(j(Y,"await")===!0)return`await ${X}.${L(Y)}()`;if(j(Y,"predicate"))return`(${X}.${L(Y)} != null)`;return`${X}.${L(Y)}`}generateOptionalProperty(W,Z){let[F,U]=Z;return`${this.generate(F,"value")}?.${U}`}generateRegexIndex(W,Z){let[F,U,$]=Z;this.helpers.add("toMatchable"),this.programVars.add("_");let Y=this.generate(F,"value"),A=this.generate(U,"value"),Q=$!==null?this.generate($,"value"):"0",X=A.includes("/m")?", true":"";return`(_ = toMatchable(${Y}${X}).match(${A})) && _[${Q}]`}generateIndexAccess(W,Z){let[F,U]=Z;if(this.is(U,"..")||this.is(U,"...")){let $=U[0]==="..",Y=this.generate(F,"value"),[A,Q]=U.slice(1);if(A===null&&Q===null)return`${Y}.slice()`;if(A===null){if($&&this.is(Q,"-",1)&&(L(Q[1])??Q[1])==1)return`${Y}.slice(0)`;let K=this.generate(Q,"value");return $?`${Y}.slice(0, +${K} + 1 || 9e9)`:`${Y}.slice(0, ${K})`}if(Q===null)return`${Y}.slice(${this.generate(A,"value")})`;let X=this.generate(A,"value");if($&&this.is(Q,"-",1)&&(L(Q[1])??Q[1])==1)return`${Y}.slice(${X})`;let D=this.generate(Q,"value");return $?`${Y}.slice(${X}, +${D} + 1 || 9e9)`:`${Y}.slice(${X}, ${D})`}if(this.is(U,"-",1)){let $=L(U[1])??U[1];if(typeof $==="number"||typeof $==="string"&&/^\d+$/.test($))return`${this.generate(F,"value")}.at(-${$})`}return`${this.generate(F,"value")}[${this.unwrap(this.generate(U,"value"))}]`}generateOptIndex(W,Z){let[F,U]=Z;if(this.is(U,"-",1)){let $=L(U[1])??U[1];if(typeof $==="number"||typeof $==="string"&&/^\d+$/.test($))return`${this.generate(F,"value")}?.at(-${$})`}return`${this.generate(F,"value")}?.[${this.generate(U,"value")}]`}generateOptCall(W,Z){let[F,...U]=Z;return`${this.generate(F,"value")}?.(${U.map(($)=>this.generate($,"value")).join(", ")})`}generateDef(W,Z,F,U){let[$,Y,A]=Z,Q=j($,"await")===!0,X=L($),D=this.generateParamList(Y),K=this.generateFunctionBody(A,Y,Q),M=this.containsAwait(A),H=this.containsYield(A);return`${M?"async ":""}function${H?"*":""} ${X}(${D}) ${K}`}generateThinArrow(W,Z,F,U){let[$,Y]=Z;if((!$||Array.isArray($)&&$.length===0)&&this.containsIt(Y))$=["it"];let A=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let Q=this.generateParamList($),X=this.generateFunctionBody(Y,$,A),D=this.containsAwait(Y),K=this.containsYield(Y),M=`${D?"async ":""}function${K?"*":""}(${Q}) ${X}`;return F==="value"?`(${M})`:M}generateFatArrow(W,Z,F,U){let[$,Y]=Z;if((!$||Array.isArray($)&&$.length===0)&&this.containsIt(Y))$=["it"];let A=this.nextFunctionIsVoid||!1;this.nextFunctionIsVoid=!1;let Q=this.generateParamList($),D=$.length===1&&typeof $[0]==="string"&&!Q.includes("=")&&!Q.includes("...")&&!Q.includes("[")&&!Q.includes("{")?Q:`(${Q})`,M=this.containsAwait(Y)?"async ":"";if(!A){if(this.is(Y,"block")&&Y.length===2){let J=Y[1];if(!Array.isArray(J)||J[0]!=="return")return`${M}${D} => ${this.generate(J,"value")}`}if(!Array.isArray(Y)||Y[0]!=="block")return`${M}${D} => ${this.generate(Y,"value")}`}let H=this.generateFunctionBody(Y,$,A);return`${M}${D} => ${H}`}generateReturn(W,Z,F,U){if(Z.length===0)return"return";let[$]=Z;if(this.sideEffectOnly)return"return";if(this.is($,"if")){let[,Y,A,...Q]=$;if(Q.length===0){let X=Array.isArray(A)&&A.length===1?A[0]:A;return`if (${this.generate(Y,"value")}) return ${this.generate(X,"value")}`}}if(this.is($,"new")&&Array.isArray($[1])&&$[1][0]==="if"){let[,Y,A]=$[1],Q=Array.isArray(A)&&A.length===1?A[0]:A;return`if (${this.generate(Y,"value")}) return ${this.generate(["new",Q],"value")}`}return`return ${this.generate($,"value")}`}generateState(W,Z){let[F,U]=Z;this.usesReactivity=!0;let $=L(F)??F;if(!this.reactiveVars)this.reactiveVars=new Set;return this.reactiveVars.add($),`const ${$} = __state(${this.generate(U,"value")})`}generateComputed(W,Z){let[F,U]=Z;if(this.usesReactivity=!0,!this.reactiveVars)this.reactiveVars=new Set;let $=L(F)??F;if(this.reactiveVars.add($),this.is(U,"block")&&U.length>2)return`const ${$} = __computed(() => ${this.generateFunctionBody(U)})`;return`const ${$} = __computed(() => ${this.generate(U,"value")})`}generateReadonly(W,Z){let[F,U]=Z;return`const ${L(F)??F} = ${this.generate(U,"value")}`}generateEffect(W,Z){let[F,U]=Z;this.usesReactivity=!0;let $;if(this.is(U,"block"))$=this.generateFunctionBody(U);else if(this.is(U,"->")||this.is(U,"=>")){let A=this.generate(U,"value");if(F)return`const ${L(F)??this.generate(F,"value")} = __effect(${A})`;return`__effect(${A})`}else $=`{ ${this.generate(U,"value")}; }`;let Y=`__effect(() => ${$})`;if(F)return`const ${L(F)??this.generate(F,"value")} = ${Y}`;return Y}generateBreak(){return"break"}generateContinue(){return"continue"}generateExistential(W,Z){return`(${this.generate(Z[0],"value")} != null)`}generateTernary(W,Z,F){let[U,$,Y]=Z;if(($?.[0]?.valueOf?.()??$?.[0])==="="&&Array.isArray($)){let Q=this.generate($[1],"value"),X=this.generate($[2],"value"),D=this.generate(Y,"value");return`${Q} = (${this.unwrap(this.generate(U,"value"))} ? ${X} : ${D})`}return`(${this.unwrap(this.generate(U,"value"))} ? ${this.generate($,"value")} : ${this.generate(Y,"value")})`}generatePipe(W,Z){let[F,U]=Z,$=this.generate(F,"value");if(Array.isArray(U)&&U.length>1){let Y=U[0];if(Array.isArray(Y)||typeof Y==="string"&&/^[a-zA-Z_$]/.test(Y)){let Q=this.generate(Y,"value"),X=U.slice(1).map((D)=>this.generate(D,"value"));return`${Q}(${$}, ${X.join(", ")})`}}return`${this.generate(U,"value")}(${$})`}generateLoop(W,Z){return`while (true) ${this.generateLoopBody(Z[0])}`}generateLoopN(W,Z){let[F,U]=Z;return`for (let it = 0; it < ${this.generate(F,"value")}; it++) ${this.generateLoopBody(U)}`}generateAwait(W,Z){return`await ${this.generate(Z[0],"value")}`}generateYield(W,Z){return Z.length===0?"yield":`yield ${this.generate(Z[0],"value")}`}generateYieldFrom(W,Z){return`yield* ${this.generate(Z[0],"value")}`}generateIf(W,Z,F,U){let[$,Y,...A]=Z;return F==="value"?this.generateIfAsExpression($,Y,A):this.generateIfAsStatement($,Y,A)}generateForIn(W,Z,F,U){let[$,Y,A,Q,X]=Z;if(F==="value"&&this.comprehensionDepth===0){let G=["for-in",$,Y,A];return this.generate(["comprehension",X,[G],Q?[Q]:[]],F)}let D=Array.isArray($)?$:[$],K=D.length===0,[M,H]=K?["_i",null]:D,J=this.is(M,"array")||this.is(M,"object")?this.generateDestructuringPattern(M):M;if(A&&A!==null){let G=this.generate(Y,"value"),q=H||"_i",w=this.generate(A,"value"),B=this.is(A,"-",1),_=B&&(A[1]==="1"||A[1]===1||L(A[1])==="1"),E=!B&&(A==="1"||A===1||L(A)==="1"),P;if(_)P=`for (let ${q} = ${G}.length - 1; ${q} >= 0; ${q}--) `;else if(E)P=`for (let ${q} = 0; ${q} < ${G}.length; ${q}++) `;else if(B)P=`for (let ${q} = ${G}.length - 1; ${q} >= 0; ${q} += ${w}) `;else P=`for (let ${q} = 0; ${q} < ${G}.length; ${q} += ${w}) `;if(this.is(X,"block")){let O=X.slice(1);this.indentLevel++;let I=[];if(!K)I.push(`const ${J} = ${G}[${q}];`);if(Q)I.push(`if (${this.generate(Q,"value")}) {`),this.indentLevel++,I.push(...this.formatStatements(O)),this.indentLevel--,I.push(this.indent()+"}");else I.push(...O.map((N)=>this.addSemicolon(N,this.generate(N,"statement"))));return this.indentLevel--,P+`{
152
149
  ${I.map((N)=>this.indent()+N).join(`
153
150
  `)}
154
151
  ${this.indent()}}`}if(K)return Q?P+`{ if (${this.generate(Q,"value")}) ${this.generate(X,"statement")}; }`:P+`{ ${this.generate(X,"statement")}; }`;return Q?P+`{ const ${J} = ${G}[${q}]; if (${this.generate(Q,"value")}) ${this.generate(X,"statement")}; }`:P+`{ const ${J} = ${G}[${q}]; ${this.generate(X,"statement")}; }`}if(H){let G=this.generate(Y,"value"),q=`for (let ${H} = 0; ${H} < ${G}.length; ${H}++) `;if(this.is(X,"block")){if(q+=`{
@@ -517,7 +514,7 @@ if (typeof globalThis !== 'undefined') {
517
514
  `:"",W=U.slice(0,$).join(`
518
515
  `)}let A=new c().tokenize(W);if(this.options.showTokens)A.forEach((z)=>console.log(`${z[0].padEnd(12)} ${JSON.stringify(z[1])}`)),console.log();let Q=null,X=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)X=[...A];A=A.filter((z)=>z[0]!=="TYPE_DECL");while(A.length>0&&A[0][0]==="TERMINATOR")A.shift();if(A.every((z)=>z[0]==="TERMINATOR")){if(X)Q=F1(X,["program"]);return{tokens:A,sexpr:["program"],code:"",dts:Q,data:F,reactiveVars:{}}}l.lexer={tokens:A,pos:0,setInput:function(){},lex:function(){if(this.pos>=this.tokens.length)return 1;let z=this.tokens[this.pos++],G=z[1];if(z.data)G=new String(G),Object.assign(G,z.data);return this.text=G,this.loc=z.loc,z[0]}};let D;try{D=l.parse(W)}catch(z){if(/\?\s*\([^)]*\?[^)]*:[^)]*\)\s*:/.test(W)||/\?\s+\w+\s+\?\s+/.test(W))throw Error("Nested ternary operators are not supported. Use if/else statements instead.");throw z}if(this.options.showSExpr)console.log(v(D,0,!0)),console.log();let K=null;if(this.options.sourceMap){let z=(this.options.filename||"output")+".js",G=this.options.filename||"input.rip";K=new D1(z,G,W)}let M=new u({dataSection:F,skipPreamble:this.options.skipPreamble,reactiveVars:this.options.reactiveVars,sourceMap:K}),H=M.compile(D),J=K?K.toJSON():null,R=K?K.toReverseMap():null;if(J&&this.options.sourceMap==="inline"){let z=typeof Buffer<"u"?Buffer.from(J).toString("base64"):btoa(J);H+=`
519
516
  //# sourceMappingURL=data:application/json;base64,${z}`}else if(J&&this.options.filename)H+=`
520
- //# sourceMappingURL=${this.options.filename}.js.map`;if(X)Q=F1(X,D);return{tokens:A,sexpr:D,code:H,dts:Q,map:J,reverseMap:R,data:F,reactiveVars:M.reactiveVars}}compileToJS(W){return this.compile(W).code}compileToSExpr(W){return this.compile(W).sexpr}}h1(u,c);u.prototype.generateEnum=G1;function z1(W,Z={}){return new $1(Z).compile(W)}function m(W,Z={}){return new $1(Z).compileToJS(W)}function Y1(){return new u({}).getReactiveRuntime()}function H1(){return new u({}).getComponentRuntime()}var T2="3.10.9",S2="2026-02-20@07:22:34GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(Y1())();var L2=(W)=>{let Z=W.match(/^[ \t]*(?=\S)/gm),F=Math.min(...(Z||[]).map((U)=>U.length));return W.replace(RegExp(`^[ ]{${F}}`,"gm"),"").trim()};async function f2(){let W=document.querySelectorAll('script[type="text/rip"]');for(let Z of W){if(Z.hasAttribute("data-rip-processed"))continue;if(Z.hasAttribute("data-name"))continue;try{let F;if(Z.src){let $=await fetch(Z.src);if(!$.ok){console.error(`Rip: failed to fetch ${Z.src} (${$.status})`);continue}F=await $.text()}else F=L2(Z.textContent);let U;try{U=m(F)}catch($){console.error("Rip compile error:",$.message),console.error("Source:",F);continue}await(0,eval)(`(async()=>{
517
+ //# sourceMappingURL=${this.options.filename}.js.map`;if(X)Q=F1(X,D);return{tokens:A,sexpr:D,code:H,dts:Q,map:J,reverseMap:R,data:F,reactiveVars:M.reactiveVars}}compileToJS(W){return this.compile(W).code}compileToSExpr(W){return this.compile(W).sexpr}}h1(u,c);u.prototype.generateEnum=G1;function z1(W,Z={}){return new $1(Z).compile(W)}function m(W,Z={}){return new $1(Z).compileToJS(W)}function Y1(){return new u({}).getReactiveRuntime()}function H1(){return new u({}).getComponentRuntime()}var T2="3.10.11",S2="2026-02-20@13:12:39GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(Y1())();var L2=(W)=>{let Z=W.match(/^[ \t]*(?=\S)/gm),F=Math.min(...(Z||[]).map((U)=>U.length));return W.replace(RegExp(`^[ ]{${F}}`,"gm"),"").trim()};async function f2(){let W=document.querySelectorAll('script[type="text/rip"]');for(let Z of W){if(Z.hasAttribute("data-rip-processed"))continue;if(Z.hasAttribute("data-name"))continue;try{let F;if(Z.src){let $=await fetch(Z.src);if(!$.ok){console.error(`Rip: failed to fetch ${Z.src} (${$.status})`);continue}F=await $.text()}else F=L2(Z.textContent);let U;try{U=m(F)}catch($){console.error("Rip compile error:",$.message),console.error("Source:",F);continue}await(0,eval)(`(async()=>{
521
518
  ${U}
522
519
  })()`),Z.setAttribute("data-rip-processed","true")}catch(F){console.error("Rip runtime error:",F)}}}async function W1(W){for(let[Y,A]of Object.entries(W1.modules))if(W.includes(Y))return A;let Z=await fetch(W).then((Y)=>{if(!Y.ok)throw Error(`importRip: ${W} (${Y.status})`);return Y.text()}),F=m(Z),U=new Blob([F],{type:"application/javascript"}),$=URL.createObjectURL(U);try{return await import($)}finally{URL.revokeObjectURL($)}}W1.modules={};function V2(W){try{let Z=W.replace(/^/gm," "),U=m(`do ->
523
- ${Z}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let $=(0,eval)(U);if($&&typeof $.then==="function")return $.then((Y)=>{if(Y!==void 0)globalThis._=Y;return Y});if($!==void 0)globalThis._=$;return $}catch(Z){console.error("Rip compilation error:",Z.message);return}}if(typeof globalThis<"u")globalThis.rip=V2,globalThis.importRip=W1,globalThis.compileToJS=m,globalThis.__ripExports={compile:z1,compileToJS:m,formatSExpr:v,VERSION:T2,BUILD_DATE:S2,getReactiveRuntime:Y1,getComponentRuntime:H1};async function j2(){if(globalThis.__ripLaunched)return;let W=W1.modules?.["ui.rip"];if(!W?.launch)return;let Z=document.querySelector("script[data-hash], script[data-url]"),F=Z?.getAttribute("data-url")||"";if(!(document.querySelectorAll('script[type="text/rip"][data-name]').length>0)&&!F)return;let $={};if(Z?.hasAttribute("data-hash"))$.hash=Z.getAttribute("data-hash")!=="false";await W.launch(F,$)}if(typeof document<"u")globalThis.__ripScriptsReady=new Promise((W)=>{let Z=()=>f2().then(j2).then(W);if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>queueMicrotask(Z));else queueMicrotask(Z)});export{V2 as rip,f2 as processRipScripts,l as parser,W1 as importRip,Y1 as getReactiveRuntime,H1 as getComponentRuntime,v as formatSExpr,m as compileToJS,z1 as compile,T2 as VERSION,c as Lexer,$1 as Compiler,u as CodeGenerator,S2 as BUILD_DATE};
520
+ ${Z}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let $=(0,eval)(U);if($&&typeof $.then==="function")return $.then((Y)=>{if(Y!==void 0)globalThis._=Y;return Y});if($!==void 0)globalThis._=$;return $}catch(Z){console.error("Rip compilation error:",Z.message);return}}if(typeof globalThis<"u")globalThis.rip=V2,globalThis.importRip=W1,globalThis.compileToJS=m,globalThis.__ripExports={compile:z1,compileToJS:m,formatSExpr:v,VERSION:T2,BUILD_DATE:S2,getReactiveRuntime:Y1,getComponentRuntime:H1};async function j2(){if(globalThis.__ripLaunched)return;let W=W1.modules?.["ui.rip"];if(!W?.launch)return;let Z=document.querySelector("script[data-hash], script[data-url]"),F=Z?.getAttribute("data-url")||"";if(!(document.querySelectorAll('script[type="text/rip"][data-name]').length>0)&&!F)return;let Y={hash:Z?.getAttribute("data-hash")!=="false"};await W.launch(F,Y)}if(typeof document<"u")globalThis.__ripScriptsReady=new Promise((W)=>{let Z=()=>f2().then(j2).then(W);if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>queueMicrotask(Z));else queueMicrotask(Z)});export{V2 as rip,f2 as processRipScripts,l as parser,W1 as importRip,Y1 as getReactiveRuntime,H1 as getComponentRuntime,v as formatSExpr,m as compileToJS,z1 as compile,T2 as VERSION,c as Lexer,$1 as Compiler,u as CodeGenerator,S2 as BUILD_DATE};
Binary file
package/docs/index.html CHANGED
@@ -520,8 +520,9 @@
520
520
  <div class="tabs">
521
521
  <button class="tab active" data-tab="compiler"><span class="tab-full">Live Compiler</span><span class="tab-short">Compiler</span></button>
522
522
  <button class="tab" data-tab="repl"><span class="tab-full">REPL Console</span><span class="tab-short">REPL</span></button>
523
- <button class="tab" data-tab="demo">Demo</button>
524
523
  <button class="tab" data-tab="example">Example</button>
524
+ <button class="tab" data-tab="sierpinski">Sierpinski</button>
525
+ <button class="tab" data-tab="demo" title="Opens in new tab">Demo ⧉</button>
525
526
  </div>
526
527
 
527
528
  <!-- Content -->
@@ -600,9 +601,9 @@
600
601
  </div>
601
602
  </div>
602
603
 
603
- <!-- Demo Pane -->
604
- <div class="pane" id="demo-pane">
605
- <iframe id="demo-iframe" style="width: 100%; height: 100%; border: none;"></iframe>
604
+ <!-- Sierpinski Pane -->
605
+ <div class="pane" id="sierpinski-pane">
606
+ <iframe id="sierpinski-iframe" style="width: 100%; height: 100%; border: none;"></iframe>
606
607
  </div>
607
608
 
608
609
  <!-- Example Pane -->
@@ -1124,10 +1125,13 @@
1124
1125
  # Tab Switching
1125
1126
  # ====================================================================
1126
1127
 
1127
- demoLoaded = false
1128
+ sierpinskiLoaded = false
1128
1129
  exampleLoaded = false
1129
1130
 
1130
1131
  def switchToTab(tabName)
1132
+ if tabName is 'demo'
1133
+ window.open 'https://shreeve.github.io/rip-lang/results/', '_blank'
1134
+ return
1131
1135
  window.location.hash = tabName
1132
1136
  document.querySelectorAll('.tab').forEach (t) -> t.classList.remove 'active'
1133
1137
  document.querySelector(".tab[data-tab='#{tabName}']").classList.add 'active'
@@ -1139,10 +1143,10 @@
1139
1143
  else if tabName is 'compiler'
1140
1144
  setTheme! themeSelect.value
1141
1145
  compileCode()
1142
- else if tabName is 'demo'
1143
- unless demoLoaded
1144
- document.getElementById('demo-iframe').src = 'sierpinski.html'
1145
- demoLoaded = true
1146
+ else if tabName is 'sierpinski'
1147
+ unless sierpinskiLoaded
1148
+ document.getElementById('sierpinski-iframe').src = 'sierpinski.html'
1149
+ sierpinskiLoaded = true
1146
1150
  else if tabName is 'example'
1147
1151
  unless exampleLoaded
1148
1152
  document.getElementById('example-iframe').src = 'example/'
@@ -1153,7 +1157,7 @@
1153
1157
 
1154
1158
  window.addEventListener 'hashchange', ->
1155
1159
  hash = window.location.hash.slice 1
1156
- switchToTab hash if hash is 'compiler' or hash is 'repl' or hash is 'demo' or hash is 'example'
1160
+ switchToTab hash if hash is 'compiler' or hash is 'repl' or hash is 'sierpinski' or hash is 'example'
1157
1161
 
1158
1162
  # ====================================================================
1159
1163
  # Resizable Panes
@@ -1471,7 +1475,7 @@
1471
1475
 
1472
1476
  # Initialize from URL hash (default to compiler)
1473
1477
  initialTab = window.location.hash.slice 1
1474
- if initialTab is 'compiler' or initialTab is 'repl' or initialTab is 'demo' or initialTab is 'example'
1478
+ if initialTab is 'compiler' or initialTab is 'repl' or initialTab is 'sierpinski' or initialTab is 'example'
1475
1479
  switchToTab! initialTab
1476
1480
  else
1477
1481
  compileCode()
@@ -7,7 +7,7 @@
7
7
  <link rel="preconnect" href="https://fonts.googleapis.com">
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
9
  <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,500;0,700;1,400&family=Nothing+You+Could+Do&display=swap" rel="stylesheet">
10
- <script type="module" src="../dist/rip-ui.min.js" data-hash="true"></script>
10
+ <script type="module" src="../dist/rip-ui.min.js"></script>
11
11
  <style>
12
12
  /* ==========================================================================
13
13
  Lab Results — Styles
@@ -566,8 +566,10 @@ body {
566
566
  .gauge__value { font-size: 18px; color: white; bottom: 26px; }
567
567
  .gauge__units { font-size: 13px; color: rgba(255,255,255,.9); bottom: 13px; }
568
568
 
569
+ @page { size: letter; margin: 0; }
570
+
569
571
  @media print {
570
- body { background: white; }
572
+ body { margin: 0; background: white; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
571
573
 
572
574
  .header, .sidebar, .drawer, .drawer-overlay, .btn-primary,
573
575
  .settings__section { display: none !important; }
@@ -578,16 +580,15 @@ body {
578
580
  .brochure { width: 100%; box-shadow: none; }
579
581
 
580
582
  .brochure__page {
581
- width: 100%;
582
- height: 100%;
583
- position: absolute;
584
- top: 0; left: 0;
585
- margin: auto;
583
+ width: 8.5in;
584
+ min-height: 11in;
586
585
  border: none;
587
- page-break-before: always;
586
+ overflow: hidden;
587
+ break-before: page;
588
+ break-inside: avoid;
588
589
  }
589
590
 
590
- .brochure__page:first-child { page-break-before: auto; }
591
+ .brochure__page:first-child { break-before: auto; }
591
592
  }
592
593
  </style>
593
594
  </head>
@@ -610,7 +611,7 @@ export Home = component
610
611
  gender := 'Male'
611
612
 
612
613
  history := [
613
- date: '2022-10'
614
+ date: "#{new Date().getFullYear()}-#{String(new Date().getMonth() + 1).padStart(2, '0')}"
614
615
  triglycerides: 181
615
616
  hdlCholesterol: 44
616
617
  totalCholesterol: 177
@@ -815,6 +816,17 @@ export Settings = component
815
816
  label "Hemoglobin A1c (%)"
816
817
  input type: 'number', step: '0.1', value <=> history[0].a1c
817
818
 
819
+ if history?[0]?.waistCircumference
820
+ .settings__section
821
+ .settings__heading "Physical Measurements"
822
+ .settings__fields
823
+ .settings__field
824
+ label "Waist Circumference (in)"
825
+ input type: 'number', value <=> history[0].waistCircumference
826
+ .settings__field
827
+ label "Blood Pressure (mm/Hg)"
828
+ input type: 'text', value <=> history[0].bloodPressure
829
+
818
830
  button.btn-primary "Print PDF"
819
831
  @click: -> window.print()
820
832
  </script>
@@ -914,9 +926,10 @@ export Summary = component
914
926
  "#{mo}/#{dy}/#{yr}"
915
927
 
916
928
  historyDate ~=
917
- return '' unless history and history[0] and history[0].date
918
- parts = history[0].date.split('-')
919
- "#{parts[1]}/#{parts[0]}"
929
+ return '' unless history?[0]?.date
930
+ months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
931
+ [yr, mo] = history[0].date.split('-')
932
+ "#{months[parseInt(mo, 10) - 1]} #{yr}"
920
933
 
921
934
  checkIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>'
922
935
  warnIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>'
@@ -993,11 +1006,11 @@ export DetailPage = component
993
1006
  history?[0]?[topic.conditional]?
994
1007
 
995
1008
  tipIcons :=
996
- utensils: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 2v7c0 1.1.9 2 2 2h4c1.1 0 2-.9 2-2V2"/><line x1="7" y1="2" x2="7" y2="22"/><path d="M21 15V2a5 5 0 00-5 5v6h4"/><line x1="21" y1="12" x2="21" y2="22"/></svg>'
997
- drop: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2.69l5.66 5.66a8 8 0 11-11.31 0z"/></svg>'
998
- walk: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="13" cy="4" r="2"/><path d="M7 21l3-4V11l-2-2-3 3"/><path d="M16 21l-2-6-3-1"/></svg>'
999
- doctor: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 11V3M4.93 7.5l7.07 3.5 7.07-3.5"/><circle cx="12" cy="18" r="3"/><line x1="12" y1="15" x2="12" y2="11"/></svg>'
1000
- smile: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>'
1009
+ utensils: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2"/><path d="M7 2v20"/><path d="M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/></svg>'
1010
+ drop: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"/></svg>'
1011
+ walk: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="5" r="1"/><path d="m9 20 3-6 3 6"/><path d="m6 8 6 2 6-2"/><path d="M12 10v4"/></svg>'
1012
+ doctor: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M11 2v2"/><path d="M5 2v2"/><path d="M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1"/><path d="M8 15a6 6 0 0 0 12 0v-3"/><circle cx="20" cy="10" r="2"/></svg>'
1013
+ smile: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" x2="9.01" y1="9" y2="9"/><line x1="15" x2="15.01" y1="9" y2="9"/></svg>'
1001
1014
 
1002
1015
  checkIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>'
1003
1016
  warnIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.10.9",
3
+ "version": "3.10.11",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/browser.js CHANGED
@@ -138,6 +138,7 @@ if (typeof globalThis !== 'undefined') {
138
138
 
139
139
  // Auto-launch: if rip-ui is bundled and the page has component scripts or a data-url,
140
140
  // call launch() automatically with config from the script tag's data attributes.
141
+ // Hash routing defaults to true (opt out with data-hash="false").
141
142
  async function autoLaunch() {
142
143
  if (globalThis.__ripLaunched) return;
143
144
  const ui = importRip.modules?.['ui.rip'];
@@ -146,8 +147,8 @@ async function autoLaunch() {
146
147
  const url = cfg?.getAttribute('data-url') || '';
147
148
  const hasComponents = document.querySelectorAll('script[type="text/rip"][data-name]').length > 0;
148
149
  if (!hasComponents && !url) return;
149
- const opts = {};
150
- if (cfg?.hasAttribute('data-hash')) opts.hash = cfg.getAttribute('data-hash') !== 'false';
150
+ const hash = cfg?.getAttribute('data-hash');
151
+ const opts = { hash: hash !== 'false' };
151
152
  await ui.launch(url, opts);
152
153
  }
153
154
 
package/src/compiler.js CHANGED
@@ -371,7 +371,7 @@ export class CodeGenerator {
371
371
  return;
372
372
  }
373
373
 
374
- if (head === 'def' || head === '->' || head === '=>') return;
374
+ if (head === 'def' || head === '->' || head === '=>' || head === 'effect') return;
375
375
 
376
376
  if (head === 'if') {
377
377
  let [condition, thenBranch, elseBranch] = rest;
@@ -423,7 +423,7 @@ export class CodeGenerator {
423
423
  collect(value);
424
424
  return;
425
425
  }
426
- if (head === 'def' || head === '->' || head === '=>') return;
426
+ if (head === 'def' || head === '->' || head === '=>' || head === 'effect') return;
427
427
  if (head === 'try') {
428
428
  collect(rest[0]);
429
429
  if (rest.length >= 2 && Array.isArray(rest[1]) && rest[1].length === 2 && rest[1][0] !== 'block') {
@@ -1110,8 +1110,7 @@ export class CodeGenerator {
1110
1110
  this.usesReactivity = true;
1111
1111
  let bodyCode;
1112
1112
  if (this.is(body, 'block')) {
1113
- let stmts = this.withIndent(() => this.formatStatements(body.slice(1)));
1114
- bodyCode = `{\n${stmts.join('\n')}\n${this.indent()}}`;
1113
+ bodyCode = this.generateFunctionBody(body);
1115
1114
  } else if ((this.is(body, '->') || this.is(body, '=>'))) {
1116
1115
  let fnCode = this.generate(body, 'value');
1117
1116
  if (target) return `const ${str(target) ?? this.generate(target, 'value')} = __effect(${fnCode})`;