Merge pull request #16305 from Snuffleupagus/PDFJSDev-skip-PRODUCTION

Remove the `PRODUCTION` build-target
This commit is contained in:
Tim van der Meij 2023-04-22 14:53:30 +02:00 committed by GitHub
commit c9359957e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 89 additions and 269 deletions

View File

@ -96,7 +96,6 @@ const AUTOPREFIXER_CONFIG = {
const BABEL_TARGETS = ENV_TARGETS.join(", "); const BABEL_TARGETS = ENV_TARGETS.join(", ");
const DEFINES = Object.freeze({ const DEFINES = Object.freeze({
PRODUCTION: true,
SKIP_BABEL: true, SKIP_BABEL: true,
TESTING: undefined, TESTING: undefined,
// The main build targets: // The main build targets:

View File

@ -797,10 +797,7 @@ class Annotation {
* @param {Dict} borderStyle - The border style dictionary * @param {Dict} borderStyle - The border style dictionary
*/ */
setBorderStyle(borderStyle) { setBorderStyle(borderStyle) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert(this.rectangle, "setRectangle must have been called previously."); assert(this.rectangle, "setRectangle must have been called previously.");
} }
@ -1062,8 +1059,7 @@ class Annotation {
*/ */
reset() { reset() {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
this.appearance && this.appearance &&
!this._streams.includes(this.appearance) !this._streams.includes(this.appearance)
) { ) {
@ -1161,10 +1157,7 @@ class AnnotationBorderStyle {
* @param {Array} rect - The annotation `Rect` entry. * @param {Array} rect - The annotation `Rect` entry.
*/ */
setWidth(width, rect = [0, 0, 0, 0]) { setWidth(width, rect = [0, 0, 0, 0]) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
Array.isArray(rect) && rect.length === 4, Array.isArray(rect) && rect.length === 4,
"A valid `rect` parameter must be provided." "A valid `rect` parameter must be provided."
@ -2381,10 +2374,7 @@ class WidgetAnnotation extends Annotation {
* @private * @private
*/ */
_getSaveFieldResources(xref) { _getSaveFieldResources(xref) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
this.data.defaultAppearanceData, this.data.defaultAppearanceData,
"Expected `_defaultAppearanceData` to have been set." "Expected `_defaultAppearanceData` to have been set."

View File

@ -295,10 +295,7 @@ class ChunkedStreamManager {
resolve(chunkData); resolve(chunkData);
return; return;
} }
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
value instanceof ArrayBuffer, value instanceof ArrayBuffer,
"readChunk (sendRequest) - expected an ArrayBuffer." "readChunk (sendRequest) - expected an ArrayBuffer."

View File

@ -140,10 +140,7 @@ class ColorSpace {
comps, comps,
alpha01 alpha01
) { ) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'ColorSpace.fillRgb: Unsupported "dest" type.' 'ColorSpace.fillRgb: Unsupported "dest" type.'
@ -326,10 +323,7 @@ class ColorSpace {
pdfFunctionFactory, pdfFunctionFactory,
localColorSpaceCache, localColorSpaceCache,
}) { }) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
!this.getCached(cs, xref, localColorSpaceCache), !this.getCached(cs, xref, localColorSpaceCache),
"Expected `ColorSpace.getCached` to have been manually checked " + "Expected `ColorSpace.getCached` to have been manually checked " +
@ -551,10 +545,7 @@ class AlternateCS extends ColorSpace {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'AlternateCS.getRgbItem: Unsupported "dest" type.' 'AlternateCS.getRgbItem: Unsupported "dest" type.'
@ -566,10 +557,7 @@ class AlternateCS extends ColorSpace {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'AlternateCS.getRgbBuffer: Unsupported "dest" type.' 'AlternateCS.getRgbBuffer: Unsupported "dest" type.'
@ -656,10 +644,7 @@ class IndexedCS extends ColorSpace {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'IndexedCS.getRgbItem: Unsupported "dest" type.' 'IndexedCS.getRgbItem: Unsupported "dest" type.'
@ -671,10 +656,7 @@ class IndexedCS extends ColorSpace {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'IndexedCS.getRgbBuffer: Unsupported "dest" type.' 'IndexedCS.getRgbBuffer: Unsupported "dest" type.'
@ -721,10 +703,7 @@ class DeviceGrayCS extends ColorSpace {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'DeviceGrayCS.getRgbItem: Unsupported "dest" type.' 'DeviceGrayCS.getRgbItem: Unsupported "dest" type.'
@ -735,10 +714,7 @@ class DeviceGrayCS extends ColorSpace {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'DeviceGrayCS.getRgbBuffer: Unsupported "dest" type.' 'DeviceGrayCS.getRgbBuffer: Unsupported "dest" type.'
@ -770,10 +746,7 @@ class DeviceRgbCS extends ColorSpace {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'DeviceRgbCS.getRgbItem: Unsupported "dest" type.' 'DeviceRgbCS.getRgbItem: Unsupported "dest" type.'
@ -785,10 +758,7 @@ class DeviceRgbCS extends ColorSpace {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'DeviceRgbCS.getRgbBuffer: Unsupported "dest" type.' 'DeviceRgbCS.getRgbBuffer: Unsupported "dest" type.'
@ -894,10 +864,7 @@ const DeviceCmykCS = (function DeviceCmykCSClosure() {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'DeviceCmykCS.getRgbItem: Unsupported "dest" type.' 'DeviceCmykCS.getRgbItem: Unsupported "dest" type.'
@ -907,10 +874,7 @@ const DeviceCmykCS = (function DeviceCmykCSClosure() {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'DeviceCmykCS.getRgbBuffer: Unsupported "dest" type.' 'DeviceCmykCS.getRgbBuffer: Unsupported "dest" type.'
@ -1008,10 +972,7 @@ const CalGrayCS = (function CalGrayCSClosure() {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'CalGrayCS.getRgbItem: Unsupported "dest" type.' 'CalGrayCS.getRgbItem: Unsupported "dest" type.'
@ -1021,10 +982,7 @@ const CalGrayCS = (function CalGrayCSClosure() {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'CalGrayCS.getRgbBuffer: Unsupported "dest" type.' 'CalGrayCS.getRgbBuffer: Unsupported "dest" type.'
@ -1317,10 +1275,7 @@ const CalRGBCS = (function CalRGBCSClosure() {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'CalRGBCS.getRgbItem: Unsupported "dest" type.' 'CalRGBCS.getRgbItem: Unsupported "dest" type.'
@ -1330,10 +1285,7 @@ const CalRGBCS = (function CalRGBCSClosure() {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'CalRGBCS.getRgbBuffer: Unsupported "dest" type.' 'CalRGBCS.getRgbBuffer: Unsupported "dest" type.'
@ -1484,10 +1436,7 @@ const LabCS = (function LabCSClosure() {
} }
getRgbItem(src, srcOffset, dest, destOffset) { getRgbItem(src, srcOffset, dest, destOffset) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'LabCS.getRgbItem: Unsupported "dest" type.' 'LabCS.getRgbItem: Unsupported "dest" type.'
@ -1497,10 +1446,7 @@ const LabCS = (function LabCSClosure() {
} }
getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) { getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
dest instanceof Uint8ClampedArray, dest instanceof Uint8ClampedArray,
'LabCS.getRgbBuffer: Unsupported "dest" type.' 'LabCS.getRgbBuffer: Unsupported "dest" type.'

View File

@ -86,10 +86,7 @@ class XRefParseException extends BaseException {
* @returns {Uint8Array} * @returns {Uint8Array}
*/ */
function arrayBuffersToBytes(arr) { function arrayBuffersToBytes(arr) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
for (const item of arr) { for (const item of arr) {
assert( assert(
item instanceof ArrayBuffer, item instanceof ArrayBuffer,

View File

@ -705,10 +705,7 @@ const EMPTY_FINGERPRINT =
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
function find(stream, signature, limit = 1024, backwards = false) { function find(stream, signature, limit = 1024, backwards = false) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert(limit > 0, 'The "limit" must be a positive integer.'); assert(limit > 0, 'The "limit" must be a positive integer.');
} }
const signatureLength = signature.length; const signatureLength = signature.length;
@ -762,10 +759,7 @@ function find(stream, signature, limit = 1024, backwards = false) {
*/ */
class PDFDocument { class PDFDocument {
constructor(pdfManager, stream) { constructor(pdfManager, stream) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
stream instanceof BaseStream, stream instanceof BaseStream,
'PDFDocument: Invalid "stream" argument.' 'PDFDocument: Invalid "stream" argument.'
@ -1426,10 +1420,7 @@ class PDFDocument {
async _getLinearizationPage(pageIndex) { async _getLinearizationPage(pageIndex) {
const { catalog, linearization, xref } = this; const { catalog, linearization, xref } = this;
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
linearization && linearization.pageFirst === pageIndex, linearization && linearization.pageFirst === pageIndex,
"_getLinearizationPage - invalid pageIndex argument." "_getLinearizationPage - invalid pageIndex argument."

View File

@ -4529,10 +4529,7 @@ class TranslatedFont {
* @private * @private
*/ */
_removeType3ColorOperators(operatorList, fontBBoxSize = NaN) { _removeType3ColorOperators(operatorList, fontBBoxSize = NaN) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
operatorList.fnArray[0] === OPS.setCharWidthAndBounds, operatorList.fnArray[0] === OPS.setCharWidthAndBounds,
"Type3 glyph shall start with the d1 operator." "Type3 glyph shall start with the d1 operator."

View File

@ -296,10 +296,7 @@ function int32(b0, b1, b2, b3) {
} }
function string16(value) { function string16(value) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
typeof value === "number" && Math.abs(value) < 2 ** 16, typeof value === "number" && Math.abs(value) < 2 ** 16,
`string16: Unexpected input "${value}".` `string16: Unexpected input "${value}".`
@ -309,10 +306,7 @@ function string16(value) {
} }
function safeString16(value) { function safeString16(value) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
typeof value === "number" && !Number.isNaN(value), typeof value === "number" && !Number.isNaN(value),
`safeString16: Unexpected input "${value}".` `safeString16: Unexpected input "${value}".`

View File

@ -564,10 +564,7 @@ class PDFImage {
} }
fillOpacity(rgbaBuf, width, height, actualHeight, image) { fillOpacity(rgbaBuf, width, height, actualHeight, image) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
rgbaBuf instanceof Uint8ClampedArray, rgbaBuf instanceof Uint8ClampedArray,
'PDFImage.fillOpacity: Unsupported "rgbaBuf" type.' 'PDFImage.fillOpacity: Unsupported "rgbaBuf" type.'
@ -637,10 +634,7 @@ class PDFImage {
} }
undoPreblend(buffer, width, height) { undoPreblend(buffer, width, height) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
buffer instanceof Uint8ClampedArray, buffer instanceof Uint8ClampedArray,
'PDFImage.undoPreblend: Unsupported "buffer" type.' 'PDFImage.undoPreblend: Unsupported "buffer" type.'
@ -893,10 +887,7 @@ class PDFImage {
} }
fillGrayBuffer(buffer) { fillGrayBuffer(buffer) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
buffer instanceof Uint8ClampedArray, buffer instanceof Uint8ClampedArray,
'PDFImage.fillGrayBuffer: Unsupported "buffer" type.' 'PDFImage.fillGrayBuffer: Unsupported "buffer" type.'

View File

@ -186,10 +186,7 @@ class GlobalImageCache {
} }
constructor() { constructor() {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
GlobalImageCache.NUM_PAGES_THRESHOLD > 1, GlobalImageCache.NUM_PAGES_THRESHOLD > 1,
"GlobalImageCache - invalid NUM_PAGES_THRESHOLD constant." "GlobalImageCache - invalid NUM_PAGES_THRESHOLD constant."

View File

@ -1528,10 +1528,7 @@ class JpegImage {
forceRGB = false, forceRGB = false,
isSourcePDF = false, isSourcePDF = false,
}) { }) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
isSourcePDF === true, isSourcePDF === true,
'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.' 'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.'

View File

@ -202,10 +202,7 @@ class Parser {
} else if (state === 1) { } else if (state === 1) {
state = ch === I ? 2 : 0; state = ch === I ? 2 : 0;
} else { } else {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert(state === 2, "findDefaultInlineStreamEnd - invalid state."); assert(state === 2, "findDefaultInlineStreamEnd - invalid state.");
} }
if (ch === SPACE || ch === LF || ch === CR) { if (ch === SPACE || ch === LF || ch === CR) {

View File

@ -25,8 +25,7 @@ const Name = (function NameClosure() {
class Name { class Name {
constructor(name) { constructor(name) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
typeof name !== "string" typeof name !== "string"
) { ) {
unreachable('Name: The "name" must be a string.'); unreachable('Name: The "name" must be a string.');
@ -54,8 +53,7 @@ const Cmd = (function CmdClosure() {
class Cmd { class Cmd {
constructor(cmd) { constructor(cmd) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
typeof cmd !== "string" typeof cmd !== "string"
) { ) {
unreachable('Cmd: The "cmd" must be a string.'); unreachable('Cmd: The "cmd" must be a string.');
@ -103,8 +101,7 @@ class Dict {
let value = this._map[key1]; let value = this._map[key1];
if (value === undefined && key2 !== undefined) { if (value === undefined && key2 !== undefined) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
key2.length < key1.length key2.length < key1.length
) { ) {
unreachable("Dict.get: Expected keys to be ordered by length."); unreachable("Dict.get: Expected keys to be ordered by length.");
@ -112,8 +109,7 @@ class Dict {
value = this._map[key2]; value = this._map[key2];
if (value === undefined && key3 !== undefined) { if (value === undefined && key3 !== undefined) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
key3.length < key2.length key3.length < key2.length
) { ) {
unreachable("Dict.get: Expected keys to be ordered by length."); unreachable("Dict.get: Expected keys to be ordered by length.");
@ -132,8 +128,7 @@ class Dict {
let value = this._map[key1]; let value = this._map[key1];
if (value === undefined && key2 !== undefined) { if (value === undefined && key2 !== undefined) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
key2.length < key1.length key2.length < key1.length
) { ) {
unreachable("Dict.getAsync: Expected keys to be ordered by length."); unreachable("Dict.getAsync: Expected keys to be ordered by length.");
@ -141,8 +136,7 @@ class Dict {
value = this._map[key2]; value = this._map[key2];
if (value === undefined && key3 !== undefined) { if (value === undefined && key3 !== undefined) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
key3.length < key2.length key3.length < key2.length
) { ) {
unreachable("Dict.getAsync: Expected keys to be ordered by length."); unreachable("Dict.getAsync: Expected keys to be ordered by length.");
@ -161,8 +155,7 @@ class Dict {
let value = this._map[key1]; let value = this._map[key1];
if (value === undefined && key2 !== undefined) { if (value === undefined && key2 !== undefined) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
key2.length < key1.length key2.length < key1.length
) { ) {
unreachable("Dict.getArray: Expected keys to be ordered by length."); unreachable("Dict.getArray: Expected keys to be ordered by length.");
@ -170,8 +163,7 @@ class Dict {
value = this._map[key2]; value = this._map[key2];
if (value === undefined && key3 !== undefined) { if (value === undefined && key3 !== undefined) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
key3.length < key2.length key3.length < key2.length
) { ) {
unreachable("Dict.getArray: Expected keys to be ordered by length."); unreachable("Dict.getArray: Expected keys to be ordered by length.");
@ -209,10 +201,7 @@ class Dict {
} }
set(key, value) { set(key, value) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof key !== "string") { if (typeof key !== "string") {
unreachable('Dict.set: The "key" must be a string.'); unreachable('Dict.set: The "key" must be a string.');
} else if (value === undefined) { } else if (value === undefined) {
@ -325,8 +314,7 @@ const Ref = (function RefClosure() {
class RefSet { class RefSet {
constructor(parent = null) { constructor(parent = null) {
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
PDFJSDev.test("!PRODUCTION || TESTING")) &&
parent && parent &&
!(parent instanceof RefSet) !(parent instanceof RefSet)
) { ) {
@ -405,10 +393,7 @@ function isDict(v, type) {
} }
function isRefsEqual(v1, v2) { function isRefsEqual(v1, v2) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
v1 instanceof Ref && v2 instanceof Ref, v1 instanceof Ref && v2 instanceof Ref,
"isRefsEqual: Both parameters should be `Ref`s." "isRefsEqual: Both parameters should be `Ref`s."

View File

@ -309,10 +309,7 @@ class WorkerMessageHandler {
cancelXHRs = null; cancelXHRs = null;
return; return;
} }
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
value instanceof ArrayBuffer, value instanceof ArrayBuffer,
"readChunk (getPdfManager) - expected an ArrayBuffer." "readChunk (getPdfManager) - expected an ArrayBuffer."

View File

@ -873,10 +873,7 @@ class XRef {
xrefEntry = parser.getObj(); xrefEntry = parser.getObj();
} }
if (!(xrefEntry instanceof BaseStream)) { if (!(xrefEntry instanceof BaseStream)) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
xrefEntry !== undefined, xrefEntry !== undefined,
'fetchUncompressed: The "xrefEntry" cannot be undefined.' 'fetchUncompressed: The "xrefEntry" cannot be undefined.'
@ -947,10 +944,7 @@ class XRef {
const num = nums[i], const num = nums[i],
entry = this.entries[num]; entry = this.entries[num];
if (entry && entry.offset === tableOffset && entry.gen === i) { if (entry && entry.offset === tableOffset && entry.gen === i) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
obj !== undefined, obj !== undefined,
'fetchCompressed: The "obj" cannot be undefined.' 'fetchCompressed: The "obj" cannot be undefined.'

View File

@ -489,10 +489,7 @@ class AnnotationElement {
* @returns {Array<HTMLElement>} An array of section elements. * @returns {Array<HTMLElement>} An array of section elements.
*/ */
_renderQuadrilaterals(className) { _renderQuadrilaterals(className) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert(this.quadrilaterals, "Missing quadrilaterals during rendering"); assert(this.quadrilaterals, "Missing quadrilaterals during rendering");
} }

View File

@ -89,7 +89,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC") && isNodeJS) {
} }
let createPDFNetworkStream; let createPDFNetworkStream;
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined") {
const streamsPromise = Promise.all([ const streamsPromise = Promise.all([
import("./network.js"), import("./network.js"),
import("./fetch_stream.js"), import("./fetch_stream.js"),
@ -1799,10 +1799,7 @@ class PDFPageProxy {
* @private * @private
*/ */
_pumpOperatorList({ renderingIntent, cacheKey, annotationStorageMap }) { _pumpOperatorList({ renderingIntent, cacheKey, annotationStorageMap }) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
Number.isInteger(renderingIntent) && renderingIntent > 0, Number.isInteger(renderingIntent) && renderingIntent > 0,
'_pumpOperatorList: Expected valid "renderingIntent" argument.' '_pumpOperatorList: Expected valid "renderingIntent" argument.'
@ -1869,10 +1866,7 @@ class PDFPageProxy {
* @private * @private
*/ */
_abortOperatorList({ intentState, reason, force = false }) { _abortOperatorList({ intentState, reason, force = false }) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
reason instanceof Error, reason instanceof Error,
'_abortOperatorList: Expected valid "reason" argument.' '_abortOperatorList: Expected valid "reason" argument.'
@ -2139,7 +2133,7 @@ class PDFWorker {
// Some versions of FF can't create a worker on localhost, see: // Some versions of FF can't create a worker on localhost, see:
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280 // https://bugzilla.mozilla.org/show_bug.cgi?id=683280
const worker = const worker =
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) && typeof PDFJSDev === "undefined" &&
!workerSrc.endsWith("/build/pdf.worker.js") && !workerSrc.endsWith("/build/pdf.worker.js") &&
!workerSrc.endsWith("/src/worker_loader.js") !workerSrc.endsWith("/src/worker_loader.js")
? new Worker(workerSrc, { type: "module" }) ? new Worker(workerSrc, { type: "module" })
@ -2330,7 +2324,7 @@ class PDFWorker {
// The worker was already loaded using e.g. a `<script>` tag. // The worker was already loaded using e.g. a `<script>` tag.
return mainWorkerMessageHandler; return mainWorkerMessageHandler;
} }
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined") {
const worker = await import("pdfjs/pdf.worker.js"); const worker = await import("pdfjs/pdf.worker.js");
return worker.WorkerMessageHandler; return worker.WorkerMessageHandler;
} }

View File

@ -85,10 +85,7 @@ class FreeTextEditor extends AnnotationEditor {
const style = getComputedStyle(document.documentElement); const style = getComputedStyle(document.documentElement);
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
const lineHeight = parseFloat( const lineHeight = parseFloat(
style.getPropertyValue("--freetext-line-height") style.getPropertyValue("--freetext-line-height")
); );

View File

@ -32,7 +32,7 @@ class FontLoader {
this.nativeFontFaces = []; this.nativeFontFaces = [];
this.styleElement = this.styleElement =
typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || TESTING") typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")
? styleElement ? styleElement
: null; : null;
@ -116,10 +116,7 @@ class FontLoader {
get isFontLoadingAPISupported() { get isFontLoadingAPISupported() {
const hasFonts = !!this._document?.fonts; const hasFonts = !!this._document?.fonts;
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
return shadow( return shadow(
this, this,
"isFontLoadingAPISupported", "isFontLoadingAPISupported",

View File

@ -27,10 +27,7 @@ function validateRangeRequestCapabilities({
rangeChunkSize, rangeChunkSize,
disableRange, disableRange,
}) { }) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
Number.isInteger(rangeChunkSize) && rangeChunkSize > 0, Number.isInteger(rangeChunkSize) && rangeChunkSize > 0,
"rangeChunkSize must be an integer larger than zero." "rangeChunkSize must be an integer larger than zero."

View File

@ -34,10 +34,7 @@ let SVGGraphics = class {
} }
}; };
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
const SVG_DEFAULTS = { const SVG_DEFAULTS = {
fontStyle: "normal", fontStyle: "normal",
fontWeight: "normal", fontWeight: "normal",

View File

@ -55,12 +55,12 @@ class Sandbox {
} }
create(data) { create(data) {
if (PDFJSDev.test("!PRODUCTION || TESTING")) { if (PDFJSDev.test("TESTING")) {
this._module.ccall("nukeSandbox", null, []); this._module.ccall("nukeSandbox", null, []);
} }
const code = [PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE")]; const code = [PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE")];
if (PDFJSDev.test("!PRODUCTION || TESTING")) { if (PDFJSDev.test("TESTING")) {
code.push( code.push(
`globalThis.sendResultForTesting = callExternalFunction.bind(null, "send");` `globalThis.sendResultForTesting = callExternalFunction.bind(null, "send");`
); );
@ -122,7 +122,7 @@ class Sandbox {
} }
evalForTesting(code, key) { evalForTesting(code, key) {
if (PDFJSDev.test("!PRODUCTION || TESTING")) { if (PDFJSDev.test("TESTING")) {
this._module.ccall( this._module.ccall(
"evalInSandbox", "evalInSandbox",
null, null,

View File

@ -149,10 +149,7 @@ class MessageHandler {
} }
on(actionName, handler) { on(actionName, handler) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
typeof handler === "function", typeof handler === "function",
'MessageHandler.on: Expected "handler" to be a function.' 'MessageHandler.on: Expected "handler" to be a function.'

View File

@ -452,10 +452,7 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
} }
function shadow(obj, prop, value, nonSerializable = false) { function shadow(obj, prop, value, nonSerializable = false) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
prop in obj, prop in obj,
`shadow: Property "${prop && prop.toString()}" not found in object.` `shadow: Property "${prop && prop.toString()}" not found in object.`
@ -574,10 +571,7 @@ function stringToBytes(str) {
} }
function string32(value) { function string32(value) {
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert( assert(
typeof value === "number" && Math.abs(value) < 2 ** 32, typeof value === "number" && Math.abs(value) < 2 ** 32,
`string32: Unexpected input "${value}".` `string32: Unexpected input "${value}".`

View File

@ -310,7 +310,7 @@ const PDFViewerApplication = {
params = parseQueryString(hash); params = parseQueryString(hash);
if ( if (
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) && typeof PDFJSDev === "undefined" &&
params.get("workermodules") === "true" params.get("workermodules") === "true"
) { ) {
AppOptions.set("workerSrc", "../src/pdf.worker.js"); 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. // It is not possible to change locale for the (various) extension builds.
if ( if (
(typeof PDFJSDev === "undefined" || (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
params.has("locale") params.has("locale")
) { ) {
AppOptions.set("locale", params.get("locale")); AppOptions.set("locale", params.get("locale"));
@ -390,7 +389,7 @@ const PDFViewerApplication = {
*/ */
async _initializeL10n() { async _initializeL10n() {
this.l10n = this.externalServices.createL10n( this.l10n = this.externalServices.createL10n(
typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || GENERIC") typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? { locale: AppOptions.get("locale") } ? { locale: AppOptions.get("locale") }
: null : null
); );
@ -480,8 +479,7 @@ const PDFViewerApplication = {
const pdfScriptingManager = new PDFScriptingManager({ const pdfScriptingManager = new PDFScriptingManager({
eventBus, eventBus,
sandboxBundleSrc: sandboxBundleSrc:
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC || CHROME")
PDFJSDev.test("!PRODUCTION || GENERIC || CHROME")
? AppOptions.get("sandboxBundleSrc") ? AppOptions.get("sandboxBundleSrc")
: null, : null,
scriptingFactory: externalServices, scriptingFactory: externalServices,
@ -959,7 +957,7 @@ const PDFViewerApplication = {
...args, ...args,
}; };
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined") {
params.docBaseUrl ||= document.URL.split("#")[0]; params.docBaseUrl ||= document.URL.split("#")[0];
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) { } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
params.docBaseUrl ||= this.baseUrl; params.docBaseUrl ||= this.baseUrl;
@ -2159,7 +2157,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
async function loadFakeWorker() { async function loadFakeWorker() {
GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc"); GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc");
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined") {
window.pdfjsWorker = await import("pdfjs/pdf.worker.js"); window.pdfjsWorker = await import("pdfjs/pdf.worker.js");
return; return;
} }
@ -2169,7 +2167,7 @@ async function loadFakeWorker() {
async function loadPDFBug(self) { async function loadPDFBug(self) {
const { debuggerScriptPath } = self.appConfig; const { debuggerScriptPath } = self.appConfig;
const { PDFBug } = const { PDFBug } =
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") typeof PDFJSDev === "undefined"
? await import(debuggerScriptPath) // eslint-disable-line no-unsanitized/method ? await import(debuggerScriptPath) // eslint-disable-line no-unsanitized/method
: await __non_webpack_import__(debuggerScriptPath); // eslint-disable-line no-undef : await __non_webpack_import__(debuggerScriptPath); // eslint-disable-line no-undef

View File

@ -158,7 +158,7 @@ const defaultOptions = {
}, },
pdfBugEnabled: { pdfBugEnabled: {
/** @type {boolean} */ /** @type {boolean} */
value: typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION"), value: typeof PDFJSDev === "undefined",
kind: OptionKind.VIEWER + OptionKind.PREFERENCE, kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
}, },
printResolution: { printResolution: {
@ -210,9 +210,7 @@ const defaultOptions = {
cMapUrl: { cMapUrl: {
/** @type {string} */ /** @type {string} */
value: value:
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") typeof PDFJSDev === "undefined" ? "../external/bcmaps/" : "../web/cmaps/",
? "../external/bcmaps/"
: "../web/cmaps/",
kind: OptionKind.API, kind: OptionKind.API,
}, },
disableAutoFetch: { disableAutoFetch: {
@ -273,7 +271,7 @@ const defaultOptions = {
standardFontDataUrl: { standardFontDataUrl: {
/** @type {string} */ /** @type {string} */
value: value:
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") typeof PDFJSDev === "undefined"
? "../external/standard_fonts/" ? "../external/standard_fonts/"
: "../web/standard_fonts/", : "../web/standard_fonts/",
kind: OptionKind.API, kind: OptionKind.API,
@ -293,7 +291,7 @@ const defaultOptions = {
/** @type {string} */ /** @type {string} */
value: value:
// eslint-disable-next-line no-nested-ternary // eslint-disable-next-line no-nested-ternary
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") typeof PDFJSDev === "undefined"
? "../src/worker_loader.js" ? "../src/worker_loader.js"
: PDFJSDev.test("MOZCENTRAL") : PDFJSDev.test("MOZCENTRAL")
? "resource://pdf.js/build/pdf.worker.js" ? "resource://pdf.js/build/pdf.worker.js"
@ -301,10 +299,7 @@ const defaultOptions = {
kind: OptionKind.WORKER, kind: OptionKind.WORKER,
}, },
}; };
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
defaultOptions.defaultUrl = { defaultOptions.defaultUrl = {
/** @type {string} */ /** @type {string} */
value: "compressed.tracemonkey-pldi-09.pdf", value: "compressed.tracemonkey-pldi-09.pdf",
@ -323,7 +318,7 @@ if (
defaultOptions.sandboxBundleSrc = { defaultOptions.sandboxBundleSrc = {
/** @type {string} */ /** @type {string} */
value: value:
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") typeof PDFJSDev === "undefined"
? "../build/dev-sandbox/pdf.sandbox.js" ? "../build/dev-sandbox/pdf.sandbox.js"
: "../build/pdf.sandbox.js", : "../build/pdf.sandbox.js",
kind: OptionKind.VIEWER, kind: OptionKind.VIEWER,

View File

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

View File

@ -240,10 +240,7 @@ class PDFViewer {
this.container = options.container; this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild; this.viewer = options.viewer || options.container.firstElementChild;
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") { if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
throw new Error("Invalid `container` and/or `viewer` option."); throw new Error("Invalid `container` and/or `viewer` option.");
} }
@ -269,10 +266,7 @@ class PDFViewer {
options.annotationEditorMode ?? AnnotationEditorType.NONE; options.annotationEditorMode ?? AnnotationEditorType.NONE;
this.imageResourcesPath = options.imageResourcesPath || ""; this.imageResourcesPath = options.imageResourcesPath || "";
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false; this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
if ( if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
this.removePageBorders = options.removePageBorders || false; this.removePageBorders = options.removePageBorders || false;
} }
this.useOnlyCssZoom = options.useOnlyCssZoom || false; this.useOnlyCssZoom = options.useOnlyCssZoom || false;

View File

@ -22,7 +22,7 @@ import { AppOptions, OptionKind } from "./app_options.js";
*/ */
class BasePreferences { class BasePreferences {
#defaults = Object.freeze( #defaults = Object.freeze(
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") typeof PDFJSDev === "undefined"
? AppOptions.getAll(OptionKind.PREFERENCE) ? AppOptions.getAll(OptionKind.PREFERENCE)
: PDFJSDev.eval("DEFAULT_PREFERENCES") : PDFJSDev.eval("DEFAULT_PREFERENCES")
); );

View File

@ -64,7 +64,7 @@ function getViewerConfiguration() {
function webViewerLoad() { function webViewerLoad() {
const config = getViewerConfiguration(); const config = getViewerConfiguration();
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) { if (typeof PDFJSDev === "undefined") {
window.isGECKOVIEW = true; window.isGECKOVIEW = true;
} }
PDFViewerApplication.run(config); PDFViewerApplication.run(config);

View File

@ -49,7 +49,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<!--<script src="resource://pdf.js/web/viewer.js"></script>--> <!--<script src="resource://pdf.js/web/viewer.js"></script>-->
<!--#elif !MINIFIED--> <!--#elif !MINIFIED-->
<!--<script src="viewer.js"></script>--> <!--<script src="viewer.js"></script>-->
<!--#elif !PRODUCTION--> <!--#elif /* Development mode. */-->
<link rel="resource" type="application/l10n" href="locale/locale.properties"> <link rel="resource" type="application/l10n" href="locale/locale.properties">
<script defer src="../node_modules/es-module-shims/dist/es-module-shims.js"></script> <script defer src="../node_modules/es-module-shims/dist/es-module-shims.js"></script>