browser_protocol/serviceworker/
mod.rs1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3
4
5pub type RegistrationID = String;
6
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
10#[serde(rename_all = "camelCase")]
11pub struct ServiceWorkerRegistration {
12
13 pub registrationId: RegistrationID,
14
15 pub scopeURL: String,
16
17 pub isDeleted: bool,
18}
19
20
21#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
22pub enum ServiceWorkerVersionRunningStatus {
23 #[default]
24 Stopped,
25 Starting,
26 Running,
27 Stopping,
28}
29
30
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
32pub enum ServiceWorkerVersionStatus {
33 #[default]
34 New,
35 Installing,
36 Installed,
37 Activating,
38 Activated,
39 Redundant,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize, Default)]
45#[serde(rename_all = "camelCase")]
46pub struct ServiceWorkerVersion {
47
48 pub versionId: String,
49
50 pub registrationId: RegistrationID,
51
52 pub scriptURL: String,
53
54 pub runningStatus: ServiceWorkerVersionRunningStatus,
55
56 pub status: ServiceWorkerVersionStatus,
57 #[serde(skip_serializing_if = "Option::is_none")]
60 pub scriptLastModified: Option<f64>,
61 #[serde(skip_serializing_if = "Option::is_none")]
65 pub scriptResponseTime: Option<f64>,
66
67 #[serde(skip_serializing_if = "Option::is_none")]
68 pub controlledClients: Option<Vec<crate::target::TargetID>>,
69
70 #[serde(skip_serializing_if = "Option::is_none")]
71 pub targetId: Option<crate::target::TargetID>,
72
73 #[serde(skip_serializing_if = "Option::is_none")]
74 pub routerRules: Option<String>,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize, Default)]
80#[serde(rename_all = "camelCase")]
81pub struct ServiceWorkerErrorMessage {
82
83 pub errorMessage: String,
84
85 pub registrationId: RegistrationID,
86
87 pub versionId: String,
88
89 pub sourceURL: String,
90
91 pub lineNumber: i64,
92
93 pub columnNumber: i64,
94}
95
96
97#[derive(Debug, Clone, Serialize, Deserialize, Default)]
98#[serde(rename_all = "camelCase")]
99pub struct DeliverPushMessageParams {
100
101 pub origin: String,
102
103 pub registrationId: RegistrationID,
104
105 pub data: String,
106}
107
108impl DeliverPushMessageParams { pub const METHOD: &'static str = "ServiceWorker.deliverPushMessage"; }
109
110impl crate::CdpCommand for DeliverPushMessageParams {
111 const METHOD: &'static str = "ServiceWorker.deliverPushMessage";
112 type Response = crate::EmptyReturns;
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize, Default)]
116pub struct DisableParams {}
117
118impl DisableParams { pub const METHOD: &'static str = "ServiceWorker.disable"; }
119
120impl crate::CdpCommand for DisableParams {
121 const METHOD: &'static str = "ServiceWorker.disable";
122 type Response = crate::EmptyReturns;
123}
124
125
126#[derive(Debug, Clone, Serialize, Deserialize, Default)]
127#[serde(rename_all = "camelCase")]
128pub struct DispatchSyncEventParams {
129
130 pub origin: String,
131
132 pub registrationId: RegistrationID,
133
134 pub tag: String,
135
136 pub lastChance: bool,
137}
138
139impl DispatchSyncEventParams { pub const METHOD: &'static str = "ServiceWorker.dispatchSyncEvent"; }
140
141impl crate::CdpCommand for DispatchSyncEventParams {
142 const METHOD: &'static str = "ServiceWorker.dispatchSyncEvent";
143 type Response = crate::EmptyReturns;
144}
145
146
147#[derive(Debug, Clone, Serialize, Deserialize, Default)]
148#[serde(rename_all = "camelCase")]
149pub struct DispatchPeriodicSyncEventParams {
150
151 pub origin: String,
152
153 pub registrationId: RegistrationID,
154
155 pub tag: String,
156}
157
158impl DispatchPeriodicSyncEventParams { pub const METHOD: &'static str = "ServiceWorker.dispatchPeriodicSyncEvent"; }
159
160impl crate::CdpCommand for DispatchPeriodicSyncEventParams {
161 const METHOD: &'static str = "ServiceWorker.dispatchPeriodicSyncEvent";
162 type Response = crate::EmptyReturns;
163}
164
165#[derive(Debug, Clone, Serialize, Deserialize, Default)]
166pub struct EnableParams {}
167
168impl EnableParams { pub const METHOD: &'static str = "ServiceWorker.enable"; }
169
170impl crate::CdpCommand for EnableParams {
171 const METHOD: &'static str = "ServiceWorker.enable";
172 type Response = crate::EmptyReturns;
173}
174
175
176#[derive(Debug, Clone, Serialize, Deserialize, Default)]
177#[serde(rename_all = "camelCase")]
178pub struct SetForceUpdateOnPageLoadParams {
179
180 pub forceUpdateOnPageLoad: bool,
181}
182
183impl SetForceUpdateOnPageLoadParams { pub const METHOD: &'static str = "ServiceWorker.setForceUpdateOnPageLoad"; }
184
185impl crate::CdpCommand for SetForceUpdateOnPageLoadParams {
186 const METHOD: &'static str = "ServiceWorker.setForceUpdateOnPageLoad";
187 type Response = crate::EmptyReturns;
188}
189
190
191#[derive(Debug, Clone, Serialize, Deserialize, Default)]
192#[serde(rename_all = "camelCase")]
193pub struct SkipWaitingParams {
194
195 pub scopeURL: String,
196}
197
198impl SkipWaitingParams { pub const METHOD: &'static str = "ServiceWorker.skipWaiting"; }
199
200impl crate::CdpCommand for SkipWaitingParams {
201 const METHOD: &'static str = "ServiceWorker.skipWaiting";
202 type Response = crate::EmptyReturns;
203}
204
205
206#[derive(Debug, Clone, Serialize, Deserialize, Default)]
207#[serde(rename_all = "camelCase")]
208pub struct StartWorkerParams {
209
210 pub scopeURL: String,
211}
212
213impl StartWorkerParams { pub const METHOD: &'static str = "ServiceWorker.startWorker"; }
214
215impl crate::CdpCommand for StartWorkerParams {
216 const METHOD: &'static str = "ServiceWorker.startWorker";
217 type Response = crate::EmptyReturns;
218}
219
220#[derive(Debug, Clone, Serialize, Deserialize, Default)]
221pub struct StopAllWorkersParams {}
222
223impl StopAllWorkersParams { pub const METHOD: &'static str = "ServiceWorker.stopAllWorkers"; }
224
225impl crate::CdpCommand for StopAllWorkersParams {
226 const METHOD: &'static str = "ServiceWorker.stopAllWorkers";
227 type Response = crate::EmptyReturns;
228}
229
230
231#[derive(Debug, Clone, Serialize, Deserialize, Default)]
232#[serde(rename_all = "camelCase")]
233pub struct StopWorkerParams {
234
235 pub versionId: String,
236}
237
238impl StopWorkerParams { pub const METHOD: &'static str = "ServiceWorker.stopWorker"; }
239
240impl crate::CdpCommand for StopWorkerParams {
241 const METHOD: &'static str = "ServiceWorker.stopWorker";
242 type Response = crate::EmptyReturns;
243}
244
245
246#[derive(Debug, Clone, Serialize, Deserialize, Default)]
247#[serde(rename_all = "camelCase")]
248pub struct UnregisterParams {
249
250 pub scopeURL: String,
251}
252
253impl UnregisterParams { pub const METHOD: &'static str = "ServiceWorker.unregister"; }
254
255impl crate::CdpCommand for UnregisterParams {
256 const METHOD: &'static str = "ServiceWorker.unregister";
257 type Response = crate::EmptyReturns;
258}
259
260
261#[derive(Debug, Clone, Serialize, Deserialize, Default)]
262#[serde(rename_all = "camelCase")]
263pub struct UpdateRegistrationParams {
264
265 pub scopeURL: String,
266}
267
268impl UpdateRegistrationParams { pub const METHOD: &'static str = "ServiceWorker.updateRegistration"; }
269
270impl crate::CdpCommand for UpdateRegistrationParams {
271 const METHOD: &'static str = "ServiceWorker.updateRegistration";
272 type Response = crate::EmptyReturns;
273}