BroadcastUpdatePlugin.d.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { WorkboxPlugin } from 'workbox-core/types.js';
  2. import { BroadcastCacheUpdateOptions } from './BroadcastCacheUpdate.js';
  3. import './_version.js';
  4. /**
  5. * This plugin will automatically broadcast a message whenever a cached response
  6. * is updated.
  7. *
  8. * @memberof module:workbox-broadcast-update
  9. */
  10. declare class BroadcastUpdatePlugin implements WorkboxPlugin {
  11. private readonly _broadcastUpdate;
  12. /**
  13. * Construct a BroadcastCacheUpdate instance with the passed options and
  14. * calls its [`notifyIfUpdated()`]{@link module:workbox-broadcast-update.BroadcastCacheUpdate~notifyIfUpdated}
  15. * method whenever the plugin's `cacheDidUpdate` callback is invoked.
  16. *
  17. * @param {Object} options
  18. * @param {Array<string>} [options.headersToCheck=['content-length', 'etag', 'last-modified']]
  19. * A list of headers that will be used to determine whether the responses
  20. * differ.
  21. * @param {string} [options.generatePayload] A function whose return value
  22. * will be used as the `payload` field in any cache update messages sent
  23. * to the window clients.
  24. */
  25. constructor(options: BroadcastCacheUpdateOptions);
  26. /**
  27. * A "lifecycle" callback that will be triggered automatically by the
  28. * `workbox-sw` and `workbox-runtime-caching` handlers when an entry is
  29. * added to a cache.
  30. *
  31. * @private
  32. * @param {Object} options The input object to this function.
  33. * @param {string} options.cacheName Name of the cache being updated.
  34. * @param {Response} [options.oldResponse] The previous cached value, if any.
  35. * @param {Response} options.newResponse The new value in the cache.
  36. * @param {Request} options.request The request that triggered the update.
  37. * @param {Request} [options.event] The event that triggered the update.
  38. */
  39. cacheDidUpdate: WorkboxPlugin['cacheDidUpdate'];
  40. }
  41. export { BroadcastUpdatePlugin };