diff --git a/.github/workflows/deploy-beta.yml b/.github/workflows/deploy-beta.yml index b2b2327..017ae0c 100644 --- a/.github/workflows/deploy-beta.yml +++ b/.github/workflows/deploy-beta.yml @@ -10,7 +10,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Setup pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 with: version: 8.x - name: Setup Node.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0b23e08..0c56ed5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Setup pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 with: version: 8.x - name: Setup Node.js diff --git a/.github/workflows/deprecate-version.yml b/.github/workflows/deprecate-version.yml index 120a605..5030b07 100644 --- a/.github/workflows/deprecate-version.yml +++ b/.github/workflows/deprecate-version.yml @@ -18,7 +18,7 @@ jobs: deprecate: runs-on: ubuntu-latest steps: - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: version: 8.x - uses: actions/setup-node@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e8b4259..0aa62dc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup pnpm - uses: pnpm/action-setup@v2.2.2 + uses: pnpm/action-setup@v4 with: version: 8.x - name: Checkout @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup pnpm - uses: pnpm/action-setup@v2.2.2 + uses: pnpm/action-setup@v4 with: version: 8.x - name: Checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d415ae..4dc4e8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## v1.6.2 (10/10/2023) + +### Changes + +- :arrow_up: update pdfjs-dist to v4.10.38 + ## v1.6.1 (10/10/2023) ### Changes diff --git a/cypress/downloads/downloads.html b/cypress/downloads/downloads.html new file mode 100644 index 0000000..230ab57 Binary files /dev/null and b/cypress/downloads/downloads.html differ diff --git a/cypress/snapshots/components/AnnotationViewer.spec.tsx/remote.file.snap.png b/cypress/snapshots/components/AnnotationViewer.spec.tsx/remote.file.snap.png index 1cb75e9..da88355 100644 Binary files a/cypress/snapshots/components/AnnotationViewer.spec.tsx/remote.file.snap.png and b/cypress/snapshots/components/AnnotationViewer.spec.tsx/remote.file.snap.png differ diff --git a/package.json b/package.json index 19687c7..530c4b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-mindee-js", - "version": "1.6.1", + "version": "1.6.2", "description": "Front-End Computer Vision SDK for React", "author": "@mindee", "license": "MIT", @@ -16,7 +16,7 @@ "@types/utif": "^3.0.1", "heic2any": "^0.0.4", "konva": "^8.1.3", - "pdfjs-dist": "2.6.347", + "pdfjs-dist": "4.10.38", "utif": "^3.1.0", "uuid": "^8.3.2" }, @@ -57,8 +57,8 @@ "cy:prepare": "pnpm build", "prepare": "ts-patch install -s", "build": "vite build", - "cy:open": "cypress open --component --browser firefox", - "cy:run": "cypress run --component --browser firefox", + "cy:open": "cypress open --component --browser chrome", + "cy:run": "cypress run --component --browser chrome", "docs:start": "pnpm --dir ./docs start", "docs:install": "pnpm --dir ./docs install", "docs:prepare": "pnpm build && pnpm docs:install", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53c4d77..5292fe1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -15,8 +15,8 @@ dependencies: specifier: ^8.1.3 version: 8.1.3 pdfjs-dist: - specifier: 2.6.347 - version: 2.6.347 + specifier: 4.10.38 + version: 4.10.38 utif: specifier: ^3.1.0 version: 3.1.0 @@ -1096,6 +1096,94 @@ packages: resolution: {integrity: sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug==} dev: true + /@napi-rs/canvas-android-arm64@0.1.65: + resolution: {integrity: sha512-ZYwqFYEKcT5Zr8lbiaJNJj/poLaeK2TncolY914r+gD2TJNeP7ZqvE7A2SX/1C9MB4E3DQEwm3YhL3WEf0x3MQ==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-darwin-arm64@0.1.65: + resolution: {integrity: sha512-Pg1pfiJEyDIsX+V0QaJPRWvXbw5zmWAk3bivFCvt/5pwZb37/sT6E/RqPHT9NnqpDyKW6SriwY9ypjljysUA1Q==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-darwin-x64@0.1.65: + resolution: {integrity: sha512-3Tr+/HjdJN7Z/VKIcsxV2DvDIibZCExgfYTgljCkUSFuoI7iNkOE6Dc1Q6j212EB9PeO8KmfrViBqHYT6IwWkA==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-linux-arm-gnueabihf@0.1.65: + resolution: {integrity: sha512-3KP+dYObH7CVkZMZWwk1WX9jRjL+EKdQtD43H8MOI+illf+dwqLlecdQ4d9bQRIxELKJ8dyPWY4fOp/Ngufrdg==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-linux-arm64-gnu@0.1.65: + resolution: {integrity: sha512-Ka3StKz7Dq7kjTF3nNJCq43UN/VlANS7qGE3dWkn1d+tQNsCRy/wRmyt1TUFzIjRqcTFMQNRbgYq84+53UBA0A==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-linux-arm64-musl@0.1.65: + resolution: {integrity: sha512-O4xMASm2JrmqYoiDyxVWi+z5C14H+oVEag2rZ5iIA67dhWqYZB+iO7wCFpBYRj31JPBR29FOsu6X9zL+DwBFdw==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-linux-riscv64-gnu@0.1.65: + resolution: {integrity: sha512-dblWDaA59ZU8bPbkfM+riSke7sFbNZ70LEevUdI5rgiFEUzYUQlU34gSBzemTACj5rCWt1BYeu0GfkLSjNMBSw==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-linux-x64-gnu@0.1.65: + resolution: {integrity: sha512-wsp+atutw13OJXGU3DDkdngtBDoEg01IuK5xMe0L6VFPV8maGkh17CXze078OD5QJOc6kFyw3DDscMLOPF8+oA==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-linux-x64-musl@0.1.65: + resolution: {integrity: sha512-odX+nN+IozWzhdj31INcHz3Iy9+EckNw+VqsZcaUxZOTu7/3FmktRNI6aC1qe5minZNv1m05YOS1FVf7fvmjlA==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas-win32-x64-msvc@0.1.65: + resolution: {integrity: sha512-RZQX3luWnlNWgdMnLMQ1hyfQraeAn9lnxWWVCHuUM4tAWEV8UDdeb7cMwmJW7eyt8kAosmjeHt3cylQMHOxGFg==} + engines: {node: '>= 10'} + requiresBuild: true + dev: false + optional: true + + /@napi-rs/canvas@0.1.65: + resolution: {integrity: sha512-YcFhXQcp+b2d38zFOJNbpyPHnIL7KAEkhJQ+UeeKI5IpE9B8Cpf/M6RiHPQXSsSqnYbrfFylnW49dyh2oeSblQ==} + engines: {node: '>= 10'} + requiresBuild: true + optionalDependencies: + '@napi-rs/canvas-android-arm64': 0.1.65 + '@napi-rs/canvas-darwin-arm64': 0.1.65 + '@napi-rs/canvas-darwin-x64': 0.1.65 + '@napi-rs/canvas-linux-arm-gnueabihf': 0.1.65 + '@napi-rs/canvas-linux-arm64-gnu': 0.1.65 + '@napi-rs/canvas-linux-arm64-musl': 0.1.65 + '@napi-rs/canvas-linux-riscv64-gnu': 0.1.65 + '@napi-rs/canvas-linux-x64-gnu': 0.1.65 + '@napi-rs/canvas-linux-x64-musl': 0.1.65 + '@napi-rs/canvas-win32-x64-msvc': 0.1.65 + dev: false + optional: true + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1557,6 +1645,7 @@ packages: /abab@2.0.6: resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==} + deprecated: Use your platform's native atob() and btoa() methods instead dev: true /acorn-globals@6.0.0: @@ -2469,6 +2558,7 @@ packages: /domexception@2.0.1: resolution: {integrity: sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==} engines: {node: '>=8'} + deprecated: Use your platform's native DOMException instead dependencies: webidl-conversions: 5.0.0 dev: true @@ -3206,6 +3296,7 @@ packages: /growly@1.3.0: resolution: {integrity: sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw==} + requiresBuild: true dev: true optional: true @@ -3409,6 +3500,7 @@ packages: /is-accessor-descriptor@0.1.6: resolution: {integrity: sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==} engines: {node: '>=0.10.0'} + deprecated: Please upgrade to v0.1.7 dependencies: kind-of: 3.2.2 dev: true @@ -3416,6 +3508,7 @@ packages: /is-accessor-descriptor@1.0.0: resolution: {integrity: sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==} engines: {node: '>=0.10.0'} + deprecated: Please upgrade to v1.0.1 dependencies: kind-of: 6.0.3 dev: true @@ -3457,6 +3550,7 @@ packages: /is-data-descriptor@0.1.4: resolution: {integrity: sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==} engines: {node: '>=0.10.0'} + deprecated: Please upgrade to v0.1.5 dependencies: kind-of: 3.2.2 dev: true @@ -3464,6 +3558,7 @@ packages: /is-data-descriptor@1.0.0: resolution: {integrity: sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==} engines: {node: '>=0.10.0'} + deprecated: Please upgrade to v1.0.1 dependencies: kind-of: 6.0.3 dev: true @@ -3490,6 +3585,7 @@ packages: resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} engines: {node: '>=8'} hasBin: true + requiresBuild: true dev: true optional: true @@ -3597,6 +3693,7 @@ packages: /is-wsl@2.2.0: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} + requiresBuild: true dependencies: is-docker: 2.2.1 dev: true @@ -4871,8 +4968,11 @@ packages: engines: {node: '>=8'} dev: true - /pdfjs-dist@2.6.347: - resolution: {integrity: sha512-QC+h7hG2su9v/nU1wEI3SnpPIrqJODL7GTDFvR74ANKGq1AFJW16PH8VWnhpiTi9YcLSFV9xLeWSgq+ckHLdVQ==} + /pdfjs-dist@4.10.38: + resolution: {integrity: sha512-/Y3fcFrXEAsMjJXeL9J8+ZG9U01LbuWaYypvDW2ycW1jL269L3js3DVBjDJ0Up9Np1uqDXsDrRihHANhZOlwdQ==} + engines: {node: '>=20'} + optionalDependencies: + '@napi-rs/canvas': 0.1.65 dev: false /pend@1.2.0: @@ -5368,6 +5468,7 @@ packages: /shellwords@0.1.1: resolution: {integrity: sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==} + requiresBuild: true dev: true optional: true diff --git a/src/utils/getImagesFromPDF.ts b/src/utils/getImagesFromPDF.ts index dd4d971..6c24028 100644 --- a/src/utils/getImagesFromPDF.ts +++ b/src/utils/getImagesFromPDF.ts @@ -1,13 +1,15 @@ -import { getDocument, GlobalWorkerOptions, version } from 'pdfjs-dist' import { + getDocument, + GlobalWorkerOptions, PDFDocumentProxy, PDFPageProxy, - RenderParameters, -} from 'pdfjs-dist/types/display/api' + version, +} from 'pdfjs-dist' +import { RenderParameters } from 'pdfjs-dist/types/src/display/api' import { MAX_PDF_SCALE, PDF_RESOLUTION } from '@/common/constants' -GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${version}/pdf.worker.js` +GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${version}/build/pdf.worker.min.mjs` const getImageFromPage = async ( _document: PDFDocumentProxy,