diff --git a/deps.sh b/deps.sh deleted file mode 100755 index 01b7845..0000000 --- a/deps.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Your bash variables here -AERO_PATH="public/aero" # The directory where aero's files should be - -./node_modules/aero-proxy/examples/install-aero.sh - -curl https://raw.githubusercontent.com/vortexdeveloperlabs/sdk/refs/heads/main/aeroHandleSimple.js -o public/aeroHandleSimple.js -cp ./node_modules/aero-proxy/examples/swWithSwitcher.js public/sw.js -sed -i 's/const defaultProxy = "aero";/const defaultProxy = "uv";/' public/sw.js diff --git a/package.json b/package.json index 6ceb6b2..d0bf599 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-tooltip": "^1.0.7", "@tomphttp/bare-server-node": "^2.0.3", + "aero-proxy": "^0.0.3", + "aero-sandbox": "^0.0.1", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "framer-motion": "^11.0.25", diff --git a/src/app/aero/[aero]/route.ts b/src/app/aero/[aero]/route.ts new file mode 100644 index 0000000..68f6d7a --- /dev/null +++ b/src/app/aero/[aero]/route.ts @@ -0,0 +1,29 @@ +import fs from 'fs' +import { notFound } from 'next/navigation' +import { NextRequest } from 'next/server' + +export async function GET(_req: NextRequest, { params }: { params: { uv: string } }) { + const requestedFile = params.uv + if (requestedFile === 'aero.config.js') { + const file = fs.readFileSync(process.cwd() + `/src/lib/aero/${requestedFile}`) + const fileBlob = new Blob([file]) + return new Response(fileBlob, { + headers: { + 'Content-Type': 'application/javascript' + } + }) + } else { + try { + const res = await fetch(`https://unpkg.com/browse/aero-proxy@0.0.3/dist/${requestedFile}`) + const file = await res.text() + const fileBlob = new Blob([file]) + return new Response(fileBlob, { + headers: { + 'Content-Type': 'application/javascript' + } + }) + } catch { + notFound() + } + } +} diff --git a/src/app/go/[...route]/page.tsx b/src/app/go/[...route]/page.tsx index 23fd5ec..6dec4ed 100644 --- a/src/app/go/[...route]/page.tsx +++ b/src/app/go/[...route]/page.tsx @@ -22,15 +22,27 @@ export default function Route({ params }: { params: { route: string[] } }) { useEffect(() => { if ('serviceWorker' in navigator) { - navigator.serviceWorker - .register('/uv/sw.js', { - scope: '/uv/service' - }) - .then(() => { - if (ref.current) { - ref.current.src = '/uv/service/' + encodeXor(formatSearch(atob(decodeURIComponent(route)))) - } - }) + if (localStorage.getItem("defaultProxy") === "aero") + navigator.serviceWorker + .register('/aero/sw.aero.js', { + scope: '/aero/service' + }) + .then(() => { + if (ref.current) { + ref.current.src = '/aero/service/' + formatSearch(atob(decodeURIComponent(route))) + } + }) + else { + navigator.serviceWorker + .register('/uv/sw.js', { + scope: '/uv/service' + }) + .then(() => { + if (ref.current) { + ref.current.src = '/uv/service/' + encodeXor(formatSearch(atob(decodeURIComponent(route)))) + } + }) + } } }, []) @@ -39,6 +51,7 @@ export default function Route({ params }: { params: { route: string[] } }) { if (!ref.current || !ref.current.contentWindow) return const contentWindow = ref.current.contentWindow as ContentWindow if (!('__uv$location' in contentWindow)) return + if (!('aeroConfig' in contentWindow)) return const shortcuts: any[] = store('shortcuts') if (shortcuts.some((value) => value.url == contentWindow.__uv$location.href)) { diff --git a/src/app/uv/[uv]/route.ts b/src/app/uv/[uv]/route.ts index 5c95891..68f6d7a 100644 --- a/src/app/uv/[uv]/route.ts +++ b/src/app/uv/[uv]/route.ts @@ -4,8 +4,8 @@ import { NextRequest } from 'next/server' export async function GET(_req: NextRequest, { params }: { params: { uv: string } }) { const requestedFile = params.uv - if (requestedFile === 'uv.config.js') { - const file = fs.readFileSync(process.cwd() + `/src/lib/uv/${requestedFile}`) + if (requestedFile === 'aero.config.js') { + const file = fs.readFileSync(process.cwd() + `/src/lib/aero/${requestedFile}`) const fileBlob = new Blob([file]) return new Response(fileBlob, { headers: { @@ -14,7 +14,7 @@ export async function GET(_req: NextRequest, { params }: { params: { uv: string }) } else { try { - const res = await fetch(`https://unpkg.com/@titaniumnetwork-dev/ultraviolet@2.0.0/dist/${requestedFile}`) + const res = await fetch(`https://unpkg.com/browse/aero-proxy@0.0.3/dist/${requestedFile}`) const file = await res.text() const fileBlob = new Blob([file]) return new Response(fileBlob, { diff --git a/src/lib/aero/aero.config.js b/src/lib/aero/aero.config.js new file mode 100644 index 0000000..097b921 --- /dev/null +++ b/src/lib/aero/aero.config.js @@ -0,0 +1,48 @@ +/** @import { Config } from "aero-proxy" */ + +const escapeKeyword = "_"; + +/** + * @type {Config} + */ +self.aeroConfig = { + bc: new BareMux(), + prefix: "/aero/service", + pathToInitialSW: "/sw.js", + bundles: { + "bare-mux": "/aero/BareMux.aero.js", + handle: "/aero/sw.aero.js", + sandbox: "/aero/sandbox/sandbox.aero.js" + }, + aeroPathFilter: path => + Object.values(self.config.bundles).find(bundlePath => + path.startsWith(bundlePath) + ) === null || + path.startsWith("/tests/") || + path.startsWith("/baremux") || + path.startsWith("/epoxy/") || + !path.startsWith(aeroConfig.prefix), + searchParamOptions: { + referrerPolicy: { + escapeKeyword, + searchParam: "passthroughReferrerPolicy" + }, + isModule: { + escapeKeyword, + searchParam: "isModule" + }, + integrity: { + escapeKeyword, + searchParam: "integrity" + } + }, + cacheKey: "httpCache", + dynamicConfig: { + dbName: "aero", + id: "update" + }, + //urlEncoder: __uv$config.urlEncoder, + //urlDecoder: __uv$config.urlDecoder, + urlEncoder: url => url, + urlDecoder: url => url +};