mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-14 04:20:00 -04:00
Remove bareswitcher on UV (not needed due to bare-mux), add bareTransport to sw
This commit is contained in:
parent
c55f67ad58
commit
11dce272a4
1 changed files with 7 additions and 19 deletions
26
public/sw.js
26
public/sw.js
|
@ -1,5 +1,6 @@
|
|||
importScripts("/epoxy/index.js");
|
||||
importScripts("/libcurl/index.cjs");
|
||||
importScripts("/transports/bareTransport.js");
|
||||
importScripts("/uv/uv.bundle.js");
|
||||
importScripts("/uv/uv.config.js");
|
||||
importScripts(__uv$config.sw || "/uv/uv.sw.js");
|
||||
|
@ -27,22 +28,6 @@ const dynPromise = new Promise(async (resolve) => {
|
|||
resolve();
|
||||
});
|
||||
|
||||
const uvPromise = new Promise(async (resolve) => {
|
||||
try {
|
||||
const bare =
|
||||
(await localforage.getItem("bare")) || location.origin + "/bare/";
|
||||
const proxyUrl = (await localforage.getItem("HTTPProxy")) || "";
|
||||
const [proxyIP, proxyPort] = proxyUrl.split(":");
|
||||
self.__uv$config.bare = bare;
|
||||
self.__uv$config.proxyPort = proxyPort;
|
||||
self.__uv$config.proxyIp = proxyIP;
|
||||
self.uv = new UVServiceWorker(self.__uv$config);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
if (
|
||||
event.request.url.startsWith(location.origin + self.__dynamic$config.prefix)
|
||||
|
@ -63,11 +48,14 @@ self.addEventListener("fetch", (event) => {
|
|||
) {
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
try {
|
||||
await uvPromise;
|
||||
} catch (error) {}
|
||||
return await self.uv.fetch(event);
|
||||
})()
|
||||
);
|
||||
} else {
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
return await fetch(event.request);
|
||||
})()
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue