Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : ORIX App Universe8 * File : src/components/downloads/DownloadPanel.tsx9 * Module : components10 * Repository : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website : https://www.orixlab.dev12 * Created : 2026-11-2113 * Last Modified : 2026-11-2114 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import type { AppDoc } from "@/models/app";44import { dict, fmtBytes, fmtDate, tr, type Locale } from "@/lib/i18n";45import { latestArtifact, publishedArtifacts, signatureOf, versionLabel, type Release } from "@/lib/releases/store";46import { repoMeta, syncHealth } from "@/lib/releases/sync";47import { betaAccess } from "@/lib/testflight";48import { downloadUrl } from "@/lib/view";49import { env } from "@/lib/env";50import { Arrow, Down } from "../ui/Badges";51import { TrackedLink } from "../ui/TrackedLink";5253const Check = ({ ok }: { ok: boolean }) => (54 <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden className="mt-0.5 flex-none" style={{ color: ok ? "var(--ok)" : "var(--warn)" }}>55 <circle cx="8" cy="8" r="7" stroke="currentColor" strokeWidth="1.4" />{ok ? <path d="m4.8 8.2 2.2 2.2 4.2-4.6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /> : <path d="M8 4.5v4.2M8 11.2v.2" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />}56 </svg>57);5859function MacDownload({ app, locale, all }: { app: AppDoc; locale: Locale; all: Release[] }) {60 const t = dict(locale), latest = latestArtifact(app.slug);61 if (!latest) {62 return (63 <div className="card p-7" data-testid="dl-mac-none">64 <h3 className="h3">{t.dl.mac}</h3>65 <p className="mt-3 text-ink2">{tr(app.distribution.find((d) => d.channel === "dmg")?.note ?? { en: "", fr: "" }, locale) || t.dl.noDmg}</p>66 <p className="mt-6"><span className="btn-quiet" data-testid="dl-unavailable">{app.status === "coming-soon" || app.status === "development" ? t.action.comingSoon : t.action.noRelease}</span></p>67 </div>68 );69 }70 const sig = signatureOf(latest), version = versionLabel(latest);71 const rows: [string, string][] = [[t.dl.version, version], [t.dl.size, latest.asset_size ? fmtBytes(latest.asset_size, locale) : "—"]];72 if (app.minOS.macos) rows.push([t.dl.minOS, `macOS ${app.minOS.macos}+`]);73 if (app.architectures.length) rows.push([t.dl.arch, app.architectures.join(", ")]);74 if (latest.published_at) rows.push([t.dl.date, fmtDate(latest.tag_date ?? latest.published_at, locale)]);75 return (76 <div className="card p-7" data-testid="dl-mac">77 <h3 className="h3">{t.dl.mac}</h3>78 <dl className="mt-5 grid grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-3">79 {rows.map(([k, v]) => <div key={k}><dt className="text-[0.78rem] font-semibold text-ink3">{k}</dt><dd className="mono mt-0.5 text-[0.95rem]">{v}</dd></div>)}80 </dl>81 <p className="mt-7"><TrackedLink href={downloadUrl(latest)} slug={app.slug} version={version} className="btn btn-primary" download><Down />{t.action.download}</TrackedLink></p>82 <ul className="mt-6 grid gap-2 text-[0.88rem] text-ink2">83 <li className="flex gap-2"><Check ok />{t.dl.integrity}</li>84 <li className="flex gap-2"><Check ok={sig?.notarized === true} />{sig?.notarized === true ? t.dl.notarized : t.dl.notNotarized}</li>85 </ul>86 <p className="mt-5 text-[0.72rem] font-semibold uppercase tracking-[0.1em] text-ink3">{t.dl.sha}</p>87 <p className="mono mt-1 break-all text-[0.78rem] text-ink2" data-testid="dl-sha">{latest.sha256_computed}</p>88 {all.length > 1 && (89 <details className="mt-6 rule pt-4 text-[0.92rem]">90 <summary className="cursor-pointer font-semibold">{t.dl.older}</summary>91 <ul className="mt-3 grid gap-2">{all.filter((r) => r.id !== latest.id).map((r) => (92 <li key={r.id} className="flex flex-wrap items-baseline gap-x-4"><TrackedLink href={downloadUrl(r)} slug={app.slug} version={versionLabel(r)} className="link mono" download>{r.asset_name} · {versionLabel(r)}</TrackedLink><span className="text-ink3">{r.asset_size ? fmtBytes(r.asset_size, locale) : ""}</span></li>93 ))}</ul>94 </details>95 )}96 </div>97 );98}99100function TestFlight({ app, locale }: { app: AppDoc; locale: Locale }) {101 const t = dict(locale), beta = betaAccess(app);102 if (beta.kind === "none") return null;103 const note = app.distribution.find((d) => d.channel === "testflight")?.note;104 return (105 <div className="card p-7" data-testid="dl-testflight">106 <h3 className="h3">{t.dl.tfTitle}</h3>107 {beta.kind === "join" ? (108 <>109 <p className="mt-3 text-ink2">{t.dl.tfOpen}</p>110 <p className="mt-6"><TrackedLink href={beta.url} slug={app.slug} version={`testflight-${app.version ?? "beta"}`} className="btn btn-primary" external>{t.action.testflight}<Arrow /></TrackedLink></p>111 <ol className="mt-6 grid gap-2 text-[0.92rem] text-ink2">{t.dl.tfSteps.map((s, i) => <li key={i} className="flex gap-3"><span className="mono text-ink3">{i + 1}</span>{s}</li>)}</ol>112 <p className="mt-5 text-[0.8rem] text-ink3">{t.dl.verifiedOn(fmtDate(beta.verifiedAt, locale))}</p>113 </>114 ) : (115 <>116 <p className="mt-3 text-ink2">{(note && tr(note, locale)) || t.dl.tfReasons[beta.reason]}</p>117 <p className="mt-6"><span className="btn-quiet" data-testid="tf-unavailable">{t.action.betaSoon}</span></p>118 <p className="mt-4 text-[0.85rem] text-ink3">{t.dl.tfReasons[beta.reason]}</p>119 </>120 )}121 </div>122 );123}124125function Store({ app, locale }: { app: AppDoc; locale: Locale }) {126 const t = dict(locale);127 const stores = app.distribution.filter((d) => (d.channel === "appstore-ios" || d.channel === "appstore-mac") && d.state === "public" && d.url?.startsWith("https://apps.apple.com/"));128 if (!stores.length) return <p className="text-[0.9rem] text-ink3">{t.dl.appStoreSoon}</p>;129 return <p className="flex flex-wrap gap-3">{stores.map((d) => <TrackedLink key={d.channel} href={d.url!} slug={app.slug} version={d.channel} className="btn btn-ghost" external>{t.dl.channel[d.channel]}<Arrow /></TrackedLink>)}</p>;130}131132/** Every distribution channel of an application, each shown only in the state that has been verified. */133export function DownloadPanel({ app, locale }: { app: AppDoc; locale: Locale }) {134 const t = dict(locale);135 const mac = app.platforms.includes("macos"), mobile = app.platforms.some((p) => p !== "macos");136 const meta = app.repo.visibility === "public" ? repoMeta(app.slug) : null;137 const health = syncHealth(env.syncIntervalMin);138 return (139 <div className="grid gap-5">140 <div className={`grid gap-5 ${mac && mobile ? "lg:grid-cols-2" : ""}`}>141 {mac && <MacDownload app={app} locale={locale} all={publishedArtifacts(app.slug)} />}142 {mobile && <TestFlight app={app} locale={locale} />}143 </div>144 <Store app={app} locale={locale} />145 {meta && <p className="text-[0.8rem] text-ink3" data-testid="sync-note">{health.stale ? t.dl.stale : t.dl.synced(fmtDate(meta.fetchedAt, locale))}</p>}146 </div>147 );148}149