From b152154cf0ad41ff4dcb44c198e6f6505f72e337 Mon Sep 17 00:00:00 2001 From: rift <117926989+Riftriot@users.noreply.github.com> Date: Sun, 7 Apr 2024 16:01:41 -0500 Subject: [PATCH] There ARE bare clients !? --- index.html | 19 ------------ src/components/iframe/IframeHeader.tsx | 2 +- src/routes.tsx | 42 +++++++++++++++++--------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/index.html b/index.html index 8e0c8d9..5e88cb8 100644 --- a/index.html +++ b/index.html @@ -10,25 +10,6 @@ -
diff --git a/src/components/iframe/IframeHeader.tsx b/src/components/iframe/IframeHeader.tsx index 5d4c685..f0fe784 100644 --- a/src/components/iframe/IframeHeader.tsx +++ b/src/components/iframe/IframeHeader.tsx @@ -12,7 +12,7 @@ import { IoChevronForwardSharp, IoReloadSharp } from "react-icons/io5"; -import { FaShareAlt } from "react-icons/fa"; +import { FaShareAlt, FaPencilAlt } from "react-icons/fa"; import { FaXmark } from "react-icons/fa6"; interface ProxyFrame extends HTMLElement { diff --git a/src/routes.tsx b/src/routes.tsx index eb1d171..20bd1c2 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -7,25 +7,39 @@ import { Radon } from "./pages/Radon"; import { Settings } from "./pages/Settings/"; import { AboutBlank } from "./AboutBlank"; import { Faq } from "./pages/Faq"; -//import { setTransport } from "./util/transports.js"; +import { SetTransport } from "@mercuryworkshop/bare-mux"; import "./style.css"; import "./i18n"; -import { setTransport } from "./util/transports"; export default function Routes() { - //if ("serviceWorker" in navigator) { - //window.addEventListener("load", () => { - // navigator.serviceWorker - // .register("/sw.js", { - // scope: "/~/" - // }) - // .then(() => { - // console.log("Service worker registered successfully"); - // setTransport(); - // }); - //}); - //} + const wispUrl = + (location.protocol === "https:" ? "wss://" : "ws://") + + location.host + + "/wisp/"; // @TODO Japan - US ping + + if ("serviceWorker" in navigator) { + console.log("am bout to bus"); + navigator.serviceWorker + .register("/sw.js", { + scope: "/~/" + }) + .then(() => { + console.log("Service Worker Registered"); + try { + localStorage.setItem("transport", "libcurl"); + console.log("Setting transport to Libcurl"); + SetTransport("CurlMod.LibcurlClient", { + wisp: wispUrl + }); + } catch {} + }) + .catch((err) => { + console.error("Service Worker Failed to Register", err); + }); + } else { + alert("err"); + } return (