From fb31751fab32c8b67affd75603084e4f143bc758 Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Sun, 26 May 2019 16:09:03 +0200 Subject: Add basic project structure --- WebInterface/wasm/asm-paint/Cargo.toml | 2 +- WebInterface/wasm/asm-paint/run | 2 +- WebInterface/wasm/asm-paint/src/app.rs | 16 ++++++++++++++++ WebInterface/wasm/asm-paint/src/lib.rs | 7 ++++++- WebInterface/wasm/asm-paint/src/site.rs | 18 ++++++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 WebInterface/wasm/asm-paint/src/app.rs create mode 100644 WebInterface/wasm/asm-paint/src/site.rs diff --git a/WebInterface/wasm/asm-paint/Cargo.toml b/WebInterface/wasm/asm-paint/Cargo.toml index e8f5acb..e2b1e17 100644 --- a/WebInterface/wasm/asm-paint/Cargo.toml +++ b/WebInterface/wasm/asm-paint/Cargo.toml @@ -3,7 +3,7 @@ name = "asm-paint-rs" version = "0.1.0" authors = [ "natrixaeria", - "Dennis Kobert " + "TrueDoctor" ] edition = "2018" diff --git a/WebInterface/wasm/asm-paint/run b/WebInterface/wasm/asm-paint/run index 61c1997..1da1e35 100755 --- a/WebInterface/wasm/asm-paint/run +++ b/WebInterface/wasm/asm-paint/run @@ -1,3 +1,3 @@ #!/bin/sh -wasm-pack build --target web +wasm-pack build --release --target web diff --git a/WebInterface/wasm/asm-paint/src/app.rs b/WebInterface/wasm/asm-paint/src/app.rs new file mode 100644 index 0000000..d5d0e45 --- /dev/null +++ b/WebInterface/wasm/asm-paint/src/app.rs @@ -0,0 +1,16 @@ +use crate::site::Site; + +pub struct App { + site: Site, +} + +impl App { + pub fn new() -> Option { + Some(Self { + site: Site::from_current()?, + }) + } + + pub fn run(&self) { + } +} diff --git a/WebInterface/wasm/asm-paint/src/lib.rs b/WebInterface/wasm/asm-paint/src/lib.rs index fea9d0f..037e8e9 100644 --- a/WebInterface/wasm/asm-paint/src/lib.rs +++ b/WebInterface/wasm/asm-paint/src/lib.rs @@ -1,4 +1,6 @@ mod client_logger; +mod site; +mod app; use wasm_bindgen::prelude::*; @@ -9,5 +11,8 @@ extern crate log; pub fn entry() { client_logger::init_logger(); - info!("{}", 42); + info!("begin running wasm application"); + + let app = app::App::new().unwrap(); + app.run(); } diff --git a/WebInterface/wasm/asm-paint/src/site.rs b/WebInterface/wasm/asm-paint/src/site.rs new file mode 100644 index 0000000..740cb90 --- /dev/null +++ b/WebInterface/wasm/asm-paint/src/site.rs @@ -0,0 +1,18 @@ +use web_sys; + +pub struct Site { + window: web_sys::Window, + document: web_sys::Document, +} + +impl Site { + pub fn from_current() -> Option { + let window = web_sys::window() + .or_else(|| {error!("unable to query window"); None})?; + let document = window.document() + .or_else(|| {error!("unable to query document"); None})?; + Some(Self { + window, document + }) + } +} -- cgit v1.2.3-54-g00ecf