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:
Jonas Jenwald 2023-03-18 12:09:25 +01:00
parent 3e08eee511
commit 804aa896a7
29 changed files with 88 additions and 267 deletions

View file

@ -165,10 +165,7 @@ class PDFPageView {
this.renderTask = null;
this.resume = null;
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this._isStandalone = !this.renderingQueue?.hasViewer();
}
@ -194,8 +191,7 @@ class PDFPageView {
container?.append(div);
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this._isStandalone
) {
// Ensure that the various layers always get the correct initial size,
@ -548,8 +544,7 @@ class PDFPageView {
this.#setDimensions();
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this._isStandalone
) {
this.div.parentNode?.style.setProperty(
@ -686,8 +681,7 @@ class PDFPageView {
}) {
// Scale target (canvas), its wrapper and page container.
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")) &&
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
!(target instanceof HTMLCanvasElement)
) {
throw new Error("Expected `target` to be a canvas.");