use stock SW, run on /uv/ scope

This commit is contained in:
David Reed 2022-12-02 17:51:14 -05:00
parent f06bcbaf98
commit 66520e1565
No known key found for this signature in database
GPG key ID: 2211691D8A1EE72F
3 changed files with 3 additions and 10 deletions

View file

@ -7,7 +7,7 @@ async function registerSW() {
if (!navigator.serviceWorker) if (!navigator.serviceWorker)
throw new Error("Your browser doesn't support service workers."); throw new Error("Your browser doesn't support service workers.");
await navigator.serviceWorker.register("./sw.js", { await navigator.serviceWorker.register(__uv$config.sw, {
scope: __uv$config.prefix, scope: __uv$config.prefix,
}); });
} }

View file

@ -1,7 +0,0 @@
importScripts("./uv/uv.bundle.js");
importScripts("./uv/uv.config.js");
importScripts("./uv/uv.sw.js");
const sw = new UVServiceWorker();
self.addEventListener("fetch", (event) => event.respondWith(sw.fetch(event)));

View file

@ -1,12 +1,12 @@
// This file overwrites the stock UV config.js // This file overwrites the stock UV config.js
self.__uv$config = { self.__uv$config = {
prefix: "/service/", prefix: "/uv/service/",
bare: "/bare/", bare: "/bare/",
encodeUrl: Ultraviolet.codec.xor.encode, encodeUrl: Ultraviolet.codec.xor.encode,
decodeUrl: Ultraviolet.codec.xor.decode, decodeUrl: Ultraviolet.codec.xor.decode,
handler: "/uv/uv.handler.js", handler: "/uv/uv.handler.js",
bundle: "/uv/uv.bundle.js", bundle: "/uv/uv.bundle.js",
config: "/uv/uv.config.js", config: "/uv/uv.config.js",
sw: "/uv/uv.sw.js", sw: "/uv/sw.js",
}; };