1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pub extern crate wasm_bindgen;
pub extern crate web_sys;
extern crate xloop_types as types;

pub mod app;
pub mod error;
pub mod win;

pub mod prelude {}

#[derive(Debug)]
pub struct Platform;

impl types::Platform for Platform {
	type Error = error::Error;
	type AppRef<'a> = app::AppRef<'a>;
	type AppHandle = app::AppHandle;
	type AppProxy = app::AppProxy;
	type WinRef<'a> = win::WinRef<'a>;
	type WinHandle = win::WinHandle;
	type WinRaw = win::WinRaw;
	type EvtMouse<'a> = win::WinMouse<'a>;
	type EvtWheel<'a> = win::WinWheel<'a>;
	type EvtKey<'a> = win::WinKey<'a>;
	type EvtTouch<'a> = win::WinTouch<'a>;
	type EvtCommit<'a> = &'a types::EvtCommit;
	fn run(delegate: impl types::AppDelegate<Self> + 'static) -> Result<Option<Self::AppHandle>, Self::Error> {
		app::with_app(Some(std::rc::Rc::new(delegate)), |_| {});
		use types::AppHandle as _;
		app::AppHandle::singleton().ok_or(error::Error)?.run();
		Ok(None)
	}
	fn win(_key: impl AsRef<str>, delegate: impl types::WinDelegate<Self> + 'static) -> Result<Self::WinHandle, Self::Error> {
		unsafe { win::WinHandle::new(_key, delegate).ok_or(error::Error) }
	}
	fn log(level: log::LevelFilter) {
		console_log::init_with_level(level.to_level().unwrap_or(log::Level::Info)).ok();
	}
	fn read(_path: impl AsRef<std::path::Path>) -> Option<Vec<u8>> {
		None
	}
}