- Complete React app with 7 developer tools - JSON Tool with visual structured editor - Serialize Tool with visual structured editor - URL, Base64, CSV/JSON, Beautifier, Diff tools - Responsive navigation with dropdown menu - Dark/light mode toggle - Mobile-responsive design with sticky header - All tools working with copy/paste functionality
35 lines
815 B
TypeScript
35 lines
815 B
TypeScript
import {Strategy} from 'workbox-strategies/Strategy.js';
|
|
|
|
import './_version.js';
|
|
|
|
export interface WarmStrategyCacheOptions {
|
|
urls: Array<string>;
|
|
strategy: Strategy;
|
|
}
|
|
|
|
// Give TypeScript the correct global.
|
|
declare let self: ServiceWorkerGlobalScope;
|
|
|
|
/**
|
|
* @memberof workbox-recipes
|
|
|
|
* @param {Object} options
|
|
* @param {string[]} options.urls Paths to warm the strategy's cache with
|
|
* @param {Strategy} options.strategy Strategy to use
|
|
*/
|
|
function warmStrategyCache(options: WarmStrategyCacheOptions): void {
|
|
self.addEventListener('install', (event) => {
|
|
const done = options.urls.map(
|
|
(path) =>
|
|
options.strategy.handleAll({
|
|
event,
|
|
request: new Request(path),
|
|
})[1],
|
|
);
|
|
|
|
event.waitUntil(Promise.all(done));
|
|
});
|
|
}
|
|
|
|
export {warmStrategyCache};
|