| 1 | import { WorkboxPlugin } from 'workbox-core/types.js';
|
|---|
| 2 | import { PrecacheController } from './PrecacheController.js';
|
|---|
| 3 | import './_version.js';
|
|---|
| 4 | /**
|
|---|
| 5 | * `PrecacheFallbackPlugin` allows you to specify an "offline fallback"
|
|---|
| 6 | * response to be used when a given strategy is unable to generate a response.
|
|---|
| 7 | *
|
|---|
| 8 | * It does this by intercepting the `handlerDidError` plugin callback
|
|---|
| 9 | * and returning a precached response, taking the expected revision parameter
|
|---|
| 10 | * into account automatically.
|
|---|
| 11 | *
|
|---|
| 12 | * Unless you explicitly pass in a `PrecacheController` instance to the
|
|---|
| 13 | * constructor, the default instance will be used. Generally speaking, most
|
|---|
| 14 | * developers will end up using the default.
|
|---|
| 15 | *
|
|---|
| 16 | * @memberof workbox-precaching
|
|---|
| 17 | */
|
|---|
| 18 | declare class PrecacheFallbackPlugin implements WorkboxPlugin {
|
|---|
| 19 | private readonly _fallbackURL;
|
|---|
| 20 | private readonly _precacheController;
|
|---|
| 21 | /**
|
|---|
| 22 | * Constructs a new PrecacheFallbackPlugin with the associated fallbackURL.
|
|---|
| 23 | *
|
|---|
| 24 | * @param {Object} config
|
|---|
| 25 | * @param {string} config.fallbackURL A precached URL to use as the fallback
|
|---|
| 26 | * if the associated strategy can't generate a response.
|
|---|
| 27 | * @param {PrecacheController} [config.precacheController] An optional
|
|---|
| 28 | * PrecacheController instance. If not provided, the default
|
|---|
| 29 | * PrecacheController will be used.
|
|---|
| 30 | */
|
|---|
| 31 | constructor({ fallbackURL, precacheController, }: {
|
|---|
| 32 | fallbackURL: string;
|
|---|
| 33 | precacheController?: PrecacheController;
|
|---|
| 34 | });
|
|---|
| 35 | /**
|
|---|
| 36 | * @return {Promise<Response>} The precache response for the fallback URL.
|
|---|
| 37 | *
|
|---|
| 38 | * @private
|
|---|
| 39 | */
|
|---|
| 40 | handlerDidError: WorkboxPlugin['handlerDidError'];
|
|---|
| 41 | }
|
|---|
| 42 | export { PrecacheFallbackPlugin };
|
|---|