1//! Raw API bindings for Web APIs
2//!
3//! This is a procedurally generated crate from browser WebIDL which provides a
4//! binding to all APIs that browsers provide on the web.
5//!
6//! This crate by default contains very little when compiled as almost all of
7//! its exposed APIs are gated by Cargo features. The exhaustive list of
8//! features can be found in `crates/web-sys/Cargo.toml`, but the rule of thumb
9//! for `web-sys` is that each type has its own cargo feature (named after the
10//! type). Using an API requires enabling the features for all types used in the
11//! API, and APIs should mention in the documentation what features they
12//! require.
13
14#![doc(html_root_url = "https://docs.rs/web-sys/0.3")]
15#![allow(deprecated)]
16
17mod features;
18pub use features::*;
19
20pub use js_sys;
21pub use wasm_bindgen;
22
23/// Getter for the `Window` object
24///
25/// [MDN Documentation]
26///
27/// *This API requires the following crate features to be activated: `Window`*
28///
29/// [MDN Documentation]: https://developer.mozilla.org/en-US/docs/Web/API/Window
30#[cfg(feature = "Window")]
31pub fn window() -> Option<Window> {
32 use wasm_bindgen::JsCast;
33
34 js_sys::global().dyn_into::<Window>().ok()
35}
36