rip-lang 3.12.5 → 3.13.0

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.12.5",
3
+ "version": "3.13.0",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/app.rip CHANGED
@@ -661,6 +661,7 @@ export createRenderer = (opts = {}) ->
661
661
 
662
662
  currentComponent = null
663
663
  currentRoute = null
664
+ currentParams = null
664
665
  currentLayouts = []
665
666
  layoutInstances = []
666
667
  mountPoint = container
@@ -702,7 +703,9 @@ export createRenderer = (opts = {}) ->
702
703
  mountRoute = (info) ->
703
704
  { route, params, layouts: layoutFiles, query } = info
704
705
  return unless route
705
- return if route.file is currentRoute # already showing this route
706
+ if route.file is currentRoute and JSON.stringify(params) is JSON.stringify(currentParams)
707
+ return
708
+ currentParams = params
706
709
 
707
710
  gen = ++generation
708
711
  router.navigating = true
package/src/compiler.js CHANGED
@@ -637,8 +637,26 @@ export class CodeGenerator {
637
637
  let skip = this.options.skipPreamble;
638
638
 
639
639
  if (!skip) {
640
- if (this.helpers.has('slice')) { code += 'const slice = [].slice;\n'; needsBlank = true; }
641
- if (this.helpers.has('modulo')) { code += 'const modulo = (n, d) => { n = +n; d = +d; return (n % d + d) % d; };\n'; needsBlank = true; }
640
+
641
+ // Standard library always available, override by redeclaring
642
+ if (needsBlank) code += '\n';
643
+ code += 'globalThis.abort ??= (msg) => { if (msg) console.error(msg); process.exit(1); };\n';
644
+ code += 'globalThis.assert ??= (v, msg) => { if (!v) throw new Error(msg || "Assertion failed"); };\n';
645
+ code += 'globalThis.exit ??= (code) => process.exit(code || 0);\n';
646
+ code += 'globalThis.kind ??= (v) => v != null ? (v.constructor?.name || Object.prototype.toString.call(v).slice(8, -1)).toLowerCase() : String(v);\n';
647
+ code += 'globalThis.noop ??= () => {};\n';
648
+ code += 'globalThis.p ??= console.log;\n';
649
+ code += 'globalThis.pp ??= (v) => { console.log(JSON.stringify(v, null, 2)); return v; };\n';
650
+ code += 'globalThis.raise ??= (a, b) => { throw (b !== undefined ? new a(b) : new Error(a)); };\n';
651
+ code += 'globalThis.rand ??= (a, b) => b !== undefined ? (a > b && ([a, b] = [b, a]), Math.floor(Math.random() * (b - a + 1) + a)) : a ? Math.floor(Math.random() * a) : Math.random();\n';
652
+ code += 'globalThis.sleep ??= (ms) => new Promise(r => setTimeout(r, ms));\n';
653
+ code += 'globalThis.todo ??= (msg) => { throw new Error(msg || "Not implemented"); };\n';
654
+ code += 'globalThis.warn ??= console.warn;\n';
655
+ code += 'globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));\n';
656
+ needsBlank = true;
657
+
658
+ if (this.helpers.has('slice' )) { code += 'const slice = [].slice;\n'; needsBlank = true; }
659
+ if (this.helpers.has('modulo' )) { code += 'const modulo = (n, d) => { n = +n; d = +d; return (n % d + d) % d; };\n'; needsBlank = true; }
642
660
  if (this.helpers.has('toMatchable')) {
643
661
  code += 'const toMatchable = (v, allowNewlines) => {\n';
644
662
  code += ' if (typeof v === "string") return !allowNewlines && /[\\n\\r]/.test(v) ? null : v;\n';