Update playground
This commit is contained in:
2
node_modules/.mf/cf.json
generated
vendored
2
node_modules/.mf/cf.json
generated
vendored
@@ -1 +1 @@
|
|||||||
{"httpProtocol":"HTTP/1.1","clientAcceptEncoding":"gzip, deflate, br","requestPriority":"","edgeRequestKeepAliveStatus":1,"requestHeaderNames":{},"clientTcpRtt":12,"colo":"SYD","asn":9443,"asOrganization":"Vocus","country":"AU","isEUCountry":false,"city":"Sydney","continent":"OC","region":"New South Wales","regionCode":"NSW","timezone":"Australia/Sydney","longitude":"151.20732","latitude":"-33.86785","postalCode":"1001","tlsVersion":"TLSv1.3","tlsCipher":"AEAD-AES256-GCM-SHA384","tlsClientRandom":"ZCFOIxx+dLjJKWNa9xLCxaSIHvshEBi9p5Ma3GkbD6Y=","tlsClientCiphersSha1":"kXrN3VEKDdzz2cPKTQaKzpxVTxQ=","tlsClientExtensionsSha1":"1eY97BUYYO8vDaTfHQywB1pcNdM=","tlsClientExtensionsSha1Le":"u4wtEMFQBY18l3BzHAvORm+KGRw=","tlsExportedAuthenticator":{"clientHandshake":"60c7a93668cf712955e55da8d87ad7d798dd50f3bd0f41cf6b50bd536330370c8d70f3c724a783da997a7ce56eb10942","serverHandshake":"a1387243818dc978c8e6191d9435d288d47c82a4c87c3727ee318328e68412165a11e528abea944087ca1463ad1dfeb5","clientFinished":"3187fbfafb25128e53194b2cc610611991652337efdaf72c36409d98dfd12ca3a8a01c6a4b3bec6b601abdd178673f94","serverFinished":"f55737956343d6a2de3e75a6297677de63f979c2a570fc887651fd9b0fa24a9671b4545cdec6cfab6ecd70e39f6b1aea"},"tlsClientHelloLength":"1603","tlsClientAuth":{"certPresented":"0","certVerified":"NONE","certRevoked":"0","certIssuerDN":"","certSubjectDN":"","certIssuerDNRFC2253":"","certSubjectDNRFC2253":"","certIssuerDNLegacy":"","certSubjectDNLegacy":"","certSerial":"","certIssuerSerial":"","certSKI":"","certIssuerSKI":"","certFingerprintSHA1":"","certFingerprintSHA256":"","certNotBefore":"","certNotAfter":""},"verifiedBotCategory":"","botManagement":{"corporateProxy":false,"verifiedBot":false,"jsDetection":{"passed":false},"staticResource":false,"detectionIds":{},"score":99}}
|
{"httpProtocol":"HTTP/1.1","clientAcceptEncoding":"gzip, deflate, br","requestPriority":"","edgeRequestKeepAliveStatus":1,"requestHeaderNames":{},"clientTcpRtt":26,"colo":"SYD","asn":9443,"asOrganization":"Vocus","country":"AU","isEUCountry":false,"city":"Sydney","continent":"OC","region":"New South Wales","regionCode":"NSW","timezone":"Australia/Sydney","longitude":"151.20732","latitude":"-33.86785","postalCode":"1001","tlsVersion":"TLSv1.3","tlsCipher":"AEAD-AES256-GCM-SHA384","tlsClientRandom":"q+XTQrmbIX2iNNAi+8RaMkPlVKucfKu2QjNQej35Jo8=","tlsClientCiphersSha1":"kXrN3VEKDdzz2cPKTQaKzpxVTxQ=","tlsClientExtensionsSha1":"1eY97BUYYO8vDaTfHQywB1pcNdM=","tlsClientExtensionsSha1Le":"u4wtEMFQBY18l3BzHAvORm+KGRw=","tlsExportedAuthenticator":{"clientHandshake":"918753d88f16497a81bec58c93db6eb95382e6cc3fef5af6c045f00ddd7b4ff09bca2042e3e9a2809bd9e43d17a91692","serverHandshake":"0ec75818c051cc9c6548de819406a93217de79a9d796a3632a1987dcada263f5cbc07cccf47598c74ac989687992921e","clientFinished":"f14e7fd18d6916fedd649672b8eda2fce6b0e2210de45f35605155815ed0be3b6868e8798f35e8f8aba21beabbab48d2","serverFinished":"46f06972f7ed47a394e7b635e7762eddf8df855ef2a2a1ce30d44c672eb4a115903238c40a834112f656434d29485f2f"},"tlsClientHelloLength":"1603","tlsClientAuth":{"certPresented":"0","certVerified":"NONE","certRevoked":"0","certIssuerDN":"","certSubjectDN":"","certIssuerDNRFC2253":"","certSubjectDNRFC2253":"","certIssuerDNLegacy":"","certSubjectDNLegacy":"","certSerial":"","certIssuerSerial":"","certSKI":"","certIssuerSKI":"","certFingerprintSHA1":"","certFingerprintSHA256":"","certNotBefore":"","certNotAfter":""},"verifiedBotCategory":"","botManagement":{"corporateProxy":false,"verifiedBot":false,"jsDetection":{"passed":false},"staticResource":false,"detectionIds":{},"score":99}}
|
||||||
@@ -16,12 +16,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h1>Solstice Playground</h1>
|
<h1>Solstice Playground</h1>
|
||||||
<h2>Broken right now. Sorry!</h2>
|
|
||||||
|
|
||||||
<textarea class="code" id="editor" spellcheck="false" placeholder="Enter Solstice code here..." rows="20">
|
<textarea class="code" id="editor" spellcheck="false" placeholder="Enter Solstice code here..." rows="20">
|
||||||
puts "Hello from Solstice via WebAssembly!"
|
puts "Hello from Solstice via WebAssembly!"
|
||||||
puts "Let's do some math:"
|
</textarea>
|
||||||
puts 10 + 20 + 12</textarea>
|
|
||||||
|
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<button id="runBtn" style="font-size: 20px;">Loading WASM...</button>
|
<button id="runBtn" style="font-size: 20px;">Loading WASM...</button>
|
||||||
@@ -30,57 +28,32 @@ puts 10 + 20 + 12</textarea>
|
|||||||
<h3>Output:</h3>
|
<h3>Output:</h3>
|
||||||
<pre class="code" id="output">Output will appear here. Click "Run Code" to run!</pre>
|
<pre class="code" id="output">Output will appear here. Click "Run Code" to run!</pre>
|
||||||
|
|
||||||
<script type="module">
|
<script src="playground.js"></script>
|
||||||
import createSolsticeModule from './playground.js';
|
<script>
|
||||||
|
|
||||||
let solsticeModule = null;
|
|
||||||
const outputDiv = document.getElementById('output');
|
const outputDiv = document.getElementById('output');
|
||||||
|
const codeArea = document.getElementById('editor');
|
||||||
const runBtn = document.getElementById('runBtn');
|
const runBtn = document.getElementById('runBtn');
|
||||||
const editor = document.getElementById('editor');
|
|
||||||
|
|
||||||
// Initialize the Emscripten module
|
// Emscripten provides a 'Module' object that fires 'onRuntimeInitialized'
|
||||||
createSolsticeModule({
|
Module.onRuntimeInitialized = () => {
|
||||||
// Redirect stdout to our output div
|
outputDiv.innerText = "Ready to run.";
|
||||||
print: (text) => {
|
runBtn.innerText = "Run";
|
||||||
outputDiv.textContent += text + "\n";
|
|
||||||
console.log(text);
|
|
||||||
},
|
|
||||||
// Redirect stderr to our output div (and console)
|
|
||||||
printErr: (text) => {
|
|
||||||
outputDiv.textContent += "[stderr] " + text + "\n";
|
|
||||||
console.error(text);
|
|
||||||
}
|
|
||||||
}).then((instance) => {
|
|
||||||
solsticeModule = instance;
|
|
||||||
runBtn.textContent = "Run Code";
|
|
||||||
runBtn.disabled = false;
|
|
||||||
console.log("Solstice WASM module loaded successfully");
|
|
||||||
}).catch(err => {
|
|
||||||
console.error("Failed to load WASM module:", err);
|
|
||||||
outputDiv.innerHTML = '<span class="error">Error loading WASM module. See console for details.</span>';
|
|
||||||
runBtn.textContent = "Load Failed";
|
|
||||||
});
|
|
||||||
|
|
||||||
runBtn.addEventListener('click', () => {
|
runBtn.addEventListener('click', () => {
|
||||||
if (!solsticeModule) return;
|
const source = codeArea.value;
|
||||||
|
|
||||||
outputDiv.textContent = ""; // Clear previous output
|
// Use 'ccall' to call the C function:
|
||||||
const code = editor.value;
|
// ccall(name, returnType, [argTypes], [args])
|
||||||
|
const result = Module.ccall(
|
||||||
try {
|
'solstice_run', // C function name
|
||||||
// Call the C++ function 'run_source' exported via EMSCRIPTEN_KEEPALIVE
|
'string', // Return type
|
||||||
// int run_source(char* code)
|
['string'], // Argument types
|
||||||
solsticeModule.ccall(
|
[source] // Arguments
|
||||||
'run_source', // function name
|
|
||||||
'number', // return type
|
|
||||||
['string'], // argument types
|
|
||||||
[code] // arguments
|
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
outputDiv.innerHTML += `\n<span class="error">[Runtime Error] ${e}</span>`;
|
outputDiv.innerText = result;
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user