diff --git a/index.js b/index.js index 5f2fcac..d414714 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,7 @@ import dotenv from "dotenv"; import cookieParser from "cookie-parser"; import wisp from "wisp-server-node"; import fs from "node:fs"; -import fetch from 'node-fetch'; +import fetch from "node-fetch"; dotenv.config(); const LICENSE_SERVER_URL = "https://license.mercurywork.shop/validate?license="; @@ -137,8 +137,8 @@ app.use("/custom-favicon", async (req, res) => { const response = await fetch(url).then((apiRes) => apiRes.buffer()); res.send(response); } catch (err) { - console.log(err) - res.send("Error") + console.log(err); + res.send("Error"); } }); app.use("/", express.static("dist/client/")); diff --git a/public/bare_transport.js b/public/bare_transport.js index 888d4b3..62e4561 100644 --- a/public/bare_transport.js +++ b/public/bare_transport.js @@ -4,8 +4,7 @@ ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) - : ((global = - typeof globalThis !== "undefined" ? globalThis : global || self), + : ((global = typeof globalThis !== "undefined" ? globalThis : global || self), factory((global.BareMod = {}))); })(this, function (exports) { "use strict"; @@ -17,12 +16,12 @@ const WebSocket = globalThis.WebSocket; const WebSocketFields = { prototype: { - send: WebSocket.prototype.send + send: WebSocket.prototype.send, }, CLOSED: WebSocket.CLOSED, CLOSING: WebSocket.CLOSING, CONNECTING: WebSocket.CONNECTING, - OPEN: WebSocket.OPEN + OPEN: WebSocket.OPEN, }; class BareError extends Error { @@ -441,7 +440,7 @@ throw new BareError(400, { code: "INVALID_BARE_HEADER", id: `request.headers.${header}`, - message: `Value didn't begin with semi-colon.` + message: `Value didn't begin with semi-colon.`, }); } const id = parseInt(header.slice(prefix.length + 1)); @@ -473,16 +472,7 @@ async init() { this.ready = true; } - connect( - url, - origin, - protocols, - requestHeaders, - onopen, - onmessage, - onclose, - onerror - ) { + connect(url, origin, protocols, requestHeaders, onopen, onmessage, onclose, onerror) { const ws = new WebSocket(this.ws); const cleanup = () => { ws.removeEventListener("close", closeListener); @@ -495,13 +485,10 @@ cleanup(); // ws.binaryType is irrelevant when sending text if (typeof event.data !== "string") - throw new TypeError( - "the first websocket message was not a text frame" - ); + throw new TypeError("the first websocket message was not a text frame"); const message = JSON.parse(event.data); // finally - if (message.type !== "open") - throw new TypeError("message was not of open type"); + if (message.type !== "open") throw new TypeError("message was not of open type"); // onMeta({ // protocol: message.protocol, // setCookies: message.setCookies, @@ -526,7 +513,7 @@ remote: url.toString(), protocols, headers: requestHeaders, - forwardHeaders: [] + forwardHeaders: [], }) ); // ); @@ -540,16 +527,13 @@ const options = { credentials: "omit", method: method, - signal + signal, }; if (body !== undefined) { options.body = body; } options.headers = this.createBareHeaders(remote, headers); - const response = await fetch( - this.http + "?cache=" + md5(remote.toString()), - options - ); + const response = await fetch(this.http + "?cache=" + md5(remote.toString()), options); const readResponse = await this.readBareResponse(response); // const result: Response & Partial = new Response( // statusEmpty.includes(readResponse.status!) ? undefined : response.body, @@ -566,7 +550,7 @@ body: response.body, headers: readResponse.headers, status: readResponse.status, - statusText: readResponse.statusText + statusText: readResponse.statusText, }; } async readBareResponse(response) { @@ -583,13 +567,7 @@ if (xBareHeaders !== null) result.headers = JSON.parse(xBareHeaders); return result; } - createBareHeaders( - remote, - bareHeaders, - forwardHeaders = [], - passHeaders = [], - passStatus = [] - ) { + createBareHeaders(remote, bareHeaders, forwardHeaders = [], passHeaders = [], passStatus = []) { const headers = new Headers(); headers.set("x-bare-url", remote.toString()); headers.set("x-bare-headers", JSON.stringify(bareHeaders)); @@ -608,4 +586,4 @@ } exports.BareClient = ClientV3; -}); \ No newline at end of file +}); diff --git a/public/sw.js b/public/sw.js index e0285d3..b132ade 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,6 +1,6 @@ importScripts("/libcurl/index.js"); importScripts("/epoxy/index.js"); -importScripts("/bare_transport.js") +importScripts("/bare_transport.js"); importScripts("/uv/uv.bundle.js"); importScripts("/uv.config.js"); importScripts(__uv$config.sw); diff --git a/src/components/ProxyRegistrar.astro b/src/components/ProxyRegistrar.astro index 4596cd2..4d11d0b 100644 --- a/src/components/ProxyRegistrar.astro +++ b/src/components/ProxyRegistrar.astro @@ -1,10 +1,10 @@ - - - - - + + + + + diff --git a/src/components/SettingsContent/CloakingTab.astro b/src/components/SettingsContent/CloakingTab.astro index 035fa32..a8bf279 100644 --- a/src/components/SettingsContent/CloakingTab.astro +++ b/src/components/SettingsContent/CloakingTab.astro @@ -1,5 +1,7 @@ --- -import Input from "../Input.astro"; +import Input from "@components/UI/Input.astro"; +import { i18n } from "@i18n/utils"; +const t = i18n.inferLangUseTranslations(Astro.url); const presetCloaks = [ { @@ -8,8 +10,7 @@ const presetCloaks = [ }, { cloakTitle: "Google", - favicon: - "/icons/google.png", + favicon: "/icons/google.png", }, { cloakTitle: "Canvas", @@ -21,8 +22,7 @@ const presetCloaks = [ }, { cloakTitle: "Classlink", - favicon: - "/icons/classlink.png", + favicon: "/icons/classlink.png", }, { cloakTitle: "Google Drive", @@ -58,7 +58,7 @@ const presetCloaks = [
- +
diff --git a/src/components/SettingsContent/CreditsTab.astro b/src/components/SettingsContent/CreditsTab.astro index fd349ad..3f0da2f 100644 --- a/src/components/SettingsContent/CreditsTab.astro +++ b/src/components/SettingsContent/CreditsTab.astro @@ -1,7 +1,6 @@ --- -import { getLangFromUrl, useTranslations } from "../../i18n/utils"; -const lang = getLangFromUrl(Astro.url); -const t = useTranslations(lang); +import { i18n } from "@i18n/utils"; +const t = i18n.inferLangUseTranslations(Astro.url); ---
diff --git a/src/components/SettingsContent/CustomizationTab.astro b/src/components/SettingsContent/CustomizationTab.astro index ad30a91..f62f586 100644 --- a/src/components/SettingsContent/CustomizationTab.astro +++ b/src/components/SettingsContent/CustomizationTab.astro @@ -1,9 +1,8 @@ --- -import Dropdown from "../Dropdown.astro"; +import Dropdown from "@components/UI/Dropdown.astro"; -import { getLangFromUrl, useTranslations } from "../../i18n/utils"; -const lang = getLangFromUrl(Astro.url); -const t = useTranslations(lang); +import { i18n } from "@i18n/utils"; +const t = i18n.inferLangUseTranslations(Astro.url); const themeList = [ { name: t("settings.customization.theme.Alu"), value: "alu" }, diff --git a/src/components/SettingsContent/ProxyTab.astro b/src/components/SettingsContent/ProxyTab.astro index 97e8d6e..4b5d1d1 100644 --- a/src/components/SettingsContent/ProxyTab.astro +++ b/src/components/SettingsContent/ProxyTab.astro @@ -1,10 +1,9 @@ --- -import Input from "../Input.astro"; -import Dropdown from "../Dropdown.astro"; +import Input from "@components/UI/Input.astro"; +import Dropdown from "@components/UI/Dropdown.astro"; -import { getLangFromUrl, useTranslations } from "../../i18n/utils"; -const lang = getLangFromUrl(Astro.url); -const t = useTranslations(lang); +import { i18n } from "@i18n/utils"; +const t = i18n.inferLangUseTranslations(Astro.url); const proxyList = [ { name: t("settings.proxy.auto"), value: "auto" }, diff --git a/src/components/SettingsTablist.astro b/src/components/SettingsTablist.astro index aa5f07f..9597b12 100644 --- a/src/components/SettingsTablist.astro +++ b/src/components/SettingsTablist.astro @@ -1,12 +1,12 @@ --- import ProxyTab from "./SettingsContent/ProxyTab.astro"; import CustomizationTab from "./SettingsContent/CustomizationTab.astro"; - -import { getLangFromUrl, useTranslations } from "../i18n/utils"; import CloakingTab from "./SettingsContent/CloakingTab.astro"; import CreditsTab from "./SettingsContent/CreditsTab.astro"; -const lang = getLangFromUrl(Astro.url); -const t = useTranslations(lang); + +import { i18n } from "@i18n/utils"; +const lang = i18n.getLangFromUrl(Astro.url); +const t = i18n.useTranslations(lang); ---
diff --git a/src/components/Switch.astro b/src/components/Switch.astro deleted file mode 100644 index c55c047..0000000 --- a/src/components/Switch.astro +++ /dev/null @@ -1,192 +0,0 @@ ---- -const { inputID } = Astro.props; ---- - - - - diff --git a/src/components/Dropdown.astro b/src/components/UI/Dropdown.astro similarity index 100% rename from src/components/Dropdown.astro rename to src/components/UI/Dropdown.astro diff --git a/src/components/Footer.astro b/src/components/UI/Footer.astro similarity index 87% rename from src/components/Footer.astro rename to src/components/UI/Footer.astro index 3371c37..50bb566 100644 --- a/src/components/Footer.astro +++ b/src/components/UI/Footer.astro @@ -1,9 +1,8 @@ --- -import { getLangFromUrl, useTranslations } from "../i18n/utils"; +import { i18n } from "@i18n/utils"; import Link from "./Link.astro"; -import WaveSVG from "./WaveSVG.astro"; -const lang = getLangFromUrl(Astro.url); -const t = useTranslations(lang); +import WaveSVG from "../WaveSVG.astro"; +const t = i18n.inferLangUseTranslations(Astro.url); ---