mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Re-factor DefaultExternalServices
into a regular class, without static methods
The `DefaultExternalServices` code, which is used to provide build-specific functionality, is very old. This results in a pattern where we first initialize `PDFViewerApplication.externalServices` and then *override* it for the different builds. By converting `DefaultExternalServices` into a "regular" class, and leveraging import maps, we can directly initialize the correct instance depending on the build.
This commit is contained in:
parent
d1080e785a
commit
5dd25b6e80
9 changed files with 80 additions and 61 deletions
|
@ -13,8 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DefaultExternalServices, PDFViewerApplication } from "./app.js";
|
||||
import { AppOptions } from "./app_options.js";
|
||||
import { BaseExternalServices } from "./external_services.js";
|
||||
import { BasePreferences } from "./preferences.js";
|
||||
import { GenericL10n } from "./genericl10n.js";
|
||||
import { GenericScripting } from "./generic_scripting.js";
|
||||
|
@ -37,15 +37,14 @@ class Preferences extends BasePreferences {
|
|||
}
|
||||
}
|
||||
|
||||
class GenericExternalServices extends DefaultExternalServices {
|
||||
static async createL10n() {
|
||||
class ExternalServices extends BaseExternalServices {
|
||||
async createL10n() {
|
||||
return new GenericL10n(AppOptions.get("locale"));
|
||||
}
|
||||
|
||||
static createScripting() {
|
||||
createScripting() {
|
||||
return new GenericScripting(AppOptions.get("sandboxBundleSrc"));
|
||||
}
|
||||
}
|
||||
PDFViewerApplication.externalServices = GenericExternalServices;
|
||||
|
||||
export { GenericCom, Preferences };
|
||||
export { ExternalServices, GenericCom, Preferences };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue