diff --git a/package.json b/package.json index 508ecfd..e22310a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "eslint" + "lint": "eslint", + "test:downloads": "node --experimental-strip-types --test tests/desktop-downloads.test.mjs" }, "dependencies": { "@such-software/smirk-dapp-api": "^0.3.0", diff --git a/src/app/downloads/DownloadChoices.tsx b/src/app/downloads/DownloadChoices.tsx new file mode 100644 index 0000000..69f953b --- /dev/null +++ b/src/app/downloads/DownloadChoices.tsx @@ -0,0 +1,33 @@ +'use client'; + +import { useEffect, useState } from 'react'; +import { OFFICIAL_RELEASES, type DesktopRelease, type DesktopPlatform } from '@/lib/desktop-releases'; +import { suggestDesktopPlatform, type SuggestedPlatform } from '@/lib/desktop-platform'; + +const platforms: { id: DesktopPlatform; label: string; format: string }[] = [ + { id: 'macos', label: 'macOS', format: 'DMG installer' }, + { id: 'windows', label: 'Windows', format: 'x64 installer' }, + { id: 'linux', label: 'Linux', format: 'x86_64 AppImage' }, +]; + +export default function DownloadChoices({ release }: { release: DesktopRelease | null }) { + const [suggested, setSuggested] = useState(null); + useEffect(() => { setSuggested(suggestDesktopPlatform(navigator.platform, navigator.userAgent, navigator.maxTouchPoints)); }, []); + return <> + {suggested === 'mobile' &&

These installers are for desktop computers. Open this page on your Mac, Windows PC, or Linux computer.

} +
+ {platforms.map(platform => { + const href = release?.downloads[platform.id]; + const preferred = suggested === platform.id; + return
+
{preferred ? 'Suggested for your device' : ''}
+

{platform.label}

+

{platform.format}

+ {href ? Download for {platform.label} + : <>

Check the official release for an available installer.

View releases} +
; + })} +
+

Your device suggestion stays in this browser. You can choose any platform.

+ ; +} diff --git a/src/app/downloads/page.tsx b/src/app/downloads/page.tsx new file mode 100644 index 0000000..40b11cf --- /dev/null +++ b/src/app/downloads/page.tsx @@ -0,0 +1,26 @@ +import type { Metadata } from 'next'; +import Link from 'next/link'; +import { latestDesktopRelease } from '@/lib/desktop-release-server'; +import { OFFICIAL_RELEASES } from '@/lib/desktop-releases'; +import DownloadChoices from './DownloadChoices'; + +export const metadata: Metadata = { title: 'Download desktop', description: 'Get Smirk Wallet for macOS, Windows, or Linux from the official GitHub release.' }; +export const revalidate = 300; + +export default async function Downloads() { + const release = await latestDesktopRelease(); + return
+ ← Smirk Wallet +
+

Your wallet. Your computer.

+

Download Smirk

+

Smirk Wallet for macOS, Windows, and Linux. Downloads come directly from our official GitHub releases.

+

{release ? `Latest published release: ${release.version}` : 'We could not load the latest release. You can still browse the official releases below.'}

+
+ +
+ Release notes and all files + Get the browser extension +
+
; +} diff --git a/src/app/page.tsx b/src/app/page.tsx index f003f2f..ed97289 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,6 +3,7 @@ import { useState, useEffect } from 'react'; import Image from 'next/image'; import Link from 'next/link'; +import { OFFICIAL_RELEASES } from '@/lib/desktop-releases'; import { getChallenge, verifySignature, getMe, getUserCount, type AuthResponse } from '@/lib/api'; type Asset = 'btc' | 'ltc' | 'xmr' | 'wow' | 'grin'; @@ -169,8 +170,9 @@ export default function Home() { // Show loading while checking session if (checkingSession) { return ( -
+
+ Download desktop
); } @@ -243,6 +245,8 @@ export default function Home() { )}
+ Download desktop + {/* Initial state - Connect button */} {step === 'initial' && (
@@ -263,7 +267,7 @@ export default function Home() { Chrome Store