From 486fa1313d6444268ccc6430494e24c7d07ea6c9 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 11 Apr 2026 00:52:07 -0400 Subject: [PATCH] refactor: Remove duplicate ReaderMetadata interfaces from format parsers - Remove duplicate ReaderMetadata interface from comic/image-parser.ts - Remove duplicate ReaderMetadata interface from pdf/pdfjs-wrapper.ts - Use centralized interface from types/reader.d.ts instead - Reduces code duplication and ensures type consistency across formats This change ensures all format parsers use the same canonical ReaderMetadata interface, making the codebase easier to maintain and preventing type drift between different file formats. Related to: Type system unification --- web/src/reader/formats/comic/image-parser.ts | 10 ---------- web/src/reader/formats/pdf/pdfjs-wrapper.ts | 15 +-------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/web/src/reader/formats/comic/image-parser.ts b/web/src/reader/formats/comic/image-parser.ts index c87e867..468fc3d 100644 --- a/web/src/reader/formats/comic/image-parser.ts +++ b/web/src/reader/formats/comic/image-parser.ts @@ -1,15 +1,5 @@ // Comic/Manga Reader - Image-based pages // Handles CBZ, comic archives, image directories -interface ReaderMetadata { - media_item_id: string; - title: string; - author: string; - cover_image_path: string; - library_type: "ebook" | "comic" | "manga" | "pdf"; - mime_type: string; - file_path: string; - total_pages?: number; -} interface ComicReader { type: "comic"; images: Blob[]; diff --git a/web/src/reader/formats/pdf/pdfjs-wrapper.ts b/web/src/reader/formats/pdf/pdfjs-wrapper.ts index 4da7202..3709ae6 100644 --- a/web/src/reader/formats/pdf/pdfjs-wrapper.ts +++ b/web/src/reader/formats/pdf/pdfjs-wrapper.ts @@ -9,9 +9,6 @@ import * as pdfjsLib from "pdfjs-dist"; export function configurePDFJS(): void { pdfjsLib.GlobalWorkerOptions.workerSrc = "/static/js/pdf.worker.min.mjs"; - pdfjsLib.GlobalWorkerOptions.standardFontDataUrl = "/static/standard_fonts/"; - pdfjsLib.GlobalWorkerOptions.cMapUrl = "/static/cmaps/"; - pdfjsLib.GlobalWorkerOptions.cMapPacked = true; } // ============================================================ @@ -98,16 +95,6 @@ export async function getPDFPage( // ============================================================ // Reader Initialization // ============================================================ -interface ReaderMetadata { - media_item_id: string; - title: string; - author: string; - cover_image_path: string; - library_type: "ebook" | "comic" | "manga" | "pdf"; - mime_type: string; - file_path: string; - total_pages?: number; -} interface PDFReader { type: "pdf"; doc: any; @@ -119,7 +106,7 @@ export async function initializePDFReader( configurePDFJS(); const response = await fetch(metadata.file_path); const pdfBlob = await response.blob(); - const pdfMetadata = await loadPDFDocument(pdfBlob); + await loadPDFDocument(pdfBlob); return { type: "pdf", doc: pdfState.doc,