Repository navigation
PER-10855: bump pdfjs-dist to 4.2.67 #2439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
27e4098
8976344
0261248
1856ce6
4458ff1
49cb539
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,14 +24,48 @@ export function assertRasterDimensions(pageNumber, width, height) { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| export async function openDocument(_, { origin }) { | ||||||||||||||||||||||||||||||||||||
| let lib = window['pdfjs-dist/build/pdf'] || window.pdfjsLib; | ||||||||||||||||||||||||||||||||||||
| // pdfjs-dist v4 is ESM only -- there is no UMD bundle left to read off disk and | ||||||||||||||||||||||||||||||||||||
| // eval into the page, so the library is imported as a module from the asset | ||||||||||||||||||||||||||||||||||||
| // server and parked on `window.pdfjsLib` for the scripts that follow. The | ||||||||||||||||||||||||||||||||||||
| // element's error event is the only signal for an import that never resolves. | ||||||||||||||||||||||||||||||||||||
| export async function loadLibrary(_, { origin, libFile }) { | ||||||||||||||||||||||||||||||||||||
| if (window.pdfjsLib) return true; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| let loaded = new Promise((resolve, reject) => { | ||||||||||||||||||||||||||||||||||||
| window.__percyPdfLoad = { resolve, reject }; | ||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| let script = document.createElement('script'); | ||||||||||||||||||||||||||||||||||||
| script.type = 'module'; | ||||||||||||||||||||||||||||||||||||
| script.textContent = [ | ||||||||||||||||||||||||||||||||||||
| `import * as lib from '${origin}/pdfjs/${libFile}';`, | ||||||||||||||||||||||||||||||||||||
| 'window.pdfjsLib = lib;', | ||||||||||||||||||||||||||||||||||||
| 'window.__percyPdfLoad.resolve();' | ||||||||||||||||||||||||||||||||||||
| ].join('\n'); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| script.onerror = () => window.__percyPdfLoad.reject( | ||||||||||||||||||||||||||||||||||||
| new Error('pdf.js failed to load in the page') | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| document.head.appendChild(script); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||
| await loaded; | ||||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||||
| delete window.__percyPdfLoad; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| export async function openDocument(_, { origin, workerFile }) { | ||||||||||||||||||||||||||||||||||||
| let lib = window.pdfjsLib; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (!lib) { | ||||||||||||||||||||||||||||||||||||
| throw new Error('pdf.js did not initialise in the page'); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| lib.GlobalWorkerOptions.workerSrc = `${origin}/pdfjs/pdf.worker.js`; | ||||||||||||||||||||||||||||||||||||
| lib.GlobalWorkerOptions.workerSrc = `${origin}/pdfjs/${workerFile}`; | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+61
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: rg -n "openDocument\s*\(|openDocument\b" packages --glob '!**/node_modules/**'
sed -n '1,115p' packages/cli-pdf/src/browser-scripts.js
sed -n '45,105p' packages/core/src/pdf-rasterize.js
sed -n '1,80p' packages/cli-pdf/src/index.jsRepository: percy/cli Length of output: 7593 🏁 Script executed: #!/bin/bash
printf '%s\n' '--- tracked references ---'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.git/**' 'openDocument|workerFile|pdfjs/' .
printf '%s\n' '--- package metadata ---'
find packages -maxdepth 3 -name package.json -print -exec sed -n '1,180p' {} \;
printf '%s\n' '--- asset definitions and server ---'
rg -n 'workerFile|createAssetServer|standard_fonts|cmaps|pdfjs' packages --glob '!**/node_modules/**'Repository: percy/cli Length of output: 25952 Set a default worker filename for existing When a consumer calls the exported Proposed fix-export async function openDocument(_, { origin, workerFile }) {
+export async function openDocument(_, { origin, workerFile = 'pdf.worker.mjs' }) {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| let doc = await lib.getDocument({ | ||||||||||||||||||||||||||||||||||||
| url: `${origin}/doc.pdf`, | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: percy/cli
Length of output: 4190
🏁 Script executed:
Repository: percy/cli
Length of output: 6820
🌐 Web query:
official npm metadata pdfjs-dist 4.2.67 engines node💡 Result:
<source_evidence>
Citations:
🏁 Script executed:
Repository: percy/cli
Length of output: 2433
🌐 Web query:
"pdfjs-dist@4.2.67" "engines" "node" ">=18"💡 Result:
<source_evidence>
Citations:
🏁 Script executed:
Repository: percy/cli
Length of output: 236
Align the package engine with the PDF renderer.
pdfjs-dist@4.2.67requires Node>=18, but@percy/cli-pdfadvertises Node>=14. If the optional dependency is skipped on Node 14–17,pdfjsAssets()throws and core returns HTTP 501. PDF rendering is therefore unavailable for supported runtimes.Raise the engine requirement for this PDF.js v4 implementation:
Suggested fix
"engines": { - "node": ">=14" + "node": ">=18" },If Node 14–17 support is required, use a PDF.js release compatible with those runtimes and its matching asset layout instead.
🤖 Prompt for AI Agents