1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
use super::*;
/// The ServiceWorkerRegistration class.
/// [`ServiceWorkerRegistration`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct ServiceWorkerRegistration {
inner: EventTarget,
}
impl FromVal for ServiceWorkerRegistration {
fn from_val(v: &Any) -> Self {
ServiceWorkerRegistration {
inner: EventTarget::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for ServiceWorkerRegistration {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for ServiceWorkerRegistration {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for ServiceWorkerRegistration {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for ServiceWorkerRegistration {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<ServiceWorkerRegistration> for Any {
fn from(s: ServiceWorkerRegistration) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&ServiceWorkerRegistration> for Any {
fn from(s: &ServiceWorkerRegistration) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(ServiceWorkerRegistration);
impl ServiceWorkerRegistration {
/// Getter of the `installing` attribute.
/// [`ServiceWorkerRegistration.installing`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/installing)
pub fn installing(&self) -> ServiceWorker {
self.inner.get("installing").as_::<ServiceWorker>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `waiting` attribute.
/// [`ServiceWorkerRegistration.waiting`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/waiting)
pub fn waiting(&self) -> ServiceWorker {
self.inner.get("waiting").as_::<ServiceWorker>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `active` attribute.
/// [`ServiceWorkerRegistration.active`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/active)
pub fn active(&self) -> ServiceWorker {
self.inner.get("active").as_::<ServiceWorker>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `navigationPreload` attribute.
/// [`ServiceWorkerRegistration.navigationPreload`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/navigationPreload)
pub fn navigation_preload(&self) -> NavigationPreloadManager {
self.inner
.get("navigationPreload")
.as_::<NavigationPreloadManager>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `scope` attribute.
/// [`ServiceWorkerRegistration.scope`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/scope)
pub fn scope(&self) -> JsString {
self.inner.get("scope").as_::<JsString>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `updateViaCache` attribute.
/// [`ServiceWorkerRegistration.updateViaCache`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/updateViaCache)
pub fn update_via_cache(&self) -> ServiceWorkerUpdateViaCache {
self.inner
.get("updateViaCache")
.as_::<ServiceWorkerUpdateViaCache>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `onupdatefound` attribute.
/// [`ServiceWorkerRegistration.onupdatefound`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/onupdatefound)
pub fn onupdatefound(&self) -> Any {
self.inner.get("onupdatefound").as_::<Any>()
}
/// Setter of the `onupdatefound` attribute.
/// [`ServiceWorkerRegistration.onupdatefound`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/onupdatefound)
pub fn set_onupdatefound(&mut self, value: &Any) {
self.inner.set("onupdatefound", value);
}
}
impl ServiceWorkerRegistration {
/// Getter of the `backgroundFetch` attribute.
/// [`ServiceWorkerRegistration.backgroundFetch`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/backgroundFetch)
pub fn background_fetch(&self) -> BackgroundFetchManager {
self.inner
.get("backgroundFetch")
.as_::<BackgroundFetchManager>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `sync` attribute.
/// [`ServiceWorkerRegistration.sync`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/sync)
pub fn sync(&self) -> SyncManager {
self.inner.get("sync").as_::<SyncManager>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `index` attribute.
/// [`ServiceWorkerRegistration.index`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/index)
pub fn index(&self) -> ContentIndex {
self.inner.get("index").as_::<ContentIndex>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `cookies` attribute.
/// [`ServiceWorkerRegistration.cookies`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/cookies)
pub fn cookies(&self) -> CookieStoreManager {
self.inner.get("cookies").as_::<CookieStoreManager>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `paymentManager` attribute.
/// [`ServiceWorkerRegistration.paymentManager`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/paymentManager)
pub fn payment_manager(&self) -> PaymentManager {
self.inner.get("paymentManager").as_::<PaymentManager>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `periodicSync` attribute.
/// [`ServiceWorkerRegistration.periodicSync`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/periodicSync)
pub fn periodic_sync(&self) -> PeriodicSyncManager {
self.inner.get("periodicSync").as_::<PeriodicSyncManager>()
}
}
impl ServiceWorkerRegistration {
/// Getter of the `pushManager` attribute.
/// [`ServiceWorkerRegistration.pushManager`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/pushManager)
pub fn push_manager(&self) -> PushManager {
self.inner.get("pushManager").as_::<PushManager>()
}
}
impl ServiceWorkerRegistration {
/// The update method.
/// [`ServiceWorkerRegistration.update`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/update)
pub fn update(&self) -> Promise<ServiceWorkerRegistration> {
self.inner
.call("update", &[])
.as_::<Promise<ServiceWorkerRegistration>>()
}
}
impl ServiceWorkerRegistration {
/// The unregister method.
/// [`ServiceWorkerRegistration.unregister`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/unregister)
pub fn unregister(&self) -> Promise<bool> {
self.inner.call("unregister", &[]).as_::<Promise<bool>>()
}
}
impl ServiceWorkerRegistration {
/// The showNotification method.
/// [`ServiceWorkerRegistration.showNotification`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification)
pub fn show_notification(&self, title: &JsString) -> Promise<Undefined> {
self.inner
.call("showNotification", &[title.into()])
.as_::<Promise<Undefined>>()
}
}
impl ServiceWorkerRegistration {
/// The showNotification method.
/// [`ServiceWorkerRegistration.showNotification`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification)
pub fn show_notification_with_options(
&self,
title: &JsString,
options: &NotificationOptions,
) -> Promise<Undefined> {
self.inner
.call("showNotification", &[title.into(), options.into()])
.as_::<Promise<Undefined>>()
}
}
impl ServiceWorkerRegistration {
/// The getNotifications method.
/// [`ServiceWorkerRegistration.getNotifications`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/getNotifications)
pub fn get_notifications(&self) -> Promise<TypedArray<Notification>> {
self.inner
.call("getNotifications", &[])
.as_::<Promise<TypedArray<Notification>>>()
}
}
impl ServiceWorkerRegistration {
/// The getNotifications method.
/// [`ServiceWorkerRegistration.getNotifications`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/getNotifications)
pub fn get_notifications_with_filter(
&self,
filter: &GetNotificationOptions,
) -> Promise<TypedArray<Notification>> {
self.inner
.call("getNotifications", &[filter.into()])
.as_::<Promise<TypedArray<Notification>>>()
}
}