Skip to content

Commit e7361d8

Browse files
committed
Generate Clipboard APIs
1 parent 1d84a84 commit e7361d8

10 files changed

+405
-16
lines changed

crates/web-sys/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ ClientQueryOptions = []
151151
ClientRectsAndTexts = []
152152
ClientType = []
153153
Clients = []
154+
Clipboard = ["EventTarget"]
154155
ClipboardEvent = ["Event"]
155156
ClipboardEventInit = []
157+
ClipboardItem = []
158+
ClipboardItemOptions = []
159+
ClipboardPermissionDescriptor = []
156160
CloseEvent = ["Event"]
157161
CloseEventInit = []
158162
CollectedClientData = []
@@ -835,6 +839,7 @@ PresentationConnectionList = ["EventTarget"]
835839
PresentationConnectionState = []
836840
PresentationReceiver = []
837841
PresentationRequest = ["EventTarget"]
842+
PresentationStyle = []
838843
ProcessingInstruction = ["CharacterData", "EventTarget", "Node"]
839844
ProfileTimelineLayerRect = []
840845
ProfileTimelineMarker = []
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 = Clipboard , typescript_type = "Clipboard" ) ]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `Clipboard` class."]
10+
#[doc = ""]
11+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard)"]
12+
#[doc = ""]
13+
#[doc = "*This API requires the following crate features to be activated: `Clipboard`*"]
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 Clipboard;
18+
#[cfg(web_sys_unstable_apis)]
19+
# [ wasm_bindgen ( method , structural , js_class = "Clipboard" , js_name = read ) ]
20+
#[doc = "The `read()` method."]
21+
#[doc = ""]
22+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/read)"]
23+
#[doc = ""]
24+
#[doc = "*This API requires the following crate features to be activated: `Clipboard`*"]
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 read(this: &Clipboard) -> ::js_sys::Promise;
29+
#[cfg(web_sys_unstable_apis)]
30+
# [ wasm_bindgen ( method , structural , js_class = "Clipboard" , js_name = readText ) ]
31+
#[doc = "The `readText()` method."]
32+
#[doc = ""]
33+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText)"]
34+
#[doc = ""]
35+
#[doc = "*This API requires the following crate features to be activated: `Clipboard`*"]
36+
#[doc = ""]
37+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
38+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
39+
pub fn read_text(this: &Clipboard) -> ::js_sys::Promise;
40+
#[cfg(web_sys_unstable_apis)]
41+
# [ wasm_bindgen ( method , structural , js_class = "Clipboard" , js_name = write ) ]
42+
#[doc = "The `write()` method."]
43+
#[doc = ""]
44+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write)"]
45+
#[doc = ""]
46+
#[doc = "*This API requires the following crate features to be activated: `Clipboard`*"]
47+
#[doc = ""]
48+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
49+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
50+
pub fn write(this: &Clipboard, data: &::wasm_bindgen::JsValue) -> ::js_sys::Promise;
51+
#[cfg(web_sys_unstable_apis)]
52+
# [ wasm_bindgen ( method , structural , js_class = "Clipboard" , js_name = writeText ) ]
53+
#[doc = "The `writeText()` method."]
54+
#[doc = ""]
55+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText)"]
56+
#[doc = ""]
57+
#[doc = "*This API requires the following crate features to be activated: `Clipboard`*"]
58+
#[doc = ""]
59+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
60+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
61+
pub fn write_text(this: &Clipboard, data: &str) -> ::js_sys::Promise;
62+
}

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(unused_imports)]
22
use super::*;
33
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
45
#[wasm_bindgen]
56
extern "C" {
67
# [ wasm_bindgen ( extends = Event , extends = :: js_sys :: Object , js_name = ClipboardEvent , typescript_type = "ClipboardEvent" ) ]
@@ -10,29 +11,82 @@ extern "C" {
1011
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent)"]
1112
#[doc = ""]
1213
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`*"]
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)*"]
1317
pub type ClipboardEvent;
18+
#[cfg(web_sys_unstable_apis)]
1419
#[cfg(feature = "DataTransfer")]
1520
# [ wasm_bindgen ( structural , method , getter , js_class = "ClipboardEvent" , js_name = clipboardData ) ]
1621
#[doc = "Getter for the `clipboardData` field of this object."]
1722
#[doc = ""]
1823
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/clipboardData)"]
1924
#[doc = ""]
2025
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`, `DataTransfer`*"]
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)*"]
2129
pub fn clipboard_data(this: &ClipboardEvent) -> Option<DataTransfer>;
30+
#[cfg(web_sys_unstable_apis)]
31+
#[cfg(feature = "DataTransfer")]
32+
# [ wasm_bindgen ( structural , method , getter , js_class = "ClipboardEvent" , js_name = clipboardData ) ]
33+
#[doc = "Getter for the `clipboardData` field of this object."]
34+
#[doc = ""]
35+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/clipboardData)"]
36+
#[doc = ""]
37+
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`, `DataTransfer`*"]
38+
#[doc = ""]
39+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
40+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
41+
pub fn clipboard_data(this: &ClipboardEvent) -> Option<DataTransfer>;
42+
#[cfg(web_sys_unstable_apis)]
2243
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
2344
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
2445
#[doc = ""]
2546
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
2647
#[doc = ""]
2748
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`*"]
49+
#[doc = ""]
50+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
51+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
2852
pub fn new(type_: &str) -> Result<ClipboardEvent, JsValue>;
53+
#[cfg(web_sys_unstable_apis)]
2954
#[cfg(feature = "ClipboardEventInit")]
3055
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
3156
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
3257
#[doc = ""]
3358
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
3459
#[doc = ""]
3560
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`, `ClipboardEventInit`*"]
61+
#[doc = ""]
62+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
63+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
64+
pub fn new_with_event_init_dict(
65+
type_: &str,
66+
event_init_dict: &ClipboardEventInit,
67+
) -> Result<ClipboardEvent, JsValue>;
68+
#[cfg(web_sys_unstable_apis)]
69+
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
70+
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
71+
#[doc = ""]
72+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
73+
#[doc = ""]
74+
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`*"]
75+
#[doc = ""]
76+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
77+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
78+
pub fn new(type_: &str) -> Result<ClipboardEvent, JsValue>;
79+
#[cfg(web_sys_unstable_apis)]
80+
#[cfg(feature = "ClipboardEventInit")]
81+
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
82+
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
83+
#[doc = ""]
84+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
85+
#[doc = ""]
86+
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`, `ClipboardEventInit`*"]
87+
#[doc = ""]
88+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
89+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
3690
pub fn new_with_event_init_dict(
3791
type_: &str,
3892
event_init_dict: &ClipboardEventInit,

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

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
#![allow(unused_imports)]
22
use super::*;
33
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
45
#[wasm_bindgen]
56
extern "C" {
67
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = ClipboardEventInit ) ]
78
#[derive(Debug, Clone, PartialEq, Eq)]
89
#[doc = "The `ClipboardEventInit` dictionary."]
910
#[doc = ""]
1011
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`*"]
12+
#[doc = ""]
13+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
14+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
1115
pub type ClipboardEventInit;
1216
}
17+
#[cfg(web_sys_unstable_apis)]
1318
impl ClipboardEventInit {
1419
#[doc = "Construct a new `ClipboardEventInit`."]
1520
#[doc = ""]
1621
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`*"]
22+
#[doc = ""]
23+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
24+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
1725
pub fn new() -> Self {
1826
#[allow(unused_mut)]
1927
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
2028
ret
2129
}
30+
#[cfg(web_sys_unstable_apis)]
2231
#[doc = "Change the `bubbles` field of this object."]
2332
#[doc = ""]
2433
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`*"]
34+
#[doc = ""]
35+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
36+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
2537
pub fn bubbles(&mut self, val: bool) -> &mut Self {
2638
use wasm_bindgen::JsValue;
2739
let r = ::js_sys::Reflect::set(
@@ -36,9 +48,13 @@ impl ClipboardEventInit {
3648
let _ = r;
3749
self
3850
}
51+
#[cfg(web_sys_unstable_apis)]
3952
#[doc = "Change the `cancelable` field of this object."]
4053
#[doc = ""]
4154
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`*"]
55+
#[doc = ""]
56+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
57+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
4258
pub fn cancelable(&mut self, val: bool) -> &mut Self {
4359
use wasm_bindgen::JsValue;
4460
let r = ::js_sys::Reflect::set(
@@ -53,9 +69,13 @@ impl ClipboardEventInit {
5369
let _ = r;
5470
self
5571
}
72+
#[cfg(web_sys_unstable_apis)]
5673
#[doc = "Change the `composed` field of this object."]
5774
#[doc = ""]
5875
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`*"]
76+
#[doc = ""]
77+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
78+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
5979
pub fn composed(&mut self, val: bool) -> &mut Self {
6080
use wasm_bindgen::JsValue;
6181
let r = ::js_sys::Reflect::set(
@@ -70,27 +90,19 @@ impl ClipboardEventInit {
7090
let _ = r;
7191
self
7292
}
73-
#[doc = "Change the `data` field of this object."]
93+
#[cfg(web_sys_unstable_apis)]
94+
#[cfg(feature = "DataTransfer")]
95+
#[doc = "Change the `clipboardData` field of this object."]
7496
#[doc = ""]
75-
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`*"]
76-
pub fn data(&mut self, val: &str) -> &mut Self {
77-
use wasm_bindgen::JsValue;
78-
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("data"), &JsValue::from(val));
79-
debug_assert!(
80-
r.is_ok(),
81-
"setting properties should never fail on our dictionary objects"
82-
);
83-
let _ = r;
84-
self
85-
}
86-
#[doc = "Change the `dataType` field of this object."]
97+
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`, `DataTransfer`*"]
8798
#[doc = ""]
88-
#[doc = "*This API requires the following crate features to be activated: `ClipboardEventInit`*"]
89-
pub fn data_type(&mut self, val: &str) -> &mut Self {
99+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
100+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
101+
pub fn clipboard_data(&mut self, val: Option<&DataTransfer>) -> &mut Self {
90102
use wasm_bindgen::JsValue;
91103
let r = ::js_sys::Reflect::set(
92104
self.as_ref(),
93-
&JsValue::from("dataType"),
105+
&JsValue::from("clipboardData"),
94106
&JsValue::from(val),
95107
);
96108
debug_assert!(
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 = ClipboardItem , typescript_type = "ClipboardItem" ) ]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `ClipboardItem` class."]
10+
#[doc = ""]
11+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem)"]
12+
#[doc = ""]
13+
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"]
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 ClipboardItem;
18+
#[cfg(web_sys_unstable_apis)]
19+
#[cfg(feature = "PresentationStyle")]
20+
# [ wasm_bindgen ( structural , method , getter , js_class = "ClipboardItem" , js_name = presentationStyle ) ]
21+
#[doc = "Getter for the `presentationStyle` field of this object."]
22+
#[doc = ""]
23+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/presentationStyle)"]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`, `PresentationStyle`*"]
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 presentation_style(this: &ClipboardItem) -> PresentationStyle;
30+
#[cfg(web_sys_unstable_apis)]
31+
# [ wasm_bindgen ( structural , method , getter , js_class = "ClipboardItem" , js_name = lastModified ) ]
32+
#[doc = "Getter for the `lastModified` field of this object."]
33+
#[doc = ""]
34+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/lastModified)"]
35+
#[doc = ""]
36+
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"]
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 last_modified(this: &ClipboardItem) -> f64;
41+
#[cfg(web_sys_unstable_apis)]
42+
# [ wasm_bindgen ( structural , method , getter , js_class = "ClipboardItem" , js_name = delayed ) ]
43+
#[doc = "Getter for the `delayed` field of this object."]
44+
#[doc = ""]
45+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/delayed)"]
46+
#[doc = ""]
47+
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"]
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 delayed(this: &ClipboardItem) -> bool;
52+
#[cfg(web_sys_unstable_apis)]
53+
# [ wasm_bindgen ( method , structural , js_class = "ClipboardItem" , js_name = getType ) ]
54+
#[doc = "The `getType()` method."]
55+
#[doc = ""]
56+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/getType)"]
57+
#[doc = ""]
58+
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"]
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 get_type(this: &ClipboardItem, type_: &str) -> ::js_sys::Promise;
63+
}

0 commit comments

Comments
 (0)