Sonu Kapoor 036a2faf02 feat(service-worker): add UnrecoverableStateError (#36847)
In several occasions it has been observed when the browser has evicted
eagerly cached assets from the cache and which can also not be found on the
server anymore. This can lead to broken state where only parts of the application
will load and others will fail.

This commit fixes this issue by checking for the missing asset in the cache
and on the server. If this condition is true, the broken client will be
notified about the current state through the `UnrecoverableStateError`.

Closes #36539

PR Close #36847
2020-08-31 11:41:11 -07:00

66 lines
1.8 KiB
TypeScript

export declare class ServiceWorkerModule {
static register(script: string, opts?: SwRegistrationOptions): ModuleWithProviders<ServiceWorkerModule>;
}
export declare class SwPush {
get isEnabled(): boolean;
readonly messages: Observable<object>;
readonly notificationClicks: Observable<{
action: string;
notification: NotificationOptions & {
title: string;
};
}>;
readonly subscription: Observable<PushSubscription | null>;
constructor(sw: ɵangular_packages_service_worker_service_worker_a);
requestSubscription(options: {
serverPublicKey: string;
}): Promise<PushSubscription>;
unsubscribe(): Promise<void>;
}
export declare abstract class SwRegistrationOptions {
enabled?: boolean;
registrationStrategy?: string | (() => Observable<unknown>);
scope?: string;
}
export declare class SwUpdate {
readonly activated: Observable<UpdateActivatedEvent>;
readonly available: Observable<UpdateAvailableEvent>;
get isEnabled(): boolean;
readonly unrecoverable: Observable<UnrecoverableStateEvent>;
constructor(sw: ɵangular_packages_service_worker_service_worker_a);
activateUpdate(): Promise<void>;
checkForUpdate(): Promise<void>;
}
export declare interface UnrecoverableStateEvent {
reason: string;
type: 'UNRECOVERABLE_STATE';
}
export declare interface UpdateActivatedEvent {
current: {
hash: string;
appData?: Object;
};
previous?: {
hash: string;
appData?: Object;
};
type: 'UPDATE_ACTIVATED';
}
export declare interface UpdateAvailableEvent {
available: {
hash: string;
appData?: Object;
};
current: {
hash: string;
appData?: Object;
};
type: 'UPDATE_AVAILABLE';
}