fix(web): lecteurs EPUB/PDF — gestion d'erreurs, worker pdf.js local

Composant ReaderError avec diagnostic et actions de repli, worker
pdf.js servi localement (pdfWorker) pour éviter les CDN, typage du
view foliate, navigation retour vers la fiche livre et styles lecteur
associés.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Git Agent
2026-08-23 16:24:02 +02:00
parent f3c6da2889
commit 4aacac12da
8 changed files with 316 additions and 50 deletions

View File

@ -0,0 +1,53 @@
import { ArrowLeft, Download, RotateCcw } from "lucide-react";
import { navigate } from "../router";
export function readerErrorMessage(error: unknown, fallback: string): string {
if (error instanceof Error && error.message.trim()) return error.message;
if (typeof error === "string" && error.trim()) return error;
return fallback;
}
export function ReaderError({
title,
detail,
technicalDetail,
downloadUrl,
backHref,
onRetry
}: {
title: string;
detail: string;
technicalDetail?: string;
downloadUrl: string;
backHref: string;
onRetry: () => void;
}) {
return (
<div className="reader-error">
<div>
<h2>{title}</h2>
<p>{detail}</p>
</div>
<div className="reader-error-actions">
<button className="ghost-button" onClick={onRetry}>
<RotateCcw size={16} />
Réessayer
</button>
<button className="ghost-button" onClick={() => navigate(backHref)}>
<ArrowLeft size={16} />
Retour à la fiche
</button>
<a className="ghost-button" href={downloadUrl} download>
<Download size={16} />
Télécharger
</a>
</div>
{technicalDetail && (
<details>
<summary>Détail technique</summary>
<pre>{technicalDetail}</pre>
</details>
)}
</div>
);
}