Update PDF worker paths and remove setup script
This commit is contained in:
parent
4e857a75f0
commit
d10d4410e2
4 changed files with 5 additions and 118778 deletions
File diff suppressed because one or more lines are too long
56851
public/pdf.worker.mjs
56851
public/pdf.worker.mjs
File diff suppressed because one or more lines are too long
|
|
@ -1,17 +0,0 @@
|
|||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { createRequire } from 'module';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const pdfjsDistPath = path.dirname(require.resolve('pdfjs-dist/package.json'));
|
||||
const pdfWorkerPath = path.join(pdfjsDistPath, 'build', 'pdf.worker.mjs');
|
||||
const pdfLegacyWorkerPath = path.join(pdfjsDistPath, 'legacy', 'build', 'pdf.worker.mjs');
|
||||
|
||||
// Create public directory if it doesn't exist
|
||||
if (!fs.existsSync('./public')) {
|
||||
fs.mkdirSync('./public', { recursive: true });
|
||||
}
|
||||
|
||||
// Copy both modern and legacy workers
|
||||
fs.cpSync(pdfWorkerPath, './public/pdf.worker.mjs', { recursive: true });
|
||||
fs.cpSync(pdfLegacyWorkerPath, './public/pdf.legacy.worker.mjs', { recursive: true });
|
||||
|
|
@ -28,12 +28,15 @@ function shouldUseLegacyBuild() {
|
|||
}
|
||||
}
|
||||
|
||||
// Initialize PDF.js worker
|
||||
// Function to initialize PDF worker
|
||||
function initPDFWorker() {
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
const useLegacy = shouldUseLegacyBuild();
|
||||
const workerSrc = useLegacy ? '/pdf.legacy.worker.mjs' : '/pdf.worker.mjs';
|
||||
// Use local worker file instead of unpkg
|
||||
const workerSrc = useLegacy
|
||||
? new URL('pdfjs-dist/legacy/build/pdf.worker.min.mjs', import.meta.url).href
|
||||
: new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).href;
|
||||
console.log('Setting PDF worker to:', workerSrc);
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
|
||||
pdfjs.GlobalWorkerOptions.workerPort = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue