wasix-org/cargo-wasix

Web Hello world example

Opened this issue · 0 comments

Hi I'm a bit compile hello world and then load it in the browser with the following. Are you able to do an example with this to point people in the right direction

Thanks

<!DOCTYPE html>
<html>

<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>Page Title</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <!-- <link rel='stylesheet' type='text/css' media='screen' href='main.css'> -->
    <script lang="ts">
        const importObject = {
            module: {},
            env: {
                memory: new WebAssembly.Memory({ initial: 256 }),
            }
        };
        const response = fetch('/wasmix-play.wasm').then((response) =>
            response.arrayBuffer()
        ).then((bytes) =>  WebAssembly.instantiate(bytes, importObject)
        ).then((instance) => {
            console.log(instance.exports);
        });
    </script>
</head>
<body>
</body>
</html>```