serwist
Version:
A Swiss Army knife for service workers.
44 lines • 1.55 kB
TypeScript
import type { CacheDidUpdateCallbackParam } from "../../types.js";
import type { BroadcastCacheUpdateOptions } from "./types.js";
/**
* A class that uses the `postMessage()` API to inform any open windows/tabs when
* a cached response has been updated.
*
* For efficiency's sake, the underlying response bodies are not compared;
* only specific response headers are checked.
*/
export declare class BroadcastCacheUpdate {
private readonly _headersToCheck;
private readonly _generatePayload;
private readonly _notifyAllClients;
/**
* Construct an instance of `BroadcastCacheUpdate`.
*
* @param options
*/
constructor({ generatePayload, headersToCheck, notifyAllClients }?: BroadcastCacheUpdateOptions);
/**
* Compares two responses and sends a message (via `postMessage()`) to all window clients if the
* responses differ. Neither of the Responses can be opaque.
*
* The message that's posted has the following format (where `payload` can
* be customized via the `generatePayload` option the instance is created
* with):
*
* ```
* {
* type: 'CACHE_UPDATED',
* meta: 'workbox-broadcast-update',
* payload: {
* cacheName: 'the-cache-name',
* updatedURL: 'https://example.com/'
* }
* }
* ```
*
* @param options
* @returns Resolves once the update is sent.
*/
notifyIfUpdated(options: CacheDidUpdateCallbackParam): Promise<void>;
}
//# sourceMappingURL=BroadcastCacheUpdate.d.ts.map