rip-lang 3.12.5 → 3.13.1
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 +1 -1
- package/docs/dist/rip.min.js +120 -106
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/app.rip +4 -1
- package/src/compiler.js +27 -2
- package/src/repl.js +4 -1
package/docs/dist/rip.min.js.br
CHANGED
|
Binary file
|
package/package.json
CHANGED
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
|
-
|
|
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,15 @@ export class CodeGenerator {
|
|
|
637
637
|
let skip = this.options.skipPreamble;
|
|
638
638
|
|
|
639
639
|
if (!skip) {
|
|
640
|
-
|
|
641
|
-
|
|
640
|
+
|
|
641
|
+
// Standard library — always available, override by redeclaring
|
|
642
|
+
if (needsBlank) code += '\n';
|
|
643
|
+
code += getStdlibCode();
|
|
644
|
+
needsBlank = true;
|
|
645
|
+
|
|
646
|
+
// On-demand helpers — only emitted when referenced
|
|
647
|
+
if (this.helpers.has('slice' )) { code += 'const slice = [].slice;\n'; needsBlank = true; }
|
|
648
|
+
if (this.helpers.has('modulo' )) { code += 'const modulo = (n, d) => { n = +n; d = +d; return (n % d + d) % d; };\n'; needsBlank = true; }
|
|
642
649
|
if (this.helpers.has('toMatchable')) {
|
|
643
650
|
code += 'const toMatchable = (v, allowNewlines) => {\n';
|
|
644
651
|
code += ' if (typeof v === "string") return !allowNewlines && /[\\n\\r]/.test(v) ? null : v;\n';
|
|
@@ -3268,6 +3275,24 @@ export function generate(sexpr, options = {}) {
|
|
|
3268
3275
|
return new CodeGenerator(options).compile(sexpr);
|
|
3269
3276
|
}
|
|
3270
3277
|
|
|
3278
|
+
export function getStdlibCode() {
|
|
3279
|
+
return `\
|
|
3280
|
+
globalThis.abort ??= (msg) => { if (msg) console.error(msg); process.exit(1); };
|
|
3281
|
+
globalThis.assert ??= (v, msg) => { if (!v) throw new Error(msg || "Assertion failed"); };
|
|
3282
|
+
globalThis.exit ??= (code) => process.exit(code || 0);
|
|
3283
|
+
globalThis.kind ??= (v) => v != null ? (v.constructor?.name || Object.prototype.toString.call(v).slice(8, -1)).toLowerCase() : String(v);
|
|
3284
|
+
globalThis.noop ??= () => {};
|
|
3285
|
+
globalThis.p ??= console.log;
|
|
3286
|
+
globalThis.pp ??= (v) => { console.log(JSON.stringify(v, null, 2)); return v; };
|
|
3287
|
+
globalThis.raise ??= (a, b) => { throw (b !== undefined ? new a(b) : new Error(a)); };
|
|
3288
|
+
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();
|
|
3289
|
+
globalThis.sleep ??= (ms) => new Promise(r => setTimeout(r, ms));
|
|
3290
|
+
globalThis.todo ??= (msg) => { throw new Error(msg || "Not implemented"); };
|
|
3291
|
+
globalThis.warn ??= console.warn;
|
|
3292
|
+
globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
3293
|
+
`;
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3271
3296
|
export function getReactiveRuntime() {
|
|
3272
3297
|
return new CodeGenerator({}).getReactiveRuntime();
|
|
3273
3298
|
}
|
package/src/repl.js
CHANGED
|
@@ -17,7 +17,7 @@ import * as fs from 'fs';
|
|
|
17
17
|
import * as path from 'path';
|
|
18
18
|
import * as os from 'os';
|
|
19
19
|
import * as vm from 'vm';
|
|
20
|
-
import { Compiler, compileToJS, getReactiveRuntime, getComponentRuntime } from './compiler.js';
|
|
20
|
+
import { Compiler, compileToJS, getStdlibCode, getReactiveRuntime, getComponentRuntime } from './compiler.js';
|
|
21
21
|
import packageJson from '../package.json' with { type: 'json' };
|
|
22
22
|
|
|
23
23
|
const VERSION = packageJson.version;
|
|
@@ -65,6 +65,9 @@ export class RipREPL {
|
|
|
65
65
|
__vars: this.vars // Reference to persisted variables
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
// Inject standard library into REPL context
|
|
69
|
+
vm.runInContext(getStdlibCode(), this.vmContext);
|
|
70
|
+
|
|
68
71
|
// Inject reactive and component runtimes
|
|
69
72
|
this.injectReactiveRuntime();
|
|
70
73
|
this.injectComponentRuntime();
|