From 08256e6795bbec885746cba1c198c0b4c5f84982 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 6 Jan 2022 12:09:57 +0100 Subject: [PATCH] Remove the `eventBus` parameter from `getViewerConfiguration` This structure contains *almost* exclusively references to DOM elements (and a couple of simple strings), rather than complete classes/functions. Hence the `eventBus`-option sticks out a fair bit, and I'd guess that it's *mostly* unused in e.g. third-party implementations. Given that we, in multiple places, mention that the default viewer shouldn't be used as-is I really don't think that we need to keep this special `eventBus`-option around. Furthermore, nowadays it's also a lot easier to (safely) access the existing `EventBus`-instance in the viewer; see https://github.com/mozilla/pdf.js/wiki/Third-party-viewer-usage#initialization-promise which shows how to listen for the default viewer being initialized (and its `eventBus` thus being available). --- web/app.js | 11 +++-------- web/viewer.js | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/web/app.js b/web/app.js index 209ad0360..912880dee 100644 --- a/web/app.js +++ b/web/app.js @@ -463,14 +463,9 @@ const PDFViewerApplication = { async _initializeViewerComponents() { const { appConfig, externalServices } = this; - let eventBus; - if (appConfig.eventBus) { - eventBus = appConfig.eventBus; - } else if (externalServices.isInAutomation) { - eventBus = new AutomationEventBus(); - } else { - eventBus = new EventBus(); - } + const eventBus = externalServices.isInAutomation + ? new AutomationEventBus() + : new EventBus(); this.eventBus = eventBus; this.overlayManager = new OverlayManager(); diff --git a/web/viewer.js b/web/viewer.js index 53fe840ac..ef73a0a2a 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -77,7 +77,6 @@ function getViewerConfiguration() { appContainer: document.body, mainContainer: document.getElementById("viewerContainer"), viewerContainer: document.getElementById("viewer"), - eventBus: null, toolbar: { container: document.getElementById("toolbarViewer"), numPages: document.getElementById("numPages"),