Skip to content

Commit

Permalink
Refactor PDF worker assignment to improve legacy worker handling and …
Browse files Browse the repository at this point in the history
…remove debug logs
  • Loading branch information
rezkiy37 committed Feb 3, 2025
1 parent 4bdeb06 commit 821dff7
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/PDFPreviewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ type Props = {
type OnPasswordCallback = (password: string | null) => void;

const shouldUseLegacyWorker = isMobileSafari() && !isModernSafari();
const pdfWorker: unknown = shouldUseLegacyWorker ? pdfWorkerLegacySource : pdfWorkerSource;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const pdfWorker = shouldUseLegacyWorker ? pdfWorkerLegacySource : pdfWorkerSource;

console.log('[dev] isMobileSafari', isMobileSafari());
console.log('[dev] isModernSafari', isModernSafari());
console.log('[dev] shouldUseLegacyWorker', shouldUseLegacyWorker);
console.log('[dev] pdfWorker', pdfWorker);

pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorkerLegacySource], {type: 'text/javascript'}));
pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorker], {type: 'text/javascript'}));

const DefaultLoadingComponent = <p>Loading...</p>;
const DefaultErrorComponent = <p>Failed to load the PDF file :(</p>;
Expand Down

0 comments on commit 821dff7

Please sign in to comment.