File: serviceworker.go

package info (click to toggle)
golang-github-chromedp-cdproto 0.0~git20230109.6b041c6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,584 kB
  • sloc: makefile: 2
file content (326 lines) | stat: -rw-r--r-- 9,712 bytes parent folder | download | duplicates (3)
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
// Package serviceworker provides the Chrome DevTools Protocol
// commands, types, and events for the ServiceWorker domain.
//
// Generated by the cdproto-gen command.
package serviceworker

// Code generated by cdproto-gen. DO NOT EDIT.

import (
	"context"

	"github.com/chromedp/cdproto/cdp"
)

// DeliverPushMessageParams [no description].
type DeliverPushMessageParams struct {
	Origin         string         `json:"origin"`
	RegistrationID RegistrationID `json:"registrationId"`
	Data           string         `json:"data"`
}

// DeliverPushMessage [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-deliverPushMessage
//
// parameters:
//
//	origin
//	registrationID
//	data
func DeliverPushMessage(origin string, registrationID RegistrationID, data string) *DeliverPushMessageParams {
	return &DeliverPushMessageParams{
		Origin:         origin,
		RegistrationID: registrationID,
		Data:           data,
	}
}

// Do executes ServiceWorker.deliverPushMessage against the provided context.
func (p *DeliverPushMessageParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandDeliverPushMessage, p, nil)
}

// DisableParams [no description].
type DisableParams struct{}

// Disable [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-disable
func Disable() *DisableParams {
	return &DisableParams{}
}

// Do executes ServiceWorker.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandDisable, nil, nil)
}

// DispatchSyncEventParams [no description].
type DispatchSyncEventParams struct {
	Origin         string         `json:"origin"`
	RegistrationID RegistrationID `json:"registrationId"`
	Tag            string         `json:"tag"`
	LastChance     bool           `json:"lastChance"`
}

// DispatchSyncEvent [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-dispatchSyncEvent
//
// parameters:
//
//	origin
//	registrationID
//	tag
//	lastChance
func DispatchSyncEvent(origin string, registrationID RegistrationID, tag string, lastChance bool) *DispatchSyncEventParams {
	return &DispatchSyncEventParams{
		Origin:         origin,
		RegistrationID: registrationID,
		Tag:            tag,
		LastChance:     lastChance,
	}
}

// Do executes ServiceWorker.dispatchSyncEvent against the provided context.
func (p *DispatchSyncEventParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandDispatchSyncEvent, p, nil)
}

// DispatchPeriodicSyncEventParams [no description].
type DispatchPeriodicSyncEventParams struct {
	Origin         string         `json:"origin"`
	RegistrationID RegistrationID `json:"registrationId"`
	Tag            string         `json:"tag"`
}

// DispatchPeriodicSyncEvent [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-dispatchPeriodicSyncEvent
//
// parameters:
//
//	origin
//	registrationID
//	tag
func DispatchPeriodicSyncEvent(origin string, registrationID RegistrationID, tag string) *DispatchPeriodicSyncEventParams {
	return &DispatchPeriodicSyncEventParams{
		Origin:         origin,
		RegistrationID: registrationID,
		Tag:            tag,
	}
}

// Do executes ServiceWorker.dispatchPeriodicSyncEvent against the provided context.
func (p *DispatchPeriodicSyncEventParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandDispatchPeriodicSyncEvent, p, nil)
}

// EnableParams [no description].
type EnableParams struct{}

// Enable [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-enable
func Enable() *EnableParams {
	return &EnableParams{}
}

// Do executes ServiceWorker.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandEnable, nil, nil)
}

// InspectWorkerParams [no description].
type InspectWorkerParams struct {
	VersionID string `json:"versionId"`
}

// InspectWorker [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-inspectWorker
//
// parameters:
//
//	versionID
func InspectWorker(versionID string) *InspectWorkerParams {
	return &InspectWorkerParams{
		VersionID: versionID,
	}
}

// Do executes ServiceWorker.inspectWorker against the provided context.
func (p *InspectWorkerParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandInspectWorker, p, nil)
}

// SetForceUpdateOnPageLoadParams [no description].
type SetForceUpdateOnPageLoadParams struct {
	ForceUpdateOnPageLoad bool `json:"forceUpdateOnPageLoad"`
}

