revert: service worker changes (#19227)

This commit is contained in:
Jason Rasmussen
2025-06-17 13:07:54 -04:00
committed by GitHub
parent 35280b94cc
commit 91cbd56c1c
4 changed files with 99 additions and 131 deletions

View File

@@ -3,21 +3,17 @@
/// <reference lib="esnext" />
/// <reference lib="webworker" />
import { installBroadcastChannelListener } from './broadcast-channel';
import { addFilesToCache, deleteOldCaches } from './cache';
import { handleFetchEvent } from './fetch-event';
import { deleteOldCaches, handleFetchEvent } from './fetch-event';
const sw = globalThis as unknown as ServiceWorkerGlobalScope;
const handleActivate = (event: ExtendableEvent) => {
event.waitUntil(sw.clients.claim());
// Remove previous cached data from disk
event.waitUntil(deleteOldCaches());
};
const handleInstall = (event: ExtendableEvent) => {
event.waitUntil(sw.skipWaiting());
// Create a new cache and add all files to it
event.waitUntil(addFilesToCache());
};
sw.addEventListener('install', handleInstall, { passive: true });