This commit is contained in:
velzie 2024-07-19 18:05:20 -04:00
commit 3d30e20150
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
7 changed files with 1637 additions and 3469 deletions

View file

@ -27,7 +27,7 @@
"@fastify/static": "^7.0.3",
"@mercuryworkshop/bare-as-module3": "^2.2.2",
"@mercuryworkshop/epoxy-transport": "^2.1.3",
"@mercuryworkshop/libcurl-transport": "^1.3.6",
"@mercuryworkshop/libcurl-transport": "^1.3.7",
"@rsdoctor/rspack-plugin": "^0.3.7",
"@rspack/cli": "^0.7.5",
"@rspack/core": "^0.7.5",
@ -56,6 +56,7 @@
"domutils": "^3.1.0",
"htmlparser2": "^9.1.0",
"meriyah": "^4.4.2",
"parse-domain": "^8.0.2"
"parse-domain": "^8.0.2",
"wisp-server-node": "^1.1.1"
}
}

5056
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,7 @@ import fastifyStatic from "@fastify/static";
import { join } from "node:path";
import { spawn } from "node:child_process";
import { fileURLToPath } from "node:url";
import wisp from "wisp-server-node";
//transports
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
@ -32,7 +33,7 @@ const fastify = Fastify({
if (bare.shouldRoute(req)) {
bare.routeUpgrade(req, socket, head);
} else {
socket.end();
wisp.routeRequest(req, socket, head);
}
});
},
@ -72,7 +73,7 @@ fastify.listen({
host: "0.0.0.0",
});
writeFileSync(".git/hooks/pre-commit", "pnpm prettier . -w");
writeFileSync(".git/hooks/pre-commit", "pnpm prettier . -w\ngit add -A");
chmodSync(".git/hooks/pre-commit", 0o755);
const watch = spawn("pnpm", ["rspack", "-w"], {

View file

@ -8,7 +8,7 @@ const store = new IDBMapSync(locationProxy.host, {
await store.sync();
const localStorageProxy = new Proxy(window.localStorage, {
const localStorageProxy = new Proxy(window.localStorage, {
get(target, prop) {
switch (prop) {
case "getItem":
@ -68,17 +68,17 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
case "getItem":
return (key: string) => {
return target.getItem(locationProxy.host + "@" + key);
}
};
case "setItem":
return (key: string, value: string) => {
target.setItem(locationProxy.host + "@" + key, value);
}
};
case "removeItem":
return (key: string) => {
target.removeItem(locationProxy.host + "@" + key);
}
};
case "clear":
return () => {
@ -87,14 +87,16 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
target.removeItem(key);
}
}
}
};
case "key":
return (index: number) => {
const keys = Object.keys(target).filter((key) => key.startsWith(locationProxy.host));
const keys = Object.keys(target).filter((key) =>
key.startsWith(locationProxy.host)
);
return target.getItem(keys[index]);
}
};
case "length":
return target.length;
@ -109,8 +111,11 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
},
defineProperty(target, property, attributes) {
target.setItem(locationProxy.host + "@" + (property as string), attributes.value);
target.setItem(
locationProxy.host + "@" + (property as string),
attributes.value
);
return true;
},
});
@ -119,4 +124,4 @@ delete window.localStorage;
delete window.sessionStorage;
window.localStorage = localStorageProxy;
window.sessionStorage = sessionStorageProxy;
window.sessionStorage = sessionStorageProxy;

View file

@ -37,7 +37,10 @@ export function rewriteHeaders(rawHeaders: BareHeaders, origin?: URL) {
urlHeaders.forEach((header) => {
if (headers[header])
headers[header] = encodeUrl(headers[header] as string, origin);
headers[header] = encodeUrl(
headers[header]?.toString() as string,
origin
);
});
if (headers["link"]) {

View file

@ -73,9 +73,7 @@ async function handleResponse(
switch (destination) {
case "iframe":
case "document":
if (
responseHeaders["content-type"]?.toString()?.startsWith("text/html")
) {
if (responseHeaders["content-type"]?.startsWith("text/html")) {
responseBody = rewriteHtml(await response.text(), url);
} else {
responseBody = response.body;

View file

@ -28,7 +28,11 @@ const col = css`
const store = $store(
{
url: "https://google.com",
wispurl: "wss://wisp.mercurywork.shop/",
wispurl:
(location.protocol === "https:" ? "wss" : "ws") +
"://" +
location.host +
"/wisp/",
bareurl:
(location.protocol === "https:" ? "https" : "http") +
"://" +