clone

one developer profile for links and private tcp services, reached peer to peer over iroh with no open ports

main
devsite / web / install.ts
install.ts 1.7K
1interface NavigatorWithUserAgentData extends Navigator {2 userAgentData?: { platform?: string };3}45function prefersHomebrewInstall() {6 const platform = (navigator as NavigatorWithUserAgentData).userAgentData?.platform7 || navigator.platform || '';8 return /mac/i.test(platform) || /Macintosh|Mac OS X/i.test(navigator.userAgent);9}1011export function installControlMarkup() {12 return prefersHomebrewInstall()13 ? `<fieldset role="group">14 <input id="install-command" aria-label="Homebrew install command"15 value="brew install FelineStateMachine/tap/devsite" readonly>16 <button id="copy-install" type="button">Copy</button>17 </fieldset>`18 : `<fieldset role="group">19 <input aria-label="Latest binary release"20 value="GitHub - latest devsite binary release" readonly>21 <a href="https://github.com/FelineStateMachine/devsite/releases/latest"22 role="button">Download</a>23 </fieldset>`;24}2526export function bindInstallControl() {27 const installCommand = document.getElementById('install-command');28 const copyInstall = document.getElementById('copy-install');29 if (!(installCommand instanceof HTMLInputElement)30 || !(copyInstall instanceof HTMLButtonElement)) return;3132 let copyReset: ReturnType<typeof setTimeout> | undefined;33 copyInstall.addEventListener('click', async () => {34 try {35 await navigator.clipboard.writeText(installCommand.value);36 copyInstall.textContent = 'Copied';37 clearTimeout(copyReset);38 copyReset = setTimeout(() => {39 copyInstall.textContent = 'Copy';40 }, 1400);41 } catch {42 copyInstall.textContent = 'Select';43 installCommand.select();44 }45 });46}