added hello-world wasm example and npmPackage nix derivation
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
static PROTO_VERSION: u8 = 1;
|
||||
|
||||
// the core part houses the code that can run on any platform
|
||||
/*
|
||||
pub mod core {
|
||||
pub mod memstore;
|
||||
pub mod instance;
|
||||
@@ -14,7 +16,12 @@ pub mod core {
|
||||
}
|
||||
|
||||
pub use core::*;
|
||||
|
||||
// */
|
||||
|
||||
pub mod platform {
|
||||
#[cfg(feature = "wasm-target")]
|
||||
pub mod wasm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
19
src/platform/wasm/mod.rs
Normal file
19
src/platform/wasm/mod.rs
Normal 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!");
|
||||
}
|
||||
0
src/platform/wasm/utils.rs
Normal file
0
src/platform/wasm/utils.rs
Normal file
Reference in New Issue
Block a user