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
use super::*;
/// The ServiceWorkerContainer class.
/// [`ServiceWorkerContainer`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct ServiceWorkerContainer {
inner: EventTarget,
}
impl FromVal for ServiceWorkerContainer {
fn from_val(v: &Any) -> Self {
ServiceWorkerContainer {
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 ServiceWorkerContainer {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for ServiceWorkerContainer {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for ServiceWorkerContainer {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for ServiceWorkerContainer {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<ServiceWorkerContainer> for Any {
fn from(s: ServiceWorkerContainer) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&ServiceWorkerContainer> for Any {
fn from(s: &ServiceWorkerContainer) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(ServiceWorkerContainer);
impl ServiceWorkerContainer {
/// Getter of the `controller` attribute.
/// [`ServiceWorkerContainer.controller`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller)
pub fn controller(&self) -> ServiceWorker {
self.inner.get("controller").as_::<ServiceWorker>()
}
}
impl ServiceWorkerContainer {
/// Getter of the `ready` attribute.
/// [`ServiceWorkerContainer.ready`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/ready)
pub fn ready(&self) -> Promise<ServiceWorkerRegistration> {
self.inner
.get("ready")
.as_::<Promise<ServiceWorkerRegistration>>()
}
}
impl ServiceWorkerContainer {
/// Getter of the `oncontrollerchange` attribute.
/// [`ServiceWorkerContainer.oncontrollerchange`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange)
pub fn oncontrollerchange(&self) -> Any {
self.inner.get("oncontrollerchange").as_::<Any>()
}
/// Setter of the `oncontrollerchange` attribute.
/// [`ServiceWorkerContainer.oncontrollerchange`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange)
pub fn set_oncontrollerchange(&mut self, value: &Any) {
self.inner.set("oncontrollerchange", value);
}
}
impl ServiceWorkerContainer {
/// Getter of the `onmessage` attribute.
/// [`ServiceWorkerContainer.onmessage`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onmessage)
pub fn onmessage(&self) -> Any {
self.inner.get("onmessage").as_::<Any>()
}
/// Setter of the `onmessage` attribute.
/// [`ServiceWorkerContainer.onmessage`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onmessage)
pub fn set_onmessage(&mut self, value: &Any) {
self.inner.set("onmessage", value);
}
}
impl ServiceWorkerContainer {
/// Getter of the `onmessageerror` attribute.
/// [`ServiceWorkerContainer.onmessageerror`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onmessageerror)
pub fn onmessageerror(&self) -> Any {
self.inner.get("onmessageerror").as_::<Any>()
}
/// Setter of the `onmessageerror` attribute.
/// [`ServiceWorkerContainer.onmessageerror`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onmessageerror)
pub fn set_onmessageerror(&mut self, value: &Any) {
self.inner.set("onmessageerror", value);
}
}
impl ServiceWorkerContainer {
/// The register method.
/// [`ServiceWorkerContainer.register`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register)
pub fn register(&self, script_url: &Any) -> Promise<ServiceWorkerRegistration> {
self.inner
.call("register", &[script_url.into()])
.as_::<Promise<ServiceWorkerRegistration>>()
}
}
impl ServiceWorkerContainer {
/// The register method.
/// [`ServiceWorkerContainer.register`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register)
pub fn register_with_options(
&self,
script_url: &Any,
options: &RegistrationOptions,
) -> Promise<ServiceWorkerRegistration> {
self.inner
.call("register", &[script_url.into(), options.into()])
.as_::<Promise<ServiceWorkerRegistration>>()
}
}
impl ServiceWorkerContainer {
/// The getRegistration method.
/// [`ServiceWorkerContainer.getRegistration`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/getRegistration)
pub fn get_registration(&self) -> Promise<Any> {
self.inner
.call("getRegistration", &[])
.as_::<Promise<Any>>()
}
}
impl ServiceWorkerContainer {
/// The getRegistration method.
/// [`ServiceWorkerContainer.getRegistration`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/getRegistration)
pub fn get_registration_with_client_url(&self, client_url: &JsString) -> Promise<Any> {
self.inner
.call("getRegistration", &[client_url.into()])
.as_::<Promise<Any>>()
}
}
impl ServiceWorkerContainer {
/// The getRegistrations method.
/// [`ServiceWorkerContainer.getRegistrations`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/getRegistrations)
pub fn get_registrations(&self) -> Promise<TypedArray<ServiceWorkerRegistration>> {
self.inner
.call("getRegistrations", &[])
.as_::<Promise<TypedArray<ServiceWorkerRegistration>>>()
}
}
impl ServiceWorkerContainer {
/// The startMessages method.
/// [`ServiceWorkerContainer.startMessages`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/startMessages)
pub fn start_messages(&self) -> Undefined {
self.inner.call("startMessages", &[]).as_::<Undefined>()
}
}