This already looks a number times better
This commit is contained in:
parent
9c3ffcc58e
commit
b06c338c20
5 changed files with 42 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { settings, Settings } from "@utils/settings/index";
|
/* import { settings, Settings } from "@utils/settings/index";
|
||||||
import { loadProxyScripts, setTransport, initSw, setSWStuff } from "@utils/registerSW";
|
import { loadProxyScripts, setTransport, initSw, setSWStuff } from "@utils/registerSW";
|
||||||
// This loads the settings in a nice way
|
// This loads the settings in a nice way
|
||||||
settings.tabSettings.cloakTab(localStorage.getItem(Settings.TabSettings.tabCloak) as string || "default");
|
settings.tabSettings.cloakTab(localStorage.getItem(Settings.TabSettings.tabCloak) as string || "default");
|
||||||
|
|
@ -22,4 +22,28 @@
|
||||||
const sw = await initSw();
|
const sw = await initSw();
|
||||||
await setSWStuff({sw: sw.sw, conn, sj: sw.sj });
|
await setSWStuff({sw: sw.sw, conn, sj: sw.sj });
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
import { EventHandler } from "@utils/events";
|
||||||
|
import { SW, createProxyScripts, checkProxyScripts, createBareMuxConn, setTransport } from "@utils/serviceWorker";
|
||||||
|
|
||||||
|
const init = async () => {
|
||||||
|
for (const script of createProxyScripts()) {
|
||||||
|
document.body.appendChild(script);
|
||||||
|
}
|
||||||
|
await checkProxyScripts();
|
||||||
|
const conn = await createBareMuxConn("/baremux/worker.js");
|
||||||
|
await setTransport(conn, "libcurl");
|
||||||
|
window.sw = new SW(conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
const eventHandler = new EventHandler({
|
||||||
|
events: {
|
||||||
|
"DOMContentLoaded": (async () => {
|
||||||
|
await init();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
logging: true
|
||||||
|
});
|
||||||
|
//bind the events
|
||||||
|
eventHandler.bind();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
11
src/global.d.ts
vendored
Normal file
11
src/global.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
// LEGIT here for ONE global.
|
||||||
|
|
||||||
|
import type { SW } from "@utils/serviceWorker";
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
sw: SW;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export {};
|
||||||
|
|
@ -47,7 +47,8 @@ import Layout from "@layouts/Layout.astro";
|
||||||
},
|
},
|
||||||
logging: false
|
logging: false
|
||||||
});
|
});
|
||||||
eHandler.handleEvents();
|
//Bind the events.
|
||||||
|
eHandler.bind();
|
||||||
</script>
|
</script>
|
||||||
<noscript>
|
<noscript>
|
||||||
JavaScript is required to run this app.
|
JavaScript is required to run this app.
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,11 @@ import LoadingComponent from "@components/Loading.astro";
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Layout title="Loading page..." noHeader="true">
|
<Layout title="Loading page..." noHeader="true">
|
||||||
<LoadingComponent />
|
<LoadingComponent />
|
||||||
</Layout-->
|
</Layout>
|
||||||
<script>
|
<script>
|
||||||
import { EventHandler } from "@utils/events";
|
import { EventHandler } from "@utils/events";
|
||||||
import { checkProxyScripts, createBareMuxConn, createProxyScripts, SW } from "@utils/serviceWorker";
|
|
||||||
import { navigate } from "astro:transitions/client";
|
import { navigate } from "astro:transitions/client";
|
||||||
function isComingFromIframe() {
|
function isComingFromIframe() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -25,7 +24,7 @@ import Layout from "@layouts/Layout.astro";
|
||||||
const isIframe = isComingFromIframe();
|
const isIframe = isComingFromIframe();
|
||||||
if (!isIframe) {
|
if (!isIframe) {
|
||||||
console.log("Assuming request isn't coming from iframe. Redirecting...");
|
console.log("Assuming request isn't coming from iframe. Redirecting...");
|
||||||
navigate("/");
|
//navigate("/");
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ const setTransport = (conn: BareMuxConnection, transport?: "libcurl" | "epoxy")
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
console.log(`Set wisp server at: ${server ? WispServers[server]: WispServers.default }`);
|
console.log(`Set wisp server at: ${server ? WispServers[server]: WispServers.default }`);
|
||||||
if (transport === "epoxy") return resolve(conn.setTransport("/epoxy/index.mjs", [ { wisp: server ? WispServers[server] : WispServers.default }]));
|
if (transport === "epoxy") return resolve(conn.setTransport("/epoxy/index.mjs", [ { wisp: server ? WispServers[server] : WispServers.default }]));
|
||||||
if (transport === "libcurl") return resolve(conn.setTransport("/libcurl/index.msj", [ { wisp: server ? WispServers[server] : WispServers.default }]));
|
if (transport === "libcurl") return resolve(conn.setTransport("/libcurl/index.mjs", [ { wisp: server ? WispServers[server] : WispServers.default }]));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue