1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #18983 from Snuffleupagus/api-FetchBuiltInCMap-FetchStandardFontData-async

Change the "FetchBuiltInCMap"/"FetchStandardFontData" message-handlers to be asynchronous
This commit is contained in:
Tim van der Meij 2024-10-31 20:30:11 +01:00 committed by GitHub
commit 06f3b2d0a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2916,29 +2916,31 @@ class WorkerTransport {
});
});
messageHandler.on("FetchBuiltInCMap", data => {
messageHandler.on("FetchBuiltInCMap", async data => {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Not implemented: FetchBuiltInCMap");
}
if (this.destroyed) {
return Promise.reject(new Error("Worker was destroyed."));
throw new Error("Worker was destroyed.");
}
if (!this.cMapReaderFactory) {
return Promise.reject(
new Error(
"CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."
)
throw new Error(
"CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."
);
}
return this.cMapReaderFactory.fetch(data);
});
messageHandler.on("FetchStandardFontData", data => {
messageHandler.on("FetchStandardFontData", async data => {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Not implemented: FetchStandardFontData");
}
if (this.destroyed) {
return Promise.reject(new Error("Worker was destroyed."));
throw new Error("Worker was destroyed.");
}
if (!this.standardFontDataFactory) {
return Promise.reject(
new Error(
"StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."
)
throw new Error(
"StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."
);
}
return this.standardFontDataFactory.fetch(data);