Skip to content

Commit 5329192

Browse files
authored
Merge pull request #49 from callstack-internal/remove-legacy-pdf-worker
remove legacy pdf worker
2 parents de65f3f + 6effa8d commit 5329192

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

example/webpack.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ module.exports = {
4949
test: new RegExp('node_modules/pdfjs-dist/build/pdf.worker.min.mjs'),
5050
type: 'asset/source',
5151
},
52-
{
53-
// eslint-disable-next-line prefer-regex-literals
54-
test: new RegExp('node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs'),
55-
type: 'asset/source',
56-
},
5752
],
5853
},
5954
plugins: [

src/PDFPreviewer.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// eslint-disable-next-line import/extensions
22
import pdfWorkerSource from 'pdfjs-dist/build/pdf.worker.min.mjs';
33
// eslint-disable-next-line import/extensions
4-
import pdfWorkerLegacySource from 'pdfjs-dist/legacy/build/pdf.worker.mjs';
54
import React, {memo, useCallback, useLayoutEffect, useRef, useState} from 'react';
65
import type {CSSProperties, ReactNode} from 'react';
76
import times from 'lodash/times';
@@ -15,7 +14,7 @@ import {pdfPreviewerStyles as styles} from './styles';
1514
import PDFPasswordForm, {type PDFPasswordFormProps} from './PDFPasswordForm';
1615
import PageRenderer from './PageRenderer';
1716
import {PAGE_BORDER, LARGE_SCREEN_SIDE_SPACING, DEFAULT_DOCUMENT_OPTIONS, DEFAULT_EXTERNAL_LINK_TARGET, PDF_PASSWORD_FORM_RESPONSES} from './constants';
18-
import {isMobileSafari, isModernSafari, setListAttributes} from './helpers';
17+
import {setListAttributes} from './helpers';
1918

2019
type Props = {
2120
file: string;
@@ -35,11 +34,7 @@ type Props = {
3534

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

38-
const shouldUseLegacyWorker = isMobileSafari() && !isModernSafari();
39-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
40-
const pdfWorker = shouldUseLegacyWorker ? pdfWorkerLegacySource : pdfWorkerSource;
41-
42-
pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorker], {type: 'text/javascript'}));
37+
pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorkerSource], {type: 'text/javascript'}));
4338

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

src/pdf.worker.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
declare module 'pdfjs-dist/build/pdf.worker.min.mjs';
2-
declare module 'pdfjs-dist/legacy/build/pdf.worker.mjs';

0 commit comments

Comments
 (0)