import './page.js'; import { validateCreatorsRelease } from './installer-release.js'; const status = document.querySelector('#installer-status'); const button = document.querySelector('#installer-download'); const retry = document.querySelector('#installer-retry'); async function configureInstaller() { retry.hidden = true; retry.disabled = true; try { const response = await fetch('/mac-release.json', { cache: 'no-store' }); // Keep the finished page neutral until the owner supplies the release files. if (response.status === 404) return; // Vite serves HTML for an absent JSON file during local previews. if (!response.headers.get('content-type')?.includes('application/json')) return; if (!response.ok) throw new Error('Release lookup failed'); const release = validateCreatorsRelease(await response.json(), location.origin); button.href = release.downloadUrl; button.hidden = false; document.querySelector('#installer-placeholder').hidden = true; const fileName = new URL(release.downloadUrl).pathname.split('/').pop(); document.querySelector('#installer-details').textContent = `Version ${release.version} (${release.build}) · ${(release.bytes / 1048576).toFixed(1)} MB · ${fileName}`; const sourceLink = document.querySelector('#installer-source'); sourceLink.href = release.sourceUrl; sourceLink.hidden = false; document.querySelector('#installer-trust').hidden = false; document.querySelector('#installer-checksum').hidden = false; document.querySelector('#installer-sha').textContent = release.sha256; status.textContent = 'Click below to download the installer, then follow the steps below.'; } catch { status.textContent = 'The download details could not be loaded. Try again.'; retry.hidden = false; } finally { retry.disabled = false; } } retry.addEventListener('click', configureInstaller); configureInstaller();