rip-lang 3.4.2 → 3.4.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/bin/rip CHANGED
@@ -26,7 +26,7 @@ Usage:
26
26
  Options:
27
27
  -c, --compile Show compiled JavaScript output
28
28
  -d, --dts Generate .d.ts type declaration file
29
- -m, --map Generate .js.map source map file
29
+ -m, --map Embed inline source map in compiled output
30
30
  -h, --help Show this help message
31
31
  -o, --output <file> Write JavaScript to file
32
32
  -q, --quiet Suppress headers
@@ -47,7 +47,7 @@ Examples:
47
47
  rip -s -c example.rip # Show s-expressions AND JavaScript
48
48
  rip -s -t -c example.rip # Show everything (full debug mode)
49
49
  rip -d example.rip # Generate example.d.ts
50
- rip -m example.rip # Generate example.js.map
50
+ rip -m example.rip # Compile with inline source map
51
51
  rip -cd example.rip # Compile JS and generate .d.ts
52
52
  rip -q -c example.rip # Just the JS, no headers (for piping)
53
53
  rip -w # Launch browser REPL (auto-opens)
@@ -156,8 +156,7 @@ async function main() {
156
156
  showSExpr,
157
157
  quiet,
158
158
  types: generateDts ? 'emit' : undefined,
159
- sourceMap: generateMap ? true : undefined,
160
- filename: null, // set below after determining input file
159
+ sourceMap: generateMap ? 'inline' : undefined,
161
160
  };
162
161
 
163
162
  // Find input file and output file from ripOptions only
@@ -243,11 +242,6 @@ async function main() {
243
242
  source = readFileSync(inputFile, 'utf-8');
244
243
  }
245
244
 
246
- // Set filename for source map generation
247
- if (inputFile) {
248
- options.filename = inputFile.replace(/\.rip$/, '');
249
- }
250
-
251
245
  // Compile
252
246
  const compiler = new Compiler(options);
253
247
  const result = compiler.compile(source);
@@ -288,22 +282,6 @@ async function main() {
288
282
  }
289
283
  }
290
284
 
