Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+18
@@ -0,0 +1,18 @@
|
||||
import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
|
||||
export type PdfJs = typeof import("pdfjs-dist");
|
||||
|
||||
let pdfJsLoadPromise: Promise<PdfJs> | undefined;
|
||||
|
||||
export function loadPdfJs(): Promise<PdfJs> {
|
||||
pdfJsLoadPromise ??= import("pdfjs-dist").then((pdfJs) => {
|
||||
const emittedUrl = new URL(pdfWorkerUrl, globalThis.location.href);
|
||||
const sameOriginWorkerUrl = new URL(`${emittedUrl.pathname}${emittedUrl.search}${emittedUrl.hash}`, globalThis.location.origin);
|
||||
// Worker constructors require a same-origin URL, including builds whose
|
||||
// regular assets use a first-party CDN. Keeping API and worker on one
|
||||
// package version also avoids PDF.js's fail-closed version mismatch.
|
||||
pdfJs.GlobalWorkerOptions.workerSrc = sameOriginWorkerUrl.href;
|
||||
return pdfJs;
|
||||
});
|
||||
return pdfJsLoadPromise;
|
||||
}
|
||||
Reference in new issue
Block a user