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

Updated Notification APIs #3667

Merged
merged 8 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions crates/web-sys/src/features/gen_NotificationAction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = NotificationAction)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `NotificationAction` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub type NotificationAction;
}
impl NotificationAction {
#[doc = "Construct a new `NotificationAction`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn new(action: &str, title: &str) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.action(action);
ret.title(title);
ret
}
#[doc = "Change the `action` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn action(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("action"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `icon` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn icon(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("icon"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `title` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn title(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("title"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
74 changes: 74 additions & 0 deletions crates/web-sys/src/features/gen_NotificationOptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,36 @@ impl NotificationOptions {
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[doc = "Change the `actions` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
pub fn actions(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("actions"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `badge` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
pub fn badge(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("badge"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `body` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
Expand Down Expand Up @@ -73,6 +103,19 @@ impl NotificationOptions {
let _ = r;
self
}
#[doc = "Change the `image` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
pub fn image(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("image"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `lang` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
Expand All @@ -86,6 +129,23 @@ impl NotificationOptions {
let _ = r;
self
}
#[doc = "Change the `renotify` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
pub fn renotify(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("renotify"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `requireInteraction` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
Expand All @@ -103,6 +163,20 @@ impl NotificationOptions {
let _ = r;
self
}
#[doc = "Change the `silent` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
pub fn silent(&mut self, val: Option<bool>) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("silent"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `tag` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"]
Expand Down
6 changes: 6 additions & 0 deletions crates/web-sys/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5092,6 +5092,12 @@ mod gen_Notification;
#[cfg(feature = "Notification")]
pub use gen_Notification::*;

#[cfg(feature = "NotificationAction")]
#[allow(non_snake_case)]
mod gen_NotificationAction;
#[cfg(feature = "NotificationAction")]
pub use gen_NotificationAction::*;

#[cfg(feature = "NotificationBehavior")]
#[allow(non_snake_case)]
mod gen_NotificationBehavior;
Expand Down
13 changes: 12 additions & 1 deletion crates/web-sys/webidls/enabled/Notification.webidl
maccesch marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ dictionary NotificationOptions {
DOMString lang = "";
DOMString body = "";
DOMString tag = "";
DOMString icon = "";
USVString image;
USVString icon;
USVString badge;
boolean renotify = false;
boolean? silent = null;
boolean requireInteraction = false;
any data = null;
sequence<NotificationAction> actions = [];
};

dictionary GetNotificationOptions {
Expand All @@ -87,6 +92,12 @@ enum NotificationPermission {
"granted"
};

dictionary NotificationAction {
required DOMString action;
required DOMString title;
USVString icon;
};

callback NotificationPermissionCallback = undefined (NotificationPermission permission);

enum NotificationDirection {
Expand Down