@angular/service-worker 14.0.0-next.9 → 14.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/index.d.ts +94 -6
- package/esm2020/src/module.mjs +4 -4
- package/esm2020/src/push.mjs +3 -3
- package/esm2020/src/update.mjs +3 -3
- package/fesm2015/config.mjs +1 -1
- package/fesm2015/service-worker.mjs +11 -11
- package/fesm2020/config.mjs +1 -1
- package/fesm2020/service-worker.mjs +11 -11
- package/{service-worker.d.ts → index.d.ts} +465 -464
- package/ngsw-config.js +5 -5
- package/ngsw-worker.js +17 -17
- package/package.json +6 -6
- package/config/config.d.ts +0 -96
- package/config/package.json +0 -9
- package/config/public_api.d.ts +0 -11
- package/config/src/duration.d.ts +0 -9
- package/config/src/filesystem.d.ts +0 -20
- package/config/src/generator.d.ts +0 -27
- package/config/src/glob.d.ts +0 -9
- package/config/src/in.d.ts +0 -62
|
@@ -1,469 +1,470 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.0-
|
|
2
|
+
* @license Angular v14.0.0-rc.2
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
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
|
-
static
|
|
57
|
-
static
|
|
58
|
-
static
|
|
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
|
-
* @see [
|
|
134
|
-
* @see [
|
|
135
|
-
* @see [MDN:
|
|
136
|
-
* @see [MDN:
|
|
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
|
-
private
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
static
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
* `ServiceWorkerModule
|
|
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
|
-
* for
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* - resolves to `
|
|
322
|
-
* -
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
* - resolves to `
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
static
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
7
|
+
|
|
8
|
+
import * as i0 from '@angular/core';
|
|
9
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
10
|
+
import { Observable } from 'rxjs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @publicApi
|
|
14
|
+
*/
|
|
15
|
+
declare class NgswCommChannel {
|
|
16
|
+
private serviceWorker;
|
|
17
|
+
readonly worker: Observable<ServiceWorker>;
|
|
18
|
+
readonly registration: Observable<ServiceWorkerRegistration>;
|
|
19
|
+
readonly events: Observable<TypedEvent>;
|
|
20
|
+
constructor(serviceWorker: ServiceWorkerContainer | undefined);
|
|
21
|
+
postMessage(action: string, payload: Object): Promise<void>;
|
|
22
|
+
postMessageWithOperation(type: string, payload: Object, operationNonce: number): Promise<boolean>;
|
|
23
|
+
generateNonce(): number;
|
|
24
|
+
eventsOfType<T extends TypedEvent>(type: T['type'] | T['type'][]): Observable<T>;
|
|
25
|
+
nextEventOfType<T extends TypedEvent>(type: T['type']): Observable<T>;
|
|
26
|
+
waitForOperationCompleted(nonce: number): Promise<boolean>;
|
|
27
|
+
get isEnabled(): boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* An event emitted when the service worker has checked the version of the app on the server and it
|
|
32
|
+
* didn't find a new version that it doesn't have already downloaded.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
35
|
+
*
|
|
36
|
+
* @publicApi
|
|
37
|
+
*/
|
|
38
|
+
declare interface NoNewVersionDetectedEvent {
|
|
39
|
+
type: 'NO_NEW_VERSION_DETECTED';
|
|
40
|
+
version: {
|
|
41
|
+
hash: string;
|
|
42
|
+
appData?: Object;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @publicApi
|
|
48
|
+
*/
|
|
49
|
+
export declare class ServiceWorkerModule {
|
|
50
|
+
/**
|
|
51
|
+
* Register the given Angular Service Worker script.
|
|
52
|
+
*
|
|
53
|
+
* If `enabled` is set to `false` in the given options, the module will behave as if service
|
|
54
|
+
* workers are not supported by the browser, and the service worker will not be registered.
|
|
55
|
+
*/
|
|
56
|
+
static register(script: string, opts?: SwRegistrationOptions): ModuleWithProviders<ServiceWorkerModule>;
|
|
57
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ServiceWorkerModule, never>;
|
|
58
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ServiceWorkerModule, never, never, never>;
|
|
59
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ServiceWorkerModule>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Subscribe and listen to
|
|
64
|
+
* [Web Push
|
|
65
|
+
* Notifications](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices) through
|
|
66
|
+
* Angular Service Worker.
|
|
67
|
+
*
|
|
68
|
+
* @usageNotes
|
|
69
|
+
*
|
|
70
|
+
* You can inject a `SwPush` instance into any component or service
|
|
71
|
+
* as a dependency.
|
|
72
|
+
*
|
|
73
|
+
* <code-example path="service-worker/push/module.ts" region="inject-sw-push"
|
|
74
|
+
* header="app.component.ts"></code-example>
|
|
75
|
+
*
|
|
76
|
+
* To subscribe, call `SwPush.requestSubscription()`, which asks the user for permission.
|
|
77
|
+
* The call returns a `Promise` with a new
|
|
78
|
+
* [`PushSubscription`](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription)
|
|
79
|
+
* instance.
|
|
80
|
+
*
|
|
81
|
+
* <code-example path="service-worker/push/module.ts" region="subscribe-to-push"
|
|
82
|
+
* header="app.component.ts"></code-example>
|
|
83
|
+
*
|
|
84
|
+
* A request is rejected if the user denies permission, or if the browser
|
|
85
|
+
* blocks or does not support the Push API or ServiceWorkers.
|
|
86
|
+
* Check `SwPush.isEnabled` to confirm status.
|
|
87
|
+
*
|
|
88
|
+
* Invoke Push Notifications by pushing a message with the following payload.
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* {
|
|
92
|
+
* "notification": {
|
|
93
|
+
* "actions": NotificationAction[],
|
|
94
|
+
* "badge": USVString,
|
|
95
|
+
* "body": DOMString,
|
|
96
|
+
* "data": any,
|
|
97
|
+
* "dir": "auto"|"ltr"|"rtl",
|
|
98
|
+
* "icon": USVString,
|
|
99
|
+
* "image": USVString,
|
|
100
|
+
* "lang": DOMString,
|
|
101
|
+
* "renotify": boolean,
|
|
102
|
+
* "requireInteraction": boolean,
|
|
103
|
+
* "silent": boolean,
|
|
104
|
+
* "tag": DOMString,
|
|
105
|
+
* "timestamp": DOMTimeStamp,
|
|
106
|
+
* "title": DOMString,
|
|
107
|
+
* "vibrate": number[]
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* Only `title` is required. See `Notification`
|
|
113
|
+
* [instance
|
|
114
|
+
* properties](https://developer.mozilla.org/en-US/docs/Web/API/Notification#Instance_properties).
|
|
115
|
+
*
|
|
116
|
+
* While the subscription is active, Service Worker listens for
|
|
117
|
+
* [PushEvent](https://developer.mozilla.org/en-US/docs/Web/API/PushEvent)
|
|
118
|
+
* occurrences and creates
|
|
119
|
+
* [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification)
|
|
120
|
+
* instances in response.
|
|
121
|
+
*
|
|
122
|
+
* Unsubscribe using `SwPush.unsubscribe()`.
|
|
123
|
+
*
|
|
124
|
+
* An application can subscribe to `SwPush.notificationClicks` observable to be notified when a user
|
|
125
|
+
* clicks on a notification. For example:
|
|
126
|
+
*
|
|
127
|
+
* <code-example path="service-worker/push/module.ts" region="subscribe-to-notification-clicks"
|
|
128
|
+
* header="app.component.ts"></code-example>
|
|
129
|
+
*
|
|
130
|
+
* You can read more on handling notification clicks in the [Service worker notifications
|
|
131
|
+
* guide](guide/service-worker-notifications).
|
|
132
|
+
*
|
|
133
|
+
* @see [Push Notifications](https://developers.google.com/web/fundamentals/codelabs/push-notifications/)
|
|
134
|
+
* @see [Angular Push Notifications](https://blog.angular-university.io/angular-push-notifications/)
|
|
135
|
+
* @see [MDN: Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API)
|
|
136
|
+
* @see [MDN: Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API)
|
|
137
|
+
* @see [MDN: Web Push API Notifications best practices](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices)
|
|
138
|
+
*
|
|
139
|
+
* @publicApi
|
|
140
|
+
*/
|
|
141
|
+
export declare class SwPush {
|
|
142
|
+
private sw;
|
|
143
|
+
/**
|
|
144
|
+
* Emits the payloads of the received push notification messages.
|
|
145
|
+
*/
|
|
146
|
+
readonly messages: Observable<object>;
|
|
147
|
+
/**
|
|
148
|
+
* Emits the payloads of the received push notification messages as well as the action the user
|
|
149
|
+
* interacted with. If no action was used the `action` property contains an empty string `''`.
|
|
150
|
+
*
|
|
151
|
+
* Note that the `notification` property does **not** contain a
|
|
152
|
+
* [Notification][Mozilla Notification] object but rather a
|
|
153
|
+
* [NotificationOptions](https://notifications.spec.whatwg.org/#dictdef-notificationoptions)
|
|
154
|
+
* object that also includes the `title` of the [Notification][Mozilla Notification] object.
|
|
155
|
+
*
|
|
156
|
+
* [Mozilla Notification]: https://developer.mozilla.org/en-US/docs/Web/API/Notification
|
|
157
|
+
*/
|
|
158
|
+
readonly notificationClicks: Observable<{
|
|
159
|
+
action: string;
|
|
160
|
+
notification: NotificationOptions & {
|
|
161
|
+
title: string;
|
|
162
|
+
};
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Emits the currently active
|
|
166
|
+
* [PushSubscription](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription)
|
|
167
|
+
* associated to the Service Worker registration or `null` if there is no subscription.
|
|
168
|
+
*/
|
|
169
|
+
readonly subscription: Observable<PushSubscription | null>;
|
|
170
|
+
/**
|
|
171
|
+
* True if the Service Worker is enabled (supported by the browser and enabled via
|
|
172
|
+
* `ServiceWorkerModule`).
|
|
173
|
+
*/
|
|
174
|
+
get isEnabled(): boolean;
|
|
175
|
+
private pushManager;
|
|
176
|
+
private subscriptionChanges;
|
|
177
|
+
constructor(sw: NgswCommChannel);
|
|
178
|
+
/**
|
|
179
|
+
* Subscribes to Web Push Notifications,
|
|
180
|
+
* after requesting and receiving user permission.
|
|
181
|
+
*
|
|
182
|
+
* @param options An object containing the `serverPublicKey` string.
|
|
183
|
+
* @returns A Promise that resolves to the new subscription object.
|
|
184
|
+
*/
|
|
185
|
+
requestSubscription(options: {
|
|
186
|
+
serverPublicKey: string;
|
|
187
|
+
}): Promise<PushSubscription>;
|
|
188
|
+
/**
|
|
189
|
+
* Unsubscribes from Service Worker push notifications.
|
|
190
|
+
*
|
|
191
|
+
* @returns A Promise that is resolved when the operation succeeds, or is rejected if there is no
|
|
192
|
+
* active subscription or the unsubscribe operation fails.
|
|
193
|
+
*/
|
|
194
|
+
unsubscribe(): Promise<void>;
|
|
195
|
+
private decodeBase64;
|
|
196
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SwPush, never>;
|
|
197
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SwPush>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Token that can be used to provide options for `ServiceWorkerModule` outside of
|
|
202
|
+
* `ServiceWorkerModule.register()`.
|
|
203
|
+
*
|
|
204
|
+
* You can use this token to define a provider that generates the registration options at runtime,
|
|
205
|
+
* for example via a function call:
|
|
206
|
+
*
|
|
207
|
+
* {@example service-worker/registration-options/module.ts region="registration-options"
|
|
208
|
+
* header="app.module.ts"}
|
|
209
|
+
*
|
|
210
|
+
* @publicApi
|
|
211
|
+
*/
|
|
212
|
+
export declare abstract class SwRegistrationOptions {
|
|
213
|
+
/**
|
|
214
|
+
* Whether the ServiceWorker will be registered and the related services (such as `SwPush` and
|
|
215
|
+
* `SwUpdate`) will attempt to communicate and interact with it.
|
|
216
|
+
*
|
|
217
|
+
* Default: true
|
|
218
|
+
*/
|
|
219
|
+
enabled?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* A URL that defines the ServiceWorker's registration scope; that is, what range of URLs it can
|
|
222
|
+
* control. It will be used when calling
|
|
223
|
+
* [ServiceWorkerContainer#register()](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register).
|
|
224
|
+
*/
|
|
225
|
+
scope?: string;
|
|
226
|
+
/**
|
|
227
|
+
* Defines the ServiceWorker registration strategy, which determines when it will be registered
|
|
228
|
+
* with the browser.
|
|
229
|
+
*
|
|
230
|
+
* The default behavior of registering once the application stabilizes (i.e. as soon as there are
|
|
231
|
+
* no pending micro- and macro-tasks) is designed to register the ServiceWorker as soon as
|
|
232
|
+
* possible but without affecting the application's first time load.
|
|
233
|
+
*
|
|
234
|
+
* Still, there might be cases where you want more control over when the ServiceWorker is
|
|
235
|
+
* registered (for example, there might be a long-running timeout or polling interval, preventing
|
|
236
|
+
* the app from stabilizing). The available option are:
|
|
237
|
+
*
|
|
238
|
+
* - `registerWhenStable:<timeout>`: Register as soon as the application stabilizes (no pending
|
|
239
|
+
* micro-/macro-tasks) but no later than `<timeout>` milliseconds. If the app hasn't
|
|
240
|
+
* stabilized after `<timeout>` milliseconds (for example, due to a recurrent asynchronous
|
|
241
|
+
* task), the ServiceWorker will be registered anyway.
|
|
242
|
+
* If `<timeout>` is omitted, the ServiceWorker will only be registered once the app
|
|
243
|
+
* stabilizes.
|
|
244
|
+
* - `registerImmediately`: Register immediately.
|
|
245
|
+
* - `registerWithDelay:<timeout>`: Register with a delay of `<timeout>` milliseconds. For
|
|
246
|
+
* example, use `registerWithDelay:5000` to register the ServiceWorker after 5 seconds. If
|
|
247
|
+
* `<timeout>` is omitted, is defaults to `0`, which will register the ServiceWorker as soon
|
|
248
|
+
* as possible but still asynchronously, once all pending micro-tasks are completed.
|
|
249
|
+
* - An [Observable](guide/observables) factory function: A function that returns an `Observable`.
|
|
250
|
+
* The function will be used at runtime to obtain and subscribe to the `Observable` and the
|
|
251
|
+
* ServiceWorker will be registered as soon as the first value is emitted.
|
|
252
|
+
*
|
|
253
|
+
* Default: 'registerWhenStable:30000'
|
|
254
|
+
*/
|
|
255
|
+
registrationStrategy?: string | (() => Observable<unknown>);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Subscribe to update notifications from the Service Worker, trigger update
|
|
260
|
+
* checks, and forcibly activate updates.
|
|
261
|
+
*
|
|
262
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
263
|
+
*
|
|
264
|
+
* @publicApi
|
|
265
|
+
*/
|
|
266
|
+
export declare class SwUpdate {
|
|
267
|
+
private sw;
|
|
268
|
+
/**
|
|
269
|
+
* Emits a `VersionDetectedEvent` event whenever a new version is detected on the server.
|
|
270
|
+
*
|
|
271
|
+
* Emits a `VersionInstallationFailedEvent` event whenever checking for or downloading a new
|
|
272
|
+
* version fails.
|
|
273
|
+
*
|
|
274
|
+
* Emits a `VersionReadyEvent` event whenever a new version has been downloaded and is ready for
|
|
275
|
+
* activation.
|
|
276
|
+
*/
|
|
277
|
+
readonly versionUpdates: Observable<VersionEvent>;
|
|
278
|
+
/**
|
|
279
|
+
* Emits an `UpdateAvailableEvent` event whenever a new app version is available.
|
|
280
|
+
*
|
|
281
|
+
* @deprecated Use {@link versionUpdates} instead.
|
|
282
|
+
*
|
|
283
|
+
* The of behavior `available` can be rebuild by filtering for the `VersionReadyEvent`:
|
|
284
|
+
* ```
|
|
285
|
+
* import {filter, map} from 'rxjs/operators';
|
|
286
|
+
* // ...
|
|
287
|
+
* const updatesAvailable = swUpdate.versionUpdates.pipe(
|
|
288
|
+
* filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'),
|
|
289
|
+
* map(evt => ({
|
|
290
|
+
* type: 'UPDATE_AVAILABLE',
|
|
291
|
+
* current: evt.currentVersion,
|
|
292
|
+
* available: evt.latestVersion,
|
|
293
|
+
* })));
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
readonly available: Observable<UpdateAvailableEvent>;
|
|
297
|
+
/**
|
|
298
|
+
* Emits an `UpdateActivatedEvent` event whenever the app has been updated to a new version.
|
|
299
|
+
*
|
|
300
|
+
* @deprecated Use the return value of {@link SwUpdate#activateUpdate} instead.
|
|
301
|
+
*
|
|
302
|
+
*/
|
|
303
|
+
readonly activated: Observable<UpdateActivatedEvent>;
|
|
304
|
+
/**
|
|
305
|
+
* Emits an `UnrecoverableStateEvent` event whenever the version of the app used by the service
|
|
306
|
+
* worker to serve this client is in a broken state that cannot be recovered from without a full
|
|
307
|
+
* page reload.
|
|
308
|
+
*/
|
|
309
|
+
readonly unrecoverable: Observable<UnrecoverableStateEvent>;
|
|
310
|
+
/**
|
|
311
|
+
* True if the Service Worker is enabled (supported by the browser and enabled via
|
|
312
|
+
* `ServiceWorkerModule`).
|
|
313
|
+
*/
|
|
314
|
+
get isEnabled(): boolean;
|
|
315
|
+
constructor(sw: NgswCommChannel);
|
|
316
|
+
/**
|
|
317
|
+
* Checks for an update and waits until the new version is downloaded from the server and ready
|
|
318
|
+
* for activation.
|
|
319
|
+
*
|
|
320
|
+
* @returns a promise that
|
|
321
|
+
* - resolves to `true` if a new version was found and is ready to be activated.
|
|
322
|
+
* - resolves to `false` if no new version was found
|
|
323
|
+
* - rejects if any error occurs
|
|
324
|
+
*/
|
|
325
|
+
checkForUpdate(): Promise<boolean>;
|
|
326
|
+
/**
|
|
327
|
+
* Updates the current client (i.e. browser tab) to the latest version that is ready for
|
|
328
|
+
* activation.
|
|
329
|
+
*
|
|
330
|
+
* @returns a promise that
|
|
331
|
+
* - resolves to `true` if an update was activated successfully
|
|
332
|
+
* - resolves to `false` if no update was available (for example, the client was already on the
|
|
333
|
+
* latest version).
|
|
334
|
+
* - rejects if any error occurs
|
|
335
|
+
*/
|
|
336
|
+
activateUpdate(): Promise<boolean>;
|
|
337
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SwUpdate, never>;
|
|
338
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SwUpdate>;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
declare interface TypedEvent {
|
|
342
|
+
type: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* An event emitted when the version of the app used by the service worker to serve this client is
|
|
347
|
+
* in a broken state that cannot be recovered from and a full page reload is required.
|
|
348
|
+
*
|
|
349
|
+
* For example, the service worker may not be able to retrieve a required resource, neither from the
|
|
350
|
+
* cache nor from the server. This could happen if a new version is deployed to the server and the
|
|
351
|
+
* service worker cache has been partially cleaned by the browser, removing some files of a previous
|
|
352
|
+
* app version but not all.
|
|
353
|
+
*
|
|
354
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
355
|
+
*
|
|
356
|
+
* @publicApi
|
|
357
|
+
*/
|
|
358
|
+
export declare interface UnrecoverableStateEvent {
|
|
359
|
+
type: 'UNRECOVERABLE_STATE';
|
|
360
|
+
reason: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* An event emitted when a new version of the app has been downloaded and activated.
|
|
365
|
+
*
|
|
366
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
367
|
+
*
|
|
368
|
+
* @deprecated
|
|
369
|
+
* This event is only emitted by the deprecated {@link SwUpdate#activated}.
|
|
370
|
+
* Use the return value of {@link SwUpdate#activateUpdate} instead.
|
|
371
|
+
*
|
|
372
|
+
* @publicApi
|
|
373
|
+
*/
|
|
374
|
+
export declare interface UpdateActivatedEvent {
|
|
375
|
+
type: 'UPDATE_ACTIVATED';
|
|
376
|
+
previous?: {
|
|
377
|
+
hash: string;
|
|
378
|
+
appData?: Object;
|
|
379
|
+
};
|
|
380
|
+
current: {
|
|
381
|
+
hash: string;
|
|
382
|
+
appData?: Object;
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* An event emitted when a new version of the app is available.
|
|
388
|
+
*
|
|
389
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
390
|
+
*
|
|
391
|
+
* @deprecated
|
|
392
|
+
* This event is only emitted by the deprecated {@link SwUpdate#available}.
|
|
393
|
+
* Use the {@link VersionReadyEvent} instead, which is emitted by {@link SwUpdate#versionUpdates}.
|
|
394
|
+
* See {@link SwUpdate#available} docs for an example.
|
|
395
|
+
*
|
|
396
|
+
* @publicApi
|
|
397
|
+
*/
|
|
398
|
+
export declare interface UpdateAvailableEvent {
|
|
399
|
+
type: 'UPDATE_AVAILABLE';
|
|
400
|
+
current: {
|
|
401
|
+
hash: string;
|
|
402
|
+
appData?: Object;
|
|
403
|
+
};
|
|
404
|
+
available: {
|
|
405
|
+
hash: string;
|
|
406
|
+
appData?: Object;
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* An event emitted when the service worker has detected a new version of the app on the server and
|
|
412
|
+
* is about to start downloading it.
|
|
413
|
+
*
|
|
414
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
415
|
+
*
|
|
416
|
+
* @publicApi
|
|
417
|
+
*/
|
|
418
|
+
export declare interface VersionDetectedEvent {
|
|
419
|
+
type: 'VERSION_DETECTED';
|
|
420
|
+
version: {
|
|
421
|
+
hash: string;
|
|
422
|
+
appData?: object;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* A union of all event types that can be emitted by
|
|
428
|
+
* {@link api/service-worker/SwUpdate#versionUpdates SwUpdate#versionUpdates}.
|
|
429
|
+
*
|
|
430
|
+
* @publicApi
|
|
431
|
+
*/
|
|
432
|
+
export declare type VersionEvent = VersionDetectedEvent | VersionInstallationFailedEvent | VersionReadyEvent | NoNewVersionDetectedEvent;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* An event emitted when the installation of a new version failed.
|
|
436
|
+
* It may be used for logging/monitoring purposes.
|
|
437
|
+
*
|
|
438
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
439
|
+
*
|
|
440
|
+
* @publicApi
|
|
441
|
+
*/
|
|
442
|
+
export declare interface VersionInstallationFailedEvent {
|
|
443
|
+
type: 'VERSION_INSTALLATION_FAILED';
|
|
444
|
+
version: {
|
|
445
|
+
hash: string;
|
|
446
|
+
appData?: object;
|
|
447
|
+
};
|
|
448
|
+
error: string;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* An event emitted when a new version of the app is available.
|
|
453
|
+
*
|
|
454
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
455
|
+
*
|
|
456
|
+
* @publicApi
|
|
457
|
+
*/
|
|
458
|
+
export declare interface VersionReadyEvent {
|
|
459
|
+
type: 'VERSION_READY';
|
|
460
|
+
currentVersion: {
|
|
461
|
+
hash: string;
|
|
462
|
+
appData?: object;
|
|
463
|
+
};
|
|
464
|
+
latestVersion: {
|
|
465
|
+
hash: string;
|
|
466
|
+
appData?: object;
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export { }
|