Remove pdfjs-dist split test

GitOrigin-RevId: 39c8a54921c2b541a5bbe3670e1baa6fd9d5f745
This commit is contained in:
Alf Eaton 2024-09-14 14:53:53 +01:00 committed by Copybot
parent 90904e876c
commit 5e7f4feeb8
7 changed files with 49 additions and 165 deletions

74
package-lock.json generated
View file

@ -31585,26 +31585,7 @@
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
"integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10="
},
"node_modules/pdfjs-dist213": {
"name": "pdfjs-dist",
"version": "2.13.216",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.13.216.tgz",
"integrity": "sha512-qn/9a/3IHIKZarTK6ajeeFXBkG15Lg1Fx99PxU09PAU2i874X8mTcHJYyDJxu7WDfNhV6hM7bRQBZU384anoqQ==",
"dev": true,
"dependencies": {
"web-streams-polyfill": "^3.2.0"
},
"peerDependencies": {
"worker-loader": "^3.0.8"
},
"peerDependenciesMeta": {
"worker-loader": {
"optional": true
}
}
},
"node_modules/pdfjs-dist401": {
"name": "pdfjs-dist",
"node_modules/pdfjs-dist": {
"version": "4.5.136",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-4.5.136.tgz",
"integrity": "sha512-V1BALcAN/FmxBEShLxoP73PlQZAZtzlaNfRbRhJrKvXzjLC5VaIlBAQUJuWP8iaYUmIdmdLHmt3E2TBglxOm3w==",
@ -40806,28 +40787,6 @@
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"dev": true
},
"node_modules/worker-loader": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-3.0.8.tgz",
"integrity": "sha512-XQyQkIFeRVC7f7uRhFdNMe/iJOdO6zxAaR3EWbDp45v3mDhrTi+++oswKNxShUNjPC/1xUp5DB29YKLhFo129g==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "^4.0.0 || ^5.0.0"
}
},
"node_modules/workerpool": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz",
@ -43979,8 +43938,7 @@
"mock-fs": "^5.1.2",
"nvd3": "^1.8.6",
"overleaf-editor-core": "*",
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
"pdfjs-dist401": "npm:pdfjs-dist@4.5.136",
"pdfjs-dist": "4.5.136",
"pirates": "^4.0.1",
"postcss": "^8.4.31",
"postcss-loader": "^7.3.3",
@ -52539,8 +52497,7 @@
"passport-local": "^1.0.0",
"passport-oauth2": "^1.5.0",
"passport-orcid": "0.0.4",
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
"pdfjs-dist401": "npm:pdfjs-dist@4.5.136",
"pdfjs-dist": "4.5.136",
"pirates": "^4.0.1",
"postcss": "^8.4.31",
"postcss-loader": "^7.3.3",
@ -72104,17 +72061,8 @@
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
"integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10="
},
"pdfjs-dist213": {
"version": "npm:pdfjs-dist@2.13.216",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.13.216.tgz",
"integrity": "sha512-qn/9a/3IHIKZarTK6ajeeFXBkG15Lg1Fx99PxU09PAU2i874X8mTcHJYyDJxu7WDfNhV6hM7bRQBZU384anoqQ==",
"dev": true,
"requires": {
"web-streams-polyfill": "^3.2.0"
}
},
"pdfjs-dist401": {
"version": "npm:pdfjs-dist@4.5.136",
"pdfjs-dist": {
"version": "4.5.136",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-4.5.136.tgz",
"integrity": "sha512-V1BALcAN/FmxBEShLxoP73PlQZAZtzlaNfRbRhJrKvXzjLC5VaIlBAQUJuWP8iaYUmIdmdLHmt3E2TBglxOm3w==",
"dev": true,
@ -78824,18 +78772,6 @@
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"dev": true
},
"worker-loader": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-3.0.8.tgz",
"integrity": "sha512-XQyQkIFeRVC7f7uRhFdNMe/iJOdO6zxAaR3EWbDp45v3mDhrTi+++oswKNxShUNjPC/1xUp5DB29YKLhFo129g==",
"dev": true,
"optional": true,
"peer": true,
"requires": {
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0"
}
},
"workerpool": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz",

