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) { if (this.destroyed) {
return Promise.reject(new Error("Worker was destroyed.")); throw new Error("Worker was destroyed.");
} }
if (!this.cMapReaderFactory) { if (!this.cMapReaderFactory) {
return Promise.reject( throw new Error(
new Error( "CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."
"CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."
)
); );
} }
return this.cMapReaderFactory.fetch(data); 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) { if (this.destroyed) {
return Promise.reject(new Error("Worker was destroyed.")); throw new Error("Worker was destroyed.");
} }
if (!this.standardFontDataFactory) { if (!this.standardFontDataFactory) {
return Promise.reject( throw new Error(
new Error( "StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."
"StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."
)
); );
} }
return this.standardFontDataFactory.fetch(data); return this.standardFontDataFactory.fetch(data);