diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index f8c92ca2e88..168af2fdc2f 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -1303,6 +1303,9 @@ VrStageParameters = [] VrSubmitFrameResult = [] VttCue = ["EventTarget", "TextTrackCue"] VttRegion = [] +WakeLock = [] +WakeLockType = [] +WakeLockSentinel = [] WatchAdvertisementsOptions = [] WaveShaperNode = ["AudioNode", "EventTarget"] WaveShaperOptions = [] diff --git a/crates/web-sys/src/features/gen_Navigator.rs b/crates/web-sys/src/features/gen_Navigator.rs index bce72048b23..f2be1a279e8 100644 --- a/crates/web-sys/src/features/gen_Navigator.rs +++ b/crates/web-sys/src/features/gen_Navigator.rs @@ -129,6 +129,18 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn clipboard(this: &Navigator) -> Clipboard; #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "WakeLock")] + # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = wakeLock)] + #[doc = "Getter for the `wakeLock` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/wakeLock)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Navigator`, `WakeLock`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn wake_lock(this: &Navigator) -> WakeLock; + #[cfg(web_sys_unstable_apis)] #[cfg(feature = "Gpu")] # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = gpu)] #[doc = "Getter for the `gpu` field of this object."] diff --git a/crates/web-sys/src/features/gen_WakeLock.rs b/crates/web-sys/src/features/gen_WakeLock.rs new file mode 100644 index 00000000000..ecdad001894 --- /dev/null +++ b/crates/web-sys/src/features/gen_WakeLock.rs @@ -0,0 +1,30 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = WakeLock , typescript_type = "WakeLock")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `WakeLock` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLock)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLock`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type WakeLock; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "WakeLockType")] + # [wasm_bindgen (method , structural , js_class = "WakeLock" , js_name = request)] + #[doc = "The `request()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLock/request)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLock`, `WakeLockType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn request(this: &WakeLock, type_: WakeLockType) -> ::js_sys::Promise; +} diff --git a/crates/web-sys/src/features/gen_WakeLockSentinel.rs b/crates/web-sys/src/features/gen_WakeLockSentinel.rs new file mode 100644 index 00000000000..3cd67d7f153 --- /dev/null +++ b/crates/web-sys/src/features/gen_WakeLockSentinel.rs @@ -0,0 +1,74 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = WakeLockSentinel , typescript_type = "WakeLockSentinel")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `WakeLockSentinel` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type WakeLockSentinel; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "WakeLockSentinel" , js_name = released)] + #[doc = "Getter for the `released` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/released)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn released(this: &WakeLockSentinel) -> bool; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "WakeLockType")] + # [wasm_bindgen (structural , method , getter , js_class = "WakeLockSentinel" , js_name = type)] + #[doc = "Getter for the `type` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/type)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`, `WakeLockType`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn type_(this: &WakeLockSentinel) -> WakeLockType; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "WakeLockSentinel" , js_name = onrelease)] + #[doc = "Getter for the `onrelease` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/onrelease)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn onrelease(this: &WakeLockSentinel) -> Option<::js_sys::Function>; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , setter , js_class = "WakeLockSentinel" , js_name = onrelease)] + #[doc = "Setter for the `onrelease` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/onrelease)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_onrelease(this: &WakeLockSentinel, value: Option<&::js_sys::Function>); + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (method , structural , js_class = "WakeLockSentinel" , js_name = release)] + #[doc = "The `release()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/release)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn release(this: &WakeLockSentinel) -> ::js_sys::Promise; +} diff --git a/crates/web-sys/src/features/gen_WakeLockType.rs b/crates/web-sys/src/features/gen_WakeLockType.rs new file mode 100644 index 00000000000..b09491890c9 --- /dev/null +++ b/crates/web-sys/src/features/gen_WakeLockType.rs @@ -0,0 +1,14 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `WakeLockType` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `WakeLockType`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum WakeLockType { + Screen = "screen", +} diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index 7059612767a..be4ec6e802a 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -7660,6 +7660,24 @@ mod gen_VttRegion; #[cfg(feature = "VttRegion")] pub use gen_VttRegion::*; +#[cfg(feature = "WakeLock")] +#[allow(non_snake_case)] +mod gen_WakeLock; +#[cfg(feature = "WakeLock")] +pub use gen_WakeLock::*; + +#[cfg(feature = "WakeLockSentinel")] +#[allow(non_snake_case)] +mod gen_WakeLockSentinel; +#[cfg(feature = "WakeLockSentinel")] +pub use gen_WakeLockSentinel::*; + +#[cfg(feature = "WakeLockType")] +#[allow(non_snake_case)] +mod gen_WakeLockType; +#[cfg(feature = "WakeLockType")] +pub use gen_WakeLockType::*; + #[cfg(feature = "WatchAdvertisementsOptions")] #[allow(non_snake_case)] mod gen_WatchAdvertisementsOptions; diff --git a/crates/web-sys/webidls/unstable/ScreenWakeLock.webidl b/crates/web-sys/webidls/unstable/ScreenWakeLock.webidl new file mode 100644 index 00000000000..c14d783d4de --- /dev/null +++ b/crates/web-sys/webidls/unstable/ScreenWakeLock.webidl @@ -0,0 +1,23 @@ +/* The origin of this IDL file is + * https://www.w3.org/TR/screen-wake-lock/#idl-index + */ + +[SecureContext] +partial interface Navigator { + [SameObject] readonly attribute WakeLock wakeLock; +}; + +[SecureContext, Exposed=(Window)] +interface WakeLock { + Promise request(WakeLockType type); +}; + +[SecureContext, Exposed=(Window)] +interface WakeLockSentinel : EventTarget { + readonly attribute boolean released; + readonly attribute WakeLockType type; + Promise release(); + attribute EventHandler onrelease; +}; + +enum WakeLockType { "screen" };