Add libcurl

This commit is contained in:
MotorTruck1221 2024-03-09 02:51:29 -07:00
parent c5e05997dd
commit bf24bf53c0
No known key found for this signature in database
GPG key ID: 06901A625432AC21
4 changed files with 17 additions and 18 deletions

View file

@ -1,4 +1,5 @@
importScripts("/epoxy/index.js");
importScripts("/libcurl/index.cjs");
importScripts("/uv/uv.bundle.js");
importScripts("/uv/uv.config.js");
importScripts(__uv$config.sw || "/uv/uv.sw.js");

View file

@ -123,7 +123,14 @@ async function MasqFail(req: Request, res: Response) {
return;
}) */
app.use(express.static("dist"));
app.use(express.static("dist", {
//force .cjs files to be served as text/javascript (libcurl)
setHeaders: (res, path) => {
if (path.endsWith(".cjs")) {
res.setHeader("Content-Type", "text/javascript");
}
}
}));
app.get("/search=:query", async (req: Request, res: Response) => {
const { query } = req.params;

View file

@ -33,8 +33,7 @@ const Proxy = ({ id, active }) => {
(location.protocol === "https:" ? "wss://" : "ws://") +
location.host +
"/wisp/";
//libcurl can be added here when it's stable
const transports = [{ id: "epoxy", label: "Epoxy" }];
const transports = [{ id: "epoxy", label: "Epoxy" }, { id: "libcurl", label: "Libcurl" }];
return (
<motion.div

View file

@ -14,10 +14,15 @@ function changeTransport(transport: string, wispUrl: string) {
switch (transport) {
case "epoxy":
localStorage.setItem("transport", "epoxy");
console.log("Setting transport to 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
case "libcurl":
localStorage.setItem("transport", "libcurl");
console.log("Setting transport to Libcurl");
SetTransport("CurlMod.LibcurlClient", { wisp: wispUrl, wasm: "/libcurl.wasm" });
break;
//stuff like bare-as-module3 COULD also be added
default:
SetTransport("EpxMod.EpoxyClient", { wisp: wispUrl });
break;
@ -28,19 +33,6 @@ 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 +