Refactor the DownloadManager initialization in GENERIC/CHROME builds again (PR 8203 follow-up)

In the first commit in PR 8203, I changed how the `DownloadManager` was included/initialized in `GENERIC`/`CHROME` builds.
The change was prompted by the fact that you cannot have conditional `import`s with ES6 modules, and I wanted to avoid bundling the general `DownloadManager` into the various Firefox specific build targets.

What I completely missed though, is that the new code meant that `download_manager.js` will now be pulling in the *entire* viewer (through `app.js`).
This is a *really* stupid mistake on my part, since it causes the `dist/build/pdf_viewer.js` used with the viewer components to now include basically the entire default viewer.

The simplest solution that I could come up with, is to add a `genericcom.js` file (similar to the `firefoxcom.js`/`chromecom.js` files) which will be responsible for importing/initializing the `DownloadManager`.
This commit is contained in:
Jonas Jenwald 2017-04-17 01:55:45 +02:00
parent bd0e4dc4e3
commit 594e8c05ef
4 changed files with 47 additions and 15 deletions

View file

@ -45,12 +45,14 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
window.FirefoxCom = require('./firefoxcom.js').FirefoxCom;
require('./firefox_print_service.js');
}
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
require('./genericcom.js');
}
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
require('./chromecom.js');
}
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME || GENERIC')) {
require('./pdf_print_service.js');
require('./download_manager.js');
}
function getViewerConfiguration() {
@ -172,10 +174,11 @@ function getViewerConfiguration() {
function webViewerLoad() {
var config = getViewerConfiguration();
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
Promise.all([SystemJS.import('pdfjs-web/app'),
SystemJS.import('pdfjs-web/pdf_print_service'),
SystemJS.import('pdfjs-web/download_manager')])
.then(function (modules) {
Promise.all([
SystemJS.import('pdfjs-web/app'),
SystemJS.import('pdfjs-web/genericcom'),
SystemJS.import('pdfjs-web/pdf_print_service'),
]).then(function (modules) {
var app = modules[0];
window.PDFViewerApplication = app.PDFViewerApplication;
app.PDFViewerApplication.run(config);