pdfjs = {
const [pdfjs, workerSrc, viewerStyle] = await Promise.all([
require("pdfjs-dist@2"),
require.resolve("pdfjs-dist@2/build/pdf.worker.js"),
require.resolve("pdfjs-dist@2/web/pdf_viewer.css")
]);
pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
window["pdfjs-dist/build/pdf"] = pdfjs;
Object.assign(pdfjs, await require("pdfjs-dist@2/web/pdf_viewer.js"));
delete window["pdfjs-dist/build/pdf"];
const link = document.head.appendChild(html`<style>
@import url("${viewerStyle}");
.pdfViewer {
overflow: hidden;
margin-bottom: -1em;
}
.pdfViewer .page {
border: solid 1px #ccc;
margin-bottom: 1em;
}
.annotationLayer .linkAnnotation > a:hover,
.annotationLayer .buttonWidgetAnnotation.pushButton > a:hover {
opacity: initial;
background: initial;
box-shadow: initial;
}
</style>`);
invalidation.then(() => link.remove());
return pdfjs;
}