mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 07:20:02 -04:00
Merge branch 'main' of https://github.com/MercuryWorkshop/aerojet
This commit is contained in:
commit
3d30e20150
7 changed files with 1637 additions and 3469 deletions
|
@ -27,7 +27,7 @@
|
||||||
"@fastify/static": "^7.0.3",
|
"@fastify/static": "^7.0.3",
|
||||||
"@mercuryworkshop/bare-as-module3": "^2.2.2",
|
"@mercuryworkshop/bare-as-module3": "^2.2.2",
|
||||||
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
||||||
"@mercuryworkshop/libcurl-transport": "^1.3.6",
|
"@mercuryworkshop/libcurl-transport": "^1.3.7",
|
||||||
"@rsdoctor/rspack-plugin": "^0.3.7",
|
"@rsdoctor/rspack-plugin": "^0.3.7",
|
||||||
"@rspack/cli": "^0.7.5",
|
"@rspack/cli": "^0.7.5",
|
||||||
"@rspack/core": "^0.7.5",
|
"@rspack/core": "^0.7.5",
|
||||||
|
@ -56,6 +56,7 @@
|
||||||
"domutils": "^3.1.0",
|
"domutils": "^3.1.0",
|
||||||
"htmlparser2": "^9.1.0",
|
"htmlparser2": "^9.1.0",
|
||||||
"meriyah": "^4.4.2",
|
"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
5056
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,7 @@ import fastifyStatic from "@fastify/static";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
import wisp from "wisp-server-node";
|
||||||
|
|
||||||
//transports
|
//transports
|
||||||
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
|
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
|
||||||
|
@ -32,7 +33,7 @@ const fastify = Fastify({
|
||||||
if (bare.shouldRoute(req)) {
|
if (bare.shouldRoute(req)) {
|
||||||
bare.routeUpgrade(req, socket, head);
|
bare.routeUpgrade(req, socket, head);
|
||||||
} else {
|
} else {
|
||||||
socket.end();
|
wisp.routeRequest(req, socket, head);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -72,7 +73,7 @@ fastify.listen({
|
||||||
host: "0.0.0.0",
|
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);
|
chmodSync(".git/hooks/pre-commit", 0o755);
|
||||||
|
|
||||||
const watch = spawn("pnpm", ["rspack", "-w"], {
|
const watch = spawn("pnpm", ["rspack", "-w"], {
|
||||||
|
|
|
@ -8,7 +8,7 @@ const store = new IDBMapSync(locationProxy.host, {
|
||||||
|
|
||||||
await store.sync();
|
await store.sync();
|
||||||
|
|
||||||
const localStorageProxy = new Proxy(window.localStorage, {
|
const localStorageProxy = new Proxy(window.localStorage, {
|
||||||
get(target, prop) {
|
get(target, prop) {
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
case "getItem":
|
case "getItem":
|
||||||
|
@ -68,17 +68,17 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
|
||||||
case "getItem":
|
case "getItem":
|
||||||
return (key: string) => {
|
return (key: string) => {
|
||||||
return target.getItem(locationProxy.host + "@" + key);
|
return target.getItem(locationProxy.host + "@" + key);
|
||||||
}
|
};
|
||||||
|
|
||||||
case "setItem":
|
case "setItem":
|
||||||
return (key: string, value: string) => {
|
return (key: string, value: string) => {
|
||||||
target.setItem(locationProxy.host + "@" + key, value);
|
target.setItem(locationProxy.host + "@" + key, value);
|
||||||
}
|
};
|
||||||
|
|
||||||
case "removeItem":
|
case "removeItem":
|
||||||
return (key: string) => {
|
return (key: string) => {
|
||||||
target.removeItem(locationProxy.host + "@" + key);
|
target.removeItem(locationProxy.host + "@" + key);
|
||||||
}
|
};
|
||||||
|
|
||||||
case "clear":
|
case "clear":
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -87,14 +87,16 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
|
||||||
target.removeItem(key);
|
target.removeItem(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
case "key":
|
case "key":
|
||||||
return (index: number) => {
|
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]);
|
return target.getItem(keys[index]);
|
||||||
}
|
};
|
||||||
|
|
||||||
case "length":
|
case "length":
|
||||||
return target.length;
|
return target.length;
|
||||||
|
@ -109,8 +111,11 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
|
||||||
},
|
},
|
||||||
|
|
||||||
defineProperty(target, property, attributes) {
|
defineProperty(target, property, attributes) {
|
||||||
target.setItem(locationProxy.host + "@" + (property as string), attributes.value);
|
target.setItem(
|
||||||
|
locationProxy.host + "@" + (property as string),
|
||||||
|
attributes.value
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -119,4 +124,4 @@ delete window.localStorage;
|
||||||
delete window.sessionStorage;
|
delete window.sessionStorage;
|
||||||
|
|
||||||
window.localStorage = localStorageProxy;
|
window.localStorage = localStorageProxy;
|
||||||
window.sessionStorage = sessionStorageProxy;
|
window.sessionStorage = sessionStorageProxy;
|
||||||
|
|
|
@ -37,7 +37,10 @@ export function rewriteHeaders(rawHeaders: BareHeaders, origin?: URL) {
|
||||||
|
|
||||||
urlHeaders.forEach((header) => {
|
urlHeaders.forEach((header) => {
|
||||||
if (headers[header])
|
if (headers[header])
|
||||||
headers[header] = encodeUrl(headers[header] as string, origin);
|
headers[header] = encodeUrl(
|
||||||
|
headers[header]?.toString() as string,
|
||||||
|
origin
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (headers["link"]) {
|
if (headers["link"]) {
|
||||||
|
|
|
@ -73,9 +73,7 @@ async function handleResponse(
|
||||||
switch (destination) {
|
switch (destination) {
|
||||||
case "iframe":
|
case "iframe":
|
||||||
case "document":
|
case "document":
|
||||||
if (
|
if (responseHeaders["content-type"]?.startsWith("text/html")) {
|
||||||
responseHeaders["content-type"]?.toString()?.startsWith("text/html")
|
|
||||||
) {
|
|
||||||
responseBody = rewriteHtml(await response.text(), url);
|
responseBody = rewriteHtml(await response.text(), url);
|
||||||
} else {
|
} else {
|
||||||
responseBody = response.body;
|
responseBody = response.body;
|
||||||
|
|
|
@ -28,7 +28,11 @@ const col = css`
|
||||||
const store = $store(
|
const store = $store(
|
||||||
{
|
{
|
||||||
url: "https://google.com",
|
url: "https://google.com",
|
||||||
wispurl: "wss://wisp.mercurywork.shop/",
|
wispurl:
|
||||||
|
(location.protocol === "https:" ? "wss" : "ws") +
|
||||||
|
"://" +
|
||||||
|
location.host +
|
||||||
|
"/wisp/",
|
||||||
bareurl:
|
bareurl:
|
||||||
(location.protocol === "https:" ? "https" : "http") +
|
(location.protocol === "https:" ? "https" : "http") +
|
||||||
"://" +
|
"://" +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue