rip-lang 3.6.0 → 3.6.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
CHANGED
|
@@ -307,7 +307,7 @@ Simple arrays (with `.loc`) instead of AST node classes. The compiler is self-ho
|
|
|
307
307
|
| Grammar | `src/grammar/grammar.rip` | 935 |
|
|
308
308
|
| Parser Generator | `src/grammar/solar.rip` | 916 |
|
|
309
309
|
| REPL | `src/repl.js` | 707 |
|
|
310
|
-
| Browser Entry | `src/browser.js` |
|
|
310
|
+
| Browser Entry | `src/browser.js` | 119 |
|
|
311
311
|
| Tags | `src/tags.js` | 63 |
|
|
312
312
|
| **Total** | | **~10,325** |
|
|
313
313
|
|
package/docs/RIP-GUIDE.md
CHANGED
|
@@ -534,6 +534,57 @@ user.save!()
|
|
|
534
534
|
|
|
535
535
|
---
|
|
536
536
|
|
|
537
|
+
## Browser
|
|
538
|
+
|
|
539
|
+
Rip runs directly in the browser with full async/await support — no build step.
|
|
540
|
+
|
|
541
|
+
### Inline Scripts
|
|
542
|
+
|
|
543
|
+
Load the compiler, then write Rip:
|
|
544
|
+
|
|
545
|
+
```html
|
|
546
|
+
<script type="module" src="/rip/browser.js"></script>
|
|
547
|
+
<script type="text/rip">
|
|
548
|
+
res = fetch! 'https://api.example.com/data'
|
|
549
|
+
data = res.json!
|
|
550
|
+
console.log data
|
|
551
|
+
</script>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
The `!` operator works in inline scripts — `processRipScripts` wraps
|
|
555
|
+
compiled code in an async IIFE transparently.
|
|
556
|
+
|
|
557
|
+
### Console REPL
|
|
558
|
+
|
|
559
|
+
The `rip()` function is available in any browser console where `rip.browser.js`
|
|
560
|
+
is loaded:
|
|
561
|
+
|
|
562
|
+
```javascript
|
|
563
|
+
rip("42 * 10 + 8") // → 428
|
|
564
|
+
rip("name = 'Alice'") // → 'Alice' (persists on globalThis)
|
|
565
|
+
rip("(x * x for x in [1..5])") // → [1, 4, 9, 16, 25]
|
|
566
|
+
|
|
567
|
+
// Async — use await, Chrome displays the resolved value
|
|
568
|
+
await rip("res = fetch! 'https://jsonplaceholder.typicode.com/todos/1'; res.json!")
|
|
569
|
+
// → {userId: 1, id: 1, title: 'delectus aut autem', completed: false}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Sync code returns values directly. Async code (using `!`) returns a Promise
|
|
573
|
+
that Chrome auto-awaits. Variables persist between calls on `globalThis`.
|
|
574
|
+
|
|
575
|
+
### `importRip(url)`
|
|
576
|
+
|
|
577
|
+
Fetch, compile, and import a `.rip` file as an ES module:
|
|
578
|
+
|
|
579
|
+
```html
|
|
580
|
+
<script type="text/rip">
|
|
581
|
+
{ launch } = importRip! '/rip/ui.rip'
|
|
582
|
+
launch '/demo'
|
|
583
|
+
</script>
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
537
588
|
## Full-Stack Example
|
|
538
589
|
|
|
539
590
|
A complete API server in Rip:
|
package/docs/dist/rip.browser.js
CHANGED
|
@@ -7560,8 +7560,8 @@ function getComponentRuntime() {
|
|
|
7560
7560
|
return new CodeGenerator({}).getComponentRuntime();
|
|
7561
7561
|
}
|
|
7562
7562
|
// src/browser.js
|
|
7563
|
-
var VERSION = "3.6.
|
|
7564
|
-
var BUILD_DATE = "2026-02-
|
|
7563
|
+
var VERSION = "3.6.1";
|
|
7564
|
+
var BUILD_DATE = "2026-02-11@00:29:14GMT";
|
|
7565
7565
|
if (typeof globalThis !== "undefined" && !globalThis.__rip) {
|
|
7566
7566
|
new Function(getReactiveRuntime())();
|
|
7567
7567
|
}
|
|
@@ -525,7 +525,7 @@ if (typeof globalThis !== 'undefined') {
|
|
|
525
525
|
`:"",Y=U.slice(0,W).join(`
|
|
526
526
|
`)}let $=new v().tokenize(Y);if(this.options.showTokens)$.forEach((z)=>console.log(`${z[0].padEnd(12)} ${JSON.stringify(z[1])}`)),console.log();let Q=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)Q=Z1($);$=$.filter((z)=>z[0]!=="TYPE_DECL");while($.length>0&&$[0][0]==="TERMINATOR")$.shift();if($.every((z)=>z[0]==="TERMINATOR"))return{tokens:$,sexpr:["program"],code:"",dts:Q,data:F,reactiveVars:{}};g.lexer={tokens:$,pos:0,setInput:function(){},lex:function(){if(this.pos>=this.tokens.length)return 1;let z=this.tokens[this.pos++],R=z[1];if(z.data)R=new String(R),Object.assign(R,z.data);return this.text=R,this.loc=z.loc,z[0]}};let J;try{J=g.parse(Y)}catch(z){if(/\?\s*\([^)]*\?[^)]*:[^)]*\)\s*:/.test(Y)||/\?\s+\w+\s+\?\s+/.test(Y))throw Error("Nested ternary operators are not supported. Use if/else statements instead.");throw z}if(this.options.showSExpr)console.log(b(J,0,!0)),console.log();let Z=null;if(this.options.sourceMap){let z=(this.options.filename||"output")+".js",R=this.options.filename||"input.rip";Z=new Y1(z,R,Y)}let X=new V({dataSection:F,skipReactiveRuntime:this.options.skipReactiveRuntime,skipComponentRuntime:this.options.skipComponentRuntime,reactiveVars:this.options.reactiveVars,sourceMap:Z}),D=X.compile(J),K=Z?Z.toJSON():null,M=Z?Z.toReverseMap():null;if(K&&this.options.sourceMap==="inline"){let z=typeof Buffer<"u"?Buffer.from(K).toString("base64"):btoa(K);D+=`
|
|
527
527
|
//# sourceMappingURL=data:application/json;base64,${z}`}else if(K&&this.options.filename)D+=`
|
|
528
|
-
//# sourceMappingURL=${this.options.filename}.js.map`;return{tokens:$,sexpr:J,code:D,dts:Q,map:K,reverseMap:M,data:F,reactiveVars:X.reactiveVars}}compileToJS(Y){return this.compile(Y).code}compileToSExpr(Y){return this.compile(Y).sexpr}}T1(V);V.prototype.generateEnum=J1;function O2(Y,F={}){return new t(F).compile(Y)}function x(Y,F={}){return new t(F).compileToJS(Y)}function U1(){return new V({}).getReactiveRuntime()}function q2(){return new V({}).getComponentRuntime()}var g2="3.6.
|
|
528
|
+
//# sourceMappingURL=${this.options.filename}.js.map`;return{tokens:$,sexpr:J,code:D,dts:Q,map:K,reverseMap:M,data:F,reactiveVars:X.reactiveVars}}compileToJS(Y){return this.compile(Y).code}compileToSExpr(Y){return this.compile(Y).sexpr}}T1(V);V.prototype.generateEnum=J1;function O2(Y,F={}){return new t(F).compile(Y)}function x(Y,F={}){return new t(F).compileToJS(Y)}function U1(){return new V({}).getReactiveRuntime()}function q2(){return new V({}).getComponentRuntime()}var g2="3.6.1",k2="2026-02-11@00:29:14GMT";if(typeof globalThis<"u"&&!globalThis.__rip)Function(U1())();var P2=(Y)=>{let F=Y.match(/^[ \t]*(?=\S)/gm),U=Math.min(...(F||[]).map((W)=>W.length));return Y.replace(RegExp(`^[ ]{${U}}`,"gm"),"").trim()};async function N1(){let Y=document.querySelectorAll('script[type="text/rip"]');for(let F of Y){if(F.hasAttribute("data-rip-processed"))continue;try{let U=P2(F.textContent),W=x(U);await(0,eval)(`(async()=>{
|
|
529
529
|
${W}
|
|
530
530
|
})()`),F.setAttribute("data-rip-processed","true")}catch(U){console.error("Error compiling Rip script:",U),console.error("Script content:",F.textContent)}}}if(typeof document<"u")if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",N1);else N1();async function _2(Y){let F=await fetch(Y).then(($)=>{if(!$.ok)throw Error(`importRip: ${Y} (${$.status})`);return $.text()}),U=x(F),W=new Blob([U],{type:"application/javascript"}),A=URL.createObjectURL(W);try{return await import(A)}finally{URL.revokeObjectURL(A)}}function w2(Y){try{let F=Y.replace(/^/gm," "),W=x(`do ->
|
|
531
531
|
${F}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");W=W.replace(/^const\s+(\w+)\s*=/gm,"globalThis.$1 =");let A=(0,eval)(W);if(A&&typeof A.then==="function")return A.then(($)=>{if($!==void 0)globalThis._=$;return $});if(A!==void 0)globalThis._=A;return A}catch(F){console.error("Rip compilation error:",F.message);return}}if(typeof globalThis<"u")globalThis.rip=w2,globalThis.importRip=_2,globalThis.compileToJS=x;export{w2 as rip,N1 as processRipScripts,g as parser,_2 as importRip,U1 as getReactiveRuntime,q2 as getComponentRuntime,b as formatSExpr,x as compileToJS,O2 as compile,g2 as VERSION,v as Lexer,t as Compiler,V as CodeGenerator,k2 as BUILD_DATE};
|
|
Binary file
|