neutronium 3.0.9 → 3.1.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/compiler/template.js +17 -0
- package/package.json +1 -1
- package/sandbox.mjs +25 -22
package/compiler/template.js
CHANGED
|
@@ -22,4 +22,21 @@ function baseHtml(script) {
|
|
|
22
22
|
`.trim();
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function basehtml(script) {
|
|
26
|
+
return `
|
|
27
|
+
<!DOCTYPE html>
|
|
28
|
+
<html>
|
|
29
|
+
<head>
|
|
30
|
+
<meta charset="UTF-8">
|
|
31
|
+
<title>Neutronium App</title>
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<script>
|
|
35
|
+
${script}
|
|
36
|
+
</script>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
39
|
+
`.trim();
|
|
40
|
+
}
|
|
41
|
+
|
|
25
42
|
module.exports = { baseHtml };
|
package/package.json
CHANGED
package/sandbox.mjs
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import * as Babel from
|
|
2
|
-
import {
|
|
1
|
+
import * as Babel from "https://esm.sh/@babel/standalone@7.28.6/es2022/standalone.mjs";
|
|
2
|
+
import { basehtml } from "./compiler/template.js";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export function compileAndReturnOutput(source) {
|
|
5
5
|
try {
|
|
6
|
-
|
|
6
|
+
console.log("⚙️ Babel transforming");
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
const result = Babel.transform(source, {
|
|
9
|
+
plugins: [[
|
|
10
|
+
Babel.availablePlugins["transform-react-jsx"],
|
|
11
|
+
{
|
|
12
|
+
pragma: "_neutronium.h",
|
|
13
|
+
pragmaFrag: "_neutronium.Fragment",
|
|
14
|
+
runtime: "classic",
|
|
15
|
+
}
|
|
16
|
+
]]
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const compiledCode = `
|
|
20
|
+
import * as _neutronium from "neutronium";
|
|
21
|
+
${result.code}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
console.log("🛠️ Generating index.html...");
|
|
25
|
+
|
|
26
|
+
return basehtml(compiledCode);
|
|
22
27
|
|
|
23
|
-
console.log('✅ Compilation complete!');
|
|
24
|
-
return htmlContent;
|
|
25
28
|
} catch (e) {
|
|
26
|
-
console.error(
|
|
27
|
-
return
|
|
29
|
+
console.error("❌ Compilation failed:", e);
|
|
30
|
+
return null;
|
|
28
31
|
}
|
|
29
32
|
}
|