added hello-world wasm example and npmPackage nix derivation

This commit is contained in:
Sebastian Moser
2024-05-23 00:24:09 +02:00
parent a16c2f9221
commit 7944fd3f7f
4 changed files with 69 additions and 6 deletions

19
src/platform/wasm/mod.rs Normal file
View File

@@ -0,0 +1,19 @@
mod utils;
use wasm_bindgen::prelude::*;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[wasm_bindgen]
extern {
fn alert(s: &str);
}
#[wasm_bindgen]
pub fn greet() {
alert("Hello, wasm-game-of-life!");
}