rip-lang 2.8.1 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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-2.8.1-blue.svg" alt="Version"></a>
12
+ <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-2.8.3-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-1021%2F1021-brightgreen.svg" alt="Tests"></a>
15
15
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
@@ -1946,16 +1946,16 @@ Rewriter = function() {
1946
1946
  val.generated = true;
1947
1947
  return tokens.splice(idx, 0, generate("{", val, token, prevToken));
1948
1948
  };
1949
- endImplicitObject = function(j) {
1950
- j = j != null ? j : i;
1949
+ endImplicitObject = function(j2) {
1950
+ j2 = j2 != null ? j2 : i;
1951
1951
  stack.pop();
1952
- tokens.splice(j, 0, generate("}", "}", token, prevToken));
1952
+ tokens.splice(j2, 0, generate("}", "}", token, prevToken));
1953
1953
  return i += 1;
1954
1954
  };
1955
- implicitObjectContinues = (j) => {
1955
+ implicitObjectContinues = (j2) => {
1956
1956
  var nextTerminatorIdx;
1957
1957
  nextTerminatorIdx = null;
1958
- this.detectEnd(j, function(token2) {
1958
+ this.detectEnd(j2, function(token2) {
1959
1959
  return token2[0] === "TERMINATOR";
1960
1960
  }, function(token2, i2) {
1961
1961
  return nextTerminatorIdx = i2;
@@ -2100,12 +2100,35 @@ Rewriter = function() {
2100
2100
  }
2101
2101
  }
2102
2102
  newLine = prevTag === "OUTDENT" || prevToken.newLine;
2103
- if (indexOf.call(IMPLICIT_END, tag) >= 0 || indexOf.call(CALL_CLOSERS, tag) >= 0 && newLine || (tag === ".." || tag === "...") && this.findTagsBackwards(i, ["INDEX_START"])) {
2103
+ var isLogicalOp = tag === "||" || tag === "&&";
2104
+ var logicalOpHasMoreArgs = false;
2105
+ if (isLogicalOp && i + 1 < tokens.length) {
2106
+ var nextTok = tokens[i + 1][0];
2107
+ var j = i + 1;
2108
+ if (nextTok === "(" || nextTok === "[" || nextTok === "{") {
2109
+ var depth = 1;
2110
+ j++;
2111
+ while (j < tokens.length && depth > 0) {
2112
+ var lt = tokens[j][0];
2113
+ if (lt === "(" || lt === "[" || lt === "{")
2114
+ depth++;
2115
+ else if (lt === ")" || lt === "]" || lt === "}")
2116
+ depth--;
2117
+ j++;
2118
+ }
2119
+ } else if (nextTok !== "TERMINATOR" && nextTok !== "OUTDENT" && nextTok !== ",") {
2120
+ j++;
2121
+ }
2122
+ if (j < tokens.length && tokens[j][0] === ",") {
2123
+ logicalOpHasMoreArgs = true;
2124
+ }
2125
+ }
2126
+ if (indexOf.call(IMPLICIT_END, tag) >= 0 && !(isLogicalOp && logicalOpHasMoreArgs) || indexOf.call(CALL_CLOSERS, tag) >= 0 && newLine || (tag === ".." || tag === "...") && this.findTagsBackwards(i, ["INDEX_START"])) {
2104
2127
  while (inImplicit()) {
2105
2128
  [stackTag, stackIdx, { sameLine, startsLine }] = stackTop();
2106
2129
  if (inImplicitCall() && prevTag !== "," || prevTag === "," && tag === "TERMINATOR" && nextTag == null) {
2107
2130
  endImplicitCall();
2108
- } else if (inImplicitObject() && sameLine && tag !== "TERMINATOR" && prevTag !== ":" && !((tag === "POST_IF" || tag === "FOR" || tag === "WHILE" || tag === "UNTIL") && startsLine && implicitObjectContinues(i + 1))) {
2131
+ } else if (inImplicitObject() && !isLogicalOp && sameLine && tag !== "TERMINATOR" && prevTag !== ":" && !((tag === "POST_IF" || tag === "FOR" || tag === "WHILE" || tag === "UNTIL") && startsLine && implicitObjectContinues(i + 1))) {
2109
2132
  endImplicitObject();
2110
2133
  } else if (inImplicitObject() && tag === "TERMINATOR" && prevTag !== "," && !(startsLine && this.looksObjectish(i + 1))) {
2111
2134
  endImplicitObject();
@@ -2624,7 +2647,7 @@ EXPRESSION_CLOSE = ["CATCH", "THEN", "ELSE", "FINALLY"].concat(EXPRESSION_END);
2624
2647
  IMPLICIT_FUNC = ["IDENTIFIER", "PROPERTY", "SUPER", ")", "CALL_END", "]", "INDEX_END", "@", "THIS"];
2625
2648
  IMPLICIT_CALL = ["IDENTIFIER", "PROPERTY", "NUMBER", "INFINITY", "NAN", "STRING", "STRING_START", "REGEX", "REGEX_START", "JS", "NEW", "PARAM_START", "CLASS", "IF", "TRY", "SWITCH", "THIS", "DYNAMIC_IMPORT", "IMPORT_META", "NEW_TARGET", "UNDEFINED", "NULL", "BOOL", "UNARY", "DO", "DO_IIFE", "YIELD", "AWAIT", "UNARY_MATH", "SUPER", "THROW", "@", "->", "=>", "[", "(", "{", "--", "++"];
2626
2649
  IMPLICIT_UNSPACED_CALL = ["+", "-"];
2627
- IMPLICIT_END = ["POST_IF", "FOR", "WHILE", "UNTIL", "WHEN", "BY", "LOOP", "TERMINATOR"];
2650
+ IMPLICIT_END = ["POST_IF", "FOR", "WHILE", "UNTIL", "WHEN", "BY", "LOOP", "TERMINATOR", "||", "&&"];
2628
2651
  IMPLICIT_COMMA_BEFORE_ARROW = ["STRING", "STRING_END", "REGEX", "REGEX_END", "NUMBER", "BOOL", "NULL", "UNDEFINED", "INFINITY", "NAN", "]", "}"];
2629
2652
  SINGLE_LINERS = ["ELSE", "->", "=>", "TRY", "FINALLY", "THEN"];
2630
2653
  SINGLE_CLOSERS = ["TERMINATOR", "CATCH", "FINALLY", "ELSE", "OUTDENT", "LEADING_WHEN"];
@@ -4648,27 +4671,27 @@ ${this.indent()}}`;
4648
4671
  }
4649
4672
  if (step && step !== null) {
4650
4673
  const iterableCode = this.generate(iterable, "value");
4651
- const indexVarName2 = indexVar || "_i";
4674
+ const indexVarName = indexVar || "_i";
4652
4675
  const stepCode = this.generate(step, "value");
4653
4676
  const isNegativeStep = this.isNegativeStep(step);
4654
4677
  const isMinusOne = isNegativeStep && (step[1] === "1" || step[1] === 1 || step[1] instanceof String && step[1].valueOf() === "1");
4655
4678
  const isPlusOne = !isNegativeStep && (step === "1" || step === 1 || step instanceof String && step.valueOf() === "1");
4656
4679
  let loopHeader;
4657
4680
  if (isMinusOne) {
4658
- loopHeader = `for (let ${indexVarName2} = ${iterableCode}.length - 1; ${indexVarName2} >= 0; ${indexVarName2}--) `;
4681
+ loopHeader = `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName}--) `;
4659
4682
  } else if (isPlusOne) {
4660
- loopHeader = `for (let ${indexVarName2} = 0; ${indexVarName2} < ${iterableCode}.length; ${indexVarName2}++) `;
4683
+ loopHeader = `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName}++) `;
4661
4684
  } else if (isNegativeStep) {
4662
- loopHeader = `for (let ${indexVarName2} = ${iterableCode}.length - 1; ${indexVarName2} >= 0; ${indexVarName2} += ${stepCode}) `;
4685
+ loopHeader = `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) `;
4663
4686
  } else {
4664
- loopHeader = `for (let ${indexVarName2} = 0; ${indexVarName2} < ${iterableCode}.length; ${indexVarName2} += ${stepCode}) `;
4687
+ loopHeader = `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) `;
4665
4688
  }
4666
4689
  if (Array.isArray(body) && body[0] === "block") {
4667
4690
  const statements = body.slice(1);
4668
4691
  this.indentLevel++;
4669
4692
  const stmts = [];
4670
4693
  if (!noVar) {
4671
- stmts.push(`const ${itemVarPattern} = ${iterableCode}[${indexVarName2}];`);
4694
+ stmts.push(`const ${itemVarPattern} = ${iterableCode}[${indexVarName}];`);
4672
4695
  }
4673
4696
  if (guard) {
4674
4697
  const guardCode = this.generate(guard, "value");
@@ -4696,9 +4719,9 @@ ${this.indent()}}`;
4696
4719
  } else {
4697
4720
  if (guard) {
4698
4721
  const guardCode = this.generate(guard, "value");
4699
- return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${indexVarName2}]; if (${guardCode}) ${this.generate(body, "statement")}; }`;
4722
+ return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${indexVarName}]; if (${guardCode}) ${this.generate(body, "statement")}; }`;
4700
4723
  } else {
4701
- return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${indexVarName2}]; ${this.generate(body, "statement")}; }`;
4724
+ return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${indexVarName}]; ${this.generate(body, "statement")}; }`;
4702
4725
  }