// SetForceUpdateOnPageLoad [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-setForceUpdateOnPageLoad
//
// parameters:
//
//	forceUpdateOnPageLoad
func SetForceUpdateOnPageLoad(forceUpdateOnPageLoad bool) *SetForceUpdateOnPageLoadParams {
	return &SetForceUpdateOnPageLoadParams{
		ForceUpdateOnPageLoad: forceUpdateOnPageLoad,
	}
}

// Do executes ServiceWorker.setForceUpdateOnPageLoad against the provided context.
func (p *SetForceUpdateOnPageLoadParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandSetForceUpdateOnPageLoad, p, nil)
}

// SkipWaitingParams [no description].
type SkipWaitingParams struct {
	ScopeURL string `json:"scopeURL"`
}

// SkipWaiting [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-skipWaiting
//
// parameters:
//
//	scopeURL
func SkipWaiting(scopeURL string) *SkipWaitingParams {
	return &SkipWaitingParams{
		ScopeURL: scopeURL,
	}
}

// Do executes ServiceWorker.skipWaiting against the provided context.
func (p *SkipWaitingParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandSkipWaiting, p, nil)
}

// StartWorkerParams [no description].
type StartWorkerParams struct {
	ScopeURL string `json:"scopeURL"`
}

// StartWorker [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-startWorker
//
// parameters:
//
//	scopeURL
func StartWorker(scopeURL string) *StartWorkerParams {
	return &StartWorkerParams{
		ScopeURL: scopeURL,
	}
}

// Do executes ServiceWorker.startWorker against the provided context.
func (p *StartWorkerParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandStartWorker, p, nil)
}

// StopAllWorkersParams [no description].
type StopAllWorkersParams struct{}

// StopAllWorkers [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-stopAllWorkers
func StopAllWorkers() *StopAllWorkersParams {
	return &StopAllWorkersParams{}
}

// Do executes ServiceWorker.stopAllWorkers against the provided context.
func (p *StopAllWorkersParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandStopAllWorkers, nil, nil)
}

// StopWorkerParams [no description].
type StopWorkerParams struct {
	VersionID string `json:"versionId"`
}

// StopWorker [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-stopWorker
//
// parameters:
//
//	versionID
func StopWorker(versionID string) *StopWorkerParams {
	return &StopWorkerParams{
		VersionID: versionID,
	}
}

// Do executes ServiceWorker.stopWorker against the provided context.
func (p *StopWorkerParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandStopWorker, p, nil)
}

// UnregisterParams [no description].
type UnregisterParams struct {
	ScopeURL string `json:"scopeURL"`
}

// Unregister [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-unregister
//
// parameters:
//
//	scopeURL
func Unregister(scopeURL string) *UnregisterParams {
	return &UnregisterParams{
		ScopeURL: scopeURL,
	}
}

// Do executes ServiceWorker.unregister against the provided context.
func (p *UnregisterParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandUnregister, p, nil)
}

// UpdateRegistrationParams [no description].
type UpdateRegistrationParams struct {
	ScopeURL string `json:"scopeURL"`
}

// UpdateRegistration [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-updateRegistration
//
// parameters:
//
//	scopeURL
func UpdateRegistration(scopeURL string) *UpdateRegistrationParams {
	return &UpdateRegistrationParams{
		ScopeURL: scopeURL,
	}
}

// Do executes ServiceWorker.updateRegistration against the provided context.
func (p *UpdateRegistrationParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandUpdateRegistration, p, nil)
}

// Command names.
const (
	CommandDeliverPushMessage        = "ServiceWorker.deliverPushMessage"
	CommandDisable                   = "ServiceWorker.disable"
	CommandDispatchSyncEvent         = "ServiceWorker.dispatchSyncEvent"
	CommandDispatchPeriodicSyncEvent = "ServiceWorker.dispatchPeriodicSyncEvent"
	CommandEnable                    = "ServiceWorker.enable"
	CommandInspectWorker             = "ServiceWorker.inspectWorker"
	CommandSetForceUpdateOnPageLoad  = "ServiceWorker.setForceUpdateOnPageLoad"
	CommandSkipWaiting               = "ServiceWorker.skipWaiting"
	CommandStartWorker               = "ServiceWorker.startWorker"
	CommandStopAllWorkers            = "ServiceWorker.stopAllWorkers"
	CommandStopWorker                = "ServiceWorker.stopWorker"
	CommandUnregister                = "ServiceWorker.unregister"
	CommandUpdateRegistration        = "ServiceWorker.updateRegistration"
)