Package a self-contained macOS app and harden serving

- Add macos/build.mjs: stages a universal .app outside the checkout, bundles
  and checksums Node, installs production deps per architecture, compiles the
  launcher shim, signs ad-hoc or with a Developer ID, and writes a zip and dmg
  with an optional notarization path.
- Serve precompressed brotli/gzip assets and split admin panels and the public
  pages out of the main bundle.
- Support HTTP range requests, and fix upload and quota accounting, gallery
  download counts and unreadable-file handling.
- Add server HTTP integration tests, a Gitea CI workflow, a catalog backup
  script and a crash screen for the UI.
This commit is contained in:
2026-11-29 06:23:58 +00:00
parent d42727618e
commit b34d34dacb
24 changed files with 2598 additions and 93 deletions
+105
View File
@@ -0,0 +1,105 @@
import { Component, type ErrorInfo, type ReactNode } from 'react';
interface Props {
children: ReactNode;
}
interface State {
error: Error | null;
componentStack: string;
version: string;
copied: boolean;
}
/**
* Without this, one exception anywhere in the tree unmounts React and leaves a
* blank page with nothing to report. The boundary keeps a way back (reload)
* and a way to tell support what happened, and says plainly that the library
* itself is untouched.
*/
export default class ErrorBoundary extends Component<Props, State> {
state: State = { error: null, componentStack: '', version: '', copied: false };
static getDerivedStateFromError(error: Error): Partial<State> {
return { error };
}
componentDidCatch(error: Error, info: ErrorInfo) {
console.error('Luminary crashed while rendering', error, info.componentStack);
this.setState({ componentStack: info.componentStack ?? '' });
// The version is a nicety for the diagnostics; the page works without it.
fetch('/api/health', { credentials: 'same-origin' })
.then((res) => (res.ok ? res.json() : null))
.then((body: { version?: string } | null) => {
if (body?.version) this.setState({ version: body.version });
})
.catch(() => undefined);
}
private diagnostics(): string {
const error = this.state.error;
return [
'Luminary crash report',
`Version: ${this.state.version || 'unknown'}`,
`When: ${new Date().toISOString()}`,
`Page: ${window.location.pathname}${window.location.search}`,
`Browser: ${navigator.userAgent}`,
`Screen: ${window.screen.width}x${window.screen.height} @${window.devicePixelRatio}x`,
'',
`Error: ${error?.name ?? 'Error'}: ${error?.message ?? 'unknown'}`,
error?.stack ?? '',
'',
'Component stack:',
this.state.componentStack,
].join('\n');
}
private async copyDiagnostics() {
try {
await navigator.clipboard.writeText(this.diagnostics());
this.setState({ copied: true });
window.setTimeout(() => this.setState({ copied: false }), 2500);
} catch {
// Clipboard access can be denied; the email link still carries the report.
this.setState({ copied: false });
}
}
render() {
const error = this.state.error;
if (!error) return this.props.children;
const subject = encodeURIComponent('Luminary crash report');
const body = encodeURIComponent(this.diagnostics().slice(0, 1800));
const mailto = `mailto:bhursey@gmail.com?subject=${subject}&body=${body}`;
return (
<section className="crash-screen" role="alert">
<div className="crash-card">
<h1>Luminary hit an unexpected error</h1>
<p>
Your photos, edits and catalog are safe on disk — nothing was deleted. Reloading
usually clears it. If it keeps happening, send the diagnostics below so it can be
fixed.
</p>
<p className="crash-message">{error.message || 'Unknown error'}</p>
<div className="btn-row">
<button className="btn primary" onClick={() => window.location.reload()}>
Reload Luminary
</button>
<button className="btn ghost" onClick={() => void this.copyDiagnostics()}>
{this.state.copied ? 'Copied' : 'Copy diagnostics'}
</button>
<a className="btn ghost" href={mailto}>
Email support
</a>
</div>
<details className="crash-details">
<summary>Technical details</summary>
<pre>{this.diagnostics()}</pre>
</details>
</div>
</section>
);
}
}