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
@ -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."
|
||||||
|
@ -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."
|
||||||
|
@ -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.'
|
||||||
|
@ -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,
|
||||||
|
@ -698,10 +698,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;
|
||||||
@ -755,10 +752,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.'
|
||||||
@ -1419,10 +1413,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."
|
||||||
|
@ -4508,10 +4508,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."
|
||||||
|
@ -316,10 +316,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}".`
|
||||||
@ -329,10 +326,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}".`
|
||||||
|
@ -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.'
|
||||||
|
@ -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."
|
||||||
|
@ -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.'
|
||||||
|
@ -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) {
|
||||||
|
@ -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."
|
||||||
|
@ -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."
|
||||||
|
@ -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.'
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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"),
|
||||||
@ -1793,10 +1793,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.'
|
||||||
@ -1863,10 +1860,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.'
|
||||||
@ -2133,7 +2127,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" })
|
||||||
@ -2324,7 +2318,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;
|
||||||
}
|
}
|
||||||
|
@ -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")
|
||||||
);
|
);
|
||||||
|
@ -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",
|
||||||
|
@ -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."
|
||||||
|
@ -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",
|
||||||
|
@ -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,
|
||||||
|
@ -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.'
|
||||||
|
@ -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}".`
|
||||||
|
16
web/app.js
16
web/app.js
@ -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
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
@ -548,8 +544,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(
|
||||||
@ -686,8 +681,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.");
|
||||||
|
@ -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.");
|
||||||
}
|
}
|
||||||
@ -274,10 +271,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;
|
||||||
|
@ -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")
|
||||||
);
|
);
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user