PWA
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m24s

This commit is contained in:
eewing
2026-02-19 07:41:49 -06:00
parent 5776a1fdb1
commit c0fae761da
10919 changed files with 874329 additions and 13511 deletions
+34
View File
@@ -0,0 +1,34 @@
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};