From 0876527eafcd7c372873314cc9c7e93cba2991e2 Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Tue, 11 Jun 2019 21:05:15 +0200 Subject: Create a web page --- webhogg/wasm/pkg/main.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 webhogg/wasm/pkg/main.js (limited to 'webhogg/wasm/pkg/main.js') diff --git a/webhogg/wasm/pkg/main.js b/webhogg/wasm/pkg/main.js new file mode 100644 index 0000000..f80fabb --- /dev/null +++ b/webhogg/wasm/pkg/main.js @@ -0,0 +1 @@ +let data = fetch('bin/webhogg-wasm_bg.wasm'); -- cgit v1.2.3-70-g09d2 From 286be2a2fe89927c1a7bb6855b3d001a70dd312d Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Tue, 11 Jun 2019 23:40:24 +0200 Subject: Add workers --- webhogg/wasm/Cargo.toml | 7 +++++++ webhogg/wasm/build | 6 ++++-- webhogg/wasm/pkg/main.js | 10 +++++++++- webhogg/wasm/pkg/worker-graphics.js | 1 + webhogg/wasm/src/lib.rs | 8 ++++++++ webhogg/wasm/src/main.rs | 3 --- 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 webhogg/wasm/pkg/worker-graphics.js create mode 100644 webhogg/wasm/src/lib.rs delete mode 100644 webhogg/wasm/src/main.rs (limited to 'webhogg/wasm/pkg/main.js') diff --git a/webhogg/wasm/Cargo.toml b/webhogg/wasm/Cargo.toml index b01d7e3..7978928 100644 --- a/webhogg/wasm/Cargo.toml +++ b/webhogg/wasm/Cargo.toml @@ -8,4 +8,11 @@ authors = [ edition = "2018" description = "WebAssembly frontend for the webhogg project" +[lib] +crate-type = ["cdylib"] + +[profile.release] +lto = true + [dependencies] +wasm-bindgen = "0.2" diff --git a/webhogg/wasm/build b/webhogg/wasm/build index a0c4df1..e14f004 100755 --- a/webhogg/wasm/build +++ b/webhogg/wasm/build @@ -1,5 +1,7 @@ #!/bin/bash cargo build --target wasm32-unknown-unknown --release -wasm-bindgen target/wasm32-unknown-unknown/release/webhogg-wasm.wasm --out-dir bin/ --no-typescript --target no-modules --remove-producers-section --remove-name-section -wasm-opt -Oz bin/*.wasm -o bin/*.wasm +wasm-bindgen target/wasm32-unknown-unknown/release/webhogg_wasm.wasm --out-dir bin/ --no-typescript --target no-modules --remove-producers-section --remove-name-section +wasm-opt -Oz bin/webhogg_wasm_bg.wasm -o bin/webhogg-wasm.wasm +rm bin/webhogg_wasm_bg.wasm +mv bin/webhogg_wasm.js bin/webhogg-wasm.js diff --git a/webhogg/wasm/pkg/main.js b/webhogg/wasm/pkg/main.js index f80fabb..eec740d 100644 --- a/webhogg/wasm/pkg/main.js +++ b/webhogg/wasm/pkg/main.js @@ -1 +1,9 @@ -let data = fetch('bin/webhogg-wasm_bg.wasm'); +async function main() { + let fetchingSource = fetch('bin/webhogg-wasm.wasm'); + let fetchedSource = await fetchingSource; + let source = await fetchedSource.text(); + //alert(source) + let workerGraphics = new Worker('pkg/worker-graphics.js'); +} + +main(); diff --git a/webhogg/wasm/pkg/worker-graphics.js b/webhogg/wasm/pkg/worker-graphics.js new file mode 100644 index 0000000..8360014 --- /dev/null +++ b/webhogg/wasm/pkg/worker-graphics.js @@ -0,0 +1 @@ +console.log('lelel'); diff --git a/webhogg/wasm/src/lib.rs b/webhogg/wasm/src/lib.rs new file mode 100644 index 0000000..cb334fb --- /dev/null +++ b/webhogg/wasm/src/lib.rs @@ -0,0 +1,8 @@ +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +pub fn enrty() { +} + +fn main() { +} diff --git a/webhogg/wasm/src/main.rs b/webhogg/wasm/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/webhogg/wasm/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} -- cgit v1.2.3-70-g09d2