Repository navigation
Support individual runtime asset URLs for hashed static files - #57
Conversation
Allow PDF.js scripts and stylesheets to use URLs generated by static asset pipelines such as Django's ManifestStaticFilesStorage. Preserve assets-base and bundled fallbacks, centralize worker URL resolution, and add documentation, a demo, and regression tests.
|
Thanks for this — the motivation is clear and the fallback order (attribute → 1. Runtime The init path now normalizes viewerOptions?.set('workerSrc', newValue || this.getRuntimeFileUrls().workerSrc)With a root-relative value such as viewerOptions?.set('workerSrc', this.getRuntimeFileUrls().workerSrc)A runtime test with a relative value would cover it — the existing one only uses an absolute URL. 2. Whitespace-only values are treated as set
const attr = this.getAttribute(...)?.trim()Everything else looks good to me. |
`pdf-src` reads as the PDF document URL next to `src`. `pdfjs-lib-src` names the PDF.js core library module (`pdf.mjs`, which sets `globalThis.pdfjsLib`) and avoids confusion with the pdf-lib package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the quick fixes, both look good. One more change, which I've pushed to your branch myself (c1eb859): Next to The commit renames the internal key |
I've also noticed that |
Follow-ups from the review of missing-elements#57: - Replace the regex that derived attribute names from object keys with an explicit RUNTIME_FILES table (attribute, dist file name, default). - Read runtime file URLs once per build, so the srcdoc CSP and the files it loads always come from the same values. - Escape stylesheet URLs written into the srcdoc markup; values that are not valid URLs are passed through as written. - Document that all runtime files must come from the same release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Released in v4.3.0, now on npm as Thank you for this one, @nvi9. The motivation was clear, the fallback order was right from the start, and the quick turnaround on the review points made it easy to land. The Django example in the demo is a nice touch for anyone else on a hashed-static-files setup. |
Summary
Allow PDF.js scripts and stylesheets to use URLs generated by static asset pipelines such as Django's ManifestStaticFilesStorage.
assets-baseconfigures a directorybut still assumes fixed filenames, so it cannot select those hashed runtime files individually.
This PR adds
pdf-src,viewer-src,viewer-css-src, andtheme-css-srcalongside the existingworker-srcattribute.with or without
assets-base.assets-base, then thebundled defaults.
Existing runtime worker option updates remain supported.
getRuntimeFileUrls().Validation
Checklist