Skip to content

Commit 72ef869

Browse files
authored
ScreenWakeLock.webidl (#2568)
1 parent 78a3721 commit 72ef869

File tree

7 files changed

+174
-0
lines changed

7 files changed

+174
-0
lines changed

crates/web-sys/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,9 @@ VrStageParameters = []
13031303
VrSubmitFrameResult = []
13041304
VttCue = ["EventTarget", "TextTrackCue"]
13051305
VttRegion = []
1306+
WakeLock = []
1307+
WakeLockType = []
1308+
WakeLockSentinel = []
13061309
WatchAdvertisementsOptions = []
13071310
WaveShaperNode = ["AudioNode", "EventTarget"]
13081311
WaveShaperOptions = []

crates/web-sys/src/features/gen_Navigator.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ extern "C" {
129129
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
130130
pub fn clipboard(this: &Navigator) -> Clipboard;
131131
#[cfg(web_sys_unstable_apis)]
132+
#[cfg(feature = "WakeLock")]
133+
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = wakeLock)]
134+
#[doc = "Getter for the `wakeLock` field of this object."]
135+
#[doc = ""]
136+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/wakeLock)"]
137+
#[doc = ""]
138+
#[doc = "*This API requires the following crate features to be activated: `Navigator`, `WakeLock`*"]
139+
#[doc = ""]
140+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
141+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
142+
pub fn wake_lock(this: &Navigator) -> WakeLock;
143+
#[cfg(web_sys_unstable_apis)]
132144
#[cfg(feature = "Gpu")]
133145
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = gpu)]
134146
#[doc = "Getter for the `gpu` field of this object."]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
5+
#[wasm_bindgen]
6+
extern "C" {
7+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = WakeLock , typescript_type = "WakeLock")]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `WakeLock` class."]
10+
#[doc = ""]
11+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLock)"]
12+
#[doc = ""]
13+
#[doc = "*This API requires the following crate features to be activated: `WakeLock`*"]
14+
#[doc = ""]
15+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
16+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
17+
pub type WakeLock;
18+
#[cfg(web_sys_unstable_apis)]
19+
#[cfg(feature = "WakeLockType")]
20+
# [wasm_bindgen (method , structural , js_class = "WakeLock" , js_name = request)]
21+
#[doc = "The `request()` method."]
22+
#[doc = ""]
23+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLock/request)"]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `WakeLock`, `WakeLockType`*"]
26+
#[doc = ""]
27+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
28+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
29+
pub fn request(this: &WakeLock, type_: WakeLockType) -> ::js_sys::Promise;
30+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
5+
#[wasm_bindgen]
6+
extern "C" {
7+
# [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = WakeLockSentinel , typescript_type = "WakeLockSentinel")]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `WakeLockSentinel` class."]
10+
#[doc = ""]
11+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel)"]
12+
#[doc = ""]
13+
#[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"]
14+
#[doc = ""]
15+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
16+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
17+
pub type WakeLockSentinel;
18+
#[cfg(web_sys_unstable_apis)]
19+
# [wasm_bindgen (structural , method , getter , js_class = "WakeLockSentinel" , js_name = released)]
20+
#[doc = "Getter for the `released` field of this object."]
21+
#[doc = ""]
22+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/released)"]
23+
#[doc = ""]
24+
#[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"]
25+
#[doc = ""]
26+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
27+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
28+
pub fn released(this: &WakeLockSentinel) -> bool;
29+
#[cfg(web_sys_unstable_apis)]
30+
#[cfg(feature = "WakeLockType")]
31+
# [wasm_bindgen (structural , method , getter , js_class = "WakeLockSentinel" , js_name = type)]
32+
#[doc = "Getter for the `type` field of this object."]
33+
#[doc = ""]
34+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/type)"]
35+
#[doc = ""]
36+
#[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`, `WakeLockType`*"]
37+
#[doc = ""]
38+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
39+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
40+
pub fn type_(this: &WakeLockSentinel) -> WakeLockType;
41+
#[cfg(web_sys_unstable_apis)]
42+
# [wasm_bindgen (structural , method , getter , js_class = "WakeLockSentinel" , js_name = onrelease)]
43+
#[doc = "Getter for the `onrelease` field of this object."]
44+
#[doc = ""]
45+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/onrelease)"]
46+
#[doc = ""]
47+
#[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"]
48+
#[doc = ""]
49+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
50+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
51+
pub fn onrelease(this: &WakeLockSentinel) -> Option<::js_sys::Function>;
52+
#[cfg(web_sys_unstable_apis)]
53+
# [wasm_bindgen (structural , method , setter , js_class = "WakeLockSentinel" , js_name = onrelease)]
54+
#[doc = "Setter for the `onrelease` field of this object."]
55+
#[doc = ""]
56+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/onrelease)"]
57+
#[doc = ""]
58+
#[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"]
59+
#[doc = ""]
60+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
61+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
62+
pub fn set_onrelease(this: &WakeLockSentinel, value: Option<&::js_sys::Function>);
63+
#[cfg(web_sys_unstable_apis)]
64+
# [wasm_bindgen (method , structural , js_class = "WakeLockSentinel" , js_name = release)]
65+
#[doc = "The `release()` method."]
66+
#[doc = ""]
67+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/release)"]
68+
#[doc = ""]
69+
#[doc = "*This API requires the following crate features to be activated: `WakeLockSentinel`*"]
70+
#[doc = ""]
71+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
72+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
73+
pub fn release(this: &WakeLockSentinel) -> ::js_sys::Promise;
74+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![allow(unused_imports)]
2+
use wasm_bindgen::prelude::*;
3+
#[cfg(web_sys_unstable_apis)]
4+
#[wasm_bindgen]
5+
#[doc = "The `WakeLockType` enum."]
6+
#[doc = ""]
7+
#[doc = "*This API requires the following crate features to be activated: `WakeLockType`*"]
8+
#[doc = ""]
9+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
10+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
11+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12+
pub enum WakeLockType {
13+
Screen = "screen",
14+
}

