rip-lang 3.13.21 → 3.13.23

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.13.21",
3
+ "version": "3.13.23",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/components.js CHANGED
@@ -397,7 +397,17 @@ export function installComponentSupport(CodeGenerator, Lexer) {
397
397
  // ─────────────────────────────────────────────────────────────────────
398
398
  // Implicit nesting (inject -> before INDENT)
399
399
  // ─────────────────────────────────────────────────────────────────────
400
- if (nextToken && nextToken[0] === 'INDENT' && !nextToken.fromThen) {
400
+ if (nextToken && nextToken[0] === 'INDENT') {
401
+ // Skip fromThen INDENTs inside string interpolation (e.g. "#{if x then y else z}")
402
+ if (nextToken.fromThen) {
403
+ let depth = 0;
404
+ for (let j = i; j >= 0; j--) {
405
+ let jt = tokens[j][0];
406
+ if (jt === 'INTERPOLATION_END' || jt === 'STRING_END') depth++;
407
+ if (jt === 'INTERPOLATION_START' || jt === 'STRING_START') depth--;
408
+ if (depth < 0) { return 1; }
409
+ }
410
+ }
401
411
  if (tag === '->' || tag === '=>' || tag === 'CALL_START' || tag === '(') {
402
412
  return 1;
403
413
  }
@@ -1511,6 +1521,10 @@ export function installComponentSupport(CodeGenerator, Lexer) {
1511
1521
  this._createLines = [];
1512
1522
  this._setupLines = [];
1513
1523
 
1524
+ // Capture enclosing loop variables before pushing current loop
1525
+ const outerLoopParams = this._loopVarStack.map(v => `${v.itemVar}, ${v.indexVar}`).join(', ');
1526
+ const outerExtra = outerLoopParams ? `, ${outerLoopParams}` : '';
1527
+
1514
1528
  this._loopVarStack.push({ itemVar, indexVar });
1515
1529
  const itemNode = this.generateTemplateBlock(body);
1516
1530
  this._loopVarStack.pop();
@@ -1524,7 +1538,7 @@ export function installComponentSupport(CodeGenerator, Lexer) {
1524
1538
 
1525
1539
  // Generate block factory
1526
1540
  const factoryLines = [];
1527
- factoryLines.push(`function ${blockName}(ctx, ${itemVar}, ${indexVar}) {`);
1541
+ factoryLines.push(`function ${blockName}(ctx, ${itemVar}, ${indexVar}${outerExtra}) {`);
1528
1542
 
1529
1543
  const localVars = new Set();
1530
1544
  for (const line of itemCreateLines) {
@@ -1562,7 +1576,7 @@ export function installComponentSupport(CodeGenerator, Lexer) {
1562
1576
  factoryLines.push(` },`);
1563
1577
 
1564
1578
  // p() - update
1565
- factoryLines.push(` p(ctx, ${itemVar}, ${indexVar}) {`);
1579
+ factoryLines.push(` p(ctx, ${itemVar}, ${indexVar}${outerExtra}) {`);
1566
1580
  if (hasEffects) {
1567
1581
  factoryLines.push(` disposers.forEach(d => d());`);
1568
1582
  factoryLines.push(` disposers = [];`);
@@ -1615,11 +1629,11 @@ export function installComponentSupport(CodeGenerator, Lexer) {
1615
1629
  setupLines.push(` const __key = ${keyExpr};`);
1616
1630
  setupLines.push(` let __block = __map.get(__key);`);
1617
1631
  setupLines.push(` if (!__block) {`);
1618
- setupLines.push(` __block = ${blockName}(this, ${itemVar}, ${indexVar});`);
1632
+ setupLines.push(` __block = ${blockName}(this, ${itemVar}, ${indexVar}${outerExtra});`);
1619
1633
  setupLines.push(` __block.c();`);
1620
1634
  setupLines.push(` }`);
1621
1635
  setupLines.push(` __block.m(__parent, __anchor);`);
1622
- setupLines.push(` __block.p(this, ${itemVar}, ${indexVar});`);
1636
+ setupLines.push(` __block.p(this, ${itemVar}, ${indexVar}${outerExtra});`);
1623
1637
  setupLines.push(` __newMap.set(__key, __block);`);
1624
1638
  setupLines.push(` }`);
1625
1639
  setupLines.push(``);