diff --git a/src/pages/Settings/ProxyInput.tsx b/src/pages/Settings/ProxyInput.tsx
index 77ac484..afbbaa5 100644
--- a/src/pages/Settings/ProxyInput.tsx
+++ b/src/pages/Settings/ProxyInput.tsx
@@ -1,140 +1,140 @@
-import { useState, useEffect } from "preact/hooks";
-import { set } from "../../util/IDB";
-import { uninstallServiceWorkers } from "../../util/SWHelper";
-import { useTranslation } from "react-i18next";
-import { ToastContainer, toast } from "react-toastify";
-
-interface BareInputProps {
- placeholder: string;
- storageKey: string;
-}
-
-function ProxyInput(props: BareInputProps) {
- const { t } = useTranslation();
- const bareServer = localStorage.getItem("bare") || "/bare/";
- const HTTPProxy = localStorage.getItem("HTTPProxy") || "";
- const [inputValue, setInputValue] = useState(HTTPProxy);
-
- function resetProxy() {
- set("HTTPProxy", "");
- localStorage.setItem("HTTPProxy", "");
- uninstallServiceWorkers();
- window.location.reload();
- }
-
- function validateUrl(url: string) {
- let finalUrl = url;
-
- if (url === null || url === undefined || url === "") {
- finalUrl = "";
- return finalUrl;
- }
-
- return finalUrl;
- }
- function handleChange() {
- const proxyUrl = validateUrl(
- (document.getElementById("pinput") as HTMLInputElement).value
- );
-
- if (!(proxyUrl === "")) {
- const [proxyIP, proxyPort] = proxyUrl.split(":");
-
- fetch(bareServer)
- .then((response) => response.json())
- .then((jsonResponse) => {
- if (jsonResponse.hasOwnProperty("HTTPProxy")) {
- const headers = new Headers({
- "x-bare-url": "https://www.google.com",
- "X-Bare-Headers": JSON.stringify({
- Accept:
- "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
- }),
- "x-bare-proxy-ip": proxyIP,
- "x-bare-proxy-port": proxyPort
- });
-
- return fetch(bareServer + "v3/", {
- method: "GET",
- headers: headers
- })
- .then((response) => {
- if (
- response.headers.get("x-bare-status") === "200" ||
- response.headers.get("x-bare-status") === "302"
- ) {
- // Success!
- set("HTTPProxy", proxyUrl);
- localStorage.setItem("HTTPProxy", proxyUrl);
- uninstallServiceWorkers();
- window.location.reload();
- return true;
- } else {
- (
- document.getElementById("pinput") as HTMLInputElement
- ).value = localStorage.getItem("HTTPProxy") || "";
- toast(t("settings.httpProxy.badProxy"), {
- type: "error"
- });
- }
- })
- .catch((error) => {
- (document.getElementById("pinput") as HTMLInputElement).value =
- localStorage.getItem("HTTPProxy") || "";
- toast(t("settings.httpProxy.badProxy"), {
- type: "error"
- });
- });
- } else {
- (document.getElementById("pinput") as HTMLInputElement).value =
- localStorage.getItem("HTTPProxy") || "";
- toast(t("settings.httpProxy.badBare"), {
- type: "error"
- });
- }
- })
- .catch((error) => console.error("Error:", error));
- } else {
- // reset UV config to have no proxy
- set("HTTPProxy", "");
- localStorage.setItem("HTTPProxy", "");
- uninstallServiceWorkers();
- window.location.reload();
- }
- }
- return (
-
-
-
-
{
- if (event.key === "Enter") {
- handleChange();
- }
- }}
- id="pinput"
- className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-sm text-input-text"
- />
-
-
- {t("settings.bare.select")}
-
-
- {t("settings.httpProxy.reset")}
-
-
-
-
- );
-}
-
-export default ProxyInput;
+import { useState, useEffect } from "preact/hooks";
+import { set } from "../../util/IDB";
+import { uninstallServiceWorkers } from "../../util/SWHelper";
+import { useTranslation } from "react-i18next";
+import { ToastContainer, toast } from "react-toastify";
+
+interface BareInputProps {
+ placeholder: string;
+ storageKey: string;
+}
+
+function ProxyInput(props: BareInputProps) {
+ const { t } = useTranslation();
+ const bareServer = localStorage.getItem("bare") || "/bare/";
+ const HTTPProxy = localStorage.getItem("HTTPProxy") || "";
+ const [inputValue, setInputValue] = useState(HTTPProxy);
+
+ function resetProxy() {
+ set("HTTPProxy", "");
+ localStorage.setItem("HTTPProxy", "");
+ uninstallServiceWorkers();
+ window.location.reload();
+ }
+
+ function validateUrl(url: string) {
+ let finalUrl = url;
+
+ if (url === null || url === undefined || url === "") {
+ finalUrl = "";
+ return finalUrl;
+ }
+
+ return finalUrl;
+ }
+ function handleChange() {
+ const proxyUrl = validateUrl(
+ (document.getElementById("pinput") as HTMLInputElement).value
+ );
+
+ if (!(proxyUrl === "")) {
+ const [proxyIP, proxyPort] = proxyUrl.split(":");
+
+ fetch(bareServer)
+ .then((response) => response.json())
+ .then((jsonResponse) => {
+ if (jsonResponse.hasOwnProperty("HTTPProxy")) {
+ const headers = new Headers({
+ "x-bare-url": "https://www.google.com",
+ "X-Bare-Headers": JSON.stringify({
+ Accept:
+ "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
+ }),
+ "x-bare-proxy-ip": proxyIP,
+ "x-bare-proxy-port": proxyPort
+ });
+
+ return fetch(bareServer + "v3/", {
+ method: "GET",
+ headers: headers
+ })
+ .then((response) => {
+ if (
+ response.headers.get("x-bare-status") === "200" ||
+ response.headers.get("x-bare-status") === "302"
+ ) {
+ // Success!
+ set("HTTPProxy", proxyUrl);
+ localStorage.setItem("HTTPProxy", proxyUrl);
+ uninstallServiceWorkers();
+ window.location.reload();
+ return true;
+ } else {
+ (
+ document.getElementById("pinput") as HTMLInputElement
+ ).value = localStorage.getItem("HTTPProxy") || "";
+ toast(t("settings.httpProxy.badProxy"), {
+ type: "error"
+ });
+ }
+ })
+ .catch((error) => {
+ (document.getElementById("pinput") as HTMLInputElement).value =
+ localStorage.getItem("HTTPProxy") || "";
+ toast(t("settings.httpProxy.badProxy"), {
+ type: "error"
+ });
+ });
+ } else {
+ (document.getElementById("pinput") as HTMLInputElement).value =
+ localStorage.getItem("HTTPProxy") || "";
+ toast(t("settings.httpProxy.badBare"), {
+ type: "error"
+ });
+ }
+ })
+ .catch((error) => console.error("Error:", error));
+ } else {
+ // reset UV config to have no proxy
+ set("HTTPProxy", "");
+ localStorage.setItem("HTTPProxy", "");
+ uninstallServiceWorkers();
+ window.location.reload();
+ }
+ }
+ return (
+
+
+
+
{
+ if (event.key === "Enter") {
+ handleChange();
+ }
+ }}
+ id="pinput"
+ className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-sm text-input-text"
+ />
+
+
+ {t("settings.bare.select")}
+
+
+ {t("settings.httpProxy.reset")}
+
+
+
+
+ );
+}
+
+export default ProxyInput;
diff --git a/src/pages/Settings/WispInput.tsx b/src/pages/Settings/WispInput.tsx
index dec8a8d..d84a79f 100644
--- a/src/pages/Settings/WispInput.tsx
+++ b/src/pages/Settings/WispInput.tsx
@@ -1,58 +1,66 @@
-import { useState, useEffect } from "preact/hooks";
-import { useTranslation } from "react-i18next";
-import { changeTransport } from "../../util/transports";
-import { ToastContainer, toast } from "react-toastify";
-
-interface WispInputProps {
- placeholder: string;
-}
-
-function WispInput(props: WispInputProps) {
- const { t } = useTranslation();
- const value = localStorage.getItem("wispUrl") || (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
- const [inputValue, setInputValue] = useState(value);
- function validateUrl(url: string) {
- let finalUrl = url;
- if (finalUrl.startsWith("http://")) {
- finalUrl = finalUrl.replace("http://", "ws://");
- } else if (finalUrl.startsWith("https://")) {
- finalUrl = finalUrl.replace("https://", "wss://");
- }
- else if (finalUrl === "" || finalUrl === null || finalUrl === undefined) {
- finalUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
- }
- return finalUrl;
- }
- function handleChange() {
- const url = validateUrl((document.getElementById("wispinput") as HTMLInputElement).value);
- localStorage.setItem("wispUrl", url);
- changeTransport(localStorage.getItem("transport") || "epoxy", url);
- }
- return (
-
-
-
-
{
- if (event.key === "Enter") {
- handleChange();
- }
- }}
- id="wispinput"
- className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-xl text-input-text"
- />
-
- Select
-
-
-
- );
-}
-
-export default WispInput;
+import { useState, useEffect } from "preact/hooks";
+import { useTranslation } from "react-i18next";
+import { changeTransport } from "../../util/transports";
+import { ToastContainer, toast } from "react-toastify";
+
+interface WispInputProps {
+ placeholder: string;
+}
+
+function WispInput(props: WispInputProps) {
+ const { t } = useTranslation();
+ const value =
+ localStorage.getItem("wispUrl") ||
+ (location.protocol === "https:" ? "wss://" : "ws://") +
+ location.host +
+ "/wisp/";
+ const [inputValue, setInputValue] = useState(value);
+ function validateUrl(url: string) {
+ let finalUrl = url;
+ if (finalUrl.startsWith("http://")) {
+ finalUrl = finalUrl.replace("http://", "ws://");
+ } else if (finalUrl.startsWith("https://")) {
+ finalUrl = finalUrl.replace("https://", "wss://");
+ } else if (finalUrl === "" || finalUrl === null || finalUrl === undefined) {
+ finalUrl =
+ (location.protocol === "https:" ? "wss://" : "ws://") +
+ location.host +
+ "/wisp/";
+ }
+ return finalUrl;
+ }
+ function handleChange() {
+ const url = validateUrl(
+ (document.getElementById("wispinput") as HTMLInputElement).value
+ );
+ localStorage.setItem("wispUrl", url);
+ changeTransport(localStorage.getItem("transport") || "epoxy", url);
+ }
+ return (
+
+
+
+
{
+ if (event.key === "Enter") {
+ handleChange();
+ }
+ }}
+ id="wispinput"
+ className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-xl text-input-text"
+ />
+
+ Select
+
+
+
+ );
+}
+
+export default WispInput;
diff --git a/src/pages/config.json b/src/pages/config.json
index f2ea571..4d20b55 100644
--- a/src/pages/config.json
+++ b/src/pages/config.json
@@ -1,3 +1,3 @@
-{
- "prod": false
-}
+{
+ "prod": false
+}
diff --git a/src/util/transports.ts b/src/util/transports.ts
index 56f7aa5..1a519d2 100644
--- a/src/util/transports.ts
+++ b/src/util/transports.ts
@@ -1,40 +1,54 @@
-import { SetTransport, registerRemoteListener } from "@mercuryworkshop/bare-mux";
-
-
-declare global {
- interface Window {
- BareMux: any;
- p: any;
- }
-}
-
-function changeTransport(transport: string, wispUrl: string) {
- switch (transport) {
- case "epoxy":
- localStorage.setItem("transport", "epoxy");
- SetTransport("EpxMod.EpoxyClient", { wisp: wispUrl });
- break;
- //libcurl when supported can be easily added here
- //and stuff like bare-as-module3 COULD also be added
- default:
- SetTransport("EpxMod.EpoxyClient", { wisp: wispUrl });
- break;
- }
-}
-
-function getTransport() {
- return localStorage.getItem("transport") || "epoxy";
-}
-
-function restartTransport() {
- changeTransport(getTransport(), localStorage.getItem("wispUrl") || (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/");
-}
-
-//restart transport every minute
-setInterval(restartTransport, 60000); //60000ms = 60s = 1m
-
-const wispUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
-registerRemoteListener(navigator.serviceWorker.controller!);
-changeTransport(localStorage.getItem("transport") || "epoxy", localStorage.getItem("wispUrl") || wispUrl);
-
-export { changeTransport, getTransport };
+import {
+ SetTransport,
+ registerRemoteListener
+} from "@mercuryworkshop/bare-mux";
+
+declare global {
+ interface Window {
+ BareMux: any;
+ p: any;
+ }
+}
+
+function changeTransport(transport: string, wispUrl: string) {
+ switch (transport) {
+ case "epoxy":
+ localStorage.setItem("transport", "epoxy");
+ SetTransport("EpxMod.EpoxyClient", { wisp: wispUrl });
+ break;
+ //libcurl when supported can be easily added here
+ //and stuff like bare-as-module3 COULD also be added
+ default:
+ SetTransport("EpxMod.EpoxyClient", { wisp: wispUrl });
+ break;
+ }
+}
+
+function getTransport() {
+ return localStorage.getItem("transport") || "epoxy";
+}
+
+function restartTransport() {
+ changeTransport(
+ getTransport(),
+ localStorage.getItem("wispUrl") ||
+ (location.protocol === "https:" ? "wss://" : "ws://") +
+ location.host +
+ "/wisp/"
+ );
+}
+
+//restart transport every minute
+setInterval(restartTransport, 60000); //60000ms = 60s = 1m
+
+const wispUrl =
+ (location.protocol === "https:" ? "wss://" : "ws://") +
+ location.host +
+ "/wisp/";
+registerRemoteListener(navigator.serviceWorker.controller!);
+changeTransport(
+ localStorage.getItem("transport") || "epoxy",
+ localStorage.getItem("wispUrl") || wispUrl
+);
+
+export { changeTransport, getTransport };
diff --git a/vite.config.ts b/vite.config.ts
index 3940dd6..c179700 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -25,10 +25,10 @@ export default defineConfig({
// overwrite: false
//},
{
- //include ALL files types
- src: `${epoxyPath}/**/*`,
- dest: "epoxy",
- overwrite: false
+ //include ALL files types
+ src: `${epoxyPath}/**/*`,
+ dest: "epoxy",
+ overwrite: false
},
{
// .replace fixes weird paths on Windows