Merge pull request #10787 from overleaf/ae-pdfjs-3

Start upgrading pdf.js to the latest version

GitOrigin-RevId: e7d8c6dedb0fe58ba31626408df81fd42ba1ca3b
This commit is contained in:
Alf Eaton 2022-12-08 09:27:13 +00:00 committed by Copybot
parent 61cea11b2a
commit 12af54069c
7 changed files with 177 additions and 37 deletions

184
package-lock.json generated
View file

@ -12465,6 +12465,21 @@
"url": "https://opencollective.com/browserslist"
}
},
"node_modules/canvas": {
"version": "2.10.2",
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.2.tgz",
"integrity": "sha512-FSmlsip0nZ0U4Zcfht0qBJqDhlfGuevTZKE8h+dBOYrJjGvY3iqMGSzzbvkaFhvMXiVxfcMaPHS/kge++T5SKg==",
"hasInstallScript": true,
"optional": true,
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.0",
"nan": "^2.17.0",
"simple-get": "^3.0.3"
},
"engines": {
"node": ">=6"
}
},
"node_modules/caseless": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
@ -25563,9 +25578,9 @@
"integrity": "sha512-N/sMKHniSDJBjfrkbS/tpkPj4RAbvW3mr8UAzvlMHyun93XEm83IAvhWtJVHo+RHn/oO8Job5YN4b+wRjSVp5g=="
},
"node_modules/nan": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
"version": "2.17.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz",
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ=="
},
"node_modules/nanoclone": {
"version": "0.2.1",
@ -27620,15 +27635,6 @@
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
"integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10="
},
"node_modules/pdfjs-dist210": {
"name": "pdfjs-dist",
"version": "2.10.377",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.10.377.tgz",
"integrity": "sha512-i0jRShtvgfsVQUNCoFYH4SVhPO3U0yhtiFLfZ0RR0B+68N+Vnwq+8B3cjWjLEwWGh8wg1XQ/sYMYKUlHn/Qpsw==",
"peerDependencies": {
"worker-loader": "^3.0.7"
}
},
"node_modules/pdfjs-dist213": {
"name": "pdfjs-dist",
"version": "2.13.216",
@ -27646,6 +27652,26 @@
}
}
},
"node_modules/pdfjs-dist31": {
"name": "pdfjs-dist",
"version": "3.1.81",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.1.81.tgz",
"integrity": "sha512-hZHVVbjU2Ac1VYyPFrg9fBcyS7EEdB8YFy5upk6LmnsXl10WxAavdiViGWi2C/xK0GZObEpSSJU1VnoF9t8n9w==",
"dependencies": {
"web-streams-polyfill": "^3.2.1"
},
"optionalDependencies": {
"canvas": "^2.10.2"
}
},
"node_modules/pdfjs-dist31/node_modules/web-streams-polyfill": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
"engines": {
"node": ">= 8"
}
},
"node_modules/pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
@ -31077,6 +31103,61 @@
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
},
"node_modules/simple-concat": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"optional": true
},
"node_modules/simple-get": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
"integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
"optional": true,
"dependencies": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
"simple-concat": "^1.0.0"
}
},
"node_modules/simple-get/node_modules/decompress-response": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
"optional": true,
"dependencies": {
"mimic-response": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/simple-get/node_modules/mimic-response": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
"optional": true,
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/simple-is": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/simple-is/-/simple-is-0.2.0.tgz",
@ -35088,6 +35169,7 @@
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-3.0.8.tgz",
"integrity": "sha512-XQyQkIFeRVC7f7uRhFdNMe/iJOdO6zxAaR3EWbDp45v3mDhrTi+++oswKNxShUNjPC/1xUp5DB29YKLhFo129g==",
"devOptional": true,
"dependencies": {
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0"
@ -38542,8 +38624,8 @@
"passport-orcid": "0.0.4",
"passport-saml": "https://github.com/overleaf/passport-saml/releases/download/v3.2.3-overleaf/passport-saml-3.2.3-overleaf.tar.gz",
"passport-twitter": "^1.0.4",
"pdfjs-dist210": "npm:pdfjs-dist@2.10.377",
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
"pdfjs-dist31": "npm:pdfjs-dist@3.1.81",
"prop-types": "^15.7.2",
"pug": "^3.0.1",
"pug-runtime": "^3.0.1",
@ -48663,8 +48745,8 @@
"passport-orcid": "0.0.4",
"passport-saml": "https://github.com/overleaf/passport-saml/releases/download/v3.2.3-overleaf/passport-saml-3.2.3-overleaf.tar.gz",
"passport-twitter": "^1.0.4",
"pdfjs-dist210": "npm:pdfjs-dist@2.10.377",
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
"pdfjs-dist31": "npm:pdfjs-dist@3.1.81",
"pirates": "^4.0.1",
"postcss-loader": "^6.2.1",
"prop-types": "^15.7.2",
@ -53915,6 +53997,17 @@
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001304.tgz",
"integrity": "sha512-bdsfZd6K6ap87AGqSHJP/s1V+U6Z5lyrcbBu3ovbCCf8cSYpwTtGrCBObMpJqwxfTbLW6YTIdbb1jEeTelcpYQ=="
},
"canvas": {
"version": "2.10.2",
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.2.tgz",
"integrity": "sha512-FSmlsip0nZ0U4Zcfht0qBJqDhlfGuevTZKE8h+dBOYrJjGvY3iqMGSzzbvkaFhvMXiVxfcMaPHS/kge++T5SKg==",
"optional": true,
"requires": {
"@mapbox/node-pre-gyp": "^1.0.0",
"nan": "^2.17.0",
"simple-get": "^3.0.3"
}
},
"caseless": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
@ -64296,9 +64389,9 @@
"integrity": "sha512-N/sMKHniSDJBjfrkbS/tpkPj4RAbvW3mr8UAzvlMHyun93XEm83IAvhWtJVHo+RHn/oO8Job5YN4b+wRjSVp5g=="
},
"nan": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
"version": "2.17.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz",
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ=="
},
"nanoclone": {
"version": "0.2.1",
@ -66359,12 +66452,6 @@
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
"integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10="
},
"pdfjs-dist210": {
"version": "npm:pdfjs-dist@2.10.377",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.10.377.tgz",
"integrity": "sha512-i0jRShtvgfsVQUNCoFYH4SVhPO3U0yhtiFLfZ0RR0B+68N+Vnwq+8B3cjWjLEwWGh8wg1XQ/sYMYKUlHn/Qpsw==",
"requires": {}
},
"pdfjs-dist213": {
"version": "npm:pdfjs-dist@2.13.216",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.13.216.tgz",
@ -66373,6 +66460,22 @@
"web-streams-polyfill": "^3.2.0"
}
},
"pdfjs-dist31": {
"version": "npm:pdfjs-dist@3.1.81",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.1.81.tgz",
"integrity": "sha512-hZHVVbjU2Ac1VYyPFrg9fBcyS7EEdB8YFy5upk6LmnsXl10WxAavdiViGWi2C/xK0GZObEpSSJU1VnoF9t8n9w==",
"requires": {
"canvas": "^2.10.2",
"web-streams-polyfill": "^3.2.1"
},
"dependencies": {
"web-streams-polyfill": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q=="
}
}
},
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
@ -69121,6 +69224,40 @@
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
},
"simple-concat": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",
"optional": true
},
"simple-get": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
"integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
"optional": true,
"requires": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
"simple-concat": "^1.0.0"
},
"dependencies": {
"decompress-response": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
"optional": true,
"requires": {
"mimic-response": "^2.0.0"
}
},
"mimic-response": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
"optional": true
}
}
},
"simple-is": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/simple-is/-/simple-is-0.2.0.tgz",
@ -72359,6 +72496,7 @@
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-3.0.8.tgz",
"integrity": "sha512-XQyQkIFeRVC7f7uRhFdNMe/iJOdO6zxAaR3EWbDp45v3mDhrTi+++oswKNxShUNjPC/1xUp5DB29YKLhFo129g==",
"devOptional": true,
"requires": {
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0"

View file

@ -904,7 +904,7 @@ const ProjectController = {
SplitTestHandler.getAssignment(
req,
res,
'pdfjs',
'pdfjs-31',
{},
(error, assignment) => {
// do not fail editor load if assignment fails

View file

@ -35,7 +35,7 @@ const buildConfig = () => {
)
// add entrypoints under '/' for pdfjs workers
const pdfjsVersions = ['pdfjs-dist210', 'pdfjs-dist213']
const pdfjsVersions = ['pdfjs-dist213', 'pdfjs-dist31']
for (const name of pdfjsVersions) {
addWorker(name, `${name}/legacy/build/pdf.worker.js`)
}

View file

@ -6,20 +6,20 @@ import 'core-js/stable/promise/all-settled' // polyfill for Promise.allSettled (
import getMeta from '../../../utils/meta'
import { createWorker } from '../../../utils/worker'
async function importPDFJS210() {
const cMapUrl = '/js/pdfjs-dist210/cmaps/'
const standardFontDataUrl = '/fonts/pdfjs-dist210/'
const imageResourcesPath = '/images/pdfjs-dist210'
async function importPDFJS31() {
const cMapUrl = '/js/pdfjs-dist31/cmaps/'
const standardFontDataUrl = '/fonts/pdfjs-dist31/'
const imageResourcesPath = '/images/pdfjs-dist31'
const [PDFJS, PDFJSViewer] = await Promise.all([
import('pdfjs-dist210/legacy/build/pdf'),
import('pdfjs-dist210/legacy/web/pdf_viewer'),
import('pdfjs-dist210/legacy/web/pdf_viewer.css'),
import('pdfjs-dist31/legacy/build/pdf'),
import('pdfjs-dist31/legacy/web/pdf_viewer'),
import('pdfjs-dist31/legacy/web/pdf_viewer.css'),
])
createWorker(() => {
PDFJS.GlobalWorkerOptions.workerPort = new Worker(
new URL('pdfjs-dist210/legacy/build/pdf.worker.js', import.meta.url)
new URL('pdfjs-dist31/legacy/build/pdf.worker.js', import.meta.url)
)
})
@ -66,8 +66,8 @@ async function importPDFJS() {
case 'default':
return importPDFJS213()
case '210':
return importPDFJS210()
case '318':
return importPDFJS31()
}
}

View file

@ -54,6 +54,8 @@ export default class PDFJSWrapper {
enableXfa: false, // default is false (2021-10-12), but set explicitly to be sure
renderInteractiveForms: false,
maxCanvasPixels: 8192 * 8192, // default is 4096 * 4096, increased for better resolution at high zoom levels
annotationMode: PDFJS.AnnotationMode?.ENABLE, // enable annotations but not forms
annotationEditorMode: PDFJS.AnnotationEditorType?.DISABLE, // disable annotation editing
})
linkService.setViewer(viewer)

View file

@ -200,8 +200,8 @@
"passport-orcid": "0.0.4",
"passport-saml": "https://github.com/overleaf/passport-saml/releases/download/v3.2.3-overleaf/passport-saml-3.2.3-overleaf.tar.gz",
"passport-twitter": "^1.0.4",
"pdfjs-dist210": "npm:pdfjs-dist@2.10.377",
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
"pdfjs-dist31": "npm:pdfjs-dist@3.1.81",
"prop-types": "^15.7.2",
"pug": "^3.0.1",
"pug-runtime": "^3.0.1",

View file

@ -60,7 +60,7 @@ function getModuleDirectory(moduleName) {
const mathjaxDir = getModuleDirectory('mathjax')
const aceDir = getModuleDirectory('ace-builds')
const pdfjsVersions = ['pdfjs-dist210', 'pdfjs-dist213']
const pdfjsVersions = ['pdfjs-dist213', 'pdfjs-dist31']
const vendorDir = path.join(__dirname, 'frontend/js/vendor')