Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
titaniumnetwork-dev
GitHub Repository: titaniumnetwork-dev/Ultraviolet
Path: blob/main/src/sw.js
304 views
1
/*global UVServiceWorker,__uv$config*/
2
/*
3
* Stock service worker script.
4
* Users can provide their own sw.js if they need to extend the functionality of the service worker.
5
* Ideally, this will be registered under the scope in uv.config.js so it will not need to be modified.
6
* However, if a user changes the location of uv.bundle.js/uv.config.js or sw.js is not relative to them, they will need to modify this script locally.
7
*/
8
importScripts("uv.bundle.js");
9
importScripts("uv.config.js");
10
importScripts(__uv$config.sw || "uv.sw.js");
11
12
const uv = new UVServiceWorker();
13
14
async function handleRequest(event) {
15
if (uv.route(event)) {
16
return await uv.fetch(event);
17
}
18
19
return await fetch(event.request);
20
}
21
22
self.addEventListener("fetch", (event) => {
23
event.respondWith(handleRequest(event));
24
});
25
26