rip-lang 1.1.2 → 1.1.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/docs/dist/rip.browser.js
CHANGED
|
@@ -6772,8 +6772,8 @@ function compileToJS(source, options = {}) {
|
|
|
6772
6772
|
return compiler.compileToJS(source);
|
|
6773
6773
|
}
|
|
6774
6774
|
// src/browser.js
|
|
6775
|
-
var VERSION = "1.1.
|
|
6776
|
-
var BUILD_DATE = "2025-11-02@20:
|
|
6775
|
+
var VERSION = "1.1.3";
|
|
6776
|
+
var BUILD_DATE = "2025-11-02@20:15:22GMT";
|
|
6777
6777
|
var dedent = (s) => {
|
|
6778
6778
|
const m = s.match(/^[ \t]*(?=\S)/gm);
|
|
6779
6779
|
const i = Math.min(...(m || []).map((x) => x.length));
|
|
@@ -241,4 +241,4 @@ _setDataSection();
|
|
|
241
241
|
function _setDataSection() {
|
|
242
242
|
DATA = ${JSON.stringify(U)};
|
|
243
243
|
}`;F.push(J),R=F.join(`
|
|
244
|
-
`)}return{tokens:_,sexpr:A,code:R,data:U}}compileToJS(D){return this.compile(D).code}compileToSExpr(D){return this.compile(D).sexpr}}function o2(D,U={}){return new N1(U).compile(D)}function K1(D,U={}){return new N1(U).compileToJS(D)}var G3="1.1.
|
|
244
|
+
`)}return{tokens:_,sexpr:A,code:R,data:U}}compileToJS(D){return this.compile(D).code}compileToSExpr(D){return this.compile(D).sexpr}}function o2(D,U={}){return new N1(U).compile(D)}function K1(D,U={}){return new N1(U).compileToJS(D)}var G3="1.1.3",Z3="2025-11-02@20:15:22GMT",t2=(D)=>{let U=D.match(/^[ \t]*(?=\S)/gm),Y=Math.min(...(U||[]).map((E)=>E.length));return D.replace(RegExp(`^[ ]{${Y}}`,"gm"),"").trim()};async function v2(){let D=document.querySelectorAll('script[type="text/rip"]');for(let U of D){if(U.hasAttribute("data-rip-processed"))continue;try{let Y=t2(U.textContent),E=K1(Y);(0,eval)(E),U.setAttribute("data-rip-processed","true")}catch(Y){console.error("Error compiling Rip script:",Y),console.error("Script content:",U.textContent)}}}if(typeof document!=="undefined")if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",v2);else v2();function e2(D){try{let Y=K1(D).replace(/^let\s+[^;]+;\s*\n\s*/m,"");Y=Y.replace(/^const\s+/gm,"var ");let E=(0,eval)(Y);if(E!==void 0)globalThis._=E;return E}catch(U){console.error("Rip compilation error:",U.message);return}}if(typeof globalThis!=="undefined")globalThis.rip=e2;export{e2 as rip,v2 as processRipScripts,A1 as parser,_1 as formatSExpr,K1 as compileToJS,o2 as compile,G3 as VERSION,x1 as Lexer,N1 as Compiler,R1 as CodeGenerator,Z3 as BUILD_DATE};
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rip-lang",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A lightweight scripting language that compiles to modern JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/compiler.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"bin/",
|
|
22
22
|
"src/",
|
|
23
23
|
"docs/",
|
|
24
|
+
"scripts/serve.js",
|
|
24
25
|
"rip-loader.ts",
|
|
25
26
|
"README.md",
|
|
26
27
|
"LICENSE",
|
package/scripts/serve.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// Simple static file server with brotli support
|
|
3
|
+
import { readFileSync, existsSync } from 'fs';
|
|
4
|
+
import { join, extname, dirname } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
// Get the directory where this script lives
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
|
|
11
|
+
// Serve from docs/ relative to script location (works when globally installed)
|
|
12
|
+
const ROOT = process.env.SERVE_DIR || join(__dirname, '../docs');
|
|
13
|
+
// Try port 3000 first, fallback to 0 (OS-assigned)
|
|
14
|
+
const PORT = process.env.PORT || 3000;
|
|
15
|
+
|
|
16
|
+
const MIME_TYPES = {
|
|
17
|
+
'.html': 'text/html; charset=utf-8',
|
|
18
|
+
'.js': 'application/javascript; charset=utf-8',
|
|
19
|
+
'.css': 'text/css; charset=utf-8',
|
|
20
|
+
'.json': 'application/json',
|
|
21
|
+
'.png': 'image/png',
|
|
22
|
+
'.jpg': 'image/jpeg',
|
|
23
|
+
'.svg': 'image/svg+xml',
|
|
24
|
+
'.ico': 'image/x-icon'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Request handler for serving files
|
|
28
|
+
function handleRequest(req) {
|
|
29
|
+
const url = new URL(req.url);
|
|
30
|
+
let pathname = url.pathname;
|
|
31
|
+
|
|
32
|
+
// Default to index.html for directory requests
|
|
33
|
+
if (pathname.endsWith('/')) {
|
|
34
|
+
pathname += 'index.html';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const filePath = join(ROOT, pathname);
|
|
38
|
+
const ext = extname(pathname);
|
|
39
|
+
const acceptEncoding = req.headers.get('accept-encoding') || '';
|
|
40
|
+
|
|
41
|
+
// Check for brotli compressed version (.br)
|
|
42
|
+
if (acceptEncoding.includes('br') && existsSync(filePath + '.br')) {
|
|
43
|
+
try {
|
|
44
|
+
const compressed = readFileSync(filePath + '.br');
|
|
45
|
+
return new Response(compressed, {
|
|
46
|
+
headers: {
|
|
47
|
+
'Content-Type': MIME_TYPES[ext] || 'application/octet-stream',
|
|
48
|
+
'Content-Encoding': 'br',
|
|
49
|
+
'Cache-Control': 'public, max-age=31536000'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
} catch (e) {
|
|
53
|
+
// Fall through to regular file
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Serve regular file
|
|
58
|
+
try {
|
|
59
|
+
const file = readFileSync(filePath);
|
|
60
|
+
return new Response(file, {
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': MIME_TYPES[ext] || 'application/octet-stream'
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return new Response('404 Not Found', { status: 404 });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Try to start server on preferred port, fallback to OS-assigned port
|
|
71
|
+
let server;
|
|
72
|
+
try {
|
|
73
|
+
server = Bun.serve({ port: PORT, fetch: handleRequest });
|
|
74
|
+
} catch (err) {
|
|
75
|
+
if (err.code === 'EADDRINUSE') {
|
|
76
|
+
// Port in use, let OS assign one
|
|
77
|
+
server = Bun.serve({ port: 0, fetch: handleRequest });
|
|
78
|
+
} else {
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const actualPort = server.port;
|
|
84
|
+
|
|
85
|
+
console.log(`🚀 Server running at http://localhost:${actualPort}`);
|
|
86
|
+
console.log(`📁 Serving from: ${ROOT}/`);
|
|
87
|
+
console.log(`🗜️ Brotli compression: enabled`);
|
|
88
|
+
console.log('');
|
|
89
|
+
console.log(`✨ Rip REPL: http://localhost:${actualPort}/`);
|
|
90
|
+
console.log(`📚 Examples: http://localhost:${actualPort}/examples/`);
|