|
|
@ -8,7 +8,7 @@ import { join } from 'path'; |
|
|
|
|
|
|
|
|
// DO NOT RUN THIS IN ANY PRODUCTION ENVIRONMENT EVER
|
|
|
// DO NOT RUN THIS IN ANY PRODUCTION ENVIRONMENT EVER
|
|
|
const server = createServer((req, res) => { |
|
|
const server = createServer((req, res) => { |
|
|
console.log(`reuqest? ${req.url}`); |
|
|
|
|
|
|
|
|
console.log(`get ${req.url}`); |
|
|
if (req.url === '/') { |
|
|
if (req.url === '/') { |
|
|
// https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Loading_and_running
|
|
|
// https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Loading_and_running
|
|
|
// If your browser doesn't support fetch... HAHA GET FUCKED
|
|
|
// If your browser doesn't support fetch... HAHA GET FUCKED
|
|
|
@ -22,40 +22,41 @@ const server = createServer((req, res) => { |
|
|
<head> |
|
|
<head> |
|
|
<title>eden-cli</title> |
|
|
<title>eden-cli</title> |
|
|
</head> |
|
|
</head> |
|
|
<body style="margin:0;padding:0;background-color:black;font-family:Monospace,Tahoma,Arial;"> |
|
|
|
|
|
|
|
|
<body style="margin:0;padding:0;background-color:black;font-family:Monospace,Tahoma,Arial;width:100%;height:100%;"> |
|
|
|
|
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:2px;width:100%;height:100%;"> |
|
|
|
|
|
<canvas id="canvas" oncontextmenu="event.preventDefault()" style="width:100%;height:100%;background-color:gray;"></canvas> |
|
|
|
|
|
<div id="tty-stdout"></div> |
|
|
|
|
|
</div> |
|
|
<script> |
|
|
<script> |
|
|
var Module = { //do not prepend var
|
|
|
var Module = { //do not prepend var
|
|
|
mainScriptUrlOrBlob: 'eden-cli.js', |
|
|
mainScriptUrlOrBlob: 'eden-cli.js', |
|
|
|
|
|
arguments: ['--null-render', '-F', '*:Trace', 'game.nro'], |
|
|
|
|
|
canvas: document.getElementById('canvas'), |
|
|
print: (e) => { |
|
|
print: (e) => { |
|
|
e = e.replace('[1;31m', '<span style="color:red;font-weight:bold;">'); |
|
|
e = e.replace('[1;31m', '<span style="color:red;font-weight:bold;">'); |
|
|
e = e.replace('[0;37m', '<span style="color:white;font-weight:bold;">'); |
|
|
e = e.replace('[0;37m', '<span style="color:white;font-weight:bold;">'); |
|
|
e = e.replace('[1;35m', '<span style="color:pink;font-weight:bold;">'); |
|
|
e = e.replace('[1;35m', '<span style="color:pink;font-weight:bold;">'); |
|
|
e = e.replace('[1;33m', '<span style="color:yellow;font-weight:bold;">'); |
|
|
e = e.replace('[1;33m', '<span style="color:yellow;font-weight:bold;">'); |
|
|
e = e.replace('[0m', '</span>'); |
|
|
e = e.replace('[0m', '</span>'); |
|
|
tty_stdout.innerHTML += \`\${e}</br>\`;
|
|
|
|
|
|
|
|
|
document.getElementById('tty-stdout').innerHTML += \`\${e}</br>\`;
|
|
|
}, |
|
|
}, |
|
|
printErr: (e) => { |
|
|
printErr: (e) => { |
|
|
tty_stdout.innerHTML += \`<span style="color:red">\${e}</span></br>\`;
|
|
|
|
|
|
|
|
|
document.getElementById('tty-stdout').innerHTML += \`<span style="color:red">\${e}</span></br>\`;
|
|
|
}, |
|
|
}, |
|
|
// not a wasm func but idc
|
|
|
// not a wasm func but idc
|
|
|
printInternal: (e) => { |
|
|
printInternal: (e) => { |
|
|
tty_stdout.innerHTML += \`<span style="color:pink">Internal WASM: \${e}</span></br>\`;
|
|
|
|
|
|
|
|
|
document.getElementById('tty-stdout').innerHTML += \`<span style="color:white">Internal WASM: \${e}</span></br>\`;
|
|
|
}, |
|
|
}, |
|
|
onRuntimeInitialized: () => { Module.printInternal("runtime ok"); }, |
|
|
onRuntimeInitialized: () => { Module.printInternal("runtime ok"); }, |
|
|
setStatus: (e) => { Module.printInternal(e); }, |
|
|
setStatus: (e) => { Module.printInternal(e); }, |
|
|
monitorRunDependencies: (e) => { Module.printInternal("monitor deps: " + e); }, |
|
|
monitorRunDependencies: (e) => { Module.printInternal("monitor deps: " + e); }, |
|
|
__wasm_call_ctors: () => { Module.printInternal("ctors beep"); }, |
|
|
__wasm_call_ctors: () => { Module.printInternal("ctors beep"); }, |
|
|
}; |
|
|
}; |
|
|
var tty_stdout = document.createElement('div'); |
|
|
|
|
|
document.body.appendChild(tty_stdout); |
|
|
|
|
|
Module.arguments = ['--null-render', 'game.nro']; |
|
|
|
|
|
|
|
|
|
|
|
var gameNroFileBuffer = {}; |
|
|
var gameNroFileBuffer = {}; |
|
|
|
|
|
|
|
|
Module.printInternal("Atomics: " + window.Atomics); |
|
|
|
|
|
Module.printInternal("SharedArrayBuffer: " + window.SharedArrayBuffer); |
|
|
|
|
|
|
|
|
Module.printInternal(\`Atomics: \${window.Atomics}, SharedArrayBuffer: \${window.SharedArrayBuffer}\`);
|
|
|
Module.printInternal("trying to load script (if it hangs here check console)"); |
|
|
Module.printInternal("trying to load script (if it hangs here check console)"); |
|
|
|
|
|
|
|
|
fetch('game.nro').then((resp) => { |
|
|
fetch('game.nro').then((resp) => { |
|
|
if (!resp.ok) |
|
|
if (!resp.ok) |
|
|
throw Error(\`\${resp.status}\`);
|
|
|
throw Error(\`\${resp.status}\`);
|
|
|
@ -65,7 +66,7 @@ fetch('game.nro').then((resp) => { |
|
|
Module.printInternal("buffer: " + gameNroFileBuffer); |
|
|
Module.printInternal("buffer: " + gameNroFileBuffer); |
|
|
|
|
|
|
|
|
// load the thingy AFTER loading the nro
|
|
|
// load the thingy AFTER loading the nro
|
|
|
Module.printInternal(\`loading from ${build_dir}\${Module.mainScriptUrlOrBlob}\`);
|
|
|
|
|
|
|
|
|
Module.printInternal(\`loading from ${build_dir}/\${Module.mainScriptUrlOrBlob}\`);
|
|
|
var script = document.createElement('script'); |
|
|
var script = document.createElement('script'); |
|
|
script.src = '/eden-cli.js'; |
|
|
script.src = '/eden-cli.js'; |
|
|
script.onload = () => { |
|
|
script.onload = () => { |
|
|
|