rip-lang 2.9.2 → 3.0.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": "2.9.2",
3
+ "version": "3.0.0",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/browser.js CHANGED
@@ -23,25 +23,16 @@ async function processRipScripts() {
23
23
  const scripts = document.querySelectorAll('script[type="text/rip"]');
24
24
 
25
25
  for (const script of scripts) {
26
- // Skip if already processed
27
- if (script.hasAttribute('data-rip-processed')) {
28
- continue;
29
- }
26
+ if (script.hasAttribute('data-rip-processed')) continue;
30
27
 
31
28
  try {
32
- // Get script content and remove HTML indentation
33
29
  const ripCode = dedent(script.textContent);
34
-
35
- // Compile to JavaScript
36
30
  const jsCode = compileToJS(ripCode);
37
31
 
38
32
  // Execute in global scope using indirect eval
39
- // This makes functions available as global variables
40
33
  (0, eval)(jsCode);
41
34
 
42
- // Mark as processed
43
35
  script.setAttribute('data-rip-processed', 'true');
44
-
45
36
  } catch (error) {
46
37
  console.error('Error compiling Rip script:', error);
47
38
  console.error('Script content:', script.textContent);
@@ -54,12 +45,10 @@ if (typeof document !== 'undefined') {
54
45
  if (document.readyState === 'loading') {
55
46
  document.addEventListener('DOMContentLoaded', processRipScripts);
56
47
  } else {
57
- // DOM already loaded, process immediately
58
48
  processRipScripts();
59
49
  }
60
50
  }
61
51
 
62
- // Export for manual processing if needed
63
52
  export { processRipScripts };
64
53
 
65
54
  /**
@@ -70,19 +59,13 @@ export function rip(code) {
70
59
  try {
71
60
  const js = compileToJS(code);
72
61
 
73
- // For browser console, strip ALL let/const declarations
74
- // Variables will be created as implicit globals
62
+ // Strip let/const declarations so variables become implicit globals
75
63
  let persistentJs = js.replace(/^let\s+[^;]+;\s*\n\s*/m, '');
76
64
  persistentJs = persistentJs.replace(/^const\s+/gm, 'var ');
77
65
 
78
- // Evaluate in global scope - variables become properties of globalThis
79
66
  const result = (1, eval)(persistentJs);
80
67
 
81
- // Store in global _ for convenience
82
- if (result !== undefined) {
83
- globalThis._ = result;
84
- }
85
-
68
+ if (result !== undefined) globalThis._ = result;
86
69
  return result;
87
70
  } catch (error) {
88
71
  console.error('Rip compilation error:', error.message);