rip-lang 3.14.2 → 3.14.4

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="https://github.com/shreeve/rip-lang/commits/main"><img src="https://img.shields.io/badge/version-3.14.2-blue.svg" alt="Version"></a>
12
+ <a href="https://github.com/shreeve/rip-lang/commits/main"><img src="https://img.shields.io/badge/version-3.14.4-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%2C436%2F1%2C436-brightgreen.svg" alt="Tests"></a>
15
15
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
package/docs/dist/rip.js CHANGED
@@ -5382,7 +5382,7 @@ function __schema(descriptor) {
5382
5382
  "THIS"
5383
5383
  ]);
5384
5384
  var TAGGABLE = new Set(["IDENTIFIER", "PROPERTY", ")", "CALL_END", "]", "INDEX_END"]);
5385
- var CONTROL_IN_IMPLICIT = new Set(["IF", "TRY", "FINALLY", "CATCH", "CLASS", "SWITCH", "COMPONENT"]);
5385
+ var CONTROL_IN_IMPLICIT = new Set(["IF", "TRY", "FINALLY", "CATCH", "CLASS", "SWITCH", "COMPONENT", "FOR"]);
5386
5386
  var SINGLE_LINERS = new Set(["ELSE", "->", "=>", "TRY", "FINALLY", "THEN"]);
5387
5387
  var SINGLE_CLOSERS = new Set(["TERMINATOR", "CATCH", "FINALLY", "ELSE", "OUTDENT", "LEADING_WHEN"]);
5388
5388
  var LINE_BREAK = new Set(["INDENT", "OUTDENT", "TERMINATOR"]);
@@ -12572,7 +12572,25 @@ export default ${expr[1]}`;
12572
12572
  }
12573
12573
  }
12574
12574
  }
12575
- let needsReturn = !isConstructor && !sideEffectOnly && isLast && !noRetStmts.includes(h) && !loopStmts.includes(h) && !this.hasExplicitControlFlow(stmt);
12575
+ if (!isConstructor && !sideEffectOnly && isLast && loopStmts.includes(h)) {
12576
+ if (this.containsYield(stmt)) {
12577
+ code += this.indent() + this.addSemicolon(stmt, this.emit(stmt, "statement")) + `
12578
+ `;
12579
+ return;
12580
+ }
12581
+ code += this.indent() + `const _result = [];
12582
+ `;
12583
+ this.comprehensionTarget = "_result";
12584
+ let saved = this._skipCompTargetInit;
12585
+ this._skipCompTargetInit = true;
12586
+ code += this.emit(stmt, "value");
12587
+ this._skipCompTargetInit = saved;
12588
+ this.comprehensionTarget = null;
12589
+ code += this.indent() + `return _result;
12590
+ `;
12591
+ return;
12592
+ }
12593
+ let needsReturn = !isConstructor && !sideEffectOnly && isLast && !noRetStmts.includes(h) && !this.hasExplicitControlFlow(stmt);
12576
12594
  let ctx = needsReturn ? "value" : "statement";
12577
12595
  let sc = this.emit(stmt, ctx);
12578
12596
  if (needsReturn)
@@ -12698,9 +12716,41 @@ ${this.indent()}}`;
12698
12716
  }