4703
4726
  }
4704
4727
  }
@@ -5366,19 +5389,19 @@ ${this.indent()}}`;
5366
5389
  this.indentLevel++;
5367
5390
  } else {
5368
5391
  const iterableCode = this.generate(iterable, "value");
5369
- const indexVarName2 = indexVar || "_i";
5392
+ const indexVarName = indexVar || "_i";
5370
5393
  const stepCode = this.generate(step, "value");
5371
5394
  const isNegativeStep = this.isNegativeStep(step);
5372
5395
  if (isNegativeStep) {
5373
- code += this.indent() + `for (let ${indexVarName2} = ${iterableCode}.length - 1; ${indexVarName2} >= 0; ${indexVarName2} += ${stepCode}) {
5396
+ code += this.indent() + `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) {
5374
5397
  `;
5375
5398
  } else {
5376
- code += this.indent() + `for (let ${indexVarName2} = 0; ${indexVarName2} < ${iterableCode}.length; ${indexVarName2} += ${stepCode}) {
5399
+ code += this.indent() + `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) {
5377
5400
  `;
5378
5401
  }
5379
5402
  this.indentLevel++;
5380
5403
  if (!noVar) {
5381
- code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName2}];
5404
+ code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName}];
5382
5405
  `;
5383
5406
  }
