diff --git a/web/viewer.js b/web/viewer.js index 15ef9ca0e..d447c962a 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -13,7 +13,8 @@ * limitations under the License. */ -"use strict"; +import { AppOptions } from "./app_options.js"; +import { PDFViewerApplication } from "./app.js"; /* eslint-disable-next-line no-unused-vars */ const pdfjsVersion = @@ -22,6 +23,9 @@ const pdfjsVersion = const pdfjsBuild = typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0; +window.PDFViewerApplication = PDFViewerApplication; +window.PDFViewerApplicationOptions = AppOptions; + if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) { 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")) { require("./firefoxcom.js"); require("./firefox_print_service.js"); @@ -198,23 +196,16 @@ function webViewerLoad() { const config = getViewerConfiguration(); if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { Promise.all([ - import("pdfjs-web/app.js"), - import("pdfjs-web/app_options.js"), import("pdfjs-web/genericcom.js"), import("pdfjs-web/pdf_print_service.js"), - ]).then(function ([app, appOptions, genericCom, pdfPrintService]) { - window.PDFViewerApplication = app.PDFViewerApplication; - window.PDFViewerApplicationOptions = appOptions.AppOptions; - app.PDFViewerApplication.run(config); + ]).then(function ([genericCom, pdfPrintService]) { + PDFViewerApplication.run(config); }); } else { 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")) { // Give custom implementations of the default viewer a simpler way to // 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 { document.addEventListener("DOMContentLoaded", webViewerLoad, true); } + +export { PDFViewerApplication, AppOptions as PDFViewerApplicationOptions };