@angular/service-worker 13.0.0-next.11 → 13.0.0-next.15
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/config.d.ts +1 -1
- package/esm2020/config/src/generator.mjs +23 -17
- package/esm2020/src/index.mjs +1 -1
- package/esm2020/src/low_level.mjs +15 -9
- package/esm2020/src/module.mjs +4 -4
- package/esm2020/src/push.mjs +3 -3
- package/esm2020/src/update.mjs +35 -9
- package/fesm2015/config.mjs +24 -18
- package/fesm2015/config.mjs.map +1 -1
- package/fesm2015/service-worker.mjs +55 -24
- package/fesm2015/service-worker.mjs.map +1 -1
- package/fesm2020/config.mjs +23 -17
- package/fesm2020/config.mjs.map +1 -1
- package/fesm2020/service-worker.mjs +55 -24
- package/fesm2020/service-worker.mjs.map +1 -1
- package/ngsw-config.js +5 -5
- package/ngsw-worker.js +71 -37
- package/package.json +8 -4
- package/service-worker.d.ts +122 -6
package/service-worker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v13.0.0-next.
|
|
2
|
+
* @license Angular v13.0.0-next.15
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -18,11 +18,11 @@ declare class NgswCommChannel {
|
|
|
18
18
|
readonly events: Observable<TypedEvent>;
|
|
19
19
|
constructor(serviceWorker: ServiceWorkerContainer | undefined);
|
|
20
20
|
postMessage(action: string, payload: Object): Promise<void>;
|
|
21
|
-
|
|
21
|
+
postMessageWithOperation(type: string, payload: Object, operationNonce: number): Promise<boolean>;
|
|
22
22
|
generateNonce(): number;
|
|
23
|
-
eventsOfType<T extends TypedEvent>(type: T['type']): Observable<T>;
|
|
23
|
+
eventsOfType<T extends TypedEvent>(type: T['type'] | T['type'][]): Observable<T>;
|
|
24
24
|
nextEventOfType<T extends TypedEvent>(type: T['type']): Observable<T>;
|
|
25
|
-
|
|
25
|
+
waitForOperationCompleted(nonce: number): Promise<boolean>;
|
|
26
26
|
get isEnabled(): boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -248,12 +248,40 @@ export declare abstract class SwRegistrationOptions {
|
|
|
248
248
|
*/
|
|
249
249
|
export declare class SwUpdate {
|
|
250
250
|
private sw;
|
|
251
|
+
/**
|
|
252
|
+
* Emits a `VersionDetectedEvent` event whenever a new version is detected on the server.
|
|
253
|
+
*
|
|
254
|
+
* Emits a `VersionInstallationFailedEvent` event whenever checking for or downloading a new
|
|
255
|
+
* version fails.
|
|
256
|
+
*
|
|
257
|
+
* Emits a `VersionReadyEvent` event whenever a new version has been downloaded and is ready for
|
|
258
|
+
* activation.
|
|
259
|
+
*/
|
|
260
|
+
readonly versionUpdates: Observable<VersionEvent>;
|
|
251
261
|
/**
|
|
252
262
|
* Emits an `UpdateAvailableEvent` event whenever a new app version is available.
|
|
263
|
+
*
|
|
264
|
+
* @deprecated Use {@link versionUpdates} instead.
|
|
265
|
+
*
|
|
266
|
+
* The of behavior `available` can be rebuild by filtering for the `VersionReadyEvent`:
|
|
267
|
+
* ```
|
|
268
|
+
* import {filter, map} from 'rxjs/operators';
|
|
269
|
+
* // ...
|
|
270
|
+
* const updatesAvailable = swUpdate.versionUpdates.pipe(
|
|
271
|
+
* filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'),
|
|
272
|
+
* map(evt => ({
|
|
273
|
+
* type: 'UPDATE_AVAILABLE',
|
|
274
|
+
* current: evt.currentVersion,
|
|
275
|
+
* available: evt.latestVersion,
|
|
276
|
+
* })));
|
|
277
|
+
* ```
|
|
253
278
|
*/
|
|
254
279
|
readonly available: Observable<UpdateAvailableEvent>;
|
|
255
280
|
/**
|
|
256
281
|
* Emits an `UpdateActivatedEvent` event whenever the app has been updated to a new version.
|
|
282
|
+
*
|
|
283
|
+
* @deprecated Use the return value of {@link SwUpdate#activateUpdate} instead.
|
|
284
|
+
*
|
|
257
285
|
*/
|
|
258
286
|
readonly activated: Observable<UpdateActivatedEvent>;
|
|
259
287
|
/**
|
|
@@ -268,8 +296,27 @@ export declare class SwUpdate {
|
|
|
268
296
|
*/
|
|
269
297
|
get isEnabled(): boolean;
|
|
270
298
|
constructor(sw: NgswCommChannel);
|
|
271
|
-
|
|
272
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Checks for an update and waits until the new version is downloaded from the server and ready
|
|
301
|
+
* for activation.
|
|
302
|
+
*
|
|
303
|
+
* @returns a promise that
|
|
304
|
+
* - resolves to `true` if a new version was found and is ready to be activated.
|
|
305
|
+
* - resolves to `false` if no new version was found
|
|
306
|
+
* - rejects if any error occurs
|
|
307
|
+
*/
|
|
308
|
+
checkForUpdate(): Promise<boolean>;
|
|
309
|
+
/**
|
|
310
|
+
* Updates the current client (i.e. browser tab) to the latest version that is ready for
|
|
311
|
+
* activation.
|
|
312
|
+
*
|
|
313
|
+
* @returns a promise that
|
|
314
|
+
* - resolves to `true` if an update was activated successfully
|
|
315
|
+
* - resolves to `false` if no update was available (for example, the client was already on the
|
|
316
|
+
* latest version).
|
|
317
|
+
* - rejects if any error occurs
|
|
318
|
+
*/
|
|
319
|
+
activateUpdate(): Promise<boolean>;
|
|
273
320
|
static ɵfac: i0.ɵɵFactoryDeclaration<SwUpdate, never>;
|
|
274
321
|
static ɵprov: i0.ɵɵInjectableDeclaration<SwUpdate>;
|
|
275
322
|
}
|
|
@@ -301,6 +348,10 @@ export declare interface UnrecoverableStateEvent {
|
|
|
301
348
|
*
|
|
302
349
|
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
303
350
|
*
|
|
351
|
+
* @deprecated
|
|
352
|
+
* This event is only emitted by the deprecated {@link SwUpdate#activated}.
|
|
353
|
+
* Use the return value of {@link SwUpdate#activateUpdate} instead.
|
|
354
|
+
*
|
|
304
355
|
* @publicApi
|
|
305
356
|
*/
|
|
306
357
|
export declare interface UpdateActivatedEvent {
|
|
@@ -320,6 +371,11 @@ export declare interface UpdateActivatedEvent {
|
|
|
320
371
|
*
|
|
321
372
|
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
322
373
|
*
|
|
374
|
+
* @deprecated
|
|
375
|
+
* This event is only emitted by the deprecated {@link SwUpdate#available}.
|
|
376
|
+
* Use the {@link VersionReadyEvent} instead, which is emitted by {@link SwUpdate#versionUpdates}.
|
|
377
|
+
* See {@link SwUpdate#available} docs for an example.
|
|
378
|
+
*
|
|
323
379
|
* @publicApi
|
|
324
380
|
*/
|
|
325
381
|
export declare interface UpdateAvailableEvent {
|
|
@@ -334,4 +390,64 @@ export declare interface UpdateAvailableEvent {
|
|
|
334
390
|
};
|
|
335
391
|
}
|
|
336
392
|
|
|
393
|
+
/**
|
|
394
|
+
* An event emitted when the service worker has detected a new version of the app on the server and
|
|
395
|
+
* is about to start downloading it.
|
|
396
|
+
*
|
|
397
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
398
|
+
*
|
|
399
|
+
* @publicApi
|
|
400
|
+
*/
|
|
401
|
+
export declare interface VersionDetectedEvent {
|
|
402
|
+
type: 'VERSION_DETECTED';
|
|
403
|
+
version: {
|
|
404
|
+
hash: string;
|
|
405
|
+
appData?: object;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* A union of all event types that can be emitted by
|
|
411
|
+
* {@link api/service-worker/SwUpdate#versionUpdates SwUpdate#versionUpdates}.
|
|
412
|
+
*
|
|
413
|
+
* @publicApi
|
|
414
|
+
*/
|
|
415
|
+
export declare type VersionEvent = VersionDetectedEvent | VersionInstallationFailedEvent | VersionReadyEvent;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* An event emitted when the installation of a new version failed.
|
|
419
|
+
* It may be used for logging/monitoring purposes.
|
|
420
|
+
*
|
|
421
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
422
|
+
*
|
|
423
|
+
* @publicApi
|
|
424
|
+
*/
|
|
425
|
+
export declare interface VersionInstallationFailedEvent {
|
|
426
|
+
type: 'VERSION_INSTALLATION_FAILED';
|
|
427
|
+
version: {
|
|
428
|
+
hash: string;
|
|
429
|
+
appData?: object;
|
|
430
|
+
};
|
|
431
|
+
error: string;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* An event emitted when a new version of the app is available.
|
|
436
|
+
*
|
|
437
|
+
* @see {@link guide/service-worker-communications Service worker communication guide}
|
|
438
|
+
*
|
|
439
|
+
* @publicApi
|
|
440
|
+
*/
|
|
441
|
+
export declare interface VersionReadyEvent {
|
|
442
|
+
type: 'VERSION_READY';
|
|
443
|
+
currentVersion: {
|
|
444
|
+
hash: string;
|
|
445
|
+
appData?: object;
|
|
446
|
+
};
|
|
447
|
+
latestVersion: {
|
|
448
|
+
hash: string;
|
|
449
|
+
appData?: object;
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
337
453
|
export { }
|