feat(users/kranzes): add wasm-hello-world

This can be used as a reference for how to build a wasm project with
crate2nix.

Change-Id: Ib4d0db6bf24d8f1dec4734d5f1e8de19212a54cd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11859
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Ilan Joselevich 2024-06-18 21:03:21 +03:00
parent 4b2f3c5454
commit 7f8da5e6a9
7 changed files with 1262 additions and 0 deletions

View file

@ -0,0 +1,19 @@
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
<script type="module">
import init, { hello_world } from './wasm_hello_world.js';
async function run() {
await init();
hello_world();
}
run();
</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
fn alert(s: &str);
}
#[wasm_bindgen]
pub fn hello_world() {
alert("Hello World!");
}