diff --git a/app/download-beta/page.tsx b/app/download-beta/page.tsx index a2dbf72..ed89e23 100644 --- a/app/download-beta/page.tsx +++ b/app/download-beta/page.tsx @@ -1,17 +1,10 @@ /* eslint-disable @next/next/no-img-element */ -import { binariesLink, discordLink, releaseLink } from '@/components/links'; -import { FaApple, FaWindows } from 'react-icons/fa'; -import './twinkle.css' -import Image from 'next/image'; -import SparkleOverlay from './SparkleOverlay'; - - - - - - - +import { binariesLink, discordLink, releaseLink } from "@/components/links"; +import { FaApple, FaWindows, FaLinux } from "react-icons/fa"; +import "./twinkle.css"; +import Image from "next/image"; +import SparkleOverlay from "./SparkleOverlay"; // Add this top-level cache (outside the function) let cachedVersion: string | null = null; @@ -20,195 +13,259 @@ const TTL = 15 * 60 * 1000; // 15 minutes // All required asset filenames (can be regex or exact) const REQUIRED_ASSETS = [ - (v: string) => `VoidSetup-x64-${v}.exe`, - (v: string) => `VoidSetup-arm64-${v}.exe`, - (v: string) => `Void.x64.${v}.dmg`, - (v: string) => `Void.arm64.${v}.dmg`, - // (v: string) => `Void-${v}.glibc2.29-x86_64.AppImage`, + (v: string) => `VoidSetup-x64-${v}.exe`, + (v: string) => `VoidSetup-arm64-${v}.exe`, + (v: string) => `Void.x64.${v}.dmg`, + (v: string) => `Void.arm64.${v}.dmg`, + (v: string) => `Void-${v}.glibc2.29-x86_64.AppImage`, ]; // Server-side helper async function getLatestReleaseVersion(): Promise { - const now = Date.now(); - if (cachedVersion && now - lastChecked < TTL) { - return cachedVersion; - } + const now = Date.now(); + if (cachedVersion && now - lastChecked < TTL) { + return cachedVersion; + } + + try { + const response = await fetch( + "https://api.github.com/repos/voideditor/binaries/releases/latest", + { + // Avoid Next.js caching here—we handle our own + cache: "no-store", + }, + ); - try { - const response = await fetch('https://api.github.com/repos/voideditor/binaries/releases/latest', { - // Avoid Next.js caching here—we handle our own - cache: 'no-store', - }); - - if (response.ok) { - const data = await response.json(); - const version = data.tag_name; - const assetNames: string[] = data.assets.map((a: any) => a.name); - - const allAssetsExist = REQUIRED_ASSETS.every((makeName) => - assetNames.includes(makeName(version)) - ); - - if (allAssetsExist) { - cachedVersion = version; - lastChecked = now; - return version; - } else { - console.warn('Some expected assets are missing in latest release'); - } - } - } catch (e) { - console.error('Failed to fetch latest release:', e); + if (response.ok) { + const data = await response.json(); + const version = data.tag_name; + const assetNames: string[] = data.assets.map((a: any) => a.name); + + const allAssetsExist = REQUIRED_ASSETS.every((makeName) => + assetNames.includes(makeName(version)), + ); + + if (allAssetsExist) { + cachedVersion = version; + lastChecked = now; + return version; + } else { + console.warn("Some expected assets are missing in latest release"); + } } + } catch (e) { + console.error("Failed to fetch latest release:", e); + } - return cachedVersion ?? '1.99.30023'; + return cachedVersion ?? "1.99.30023"; } - - - - - // Floating Element const FloatingElement = () => ( -
-
- Slice of the Void logo -
- - - - - - - - +
+
+ Slice of the Void logo
+ + + + + + + + +
); // Download button -const DownloadButton = ({ url, children, className }: { url: string; children: React.ReactNode; className?: string }) => ( - ( + - {children} - + href={url} + > + {children} + ); // Actual page content (Client Component with data hydration) function DownloadBetaClient({ releaseVersion }: { releaseVersion: string }) { - const downloadLinks = { - windows: { - x64: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/VoidSetup-x64-${releaseVersion}.exe`, - arm: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/VoidSetup-arm64-${releaseVersion}.exe`, - }, - mac: { - intel: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/Void.x64.${releaseVersion}.dmg`, - appleSilicon: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/Void.arm64.${releaseVersion}.dmg`, - }, - linux: { - x64: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/Void-${releaseVersion}.glibc2.29-x86_64.AppImage`, - }, - }; - - return ( -
-
- {/* left */} -
-

-
Download Void.
-

- -
- Try the beta edition of Void, and help us improve by providing{' '} - - feedback - - . -
- -
-
- - - - Download for Mac - - - - - - - Intel - - - -
- -
- - - - Download for Windows - - - - - - - ARM - - - -
-
-
- - {/* right */} -
- -
-
- - {/* desc */} -
-
- For Linux users, download Void{' '} - - here - - . -
-
- Alternatively, download Void from the source on{' '} - - GitHub - - . -
+ const downloadLinks = { + windows: { + x64: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/VoidSetup-x64-${releaseVersion}.exe`, + arm: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/VoidSetup-arm64-${releaseVersion}.exe`, + }, + mac: { + intel: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/Void.x64.${releaseVersion}.dmg`, + appleSilicon: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/Void.arm64.${releaseVersion}.dmg`, + }, + linux: { + x64: `https://github.com/voideditor/binaries/releases/download/${releaseVersion}/Void-${releaseVersion}.glibc2.29-x86_64.AppImage`, + }, + }; + + return ( +
+
+ {/* left */} +
+

+
+ Download Void.
-

- ); + + +
+ Try the beta edition of Void, and help us improve by providing{" "} + + feedback + + . +
+ +
+
+ + + + + Download for Mac + + + + + + + + Intel + + + +
+ +
+ + + + + Download for Windows + + + + + + + + ARM + + + +
+ +
+ + + + + Download for Linux (AppImage) + + + + +
+ +
+
+ For Linux, additional formats can be found{" "} + + here + {" "} + . +
+
+
+
+ + {/* right */} +
+ +
+ + + {/* desc */} +
+
+ Alternatively, download Void from the source on{" "} + + GitHub + + . +
+
+
+ ); } export default async function DownloadBetaPage() { - const releaseVersion = await getLatestReleaseVersion(); + const releaseVersion = await getLatestReleaseVersion(); - return ; -} \ No newline at end of file + return ; +}