//! [`egui`] bindings for web apps (compiling to WASM). #![allow(clippy::missing_errors_doc)] // So many `-> Result<_, JsValue>` mod app_runner; mod backend; mod events; mod input; mod panic_handler; mod text_agent; mod web_logger; mod web_runner; /// Access to the browser screen reader. #[cfg(feature = "web_screen_reader")] pub mod screen_reader; /// Access to local browser storage. pub mod storage; pub(crate) use app_runner::AppRunner; pub use panic_handler::{PanicHandler, PanicSummary}; pub use web_logger::WebLogger; pub use web_runner::WebRunner; #[cfg(not(any(feature = "glow", feature = "wgpu")))] compile_error!("You must enable either the 'glow' or 'wgpu' feature"); mod web_painter; #[cfg(feature = "glow")] mod web_painter_glow; #[cfg(feature = "glow")] pub(crate) type ActiveWebPainter = web_painter_glow::WebPainterGlow; #[cfg(feature = "wgpu")] mod web_painter_wgpu; #[cfg(all(feature = "wgpu", not(feature = "glow")))] pub(crate) type ActiveWebPainter = web_painter_wgpu::WebPainterWgpu; pub use backend::*; use wasm_bindgen::prelude::*; use web_sys::{Document, MediaQueryList, Node}; use input::{ button_from_mouse_event, modifiers_from_kb_event, modifiers_from_mouse_event, modifiers_from_wheel_event, pos_from_mouse_event, primary_touch_pos, push_touches, text_from_keyboard_event, translate_key, }; // ---------------------------------------------------------------------------- /// Debug browser resizing? const DEBUG_RESIZE: bool = false; pub(crate) fn string_from_js_value(value: &JsValue) -> String { value.as_string().unwrap_or_else(|| format!("{value:#?}")) } /// Returns the `Element` with active focus. /// /// Elements can only be focused if they are: /// - ``/`` with an `href` attribute /// - ``/`