Re-factor how the GenericL10n class fetches localization-data

- Re-factor the existing `fetchData` helper function such that it can fetch more types of data, and it now supports "arraybuffer", "json", and "text".
   This only needed minor adjustments in the `DOMCMapReaderFactory` and `DOMStandardFontDataFactory` classes.[1]

 - Expose the `fetchData` helper function in the API, such that the viewer is able to access it.

 - Use the `fetchData` helper function in the `GenericL10n` class, since this should allow fetching of localization-data even if the default viewer is run in an environment without support for the Fetch API.

---
[1] While testing this I also noticed a minor inconsistency when handling standard font-data on the worker-thread.
This commit is contained in:
Jonas Jenwald 2023-11-14 12:54:21 +01:00
parent 44cde3ccca
commit 709d89420e
6 changed files with 45 additions and 20 deletions

View file

@ -425,7 +425,7 @@ class PartialEvaluator {
`fetchStandardFontData: failed to fetch file "${url}" with "${response.statusText}".`
);
} else {
data = await response.arrayBuffer();
data = new Uint8Array(await response.arrayBuffer());
}
} else {
// Get the data on the main-thread instead.