// The dev channel's changelog at /hex/dev: what each dev build changed, from // dev-notes.json on the Release workflow's dev-notes branch (see // scripts/release-dev-notes.sh and .github/release/publish-dev-notes.sh). The // worker fetches and renders it per request, so a new dev build shows without // a site deploy. export type DevNotes = { schema: 1 builds: { version: string; commit: string; published_at: string; items: { title: string; url: string }[] }[] } const ITEM_URL = /^https:\/\/github\.com\/anomalyco\/hex\/(pull\/[0-9]+|commit\/[0-9a-f]{40})$/ function escape(text: string): string { return text.replace(/[&<>"']/g, (character) => `&#${character.charCodeAt(0)};`) } // Keeps only well-formed builds and items; the page never trusts the file's shape. export function parseDevNotes(value: unknown): DevNotes { const builds: DevNotes["builds"] = [] const raw = (value as { builds?: unknown })?.builds for (const build of Array.isArray(raw) ? raw : []) { if (typeof build?.version !== "string" || !/^0\.0\.0-dev-[0-9]+$/.test(build.version)) continue const items = (Array.isArray(build.items) ? build.items : []).filter( (item: unknown): item is { title: string; url: string } => typeof (item as { title?: unknown })?.title === "string" && typeof (item as { url?: unknown })?.url === "string" && ITEM_URL.test((item as { url: string }).url), ) builds.push({ version: build.version, commit: typeof build.commit === "string" ? build.commit : "", published_at: typeof build.published_at === "string" ? build.published_at : "", items: items.map((item: { title: string; url: string }) => ({ title: item.title, url: item.url })), }) } return { schema: 1, builds } } function date(iso: string): string { const parsed = new Date(iso) if (Number.isNaN(parsed.getTime())) return "" return parsed.toLocaleString("en-US", { timeZone: "America/New_York", dateStyle: "medium", timeStyle: "short" }) + " ET" } const REPOSITORY = "https://github.com/anomalyco/hex" const COMMIT = /^[0-9a-f]{40}$/ // ?since= (the app's What's new) shows only the builds after the // one an install runs, with every commit in between on GitHub. function since(notes: DevNotes, version: string | null): { builds: DevNotes["builds"]; summary: string } { const all = { builds: notes.builds, summary: "" } if (!version) return all const index = notes.builds.findIndex((build) => build.version === version) if (index <= 0) return all const builds = notes.builds.slice(0, index) const from = notes.builds[index].commit const to = builds[0].commit const compare = COMMIT.test(from) && COMMIT.test(to) ? ` Every commit since ${escape(version)} ·` : "" return { builds, summary: `

Changes since ${escape(version)}, the build you run.${compare} Every dev build

`, } } export function renderDevNotes(notes: DevNotes, downloadPath: string, sinceVersion: string | null = null): string { const shown = since(notes, sinceVersion) const builds = shown.builds .map((build) => { const items = build.items.length ? `` : `

Internal changes only.

` return `

${escape(build.version)}

${escape(date(build.published_at))}

${items}
` }) .join("") return ` Hex dev builds

Hex dev builds

What changed in each dev build. Dev builds update often and can break; stable is the safe choice. Download the latest Mac dev build, or switch Settings › Update channel to Dev.

${shown.summary} ${builds || `

No dev build notes yet.

`}
` }