Files
pyscript/pyscript.core/test/plugins/lua.html
2023-06-15 17:08:28 +02:00

35 lines
1.1 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Plugins</title>
<style>
py-script {
display: none;
}
</style>
<script type="importmap">
{ "imports": { "@pyscript/core": "../../min.js" } }
</script>
<script type="module">
import { registerPlugin } from "@pyscript/core";
registerPlugin("lua-script", {
type: "wasmoon",
async onRuntimeReady(wasmoon, element) {
// Somehow this doesn't work in Wasmoon
wasmoon.io.stdout = (message) => {
console.log("🌑", wasmoon.type, message);
};
wasmoon.run(element.textContent);
element.replaceChildren("See console ->");
element.style.display = "block";
},
});
</script>
</head>
<body>
<lua-script> print('Hello Console!') </lua-script>
</body>
</html>