Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScreenWakeLock.webidl #2568

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,9 @@ VrStageParameters = []
VrSubmitFrameResult = []
VttCue = ["EventTarget", "TextTrackCue"]
VttRegion = []
WakeLock = []
WakeLockType = []
WakeLockSentinel = []
WatchAdvertisementsOptions = []
WaveShaperNode = ["AudioNode", "EventTarget"]
WaveShaperOptions = []
Expand Down
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/gen_Navigator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."]
Expand Down
30 changes: 30 additions & 0 deletions crates/web-sys/src/features/gen_WakeLock.rs
Original file line number Diff line number Diff line change
@@ -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;
}
74 changes: 74 additions & 0 deletions crates/web-sys/src/features/gen_WakeLockSentinel.rs
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 14 additions & 0 deletions crates/web-sys/src/features/gen_WakeLockType.rs
Original file line number Diff line number Diff line change
@@ -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",
}
18 changes: 18 additions & 0 deletions crates/web-sys/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions crates/web-sys/webidls/unstable/ScreenWakeLock.webidl
Original file line number Diff line number Diff line change
@@ -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<WakeLockSentinel> request(WakeLockType type);
};

[SecureContext, Exposed=(Window)]
interface WakeLockSentinel : EventTarget {
readonly attribute boolean released;
readonly attribute WakeLockType type;
Promise<undefined> release();
attribute EventHandler onrelease;
};

enum WakeLockType { "screen" };