neutronium 3.0.0 → 3.0.2

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.
@@ -92,6 +92,45 @@ async function compileProject(projectDir = process.cwd()) {
92
92
  }
93
93
  }
94
94
 
95
+ async function compileAndReturnOutput(code) {
96
+ try {
97
+ log('📁 Scanning project files...');
98
+ log(`⚙️ Babel transforming`);
99
+
100
+ code = babel.transformSync(code, {
101
+ babelrc: false,
102
+ configFile: false,
103
+ presets: [],
104
+ plugins: [[
105
+ '@babel/plugin-transform-react-jsx',
106
+ {
107
+ pragma: '_neutronium.h',
108
+ pragmaFrag: '_neutronium.Fragment',
109
+ runtime: 'classic',
110
+ }
111
+ ]]
112
+ });
113
+ code = code.code
114
+ // Ensure _neutronium is imported
115
+ if (!code.includes('_neutronium')) {
116
+ code = `import * as _neutronium from 'https://esm.sh/neutronium@3.0.2/es2022/neutronium.mjs`;
117
+ }
118
+
119
+ // Replace imports to "neutronium" with local path
120
+ code = code.replace(/from\s+['"]neutronium['"]/g, `from '${neutroniumPath.replace(/\\/g, '/')}'`);
121
+
122
+ console.log('🛠️ Generating index.html...');
123
+ const htmlContent = baseHtml(code);
124
+
125
+
126
+ log('✅ Compilation complete!');
127
+ return htmlContent;
128
+ } catch (e) {
129
+ console.error('❌ Compilation failed:', e.message);
130
+ return false;
131
+ }
132
+ }
133
+
95
134
  function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
96
135
  const server = serveProject(projectDir, port);
97
136
  compileProject(projectDir);
@@ -245,4 +284,5 @@ module.exports = {
245
284
  compileProject,
246
285
  compileProjectWatch,
247
286
  serveProject,
287
+ compileAndReturnOutput
248
288
  };
@@ -1,4 +1,4 @@
1
- function baseHtml(appHtml, scriptName) {
1
+ function baseHtml(script) {
2
2
  return `
3
3
  <!DOCTYPE html>
4
4
  <html>
@@ -7,8 +7,7 @@ function baseHtml(appHtml, scriptName) {
7
7
  <title>Neutronium App</title>
8
8
  </head>
9
9
  <body>
10
- ${appHtml}
11
- <script type="module" src="./${scriptName}"></script>
10
+ ${script}
12
11
  <script>
13
12
  const ws = new WebSocket('ws://' + location.host);
14
13
  ws.onmessage = (msg) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutronium",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Ultra-dense JavaScript framework – maximum performance, minimal overhead",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -10,7 +10,7 @@
10
10
  ".": "./src/index.js"
11
11
  },
12
12
  "bin": {
13
- "neu-cli": "./cli/index.js"
13
+ "neu-cli": "cli/index.js"
14
14
  },
15
15
  "keywords": [
16
16
  "framework",