This commit is contained in:
rift 2024-11-03 20:05:10 -06:00
parent 835cb237d7
commit fc414951d1
6 changed files with 4728 additions and 5425 deletions

View file

@ -31,8 +31,6 @@
"@mercuryworkshop/epoxy-transport": "2.1.13", "@mercuryworkshop/epoxy-transport": "2.1.13",
"@mercuryworkshop/libcurl-transport": "^1.3.10", "@mercuryworkshop/libcurl-transport": "^1.3.10",
"@playform/compress": "^0.1.4", "@playform/compress": "^0.1.4",
"@rubynetwork/rammerhead": "^1.3.5",
"@rubynetwork/rammerhead-browser": "^1.0.9",
"@titaniumnetwork-dev/ultraviolet": "^3.2.7", "@titaniumnetwork-dev/ultraviolet": "^3.2.7",
"@svelte-drama/suspense": "0.5.1", "@svelte-drama/suspense": "0.5.1",
"@types/node": "^22.7.5", "@types/node": "^22.7.5",

9402
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -17,3 +17,9 @@
--tab-color: var(--black); --tab-color: var(--black);
--border-color: #16121f; --border-color: #16121f;
} }
.roboto {
font-family: "Roboto", sans-serif;
font-weight: 200;
font-style: normal;
}

View file

