import * as React from "react"; export function releaseBase(version: string) { return `https://github.com/getpaseo/paseo/releases/download/v${version}`; } export interface ReleaseAssetInfo { version: string; windowsX64Asset: string | null; windowsArm64Asset: string | null; } export function downloadUrls(release: ReleaseAssetInfo) { const { version, windowsX64Asset, windowsArm64Asset } = release; const base = releaseBase(version); return { macAppleSilicon: `${base}/Paseo-${version}-arm64.dmg`, macIntel: `${base}/Paseo-${version}-x64.dmg`, linuxAppImage: `${base}/Paseo-${version}-x86_64.AppImage`, linuxDeb: `${base}/Paseo-${version}-amd64.deb`, linuxRpm: `${base}/Paseo-${version}-x86_64.rpm`, windowsExeX64: `${base}/${windowsX64Asset ?? `Paseo-Setup-${version}.exe`}`, windowsExeArm64: windowsArm64Asset ? `${base}/${windowsArm64Asset}` : null, androidApk: `${base}/paseo-v${version}-android.apk`, }; } export const appStoreUrl = "https://apps.apple.com/app/paseo-pocket-engineer/id6758887924"; export const playStoreUrl = "https://play.google.com/store/apps/details?id=sh.paseo"; export const webAppUrl = "https://app.paseo.sh"; type Platform = "mac-silicon" | "mac-intel" | "windows" | "linux"; export interface DownloadOption { platform: Platform; label: string; href: string; icon: (props: React.SVGProps) => React.ReactElement; } export function getDownloadOptions(release: ReleaseAssetInfo): DownloadOption[] { const urls = downloadUrls(release); return [ { platform: "mac-silicon", label: "Mac", href: urls.macAppleSilicon, icon: AppleIcon, }, { platform: "mac-intel", label: "Mac Intel", href: urls.macIntel, icon: AppleIcon, }, { platform: "windows", label: "Windows", href: urls.windowsExeX64, icon: WindowsIcon, }, { platform: "linux", label: "Linux", href: urls.linuxAppImage, icon: LinuxIcon, }, ]; } export function useDetectedPlatform(): Platform { const [platform, setPlatform] = React.useState("mac-silicon"); React.useEffect(() => { const ua = navigator.userAgent.toLowerCase(); if (ua.includes("win")) { setPlatform("windows"); } else if (ua.includes("linux")) { setPlatform("linux"); } else if (ua.includes("mac")) { // Check for Apple Silicon vs Intel // navigator.platform is deprecated but still the most reliable check const isARM = /arm|aarch64/i.test(navigator.platform) || // Chrome/Edge on Apple Silicon report x86 platform but have ARM in userAgentData (navigator as unknown as { userAgentData?: { architecture?: string } }).userAgentData ?.architecture === "arm"; setPlatform(isARM ? "mac-silicon" : "mac-silicon"); // Default to Silicon for modern Macs } }, []); return platform; } export function AppleIcon(props: React.SVGProps) { return ( ); } export function AndroidIcon(props: React.SVGProps) { return ( ); } export function PlayStoreIcon(props: React.SVGProps) { return ( ); } export function WindowsIcon(props: React.SVGProps) { return ( ); } export function LinuxIcon(props: React.SVGProps) { return ( ); } export function TerminalIcon(props: React.SVGProps) { return ( ); } export function GlobeIcon(props: React.SVGProps) { return ( ); }