Skip to main content

ferroui_browser/interop/
mod.rs

1//! The boundary between the framework and the script module of the
2//! platform.
3//!
4//! One file per group of functions, as the script module groups them. Each
5//! holds the imports (functions of the script module, called from here) and
6//! the exports (functions of the framework, called by the script module).
7//! Objects of the page are opaque [`JsObject`] handles; nothing outside this
8//! module and the render targets touches them except to pass them back.
9//!
10//! [`thread_proxy`] is the one file that is not about the script module: it
11//! crosses from one thread of the module to another, and asks the script
12//! only for what the runtime carried to the main thread.
13
14pub mod canvas_helper;
15pub mod completion_helper;
16pub mod dom_helper;
17pub mod ferro_module;
18pub mod input_helper;
19pub mod native_control_host_helper;
20pub mod navigation_helper;
21pub mod screen_helper;
22pub mod storage_helper;
23pub mod stream_helper;
24pub mod thread_proxy;
25pub mod timer_helper;
26
27/// An object of the web page, held by the framework without looking inside.
28pub type JsObject = wasm_bindgen::JsValue;
29
30/// `value` unless it is `null` or `undefined`.
31pub(crate) fn non_null(value: JsObject) -> Option<JsObject> {
32    if value.is_null() || value.is_undefined() {
33        None
34    } else {
35        Some(value)
36    }
37}