@ -1,20 +1,16 @@
import { createServer } from "node:http"; import { createServer } from "node:http";
import rammerhead from "@rubynetwork/rammerhead"; import {
import { FastifyServerFactory, FastifyServerFactoryHandler, RawServerDefault } from "fastify"; FastifyServerFactory,
FastifyServerFactoryHandler,
RawServerDefault,
} from "fastify";
import wisp from "wisp-server-node"; import wisp from "wisp-server-node";
import { LOG_LEVEL, WispOptions } from "wisp-server-node/dist/Types.js"; import { LOG_LEVEL, WispOptions } from "wisp-server-node/dist/Types.js";
import { parsedDoc } from "./config.js"; import { parsedDoc } from "./config.js";
const rh = rammerhead.createRammerhead({
logLevel: parsedDoc.server.server.logging ? "debug" : "disabled",
reverseProxy: parsedDoc.server.rammerhead.reverseproxy,
disableLocalStorageSync: parsedDoc.server.rammerhead.localstorage_sync ? false : true,
disableHttp2: parsedDoc.server.rammerhead.http2 ? false : true
});
const wispOptions: WispOptions = { const wispOptions: WispOptions = {
logLevel: parsedDoc.server.server.logging ? LOG_LEVEL.DEBUG : LOG_LEVEL.NONE, logLevel: parsedDoc.server.server.logging ? LOG_LEVEL.DEBUG : LOG_LEVEL.NONE,
pingInterval: 30 pingInterval: 30,
}; };
const serverFactory: FastifyServerFactory = ( const serverFactory: FastifyServerFactory = (
@ -22,16 +18,10 @@ const serverFactory: FastifyServerFactory = (
): RawServerDefault => { ): RawServerDefault => {
const httpServer = createServer(); const httpServer = createServer();
httpServer.on("request", (req, res) => { httpServer.on("request", (req, res) => {
if (rammerhead.shouldRouteRh(req)) {
rammerhead.routeRhRequest(rh, req, res);
} else {
handler(req, res); handler(req, res);
}
}); });
httpServer.on("upgrade", (req, socket, head) => { httpServer.on("upgrade", (req, socket, head) => {
if (rammerhead.shouldRouteRh(req)) { if (parsedDoc.server.server.wisp) {
rammerhead.routeRhUpgrade(rh, req, socket, head);
} else if (parsedDoc.server.server.wisp) {
if (req.url?.endsWith("/wisp/")) { if (req.url?.endsWith("/wisp/")) {
wisp.routeRequest(req, socket as any, head, wispOptions); wisp.routeRequest(req, socket as any, head, wispOptions);
} }

View file

@ -17,7 +17,7 @@ const { title, noHeader } = Astro.props;
<SettingsLoader transition:persist /> <SettingsLoader transition:persist />
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="description" content="Astro description" /> <meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" id="favicon" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" id="favicon" />
<link <link
rel="stylesheet" rel="stylesheet"
@ -31,13 +31,19 @@ const { title, noHeader } = Astro.props;
as="style" as="style"
crossorigin="anonymous" crossorigin="anonymous"
/> />
<link rel="preload" href="https://fonts.gstatic.com/s/roboto/v32/KFOmCnqEu92Fr1Mu4mxK.woff2" as="font" type="font/woff2" crossorigin="anonymous" /> <link
rel="preload"
href="https://fonts.gstatic.com/s/roboto/v32/KFOmCnqEu92Fr1Mu4mxK.woff2"
as="font"
type="font/woff2"
crossorigin="anonymous"
/>
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<title>{title}</title> <title>{title}</title>
<ViewTransitions /> <ViewTransitions />
</head> </head>
<body class="h-full bg-primary"> <body class="h-full bg-primary">
{!noHeader && <Header /> } {!noHeader && <Header />}
<div class="h-full z-10 w-full fixed"> <div class="h-full z-10 w-full fixed">
<slot /> <slot />
</div> </div>
@ -90,9 +96,6 @@ const { title, noHeader } = Astro.props;
</style> </style>
<style is:global> <style is:global>
.roboto {
font-family: var(--font-family), Roboto;
}
/* Custom scrollbar because the default ones look like ASS */ /* Custom scrollbar because the default ones look like ASS */
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 0.5rem; width: 0.5rem;

View file

@ -3,7 +3,10 @@ import Logo from "@components/Logo.astro";
import Layout from "@layouts/Layout.astro"; import Layout from "@layouts/Layout.astro";
import { getLangFromUrl, useTranslations } from "../../i18n/utils"; import { getLangFromUrl, useTranslations } from "../../i18n/utils";
export function getStaticPaths() { export function getStaticPaths() {
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }]; const STATIC_PATHS = [
{ params: { lang: "en_US" } },
{ params: { lang: "jp" } },
];
return STATIC_PATHS; return STATIC_PATHS;
} }
export const prerender = true; export const prerender = true;
@ -13,13 +16,19 @@ import { VERSION } from "astro:env/client";
--- ---
<Layout title="Nebula"> <Layout title="Nebula">
<div class="flex flex-wrap mt-16 justify-center content-center w-full bg-primary fixed inset-0 h-[calc(100%-4rem)] z-0 flex-col items-center"> <div
<div class="w-full flex flex-col justify-center items-center content-center h-2/4"> class="flex flex-wrap mt-16 justify-center content-center w-full bg-primary fixed inset-0 h-[calc(100%-4rem)] z-0 flex-col items-center"
>
<div
class="w-full flex flex-col justify-center items-center content-center h-2/4"
>
<div class="flex flex-row items-center mb-8"> <div class="flex flex-row items-center mb-8">
<div class="h-32 w-32 fill-navbar-text-color"> <div class="h-32 w-32 fill-navbar-text-color">
<Logo /> <Logo />
</div> </div>
<h1 class="font-roboto whitespace-nowrap font-bold text-navbar-text-color sm:visible text-5xl sm:text-7xl roboto"> <h1
class="font-roboto whitespace-nowrap text-navbar-text-color sm:visible text-5xl sm:text-7xl roboto"
>
nebula. nebula.
</h1> </h1>
</div> </div>
@ -37,11 +46,13 @@ import { VERSION } from "astro:env/client";
<iframe <iframe
id="neb-iframe" id="neb-iframe"
class="hidden z-100 w-full h-full absolute top-0 bottom-0 bg-primary" class="hidden z-100 w-full h-full absolute top-0 bottom-0 bg-primary"
src="/loading" src="/loading"></iframe>
></iframe> <div
<div id="version" class="flex flex-row w-full absolute bottom-4 pr-4 pl-4 text-text-color h-6 justify-between font-roboto"> id="version"
<p> Version: { VERSION } </p> class="flex flex-row w-full absolute bottom-4 pr-4 pl-4 text-text-color h-6 justify-between font-roboto"
<p> &copy; Nebula Services 2024 </p> >
<p>Version: {VERSION}</p>
<p>&copy; Nebula Services 2024</p>
</div> </div>
</div> </div>
</Layout> </Layout>
@ -54,7 +65,7 @@ import { VERSION } from "astro:env/client";
SearchEngines, SearchEngines,
Settings, Settings,
cloak, cloak,
settings settings,
} from "@utils/settings/index"; } from "@utils/settings/index";
import { search } from "@utils/search.ts"; //../../utils/search.ts import { search } from "@utils/search.ts"; //../../utils/search.ts
import { client as libcurlClient } from "@utils/libcurl"; import { client as libcurlClient } from "@utils/libcurl";
@ -62,25 +73,44 @@ import { VERSION } from "astro:env/client";
phrase: string; phrase: string;
}; };
async function proxy(term: string, rh: boolean) { async function proxy(term: string, rh: boolean) {
const searchEngine = localStorage.getItem(Settings.ProxySettings.searchEngine); const searchEngine = localStorage.getItem(
Settings.ProxySettings.searchEngine
);
const openIn = localStorage.getItem(Settings.ProxySettings.openIn); const openIn = localStorage.getItem(Settings.ProxySettings.openIn);
let proxyUrl: any = __uv$config!.prefix + __uv$config.encodeUrl!(search(term, searchEngine ? SearchEngines[searchEngine] : SearchEngines.ddg)); let proxyUrl: any =
__uv$config!.prefix +
__uv$config.encodeUrl!(
search(
term,
searchEngine ? SearchEngines[searchEngine] : SearchEngines.ddg
)
);
if (rh) { if (rh) {
proxyUrl = await RammerheadEncode(search(term, searchEngine ? SearchEngines[searchEngine] : SearchEngines.ddg)); proxyUrl = await RammerheadEncode(
search(
term,
searchEngine ? SearchEngines[searchEngine] : SearchEngines.ddg
)
);
} }
if (openIn === "a:b" || openIn === "blob") { if (openIn === "a:b" || openIn === "blob") {
return cloak(openIn as string, "https://google.com", `${window.location.origin}${proxyUrl}`); return cloak(
} openIn as string,
else if (openIn === "direct") { "https://google.com",
`${window.location.origin}${proxyUrl}`
);
} else if (openIn === "direct") {
return (window.location.href = proxyUrl as string); return (window.location.href = proxyUrl as string);
} } else {
else {
return proxyUrl; return proxyUrl;
} }
} }
async function uv(iframe: HTMLIFrameElement, term: string) { async function uv(iframe: HTMLIFrameElement, term: string) {
const conn = await loadProxyScripts(); const conn = await loadProxyScripts();
await setTransport(conn, localStorage.getItem(Settings.ProxySettings.transport) as string); await setTransport(
conn,
localStorage.getItem(Settings.ProxySettings.transport) as string
);
const sw = await initSw(); const sw = await initSw();
await settings.marketPlaceSettings.handlePlugins(sw); await settings.marketPlaceSettings.handlePlugins(sw);
iframe.classList.remove("hidden"); iframe.classList.remove("hidden");
@ -93,7 +123,7 @@ import { VERSION } from "astro:env/client";
iframe.classList.remove("hidden"); iframe.classList.remove("hidden");
const url = await proxy(term, true); const url = await proxy(term, true);
if (url) { if (url) {
iframe.src = "/" + url as string; iframe.src = ("/" + url) as string;
} }
} }
//we need to rerun this on every page load //we need to rerun this on every page load
@ -105,9 +135,11 @@ import { VERSION } from "astro:env/client";
input?.addEventListener("keypress", async function (event: any) { input?.addEventListener("keypress", async function (event: any) {
if (event.key === "Enter") { if (event.key === "Enter") {
copyright.classList.add("hidden"); copyright.classList.add("hidden");
if (localStorage.getItem(Settings.ProxySettings.proxy) === "automatic") { if (
localStorage.getItem(Settings.ProxySettings.proxy) === "automatic"
) {
const key = SupportedSites[input?.value]; const key = SupportedSites[input?.value];
switch(key) { switch (key) {
case "uv": case "uv":
uv(iframe, input?.value); uv(iframe, input?.value);
break; break;
@ -118,11 +150,13 @@ import { VERSION } from "astro:env/client";
uv(iframe, input?.value); uv(iframe, input?.value);
break; break;
} }
} } else if (
else if (localStorage.getItem(Settings.ProxySettings.proxy) === "uv") { localStorage.getItem(Settings.ProxySettings.proxy) === "uv"
) {
uv(iframe, input?.value); uv(iframe, input?.value);
} } else if (
else if (localStorage.getItem(Settings.ProxySettings.proxy) === "rh") { localStorage.getItem(Settings.ProxySettings.proxy) === "rh"
) {
rh(iframe, input?.value); rh(iframe, input?.value);
} }
} }
@ -138,11 +172,11 @@ import { VERSION } from "astro:env/client";
} }
if (value.length >= 3) { if (value.length >= 3) {
await libcurlClient.initLibcurl(); await libcurlClient.initLibcurl();
const data = await libcurlClient.fetchFromLibcurl( const data = (await libcurlClient.fetchFromLibcurl(
`https://api.duckduckgo.com/ac?q=${encodeURIComponent(value)}&format=json`, `https://api.duckduckgo.com/ac?q=${encodeURIComponent(value)}&format=json`,
'json' "json"
) as []; )) as [];
const filteredData = data.slice(0,8); //Trim to only about 8 results. Any more and our omnibox dies const filteredData = data.slice(0, 8); //Trim to only about 8 results. Any more and our omnibox dies
if (filteredData) { if (filteredData) {
omnibox.innerHTML = ""; omnibox.innerHTML = "";
filteredData.map((results: Suggestion) => { filteredData.map((results: Suggestion) => {