Skip to content

Commit

Permalink
Merge pull request #18983 from Snuffleupagus/api-FetchBuiltInCMap-Fet…
Browse files Browse the repository at this point in the history
…chStandardFontData-async

Change the "FetchBuiltInCMap"/"FetchStandardFontData" message-handlers to be asynchronous
  • Loading branch information
timvandermeij authored Oct 31, 2024
2 parents 3ed438a + 7572382 commit 06f3b2d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 06f3b2d

Please sign in to comment.