Use standard import
statements when loading PDFViewerApplication
/AppOptions
in web/viewer
Given that we're no longer using SystemJS to load the `web/` files, see PR 11919, there's nothing that prevents us from using standard `ìmport` statements in this file. Obviously it's still necessary to load part of the code conditionally on the build type, however this still allows us to clean-up and simplify at least some of this file.
This commit is contained in:
parent
666dd73ce8
commit
e7437a0b67
@ -13,7 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
"use strict";
|
import { AppOptions } from "./app_options.js";
|
||||||
|
import { PDFViewerApplication } from "./app.js";
|
||||||
|
|
||||||
/* eslint-disable-next-line no-unused-vars */
|
/* eslint-disable-next-line no-unused-vars */
|
||||||
const pdfjsVersion =
|
const pdfjsVersion =
|
||||||
@ -22,6 +23,9 @@ const pdfjsVersion =
|
|||||||
const pdfjsBuild =
|
const pdfjsBuild =
|
||||||
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
|
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
|
||||||
|
|
||||||
|
window.PDFViewerApplication = PDFViewerApplication;
|
||||||
|
window.PDFViewerApplicationOptions = AppOptions;
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||||
var defaultUrl; // eslint-disable-line no-var
|
var defaultUrl; // eslint-disable-line no-var
|
||||||
|
|
||||||
@ -42,12 +46,6 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
let pdfjsWebApp, pdfjsWebAppOptions;
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("PRODUCTION")) {
|
|
||||||
pdfjsWebApp = require("./app.js");
|
|
||||||
pdfjsWebAppOptions = require("./app_options.js");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
require("./firefoxcom.js");
|
require("./firefoxcom.js");
|
||||||
require("./firefox_print_service.js");
|
require("./firefox_print_service.js");
|
||||||
@ -198,23 +196,16 @@ function webViewerLoad() {
|
|||||||
const config = getViewerConfiguration();
|
const config = getViewerConfiguration();
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
import("pdfjs-web/app.js"),
|
|
||||||
import("pdfjs-web/app_options.js"),
|
|
||||||
import("pdfjs-web/genericcom.js"),
|
import("pdfjs-web/genericcom.js"),
|
||||||
import("pdfjs-web/pdf_print_service.js"),
|
import("pdfjs-web/pdf_print_service.js"),
|
||||||
]).then(function ([app, appOptions, genericCom, pdfPrintService]) {
|
]).then(function ([genericCom, pdfPrintService]) {
|
||||||
window.PDFViewerApplication = app.PDFViewerApplication;
|
PDFViewerApplication.run(config);
|
||||||
window.PDFViewerApplicationOptions = appOptions.AppOptions;
|
|
||||||
app.PDFViewerApplication.run(config);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||||
pdfjsWebAppOptions.AppOptions.set("defaultUrl", defaultUrl);
|
AppOptions.set("defaultUrl", defaultUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
|
|
||||||
window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
|
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
|
||||||
// Give custom implementations of the default viewer a simpler way to
|
// Give custom implementations of the default viewer a simpler way to
|
||||||
// set various `AppOptions`, by dispatching an event once all viewer
|
// set various `AppOptions`, by dispatching an event once all viewer
|
||||||
@ -236,7 +227,7 @@ function webViewerLoad() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pdfjsWebApp.PDFViewerApplication.run(config);
|
PDFViewerApplication.run(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,3 +239,5 @@ if (
|
|||||||
} else {
|
} else {
|
||||||
document.addEventListener("DOMContentLoaded", webViewerLoad, true);
|
document.addEventListener("DOMContentLoaded", webViewerLoad, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { PDFViewerApplication, AppOptions as PDFViewerApplicationOptions };
|
||||||
|
Loading…
Reference in New Issue
Block a user