Files
dewedev/node_modules/workbox-precaching/src/cleanupOutdatedCaches.ts
dwindown 7f2dd5260f Initial commit: Developer Tools MVP with visual editor
- 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
2025-08-02 09:31:26 +07:00

42 lines
1.2 KiB
TypeScript

/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {cacheNames} from 'workbox-core/_private/cacheNames.js';
import {logger} from 'workbox-core/_private/logger.js';
import {deleteOutdatedCaches} from './utils/deleteOutdatedCaches.js';
import './_version.js';
/**
* Adds an `activate` event listener which will clean up incompatible
* precaches that were created by older versions of Workbox.
*
* @memberof workbox-precaching
*/
function cleanupOutdatedCaches(): void {
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705
self.addEventListener('activate', ((event: ExtendableEvent) => {
const cacheName = cacheNames.getPrecacheName();
event.waitUntil(
deleteOutdatedCaches(cacheName).then((cachesDeleted) => {
if (process.env.NODE_ENV !== 'production') {
if (cachesDeleted.length > 0) {
logger.log(
`The following out-of-date precaches were cleaned up ` +
`automatically:`,
cachesDeleted,
);
}
}
}),
);
}) as EventListener);
}
export {cleanupOutdatedCaches};