2022-06-04 21:34:33 +00:00
|
|
|
import {
|
2022-06-11 13:13:28 +00:00
|
|
|
fetchAsset,
|
|
|
|
fetchDocument,
|
|
|
|
fetchLoaderData,
|
2022-06-04 21:34:33 +00:00
|
|
|
isAssetRequest,
|
|
|
|
isDocumentGetRequest,
|
|
|
|
isLoaderRequest,
|
2022-06-05 21:11:21 +00:00
|
|
|
} from "./cache-utils";
|
2022-06-04 13:48:37 +00:00
|
|
|
|
2022-06-11 13:13:28 +00:00
|
|
|
declare const self: ServiceWorkerGlobalScope;
|
2022-06-01 21:56:37 +00:00
|
|
|
|
2022-06-04 21:34:33 +00:00
|
|
|
export default async function handleFetch(event: FetchEvent) {
|
|
|
|
if (isAssetRequest(event.request)) {
|
2022-06-11 13:13:28 +00:00
|
|
|
return fetchAsset(event);
|
2022-06-01 21:56:37 +00:00
|
|
|
}
|
|
|
|
|
2022-06-04 21:34:33 +00:00
|
|
|
if (isLoaderRequest(event.request)) {
|
2022-06-11 13:13:28 +00:00
|
|
|
return fetchLoaderData(event);
|
2022-06-04 21:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isDocumentGetRequest(event.request)) {
|
2022-06-11 13:13:28 +00:00
|
|
|
return fetchDocument(event);
|
2022-06-04 21:34:33 +00:00
|
|
|
}
|
|
|
|
|
2022-06-01 21:56:37 +00:00
|
|
|
return fetch(event.request);
|
|
|
|
}
|