Update PDF.js integration and dependencies

This commit is contained in:
Ludy87 2025-09-03 05:14:47 +02:00
parent 1a3e8e7ecf
commit 7d89629ecb
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
12 changed files with 2616 additions and 61679 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,34 +7,34 @@
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.7.4",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@iconify/react": "^6.0.0",
"@mantine/core": "^8.0.1",
"@mantine/dropzone": "^8.0.1",
"@mantine/hooks": "^8.0.1",
"@mui/icons-material": "^7.1.0",
"@mui/material": "^7.1.0",
"@tailwindcss/postcss": "^4.1.8",
"@emotion/styled": "^11.14.1",
"@iconify/react": "^6.0.1",
"@mantine/core": "^8.2.8",
"@mantine/dropzone": "^8.2.8",
"@mantine/hooks": "^8.2.8",
"@mui/icons-material": "^7.3.2",
"@mui/material": "^7.3.2",
"@tailwindcss/postcss": "^4.1.12",
"@tanstack/react-virtual": "^3.13.12",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^13.5.0",
"@testing-library/user-event": "^14.6.1",
"autoprefixer": "^10.4.21",
"axios": "^1.9.0",
"i18next": "^25.2.1",
"i18next-browser-languagedetector": "^8.1.0",
"axios": "^1.11.0",
"i18next": "^25.4.2",
"i18next-browser-languagedetector": "^8.2.0",
"i18next-http-backend": "^3.0.2",
"jszip": "^3.10.1",
"pdf-lib": "^1.17.1",
"pdfjs-dist": "^3.11.174",
"posthog-js": "^1.261.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-i18next": "^15.5.2",
"react-router-dom": "^7.6.0",
"tailwindcss": "^4.1.8",
"web-vitals": "^2.1.4"
"pdfjs-dist": "^5.4.149",
"posthog-js": "^1.261.4",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-i18next": "^15.7.3",
"react-router-dom": "^7.8.2",
"tailwindcss": "^4.1.12",
"web-vitals": "^5.1.0"
},
"scripts": {
"predev": "npm run generate-icons",
@ -74,21 +74,23 @@
"devDependencies": {
"@iconify-json/material-symbols": "^1.2.33",
"@iconify/utils": "^3.0.1",
"@playwright/test": "^1.40.0",
"@types/node": "^24.2.1",
"@types/react": "^19.1.4",
"@types/react-dom": "^19.1.5",
"@vitejs/plugin-react": "^4.5.0",
"@vitest/coverage-v8": "^1.0.0",
"jsdom": "^23.0.0",
"@playwright/test": "^1.55.0",
"@types/node": "^24.3.0",
"@types/pdfjs-dist": "^2.10.378",
"@types/react": "^19.1.12",
"@types/react-dom": "^19.1.9",
"@vitejs/plugin-react": "^5.0.2",
"@vitejs/plugin-react-swc": "^4.0.1",
"@vitest/coverage-v8": "^3.2.4",
"jsdom": "^26.1.0",
"license-checker": "^25.0.1",
"madge": "^8.0.0",
"postcss": "^8.5.3",
"postcss": "^8.5.6",
"postcss-cli": "^11.0.1",
"postcss-preset-mantine": "^1.17.0",
"postcss-preset-mantine": "^1.18.0",
"postcss-simple-vars": "^7.0.1",
"typescript": "^5.8.3",
"vite": "^6.3.5",
"vitest": "^1.0.0"
"typescript": "^5.9.2",
"vite": "^7.1.4",
"vitest": "^3.2.4"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -16,3 +16,5 @@ declare module '../assets/material-symbols-icons.json' {
};
export default value;
}
declare module 'pdfjs-dist/legacy/build/pdf.mjs'

View File

@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import * as pdfjsLib from 'pdfjs-dist';
import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';
import { pdfWorkerManager } from '../services/pdfWorkerManager';
export interface PdfSignatureDetectionResult {

View File

@ -1,4 +1,4 @@
import * as pdfjsLib from 'pdfjs-dist';
import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';
import { ProcessedFile, ProcessingState, PDFPage, ProcessingStrategy, ProcessingConfig, ProcessingMetrics } from '../types/processing';
import { ProcessingCache } from './processingCache';
import { FileHasher } from '../utils/fileHash';

View File

@ -4,7 +4,7 @@
* Called when files are added to FileContext, before any view sees them
*/
import * as pdfjsLib from 'pdfjs-dist';
import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';
import { generateThumbnailForFile } from '../utils/thumbnailUtils';
import { pdfWorkerManager } from './pdfWorkerManager';
import { FileId } from '../types/file';

View File

@ -130,7 +130,7 @@ export class PDFExportService {
newDoc.setModificationDate(new Date());
const pdfBytes = await newDoc.save();
return new Blob([pdfBytes], { type: 'application/pdf' });
return new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' });
}
/**
@ -176,7 +176,7 @@ export class PDFExportService {
newDoc.setModificationDate(new Date());
const pdfBytes = await newDoc.save();
return new Blob([pdfBytes], { type: 'application/pdf' });
return new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' });
}

View File

@ -5,8 +5,9 @@
* and ensuring proper cleanup when operations complete.
*/
import * as pdfjsLib from 'pdfjs-dist';
const { getDocument, GlobalWorkerOptions } = pdfjsLib;
import { GlobalWorkerOptions, getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs';
class PDFWorkerManager {
private static instance: PDFWorkerManager;
@ -31,7 +32,10 @@ class PDFWorkerManager {
*/
private initializeWorker(): void {
if (!this.isInitialized) {
GlobalWorkerOptions.workerSrc = '/pdf.worker.js';
GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/legacy/build/pdf.worker.min.mjs',
import.meta.url
).toString();
this.isInitialized = true;
}
}

View File

@ -1,5 +1,5 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import react from '@vitejs/plugin-react-swc';
export default defineConfig({
plugins: [react()],

View File

@ -1,5 +1,5 @@
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import react from '@vitejs/plugin-react-swc';
export default defineConfig({
plugins: [react()],