Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ module.exports = {
test: new RegExp('node_modules/pdfjs-dist/build/pdf.worker.min.mjs'),
type: 'asset/source',
},
{
// eslint-disable-next-line prefer-regex-literals
test: new RegExp('node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs'),
type: 'asset/source',
},
],
},
plugins: [
Expand Down
9 changes: 2 additions & 7 deletions src/PDFPreviewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// eslint-disable-next-line import/extensions
import pdfWorkerSource from 'pdfjs-dist/build/pdf.worker.min.mjs';
// eslint-disable-next-line import/extensions
import pdfWorkerLegacySource from 'pdfjs-dist/legacy/build/pdf.worker.mjs';
import React, {memo, useCallback, useLayoutEffect, useRef, useState} from 'react';
import type {CSSProperties, ReactNode} from 'react';
import times from 'lodash/times';
Expand All @@ -15,7 +14,7 @@ import {pdfPreviewerStyles as styles} from './styles';
import PDFPasswordForm, {type PDFPasswordFormProps} from './PDFPasswordForm';
import PageRenderer from './PageRenderer';
import {PAGE_BORDER, LARGE_SCREEN_SIDE_SPACING, DEFAULT_DOCUMENT_OPTIONS, DEFAULT_EXTERNAL_LINK_TARGET, PDF_PASSWORD_FORM_RESPONSES} from './constants';
import {isMobileSafari, isModernSafari, setListAttributes} from './helpers';
import {setListAttributes} from './helpers';

type Props = {
file: string;
Expand All @@ -35,11 +34,7 @@ type Props = {

type OnPasswordCallback = (password: string | null) => void;

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

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

const DefaultLoadingComponent = <p>Loading...</p>;
const DefaultErrorComponent = <p>Failed to load the PDF file :(</p>;
Expand Down
1 change: 0 additions & 1 deletion src/pdf.worker.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
declare module 'pdfjs-dist/build/pdf.worker.min.mjs';
declare module 'pdfjs-dist/legacy/build/pdf.worker.mjs';
Loading