12699
12717
  emitComprehensionWithTarget(expr, iterators, guards, targetVar) {
12700
12718
  let code = "";
12701
- code += this.indent() + `${targetVar} = [];
12719
+ if (!this._skipCompTargetInit)
12720
+ code += this.indent() + `${targetVar} = [];
12721
+ `;
12722
+ let hasCtrl = (node) => {
12723
+ if (typeof node === "string" && (node === "break" || node === "continue"))
12724
+ return true;
12725
+ if (!Array.isArray(node))
12726
+ return false;
12727
+ if (["break", "continue", "return", "throw"].includes(node[0]))
12728
+ return true;
12729
+ if (node[0] === "if")
12730
+ return node.slice(1).some(hasCtrl);
12731
+ return node.some(hasCtrl);
12732
+ };
12733
+ let emitBody = () => {
12734
+ let loopTypes = ["for-in", "for-of", "for-as", "while", "loop"];
12735
+ if (this.is(expr, "block")) {
12736
+ for (let i = 0;i < expr.length - 1; i++) {
12737
+ let s = expr[i + 1], isLast = i === expr.length - 2;
12738
+ if (!isLast || hasCtrl(s) || Array.isArray(s) && loopTypes.includes(s[0])) {
12739
+ code += this.indent() + this.emit(s, "statement") + `;
12740
+ `;
12741
+ } else {
12742
+ code += this.indent() + `${targetVar}.push(${this.emit(s, "value")});
12743
+ `;
12744
+ }
12745
+ }
12746
+ } else if (hasCtrl(expr)) {
12747
+ code += this.indent() + this.emit(expr, "statement") + `;
12748
+ `;
12749
+ } else {
12750
+ code += this.indent() + `${targetVar}.push(${this.emit(expr, "value")});
12702
12751
  `;
12703
- let unwrappedExpr = this.is(expr, "block") && expr.length === 2 ? expr[1] : expr;
12752
+ }
12753
+ };
12704
12754
  if (iterators.length === 1) {
12705
12755
  let [iterType, vars, iterable, stepOrOwn] = iterators[0];
12706
12756
  if (iterType === "for-in") {
@@ -12711,14 +12761,61 @@ ${this.indent()}}`;
12711
12761
  if (setup)
12712
12762
  code += this.indent() + setup + `
12713
12763
  `;
12714
- if (guards && guards.length > 0) {
12764
+ if (guards?.length > 0) {
12765
+ code += this.indent() + `if (${guards.map((g) => this.emit(g, "value")).join(" && ")}) {
12766
+ `;
12767
+ this.indentLevel++;
12768
+ }
12769
+ emitBody();
12770
+ if (guards?.length > 0) {
12771
+ this.indentLevel--;
12772
+ code += this.indent() + `}
12773
+ `;
12774
+ }
12775
+ this.indentLevel--;
12776
+ code += this.indent() + `}
12777
+ `;
12778
+ return code;
12779
+ }
12780
+ if (iterType === "for-of") {
12781
+ let { header, own, vv, oc, kvp } = this._forOfHeader(vars, iterable, stepOrOwn);
12782
+ code += this.indent() + header + ` {
12783
+ `;
12784
+ this.indentLevel++;
12785
+ if (own)
12786
+ code += this.indent() + `if (!Object.hasOwn(${oc}, ${kvp})) continue;
12787
+ `;
12788
+ if (vv)
12789
+ code += this.indent() + `${vv} = ${oc}[${kvp}];
12790
+ `;
12791
+ if (guards?.length > 0) {
12715
12792
  code += this.indent() + `if (${guards.map((g) => this.emit(g, "value")).join(" && ")}) {
12716
12793
  `;
12717
12794
  this.indentLevel++;
12718
12795
  }
12719
- code += this.indent() + `${targetVar}.push(${this.unwrap(this.emit(unwrappedExpr, "value"))});
12796
+ emitBody();
12797
+ if (guards?.length > 0) {
12798
+ this.indentLevel--;
12799
+ code += this.indent() + `}
12800
+ `;
12801
+ }
12802
+ this.indentLevel--;
12803
+ code += this.indent() + `}
12720
12804
  `;
12721
- if (guards && guards.length > 0) {
12805
+ return code;
12806
+ }
12807
+ if (iterType === "for-as") {
12808
+ let { header } = this._forAsHeader(vars, iterable, stepOrOwn);
12809
+ code += this.indent() + header + ` {
12810
+ `;
12811
+ this.indentLevel++;
12812
+ if (guards?.length > 0) {
12813
+ code += this.indent() + `if (${guards.map((g) => this.emit(g, "value")).join(" && ")}) {
12814
+ `;
12815
+ this.indentLevel++;
12816
+ }
12817
+ emitBody();
12818
+ if (guards?.length > 0) {
12722
12819
  this.indentLevel--;
12723
12820
  code += this.indent() + `}
12724
12821
  `;
@@ -12729,8 +12826,10 @@ ${this.indent()}}`;
12729
12826
  return code;
12730
12827
  }
12731
12828
  }
12732
- return this.indent() + `${targetVar} = (() => { /* complex comprehension */ })();
12829
+ code = "";
12830
+ code += this.indent() + `${targetVar} = ${this.emit(["comprehension", expr, iterators, guards || []], "value")};
12733
12831
  `;
12832
+ return code;
12734
12833
  }
12735
12834
  emitComprehensionAsLoop(expr, iterators, guards) {
12736
12835
  let code = "";
@@ -13835,8 +13934,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
13835
13934
  return new CodeEmitter({}).getComponentRuntime();
13836
13935
  }
13837
13936
  // src/browser.js
13838
- var VERSION = "3.14.2";
13839
- var BUILD_DATE = "2026-04-23@15:43:24GMT";
13937
+ var VERSION = "3.14.4";
13938
+ var BUILD_DATE = "2026-04-23@16:29:21GMT";
13840
13939
  if (typeof globalThis !== "undefined") {
13841
13940
  if (!globalThis.__rip)
13842
13941
  new Function(getReactiveRuntime())();
@@ -14715,9 +14814,11 @@ ${indented}`);
14715
14814
  compiled = new Map;
14716
14815
  notify = function(event, path) {
14717
14816
  let watcher;
14817
+ const _result = [];
14718
14818
  for (watcher of watchers) {
14719
- watcher(event, path);
14819
+ _result.push(watcher(event, path));
14720
14820
  }
14821
+ return _result;
14721
14822
  };
14722
14823
  return { read: function(path) {
14723
14824
  return files.get(path);
@@ -14759,10 +14860,12 @@ ${indented}`);
14759
14860
  return result;
14760
14861
  }, load: function(obj) {
14761
14862
  let content, key;
14863
+ const _result = [];
14762
14864
  for (key in obj) {
14763
14865
  content = obj[key];
14764
- files.set(key, content);
14866
+ _result.push(files.set(key, content));
14765
14867
  }
14868
+ return _result;
14766
14869
  }, watch: function(fn) {
14767
14870
  watchers.push(fn);
14768
14871
  return function() {
@@ -15432,11 +15535,13 @@ ${indented}`);
15432
15535
  });
15433
15536
  es.addEventListener("css", function() {
15434
15537
  let link;
15538
+ const _result = [];
15435
15539
  for (link of document.querySelectorAll('link[rel="stylesheet"]')) {
15436
15540
  url = new URL(link.href);
15437
15541
  url.searchParams.set("_t", Date.now());
15438
15542
  link.href = url.toString();
15439
15543
  }
15544
+ return _result;
15440
15545
  });
15441
15546
  return es.onerror = function() {
15442
15547
  es.close();