mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-28 15:12:16 +00:00
This commit employs the strategy described in #908 to apply a non-breaking change to fix WebIDL to be compatible with all browsers, including Safari. The problem here is that `BaseAudioContext` and `AudioScheduledSourceNode` are not types in Safari, but they are types in Firefox/Chrome. The fix here was to move the contents of these two interfaces into mixins, and then include the mixins in all classes which inherit from these two classes. That should have the same effect as defining the methods inherently on the original interface. Additionally a special `[RustDeprecated]` attribute to WebIDL was added to signify interfaces this has happened to. Currently it's directly tailored towards this case of "this intermediate class doesn't exist in all browsers", but we may want to refine and extend the deprecation message over time. Although it's possible we could do this as a breaking change to `web-sys` I'm hoping that we can do this as a non-breaking change for now and then eventually on the next breaking release batch all these changes together, deleting the intermediate classes. This is also hopefully a good trial run for how stable web-sys can be when it's actually stable! cc #897 cc #908
31 lines
1.0 KiB
Rust
Executable File
31 lines
1.0 KiB
Rust
Executable File
//! Raw API bindings for Web APIs
|
|
//!
|
|
//! This is a procedurally generated crate from browser WebIDL which provides a
|
|
//! binding to all APIs that browser provide on the web.
|
|
//!
|
|
//! This crate by default contains very little when compiled as almost all of
|
|
//! its exposed APIs are gated by Cargo features. The exhaustive list of
|
|
//! features can be found in `crates/web-sys/Cargo.toml`, but the rule of thumb
|
|
//! for `web-sys` is that each type has its own cargo feature (named after the
|
|
//! type). Using an API requires enabling the features for all types used in the
|
|
//! API, and APIs should mention in the documentation what features they
|
|
//! require.
|
|
|
|
#![doc(html_root_url = "https://docs.rs/web-sys/0.2")]
|
|
#![allow(deprecated)]
|
|
|
|
extern crate js_sys;
|
|
extern crate wasm_bindgen;
|
|
|
|
#[allow(unused_imports)]
|
|
use js_sys::Object;
|
|
|
|
#[cfg(feature = "Window")]
|
|
pub fn window() -> Option<Window> {
|
|
use wasm_bindgen::JsCast;
|
|
|
|
js_sys::global().dyn_into::<Window>().ok()
|
|
}
|
|
|
|
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|