mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Stop using the PRODUCTION
build-target in the JavaScript code
This *special* build-target is very old, and was introduced with the first pre-processor that only uses comments to enable/disable code. When the new pre-processor was added `PRODUCTION` effectively became redundant, at least in JavaScript code, since `typeof PDFJSDev === "undefined"` checks now do the same thing. This patch proposes that we remove `PRODUCTION` from the JavaScript code, since that simplifies the conditions and thus improves readability in many cases. *Please note:* There's not, nor has there ever been, any gulp-task that set `PRODUCTION = false` during building.
This commit is contained in:
parent
3e08eee511
commit
804aa896a7
29 changed files with 88 additions and 267 deletions
16
web/app.js
16
web/app.js
|
@ -310,7 +310,7 @@ const PDFViewerApplication = {
|
|||
params = parseQueryString(hash);
|
||||
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) &&
|
||||
typeof PDFJSDev === "undefined" &&
|
||||
params.get("workermodules") === "true"
|
||||
) {
|
||||
AppOptions.set("workerSrc", "../src/pdf.worker.js");
|
||||
|
@ -377,8 +377,7 @@ const PDFViewerApplication = {
|
|||
}
|
||||
// It is not possible to change locale for the (various) extension builds.
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||
params.has("locale")
|
||||
) {
|
||||
AppOptions.set("locale", params.get("locale"));
|
||||
|
@ -390,7 +389,7 @@ const PDFViewerApplication = {
|
|||
*/
|
||||
async _initializeL10n() {
|
||||
this.l10n = this.externalServices.createL10n(
|
||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
|
||||
? { locale: AppOptions.get("locale") }
|
||||
: null
|
||||
);
|
||||
|
@ -480,8 +479,7 @@ const PDFViewerApplication = {
|
|||
const pdfScriptingManager = new PDFScriptingManager({
|
||||
eventBus,
|
||||
sandboxBundleSrc:
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC || CHROME")
|
||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC || CHROME")
|
||||
? AppOptions.get("sandboxBundleSrc")
|
||||
: null,
|
||||
scriptingFactory: externalServices,
|
||||
|
@ -959,7 +957,7 @@ const PDFViewerApplication = {
|
|||
...args,
|
||||
};
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||
if (typeof PDFJSDev === "undefined") {
|
||||
params.docBaseUrl ||= document.URL.split("#")[0];
|
||||
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
|
||||
params.docBaseUrl ||= this.baseUrl;
|
||||
|
@ -2159,7 +2157,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||
async function loadFakeWorker() {
|
||||
GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc");
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||
if (typeof PDFJSDev === "undefined") {
|
||||
window.pdfjsWorker = await import("pdfjs/pdf.worker.js");
|
||||
return;
|
||||
}
|
||||
|
@ -2169,7 +2167,7 @@ async function loadFakeWorker() {
|
|||
async function loadPDFBug(self) {
|
||||
const { debuggerScriptPath } = self.appConfig;
|
||||
const { PDFBug } =
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
typeof PDFJSDev === "undefined"
|
||||
? await import(debuggerScriptPath) // eslint-disable-line no-unsanitized/method
|
||||
: await __non_webpack_import__(debuggerScriptPath); // eslint-disable-line no-undef
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue