refactor(app-updater): split AppUpdater.tsx into focused modules (#681)

Extract the GitHub release probe, download/relaunch state and the markdown
changelog renderer out of AppUpdater.tsx:

- utils/appUpdaterHelpers.ts   isNewer, fmtBytes, pickAsset, types
- hooks/useAppUpdater.ts        release probe + download/relaunch handlers
- components/appUpdater/Changelog.tsx

Pure code-move, no behaviour change. The AppShell call site is unchanged.
This commit is contained in:
Frank Stellmacher
2026-05-14 12:12:16 +02:00
committed by GitHub
parent cca000d3af
commit b89b5d7c94
4 changed files with 312 additions and 278 deletions
+38
View File
@@ -0,0 +1,38 @@
import React from 'react';
// Minimal inline-markdown renderer (bold, italic, code)
// IMPORTANT: regex must have NO nested capture groups — split() includes captured
// groups in the result, and nested groups produce undefined entries that crash on .startsWith()
function renderInline(text: string): React.ReactNode[] {
const parts = text.split(/(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`)/g);
return parts.map((part, i) => {
if (!part) return null;
if (part.startsWith('**') && part.endsWith('**'))
return <strong key={i}>{part.slice(2, -2)}</strong>;
if (part.startsWith('*') && part.endsWith('*'))
return <em key={i}>{part.slice(1, -1)}</em>;
if (part.startsWith('`') && part.endsWith('`'))
return <code key={i} className="changelog-code">{part.slice(1, -1)}</code>;
return part;
});
}
/** Renders a GitHub release body as themed changelog markup. */
export default function Changelog({ body }: { body: string }) {
return (
<>
{body.split('\n').map((line, i) => {
if (line.startsWith('### '))
return <div key={i} className="changelog-h3">{renderInline(line.slice(4))}</div>;
if (line.startsWith('#### '))
return <div key={i} className="changelog-h4">{renderInline(line.slice(5))}</div>;
if (line.startsWith('## '))
return null; // skip nested release headers in body
if (line.startsWith('- '))
return <div key={i} className="changelog-item">{renderInline(line.slice(2))}</div>;
if (line.trim() === '') return null;
return <div key={i} className="changelog-text">{renderInline(line)}</div>;
})}
</>
);
}