View file

@ -330,7 +330,6 @@ const _ProjectController = {
'pdf-caching-prefetch-large',
'pdf-caching-prefetching',
'pdf-presentation-mode',
'pdfjs-40',
'revert-file',
'revert-project',
'review-panel-redesign',
@ -734,7 +733,6 @@ const _ProjectController = {
wsUrl,
showSupport: Features.hasFeature('support'),
showTemplatesServerPro,
pdfjsVariant: splitTestAssignments['pdfjs-40'].variant,
debugPdfDetach,
showSymbolPalette,
symbolPaletteAvailable: Features.hasFeature('symbol-palette'),

View file

@ -17,7 +17,6 @@ meta(name="ol-compilesUserContentDomain" content=settings.compilesUserContentDom
meta(name="ol-useShareJsHash" data-type="boolean" content=true)
meta(name="ol-wsUrl" data-type="string" content=wsUrl)
meta(name="ol-wsRetryHandshake" data-type="json" content=settings.wsRetryHandshake)
meta(name="ol-pdfjsVariant" content=pdfjsVariant)
meta(name="ol-debugPdfDetach" data-type="boolean" content=debugPdfDetach)
meta(name="ol-showSymbolPalette" data-type="boolean" content=showSymbolPalette)
meta(name="ol-symbolPaletteAvailable" data-type="boolean" content=symbolPaletteAvailable)

View file

@ -41,8 +41,7 @@ const buildConfig = () => {
)
// add entrypoints under '/' for pdfjs workers
addWorker('pdfjs-dist213', 'pdfjs-dist213/legacy/build/pdf.worker.js')
addWorker('pdfjs-dist401', 'pdfjs-dist401/legacy/build/pdf.worker.mjs')
addWorker('pdfjs-dist', 'pdfjs-dist/legacy/build/pdf.worker.mjs')
return webpackConfig
}

View file

@ -5,76 +5,33 @@ import 'core-js/stable/global-this' // polyfill for globalThis (used by pdf.js)
import 'core-js/stable/promise/all-settled' // polyfill for Promise.allSettled (used by pdf.js)
import 'core-js/stable/structured-clone' // polyfill for global.StructuredClone (used by pdf.js)
import 'core-js/stable/array/at' // polyfill for Array.prototype.at (used by pdf.js)
import getMeta from '@/utils/meta'
import { createWorker } from '@/utils/worker'
async function importPDFJS401() {
const cMapUrl = '/js/pdfjs-dist401/cmaps/'
const standardFontDataUrl = '/fonts/pdfjs-dist401/'
const imageResourcesPath = '/images/pdfjs-dist401/'
// ensure that PDF.js is loaded before importing the viewer
const PDFJS = await import('pdfjs-dist401/legacy/build/pdf')
const [PDFJSViewer] = await Promise.all([
import('pdfjs-dist401/legacy/web/pdf_viewer'),
import('pdfjs-dist401/legacy/web/pdf_viewer.css'),
])
createWorker(() => {
PDFJS.GlobalWorkerOptions.workerPort = new Worker(
new URL('pdfjs-dist401/legacy/build/pdf.worker.mjs', import.meta.url) // NOTE: .mjs extension
)
})
return {
PDFJS,
PDFJSViewer,
cMapUrl,
imageResourcesPath,
standardFontDataUrl,
}
}
async function importPDFJS213() {
const cMapUrl = '/js/pdfjs-dist213/cmaps/'
const standardFontDataUrl = '/fonts/pdfjs-dist213/'
const imageResourcesPath = '/images/pdfjs-dist213/'
// ensure that PDF.js is loaded before importing the viewer
const PDFJS = await import('pdfjs-dist213/legacy/build/pdf')
const [PDFJSViewer] = await Promise.all([
import('pdfjs-dist213/legacy/web/pdf_viewer'),
import('pdfjs-dist213/legacy/web/pdf_viewer.css'),
])
createWorker(() => {
PDFJS.GlobalWorkerOptions.workerPort = new Worker(
new URL('pdfjs-dist213/legacy/build/pdf.worker.js', import.meta.url)
)
})
return {
PDFJS,
PDFJSViewer,
cMapUrl,
imageResourcesPath,
standardFontDataUrl,
}
}
async function importPDFJS() {
const variant = getMeta('ol-pdfjsVariant') || 'default'
const cMapUrl = '/js/pdfjs-dist/cmaps/'
const standardFontDataUrl = '/fonts/pdfjs-dist/'
const imageResourcesPath = '/images/pdfjs-dist/'
// NOTE: split test variants must have at least 3 characters
switch (variant) {
case '213':
case 'default':
return importPDFJS213()
// ensure that PDF.js is loaded before importing the viewer
const PDFJS = await import('pdfjs-dist/legacy/build/pdf')
case '401':
return importPDFJS401()
const [PDFJSViewer] = await Promise.all([
import('pdfjs-dist/legacy/web/pdf_viewer'),
import('pdfjs-dist/legacy/web/pdf_viewer.css'),
])
createWorker(() => {
PDFJS.GlobalWorkerOptions.workerPort = new Worker(
new URL('pdfjs-dist/legacy/build/pdf.worker.mjs', import.meta.url) // NOTE: .mjs extension
)
})
return {
PDFJS,
PDFJSViewer,
cMapUrl,
imageResourcesPath,
standardFontDataUrl,
}
}

View file

@ -323,8 +323,7 @@
"mock-fs": "^5.1.2",
"nvd3": "^1.8.6",
"overleaf-editor-core": "*",
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
"pdfjs-dist401": "npm:pdfjs-dist@4.5.136",
"pdfjs-dist": "4.5.136",
"pirates": "^4.0.1",
"postcss": "^8.4.31",
"postcss-loader": "^7.3.3",

View file

@ -66,10 +66,9 @@ function getModuleDirectory(moduleName) {
}
const mathjaxDir = getModuleDirectory('mathjax')
const pdfjsDir = getModuleDirectory('pdfjs-dist')
const dictionariesDir = getModuleDirectory('@overleaf/dictionaries')
const pdfjsVersions = ['pdfjs-dist213', 'pdfjs-dist401']
const vendorDir = path.join(__dirname, 'frontend/js/vendor')
const MATHJAX_VERSION = require('mathjax/package.json').version
@ -131,7 +130,7 @@ module.exports = {
// Only compile application files and specific dependencies
// (other npm and vendored dependencies must be in ES5 already)
exclude: [
/node_modules\/(?!(react-dnd|chart\.js|@uppy|pdfjs-dist401|react-resizable-panels)\/)/,
/node_modules\/(?!(react-dnd|chart\.js|@uppy|pdfjs-dist|react-resizable-panels)\/)/,
vendorDir,
],
use: [
@ -326,9 +325,9 @@ module.exports = {
jQuery: 'jquery',
}),
// Copy the required files for loading MathJax from MathJax NPM package
new CopyPlugin({
patterns: [
// Copy the required files for loading MathJax from MathJax NPM package
// https://www.npmjs.com/package/mathjax#user-content-hosting-your-own-copy-of-the-mathjax-components
{
from: 'es5/tex-svg-full.js',
@ -372,26 +371,23 @@ module.exports = {
toType: 'dir',
context: `${dictionariesDir}/dictionaries`,
},
...pdfjsVersions.flatMap(version => {
const dir = getModuleDirectory(version)
// Copy CMap files (used to provide support for non-Latin characters)
// and static images from pdfjs-dist package to build output.
return [
{ from: `cmaps`, to: `js/${version}/cmaps`, context: dir },
{
from: `standard_fonts`,
to: `fonts/${version}`,
context: dir,
},
{
from: `legacy/web/images`,
to: `images/${version}`,
context: dir,
},
]
}),
// Copy CMap files (used to provide support for non-Latin characters),
// fonts and images from pdfjs-dist package to build output.
{
from: 'cmaps',
to: 'js/pdfjs-dist/cmaps',
context: pdfjsDir,
},
{
from: 'standard_fonts',
to: 'fonts/pdfjs-dist',
context: pdfjsDir,
},
{
from: 'legacy/web/images',
to: 'images/pdfjs-dist',
context: pdfjsDir,
},
],
}),
],