fix: restore workerSrc — pdfjs v5 requires it at init time

pdfjs v5 checks GlobalWorkerOptions.workerSrc before reading
document options like disableWorker. Set it to satisfy the
init check even though the worker is disabled per-document.
This commit is contained in:
vicrodh committed 2026-02-26 15:18:12 -06:00
1 parent a804344953
commit 9c4632c6e5
1 file changed
+6 -3
+6 -3
View File
@@ -5,9 +5,12 @@
import { X, ChevronLeft, ChevronRight, ZoomIn, ZoomOut, Maximize, RotateCw } from 'lucide-svelte';
import * as pdfjsLib from 'pdfjs-dist';
// No web worker — run pdfjs on main thread so WASM files
// at /pdfjs/ are resolvable (workers use blob: URLs where
// relative paths break). Fine for a simple booklet viewer.
// We disable the worker at document level (disableWorker: true)
// but pdfjs v5 still requires workerSrc to be set at init time.
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url
).toString();
interface Props {
isOpen: boolean;