crates/web-sys/src/features/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7660,6 +7660,24 @@ mod gen_VttRegion;
76607660
#[cfg(feature = "VttRegion")]
76617661
pub use gen_VttRegion::*;
76627662

7663+
#[cfg(feature = "WakeLock")]
7664+
#[allow(non_snake_case)]
7665+
mod gen_WakeLock;
7666+
#[cfg(feature = "WakeLock")]
7667+
pub use gen_WakeLock::*;
7668+
7669+
#[cfg(feature = "WakeLockSentinel")]
7670+
#[allow(non_snake_case)]
7671+
mod gen_WakeLockSentinel;
7672+
#[cfg(feature = "WakeLockSentinel")]
7673+
pub use gen_WakeLockSentinel::*;
7674+
7675+
#[cfg(feature = "WakeLockType")]
7676+
#[allow(non_snake_case)]
7677+
mod gen_WakeLockType;
7678+
#[cfg(feature = "WakeLockType")]
7679+
pub use gen_WakeLockType::*;
7680+
76637681
#[cfg(feature = "WatchAdvertisementsOptions")]
76647682
#[allow(non_snake_case)]
76657683
mod gen_WatchAdvertisementsOptions;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* The origin of this IDL file is
2+
* https://www.w3.org/TR/screen-wake-lock/#idl-index
3+
*/
4+
5+
[SecureContext]
6+
partial interface Navigator {
7+
[SameObject] readonly attribute WakeLock wakeLock;
8+
};
9+
10+
[SecureContext, Exposed=(Window)]
11+
interface WakeLock {
12+
Promise<WakeLockSentinel> request(WakeLockType type);
13+
};
14+
15+
[SecureContext, Exposed=(Window)]
16+
interface WakeLockSentinel : EventTarget {
17+
readonly attribute boolean released;
18+
readonly attribute WakeLockType type;
19+
Promise<undefined> release();
20+
attribute EventHandler onrelease;
21+
};
22+
23+
enum WakeLockType { "screen" };

0 commit comments

Comments
 (0)