5384
5407
  }
@@ -6574,19 +6597,19 @@ ${this.indent()}}`;
6574
6597
  `;
6575
6598
  } else {
6576
6599
  const iterableCode = this.generate(iterable, "value");
6577
- const indexVarName2 = indexVar || "_i";
6600
+ const indexVarName = indexVar || "_i";
6578
6601
  const stepCode = this.generate(step, "value");
6579
6602
  const isNegativeStep = this.isNegativeStep(step);
6580
6603
  if (isNegativeStep) {
6581
- code += this.indent() + `for (let ${indexVarName2} = ${iterableCode}.length - 1; ${indexVarName2} >= 0; ${indexVarName2} += ${stepCode}) {
6604
+ code += this.indent() + `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) {
6582
6605
  `;
6583
6606
  } else {
6584
- code += this.indent() + `for (let ${indexVarName2} = 0; ${indexVarName2} < ${iterableCode}.length; ${indexVarName2} += ${stepCode}) {
6607
+ code += this.indent() + `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) {
6585
6608
  `;
6586
6609
  }
6587
6610
  this.indentLevel++;
6588
6611
  if (!noVar) {
6589
- code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName2}];
6612
+ code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName}];
6590
6613
  `;
6591
6614
  }
6592
6615
  }
@@ -6650,25 +6673,25 @@ ${this.indent()}}`;
6650
6673
  code += `for (let ${itemVarPattern} = ${startCode}; ${itemVarPattern} ${comparison} ${endCode}; ${itemVarPattern} += ${stepCode}) `;
6651
6674
  } else {
6652
6675
  const iterableCode = this.generate(iterable, "value");
6653
- const indexVarName2 = indexVar || "_i";
6676
+ const indexVarName = indexVar || "_i";
6654
6677
  const stepCode = this.generate(step, "value");
6655
6678
  const isNegativeStep = this.isNegativeStep(step);
6656
6679
  const isMinusOne = isNegativeStep && (step[1] === "1" || step[1] === 1 || step[1] instanceof String && step[1].valueOf() === "1");
6657
6680
  const isPlusOne = !isNegativeStep && (step === "1" || step === 1 || step instanceof String && step.valueOf() === "1");
6658
6681
  if (isMinusOne) {
6659
- code += `for (let ${indexVarName2} = ${iterableCode}.length - 1; ${indexVarName2} >= 0; ${indexVarName2}--) `;
6682
+ code += `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName}--) `;
6660
6683
  } else if (isPlusOne) {
6661
- code += `for (let ${indexVarName2} = 0; ${indexVarName2} < ${iterableCode}.length; ${indexVarName2}++) `;
6684
+ code += `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName}++) `;
6662
6685
  } else if (isNegativeStep) {
6663
- code += `for (let ${indexVarName2} = ${iterableCode}.length - 1; ${indexVarName2} >= 0; ${indexVarName2} += ${stepCode}) `;
6686
+ code += `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) `;
6664
6687
  } else {
6665
- code += `for (let ${indexVarName2} = 0; ${indexVarName2} < ${iterableCode}.length; ${indexVarName2} += ${stepCode}) `;
6688
+ code += `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) `;
6666
6689
  }
6667
6690
  code += `{
6668
6691
  `;
6669
6692
  this.indentLevel++;
6670
6693
  if (!noVar) {
6671
- code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName2}];
6694
+ code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName}];
6672
6695
  `;
6673
6696
  }
6674
6697
  }
@@ -6711,7 +6734,7 @@ ${this.indent()}}`;
6711
6734
  code += `{
6712
6735
  `;
6713
6736
  this.indentLevel++;
6714
- code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName}];
6737
+ code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVar}];
6715
6738
  `;
6716
6739
  } else {
6717
6740
  code += `for (const ${itemVarPattern} of ${this.generate(iterable, "value")}) `;
@@ -7511,8 +7534,8 @@ function compileToJS(source, options = {}) {
7511
7534
  return new Compiler(options).compileToJS(source);
7512
7535
  }
7513
7536
  // src/browser.js
7514
- var VERSION = "2.8.1";
7515
- var BUILD_DATE = "2026-02-04@03:40:08GMT";
7537
+ var VERSION = "2.8.3";
7538
+ var BUILD_DATE = "2026-02-04@08:25:13GMT";
7516
7539
  var dedent = (s) => {
7517
7540
  const m = s.match(/^[ \t]*(?=\S)/gm);
7518
7541
  const i = Math.min(...(m || []).map((x) => x.length));