@idealyst/pdf 1.2.129 → 1.2.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/PDFViewer.tsx +5 -5
package/package.json
CHANGED
package/src/PDFViewer.tsx
CHANGED
|
@@ -12,14 +12,14 @@ import React, {
|
|
|
12
12
|
useState,
|
|
13
13
|
useCallback,
|
|
14
14
|
} from 'react';
|
|
15
|
-
import
|
|
15
|
+
import { GlobalWorkerOptions, getDocument, version } from 'pdfjs-dist';
|
|
16
16
|
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
17
17
|
import type { PDFViewerProps, PDFViewerRef, PDFSource } from './types';
|
|
18
18
|
|
|
19
19
|
// Configure the PDF.js worker
|
|
20
|
-
// Users can override this by setting
|
|
21
|
-
if (!
|
|
22
|
-
|
|
20
|
+
// Users can override this by setting GlobalWorkerOptions.workerSrc before rendering
|
|
21
|
+
if (!GlobalWorkerOptions.workerSrc) {
|
|
22
|
+
GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${version}/pdf.worker.min.mjs`;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -141,7 +141,7 @@ export const PDFViewer = forwardRef<PDFViewerRef, PDFViewerProps>((props, ref) =
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
const resolved = resolveSource(source);
|
|
144
|
-
const doc = await
|
|
144
|
+
const doc = await getDocument(resolved).promise;
|
|
145
145
|
|
|
146
146
|
if (id !== loadIdRef.current) {
|
|
147
147
|
doc.destroy();
|