mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-17 13:30:00 -04:00
Merge pull request #185 from NebulaServices/dev
Merge UV and Dynamic SW files
This commit is contained in:
commit
1b750df0f1
3 changed files with 32 additions and 36 deletions
|
@ -17,11 +17,8 @@
|
|||
<script>
|
||||
if ("serviceWorker" in navigator) {
|
||||
window.addEventListener("load", () => {
|
||||
navigator.serviceWorker.register("/uvsw.js", {
|
||||
scope: __uv$config.prefix
|
||||
});
|
||||
navigator.serviceWorker.register("/dysw.js", {
|
||||
scope: __dynamic$config.prefix
|
||||
navigator.serviceWorker.register("/sw.js", {
|
||||
scope: "/~/"
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
importScripts("/dynamic/dynamic.config.js");
|
||||
importScripts("/dynamic/dynamic.worker.js");
|
||||
|
||||
const dynamic = new Dynamic();
|
||||
|
||||
self.dynamic = dynamic;
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
if (
|
||||
event.request.url.startsWith(location.origin + self.__dynamic$config.prefix)
|
||||
)
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
if (await dynamic.route(event)) {
|
||||
return await dynamic.fetch(event);
|
||||
}
|
||||
|
||||
return await fetch(event.request);
|
||||
})()
|
||||
);
|
||||
});
|
||||
importScripts("/uv/uv.bundle.js");
|
||||
importScripts("/uv/uv.config.js");
|
||||
importScripts(__uv$config.sw || "/uv/uv.sw.js");
|
||||
importScripts("/dynamic/dynamic.config.js");
|
||||
importScripts("/dynamic/dynamic.worker.js");
|
||||
|
||||
const sw = new UVServiceWorker();
|
||||
const dynamic = new Dynamic();
|
||||
|
||||
self.dynamic = dynamic;
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
if (
|
||||
event.request.url.startsWith(location.origin + self.__dynamic$config.prefix)
|
||||
) {
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
if (await dynamic.route(event)) {
|
||||
return await dynamic.fetch(event);
|
||||
}
|
||||
|
||||
return await fetch(event.request);
|
||||
})()
|
||||
);
|
||||
} else if (
|
||||
event.request.url.startsWith(location.origin + __uv$config.prefix)
|
||||
) {
|
||||
event.respondWith(sw.fetch(event));
|
||||
}
|
||||
});
|
|
@ -1,10 +0,0 @@
|
|||
importScripts("/uv/uv.bundle.js");
|
||||
importScripts("/uv/uv.config.js");
|
||||
importScripts(__uv$config.sw || "/uv/uv.sw.js");
|
||||
|
||||
const sw = new UVServiceWorker();
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
if (event.request.url.startsWith(location.origin + __uv$config.prefix))
|
||||
return event.respondWith(sw.fetch(event));
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue