Skip to content

Commit 2c62271

Browse files
author
Leonard
authored
Add experimental ViewTransition interface (#3598)
1 parent 0cbc0c9 commit 2c62271

File tree

6 files changed

+115
-0
lines changed

6 files changed

+115
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
### Added
77

8+
* Add bindings for `ViewTransition` to `web-sys`.
9+
[#3598](https://github.com/rustwasm/wasm-bindgen/pull/3598)
10+
811
* Extend `AudioContext` with unstable features supporting audio sink configuration.
912
[#3433](https://github.com/rustwasm/wasm-bindgen/pull/3433)
1013

crates/web-sys/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,7 @@ VideoStreamTrack = ["EventTarget", "MediaStreamTrack"]
14581458
VideoTrack = []
14591459
VideoTrackList = ["EventTarget"]
14601460
VideoTransferCharacteristics = []
1461+
ViewTransition = []
14611462
VisibilityState = []
14621463
VoidCallback = []
14631464
VrDisplay = ["EventTarget"]

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

+27
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,33 @@ extern "C" {
21552155
#[doc = ""]
21562156
#[doc = "*This API requires the following crate features to be activated: `Document`*"]
21572157
pub fn release_capture(this: &Document);
2158+
#[cfg(web_sys_unstable_apis)]
2159+
#[cfg(feature = "ViewTransition")]
2160+
# [wasm_bindgen (catch , method , structural , js_class = "Document" , js_name = startViewTransition)]
2161+
#[doc = "The `startViewTransition()` method."]
2162+
#[doc = ""]
2163+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)"]
2164+
#[doc = ""]
2165+
#[doc = "*This API requires the following crate features to be activated: `Document`, `ViewTransition`*"]
2166+
#[doc = ""]
2167+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
2168+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
2169+
pub fn start_view_transition(this: &Document) -> Result<ViewTransition, JsValue>;
2170+
#[cfg(web_sys_unstable_apis)]
2171+
#[cfg(feature = "ViewTransition")]
2172+
# [wasm_bindgen (catch , method , structural , js_class = "Document" , js_name = startViewTransition)]
2173+
#[doc = "The `startViewTransition()` method."]
2174+
#[doc = ""]
2175+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)"]
2176+
#[doc = ""]
2177+
#[doc = "*This API requires the following crate features to be activated: `Document`, `ViewTransition`*"]
2178+
#[doc = ""]
2179+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
2180+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
2181+
pub fn start_view_transition_with_update_callback(
2182+
this: &Document,
2183+
update_callback: Option<&::js_sys::Function>,
2184+
) -> Result<ViewTransition, JsValue>;
21582185
#[cfg(feature = "Element")]
21592186
# [wasm_bindgen (method , structural , js_class = "Document" , js_name = elementFromPoint)]
21602187
#[doc = "The `elementFromPoint()` method."]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::all)]
3+
use super::*;
4+
use wasm_bindgen::prelude::*;
5+
#[cfg(web_sys_unstable_apis)]
6+
#[wasm_bindgen]
7+
extern "C" {
8+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = ViewTransition , typescript_type = "ViewTransition")]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `ViewTransition` class."]
11+
#[doc = ""]
12+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition)"]
13+
#[doc = ""]
14+
#[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"]
15+
#[doc = ""]
16+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
17+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
18+
pub type ViewTransition;
19+
#[cfg(web_sys_unstable_apis)]
20+
# [wasm_bindgen (structural , method , getter , js_class = "ViewTransition" , js_name = updateCallbackDone)]
21+
#[doc = "Getter for the `updateCallbackDone` field of this object."]
22+
#[doc = ""]
23+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/updateCallbackDone)"]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"]
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 update_callback_done(this: &ViewTransition) -> ::js_sys::Promise;
30+
#[cfg(web_sys_unstable_apis)]
31+
# [wasm_bindgen (structural , method , getter , js_class = "ViewTransition" , js_name = ready)]
32+
#[doc = "Getter for the `ready` field of this object."]
33+
#[doc = ""]
34+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/ready)"]
35+
#[doc = ""]
36+
#[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"]
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 ready(this: &ViewTransition) -> ::js_sys::Promise;
41+
#[cfg(web_sys_unstable_apis)]
42+
# [wasm_bindgen (structural , method , getter , js_class = "ViewTransition" , js_name = finished)]
43+
#[doc = "Getter for the `finished` field of this object."]
44+
#[doc = ""]
45+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/finished)"]
46+
#[doc = ""]
47+
#[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"]
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 finished(this: &ViewTransition) -> ::js_sys::Promise;
52+
#[cfg(web_sys_unstable_apis)]
53+
# [wasm_bindgen (catch , method , structural , js_class = "ViewTransition" , js_name = skipTransition)]
54+
#[doc = "The `skipTransition()` method."]
55+
#[doc = ""]
56+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/skipTransition)"]
57+
#[doc = ""]
58+
#[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"]
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 skip_transition(this: &ViewTransition) -> Result<(), JsValue>;
63+
}

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

+6
Original file line numberDiff line numberDiff line change
@@ -8560,6 +8560,12 @@ mod gen_VideoTransferCharacteristics;
85608560
#[cfg(feature = "VideoTransferCharacteristics")]
85618561
pub use gen_VideoTransferCharacteristics::*;
85628562

8563+
#[cfg(feature = "ViewTransition")]
8564+
#[allow(non_snake_case)]
8565+
mod gen_ViewTransition;
8566+
#[cfg(feature = "ViewTransition")]
8567+
pub use gen_ViewTransition::*;
8568+
85638569
#[cfg(feature = "VisibilityState")]
85648570
#[allow(non_snake_case)]
85658571
mod gen_VisibilityState;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
partial interface Document {
2+
[Throws]
3+
ViewTransition startViewTransition(optional UpdateCallback? updateCallback = null);
4+
};
5+
6+
callback UpdateCallback = Promise<any> ();
7+
8+
[Exposed=Window]
9+
interface ViewTransition {
10+
readonly attribute Promise<undefined> updateCallbackDone;
11+
readonly attribute Promise<undefined> ready;
12+
readonly attribute Promise<undefined> finished;
13+
[Throws]
14+
undefined skipTransition();
15+
};

0 commit comments

Comments
 (0)