291
- // Write .js.map file
292
- if (generateMap && result.map) {
293
- if (inputFile) {
294
- let mapFile = inputFile.replace(/\.rip$/, '.js.map');
295
- writeFileSync(mapFile, result.map, 'utf-8');
296
- if (!options.quiet) {
297
- console.log(`Generated ${mapFile}`);
298
- }
299
- } else {
300
- // stdin — print source map to stdout
301
- if (!options.quiet) {
302
- console.log(`// == Source map == //\n`);
303
- }
304
- console.log(result.map);
305
- }
306
- }
307
285
  } catch (error) {
308
286
  console.error('Compilation Error:', error.message);
309
287
  if (error.stack) {
@@ -7505,8 +7505,9 @@ class Compiler {
7505
7505
  let map = sourceMap ? sourceMap.toJSON() : null;
7506
7506
  let reverseMap = sourceMap ? sourceMap.toReverseMap() : null;
7507
7507
  if (map && this.options.sourceMap === "inline") {
7508
+ let b64 = typeof Buffer !== "undefined" ? Buffer.from(map).toString("base64") : btoa(map);
7508
7509
  code += `
7509
- //# sourceMappingURL=data:application/json;base64,${btoa(map)}`;
7510
+ //# sourceMappingURL=data:application/json;base64,${b64}`;
7510
7511
  } else if (map && this.options.filename) {
7511
7512
  code += `
7512
7513
  //# sourceMappingURL=${this.options.filename}.js.map`;
@@ -7535,8 +7536,8 @@ function getComponentRuntime() {
7535
7536
  return new CodeGenerator({}).getComponentRuntime();
7536
7537
  }
7537
7538
  // src/browser.js
7538
- var VERSION = "3.4.2";
7539
- var BUILD_DATE = "2026-02-09@07:09:22GMT";
7539
+ var VERSION = "3.4.3";
7540
+ var BUILD_DATE = "2026-02-09@07:17:43GMT";
7540
7541
  var dedent = (s) => {
7541
7542
  const m = s.match(/^[ \t]*(?=\S)/gm);
7542
7543
  const i = Math.min(...(m || []).map((x) => x.length));
@@ -523,6 +523,6 @@ if (typeof globalThis !== 'undefined') {
523
523
  `),W=U.findIndex((R)=>R==="__DATA__");if(W!==-1){let R=U.slice(W+1);F=R.length>0?R.join(`
524
524
  `)+`
525
525
  `:"",Y=U.slice(0,W).join(`
526
- `)}let $=new v().tokenize(Y);if(this.options.showTokens)$.forEach((R)=>console.log(`${R[0].padEnd(12)} ${JSON.stringify(R[1])}`)),console.log();let Q=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)Q=Q1($);$=$.filter((R)=>R[0]!=="TYPE_DECL");while($.length>0&&$[0][0]==="TERMINATOR")$.shift();if($.every((R)=>R[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 R=this.tokens[this.pos++],M=R[1];if(R.data)M=new String(M),Object.assign(M,R.data);return this.text=M,this.loc=R.loc,R[0]}};let D;try{D=g.parse(Y)}catch(R){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 R}if(this.options.showSExpr)console.log(y(D,0,!0)),console.log();let Z=null;if(this.options.sourceMap){let R=(this.options.filename||"output")+".js",M=this.options.filename||"input.rip";Z=new Y1(R,M,Y)}let X=new V({dataSection:F,skipReactiveRuntime:this.options.skipReactiveRuntime,skipComponentRuntime:this.options.skipComponentRuntime,reactiveVars:this.options.reactiveVars,sourceMap:Z}),J=X.compile(D),K=Z?Z.toJSON():null,z=Z?Z.toReverseMap():null;if(K&&this.options.sourceMap==="inline")J+=`
527
- //# sourceMappingURL=data:application/json;base64,${btoa(K)}`;else if(K&&this.options.filename)J+=`
528
- //# sourceMappingURL=${this.options.filename}.js.map`;return{tokens:$,sexpr:D,code:J,dts:Q,map:K,reverseMap:z,data:F,reactiveVars:X.reactiveVars}}compileToJS(Y){return this.compile(Y).code}compileToSExpr(Y){return this.compile(Y).sexpr}}E1(V);V.prototype.generateEnum=Z1;function H2(Y,F={}){return new r(F).compile(Y)}function t(Y,F={}){return new r(F).compileToJS(Y)}function O2(){return new V({}).getReactiveRuntime()}function q2(){return new V({}).getComponentRuntime()}var v2="3.4.2",g2="2026-02-09@07:09:22GMT",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 T1(){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=t(U);(0,eval)(W),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",T1);else T1();function _2(Y){try{let U=t(Y).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+/gm,"var ");let W=(0,eval)(U);if(W!==void 0)globalThis._=W;return W}catch(F){console.error("Rip compilation error:",F.message);return}}if(typeof globalThis<"u")globalThis.rip=_2;export{_2 as rip,T1 as processRipScripts,g as parser,O2 as getReactiveRuntime,q2 as getComponentRuntime,y as formatSExpr,t as compileToJS,H2 as compile,v2 as VERSION,v as Lexer,r as Compiler,V as CodeGenerator,g2 as BUILD_DATE};
526
+ `)}let $=new v().tokenize(Y);if(this.options.showTokens)$.forEach((R)=>console.log(`${R[0].padEnd(12)} ${JSON.stringify(R[1])}`)),console.log();let Q=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)Q=Q1($);$=$.filter((R)=>R[0]!=="TYPE_DECL");while($.length>0&&$[0][0]==="TERMINATOR")$.shift();if($.every((R)=>R[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 R=this.tokens[this.pos++],M=R[1];if(R.data)M=new String(M),Object.assign(M,R.data);return this.text=M,this.loc=R.loc,R[0]}};let D;try{D=g.parse(Y)}catch(R){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 R}if(this.options.showSExpr)console.log(y(D,0,!0)),console.log();let Z=null;if(this.options.sourceMap){let R=(this.options.filename||"output")+".js",M=this.options.filename||"input.rip";Z=new Y1(R,M,Y)}let X=new V({dataSection:F,skipReactiveRuntime:this.options.skipReactiveRuntime,skipComponentRuntime:this.options.skipComponentRuntime,reactiveVars:this.options.reactiveVars,sourceMap:Z}),J=X.compile(D),K=Z?Z.toJSON():null,z=Z?Z.toReverseMap():null;if(K&&this.options.sourceMap==="inline"){let R=typeof Buffer<"u"?Buffer.from(K).toString("base64"):btoa(K);J+=`
527
+ //# sourceMappingURL=data:application/json;base64,${R}`}else if(K&&this.options.filename)J+=`
528
+ //# sourceMappingURL=${this.options.filename}.js.map`;return{tokens:$,sexpr:D,code:J,dts:Q,map:K,reverseMap:z,data:F,reactiveVars:X.reactiveVars}}compileToJS(Y){return this.compile(Y).code}compileToSExpr(Y){return this.compile(Y).sexpr}}E1(V);V.prototype.generateEnum=Z1;function H2(Y,F={}){return new r(F).compile(Y)}function t(Y,F={}){return new r(F).compileToJS(Y)}function O2(){return new V({}).getReactiveRuntime()}function q2(){return new V({}).getComponentRuntime()}var v2="3.4.3",g2="2026-02-09@07:17:43GMT",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 T1(){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=t(U);(0,eval)(W),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",T1);else T1();function _2(Y){try{let U=t(Y).replace(/^let\s+[^;]+;\s*\n\s*/m,"");U=U.replace(/^const\s+/gm,"var ");let W=(0,eval)(U);if(W!==void 0)globalThis._=W;return W}catch(F){console.error("Rip compilation error:",F.message);return}}if(typeof globalThis<"u")globalThis.rip=_2;export{_2 as rip,T1 as processRipScripts,g as parser,O2 as getReactiveRuntime,q2 as getComponentRuntime,y as formatSExpr,t as compileToJS,H2 as compile,v2 as VERSION,v as Lexer,r as Compiler,V as CodeGenerator,g2 as BUILD_DATE};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.4.2",
3
+ "version": "3.4.3",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/compiler.js CHANGED
@@ -3239,7 +3239,8 @@ export class Compiler {
3239
3239
  let map = sourceMap ? sourceMap.toJSON() : null;
3240
3240
  let reverseMap = sourceMap ? sourceMap.toReverseMap() : null;
3241
3241
  if (map && this.options.sourceMap === 'inline') {
3242
- code += `\n//# sourceMappingURL=data:application/json;base64,${btoa(map)}`;
3242
+ let b64 = typeof Buffer !== 'undefined' ? Buffer.from(map).toString('base64') : btoa(map);
3243
+ code += `\n//# sourceMappingURL=data:application/json;base64,${b64}`;
3243
3244
  } else if (map && this.options.filename) {
3244
3245
  code += `\n//# sourceMappingURL=${this.options.filename}.js.map`;
3245
3246
  }