NetworkOnly.d.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Strategy, StrategyOptions } from './Strategy.js';
  2. import { StrategyHandler } from './StrategyHandler.js';
  3. import './_version.js';
  4. interface NetworkOnlyOptions extends Omit<StrategyOptions, 'cacheName' | 'matchOptions'> {
  5. networkTimeoutSeconds?: number;
  6. }
  7. /**
  8. * An implementation of a
  9. * [network-only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-only)
  10. * request strategy.
  11. *
  12. * This class is useful if you want to take advantage of any
  13. * [Workbox plugins](https://developer.chrome.com/docs/workbox/using-plugins/).
  14. *
  15. * If the network request fails, this will throw a `WorkboxError` exception.
  16. *
  17. * @extends workbox-strategies.Strategy
  18. * @memberof workbox-strategies
  19. */
  20. declare class NetworkOnly extends Strategy {
  21. private readonly _networkTimeoutSeconds;
  22. /**
  23. * @param {Object} [options]
  24. * @param {Array<Object>} [options.plugins] [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
  25. * to use in conjunction with this caching strategy.
  26. * @param {Object} [options.fetchOptions] Values passed along to the
  27. * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
  28. * of [non-navigation](https://github.com/GoogleChrome/workbox/issues/1796)
  29. * `fetch()` requests made by this strategy.
  30. * @param {number} [options.networkTimeoutSeconds] If set, any network requests
  31. * that fail to respond within the timeout will result in a network error.
  32. */
  33. constructor(options?: NetworkOnlyOptions);
  34. /**
  35. * @private
  36. * @param {Request|string} request A request to run this strategy for.
  37. * @param {workbox-strategies.StrategyHandler} handler The event that
  38. * triggered the request.
  39. * @return {Promise<Response>}
  40. */
  41. _handle(request: Request, handler: StrategyHandler): Promise<Response>;
  42. }
  43. export { NetworkOnly, NetworkOnlyOptions };