Enable the ESLint prefer-const rule globally (PR 11450 follow-up)
				
					
				
			Please find additional details about the ESLint rule at https://eslint.org/docs/rules/prefer-const With the recent introduction of Prettier this sort of mass enabling of ESLint rules becomes a lot easier, since the code will be automatically reformatted as necessary to account for e.g. changed line lengths. Note that this patch is generated automatically, by using the ESLint `--fix` argument, and will thus require some additional clean-up (which is done separately).
This commit is contained in:
		
							parent
							
								
									d2d9441373
								
							
						
					
					
						commit
						9e262ae7fa
					
				@ -161,7 +161,7 @@
 | 
				
			|||||||
    "object-shorthand": ["error", "always", {
 | 
					    "object-shorthand": ["error", "always", {
 | 
				
			||||||
      "avoidQuotes": true,
 | 
					      "avoidQuotes": true,
 | 
				
			||||||
    }],
 | 
					    }],
 | 
				
			||||||
    "prefer-const": "off",
 | 
					    "prefer-const": "error",
 | 
				
			||||||
    "sort-imports": ["error", {
 | 
					    "sort-imports": ["error", {
 | 
				
			||||||
      "ignoreCase": true,
 | 
					      "ignoreCase": true,
 | 
				
			||||||
    }],
 | 
					    }],
 | 
				
			||||||
 | 
				
			|||||||
@ -1058,8 +1058,8 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
 | 
				
			|||||||
    if (Array.isArray(options)) {
 | 
					    if (Array.isArray(options)) {
 | 
				
			||||||
      const xref = params.xref;
 | 
					      const xref = params.xref;
 | 
				
			||||||
      for (let i = 0, ii = options.length; i < ii; i++) {
 | 
					      for (let i = 0, ii = options.length; i < ii; i++) {
 | 
				
			||||||
        let option = xref.fetchIfRef(options[i]);
 | 
					        const option = xref.fetchIfRef(options[i]);
 | 
				
			||||||
        let isOptionArray = Array.isArray(option);
 | 
					        const isOptionArray = Array.isArray(option);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.data.options[i] = {
 | 
					        this.data.options[i] = {
 | 
				
			||||||
          exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
 | 
					          exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { info } from "../shared/util.js";
 | 
					import { info } from "../shared/util.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
					const CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
				
			||||||
  const ccittEOL = -2;
 | 
					  const ccittEOL = -2;
 | 
				
			||||||
  const ccittEOF = -1;
 | 
					  const ccittEOF = -1;
 | 
				
			||||||
  const twoDimPass = 0;
 | 
					  const twoDimPass = 0;
 | 
				
			||||||
@ -515,9 +515,9 @@ let CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
				
			|||||||
      if (this.eof) {
 | 
					      if (this.eof) {
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let refLine = this.refLine;
 | 
					      const refLine = this.refLine;
 | 
				
			||||||
      let codingLine = this.codingLine;
 | 
					      const codingLine = this.codingLine;
 | 
				
			||||||
      let columns = this.columns;
 | 
					      const columns = this.columns;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let refPos, blackPixels, bits, i;
 | 
					      let refPos, blackPixels, bits, i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -850,7 +850,7 @@ let CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
				
			|||||||
     * @private
 | 
					     * @private
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    _addPixels(a1, blackPixels) {
 | 
					    _addPixels(a1, blackPixels) {
 | 
				
			||||||
      let codingLine = this.codingLine;
 | 
					      const codingLine = this.codingLine;
 | 
				
			||||||
      let codingPos = this.codingPos;
 | 
					      let codingPos = this.codingPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (a1 > codingLine[codingPos]) {
 | 
					      if (a1 > codingLine[codingPos]) {
 | 
				
			||||||
@ -872,7 +872,7 @@ let CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
				
			|||||||
     * @private
 | 
					     * @private
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    _addPixelsNeg(a1, blackPixels) {
 | 
					    _addPixelsNeg(a1, blackPixels) {
 | 
				
			||||||
      let codingLine = this.codingLine;
 | 
					      const codingLine = this.codingLine;
 | 
				
			||||||
      let codingPos = this.codingPos;
 | 
					      let codingPos = this.codingPos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (a1 > codingLine[codingPos]) {
 | 
					      if (a1 > codingLine[codingPos]) {
 | 
				
			||||||
@ -911,7 +911,7 @@ let CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
				
			|||||||
     * @private
 | 
					     * @private
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    _findTableCode(start, end, table, limit) {
 | 
					    _findTableCode(start, end, table, limit) {
 | 
				
			||||||
      let limitValue = limit || 0;
 | 
					      const limitValue = limit || 0;
 | 
				
			||||||
      for (let i = start; i <= end; ++i) {
 | 
					      for (let i = start; i <= end; ++i) {
 | 
				
			||||||
        let code = this._lookBits(i);
 | 
					        let code = this._lookBits(i);
 | 
				
			||||||
        if (code === ccittEOF) {
 | 
					        if (code === ccittEOF) {
 | 
				
			||||||
@ -921,7 +921,7 @@ let CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
				
			|||||||
          code <<= end - i;
 | 
					          code <<= end - i;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!limitValue || code >= limitValue) {
 | 
					        if (!limitValue || code >= limitValue) {
 | 
				
			||||||
          let p = table[code - limitValue];
 | 
					          const p = table[code - limitValue];
 | 
				
			||||||
          if (p[0] === i) {
 | 
					          if (p[0] === i) {
 | 
				
			||||||
            this._eatBits(i);
 | 
					            this._eatBits(i);
 | 
				
			||||||
            return [true, p[1], true];
 | 
					            return [true, p[1], true];
 | 
				
			||||||
@ -945,7 +945,7 @@ let CCITTFaxDecoder = (function CCITTFaxDecoder() {
 | 
				
			|||||||
          return p[1];
 | 
					          return p[1];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        let result = this._findTableCode(1, 7, twoDimTable);
 | 
					        const result = this._findTableCode(1, 7, twoDimTable);
 | 
				
			||||||
        if (result[0] && result[2]) {
 | 
					        if (result[0] && result[2]) {
 | 
				
			||||||
          return result[1];
 | 
					          return result[1];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -48,7 +48,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  CCITTFaxStream.prototype.readBlock = function() {
 | 
					  CCITTFaxStream.prototype.readBlock = function() {
 | 
				
			||||||
    while (!this.eof) {
 | 
					    while (!this.eof) {
 | 
				
			||||||
      let c = this.ccittFaxDecoder.readNextChar();
 | 
					      const c = this.ccittFaxDecoder.readNextChar();
 | 
				
			||||||
      if (c === -1) {
 | 
					      if (c === -1) {
 | 
				
			||||||
        this.eof = true;
 | 
					        this.eof = true;
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
				
			|||||||
@ -1730,7 +1730,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
 | 
				
			|||||||
      // Freetype requires the number of charset strings be correct and MacOS
 | 
					      // Freetype requires the number of charset strings be correct and MacOS
 | 
				
			||||||
      // requires a valid mapping for printing.
 | 
					      // requires a valid mapping for printing.
 | 
				
			||||||
      let out;
 | 
					      let out;
 | 
				
			||||||
      let numGlyphsLessNotDef = numGlyphs - 1;
 | 
					      const numGlyphsLessNotDef = numGlyphs - 1;
 | 
				
			||||||
      if (isCIDFont) {
 | 
					      if (isCIDFont) {
 | 
				
			||||||
        // In a CID font, the charset is a mapping of CIDs not SIDs so just
 | 
					        // In a CID font, the charset is a mapping of CIDs not SIDs so just
 | 
				
			||||||
        // create an identity mapping.
 | 
					        // create an identity mapping.
 | 
				
			||||||
@ -1742,16 +1742,16 @@ var CFFCompiler = (function CFFCompilerClosure() {
 | 
				
			|||||||
          numGlyphsLessNotDef & 0xff,
 | 
					          numGlyphsLessNotDef & 0xff,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        let length = 1 + numGlyphsLessNotDef * 2;
 | 
					        const length = 1 + numGlyphsLessNotDef * 2;
 | 
				
			||||||
        out = new Uint8Array(length);
 | 
					        out = new Uint8Array(length);
 | 
				
			||||||
        out[0] = 0; // format 0
 | 
					        out[0] = 0; // format 0
 | 
				
			||||||
        let charsetIndex = 0;
 | 
					        let charsetIndex = 0;
 | 
				
			||||||
        let numCharsets = charset.charset.length;
 | 
					        const numCharsets = charset.charset.length;
 | 
				
			||||||
        let warned = false;
 | 
					        let warned = false;
 | 
				
			||||||
        for (let i = 1; i < out.length; i += 2) {
 | 
					        for (let i = 1; i < out.length; i += 2) {
 | 
				
			||||||
          let sid = 0;
 | 
					          let sid = 0;
 | 
				
			||||||
          if (charsetIndex < numCharsets) {
 | 
					          if (charsetIndex < numCharsets) {
 | 
				
			||||||
            let name = charset.charset[charsetIndex++];
 | 
					            const name = charset.charset[charsetIndex++];
 | 
				
			||||||
            sid = strings.getSID(name);
 | 
					            sid = strings.getSID(name);
 | 
				
			||||||
            if (sid === -1) {
 | 
					            if (sid === -1) {
 | 
				
			||||||
              sid = 0;
 | 
					              sid = 0;
 | 
				
			||||||
@ -1771,7 +1771,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
 | 
				
			|||||||
      return this.compileTypedArray(encoding.raw);
 | 
					      return this.compileTypedArray(encoding.raw);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
 | 
					    compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
 | 
				
			||||||
      let format = fdSelect.format;
 | 
					      const format = fdSelect.format;
 | 
				
			||||||
      let out, i;
 | 
					      let out, i;
 | 
				
			||||||
      switch (format) {
 | 
					      switch (format) {
 | 
				
			||||||
        case 0:
 | 
					        case 0:
 | 
				
			||||||
@ -1782,9 +1782,9 @@ var CFFCompiler = (function CFFCompilerClosure() {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case 3:
 | 
					        case 3:
 | 
				
			||||||
          let start = 0;
 | 
					          const start = 0;
 | 
				
			||||||
          let lastFD = fdSelect.fdSelect[0];
 | 
					          let lastFD = fdSelect.fdSelect[0];
 | 
				
			||||||
          let ranges = [
 | 
					          const ranges = [
 | 
				
			||||||
            format,
 | 
					            format,
 | 
				
			||||||
            0, // nRanges place holder
 | 
					            0, // nRanges place holder
 | 
				
			||||||
            0, // nRanges place holder
 | 
					            0, // nRanges place holder
 | 
				
			||||||
@ -1793,14 +1793,14 @@ var CFFCompiler = (function CFFCompilerClosure() {
 | 
				
			|||||||
            lastFD,
 | 
					            lastFD,
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
          for (i = 1; i < fdSelect.fdSelect.length; i++) {
 | 
					          for (i = 1; i < fdSelect.fdSelect.length; i++) {
 | 
				
			||||||
            let currentFD = fdSelect.fdSelect[i];
 | 
					            const currentFD = fdSelect.fdSelect[i];
 | 
				
			||||||
            if (currentFD !== lastFD) {
 | 
					            if (currentFD !== lastFD) {
 | 
				
			||||||
              ranges.push((i >> 8) & 0xff, i & 0xff, currentFD);
 | 
					              ranges.push((i >> 8) & 0xff, i & 0xff, currentFD);
 | 
				
			||||||
              lastFD = currentFD;
 | 
					              lastFD = currentFD;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          // 3 bytes are pushed for every range and there are 3 header bytes.
 | 
					          // 3 bytes are pushed for every range and there are 3 header bytes.
 | 
				
			||||||
          let numRanges = (ranges.length - 3) / 3;
 | 
					          const numRanges = (ranges.length - 3) / 3;
 | 
				
			||||||
          ranges[1] = (numRanges >> 8) & 0xff;
 | 
					          ranges[1] = (numRanges >> 8) & 0xff;
 | 
				
			||||||
          ranges[2] = numRanges & 0xff;
 | 
					          ranges[2] = numRanges & 0xff;
 | 
				
			||||||
          // sentinel
 | 
					          // sentinel
 | 
				
			||||||
 | 
				
			|||||||
@ -496,7 +496,7 @@ class ChunkedStreamManager {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  onReceiveData(args) {
 | 
					  onReceiveData(args) {
 | 
				
			||||||
    let chunk = args.chunk;
 | 
					    const chunk = args.chunk;
 | 
				
			||||||
    const isProgressive = args.begin === undefined;
 | 
					    const isProgressive = args.begin === undefined;
 | 
				
			||||||
    const begin = isProgressive ? this.progressiveDataLength : args.begin;
 | 
					    const begin = isProgressive ? this.progressiveDataLength : args.begin;
 | 
				
			||||||
    const end = begin + chunk.byteLength;
 | 
					    const end = begin + chunk.byteLength;
 | 
				
			||||||
 | 
				
			|||||||
@ -267,8 +267,8 @@ class CMap {
 | 
				
			|||||||
    // indices in the *billions*. For such tables we use for..in, which isn't
 | 
					    // indices in the *billions*. For such tables we use for..in, which isn't
 | 
				
			||||||
    // ideal because it stringifies the indices for all present elements, but
 | 
					    // ideal because it stringifies the indices for all present elements, but
 | 
				
			||||||
    // it does avoid iterating over every undefined entry.
 | 
					    // it does avoid iterating over every undefined entry.
 | 
				
			||||||
    let map = this._map;
 | 
					    const map = this._map;
 | 
				
			||||||
    let length = map.length;
 | 
					    const length = map.length;
 | 
				
			||||||
    if (length <= 0x10000) {
 | 
					    if (length <= 0x10000) {
 | 
				
			||||||
      for (let i = 0; i < length; i++) {
 | 
					      for (let i = 0; i < length; i++) {
 | 
				
			||||||
        if (map[i] !== undefined) {
 | 
					        if (map[i] !== undefined) {
 | 
				
			||||||
@ -276,7 +276,7 @@ class CMap {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      for (let i in map) {
 | 
					      for (const i in map) {
 | 
				
			||||||
        callback(i, map[i]);
 | 
					        callback(i, map[i]);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -289,7 +289,7 @@ class CMap {
 | 
				
			|||||||
    if (map.length <= 0x10000) {
 | 
					    if (map.length <= 0x10000) {
 | 
				
			||||||
      return map.indexOf(value);
 | 
					      return map.indexOf(value);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (let charCode in map) {
 | 
					    for (const charCode in map) {
 | 
				
			||||||
      if (map[charCode] === value) {
 | 
					      if (map[charCode] === value) {
 | 
				
			||||||
        return charCode | 0;
 | 
					        return charCode | 0;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -37,12 +37,12 @@ import { isDict, isName, isStream } from "./primitives.js";
 | 
				
			|||||||
function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
 | 
					function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
 | 
				
			||||||
  const COMPONENTS = 3;
 | 
					  const COMPONENTS = 3;
 | 
				
			||||||
  alpha01 = alpha01 !== 1 ? 0 : alpha01;
 | 
					  alpha01 = alpha01 !== 1 ? 0 : alpha01;
 | 
				
			||||||
  let xRatio = w1 / w2;
 | 
					  const xRatio = w1 / w2;
 | 
				
			||||||
  let yRatio = h1 / h2;
 | 
					  const yRatio = h1 / h2;
 | 
				
			||||||
  let newIndex = 0,
 | 
					  let newIndex = 0,
 | 
				
			||||||
    oldIndex;
 | 
					    oldIndex;
 | 
				
			||||||
  let xScaled = new Uint16Array(w2);
 | 
					  const xScaled = new Uint16Array(w2);
 | 
				
			||||||
  let w1Scanline = w1 * COMPONENTS;
 | 
					  const w1Scanline = w1 * COMPONENTS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (let i = 0; i < w2; i++) {
 | 
					  for (let i = 0; i < w2; i++) {
 | 
				
			||||||
    xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
 | 
					    xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
 | 
				
			||||||
@ -74,7 +74,7 @@ class ColorSpace {
 | 
				
			|||||||
   * of the rgb components, each value ranging from [0,255].
 | 
					   * of the rgb components, each value ranging from [0,255].
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  getRgb(src, srcOffset) {
 | 
					  getRgb(src, srcOffset) {
 | 
				
			||||||
    let rgb = new Uint8ClampedArray(3);
 | 
					    const rgb = new Uint8ClampedArray(3);
 | 
				
			||||||
    this.getRgbItem(src, srcOffset, rgb, 0);
 | 
					    this.getRgbItem(src, srcOffset, rgb, 0);
 | 
				
			||||||
    return rgb;
 | 
					    return rgb;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -148,10 +148,10 @@ class ColorSpace {
 | 
				
			|||||||
        'ColorSpace.fillRgb: Unsupported "dest" type.'
 | 
					        'ColorSpace.fillRgb: Unsupported "dest" type.'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let count = originalWidth * originalHeight;
 | 
					    const count = originalWidth * originalHeight;
 | 
				
			||||||
    let rgbBuf = null;
 | 
					    let rgbBuf = null;
 | 
				
			||||||
    let numComponentColors = 1 << bpc;
 | 
					    const numComponentColors = 1 << bpc;
 | 
				
			||||||
    let needsResizing = originalHeight !== height || originalWidth !== width;
 | 
					    const needsResizing = originalHeight !== height || originalWidth !== width;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (this.isPassthrough(bpc)) {
 | 
					    if (this.isPassthrough(bpc)) {
 | 
				
			||||||
      rgbBuf = comps;
 | 
					      rgbBuf = comps;
 | 
				
			||||||
@ -170,14 +170,14 @@ class ColorSpace {
 | 
				
			|||||||
      // TODO it may be worth while to cache the color map. While running
 | 
					      // TODO it may be worth while to cache the color map. While running
 | 
				
			||||||
      // testing I never hit a cache so I will leave that out for now (perhaps
 | 
					      // testing I never hit a cache so I will leave that out for now (perhaps
 | 
				
			||||||
      // we are reparsing colorspaces too much?).
 | 
					      // we are reparsing colorspaces too much?).
 | 
				
			||||||
      let allColors =
 | 
					      const allColors =
 | 
				
			||||||
        bpc <= 8
 | 
					        bpc <= 8
 | 
				
			||||||
          ? new Uint8Array(numComponentColors)
 | 
					          ? new Uint8Array(numComponentColors)
 | 
				
			||||||
          : new Uint16Array(numComponentColors);
 | 
					          : new Uint16Array(numComponentColors);
 | 
				
			||||||
      for (let i = 0; i < numComponentColors; i++) {
 | 
					      for (let i = 0; i < numComponentColors; i++) {
 | 
				
			||||||
        allColors[i] = i;
 | 
					        allColors[i] = i;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let colorMap = new Uint8ClampedArray(numComponentColors * 3);
 | 
					      const colorMap = new Uint8ClampedArray(numComponentColors * 3);
 | 
				
			||||||
      this.getRgbBuffer(
 | 
					      this.getRgbBuffer(
 | 
				
			||||||
        allColors,
 | 
					        allColors,
 | 
				
			||||||
        0,
 | 
					        0,
 | 
				
			||||||
@ -260,12 +260,12 @@ class ColorSpace {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static parse(cs, xref, res, pdfFunctionFactory) {
 | 
					  static parse(cs, xref, res, pdfFunctionFactory) {
 | 
				
			||||||
    let IR = this.parseToIR(cs, xref, res, pdfFunctionFactory);
 | 
					    const IR = this.parseToIR(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
    return this.fromIR(IR);
 | 
					    return this.fromIR(IR);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static fromIR(IR) {
 | 
					  static fromIR(IR) {
 | 
				
			||||||
    let name = Array.isArray(IR) ? IR[0] : IR;
 | 
					    const name = Array.isArray(IR) ? IR[0] : IR;
 | 
				
			||||||
    let whitePoint, blackPoint, gamma;
 | 
					    let whitePoint, blackPoint, gamma;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (name) {
 | 
					    switch (name) {
 | 
				
			||||||
@ -284,7 +284,7 @@ class ColorSpace {
 | 
				
			|||||||
        whitePoint = IR[1];
 | 
					        whitePoint = IR[1];
 | 
				
			||||||
        blackPoint = IR[2];
 | 
					        blackPoint = IR[2];
 | 
				
			||||||
        gamma = IR[3];
 | 
					        gamma = IR[3];
 | 
				
			||||||
        let matrix = IR[4];
 | 
					        const matrix = IR[4];
 | 
				
			||||||
        return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
 | 
					        return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
 | 
				
			||||||
      case "PatternCS":
 | 
					      case "PatternCS":
 | 
				
			||||||
        let basePatternCS = IR[1];
 | 
					        let basePatternCS = IR[1];
 | 
				
			||||||
@ -293,19 +293,19 @@ class ColorSpace {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return new PatternCS(basePatternCS);
 | 
					        return new PatternCS(basePatternCS);
 | 
				
			||||||
      case "IndexedCS":
 | 
					      case "IndexedCS":
 | 
				
			||||||
        let baseIndexedCS = IR[1];
 | 
					        const baseIndexedCS = IR[1];
 | 
				
			||||||
        let hiVal = IR[2];
 | 
					        const hiVal = IR[2];
 | 
				
			||||||
        let lookup = IR[3];
 | 
					        const lookup = IR[3];
 | 
				
			||||||
        return new IndexedCS(this.fromIR(baseIndexedCS), hiVal, lookup);
 | 
					        return new IndexedCS(this.fromIR(baseIndexedCS), hiVal, lookup);
 | 
				
			||||||
      case "AlternateCS":
 | 
					      case "AlternateCS":
 | 
				
			||||||
        let numComps = IR[1];
 | 
					        const numComps = IR[1];
 | 
				
			||||||
        let alt = IR[2];
 | 
					        const alt = IR[2];
 | 
				
			||||||
        let tintFn = IR[3];
 | 
					        const tintFn = IR[3];
 | 
				
			||||||
        return new AlternateCS(numComps, this.fromIR(alt), tintFn);
 | 
					        return new AlternateCS(numComps, this.fromIR(alt), tintFn);
 | 
				
			||||||
      case "LabCS":
 | 
					      case "LabCS":
 | 
				
			||||||
        whitePoint = IR[1];
 | 
					        whitePoint = IR[1];
 | 
				
			||||||
        blackPoint = IR[2];
 | 
					        blackPoint = IR[2];
 | 
				
			||||||
        let range = IR[3];
 | 
					        const range = IR[3];
 | 
				
			||||||
        return new LabCS(whitePoint, blackPoint, range);
 | 
					        return new LabCS(whitePoint, blackPoint, range);
 | 
				
			||||||
      default:
 | 
					      default:
 | 
				
			||||||
        throw new FormatError(`Unknown colorspace name: ${name}`);
 | 
					        throw new FormatError(`Unknown colorspace name: ${name}`);
 | 
				
			||||||
@ -329,9 +329,9 @@ class ColorSpace {
 | 
				
			|||||||
          return ["PatternCS", null];
 | 
					          return ["PatternCS", null];
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
          if (isDict(res)) {
 | 
					          if (isDict(res)) {
 | 
				
			||||||
            let colorSpaces = res.get("ColorSpace");
 | 
					            const colorSpaces = res.get("ColorSpace");
 | 
				
			||||||
            if (isDict(colorSpaces)) {
 | 
					            if (isDict(colorSpaces)) {
 | 
				
			||||||
              let resCS = colorSpaces.get(cs.name);
 | 
					              const resCS = colorSpaces.get(cs.name);
 | 
				
			||||||
              if (resCS) {
 | 
					              if (resCS) {
 | 
				
			||||||
                if (isName(resCS)) {
 | 
					                if (isName(resCS)) {
 | 
				
			||||||
                  return this.parseToIR(resCS, xref, res, pdfFunctionFactory);
 | 
					                  return this.parseToIR(resCS, xref, res, pdfFunctionFactory);
 | 
				
			||||||
@ -345,7 +345,7 @@ class ColorSpace {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (Array.isArray(cs)) {
 | 
					    if (Array.isArray(cs)) {
 | 
				
			||||||
      let mode = xref.fetchIfRef(cs[0]).name;
 | 
					      const mode = xref.fetchIfRef(cs[0]).name;
 | 
				
			||||||
      let numComps, params, alt, whitePoint, blackPoint, gamma;
 | 
					      let numComps, params, alt, whitePoint, blackPoint, gamma;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      switch (mode) {
 | 
					      switch (mode) {
 | 
				
			||||||
@ -369,18 +369,18 @@ class ColorSpace {
 | 
				
			|||||||
          whitePoint = params.getArray("WhitePoint");
 | 
					          whitePoint = params.getArray("WhitePoint");
 | 
				
			||||||
          blackPoint = params.getArray("BlackPoint");
 | 
					          blackPoint = params.getArray("BlackPoint");
 | 
				
			||||||
          gamma = params.getArray("Gamma");
 | 
					          gamma = params.getArray("Gamma");
 | 
				
			||||||
          let matrix = params.getArray("Matrix");
 | 
					          const matrix = params.getArray("Matrix");
 | 
				
			||||||
          return ["CalRGBCS", whitePoint, blackPoint, gamma, matrix];
 | 
					          return ["CalRGBCS", whitePoint, blackPoint, gamma, matrix];
 | 
				
			||||||
        case "ICCBased":
 | 
					        case "ICCBased":
 | 
				
			||||||
          let stream = xref.fetchIfRef(cs[1]);
 | 
					          const stream = xref.fetchIfRef(cs[1]);
 | 
				
			||||||
          let dict = stream.dict;
 | 
					          const dict = stream.dict;
 | 
				
			||||||
          numComps = dict.get("N");
 | 
					          numComps = dict.get("N");
 | 
				
			||||||
          alt = dict.get("Alternate");
 | 
					          alt = dict.get("Alternate");
 | 
				
			||||||
          if (alt) {
 | 
					          if (alt) {
 | 
				
			||||||
            let altIR = this.parseToIR(alt, xref, res, pdfFunctionFactory);
 | 
					            const altIR = this.parseToIR(alt, xref, res, pdfFunctionFactory);
 | 
				
			||||||
            // Parse the /Alternate CS to ensure that the number of components
 | 
					            // Parse the /Alternate CS to ensure that the number of components
 | 
				
			||||||
            // are correct, and also (indirectly) that it is not a PatternCS.
 | 
					            // are correct, and also (indirectly) that it is not a PatternCS.
 | 
				
			||||||
            let altCS = this.fromIR(altIR, pdfFunctionFactory);
 | 
					            const altCS = this.fromIR(altIR, pdfFunctionFactory);
 | 
				
			||||||
            if (altCS.numComps === numComps) {
 | 
					            if (altCS.numComps === numComps) {
 | 
				
			||||||
              return altIR;
 | 
					              return altIR;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -407,13 +407,13 @@ class ColorSpace {
 | 
				
			|||||||
          return ["PatternCS", basePatternCS];
 | 
					          return ["PatternCS", basePatternCS];
 | 
				
			||||||
        case "Indexed":
 | 
					        case "Indexed":
 | 
				
			||||||
        case "I":
 | 
					        case "I":
 | 
				
			||||||
          let baseIndexedCS = this.parseToIR(
 | 
					          const baseIndexedCS = this.parseToIR(
 | 
				
			||||||
            cs[1],
 | 
					            cs[1],
 | 
				
			||||||
            xref,
 | 
					            xref,
 | 
				
			||||||
            res,
 | 
					            res,
 | 
				
			||||||
            pdfFunctionFactory
 | 
					            pdfFunctionFactory
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
          let hiVal = xref.fetchIfRef(cs[2]) + 1;
 | 
					          const hiVal = xref.fetchIfRef(cs[2]) + 1;
 | 
				
			||||||
          let lookup = xref.fetchIfRef(cs[3]);
 | 
					          let lookup = xref.fetchIfRef(cs[3]);
 | 
				
			||||||
          if (isStream(lookup)) {
 | 
					          if (isStream(lookup)) {
 | 
				
			||||||
            lookup = lookup.getBytes();
 | 
					            lookup = lookup.getBytes();
 | 
				
			||||||
@ -421,16 +421,16 @@ class ColorSpace {
 | 
				
			|||||||
          return ["IndexedCS", baseIndexedCS, hiVal, lookup];
 | 
					          return ["IndexedCS", baseIndexedCS, hiVal, lookup];
 | 
				
			||||||
        case "Separation":
 | 
					        case "Separation":
 | 
				
			||||||
        case "DeviceN":
 | 
					        case "DeviceN":
 | 
				
			||||||
          let name = xref.fetchIfRef(cs[1]);
 | 
					          const name = xref.fetchIfRef(cs[1]);
 | 
				
			||||||
          numComps = Array.isArray(name) ? name.length : 1;
 | 
					          numComps = Array.isArray(name) ? name.length : 1;
 | 
				
			||||||
          alt = this.parseToIR(cs[2], xref, res, pdfFunctionFactory);
 | 
					          alt = this.parseToIR(cs[2], xref, res, pdfFunctionFactory);
 | 
				
			||||||
          let tintFn = pdfFunctionFactory.create(xref.fetchIfRef(cs[3]));
 | 
					          const tintFn = pdfFunctionFactory.create(xref.fetchIfRef(cs[3]));
 | 
				
			||||||
          return ["AlternateCS", numComps, alt, tintFn];
 | 
					          return ["AlternateCS", numComps, alt, tintFn];
 | 
				
			||||||
        case "Lab":
 | 
					        case "Lab":
 | 
				
			||||||
          params = xref.fetchIfRef(cs[1]);
 | 
					          params = xref.fetchIfRef(cs[1]);
 | 
				
			||||||
          whitePoint = params.getArray("WhitePoint");
 | 
					          whitePoint = params.getArray("WhitePoint");
 | 
				
			||||||
          blackPoint = params.getArray("BlackPoint");
 | 
					          blackPoint = params.getArray("BlackPoint");
 | 
				
			||||||
          let range = params.getArray("Range");
 | 
					          const range = params.getArray("Range");
 | 
				
			||||||
          return ["LabCS", whitePoint, blackPoint, range];
 | 
					          return ["LabCS", whitePoint, blackPoint, range];
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
          throw new FormatError(`unimplemented color space object "${mode}"`);
 | 
					          throw new FormatError(`unimplemented color space object "${mode}"`);
 | 
				
			||||||
@ -505,7 +505,7 @@ class AlternateCS extends ColorSpace {
 | 
				
			|||||||
        'AlternateCS.getRgbItem: Unsupported "dest" type.'
 | 
					        'AlternateCS.getRgbItem: Unsupported "dest" type.'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let tmpBuf = this.tmpBuf;
 | 
					    const tmpBuf = this.tmpBuf;
 | 
				
			||||||
    this.tintFn(src, srcOffset, tmpBuf, 0);
 | 
					    this.tintFn(src, srcOffset, tmpBuf, 0);
 | 
				
			||||||
    this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
 | 
					    this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -520,21 +520,21 @@ class AlternateCS extends ColorSpace {
 | 
				
			|||||||
        'AlternateCS.getRgbBuffer: Unsupported "dest" type.'
 | 
					        'AlternateCS.getRgbBuffer: Unsupported "dest" type.'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let tintFn = this.tintFn;
 | 
					    const tintFn = this.tintFn;
 | 
				
			||||||
    let base = this.base;
 | 
					    const base = this.base;
 | 
				
			||||||
    let scale = 1 / ((1 << bits) - 1);
 | 
					    const scale = 1 / ((1 << bits) - 1);
 | 
				
			||||||
    let baseNumComps = base.numComps;
 | 
					    const baseNumComps = base.numComps;
 | 
				
			||||||
    let usesZeroToOneRange = base.usesZeroToOneRange;
 | 
					    const usesZeroToOneRange = base.usesZeroToOneRange;
 | 
				
			||||||
    let isPassthrough =
 | 
					    const isPassthrough =
 | 
				
			||||||
      (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
 | 
					      (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
 | 
				
			||||||
    let pos = isPassthrough ? destOffset : 0;
 | 
					    let pos = isPassthrough ? destOffset : 0;
 | 
				
			||||||
    let baseBuf = isPassthrough
 | 
					    const baseBuf = isPassthrough
 | 
				
			||||||
      ? dest
 | 
					      ? dest
 | 
				
			||||||
      : new Uint8ClampedArray(baseNumComps * count);
 | 
					      : new Uint8ClampedArray(baseNumComps * count);
 | 
				
			||||||
    let numComps = this.numComps;
 | 
					    const numComps = this.numComps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let scaled = new Float32Array(numComps);
 | 
					    const scaled = new Float32Array(numComps);
 | 
				
			||||||
    let tinted = new Float32Array(baseNumComps);
 | 
					    const tinted = new Float32Array(baseNumComps);
 | 
				
			||||||
    let i, j;
 | 
					    let i, j;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (i = 0; i < count; i++) {
 | 
					    for (i = 0; i < count; i++) {
 | 
				
			||||||
@ -585,12 +585,12 @@ class IndexedCS extends ColorSpace {
 | 
				
			|||||||
    this.base = base;
 | 
					    this.base = base;
 | 
				
			||||||
    this.highVal = highVal;
 | 
					    this.highVal = highVal;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let baseNumComps = base.numComps;
 | 
					    const baseNumComps = base.numComps;
 | 
				
			||||||
    let length = baseNumComps * highVal;
 | 
					    const length = baseNumComps * highVal;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isStream(lookup)) {
 | 
					    if (isStream(lookup)) {
 | 
				
			||||||
      this.lookup = new Uint8Array(length);
 | 
					      this.lookup = new Uint8Array(length);
 | 
				
			||||||
      let bytes = lookup.getBytes(length);
 | 
					      const bytes = lookup.getBytes(length);
 | 
				
			||||||
      this.lookup.set(bytes);
 | 
					      this.lookup.set(bytes);
 | 
				
			||||||
    } else if (isString(lookup)) {
 | 
					    } else if (isString(lookup)) {
 | 
				
			||||||
      this.lookup = new Uint8Array(length);
 | 
					      this.lookup = new Uint8Array(length);
 | 
				
			||||||
@ -614,8 +614,8 @@ class IndexedCS extends ColorSpace {
 | 
				
			|||||||
        'IndexedCS.getRgbItem: Unsupported "dest" type.'
 | 
					        'IndexedCS.getRgbItem: Unsupported "dest" type.'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let numComps = this.base.numComps;
 | 
					    const numComps = this.base.numComps;
 | 
				
			||||||
    let start = src[srcOffset] * numComps;
 | 
					    const start = src[srcOffset] * numComps;
 | 
				
			||||||
    this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
 | 
					    this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -629,13 +629,13 @@ class IndexedCS extends ColorSpace {
 | 
				
			|||||||
        'IndexedCS.getRgbBuffer: Unsupported "dest" type.'
 | 
					        'IndexedCS.getRgbBuffer: Unsupported "dest" type.'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let base = this.base;
 | 
					    const base = this.base;
 | 
				
			||||||
    let numComps = base.numComps;
 | 
					    const numComps = base.numComps;
 | 
				
			||||||
    let outputDelta = base.getOutputLength(numComps, alpha01);
 | 
					    const outputDelta = base.getOutputLength(numComps, alpha01);
 | 
				
			||||||
    let lookup = this.lookup;
 | 
					    const lookup = this.lookup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (let i = 0; i < count; ++i) {
 | 
					    for (let i = 0; i < count; ++i) {
 | 
				
			||||||
      let lookupPos = src[srcOffset++] * numComps;
 | 
					      const lookupPos = src[srcOffset++] * numComps;
 | 
				
			||||||
      base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
 | 
					      base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
 | 
				
			||||||
      destOffset += outputDelta;
 | 
					      destOffset += outputDelta;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -679,7 +679,7 @@ class DeviceGrayCS extends ColorSpace {
 | 
				
			|||||||
        'DeviceGrayCS.getRgbItem: Unsupported "dest" type.'
 | 
					        'DeviceGrayCS.getRgbItem: Unsupported "dest" type.'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let c = src[srcOffset] * 255;
 | 
					    const c = src[srcOffset] * 255;
 | 
				
			||||||
    dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
 | 
					    dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -693,11 +693,11 @@ class DeviceGrayCS extends ColorSpace {
 | 
				
			|||||||
        'DeviceGrayCS.getRgbBuffer: Unsupported "dest" type.'
 | 
					        'DeviceGrayCS.getRgbBuffer: Unsupported "dest" type.'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let scale = 255 / ((1 << bits) - 1);
 | 
					    const scale = 255 / ((1 << bits) - 1);
 | 
				
			||||||
    let j = srcOffset,
 | 
					    let j = srcOffset,
 | 
				
			||||||
      q = destOffset;
 | 
					      q = destOffset;
 | 
				
			||||||
    for (let i = 0; i < count; ++i) {
 | 
					    for (let i = 0; i < count; ++i) {
 | 
				
			||||||
      let c = scale * src[j++];
 | 
					      const c = scale * src[j++];
 | 
				
			||||||
      dest[q++] = c;
 | 
					      dest[q++] = c;
 | 
				
			||||||
      dest[q++] = c;
 | 
					      dest[q++] = c;
 | 
				
			||||||
      dest[q++] = c;
 | 
					      dest[q++] = c;
 | 
				
			||||||
@ -747,7 +747,7 @@ class DeviceRgbCS extends ColorSpace {
 | 
				
			|||||||
      dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
 | 
					      dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let scale = 255 / ((1 << bits) - 1);
 | 
					    const scale = 255 / ((1 << bits) - 1);
 | 
				
			||||||
    let j = srcOffset,
 | 
					    let j = srcOffset,
 | 
				
			||||||
      q = destOffset;
 | 
					      q = destOffset;
 | 
				
			||||||
    for (let i = 0; i < count; ++i) {
 | 
					    for (let i = 0; i < count; ++i) {
 | 
				
			||||||
@ -778,10 +778,10 @@ const DeviceCmykCS = (function DeviceCmykCSClosure() {
 | 
				
			|||||||
  // CMYK color conversion using the estimation below:
 | 
					  // CMYK color conversion using the estimation below:
 | 
				
			||||||
  //   f(A, B,.. N) = Acc+Bcm+Ccy+Dck+c+Fmm+Gmy+Hmk+Im+Jyy+Kyk+Ly+Mkk+Nk+255
 | 
					  //   f(A, B,.. N) = Acc+Bcm+Ccy+Dck+c+Fmm+Gmy+Hmk+Im+Jyy+Kyk+Ly+Mkk+Nk+255
 | 
				
			||||||
  function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
 | 
					  function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
 | 
				
			||||||
    let c = src[srcOffset] * srcScale;
 | 
					    const c = src[srcOffset] * srcScale;
 | 
				
			||||||
    let m = src[srcOffset + 1] * srcScale;
 | 
					    const m = src[srcOffset + 1] * srcScale;
 | 
				
			||||||
    let y = src[srcOffset + 2] * srcScale;
 | 
					    const y = src[srcOffset + 2] * srcScale;
 | 
				
			||||||
    let k = src[srcOffset + 3] * srcScale;
 | 
					    const k = src[srcOffset + 3] * srcScale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dest[destOffset] =
 | 
					    dest[destOffset] =
 | 
				
			||||||
      255 +
 | 
					      255 +
 | 
				
			||||||
@ -864,7 +864,7 @@ const DeviceCmykCS = (function DeviceCmykCSClosure() {
 | 
				
			|||||||
          'DeviceCmykCS.getRgbBuffer: Unsupported "dest" type.'
 | 
					          'DeviceCmykCS.getRgbBuffer: Unsupported "dest" type.'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let scale = 1 / ((1 << bits) - 1);
 | 
					      const scale = 1 / ((1 << bits) - 1);
 | 
				
			||||||
      for (let i = 0; i < count; i++) {
 | 
					      for (let i = 0; i < count; i++) {
 | 
				
			||||||
        convertToRgb(src, srcOffset, scale, dest, destOffset);
 | 
					        convertToRgb(src, srcOffset, scale, dest, destOffset);
 | 
				
			||||||
        srcOffset += 4;
 | 
					        srcOffset += 4;
 | 
				
			||||||
@ -888,15 +888,15 @@ const CalGrayCS = (function CalGrayCSClosure() {
 | 
				
			|||||||
  function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
 | 
					  function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
 | 
				
			||||||
    // A represents a gray component of a calibrated gray space.
 | 
					    // A represents a gray component of a calibrated gray space.
 | 
				
			||||||
    // A <---> AG in the spec
 | 
					    // A <---> AG in the spec
 | 
				
			||||||
    let A = src[srcOffset] * scale;
 | 
					    const A = src[srcOffset] * scale;
 | 
				
			||||||
    let AG = Math.pow(A, cs.G);
 | 
					    const AG = Math.pow(A, cs.G);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Computes L as per spec. ( = cs.YW * AG )
 | 
					    // Computes L as per spec. ( = cs.YW * AG )
 | 
				
			||||||
    // Except if other than default BlackPoint values are used.
 | 
					    // Except if other than default BlackPoint values are used.
 | 
				
			||||||
    let L = cs.YW * AG;
 | 
					    const L = cs.YW * AG;
 | 
				
			||||||
    // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
 | 
					    // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
 | 
				
			||||||
    // Convert values to rgb range [0, 255].
 | 
					    // Convert values to rgb range [0, 255].
 | 
				
			||||||
    let val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0);
 | 
					    const val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0);
 | 
				
			||||||
    dest[destOffset] = val;
 | 
					    dest[destOffset] = val;
 | 
				
			||||||
    dest[destOffset + 1] = val;
 | 
					    dest[destOffset + 1] = val;
 | 
				
			||||||
    dest[destOffset + 2] = val;
 | 
					    dest[destOffset + 2] = val;
 | 
				
			||||||
@ -977,7 +977,7 @@ const CalGrayCS = (function CalGrayCSClosure() {
 | 
				
			|||||||
          'CalGrayCS.getRgbBuffer: Unsupported "dest" type.'
 | 
					          'CalGrayCS.getRgbBuffer: Unsupported "dest" type.'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let scale = 1 / ((1 << bits) - 1);
 | 
					      const scale = 1 / ((1 << bits) - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for (let i = 0; i < count; ++i) {
 | 
					      for (let i = 0; i < count; ++i) {
 | 
				
			||||||
        convertToRgb(this, src, srcOffset, dest, destOffset, scale);
 | 
					        convertToRgb(this, src, srcOffset, dest, destOffset, scale);
 | 
				
			||||||
@ -1022,9 +1022,9 @@ const CalRGBCS = (function CalRGBCSClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
 | 
					  const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let tempNormalizeMatrix = new Float32Array(3);
 | 
					  const tempNormalizeMatrix = new Float32Array(3);
 | 
				
			||||||
  let tempConvertMatrix1 = new Float32Array(3);
 | 
					  const tempConvertMatrix1 = new Float32Array(3);
 | 
				
			||||||
  let tempConvertMatrix2 = new Float32Array(3);
 | 
					  const tempConvertMatrix2 = new Float32Array(3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
 | 
					  const DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1090,25 +1090,25 @@ const CalRGBCS = (function CalRGBCSClosure() {
 | 
				
			|||||||
    // http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/sdk/
 | 
					    // http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/sdk/
 | 
				
			||||||
    // AdobeBPC.pdf.
 | 
					    // AdobeBPC.pdf.
 | 
				
			||||||
    // The destination blackPoint is the default blackPoint [0, 0, 0].
 | 
					    // The destination blackPoint is the default blackPoint [0, 0, 0].
 | 
				
			||||||
    let zeroDecodeL = decodeL(0);
 | 
					    const zeroDecodeL = decodeL(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let X_DST = zeroDecodeL;
 | 
					    const X_DST = zeroDecodeL;
 | 
				
			||||||
    let X_SRC = decodeL(sourceBlackPoint[0]);
 | 
					    const X_SRC = decodeL(sourceBlackPoint[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let Y_DST = zeroDecodeL;
 | 
					    const Y_DST = zeroDecodeL;
 | 
				
			||||||
    let Y_SRC = decodeL(sourceBlackPoint[1]);
 | 
					    const Y_SRC = decodeL(sourceBlackPoint[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let Z_DST = zeroDecodeL;
 | 
					    const Z_DST = zeroDecodeL;
 | 
				
			||||||
    let Z_SRC = decodeL(sourceBlackPoint[2]);
 | 
					    const Z_SRC = decodeL(sourceBlackPoint[2]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let X_Scale = (1 - X_DST) / (1 - X_SRC);
 | 
					    const X_Scale = (1 - X_DST) / (1 - X_SRC);
 | 
				
			||||||
    let X_Offset = 1 - X_Scale;
 | 
					    const X_Offset = 1 - X_Scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
 | 
					    const Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
 | 
				
			||||||
    let Y_Offset = 1 - Y_Scale;
 | 
					    const Y_Offset = 1 - Y_Scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
 | 
					    const Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
 | 
				
			||||||
    let Z_Offset = 1 - Z_Scale;
 | 
					    const Z_Offset = 1 - Z_Scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
 | 
					    result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
 | 
				
			||||||
    result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
 | 
					    result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
 | 
				
			||||||
@ -1125,20 +1125,20 @@ const CalRGBCS = (function CalRGBCSClosure() {
 | 
				
			|||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let LMS = result;
 | 
					    const LMS = result;
 | 
				
			||||||
    matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
 | 
					    matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let LMS_Flat = tempNormalizeMatrix;
 | 
					    const LMS_Flat = tempNormalizeMatrix;
 | 
				
			||||||
    convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
 | 
					    convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
 | 
					    matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
 | 
					  function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
 | 
				
			||||||
    let LMS = result;
 | 
					    const LMS = result;
 | 
				
			||||||
    matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
 | 
					    matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let LMS_D65 = tempNormalizeMatrix;
 | 
					    const LMS_D65 = tempNormalizeMatrix;
 | 
				
			||||||
    convertToD65(sourceWhitePoint, LMS, LMS_D65);
 | 
					    convertToD65(sourceWhitePoint, LMS, LMS_D65);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
 | 
					    matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
 | 
				
			||||||
@ -1147,41 +1147,41 @@ const CalRGBCS = (function CalRGBCSClosure() {
 | 
				
			|||||||
  function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
 | 
					  function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
 | 
				
			||||||
    // A, B and C represent a red, green and blue components of a calibrated
 | 
					    // A, B and C represent a red, green and blue components of a calibrated
 | 
				
			||||||
    // rgb space.
 | 
					    // rgb space.
 | 
				
			||||||
    let A = adjustToRange(0, 1, src[srcOffset] * scale);
 | 
					    const A = adjustToRange(0, 1, src[srcOffset] * scale);
 | 
				
			||||||
    let B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
 | 
					    const B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
 | 
				
			||||||
    let C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
 | 
					    const C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // A <---> AGR in the spec
 | 
					    // A <---> AGR in the spec
 | 
				
			||||||
    // B <---> BGG in the spec
 | 
					    // B <---> BGG in the spec
 | 
				
			||||||
    // C <---> CGB in the spec
 | 
					    // C <---> CGB in the spec
 | 
				
			||||||
    let AGR = Math.pow(A, cs.GR);
 | 
					    const AGR = Math.pow(A, cs.GR);
 | 
				
			||||||
    let BGG = Math.pow(B, cs.GG);
 | 
					    const BGG = Math.pow(B, cs.GG);
 | 
				
			||||||
    let CGB = Math.pow(C, cs.GB);
 | 
					    const CGB = Math.pow(C, cs.GB);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Computes intermediate variables L, M, N as per spec.
 | 
					    // Computes intermediate variables L, M, N as per spec.
 | 
				
			||||||
    // To decode X, Y, Z values map L, M, N directly to them.
 | 
					    // To decode X, Y, Z values map L, M, N directly to them.
 | 
				
			||||||
    let X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
 | 
					    const X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
 | 
				
			||||||
    let Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
 | 
					    const Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
 | 
				
			||||||
    let Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
 | 
					    const Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // The following calculations are based on this document:
 | 
					    // The following calculations are based on this document:
 | 
				
			||||||
    // http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/sdk/
 | 
					    // http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/sdk/
 | 
				
			||||||
    // AdobeBPC.pdf.
 | 
					    // AdobeBPC.pdf.
 | 
				
			||||||
    let XYZ = tempConvertMatrix1;
 | 
					    const XYZ = tempConvertMatrix1;
 | 
				
			||||||
    XYZ[0] = X;
 | 
					    XYZ[0] = X;
 | 
				
			||||||
    XYZ[1] = Y;
 | 
					    XYZ[1] = Y;
 | 
				
			||||||
    XYZ[2] = Z;
 | 
					    XYZ[2] = Z;
 | 
				
			||||||
    let XYZ_Flat = tempConvertMatrix2;
 | 
					    const XYZ_Flat = tempConvertMatrix2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
 | 
					    normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let XYZ_Black = tempConvertMatrix1;
 | 
					    const XYZ_Black = tempConvertMatrix1;
 | 
				
			||||||
    compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
 | 
					    compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let XYZ_D65 = tempConvertMatrix2;
 | 
					    const XYZ_D65 = tempConvertMatrix2;
 | 
				
			||||||
    normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
 | 
					    normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let SRGB = tempConvertMatrix1;
 | 
					    const SRGB = tempConvertMatrix1;
 | 
				
			||||||
    matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
 | 
					    matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Convert the values to rgb range [0, 255].
 | 
					    // Convert the values to rgb range [0, 255].
 | 
				
			||||||
@ -1204,14 +1204,14 @@ const CalRGBCS = (function CalRGBCSClosure() {
 | 
				
			|||||||
      matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
 | 
					      matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Translate arguments to spec variables.
 | 
					      // Translate arguments to spec variables.
 | 
				
			||||||
      let XW = whitePoint[0];
 | 
					      const XW = whitePoint[0];
 | 
				
			||||||
      let YW = whitePoint[1];
 | 
					      const YW = whitePoint[1];
 | 
				
			||||||
      let ZW = whitePoint[2];
 | 
					      const ZW = whitePoint[2];
 | 
				
			||||||
      this.whitePoint = whitePoint;
 | 
					      this.whitePoint = whitePoint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let XB = blackPoint[0];
 | 
					      const XB = blackPoint[0];
 | 
				
			||||||
      let YB = blackPoint[1];
 | 
					      const YB = blackPoint[1];
 | 
				
			||||||
      let ZB = blackPoint[2];
 | 
					      const ZB = blackPoint[2];
 | 
				
			||||||
      this.blackPoint = blackPoint;
 | 
					      this.blackPoint = blackPoint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.GR = gamma[0];
 | 
					      this.GR = gamma[0];
 | 
				
			||||||
@ -1276,7 +1276,7 @@ const CalRGBCS = (function CalRGBCSClosure() {
 | 
				
			|||||||
          'CalRGBCS.getRgbBuffer: Unsupported "dest" type.'
 | 
					          'CalRGBCS.getRgbBuffer: Unsupported "dest" type.'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let scale = 1 / ((1 << bits) - 1);
 | 
					      const scale = 1 / ((1 << bits) - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for (let i = 0; i < count; ++i) {
 | 
					      for (let i = 0; i < count; ++i) {
 | 
				
			||||||
        convertToRgb(this, src, srcOffset, dest, destOffset, scale);
 | 
					        convertToRgb(this, src, srcOffset, dest, destOffset, scale);
 | 
				
			||||||
@ -1343,13 +1343,13 @@ const LabCS = (function LabCSClosure() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Computes intermediate variables X,Y,Z as per spec
 | 
					    // Computes intermediate variables X,Y,Z as per spec
 | 
				
			||||||
    let M = (Ls + 16) / 116;
 | 
					    const M = (Ls + 16) / 116;
 | 
				
			||||||
    let L = M + as / 500;
 | 
					    const L = M + as / 500;
 | 
				
			||||||
    let N = M - bs / 200;
 | 
					    const N = M - bs / 200;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let X = cs.XW * fn_g(L);
 | 
					    const X = cs.XW * fn_g(L);
 | 
				
			||||||
    let Y = cs.YW * fn_g(M);
 | 
					    const Y = cs.YW * fn_g(M);
 | 
				
			||||||
    let Z = cs.ZW * fn_g(N);
 | 
					    const Z = cs.ZW * fn_g(N);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let r, g, b;
 | 
					    let r, g, b;
 | 
				
			||||||
    // Using different conversions for D50 and D65 white points,
 | 
					    // Using different conversions for D50 and D65 white points,
 | 
				
			||||||
@ -1442,7 +1442,7 @@ const LabCS = (function LabCSClosure() {
 | 
				
			|||||||
          'LabCS.getRgbBuffer: Unsupported "dest" type.'
 | 
					          'LabCS.getRgbBuffer: Unsupported "dest" type.'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let maxVal = (1 << bits) - 1;
 | 
					      const maxVal = (1 << bits) - 1;
 | 
				
			||||||
      for (let i = 0; i < count; i++) {
 | 
					      for (let i = 0; i < count; i++) {
 | 
				
			||||||
        convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
 | 
					        convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
 | 
				
			||||||
        srcOffset += 3;
 | 
					        srcOffset += 3;
 | 
				
			||||||
 | 
				
			|||||||
@ -825,7 +825,7 @@ class AESBaseCipher {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  _decrypt(input, key) {
 | 
					  _decrypt(input, key) {
 | 
				
			||||||
    let t, u, v;
 | 
					    let t, u, v;
 | 
				
			||||||
    let state = new Uint8Array(16);
 | 
					    const state = new Uint8Array(16);
 | 
				
			||||||
    state.set(input);
 | 
					    state.set(input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // AddRoundKey
 | 
					    // AddRoundKey
 | 
				
			||||||
@ -862,10 +862,10 @@ class AESBaseCipher {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      // InvMixColumns
 | 
					      // InvMixColumns
 | 
				
			||||||
      for (let j = 0; j < 16; j += 4) {
 | 
					      for (let j = 0; j < 16; j += 4) {
 | 
				
			||||||
        let s0 = this._mix[state[j]];
 | 
					        const s0 = this._mix[state[j]];
 | 
				
			||||||
        let s1 = this._mix[state[j + 1]];
 | 
					        const s1 = this._mix[state[j + 1]];
 | 
				
			||||||
        let s2 = this._mix[state[j + 2]];
 | 
					        const s2 = this._mix[state[j + 2]];
 | 
				
			||||||
        let s3 = this._mix[state[j + 3]];
 | 
					        const s3 = this._mix[state[j + 3]];
 | 
				
			||||||
        t =
 | 
					        t =
 | 
				
			||||||
          s0 ^
 | 
					          s0 ^
 | 
				
			||||||
          (s1 >>> 8) ^
 | 
					          (s1 >>> 8) ^
 | 
				
			||||||
@ -912,7 +912,7 @@ class AESBaseCipher {
 | 
				
			|||||||
    const s = this._s;
 | 
					    const s = this._s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let t, u, v;
 | 
					    let t, u, v;
 | 
				
			||||||
    let state = new Uint8Array(16);
 | 
					    const state = new Uint8Array(16);
 | 
				
			||||||
    state.set(input);
 | 
					    state.set(input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (let j = 0; j < 16; ++j) {
 | 
					    for (let j = 0; j < 16; ++j) {
 | 
				
			||||||
@ -946,10 +946,10 @@ class AESBaseCipher {
 | 
				
			|||||||
      state[15] = t;
 | 
					      state[15] = t;
 | 
				
			||||||
      // MixColumns
 | 
					      // MixColumns
 | 
				
			||||||
      for (let j = 0; j < 16; j += 4) {
 | 
					      for (let j = 0; j < 16; j += 4) {
 | 
				
			||||||
        let s0 = state[j + 0];
 | 
					        const s0 = state[j + 0];
 | 
				
			||||||
        let s1 = state[j + 1];
 | 
					        const s1 = state[j + 1];
 | 
				
			||||||
        let s2 = state[j + 2];
 | 
					        const s2 = state[j + 2];
 | 
				
			||||||
        let s3 = state[j + 3];
 | 
					        const s3 = state[j + 3];
 | 
				
			||||||
        t = s0 ^ s1 ^ s2 ^ s3;
 | 
					        t = s0 ^ s1 ^ s2 ^ s3;
 | 
				
			||||||
        state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
 | 
					        state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
 | 
				
			||||||
        state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
 | 
					        state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
 | 
				
			||||||
@ -993,7 +993,7 @@ class AESBaseCipher {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  _decryptBlock2(data, finalize) {
 | 
					  _decryptBlock2(data, finalize) {
 | 
				
			||||||
    let sourceLength = data.length;
 | 
					    const sourceLength = data.length;
 | 
				
			||||||
    let buffer = this.buffer,
 | 
					    let buffer = this.buffer,
 | 
				
			||||||
      bufferLength = this.bufferPosition;
 | 
					      bufferLength = this.bufferPosition;
 | 
				
			||||||
    let result = [],
 | 
					    let result = [],
 | 
				
			||||||
@ -1006,7 +1006,7 @@ class AESBaseCipher {
 | 
				
			|||||||
        continue;
 | 
					        continue;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      // buffer is full, decrypting
 | 
					      // buffer is full, decrypting
 | 
				
			||||||
      let plain = this._decrypt(buffer, this._key);
 | 
					      const plain = this._decrypt(buffer, this._key);
 | 
				
			||||||
      // xor-ing the IV vector to get plain text
 | 
					      // xor-ing the IV vector to get plain text
 | 
				
			||||||
      for (let j = 0; j < 16; ++j) {
 | 
					      for (let j = 0; j < 16; ++j) {
 | 
				
			||||||
        plain[j] ^= iv[j];
 | 
					        plain[j] ^= iv[j];
 | 
				
			||||||
@ -1027,7 +1027,7 @@ class AESBaseCipher {
 | 
				
			|||||||
    let outputLength = 16 * result.length;
 | 
					    let outputLength = 16 * result.length;
 | 
				
			||||||
    if (finalize) {
 | 
					    if (finalize) {
 | 
				
			||||||
      // undo a padding that is described in RFC 2898
 | 
					      // undo a padding that is described in RFC 2898
 | 
				
			||||||
      let lastBlock = result[result.length - 1];
 | 
					      const lastBlock = result[result.length - 1];
 | 
				
			||||||
      let psLen = lastBlock[15];
 | 
					      let psLen = lastBlock[15];
 | 
				
			||||||
      if (psLen <= 16) {
 | 
					      if (psLen <= 16) {
 | 
				
			||||||
        for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
 | 
					        for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
 | 
				
			||||||
@ -1041,7 +1041,7 @@ class AESBaseCipher {
 | 
				
			|||||||
        result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
 | 
					        result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let output = new Uint8Array(outputLength);
 | 
					    const output = new Uint8Array(outputLength);
 | 
				
			||||||
    for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
 | 
					    for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
 | 
				
			||||||
      output.set(result[i], j);
 | 
					      output.set(result[i], j);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1049,7 +1049,7 @@ class AESBaseCipher {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  decryptBlock(data, finalize, iv = null) {
 | 
					  decryptBlock(data, finalize, iv = null) {
 | 
				
			||||||
    let sourceLength = data.length;
 | 
					    const sourceLength = data.length;
 | 
				
			||||||
    let buffer = this.buffer,
 | 
					    let buffer = this.buffer,
 | 
				
			||||||
      bufferLength = this.bufferPosition;
 | 
					      bufferLength = this.bufferPosition;
 | 
				
			||||||
    // If an IV is not supplied, wait for IV values. They are at the start
 | 
					    // If an IV is not supplied, wait for IV values. They are at the start
 | 
				
			||||||
@ -1080,10 +1080,10 @@ class AESBaseCipher {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  encrypt(data, iv) {
 | 
					  encrypt(data, iv) {
 | 
				
			||||||
    let sourceLength = data.length;
 | 
					    const sourceLength = data.length;
 | 
				
			||||||
    let buffer = this.buffer,
 | 
					    let buffer = this.buffer,
 | 
				
			||||||
      bufferLength = this.bufferPosition;
 | 
					      bufferLength = this.bufferPosition;
 | 
				
			||||||
    let result = [];
 | 
					    const result = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!iv) {
 | 
					    if (!iv) {
 | 
				
			||||||
      iv = new Uint8Array(16);
 | 
					      iv = new Uint8Array(16);
 | 
				
			||||||
@ -1099,7 +1099,7 @@ class AESBaseCipher {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // buffer is full, encrypting
 | 
					      // buffer is full, encrypting
 | 
				
			||||||
      let cipher = this._encrypt(buffer, this._key);
 | 
					      const cipher = this._encrypt(buffer, this._key);
 | 
				
			||||||
      iv = cipher;
 | 
					      iv = cipher;
 | 
				
			||||||
      result.push(cipher);
 | 
					      result.push(cipher);
 | 
				
			||||||
      buffer = new Uint8Array(16);
 | 
					      buffer = new Uint8Array(16);
 | 
				
			||||||
@ -1113,8 +1113,8 @@ class AESBaseCipher {
 | 
				
			|||||||
      return new Uint8Array(0);
 | 
					      return new Uint8Array(0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // combining plain text blocks into one
 | 
					    // combining plain text blocks into one
 | 
				
			||||||
    let outputLength = 16 * result.length;
 | 
					    const outputLength = 16 * result.length;
 | 
				
			||||||
    let output = new Uint8Array(outputLength);
 | 
					    const output = new Uint8Array(outputLength);
 | 
				
			||||||
    for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
 | 
					    for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
 | 
				
			||||||
      output.set(result[i], j);
 | 
					      output.set(result[i], j);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1163,7 +1163,7 @@ class AES128Cipher extends AESBaseCipher {
 | 
				
			|||||||
    const s = this._s;
 | 
					    const s = this._s;
 | 
				
			||||||
    const rcon = this._rcon;
 | 
					    const rcon = this._rcon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let result = new Uint8Array(b);
 | 
					    const result = new Uint8Array(b);
 | 
				
			||||||
    result.set(cipherKey);
 | 
					    result.set(cipherKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (let j = 16, i = 1; j < b; ++i) {
 | 
					    for (let j = 16, i = 1; j < b; ++i) {
 | 
				
			||||||
@ -1208,7 +1208,7 @@ class AES256Cipher extends AESBaseCipher {
 | 
				
			|||||||
    const b = 240;
 | 
					    const b = 240;
 | 
				
			||||||
    const s = this._s;
 | 
					    const s = this._s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let result = new Uint8Array(b);
 | 
					    const result = new Uint8Array(b);
 | 
				
			||||||
    result.set(cipherKey);
 | 
					    result.set(cipherKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let r = 1;
 | 
					    let r = 1;
 | 
				
			||||||
 | 
				
			|||||||
@ -472,7 +472,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
        !(image instanceof JpegStream) &&
 | 
					        !(image instanceof JpegStream) &&
 | 
				
			||||||
        w + h < SMALL_IMAGE_DIMENSIONS
 | 
					        w + h < SMALL_IMAGE_DIMENSIONS
 | 
				
			||||||
      ) {
 | 
					      ) {
 | 
				
			||||||
        let imageObj = new PDFImage({
 | 
					        const imageObj = new PDFImage({
 | 
				
			||||||
          xref: this.xref,
 | 
					          xref: this.xref,
 | 
				
			||||||
          res: resources,
 | 
					          res: resources,
 | 
				
			||||||
          image,
 | 
					          image,
 | 
				
			||||||
@ -652,7 +652,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
      // we will build a map of integer values in range 0..255 to be fast.
 | 
					      // we will build a map of integer values in range 0..255 to be fast.
 | 
				
			||||||
      var transferObj = smask.get("TR");
 | 
					      var transferObj = smask.get("TR");
 | 
				
			||||||
      if (isPDFFunction(transferObj)) {
 | 
					      if (isPDFFunction(transferObj)) {
 | 
				
			||||||
        let transferFn = this.pdfFunctionFactory.create(transferObj);
 | 
					        const transferFn = this.pdfFunctionFactory.create(transferObj);
 | 
				
			||||||
        var transferMap = new Uint8Array(256);
 | 
					        var transferMap = new Uint8Array(256);
 | 
				
			||||||
        var tmp = new Float32Array(1);
 | 
					        var tmp = new Float32Array(1);
 | 
				
			||||||
        for (var i = 0; i < 256; i++) {
 | 
					        for (var i = 0; i < 256; i++) {
 | 
				
			||||||
@ -683,11 +683,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
      task
 | 
					      task
 | 
				
			||||||
    ) {
 | 
					    ) {
 | 
				
			||||||
      // Create an IR of the pattern code.
 | 
					      // Create an IR of the pattern code.
 | 
				
			||||||
      let tilingOpList = new OperatorList();
 | 
					      const tilingOpList = new OperatorList();
 | 
				
			||||||
      // Merge the available resources, to prevent issues when the patternDict
 | 
					      // Merge the available resources, to prevent issues when the patternDict
 | 
				
			||||||
      // is missing some /Resources entries (fixes issue6541.pdf).
 | 
					      // is missing some /Resources entries (fixes issue6541.pdf).
 | 
				
			||||||
      let resourcesArray = [patternDict.get("Resources"), resources];
 | 
					      const resourcesArray = [patternDict.get("Resources"), resources];
 | 
				
			||||||
      let patternResources = Dict.merge(this.xref, resourcesArray);
 | 
					      const patternResources = Dict.merge(this.xref, resourcesArray);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return this.getOperatorList({
 | 
					      return this.getOperatorList({
 | 
				
			||||||
        stream: pattern,
 | 
					        stream: pattern,
 | 
				
			||||||
@ -807,8 +807,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
      var gStateKeys = gState.getKeys();
 | 
					      var gStateKeys = gState.getKeys();
 | 
				
			||||||
      var promise = Promise.resolve();
 | 
					      var promise = Promise.resolve();
 | 
				
			||||||
      for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
 | 
					      for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
 | 
				
			||||||
        let key = gStateKeys[i];
 | 
					        const key = gStateKeys[i];
 | 
				
			||||||
        let value = gState.get(key);
 | 
					        const value = gState.get(key);
 | 
				
			||||||
        switch (key) {
 | 
					        switch (key) {
 | 
				
			||||||
          case "Type":
 | 
					          case "Type":
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
@ -1206,7 +1206,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return new Promise(function promiseBody(resolve, reject) {
 | 
					      return new Promise(function promiseBody(resolve, reject) {
 | 
				
			||||||
        let next = function(promise) {
 | 
					        const next = function(promise) {
 | 
				
			||||||
          Promise.all([promise, operatorList.ready]).then(function() {
 | 
					          Promise.all([promise, operatorList.ready]).then(function() {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
              promiseBody(resolve, reject);
 | 
					              promiseBody(resolve, reject);
 | 
				
			||||||
@ -1252,7 +1252,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
                    );
 | 
					                    );
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  let xobj = xobjs.get(name);
 | 
					                  const xobj = xobjs.get(name);
 | 
				
			||||||
                  if (!xobj) {
 | 
					                  if (!xobj) {
 | 
				
			||||||
                    operatorList.addOp(fn, args);
 | 
					                    operatorList.addOp(fn, args);
 | 
				
			||||||
                    resolveXObject();
 | 
					                    resolveXObject();
 | 
				
			||||||
@ -1262,7 +1262,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
                    throw new FormatError("XObject should be a stream");
 | 
					                    throw new FormatError("XObject should be a stream");
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  let type = xobj.dict.get("Subtype");
 | 
					                  const type = xobj.dict.get("Subtype");
 | 
				
			||||||
                  if (!isName(type)) {
 | 
					                  if (!isName(type)) {
 | 
				
			||||||
                    throw new FormatError("XObject should have a Name subtype");
 | 
					                    throw new FormatError("XObject should have a Name subtype");
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
@ -1887,7 +1887,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      function enqueueChunk() {
 | 
					      function enqueueChunk() {
 | 
				
			||||||
        let length = textContent.items.length;
 | 
					        const length = textContent.items.length;
 | 
				
			||||||
        if (length > 0) {
 | 
					        if (length > 0) {
 | 
				
			||||||
          sink.enqueue(textContent, length);
 | 
					          sink.enqueue(textContent, length);
 | 
				
			||||||
          textContent.items = [];
 | 
					          textContent.items = [];
 | 
				
			||||||
@ -1898,7 +1898,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
      var timeSlotManager = new TimeSlotManager();
 | 
					      var timeSlotManager = new TimeSlotManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return new Promise(function promiseBody(resolve, reject) {
 | 
					      return new Promise(function promiseBody(resolve, reject) {
 | 
				
			||||||
        let next = function(promise) {
 | 
					        const next = function(promise) {
 | 
				
			||||||
          enqueueChunk();
 | 
					          enqueueChunk();
 | 
				
			||||||
          Promise.all([promise, sink.ready]).then(function() {
 | 
					          Promise.all([promise, sink.ready]).then(function() {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
@ -2142,7 +2142,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
                    );
 | 
					                    );
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  let xobj = xobjs.get(name);
 | 
					                  const xobj = xobjs.get(name);
 | 
				
			||||||
                  if (!xobj) {
 | 
					                  if (!xobj) {
 | 
				
			||||||
                    resolveXObject();
 | 
					                    resolveXObject();
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
@ -2151,7 +2151,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
                    throw new FormatError("XObject should be a stream");
 | 
					                    throw new FormatError("XObject should be a stream");
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  let type = xobj.dict.get("Subtype");
 | 
					                  const type = xobj.dict.get("Subtype");
 | 
				
			||||||
                  if (!isName(type)) {
 | 
					                  if (!isName(type)) {
 | 
				
			||||||
                    throw new FormatError("XObject should have a Name subtype");
 | 
					                    throw new FormatError("XObject should have a Name subtype");
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
@ -2167,10 +2167,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
                  // data can otherwise prevent `restore` operators from
 | 
					                  // data can otherwise prevent `restore` operators from
 | 
				
			||||||
                  // executing.
 | 
					                  // executing.
 | 
				
			||||||
                  // NOTE: Only an issue when `options.ignoreErrors === true`.
 | 
					                  // NOTE: Only an issue when `options.ignoreErrors === true`.
 | 
				
			||||||
                  let currentState = stateManager.state.clone();
 | 
					                  const currentState = stateManager.state.clone();
 | 
				
			||||||
                  let xObjStateManager = new StateManager(currentState);
 | 
					                  const xObjStateManager = new StateManager(currentState);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  let matrix = xobj.dict.getArray("Matrix");
 | 
					                  const matrix = xobj.dict.getArray("Matrix");
 | 
				
			||||||
                  if (Array.isArray(matrix) && matrix.length === 6) {
 | 
					                  if (Array.isArray(matrix) && matrix.length === 6) {
 | 
				
			||||||
                    xObjStateManager.transform(matrix);
 | 
					                    xObjStateManager.transform(matrix);
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
@ -2178,7 +2178,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
                  // Enqueue the `textContent` chunk before parsing the /Form
 | 
					                  // Enqueue the `textContent` chunk before parsing the /Form
 | 
				
			||||||
                  // XObject.
 | 
					                  // XObject.
 | 
				
			||||||
                  enqueueChunk();
 | 
					                  enqueueChunk();
 | 
				
			||||||
                  let sinkWrapper = {
 | 
					                  const sinkWrapper = {
 | 
				
			||||||
                    enqueueInvoked: false,
 | 
					                    enqueueInvoked: false,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    enqueue(chunk, size) {
 | 
					                    enqueue(chunk, size) {
 | 
				
			||||||
@ -2416,10 +2416,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
      let toUnicode = [],
 | 
					      let toUnicode = [],
 | 
				
			||||||
        charcode,
 | 
					        charcode,
 | 
				
			||||||
        glyphName;
 | 
					        glyphName;
 | 
				
			||||||
      let encoding = properties.defaultEncoding.slice();
 | 
					      const encoding = properties.defaultEncoding.slice();
 | 
				
			||||||
      let baseEncodingName = properties.baseEncodingName;
 | 
					      const baseEncodingName = properties.baseEncodingName;
 | 
				
			||||||
      // Merge in the differences array.
 | 
					      // Merge in the differences array.
 | 
				
			||||||
      let differences = properties.differences;
 | 
					      const differences = properties.differences;
 | 
				
			||||||
      for (charcode in differences) {
 | 
					      for (charcode in differences) {
 | 
				
			||||||
        glyphName = differences[charcode];
 | 
					        glyphName = differences[charcode];
 | 
				
			||||||
        if (glyphName === ".notdef") {
 | 
					        if (glyphName === ".notdef") {
 | 
				
			||||||
@ -2429,7 +2429,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        encoding[charcode] = glyphName;
 | 
					        encoding[charcode] = glyphName;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let glyphsUnicodeMap = getGlyphsUnicode();
 | 
					      const glyphsUnicodeMap = getGlyphsUnicode();
 | 
				
			||||||
      for (charcode in encoding) {
 | 
					      for (charcode in encoding) {
 | 
				
			||||||
        // a) Map the character code to a character name.
 | 
					        // a) Map the character code to a character name.
 | 
				
			||||||
        glyphName = encoding[charcode];
 | 
					        glyphName = encoding[charcode];
 | 
				
			||||||
@ -2482,7 +2482,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
              break;
 | 
					              break;
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
              // 'uniXXXX'/'uXXXX{XX}' glyphs
 | 
					              // 'uniXXXX'/'uXXXX{XX}' glyphs
 | 
				
			||||||
              let unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
 | 
					              const unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
 | 
				
			||||||
              if (unicode !== -1) {
 | 
					              if (unicode !== -1) {
 | 
				
			||||||
                code = unicode;
 | 
					                code = unicode;
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
@ -2492,7 +2492,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
            // equals `charcode`, using the glyph defined in the baseEncoding
 | 
					            // equals `charcode`, using the glyph defined in the baseEncoding
 | 
				
			||||||
            // seems to yield a better `toUnicode` mapping (fixes issue 5070).
 | 
					            // seems to yield a better `toUnicode` mapping (fixes issue 5070).
 | 
				
			||||||
            if (baseEncodingName && code === +charcode) {
 | 
					            if (baseEncodingName && code === +charcode) {
 | 
				
			||||||
              let baseEncoding = getEncoding(baseEncodingName);
 | 
					              const baseEncoding = getEncoding(baseEncodingName);
 | 
				
			||||||
              if (baseEncoding && (glyphName = baseEncoding[charcode])) {
 | 
					              if (baseEncoding && (glyphName = baseEncoding[charcode])) {
 | 
				
			||||||
                toUnicode[charcode] = String.fromCharCode(
 | 
					                toUnicode[charcode] = String.fromCharCode(
 | 
				
			||||||
                  glyphsUnicodeMap[glyphName]
 | 
					                  glyphsUnicodeMap[glyphName]
 | 
				
			||||||
@ -2562,12 +2562,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
        // b) Obtain the registry and ordering of the character collection used
 | 
					        // b) Obtain the registry and ordering of the character collection used
 | 
				
			||||||
        // by the font’s CMap (for example, Adobe and Japan1) from its
 | 
					        // by the font’s CMap (for example, Adobe and Japan1) from its
 | 
				
			||||||
        // CIDSystemInfo dictionary.
 | 
					        // CIDSystemInfo dictionary.
 | 
				
			||||||
        let registry = properties.cidSystemInfo.registry;
 | 
					        const registry = properties.cidSystemInfo.registry;
 | 
				
			||||||
        let ordering = properties.cidSystemInfo.ordering;
 | 
					        const ordering = properties.cidSystemInfo.ordering;
 | 
				
			||||||
        // c) Construct a second CMap name by concatenating the registry and
 | 
					        // c) Construct a second CMap name by concatenating the registry and
 | 
				
			||||||
        // ordering obtained in step (b) in the format registry–ordering–UCS2
 | 
					        // ordering obtained in step (b) in the format registry–ordering–UCS2
 | 
				
			||||||
        // (for example, Adobe–Japan1–UCS2).
 | 
					        // (for example, Adobe–Japan1–UCS2).
 | 
				
			||||||
        let ucs2CMapName = Name.get(registry + "-" + ordering + "-UCS2");
 | 
					        const ucs2CMapName = Name.get(registry + "-" + ordering + "-UCS2");
 | 
				
			||||||
        // d) Obtain the CMap with the name constructed in step (c) (available
 | 
					        // d) Obtain the CMap with the name constructed in step (c) (available
 | 
				
			||||||
        // from the ASN Web site; see the Bibliography).
 | 
					        // from the ASN Web site; see the Bibliography).
 | 
				
			||||||
        return CMapFactory.create({
 | 
					        return CMapFactory.create({
 | 
				
			||||||
@ -2575,15 +2575,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 | 
				
			|||||||
          fetchBuiltInCMap: this.fetchBuiltInCMap,
 | 
					          fetchBuiltInCMap: this.fetchBuiltInCMap,
 | 
				
			||||||
          useCMap: null,
 | 
					          useCMap: null,
 | 
				
			||||||
        }).then(function(ucs2CMap) {
 | 
					        }).then(function(ucs2CMap) {
 | 
				
			||||||
          let cMap = properties.cMap;
 | 
					          const cMap = properties.cMap;
 | 
				
			||||||
          let toUnicode = [];
 | 
					          const toUnicode = [];
 | 
				
			||||||
          cMap.forEach(function(charcode, cid) {
 | 
					          cMap.forEach(function(charcode, cid) {
 | 
				
			||||||
            if (cid > 0xffff) {
 | 
					            if (cid > 0xffff) {
 | 
				
			||||||
              throw new FormatError("Max size of CID is 65,535");
 | 
					              throw new FormatError("Max size of CID is 65,535");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // e) Map the CID obtained in step (a) according to the CMap
 | 
					            // e) Map the CID obtained in step (a) according to the CMap
 | 
				
			||||||
            // obtained in step (d), producing a Unicode value.
 | 
					            // obtained in step (d), producing a Unicode value.
 | 
				
			||||||
            let ucs2 = ucs2CMap.lookup(cid);
 | 
					            const ucs2 = ucs2CMap.lookup(cid);
 | 
				
			||||||
            if (ucs2) {
 | 
					            if (ucs2) {
 | 
				
			||||||
              toUnicode[charcode] = String.fromCharCode(
 | 
					              toUnicode[charcode] = String.fromCharCode(
 | 
				
			||||||
                (ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1)
 | 
					                (ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1)
 | 
				
			||||||
@ -3204,7 +3204,7 @@ var TranslatedFont = (function TranslatedFontClosure() {
 | 
				
			|||||||
      var charProcOperatorList = Object.create(null);
 | 
					      var charProcOperatorList = Object.create(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for (var i = 0, n = charProcKeys.length; i < n; ++i) {
 | 
					      for (var i = 0, n = charProcKeys.length; i < n; ++i) {
 | 
				
			||||||
        let key = charProcKeys[i];
 | 
					        const key = charProcKeys[i];
 | 
				
			||||||
        loadCharProcsPromise = loadCharProcsPromise.then(function() {
 | 
					        loadCharProcsPromise = loadCharProcsPromise.then(function() {
 | 
				
			||||||
          var glyphStream = charProcs.get(key);
 | 
					          var glyphStream = charProcs.get(key);
 | 
				
			||||||
          var operatorList = new OperatorList();
 | 
					          var operatorList = new OperatorList();
 | 
				
			||||||
 | 
				
			|||||||
@ -425,7 +425,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
 | 
				
			|||||||
            n = stack.pop();
 | 
					            n = stack.pop();
 | 
				
			||||||
            subrCode = null;
 | 
					            subrCode = null;
 | 
				
			||||||
            if (font.isCFFCIDFont) {
 | 
					            if (font.isCFFCIDFont) {
 | 
				
			||||||
              let fdIndex = font.fdSelect.getFDIndex(glyphId);
 | 
					              const fdIndex = font.fdSelect.getFDIndex(glyphId);
 | 
				
			||||||
              if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
 | 
					              if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
 | 
				
			||||||
                let fontDict = font.fdArray[fdIndex],
 | 
					                let fontDict = font.fdArray[fdIndex],
 | 
				
			||||||
                  subrs;
 | 
					                  subrs;
 | 
				
			||||||
@ -757,9 +757,9 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
 | 
				
			|||||||
      if (this.isCFFCIDFont) {
 | 
					      if (this.isCFFCIDFont) {
 | 
				
			||||||
        // Top DICT's FontMatrix can be ignored because CFFCompiler always
 | 
					        // Top DICT's FontMatrix can be ignored because CFFCompiler always
 | 
				
			||||||
        // removes it and copies to FDArray DICTs.
 | 
					        // removes it and copies to FDArray DICTs.
 | 
				
			||||||
        let fdIndex = this.fdSelect.getFDIndex(glyphId);
 | 
					        const fdIndex = this.fdSelect.getFDIndex(glyphId);
 | 
				
			||||||
        if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
 | 
					        if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
 | 
				
			||||||
          let fontDict = this.fdArray[fdIndex];
 | 
					          const fontDict = this.fdArray[fdIndex];
 | 
				
			||||||
          fontMatrix = fontDict.getByName("FontMatrix") || FONT_IDENTITY_MATRIX;
 | 
					          fontMatrix = fontDict.getByName("FontMatrix") || FONT_IDENTITY_MATRIX;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          warn("Invalid fd index for glyph index.");
 | 
					          warn("Invalid fd index for glyph index.");
 | 
				
			||||||
 | 
				
			|||||||
@ -294,11 +294,11 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() {
 | 
				
			|||||||
    charCodeOf(value) {
 | 
					    charCodeOf(value) {
 | 
				
			||||||
      // `Array.prototype.indexOf` is *extremely* inefficient for arrays which
 | 
					      // `Array.prototype.indexOf` is *extremely* inefficient for arrays which
 | 
				
			||||||
      // are both very sparse and very large (see issue8372.pdf).
 | 
					      // are both very sparse and very large (see issue8372.pdf).
 | 
				
			||||||
      let map = this._map;
 | 
					      const map = this._map;
 | 
				
			||||||
      if (map.length <= 0x10000) {
 | 
					      if (map.length <= 0x10000) {
 | 
				
			||||||
        return map.indexOf(value);
 | 
					        return map.indexOf(value);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      for (let charCode in map) {
 | 
					      for (const charCode in map) {
 | 
				
			||||||
        if (map[charCode] === value) {
 | 
					        if (map[charCode] === value) {
 | 
				
			||||||
          return charCode | 0;
 | 
					          return charCode | 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -697,7 +697,7 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function isTrueTypeCollectionFile(file) {
 | 
					  function isTrueTypeCollectionFile(file) {
 | 
				
			||||||
    let header = file.peekBytes(4);
 | 
					    const header = file.peekBytes(4);
 | 
				
			||||||
    return bytesToString(header) === "ttcf";
 | 
					    return bytesToString(header) === "ttcf";
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1311,7 +1311,7 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
            map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
 | 
					            map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        } else if (/Calibri/i.test(name)) {
 | 
					        } else if (/Calibri/i.test(name)) {
 | 
				
			||||||
          let SupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri();
 | 
					          const SupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri();
 | 
				
			||||||
          for (charCode in SupplementalGlyphMapForCalibri) {
 | 
					          for (charCode in SupplementalGlyphMapForCalibri) {
 | 
				
			||||||
            map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
 | 
					            map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -1397,7 +1397,7 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
      ];
 | 
					      ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      function readTables(file, numTables) {
 | 
					      function readTables(file, numTables) {
 | 
				
			||||||
        let tables = Object.create(null);
 | 
					        const tables = Object.create(null);
 | 
				
			||||||
        tables["OS/2"] = null;
 | 
					        tables["OS/2"] = null;
 | 
				
			||||||
        tables["cmap"] = null;
 | 
					        tables["cmap"] = null;
 | 
				
			||||||
        tables["head"] = null;
 | 
					        tables["head"] = null;
 | 
				
			||||||
@ -1408,7 +1408,7 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
        tables["post"] = null;
 | 
					        tables["post"] = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (let i = 0; i < numTables; i++) {
 | 
					        for (let i = 0; i < numTables; i++) {
 | 
				
			||||||
          let table = readTableEntry(font);
 | 
					          const table = readTableEntry(font);
 | 
				
			||||||
          if (!VALID_TABLES.includes(table.tag)) {
 | 
					          if (!VALID_TABLES.includes(table.tag)) {
 | 
				
			||||||
            continue; // skipping table if it's not a required or optional table
 | 
					            continue; // skipping table if it's not a required or optional table
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -1460,18 +1460,18 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      function readTrueTypeCollectionHeader(ttc) {
 | 
					      function readTrueTypeCollectionHeader(ttc) {
 | 
				
			||||||
        let ttcTag = bytesToString(ttc.getBytes(4));
 | 
					        const ttcTag = bytesToString(ttc.getBytes(4));
 | 
				
			||||||
        assert(ttcTag === "ttcf", "Must be a TrueType Collection font.");
 | 
					        assert(ttcTag === "ttcf", "Must be a TrueType Collection font.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let majorVersion = ttc.getUint16();
 | 
					        const majorVersion = ttc.getUint16();
 | 
				
			||||||
        let minorVersion = ttc.getUint16();
 | 
					        const minorVersion = ttc.getUint16();
 | 
				
			||||||
        let numFonts = ttc.getInt32() >>> 0;
 | 
					        const numFonts = ttc.getInt32() >>> 0;
 | 
				
			||||||
        let offsetTable = [];
 | 
					        const offsetTable = [];
 | 
				
			||||||
        for (let i = 0; i < numFonts; i++) {
 | 
					        for (let i = 0; i < numFonts; i++) {
 | 
				
			||||||
          offsetTable.push(ttc.getInt32() >>> 0);
 | 
					          offsetTable.push(ttc.getInt32() >>> 0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let header = {
 | 
					        const header = {
 | 
				
			||||||
          ttcTag,
 | 
					          ttcTag,
 | 
				
			||||||
          majorVersion,
 | 
					          majorVersion,
 | 
				
			||||||
          minorVersion,
 | 
					          minorVersion,
 | 
				
			||||||
@ -1493,23 +1493,23 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      function readTrueTypeCollectionData(ttc, fontName) {
 | 
					      function readTrueTypeCollectionData(ttc, fontName) {
 | 
				
			||||||
        let { numFonts, offsetTable } = readTrueTypeCollectionHeader(ttc);
 | 
					        const { numFonts, offsetTable } = readTrueTypeCollectionHeader(ttc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (let i = 0; i < numFonts; i++) {
 | 
					        for (let i = 0; i < numFonts; i++) {
 | 
				
			||||||
          ttc.pos = (ttc.start || 0) + offsetTable[i];
 | 
					          ttc.pos = (ttc.start || 0) + offsetTable[i];
 | 
				
			||||||
          let potentialHeader = readOpenTypeHeader(ttc);
 | 
					          const potentialHeader = readOpenTypeHeader(ttc);
 | 
				
			||||||
          let potentialTables = readTables(ttc, potentialHeader.numTables);
 | 
					          const potentialTables = readTables(ttc, potentialHeader.numTables);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (!potentialTables["name"]) {
 | 
					          if (!potentialTables["name"]) {
 | 
				
			||||||
            throw new FormatError(
 | 
					            throw new FormatError(
 | 
				
			||||||
              'TrueType Collection font must contain a "name" table.'
 | 
					              'TrueType Collection font must contain a "name" table.'
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          let nameTable = readNameTable(potentialTables["name"]);
 | 
					          const nameTable = readNameTable(potentialTables["name"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          for (let j = 0, jj = nameTable.length; j < jj; j++) {
 | 
					          for (let j = 0, jj = nameTable.length; j < jj; j++) {
 | 
				
			||||||
            for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
 | 
					            for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
 | 
				
			||||||
              let nameEntry = nameTable[j][k];
 | 
					              const nameEntry = nameTable[j][k];
 | 
				
			||||||
              if (nameEntry && nameEntry.replace(/\s/g, "") === fontName) {
 | 
					              if (nameEntry && nameEntry.replace(/\s/g, "") === fontName) {
 | 
				
			||||||
                return {
 | 
					                return {
 | 
				
			||||||
                  header: potentialHeader,
 | 
					                  header: potentialHeader,
 | 
				
			||||||
@ -2327,7 +2327,7 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
              } else {
 | 
					              } else {
 | 
				
			||||||
                ttContext.functionsUsed[funcId] = true;
 | 
					                ttContext.functionsUsed[funcId] = true;
 | 
				
			||||||
                if (funcId in ttContext.functionsStackDeltas) {
 | 
					                if (funcId in ttContext.functionsStackDeltas) {
 | 
				
			||||||
                  let newStackLength =
 | 
					                  const newStackLength =
 | 
				
			||||||
                    stack.length + ttContext.functionsStackDeltas[funcId];
 | 
					                    stack.length + ttContext.functionsStackDeltas[funcId];
 | 
				
			||||||
                  if (newStackLength < 0) {
 | 
					                  if (newStackLength < 0) {
 | 
				
			||||||
                    warn("TT: CALL invalid functions stack delta.");
 | 
					                    warn("TT: CALL invalid functions stack delta.");
 | 
				
			||||||
@ -2525,7 +2525,7 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      let header, tables;
 | 
					      let header, tables;
 | 
				
			||||||
      if (isTrueTypeCollectionFile(font)) {
 | 
					      if (isTrueTypeCollectionFile(font)) {
 | 
				
			||||||
        let ttcData = readTrueTypeCollectionData(font, this.name);
 | 
					        const ttcData = readTrueTypeCollectionData(font, this.name);
 | 
				
			||||||
        header = ttcData.header;
 | 
					        header = ttcData.header;
 | 
				
			||||||
        tables = ttcData.tables;
 | 
					        tables = ttcData.tables;
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
@ -3709,8 +3709,8 @@ var Type1Font = (function Type1FontClosure() {
 | 
				
			|||||||
      var charsetArray = [".notdef"];
 | 
					      var charsetArray = [".notdef"];
 | 
				
			||||||
      var i, ii;
 | 
					      var i, ii;
 | 
				
			||||||
      for (i = 0; i < count; i++) {
 | 
					      for (i = 0; i < count; i++) {
 | 
				
			||||||
        let glyphName = charstrings[i].glyphName;
 | 
					        const glyphName = charstrings[i].glyphName;
 | 
				
			||||||
        let index = CFFStandardStrings.indexOf(glyphName);
 | 
					        const index = CFFStandardStrings.indexOf(glyphName);
 | 
				
			||||||
        if (index === -1) {
 | 
					        if (index === -1) {
 | 
				
			||||||
          strings.add(glyphName);
 | 
					          strings.add(glyphName);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ import {
 | 
				
			|||||||
import { isDict, isStream } from "./primitives.js";
 | 
					import { isDict, isStream } from "./primitives.js";
 | 
				
			||||||
import { PostScriptLexer, PostScriptParser } from "./ps_parser.js";
 | 
					import { PostScriptLexer, PostScriptParser } from "./ps_parser.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let IsEvalSupportedCached = {
 | 
					const IsEvalSupportedCached = {
 | 
				
			||||||
  get value() {
 | 
					  get value() {
 | 
				
			||||||
    return shadow(this, "value", isEvalSupported());
 | 
					    return shadow(this, "value", isEvalSupported());
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
@ -150,7 +150,7 @@ var PDFFunction = (function PDFFunctionClosure() {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    parse({ xref, isEvalSupported, fn }) {
 | 
					    parse({ xref, isEvalSupported, fn }) {
 | 
				
			||||||
      let IR = this.getIR({ xref, isEvalSupported, fn });
 | 
					      const IR = this.getIR({ xref, isEvalSupported, fn });
 | 
				
			||||||
      return this.fromIR({ xref, isEvalSupported, IR });
 | 
					      return this.fromIR({ xref, isEvalSupported, IR });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -480,7 +480,7 @@ var PDFFunction = (function PDFFunctionClosure() {
 | 
				
			|||||||
      var code = IR[3];
 | 
					      var code = IR[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (isEvalSupported && IsEvalSupportedCached.value) {
 | 
					      if (isEvalSupported && IsEvalSupportedCached.value) {
 | 
				
			||||||
        let compiled = new PostScriptCompiler().compile(code, domain, range);
 | 
					        const compiled = new PostScriptCompiler().compile(code, domain, range);
 | 
				
			||||||
        if (compiled) {
 | 
					        if (compiled) {
 | 
				
			||||||
          // Compiled function consists of simple expressions such as addition,
 | 
					          // Compiled function consists of simple expressions such as addition,
 | 
				
			||||||
          // subtraction, Math.max, and also contains 'var' and 'return'
 | 
					          // subtraction, Math.max, and also contains 'var' and 'return'
 | 
				
			||||||
 | 
				
			|||||||
@ -195,7 +195,7 @@ var PDFImage = (function PDFImageClosure() {
 | 
				
			|||||||
            );
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let resources = isInline ? res : null;
 | 
					      const resources = isInline ? res : null;
 | 
				
			||||||
      this.colorSpace = ColorSpace.parse(
 | 
					      this.colorSpace = ColorSpace.parse(
 | 
				
			||||||
        colorSpace,
 | 
					        colorSpace,
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
 | 
				
			|||||||
@ -345,7 +345,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
    decodingContext
 | 
					    decodingContext
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    if (mmr) {
 | 
					    if (mmr) {
 | 
				
			||||||
      let input = new Reader(
 | 
					      const input = new Reader(
 | 
				
			||||||
        decodingContext.data,
 | 
					        decodingContext.data,
 | 
				
			||||||
        decodingContext.start,
 | 
					        decodingContext.start,
 | 
				
			||||||
        decodingContext.end
 | 
					        decodingContext.end
 | 
				
			||||||
@ -625,7 +625,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      currentHeight += deltaHeight;
 | 
					      currentHeight += deltaHeight;
 | 
				
			||||||
      let currentWidth = 0,
 | 
					      let currentWidth = 0,
 | 
				
			||||||
        totalWidth = 0;
 | 
					        totalWidth = 0;
 | 
				
			||||||
      let firstSymbol = huffman ? symbolWidths.length : 0;
 | 
					      const firstSymbol = huffman ? symbolWidths.length : 0;
 | 
				
			||||||
      while (true) {
 | 
					      while (true) {
 | 
				
			||||||
        var deltaWidth = huffman
 | 
					        var deltaWidth = huffman
 | 
				
			||||||
          ? huffmanTables.tableDeltaWidth.decode(huffmanInput)
 | 
					          ? huffmanTables.tableDeltaWidth.decode(huffmanInput)
 | 
				
			||||||
@ -703,7 +703,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      if (huffman && !refinement) {
 | 
					      if (huffman && !refinement) {
 | 
				
			||||||
        // 6.5.9 Height class collective bitmap
 | 
					        // 6.5.9 Height class collective bitmap
 | 
				
			||||||
        let bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
 | 
					        const bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
 | 
				
			||||||
        huffmanInput.byteAlign();
 | 
					        huffmanInput.byteAlign();
 | 
				
			||||||
        let collectiveBitmap;
 | 
					        let collectiveBitmap;
 | 
				
			||||||
        if (bitmapSize === 0) {
 | 
					        if (bitmapSize === 0) {
 | 
				
			||||||
@ -715,8 +715,8 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
          );
 | 
					          );
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          // MMR collective bitmap
 | 
					          // MMR collective bitmap
 | 
				
			||||||
          let originalEnd = huffmanInput.end;
 | 
					          const originalEnd = huffmanInput.end;
 | 
				
			||||||
          let bitmapEnd = huffmanInput.position + bitmapSize;
 | 
					          const bitmapEnd = huffmanInput.position + bitmapSize;
 | 
				
			||||||
          huffmanInput.end = bitmapEnd;
 | 
					          huffmanInput.end = bitmapEnd;
 | 
				
			||||||
          collectiveBitmap = decodeMMRBitmap(
 | 
					          collectiveBitmap = decodeMMRBitmap(
 | 
				
			||||||
            huffmanInput,
 | 
					            huffmanInput,
 | 
				
			||||||
@ -727,7 +727,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
          huffmanInput.end = originalEnd;
 | 
					          huffmanInput.end = originalEnd;
 | 
				
			||||||
          huffmanInput.position = bitmapEnd;
 | 
					          huffmanInput.position = bitmapEnd;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let numberOfSymbolsDecoded = symbolWidths.length;
 | 
					        const numberOfSymbolsDecoded = symbolWidths.length;
 | 
				
			||||||
        if (firstSymbol === numberOfSymbolsDecoded - 1) {
 | 
					        if (firstSymbol === numberOfSymbolsDecoded - 1) {
 | 
				
			||||||
          // collectiveBitmap is a single symbol.
 | 
					          // collectiveBitmap is a single symbol.
 | 
				
			||||||
          newSymbols.push(collectiveBitmap);
 | 
					          newSymbols.push(collectiveBitmap);
 | 
				
			||||||
@ -954,7 +954,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
    template,
 | 
					    template,
 | 
				
			||||||
    decodingContext
 | 
					    decodingContext
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    let at = [];
 | 
					    const at = [];
 | 
				
			||||||
    if (!mmr) {
 | 
					    if (!mmr) {
 | 
				
			||||||
      at.push({
 | 
					      at.push({
 | 
				
			||||||
        x: -patternWidth,
 | 
					        x: -patternWidth,
 | 
				
			||||||
@ -975,8 +975,8 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let collectiveWidth = (maxPatternIndex + 1) * patternWidth;
 | 
					    const collectiveWidth = (maxPatternIndex + 1) * patternWidth;
 | 
				
			||||||
    let collectiveBitmap = decodeBitmap(
 | 
					    const collectiveBitmap = decodeBitmap(
 | 
				
			||||||
      mmr,
 | 
					      mmr,
 | 
				
			||||||
      collectiveWidth,
 | 
					      collectiveWidth,
 | 
				
			||||||
      patternHeight,
 | 
					      patternHeight,
 | 
				
			||||||
@ -1023,7 +1023,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
    gridVectorY,
 | 
					    gridVectorY,
 | 
				
			||||||
    decodingContext
 | 
					    decodingContext
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    let skip = null;
 | 
					    const skip = null;
 | 
				
			||||||
    if (enableSkip) {
 | 
					    if (enableSkip) {
 | 
				
			||||||
      throw new Jbig2Error("skip is not supported");
 | 
					      throw new Jbig2Error("skip is not supported");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1036,7 +1036,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Prepare bitmap.
 | 
					    // Prepare bitmap.
 | 
				
			||||||
    let regionBitmap = [];
 | 
					    const regionBitmap = [];
 | 
				
			||||||
    let i, j, row;
 | 
					    let i, j, row;
 | 
				
			||||||
    for (i = 0; i < regionHeight; i++) {
 | 
					    for (i = 0; i < regionHeight; i++) {
 | 
				
			||||||
      row = new Uint8Array(regionWidth);
 | 
					      row = new Uint8Array(regionWidth);
 | 
				
			||||||
@ -1048,12 +1048,12 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      regionBitmap.push(row);
 | 
					      regionBitmap.push(row);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let numberOfPatterns = patterns.length;
 | 
					    const numberOfPatterns = patterns.length;
 | 
				
			||||||
    let pattern0 = patterns[0];
 | 
					    const pattern0 = patterns[0];
 | 
				
			||||||
    let patternWidth = pattern0[0].length,
 | 
					    const patternWidth = pattern0[0].length,
 | 
				
			||||||
      patternHeight = pattern0.length;
 | 
					      patternHeight = pattern0.length;
 | 
				
			||||||
    let bitsPerValue = log2(numberOfPatterns);
 | 
					    const bitsPerValue = log2(numberOfPatterns);
 | 
				
			||||||
    let at = [];
 | 
					    const at = [];
 | 
				
			||||||
    if (!mmr) {
 | 
					    if (!mmr) {
 | 
				
			||||||
      at.push({
 | 
					      at.push({
 | 
				
			||||||
        x: template <= 1 ? 3 : 2,
 | 
					        x: template <= 1 ? 3 : 2,
 | 
				
			||||||
@ -1403,8 +1403,8 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case 16: // PatternDictionary
 | 
					      case 16: // PatternDictionary
 | 
				
			||||||
        // 7.4.4. Pattern dictionary segment syntax
 | 
					        // 7.4.4. Pattern dictionary segment syntax
 | 
				
			||||||
        let patternDictionary = {};
 | 
					        const patternDictionary = {};
 | 
				
			||||||
        let patternDictionaryFlags = data[position++];
 | 
					        const patternDictionaryFlags = data[position++];
 | 
				
			||||||
        patternDictionary.mmr = !!(patternDictionaryFlags & 1);
 | 
					        patternDictionary.mmr = !!(patternDictionaryFlags & 1);
 | 
				
			||||||
        patternDictionary.template = (patternDictionaryFlags >> 1) & 3;
 | 
					        patternDictionary.template = (patternDictionaryFlags >> 1) & 3;
 | 
				
			||||||
        patternDictionary.patternWidth = data[position++];
 | 
					        patternDictionary.patternWidth = data[position++];
 | 
				
			||||||
@ -1416,10 +1416,10 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      case 22: // ImmediateHalftoneRegion
 | 
					      case 22: // ImmediateHalftoneRegion
 | 
				
			||||||
      case 23: // ImmediateLosslessHalftoneRegion
 | 
					      case 23: // ImmediateLosslessHalftoneRegion
 | 
				
			||||||
        // 7.4.5 Halftone region segment syntax
 | 
					        // 7.4.5 Halftone region segment syntax
 | 
				
			||||||
        let halftoneRegion = {};
 | 
					        const halftoneRegion = {};
 | 
				
			||||||
        halftoneRegion.info = readRegionSegmentInformation(data, position);
 | 
					        halftoneRegion.info = readRegionSegmentInformation(data, position);
 | 
				
			||||||
        position += RegionSegmentInformationFieldLength;
 | 
					        position += RegionSegmentInformationFieldLength;
 | 
				
			||||||
        let halftoneRegionFlags = data[position++];
 | 
					        const halftoneRegionFlags = data[position++];
 | 
				
			||||||
        halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
 | 
					        halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
 | 
				
			||||||
        halftoneRegion.template = (halftoneRegionFlags >> 1) & 3;
 | 
					        halftoneRegion.template = (halftoneRegionFlags >> 1) & 3;
 | 
				
			||||||
        halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
 | 
					        halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
 | 
				
			||||||
@ -1539,7 +1539,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      throw new Jbig2Error("parseJbig2 - invalid header.");
 | 
					      throw new Jbig2Error("parseJbig2 - invalid header.");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let header = Object.create(null);
 | 
					    const header = Object.create(null);
 | 
				
			||||||
    position += 8;
 | 
					    position += 8;
 | 
				
			||||||
    const flags = data[position++];
 | 
					    const flags = data[position++];
 | 
				
			||||||
    header.randomAccess = !(flags & 1);
 | 
					    header.randomAccess = !(flags & 1);
 | 
				
			||||||
@ -1548,13 +1548,13 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      position += 4;
 | 
					      position += 4;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let segments = readSegments(header, data, position, end);
 | 
					    const segments = readSegments(header, data, position, end);
 | 
				
			||||||
    let visitor = new SimpleSegmentVisitor();
 | 
					    const visitor = new SimpleSegmentVisitor();
 | 
				
			||||||
    processSegments(segments, visitor);
 | 
					    processSegments(segments, visitor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const { width, height } = visitor.currentPageInfo;
 | 
					    const { width, height } = visitor.currentPageInfo;
 | 
				
			||||||
    const bitPacked = visitor.buffer;
 | 
					    const bitPacked = visitor.buffer;
 | 
				
			||||||
    let imgData = new Uint8ClampedArray(width * height);
 | 
					    const imgData = new Uint8ClampedArray(width * height);
 | 
				
			||||||
    let q = 0,
 | 
					    let q = 0,
 | 
				
			||||||
      k = 0;
 | 
					      k = 0;
 | 
				
			||||||
    for (let i = 0; i < height; i++) {
 | 
					    for (let i = 0; i < height; i++) {
 | 
				
			||||||
@ -1691,7 +1691,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      var inputSymbols = [];
 | 
					      var inputSymbols = [];
 | 
				
			||||||
      for (var i = 0, ii = referredSegments.length; i < ii; i++) {
 | 
					      for (var i = 0, ii = referredSegments.length; i < ii; i++) {
 | 
				
			||||||
        let referredSymbols = symbols[referredSegments[i]];
 | 
					        const referredSymbols = symbols[referredSegments[i]];
 | 
				
			||||||
        // referredSymbols is undefined when we have a reference to a Tables
 | 
					        // referredSymbols is undefined when we have a reference to a Tables
 | 
				
			||||||
        // segment instead of a SymbolDictionary.
 | 
					        // segment instead of a SymbolDictionary.
 | 
				
			||||||
        if (referredSymbols) {
 | 
					        if (referredSymbols) {
 | 
				
			||||||
@ -1729,7 +1729,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      var symbols = this.symbols;
 | 
					      var symbols = this.symbols;
 | 
				
			||||||
      var inputSymbols = [];
 | 
					      var inputSymbols = [];
 | 
				
			||||||
      for (var i = 0, ii = referredSegments.length; i < ii; i++) {
 | 
					      for (var i = 0, ii = referredSegments.length; i < ii; i++) {
 | 
				
			||||||
        let referredSymbols = symbols[referredSegments[i]];
 | 
					        const referredSymbols = symbols[referredSegments[i]];
 | 
				
			||||||
        // referredSymbols is undefined when we have a reference to a Tables
 | 
					        // referredSymbols is undefined when we have a reference to a Tables
 | 
				
			||||||
        // segment instead of a SymbolDictionary.
 | 
					        // segment instead of a SymbolDictionary.
 | 
				
			||||||
        if (referredSymbols) {
 | 
					        if (referredSymbols) {
 | 
				
			||||||
@ -1780,7 +1780,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      if (!patterns) {
 | 
					      if (!patterns) {
 | 
				
			||||||
        this.patterns = patterns = {};
 | 
					        this.patterns = patterns = {};
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let decodingContext = new DecodingContext(data, start, end);
 | 
					      const decodingContext = new DecodingContext(data, start, end);
 | 
				
			||||||
      patterns[currentSegment] = decodePatternDictionary(
 | 
					      patterns[currentSegment] = decodePatternDictionary(
 | 
				
			||||||
        dictionary.mmr,
 | 
					        dictionary.mmr,
 | 
				
			||||||
        dictionary.patternWidth,
 | 
					        dictionary.patternWidth,
 | 
				
			||||||
@ -1792,10 +1792,10 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
 | 
					    onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
 | 
				
			||||||
      // HalftoneRegion refers to exactly one PatternDictionary.
 | 
					      // HalftoneRegion refers to exactly one PatternDictionary.
 | 
				
			||||||
      let patterns = this.patterns[referredSegments[0]];
 | 
					      const patterns = this.patterns[referredSegments[0]];
 | 
				
			||||||
      let regionInfo = region.info;
 | 
					      const regionInfo = region.info;
 | 
				
			||||||
      let decodingContext = new DecodingContext(data, start, end);
 | 
					      const decodingContext = new DecodingContext(data, start, end);
 | 
				
			||||||
      let bitmap = decodeHalftoneRegion(
 | 
					      const bitmap = decodeHalftoneRegion(
 | 
				
			||||||
        region.mmr,
 | 
					        region.mmr,
 | 
				
			||||||
        patterns,
 | 
					        patterns,
 | 
				
			||||||
        region.template,
 | 
					        region.template,
 | 
				
			||||||
@ -1864,7 +1864,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  HuffmanTreeNode.prototype = {
 | 
					  HuffmanTreeNode.prototype = {
 | 
				
			||||||
    buildTree(line, shift) {
 | 
					    buildTree(line, shift) {
 | 
				
			||||||
      let bit = (line.prefixCode >> shift) & 1;
 | 
					      const bit = (line.prefixCode >> shift) & 1;
 | 
				
			||||||
      if (shift <= 0) {
 | 
					      if (shift <= 0) {
 | 
				
			||||||
        // Create a leaf node.
 | 
					        // Create a leaf node.
 | 
				
			||||||
        this.children[bit] = new HuffmanTreeNode(line);
 | 
					        this.children[bit] = new HuffmanTreeNode(line);
 | 
				
			||||||
@ -1882,10 +1882,10 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
        if (this.isOOB) {
 | 
					        if (this.isOOB) {
 | 
				
			||||||
          return null;
 | 
					          return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let htOffset = reader.readBits(this.rangeLength);
 | 
					        const htOffset = reader.readBits(this.rangeLength);
 | 
				
			||||||
        return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
 | 
					        return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let node = this.children[reader.readBit()];
 | 
					      const node = this.children[reader.readBit()];
 | 
				
			||||||
      if (!node) {
 | 
					      if (!node) {
 | 
				
			||||||
        throw new Jbig2Error("invalid Huffman data");
 | 
					        throw new Jbig2Error("invalid Huffman data");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -1923,7 +1923,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
        prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
 | 
					        prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let histogram = new Uint32Array(prefixLengthMax + 1);
 | 
					      const histogram = new Uint32Array(prefixLengthMax + 1);
 | 
				
			||||||
      for (i = 0; i < linesLength; i++) {
 | 
					      for (i = 0; i < linesLength; i++) {
 | 
				
			||||||
        histogram[lines[i].prefixLength]++;
 | 
					        histogram[lines[i].prefixLength]++;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -1954,14 +1954,14 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
  function decodeTablesSegment(data, start, end) {
 | 
					  function decodeTablesSegment(data, start, end) {
 | 
				
			||||||
    // Decodes a Tables segment, i.e., a custom Huffman table.
 | 
					    // Decodes a Tables segment, i.e., a custom Huffman table.
 | 
				
			||||||
    // Annex B.2 Code table structure.
 | 
					    // Annex B.2 Code table structure.
 | 
				
			||||||
    let flags = data[start];
 | 
					    const flags = data[start];
 | 
				
			||||||
    let lowestValue = readUint32(data, start + 1) & 0xffffffff;
 | 
					    const lowestValue = readUint32(data, start + 1) & 0xffffffff;
 | 
				
			||||||
    let highestValue = readUint32(data, start + 5) & 0xffffffff;
 | 
					    const highestValue = readUint32(data, start + 5) & 0xffffffff;
 | 
				
			||||||
    let reader = new Reader(data, start + 9, end);
 | 
					    const reader = new Reader(data, start + 9, end);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let prefixSizeBits = ((flags >> 1) & 7) + 1;
 | 
					    const prefixSizeBits = ((flags >> 1) & 7) + 1;
 | 
				
			||||||
    let rangeSizeBits = ((flags >> 4) & 7) + 1;
 | 
					    const rangeSizeBits = ((flags >> 4) & 7) + 1;
 | 
				
			||||||
    let lines = [];
 | 
					    const lines = [];
 | 
				
			||||||
    let prefixLength,
 | 
					    let prefixLength,
 | 
				
			||||||
      rangeLength,
 | 
					      rangeLength,
 | 
				
			||||||
      currentRangeLow = lowestValue;
 | 
					      currentRangeLow = lowestValue;
 | 
				
			||||||
@ -1995,7 +1995,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
    return new HuffmanTable(lines, false);
 | 
					    return new HuffmanTable(lines, false);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let standardTablesCache = {};
 | 
					  const standardTablesCache = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function getStandardTable(number) {
 | 
					  function getStandardTable(number) {
 | 
				
			||||||
    // Annex B.5 Standard Huffman tables.
 | 
					    // Annex B.5 Standard Huffman tables.
 | 
				
			||||||
@ -2281,7 +2281,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
        this.currentByte = this.data[this.position++];
 | 
					        this.currentByte = this.data[this.position++];
 | 
				
			||||||
        this.shift = 7;
 | 
					        this.shift = 7;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let bit = (this.currentByte >> this.shift) & 1;
 | 
					      const bit = (this.currentByte >> this.shift) & 1;
 | 
				
			||||||
      this.shift--;
 | 
					      this.shift--;
 | 
				
			||||||
      return bit;
 | 
					      return bit;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -2344,7 +2344,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      codes.push(new HuffmanLine([i, codeLength, 0, 0]));
 | 
					      codes.push(new HuffmanLine([i, codeLength, 0, 0]));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Assign Huffman codes for RUNCODEs.
 | 
					    // Assign Huffman codes for RUNCODEs.
 | 
				
			||||||
    let runCodesTable = new HuffmanTable(codes, false);
 | 
					    const runCodesTable = new HuffmanTable(codes, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Read a Huffman code using the assignment above.
 | 
					    // Read a Huffman code using the assignment above.
 | 
				
			||||||
    // Interpret the RUNCODE codes and the additional bits (if any).
 | 
					    // Interpret the RUNCODE codes and the additional bits (if any).
 | 
				
			||||||
@ -2382,7 +2382,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    reader.byteAlign();
 | 
					    reader.byteAlign();
 | 
				
			||||||
    let symbolIDTable = new HuffmanTable(codes, false);
 | 
					    const symbolIDTable = new HuffmanTable(codes, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 7.4.3.1.6 Text region segment Huffman table selection
 | 
					    // 7.4.3.1.6 Text region segment Huffman table selection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2550,14 +2550,14 @@ var Jbig2Image = (function Jbig2ImageClosure() {
 | 
				
			|||||||
  function decodeMMRBitmap(input, width, height, endOfBlock) {
 | 
					  function decodeMMRBitmap(input, width, height, endOfBlock) {
 | 
				
			||||||
    // MMR is the same compression algorithm as the PDF filter
 | 
					    // MMR is the same compression algorithm as the PDF filter
 | 
				
			||||||
    // CCITTFaxDecode with /K -1.
 | 
					    // CCITTFaxDecode with /K -1.
 | 
				
			||||||
    let params = {
 | 
					    const params = {
 | 
				
			||||||
      K: -1,
 | 
					      K: -1,
 | 
				
			||||||
      Columns: width,
 | 
					      Columns: width,
 | 
				
			||||||
      Rows: height,
 | 
					      Rows: height,
 | 
				
			||||||
      BlackIs1: true,
 | 
					      BlackIs1: true,
 | 
				
			||||||
      EndOfBlock: endOfBlock,
 | 
					      EndOfBlock: endOfBlock,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    let decoder = new CCITTFaxDecoder(input, params);
 | 
					    const decoder = new CCITTFaxDecoder(input, params);
 | 
				
			||||||
    let bitmap = [],
 | 
					    let bitmap = [],
 | 
				
			||||||
      x,
 | 
					      x,
 | 
				
			||||||
      y,
 | 
					      y,
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,7 @@ import { shadow } from "../shared/util.js";
 | 
				
			|||||||
 * For JBIG2's we use a library to decode these images and
 | 
					 * For JBIG2's we use a library to decode these images and
 | 
				
			||||||
 * the stream behaves like all the other DecodeStreams.
 | 
					 * the stream behaves like all the other DecodeStreams.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
let Jbig2Stream = (function Jbig2StreamClosure() {
 | 
					const Jbig2Stream = (function Jbig2StreamClosure() {
 | 
				
			||||||
  function Jbig2Stream(stream, maybeLength, dict, params) {
 | 
					  function Jbig2Stream(stream, maybeLength, dict, params) {
 | 
				
			||||||
    this.stream = stream;
 | 
					    this.stream = stream;
 | 
				
			||||||
    this.maybeLength = maybeLength;
 | 
					    this.maybeLength = maybeLength;
 | 
				
			||||||
@ -51,19 +51,19 @@ let Jbig2Stream = (function Jbig2StreamClosure() {
 | 
				
			|||||||
    if (this.eof) {
 | 
					    if (this.eof) {
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let jbig2Image = new Jbig2Image();
 | 
					    const jbig2Image = new Jbig2Image();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let chunks = [];
 | 
					    const chunks = [];
 | 
				
			||||||
    if (isDict(this.params)) {
 | 
					    if (isDict(this.params)) {
 | 
				
			||||||
      let globalsStream = this.params.get("JBIG2Globals");
 | 
					      const globalsStream = this.params.get("JBIG2Globals");
 | 
				
			||||||
      if (isStream(globalsStream)) {
 | 
					      if (isStream(globalsStream)) {
 | 
				
			||||||
        let globals = globalsStream.getBytes();
 | 
					        const globals = globalsStream.getBytes();
 | 
				
			||||||
        chunks.push({ data: globals, start: 0, end: globals.length });
 | 
					        chunks.push({ data: globals, start: 0, end: globals.length });
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    chunks.push({ data: this.bytes, start: 0, end: this.bytes.length });
 | 
					    chunks.push({ data: this.bytes, start: 0, end: this.bytes.length });
 | 
				
			||||||
    let data = jbig2Image.parseChunks(chunks);
 | 
					    const data = jbig2Image.parseChunks(chunks);
 | 
				
			||||||
    let dataLength = data.length;
 | 
					    const dataLength = data.length;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // JBIG2 had black as 1 and white as 0, inverting the colors
 | 
					    // JBIG2 had black as 1 and white as 0, inverting the colors
 | 
				
			||||||
    for (let i = 0; i < dataLength; i++) {
 | 
					    for (let i = 0; i < dataLength; i++) {
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,7 @@ import { JpegImage } from "./jpg.js";
 | 
				
			|||||||
 * a library to decode these images and the stream behaves like all the other
 | 
					 * a library to decode these images and the stream behaves like all the other
 | 
				
			||||||
 * DecodeStreams.
 | 
					 * DecodeStreams.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
let JpegStream = (function JpegStreamClosure() {
 | 
					const JpegStream = (function JpegStreamClosure() {
 | 
				
			||||||
  function JpegStream(stream, maybeLength, dict, params) {
 | 
					  function JpegStream(stream, maybeLength, dict, params) {
 | 
				
			||||||
    // Some images may contain 'junk' before the SOI (start-of-image) marker.
 | 
					    // Some images may contain 'junk' before the SOI (start-of-image) marker.
 | 
				
			||||||
    // Note: this seems to mainly affect inline images.
 | 
					    // Note: this seems to mainly affect inline images.
 | 
				
			||||||
@ -64,19 +64,19 @@ let JpegStream = (function JpegStreamClosure() {
 | 
				
			|||||||
    if (this.eof) {
 | 
					    if (this.eof) {
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let jpegOptions = {
 | 
					    const jpegOptions = {
 | 
				
			||||||
      decodeTransform: undefined,
 | 
					      decodeTransform: undefined,
 | 
				
			||||||
      colorTransform: undefined,
 | 
					      colorTransform: undefined,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Checking if values need to be transformed before conversion.
 | 
					    // Checking if values need to be transformed before conversion.
 | 
				
			||||||
    let decodeArr = this.dict.getArray("Decode", "D");
 | 
					    const decodeArr = this.dict.getArray("Decode", "D");
 | 
				
			||||||
    if (this.forceRGB && Array.isArray(decodeArr)) {
 | 
					    if (this.forceRGB && Array.isArray(decodeArr)) {
 | 
				
			||||||
      let bitsPerComponent = this.dict.get("BitsPerComponent") || 8;
 | 
					      const bitsPerComponent = this.dict.get("BitsPerComponent") || 8;
 | 
				
			||||||
      let decodeArrLength = decodeArr.length;
 | 
					      const decodeArrLength = decodeArr.length;
 | 
				
			||||||
      let transform = new Int32Array(decodeArrLength);
 | 
					      const transform = new Int32Array(decodeArrLength);
 | 
				
			||||||
      let transformNeeded = false;
 | 
					      let transformNeeded = false;
 | 
				
			||||||
      let maxValue = (1 << bitsPerComponent) - 1;
 | 
					      const maxValue = (1 << bitsPerComponent) - 1;
 | 
				
			||||||
      for (let i = 0; i < decodeArrLength; i += 2) {
 | 
					      for (let i = 0; i < decodeArrLength; i += 2) {
 | 
				
			||||||
        transform[i] = ((decodeArr[i + 1] - decodeArr[i]) * 256) | 0;
 | 
					        transform[i] = ((decodeArr[i + 1] - decodeArr[i]) * 256) | 0;
 | 
				
			||||||
        transform[i + 1] = (decodeArr[i] * maxValue) | 0;
 | 
					        transform[i + 1] = (decodeArr[i] * maxValue) | 0;
 | 
				
			||||||
@ -90,7 +90,7 @@ let JpegStream = (function JpegStreamClosure() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    // Fetching the 'ColorTransform' entry, if it exists.
 | 
					    // Fetching the 'ColorTransform' entry, if it exists.
 | 
				
			||||||
    if (isDict(this.params)) {
 | 
					    if (isDict(this.params)) {
 | 
				
			||||||
      let colorTransform = this.params.get("ColorTransform");
 | 
					      const colorTransform = this.params.get("ColorTransform");
 | 
				
			||||||
      if (Number.isInteger(colorTransform)) {
 | 
					      if (Number.isInteger(colorTransform)) {
 | 
				
			||||||
        jpegOptions.colorTransform = colorTransform;
 | 
					        jpegOptions.colorTransform = colorTransform;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -98,7 +98,7 @@ let JpegStream = (function JpegStreamClosure() {
 | 
				
			|||||||
    const jpegImage = new JpegImage(jpegOptions);
 | 
					    const jpegImage = new JpegImage(jpegOptions);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    jpegImage.parse(this.bytes);
 | 
					    jpegImage.parse(this.bytes);
 | 
				
			||||||
    let data = jpegImage.getData({
 | 
					    const data = jpegImage.getData({
 | 
				
			||||||
      width: this.drawWidth,
 | 
					      width: this.drawWidth,
 | 
				
			||||||
      height: this.drawHeight,
 | 
					      height: this.drawHeight,
 | 
				
			||||||
      forceRGB: this.forceRGB,
 | 
					      forceRGB: this.forceRGB,
 | 
				
			||||||
 | 
				
			|||||||
@ -274,8 +274,8 @@ var JpegImage = (function JpegImageClosure() {
 | 
				
			|||||||
      var s;
 | 
					      var s;
 | 
				
			||||||
      var rs;
 | 
					      var rs;
 | 
				
			||||||
      while (k <= e) {
 | 
					      while (k <= e) {
 | 
				
			||||||
        let offsetZ = offset + dctZigZag[k];
 | 
					        const offsetZ = offset + dctZigZag[k];
 | 
				
			||||||
        let sign = component.blockData[offsetZ] < 0 ? -1 : 1;
 | 
					        const sign = component.blockData[offsetZ] < 0 ? -1 : 1;
 | 
				
			||||||
        switch (successiveACState) {
 | 
					        switch (successiveACState) {
 | 
				
			||||||
          case 0: // initial state
 | 
					          case 0: // initial state
 | 
				
			||||||
            rs = decodeHuffman(component.huffmanTableAC);
 | 
					            rs = decodeHuffman(component.huffmanTableAC);
 | 
				
			||||||
@ -1035,7 +1035,7 @@ var JpegImage = (function JpegImageClosure() {
 | 
				
			|||||||
              offset -= 3;
 | 
					              offset -= 3;
 | 
				
			||||||
              break;
 | 
					              break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            let nextFileMarker = findNextFileMarker(data, offset - 2);
 | 
					            const nextFileMarker = findNextFileMarker(data, offset - 2);
 | 
				
			||||||
            if (nextFileMarker && nextFileMarker.invalid) {
 | 
					            if (nextFileMarker && nextFileMarker.invalid) {
 | 
				
			||||||
              warn(
 | 
					              warn(
 | 
				
			||||||
                "JpegImage.parse - unexpected data, current marker is: " +
 | 
					                "JpegImage.parse - unexpected data, current marker is: " +
 | 
				
			||||||
 | 
				
			|||||||
@ -1541,7 +1541,7 @@ var JpxImage = (function JpxImageClosure() {
 | 
				
			|||||||
            y0 = y0items[j] + offset;
 | 
					            y0 = y0items[j] + offset;
 | 
				
			||||||
            y1 = y1items[j];
 | 
					            y1 = y1items[j];
 | 
				
			||||||
            y2 = y2items[j];
 | 
					            y2 = y2items[j];
 | 
				
			||||||
            let g = y0 - ((y2 + y1) >> 2);
 | 
					            const g = y0 - ((y2 + y1) >> 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            out[pos++] = (g + y2) >> shift;
 | 
					            out[pos++] = (g + y2) >> shift;
 | 
				
			||||||
            out[pos++] = g >> shift;
 | 
					            out[pos++] = g >> shift;
 | 
				
			||||||
 | 
				
			|||||||
@ -21,7 +21,7 @@ import { shadow } from "../shared/util.js";
 | 
				
			|||||||
 * For JPEG 2000's we use a library to decode these images and
 | 
					 * For JPEG 2000's we use a library to decode these images and
 | 
				
			||||||
 * the stream behaves like all the other DecodeStreams.
 | 
					 * the stream behaves like all the other DecodeStreams.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
let JpxStream = (function JpxStreamClosure() {
 | 
					const JpxStream = (function JpxStreamClosure() {
 | 
				
			||||||
  function JpxStream(stream, maybeLength, dict, params) {
 | 
					  function JpxStream(stream, maybeLength, dict, params) {
 | 
				
			||||||
    this.stream = stream;
 | 
					    this.stream = stream;
 | 
				
			||||||
    this.maybeLength = maybeLength;
 | 
					    this.maybeLength = maybeLength;
 | 
				
			||||||
@ -50,33 +50,33 @@ let JpxStream = (function JpxStreamClosure() {
 | 
				
			|||||||
    if (this.eof) {
 | 
					    if (this.eof) {
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let jpxImage = new JpxImage();
 | 
					    const jpxImage = new JpxImage();
 | 
				
			||||||
    jpxImage.parse(this.bytes);
 | 
					    jpxImage.parse(this.bytes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let width = jpxImage.width;
 | 
					    const width = jpxImage.width;
 | 
				
			||||||
    let height = jpxImage.height;
 | 
					    const height = jpxImage.height;
 | 
				
			||||||
    let componentsCount = jpxImage.componentsCount;
 | 
					    const componentsCount = jpxImage.componentsCount;
 | 
				
			||||||
    let tileCount = jpxImage.tiles.length;
 | 
					    const tileCount = jpxImage.tiles.length;
 | 
				
			||||||
    if (tileCount === 1) {
 | 
					    if (tileCount === 1) {
 | 
				
			||||||
      this.buffer = jpxImage.tiles[0].items;
 | 
					      this.buffer = jpxImage.tiles[0].items;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      let data = new Uint8ClampedArray(width * height * componentsCount);
 | 
					      const data = new Uint8ClampedArray(width * height * componentsCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for (let k = 0; k < tileCount; k++) {
 | 
					      for (let k = 0; k < tileCount; k++) {
 | 
				
			||||||
        let tileComponents = jpxImage.tiles[k];
 | 
					        const tileComponents = jpxImage.tiles[k];
 | 
				
			||||||
        let tileWidth = tileComponents.width;
 | 
					        const tileWidth = tileComponents.width;
 | 
				
			||||||
        let tileHeight = tileComponents.height;
 | 
					        const tileHeight = tileComponents.height;
 | 
				
			||||||
        let tileLeft = tileComponents.left;
 | 
					        const tileLeft = tileComponents.left;
 | 
				
			||||||
        let tileTop = tileComponents.top;
 | 
					        const tileTop = tileComponents.top;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let src = tileComponents.items;
 | 
					        const src = tileComponents.items;
 | 
				
			||||||
        let srcPosition = 0;
 | 
					        let srcPosition = 0;
 | 
				
			||||||
        let dataPosition = (width * tileTop + tileLeft) * componentsCount;
 | 
					        let dataPosition = (width * tileTop + tileLeft) * componentsCount;
 | 
				
			||||||
        let imgRowSize = width * componentsCount;
 | 
					        const imgRowSize = width * componentsCount;
 | 
				
			||||||
        let tileRowSize = tileWidth * componentsCount;
 | 
					        const tileRowSize = tileWidth * componentsCount;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (let j = 0; j < tileHeight; j++) {
 | 
					        for (let j = 0; j < tileHeight; j++) {
 | 
				
			||||||
          let rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
 | 
					          const rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
 | 
				
			||||||
          data.set(rowBytes, dataPosition);
 | 
					          data.set(rowBytes, dataPosition);
 | 
				
			||||||
          srcPosition += tileRowSize;
 | 
					          srcPosition += tileRowSize;
 | 
				
			||||||
          dataPosition += imgRowSize;
 | 
					          dataPosition += imgRowSize;
 | 
				
			||||||
 | 
				
			|||||||
@ -267,7 +267,7 @@ class Catalog {
 | 
				
			|||||||
      dests = Object.create(null);
 | 
					      dests = Object.create(null);
 | 
				
			||||||
    if (obj instanceof NameTree) {
 | 
					    if (obj instanceof NameTree) {
 | 
				
			||||||
      const names = obj.getAll();
 | 
					      const names = obj.getAll();
 | 
				
			||||||
      for (let name in names) {
 | 
					      for (const name in names) {
 | 
				
			||||||
        dests[name] = fetchDestination(names[name]);
 | 
					        dests[name] = fetchDestination(names[name]);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else if (obj instanceof Dict) {
 | 
					    } else if (obj instanceof Dict) {
 | 
				
			||||||
@ -1527,11 +1527,11 @@ var XRef = (function XRefClosure() {
 | 
				
			|||||||
          // we won't skip over a new 'obj' operator in corrupt files where
 | 
					          // we won't skip over a new 'obj' operator in corrupt files where
 | 
				
			||||||
          // 'endobj' operators are missing (fixes issue9105_reduced.pdf).
 | 
					          // 'endobj' operators are missing (fixes issue9105_reduced.pdf).
 | 
				
			||||||
          while (startPos < buffer.length) {
 | 
					          while (startPos < buffer.length) {
 | 
				
			||||||
            let endPos = startPos + skipUntil(buffer, startPos, objBytes) + 4;
 | 
					            const endPos = startPos + skipUntil(buffer, startPos, objBytes) + 4;
 | 
				
			||||||
            contentLength = endPos - position;
 | 
					            contentLength = endPos - position;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let checkPos = Math.max(endPos - CHECK_CONTENT_LENGTH, startPos);
 | 
					            const checkPos = Math.max(endPos - CHECK_CONTENT_LENGTH, startPos);
 | 
				
			||||||
            let tokenStr = bytesToString(buffer.subarray(checkPos, endPos));
 | 
					            const tokenStr = bytesToString(buffer.subarray(checkPos, endPos));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Check if the current object ends with an 'endobj' operator.
 | 
					            // Check if the current object ends with an 'endobj' operator.
 | 
				
			||||||
            if (endobjRegExp.test(tokenStr)) {
 | 
					            if (endobjRegExp.test(tokenStr)) {
 | 
				
			||||||
@ -1539,7 +1539,7 @@ var XRef = (function XRefClosure() {
 | 
				
			|||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              // Check if an "obj" occurrence is actually a new object,
 | 
					              // Check if an "obj" occurrence is actually a new object,
 | 
				
			||||||
              // i.e. the current object is missing the 'endobj' operator.
 | 
					              // i.e. the current object is missing the 'endobj' operator.
 | 
				
			||||||
              let objToken = nestedObjRegExp.exec(tokenStr);
 | 
					              const objToken = nestedObjRegExp.exec(tokenStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              if (objToken && objToken[1]) {
 | 
					              if (objToken && objToken[1]) {
 | 
				
			||||||
                warn(
 | 
					                warn(
 | 
				
			||||||
@ -1552,7 +1552,7 @@ var XRef = (function XRefClosure() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            startPos = endPos;
 | 
					            startPos = endPos;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          let content = buffer.subarray(position, position + contentLength);
 | 
					          const content = buffer.subarray(position, position + contentLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // checking XRef stream suspect
 | 
					          // checking XRef stream suspect
 | 
				
			||||||
          // (it shall have '/XRef' and next char is not a letter)
 | 
					          // (it shall have '/XRef' and next char is not a letter)
 | 
				
			||||||
@ -1597,7 +1597,7 @@ var XRef = (function XRefClosure() {
 | 
				
			|||||||
          continue;
 | 
					          continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // read the trailer dictionary
 | 
					        // read the trailer dictionary
 | 
				
			||||||
        let dict = parser.getObj();
 | 
					        const dict = parser.getObj();
 | 
				
			||||||
        if (!isDict(dict)) {
 | 
					        if (!isDict(dict)) {
 | 
				
			||||||
          continue;
 | 
					          continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -1634,7 +1634,7 @@ var XRef = (function XRefClosure() {
 | 
				
			|||||||
      // Keep track of already parsed XRef tables, to prevent an infinite loop
 | 
					      // Keep track of already parsed XRef tables, to prevent an infinite loop
 | 
				
			||||||
      // when parsing corrupt PDF files where e.g. the /Prev entries create a
 | 
					      // when parsing corrupt PDF files where e.g. the /Prev entries create a
 | 
				
			||||||
      // circular dependency between tables (fixes bug1393476.pdf).
 | 
					      // circular dependency between tables (fixes bug1393476.pdf).
 | 
				
			||||||
      let startXRefParsedCache = Object.create(null);
 | 
					      const startXRefParsedCache = Object.create(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        while (this.startXRefQueue.length) {
 | 
					        while (this.startXRefQueue.length) {
 | 
				
			||||||
@ -2178,7 +2178,7 @@ var FileSpec = (function FileSpecClosure() {
 | 
				
			|||||||
 * that have references to the catalog or other pages since that will cause the
 | 
					 * that have references to the catalog or other pages since that will cause the
 | 
				
			||||||
 * entire PDF document object graph to be traversed.
 | 
					 * entire PDF document object graph to be traversed.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
let ObjectLoader = (function() {
 | 
					const ObjectLoader = (function() {
 | 
				
			||||||
  function mayHaveChildren(value) {
 | 
					  function mayHaveChildren(value) {
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      value instanceof Ref ||
 | 
					      value instanceof Ref ||
 | 
				
			||||||
@ -2190,17 +2190,17 @@ let ObjectLoader = (function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  function addChildren(node, nodesToVisit) {
 | 
					  function addChildren(node, nodesToVisit) {
 | 
				
			||||||
    if (node instanceof Dict || isStream(node)) {
 | 
					    if (node instanceof Dict || isStream(node)) {
 | 
				
			||||||
      let dict = node instanceof Dict ? node : node.dict;
 | 
					      const dict = node instanceof Dict ? node : node.dict;
 | 
				
			||||||
      let dictKeys = dict.getKeys();
 | 
					      const dictKeys = dict.getKeys();
 | 
				
			||||||
      for (let i = 0, ii = dictKeys.length; i < ii; i++) {
 | 
					      for (let i = 0, ii = dictKeys.length; i < ii; i++) {
 | 
				
			||||||
        let rawValue = dict.getRaw(dictKeys[i]);
 | 
					        const rawValue = dict.getRaw(dictKeys[i]);
 | 
				
			||||||
        if (mayHaveChildren(rawValue)) {
 | 
					        if (mayHaveChildren(rawValue)) {
 | 
				
			||||||
          nodesToVisit.push(rawValue);
 | 
					          nodesToVisit.push(rawValue);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else if (Array.isArray(node)) {
 | 
					    } else if (Array.isArray(node)) {
 | 
				
			||||||
      for (let i = 0, ii = node.length; i < ii; i++) {
 | 
					      for (let i = 0, ii = node.length; i < ii; i++) {
 | 
				
			||||||
        let value = node[i];
 | 
					        const value = node[i];
 | 
				
			||||||
        if (mayHaveChildren(value)) {
 | 
					        if (mayHaveChildren(value)) {
 | 
				
			||||||
          nodesToVisit.push(value);
 | 
					          nodesToVisit.push(value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -2226,12 +2226,12 @@ let ObjectLoader = (function() {
 | 
				
			|||||||
        return undefined;
 | 
					        return undefined;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let { keys, dict } = this;
 | 
					      const { keys, dict } = this;
 | 
				
			||||||
      this.refSet = new RefSet();
 | 
					      this.refSet = new RefSet();
 | 
				
			||||||
      // Setup the initial nodes to visit.
 | 
					      // Setup the initial nodes to visit.
 | 
				
			||||||
      let nodesToVisit = [];
 | 
					      const nodesToVisit = [];
 | 
				
			||||||
      for (let i = 0, ii = keys.length; i < ii; i++) {
 | 
					      for (let i = 0, ii = keys.length; i < ii; i++) {
 | 
				
			||||||
        let rawValue = dict.getRaw(keys[i]);
 | 
					        const rawValue = dict.getRaw(keys[i]);
 | 
				
			||||||
        // Skip nodes that are guaranteed to be empty.
 | 
					        // Skip nodes that are guaranteed to be empty.
 | 
				
			||||||
        if (rawValue !== undefined) {
 | 
					        if (rawValue !== undefined) {
 | 
				
			||||||
          nodesToVisit.push(rawValue);
 | 
					          nodesToVisit.push(rawValue);
 | 
				
			||||||
@ -2241,8 +2241,8 @@ let ObjectLoader = (function() {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async _walk(nodesToVisit) {
 | 
					    async _walk(nodesToVisit) {
 | 
				
			||||||
      let nodesToRevisit = [];
 | 
					      const nodesToRevisit = [];
 | 
				
			||||||
      let pendingRequests = [];
 | 
					      const pendingRequests = [];
 | 
				
			||||||
      // DFS walk of the object graph.
 | 
					      // DFS walk of the object graph.
 | 
				
			||||||
      while (nodesToVisit.length) {
 | 
					      while (nodesToVisit.length) {
 | 
				
			||||||
        let currentNode = nodesToVisit.pop();
 | 
					        let currentNode = nodesToVisit.pop();
 | 
				
			||||||
@ -2265,10 +2265,10 @@ let ObjectLoader = (function() {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (currentNode && currentNode.getBaseStreams) {
 | 
					        if (currentNode && currentNode.getBaseStreams) {
 | 
				
			||||||
          let baseStreams = currentNode.getBaseStreams();
 | 
					          const baseStreams = currentNode.getBaseStreams();
 | 
				
			||||||
          let foundMissingData = false;
 | 
					          let foundMissingData = false;
 | 
				
			||||||
          for (let i = 0, ii = baseStreams.length; i < ii; i++) {
 | 
					          for (let i = 0, ii = baseStreams.length; i < ii; i++) {
 | 
				
			||||||
            let stream = baseStreams[i];
 | 
					            const stream = baseStreams[i];
 | 
				
			||||||
            if (stream.allChunksLoaded && !stream.allChunksLoaded()) {
 | 
					            if (stream.allChunksLoaded && !stream.allChunksLoaded()) {
 | 
				
			||||||
              foundMissingData = true;
 | 
					              foundMissingData = true;
 | 
				
			||||||
              pendingRequests.push({ begin: stream.start, end: stream.end });
 | 
					              pendingRequests.push({ begin: stream.start, end: stream.end });
 | 
				
			||||||
@ -2286,7 +2286,7 @@ let ObjectLoader = (function() {
 | 
				
			|||||||
        await this.xref.stream.manager.requestRanges(pendingRequests);
 | 
					        await this.xref.stream.manager.requestRanges(pendingRequests);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (let i = 0, ii = nodesToRevisit.length; i < ii; i++) {
 | 
					        for (let i = 0, ii = nodesToRevisit.length; i < ii; i++) {
 | 
				
			||||||
          let node = nodesToRevisit[i];
 | 
					          const node = nodesToRevisit[i];
 | 
				
			||||||
          // Remove any reference nodes from the current `RefSet` so they
 | 
					          // Remove any reference nodes from the current `RefSet` so they
 | 
				
			||||||
          // aren't skipped when we revist them.
 | 
					          // aren't skipped when we revist them.
 | 
				
			||||||
          if (node instanceof Ref) {
 | 
					          if (node instanceof Ref) {
 | 
				
			||||||
 | 
				
			|||||||
@ -693,8 +693,8 @@ class Parser {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    let maybeLength = length;
 | 
					    let maybeLength = length;
 | 
				
			||||||
    if (Array.isArray(filter)) {
 | 
					    if (Array.isArray(filter)) {
 | 
				
			||||||
      let filterArray = filter;
 | 
					      const filterArray = filter;
 | 
				
			||||||
      let paramsArray = params;
 | 
					      const paramsArray = params;
 | 
				
			||||||
      for (let i = 0, ii = filterArray.length; i < ii; ++i) {
 | 
					      for (let i = 0, ii = filterArray.length; i < ii; ++i) {
 | 
				
			||||||
        filter = this.xref.fetchIfRef(filterArray[i]);
 | 
					        filter = this.xref.fetchIfRef(filterArray[i]);
 | 
				
			||||||
        if (!isName(filter)) {
 | 
					        if (!isName(filter)) {
 | 
				
			||||||
 | 
				
			|||||||
@ -937,12 +937,12 @@ Shadings.Dummy = (function DummyClosure() {
 | 
				
			|||||||
})();
 | 
					})();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getTilingPatternIR(operatorList, dict, args) {
 | 
					function getTilingPatternIR(operatorList, dict, args) {
 | 
				
			||||||
  let matrix = dict.getArray("Matrix");
 | 
					  const matrix = dict.getArray("Matrix");
 | 
				
			||||||
  let bbox = Util.normalizeRect(dict.getArray("BBox"));
 | 
					  const bbox = Util.normalizeRect(dict.getArray("BBox"));
 | 
				
			||||||
  let xstep = dict.get("XStep");
 | 
					  const xstep = dict.get("XStep");
 | 
				
			||||||
  let ystep = dict.get("YStep");
 | 
					  const ystep = dict.get("YStep");
 | 
				
			||||||
  let paintType = dict.get("PaintType");
 | 
					  const paintType = dict.get("PaintType");
 | 
				
			||||||
  let tilingType = dict.get("TilingType");
 | 
					  const tilingType = dict.get("TilingType");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Ensure that the pattern has a non-zero width and height, to prevent errors
 | 
					  // Ensure that the pattern has a non-zero width and height, to prevent errors
 | 
				
			||||||
  // in `pattern_helper.js` (fixes issue8330.pdf).
 | 
					  // in `pattern_helper.js` (fixes issue8330.pdf).
 | 
				
			||||||
 | 
				
			|||||||
@ -153,14 +153,14 @@ var Dict = (function DictClosure() {
 | 
				
			|||||||
  Dict.empty = new Dict(null);
 | 
					  Dict.empty = new Dict(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Dict.merge = function(xref, dictArray) {
 | 
					  Dict.merge = function(xref, dictArray) {
 | 
				
			||||||
    let mergedDict = new Dict(xref);
 | 
					    const mergedDict = new Dict(xref);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (let i = 0, ii = dictArray.length; i < ii; i++) {
 | 
					    for (let i = 0, ii = dictArray.length; i < ii; i++) {
 | 
				
			||||||
      let dict = dictArray[i];
 | 
					      const dict = dictArray[i];
 | 
				
			||||||
      if (!isDict(dict)) {
 | 
					      if (!isDict(dict)) {
 | 
				
			||||||
        continue;
 | 
					        continue;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      for (let keyName in dict._map) {
 | 
					      for (const keyName in dict._map) {
 | 
				
			||||||
        if (mergedDict._map[keyName] !== undefined) {
 | 
					        if (mergedDict._map[keyName] !== undefined) {
 | 
				
			||||||
          continue;
 | 
					          continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -76,7 +76,7 @@ var Stream = (function StreamClosure() {
 | 
				
			|||||||
      var strEnd = this.end;
 | 
					      var strEnd = this.end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!length) {
 | 
					      if (!length) {
 | 
				
			||||||
        let subarray = bytes.subarray(pos, strEnd);
 | 
					        const subarray = bytes.subarray(pos, strEnd);
 | 
				
			||||||
        // `this.bytes` is always a `Uint8Array` here.
 | 
					        // `this.bytes` is always a `Uint8Array` here.
 | 
				
			||||||
        return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
 | 
					        return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -85,7 +85,7 @@ var Stream = (function StreamClosure() {
 | 
				
			|||||||
        end = strEnd;
 | 
					        end = strEnd;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      this.pos = end;
 | 
					      this.pos = end;
 | 
				
			||||||
      let subarray = bytes.subarray(pos, end);
 | 
					      const subarray = bytes.subarray(pos, end);
 | 
				
			||||||
      // `this.bytes` is always a `Uint8Array` here.
 | 
					      // `this.bytes` is always a `Uint8Array` here.
 | 
				
			||||||
      return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
 | 
					      return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -134,7 +134,7 @@ var Stream = (function StreamClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var StringStream = (function StringStreamClosure() {
 | 
					var StringStream = (function StringStreamClosure() {
 | 
				
			||||||
  function StringStream(str) {
 | 
					  function StringStream(str) {
 | 
				
			||||||
    let bytes = stringToBytes(str);
 | 
					    const bytes = stringToBytes(str);
 | 
				
			||||||
    Stream.call(this, bytes);
 | 
					    Stream.call(this, bytes);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -235,7 +235,7 @@ var DecodeStream = (function DecodeStreamClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.pos = end;
 | 
					      this.pos = end;
 | 
				
			||||||
      let subarray = this.buffer.subarray(pos, end);
 | 
					      const subarray = this.buffer.subarray(pos, end);
 | 
				
			||||||
      // `this.buffer` is either a `Uint8Array` or `Uint8ClampedArray` here.
 | 
					      // `this.buffer` is either a `Uint8Array` or `Uint8ClampedArray` here.
 | 
				
			||||||
      return forceClamped && !(subarray instanceof Uint8ClampedArray)
 | 
					      return forceClamped && !(subarray instanceof Uint8ClampedArray)
 | 
				
			||||||
        ? new Uint8ClampedArray(subarray)
 | 
					        ? new Uint8ClampedArray(subarray)
 | 
				
			||||||
 | 
				
			|||||||
@ -1828,7 +1828,9 @@ const PDFWorker = (function PDFWorkerClosure() {
 | 
				
			|||||||
          });
 | 
					          });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          const sendTest = () => {
 | 
					          const sendTest = () => {
 | 
				
			||||||
            let testObj = new Uint8Array([this.postMessageTransfers ? 255 : 0]);
 | 
					            const testObj = new Uint8Array([
 | 
				
			||||||
 | 
					              this.postMessageTransfers ? 255 : 0,
 | 
				
			||||||
 | 
					            ]);
 | 
				
			||||||
            // Some versions of Opera throw a DATA_CLONE_ERR on serializing the
 | 
					            // Some versions of Opera throw a DATA_CLONE_ERR on serializing the
 | 
				
			||||||
            // typed array. Also, checking if we can use transfers.
 | 
					            // typed array. Also, checking if we can use transfers.
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@
 | 
				
			|||||||
 * limitations under the License.
 | 
					 * limitations under the License.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let compatibilityParams = Object.create(null);
 | 
					const compatibilityParams = Object.create(null);
 | 
				
			||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
					if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
				
			||||||
  const { isNodeJS } = require("../shared/is_node.js");
 | 
					  const { isNodeJS } = require("../shared/is_node.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -769,7 +769,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    var backdrop = smask.backdrop || null;
 | 
					    var backdrop = smask.backdrop || null;
 | 
				
			||||||
    if (!smask.transferMap && webGLContext.isEnabled) {
 | 
					    if (!smask.transferMap && webGLContext.isEnabled) {
 | 
				
			||||||
      let composed = webGLContext.composeSMask({
 | 
					      const composed = webGLContext.composeSMask({
 | 
				
			||||||
        layer: layerCtx.canvas,
 | 
					        layer: layerCtx.canvas,
 | 
				
			||||||
        mask,
 | 
					        mask,
 | 
				
			||||||
        properties: {
 | 
					        properties: {
 | 
				
			||||||
@ -1274,7 +1274,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
				
			|||||||
        // but the line width needs to be adjusted by the current transform, so
 | 
					        // but the line width needs to be adjusted by the current transform, so
 | 
				
			||||||
        // we must scale it. To properly fix this we should be using a pattern
 | 
					        // we must scale it. To properly fix this we should be using a pattern
 | 
				
			||||||
        // transform instead (see #10955).
 | 
					        // transform instead (see #10955).
 | 
				
			||||||
        let transform = ctx.mozCurrentTransform;
 | 
					        const transform = ctx.mozCurrentTransform;
 | 
				
			||||||
        const scale = Util.singularValueDecompose2dScale(transform)[0];
 | 
					        const scale = Util.singularValueDecompose2dScale(transform)[0];
 | 
				
			||||||
        ctx.strokeStyle = strokeColor.getPattern(ctx, this);
 | 
					        ctx.strokeStyle = strokeColor.getPattern(ctx, this);
 | 
				
			||||||
        ctx.lineWidth = Math.max(
 | 
					        ctx.lineWidth = Math.max(
 | 
				
			||||||
@ -1501,7 +1501,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
				
			|||||||
      var isAddToPathSet = !!(
 | 
					      var isAddToPathSet = !!(
 | 
				
			||||||
        textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG
 | 
					        textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      let patternFill = current.patternFill && font.data;
 | 
					      const patternFill = current.patternFill && font.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      var addToPath;
 | 
					      var addToPath;
 | 
				
			||||||
      if (font.disableFontFace || isAddToPathSet || patternFill) {
 | 
					      if (font.disableFontFace || isAddToPathSet || patternFill) {
 | 
				
			||||||
@ -1612,7 +1612,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
				
			|||||||
        // TODO: Patterns are not applied correctly to text if a non-embedded
 | 
					        // TODO: Patterns are not applied correctly to text if a non-embedded
 | 
				
			||||||
        // font is used. E.g. issue 8111 and ShowText-ShadingPattern.pdf.
 | 
					        // font is used. E.g. issue 8111 and ShowText-ShadingPattern.pdf.
 | 
				
			||||||
        ctx.save();
 | 
					        ctx.save();
 | 
				
			||||||
        let pattern = current.fillColor.getPattern(ctx, this);
 | 
					        const pattern = current.fillColor.getPattern(ctx, this);
 | 
				
			||||||
        patternTransform = ctx.mozCurrentTransform;
 | 
					        patternTransform = ctx.mozCurrentTransform;
 | 
				
			||||||
        ctx.restore();
 | 
					        ctx.restore();
 | 
				
			||||||
        ctx.fillStyle = pattern;
 | 
					        ctx.fillStyle = pattern;
 | 
				
			||||||
 | 
				
			|||||||
@ -47,7 +47,7 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
 | 
				
			|||||||
  tmp = rfc2231getparam(contentDisposition);
 | 
					  tmp = rfc2231getparam(contentDisposition);
 | 
				
			||||||
  if (tmp) {
 | 
					  if (tmp) {
 | 
				
			||||||
    // RFC 2047, section
 | 
					    // RFC 2047, section
 | 
				
			||||||
    let filename = rfc2047decode(tmp);
 | 
					    const filename = rfc2047decode(tmp);
 | 
				
			||||||
    return fixupEncoding(filename);
 | 
					    return fixupEncoding(filename);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -84,8 +84,8 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
 | 
				
			|||||||
        return value;
 | 
					        return value;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        let decoder = new TextDecoder(encoding, { fatal: true });
 | 
					        const decoder = new TextDecoder(encoding, { fatal: true });
 | 
				
			||||||
        let bytes = Array.from(value, function(ch) {
 | 
					        const bytes = Array.from(value, function(ch) {
 | 
				
			||||||
          return ch.charCodeAt(0) & 0xff;
 | 
					          return ch.charCodeAt(0) & 0xff;
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        value = decoder.decode(new Uint8Array(bytes));
 | 
					        value = decoder.decode(new Uint8Array(bytes));
 | 
				
			||||||
@ -120,7 +120,7 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
 | 
				
			|||||||
      match;
 | 
					      match;
 | 
				
			||||||
    // Iterate over all filename*n= and filename*n*= with n being an integer
 | 
					    // Iterate over all filename*n= and filename*n*= with n being an integer
 | 
				
			||||||
    // of at least zero. Any non-zero number must not start with '0'.
 | 
					    // of at least zero. Any non-zero number must not start with '0'.
 | 
				
			||||||
    let iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
 | 
					    const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
 | 
				
			||||||
    while ((match = iter.exec(contentDisposition)) !== null) {
 | 
					    while ((match = iter.exec(contentDisposition)) !== null) {
 | 
				
			||||||
      let [, n, quot, part] = match;
 | 
					      let [, n, quot, part] = match;
 | 
				
			||||||
      n = parseInt(n, 10);
 | 
					      n = parseInt(n, 10);
 | 
				
			||||||
@ -133,7 +133,7 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      matches[n] = [quot, part];
 | 
					      matches[n] = [quot, part];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let parts = [];
 | 
					    const parts = [];
 | 
				
			||||||
    for (let n = 0; n < matches.length; ++n) {
 | 
					    for (let n = 0; n < matches.length; ++n) {
 | 
				
			||||||
      if (!(n in matches)) {
 | 
					      if (!(n in matches)) {
 | 
				
			||||||
        // Numbers must be consecutive. Truncate when there is a hole.
 | 
					        // Numbers must be consecutive. Truncate when there is a hole.
 | 
				
			||||||
@ -153,10 +153,10 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  function rfc2616unquote(value) {
 | 
					  function rfc2616unquote(value) {
 | 
				
			||||||
    if (value.startsWith('"')) {
 | 
					    if (value.startsWith('"')) {
 | 
				
			||||||
      let parts = value.slice(1).split('\\"');
 | 
					      const parts = value.slice(1).split('\\"');
 | 
				
			||||||
      // Find the first unescaped " and terminate there.
 | 
					      // Find the first unescaped " and terminate there.
 | 
				
			||||||
      for (let i = 0; i < parts.length; ++i) {
 | 
					      for (let i = 0; i < parts.length; ++i) {
 | 
				
			||||||
        let quotindex = parts[i].indexOf('"');
 | 
					        const quotindex = parts[i].indexOf('"');
 | 
				
			||||||
        if (quotindex !== -1) {
 | 
					        if (quotindex !== -1) {
 | 
				
			||||||
          parts[i] = parts[i].slice(0, quotindex);
 | 
					          parts[i] = parts[i].slice(0, quotindex);
 | 
				
			||||||
          parts.length = i + 1; // Truncates and stop the iteration.
 | 
					          parts.length = i + 1; // Truncates and stop the iteration.
 | 
				
			||||||
@ -169,17 +169,17 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  function rfc5987decode(extvalue) {
 | 
					  function rfc5987decode(extvalue) {
 | 
				
			||||||
    // Decodes "ext-value" from RFC 5987.
 | 
					    // Decodes "ext-value" from RFC 5987.
 | 
				
			||||||
    let encodingend = extvalue.indexOf("'");
 | 
					    const encodingend = extvalue.indexOf("'");
 | 
				
			||||||
    if (encodingend === -1) {
 | 
					    if (encodingend === -1) {
 | 
				
			||||||
      // Some servers send "filename*=" without encoding 'language' prefix,
 | 
					      // Some servers send "filename*=" without encoding 'language' prefix,
 | 
				
			||||||
      // e.g. in https://github.com/Rob--W/open-in-browser/issues/26
 | 
					      // e.g. in https://github.com/Rob--W/open-in-browser/issues/26
 | 
				
			||||||
      // Let's accept the value like Firefox (57) (Chrome 62 rejects it).
 | 
					      // Let's accept the value like Firefox (57) (Chrome 62 rejects it).
 | 
				
			||||||
      return extvalue;
 | 
					      return extvalue;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let encoding = extvalue.slice(0, encodingend);
 | 
					    const encoding = extvalue.slice(0, encodingend);
 | 
				
			||||||
    let langvalue = extvalue.slice(encodingend + 1);
 | 
					    const langvalue = extvalue.slice(encodingend + 1);
 | 
				
			||||||
    // Ignore language (RFC 5987 section 3.2.1, and RFC 6266 section 4.1 ).
 | 
					    // Ignore language (RFC 5987 section 3.2.1, and RFC 6266 section 4.1 ).
 | 
				
			||||||
    let value = langvalue.replace(/^[^']*'/, "");
 | 
					    const value = langvalue.replace(/^[^']*'/, "");
 | 
				
			||||||
    return textdecode(encoding, value);
 | 
					    return textdecode(encoding, value);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  function rfc2047decode(value) {
 | 
					  function rfc2047decode(value) {
 | 
				
			||||||
 | 
				
			|||||||
@ -271,17 +271,17 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
 | 
				
			|||||||
        );
 | 
					        );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      function spliceString(s, offset, remove, insert) {
 | 
					      function spliceString(s, offset, remove, insert) {
 | 
				
			||||||
        let chunk1 = s.substring(0, offset);
 | 
					        const chunk1 = s.substring(0, offset);
 | 
				
			||||||
        let chunk2 = s.substring(offset + remove);
 | 
					        const chunk2 = s.substring(offset + remove);
 | 
				
			||||||
        return chunk1 + insert + chunk2;
 | 
					        return chunk1 + insert + chunk2;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let i, ii;
 | 
					      let i, ii;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // The temporary canvas is used to determine if fonts are loaded.
 | 
					      // The temporary canvas is used to determine if fonts are loaded.
 | 
				
			||||||
      let canvas = document.createElement("canvas");
 | 
					      const canvas = document.createElement("canvas");
 | 
				
			||||||
      canvas.width = 1;
 | 
					      canvas.width = 1;
 | 
				
			||||||
      canvas.height = 1;
 | 
					      canvas.height = 1;
 | 
				
			||||||
      let ctx = canvas.getContext("2d");
 | 
					      const ctx = canvas.getContext("2d");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let called = 0;
 | 
					      let called = 0;
 | 
				
			||||||
      function isFontReady(name, callback) {
 | 
					      function isFontReady(name, callback) {
 | 
				
			||||||
@ -294,7 +294,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        ctx.font = "30px " + name;
 | 
					        ctx.font = "30px " + name;
 | 
				
			||||||
        ctx.fillText(".", 0, 20);
 | 
					        ctx.fillText(".", 0, 20);
 | 
				
			||||||
        let imageData = ctx.getImageData(0, 0, 1, 1);
 | 
					        const imageData = ctx.getImageData(0, 0, 1, 1);
 | 
				
			||||||
        if (imageData.data[3] > 0) {
 | 
					        if (imageData.data[3] > 0) {
 | 
				
			||||||
          callback();
 | 
					          callback();
 | 
				
			||||||
          return;
 | 
					          return;
 | 
				
			||||||
@ -309,7 +309,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
 | 
				
			|||||||
      // TODO: This could maybe be made faster by avoiding the btoa of the full
 | 
					      // TODO: This could maybe be made faster by avoiding the btoa of the full
 | 
				
			||||||
      // font by splitting it in chunks before hand and padding the font id.
 | 
					      // font by splitting it in chunks before hand and padding the font id.
 | 
				
			||||||
      let data = this._loadTestFont;
 | 
					      let data = this._loadTestFont;
 | 
				
			||||||
      let COMMENT_OFFSET = 976; // has to be on 4 byte boundary (for checksum)
 | 
					      const COMMENT_OFFSET = 976; // has to be on 4 byte boundary (for checksum)
 | 
				
			||||||
      data = spliceString(
 | 
					      data = spliceString(
 | 
				
			||||||
        data,
 | 
					        data,
 | 
				
			||||||
        COMMENT_OFFSET,
 | 
					        COMMENT_OFFSET,
 | 
				
			||||||
@ -317,8 +317,8 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
 | 
				
			|||||||
        loadTestFontId
 | 
					        loadTestFontId
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      // CFF checksum is important for IE, adjusting it
 | 
					      // CFF checksum is important for IE, adjusting it
 | 
				
			||||||
      let CFF_CHECKSUM_OFFSET = 16;
 | 
					      const CFF_CHECKSUM_OFFSET = 16;
 | 
				
			||||||
      let XXXX_VALUE = 0x58585858; // the "comment" filled with 'X'
 | 
					      const XXXX_VALUE = 0x58585858; // the "comment" filled with 'X'
 | 
				
			||||||
      let checksum = int32(data, CFF_CHECKSUM_OFFSET);
 | 
					      let checksum = int32(data, CFF_CHECKSUM_OFFSET);
 | 
				
			||||||
      for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
 | 
					      for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
 | 
				
			||||||
        checksum = (checksum - XXXX_VALUE + int32(loadTestFontId, i)) | 0;
 | 
					        checksum = (checksum - XXXX_VALUE + int32(loadTestFontId, i)) | 0;
 | 
				
			||||||
@ -334,13 +334,13 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
 | 
				
			|||||||
      const rule = `@font-face {font-family:"${loadTestFontId}";src:${url}}`;
 | 
					      const rule = `@font-face {font-family:"${loadTestFontId}";src:${url}}`;
 | 
				
			||||||
      this.insertRule(rule);
 | 
					      this.insertRule(rule);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let names = [];
 | 
					      const names = [];
 | 
				
			||||||
      for (i = 0, ii = fonts.length; i < ii; i++) {
 | 
					      for (i = 0, ii = fonts.length; i < ii; i++) {
 | 
				
			||||||
        names.push(fonts[i].loadedName);
 | 
					        names.push(fonts[i].loadedName);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      names.push(loadTestFontId);
 | 
					      names.push(loadTestFontId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let div = document.createElement("div");
 | 
					      const div = document.createElement("div");
 | 
				
			||||||
      div.setAttribute(
 | 
					      div.setAttribute(
 | 
				
			||||||
        "style",
 | 
					        "style",
 | 
				
			||||||
        "visibility: hidden;" +
 | 
					        "visibility: hidden;" +
 | 
				
			||||||
@ -348,7 +348,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
 | 
				
			|||||||
          "position: absolute; top: 0px; left: 0px;"
 | 
					          "position: absolute; top: 0px; left: 0px;"
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      for (i = 0, ii = names.length; i < ii; ++i) {
 | 
					      for (i = 0, ii = names.length; i < ii; ++i) {
 | 
				
			||||||
        let span = document.createElement("span");
 | 
					        const span = document.createElement("span");
 | 
				
			||||||
        span.textContent = "Hi";
 | 
					        span.textContent = "Hi";
 | 
				
			||||||
        span.style.fontFamily = names[i];
 | 
					        span.style.fontFamily = names[i];
 | 
				
			||||||
        div.appendChild(span);
 | 
					        div.appendChild(span);
 | 
				
			||||||
@ -383,7 +383,7 @@ class FontFaceObject {
 | 
				
			|||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    this.compiledGlyphs = Object.create(null);
 | 
					    this.compiledGlyphs = Object.create(null);
 | 
				
			||||||
    // importing translated data
 | 
					    // importing translated data
 | 
				
			||||||
    for (let i in translatedData) {
 | 
					    for (const i in translatedData) {
 | 
				
			||||||
      this[i] = translatedData[i];
 | 
					      this[i] = translatedData[i];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    this.isEvalSupported = isEvalSupported !== false;
 | 
					    this.isEvalSupported = isEvalSupported !== false;
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ class Metadata {
 | 
				
			|||||||
    data = this._repair(data);
 | 
					    data = this._repair(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Convert the string to an XML document.
 | 
					    // Convert the string to an XML document.
 | 
				
			||||||
    let parser = new SimpleXMLParser();
 | 
					    const parser = new SimpleXMLParser();
 | 
				
			||||||
    const xmlDocument = parser.parseFromString(data);
 | 
					    const xmlDocument = parser.parseFromString(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this._metadata = Object.create(null);
 | 
					    this._metadata = Object.create(null);
 | 
				
			||||||
@ -39,7 +39,7 @@ class Metadata {
 | 
				
			|||||||
    return data
 | 
					    return data
 | 
				
			||||||
      .replace(/^([^<]+)/, "")
 | 
					      .replace(/^([^<]+)/, "")
 | 
				
			||||||
      .replace(/>\\376\\377([^<]+)/g, function(all, codes) {
 | 
					      .replace(/>\\376\\377([^<]+)/g, function(all, codes) {
 | 
				
			||||||
        let bytes = codes
 | 
					        const bytes = codes
 | 
				
			||||||
          .replace(/\\([0-3])([0-7])([0-7])/g, function(code, d1, d2, d3) {
 | 
					          .replace(/\\([0-3])([0-7])([0-7])/g, function(code, d1, d2, d3) {
 | 
				
			||||||
            return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
 | 
					            return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
 | 
				
			||||||
          })
 | 
					          })
 | 
				
			||||||
@ -61,7 +61,7 @@ class Metadata {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        let chars = "";
 | 
					        let chars = "";
 | 
				
			||||||
        for (let i = 0, ii = bytes.length; i < ii; i += 2) {
 | 
					        for (let i = 0, ii = bytes.length; i < ii; i += 2) {
 | 
				
			||||||
          let code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
 | 
					          const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
 | 
				
			||||||
          if (
 | 
					          if (
 | 
				
			||||||
            code >= 32 &&
 | 
					            code >= 32 &&
 | 
				
			||||||
            code < 127 &&
 | 
					            code < 127 &&
 | 
				
			||||||
@ -90,22 +90,22 @@ class Metadata {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
 | 
					    const nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
 | 
				
			||||||
    if (!rdf || nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
 | 
					    if (!rdf || nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let children = rdf.childNodes;
 | 
					    const children = rdf.childNodes;
 | 
				
			||||||
    for (let i = 0, ii = children.length; i < ii; i++) {
 | 
					    for (let i = 0, ii = children.length; i < ii; i++) {
 | 
				
			||||||
      let desc = children[i];
 | 
					      const desc = children[i];
 | 
				
			||||||
      if (desc.nodeName.toLowerCase() !== "rdf:description") {
 | 
					      if (desc.nodeName.toLowerCase() !== "rdf:description") {
 | 
				
			||||||
        continue;
 | 
					        continue;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for (let j = 0, jj = desc.childNodes.length; j < jj; j++) {
 | 
					      for (let j = 0, jj = desc.childNodes.length; j < jj; j++) {
 | 
				
			||||||
        if (desc.childNodes[j].nodeName.toLowerCase() !== "#text") {
 | 
					        if (desc.childNodes[j].nodeName.toLowerCase() !== "#text") {
 | 
				
			||||||
          let entry = desc.childNodes[j];
 | 
					          const entry = desc.childNodes[j];
 | 
				
			||||||
          let name = entry.nodeName.toLowerCase();
 | 
					          const name = entry.nodeName.toLowerCase();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          this._metadata[name] = entry.textContent.trim();
 | 
					          this._metadata[name] = entry.textContent.trim();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -27,12 +27,12 @@ function validateRangeRequestCapabilities({
 | 
				
			|||||||
  disableRange,
 | 
					  disableRange,
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
  assert(rangeChunkSize > 0, "Range chunk size must be larger than zero");
 | 
					  assert(rangeChunkSize > 0, "Range chunk size must be larger than zero");
 | 
				
			||||||
  let returnValues = {
 | 
					  const returnValues = {
 | 
				
			||||||
    allowRangeRequests: false,
 | 
					    allowRangeRequests: false,
 | 
				
			||||||
    suggestedLength: undefined,
 | 
					    suggestedLength: undefined,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let length = parseInt(getResponseHeader("Content-Length"), 10);
 | 
					  const length = parseInt(getResponseHeader("Content-Length"), 10);
 | 
				
			||||||
  if (!Number.isInteger(length)) {
 | 
					  if (!Number.isInteger(length)) {
 | 
				
			||||||
    return returnValues;
 | 
					    return returnValues;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -52,7 +52,7 @@ function validateRangeRequestCapabilities({
 | 
				
			|||||||
    return returnValues;
 | 
					    return returnValues;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let contentEncoding = getResponseHeader("Content-Encoding") || "identity";
 | 
					  const contentEncoding = getResponseHeader("Content-Encoding") || "identity";
 | 
				
			||||||
  if (contentEncoding !== "identity") {
 | 
					  if (contentEncoding !== "identity") {
 | 
				
			||||||
    return returnValues;
 | 
					    return returnValues;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -14,10 +14,10 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
/* globals __non_webpack_require__ */
 | 
					/* globals __non_webpack_require__ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let fs = __non_webpack_require__("fs");
 | 
					const fs = __non_webpack_require__("fs");
 | 
				
			||||||
let http = __non_webpack_require__("http");
 | 
					const http = __non_webpack_require__("http");
 | 
				
			||||||
let https = __non_webpack_require__("https");
 | 
					const https = __non_webpack_require__("https");
 | 
				
			||||||
let url = __non_webpack_require__("url");
 | 
					const url = __non_webpack_require__("url");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  AbortException,
 | 
					  AbortException,
 | 
				
			||||||
@ -33,7 +33,7 @@ import {
 | 
				
			|||||||
const fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
 | 
					const fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function parseUrl(sourceUrl) {
 | 
					function parseUrl(sourceUrl) {
 | 
				
			||||||
  let parsedUrl = url.parse(sourceUrl);
 | 
					  const parsedUrl = url.parse(sourceUrl);
 | 
				
			||||||
  if (parsedUrl.protocol === "file:" || parsedUrl.host) {
 | 
					  if (parsedUrl.protocol === "file:" || parsedUrl.host) {
 | 
				
			||||||
    return parsedUrl;
 | 
					    return parsedUrl;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -78,7 +78,7 @@ class PDFNodeStream {
 | 
				
			|||||||
    if (end <= this._progressiveDataLength) {
 | 
					    if (end <= this._progressiveDataLength) {
 | 
				
			||||||
      return null;
 | 
					      return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    let rangeReader = this.isFsUrl
 | 
					    const rangeReader = this.isFsUrl
 | 
				
			||||||
      ? new PDFNodeStreamFsRangeReader(this, start, end)
 | 
					      ? new PDFNodeStreamFsRangeReader(this, start, end)
 | 
				
			||||||
      : new PDFNodeStreamRangeReader(this, start, end);
 | 
					      : new PDFNodeStreamRangeReader(this, start, end);
 | 
				
			||||||
    this._rangeRequestReaders.push(rangeReader);
 | 
					    this._rangeRequestReaders.push(rangeReader);
 | 
				
			||||||
@ -90,7 +90,7 @@ class PDFNodeStream {
 | 
				
			|||||||
      this._fullRequestReader.cancel(reason);
 | 
					      this._fullRequestReader.cancel(reason);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let readers = this._rangeRequestReaders.slice(0);
 | 
					    const readers = this._rangeRequestReaders.slice(0);
 | 
				
			||||||
    readers.forEach(function(reader) {
 | 
					    readers.forEach(function(reader) {
 | 
				
			||||||
      reader.cancel(reason);
 | 
					      reader.cancel(reason);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -103,7 +103,7 @@ class BaseFullReader {
 | 
				
			|||||||
    this._done = false;
 | 
					    this._done = false;
 | 
				
			||||||
    this._storedError = null;
 | 
					    this._storedError = null;
 | 
				
			||||||
    this.onProgress = null;
 | 
					    this.onProgress = null;
 | 
				
			||||||
    let source = stream.source;
 | 
					    const source = stream.source;
 | 
				
			||||||
    this._contentLength = source.length; // optional
 | 
					    this._contentLength = source.length; // optional
 | 
				
			||||||
    this._loaded = 0;
 | 
					    this._loaded = 0;
 | 
				
			||||||
    this._filename = null;
 | 
					    this._filename = null;
 | 
				
			||||||
@ -151,7 +151,7 @@ class BaseFullReader {
 | 
				
			|||||||
      throw this._storedError;
 | 
					      throw this._storedError;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let chunk = this._readableStream.read();
 | 
					    const chunk = this._readableStream.read();
 | 
				
			||||||
    if (chunk === null) {
 | 
					    if (chunk === null) {
 | 
				
			||||||
      this._readCapability = createPromiseCapability();
 | 
					      this._readCapability = createPromiseCapability();
 | 
				
			||||||
      return this.read();
 | 
					      return this.read();
 | 
				
			||||||
@ -164,7 +164,7 @@ class BaseFullReader {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Ensure that `read()` method returns ArrayBuffer.
 | 
					    // Ensure that `read()` method returns ArrayBuffer.
 | 
				
			||||||
    let buffer = new Uint8Array(chunk).buffer;
 | 
					    const buffer = new Uint8Array(chunk).buffer;
 | 
				
			||||||
    return { value: buffer, done: false };
 | 
					    return { value: buffer, done: false };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -222,7 +222,7 @@ class BaseRangeReader {
 | 
				
			|||||||
    this._loaded = 0;
 | 
					    this._loaded = 0;
 | 
				
			||||||
    this._readableStream = null;
 | 
					    this._readableStream = null;
 | 
				
			||||||
    this._readCapability = createPromiseCapability();
 | 
					    this._readCapability = createPromiseCapability();
 | 
				
			||||||
    let source = stream.source;
 | 
					    const source = stream.source;
 | 
				
			||||||
    this._isStreamingSupported = !source.disableStream;
 | 
					    this._isStreamingSupported = !source.disableStream;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -239,7 +239,7 @@ class BaseRangeReader {
 | 
				
			|||||||
      throw this._storedError;
 | 
					      throw this._storedError;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let chunk = this._readableStream.read();
 | 
					    const chunk = this._readableStream.read();
 | 
				
			||||||
    if (chunk === null) {
 | 
					    if (chunk === null) {
 | 
				
			||||||
      this._readCapability = createPromiseCapability();
 | 
					      this._readCapability = createPromiseCapability();
 | 
				
			||||||
      return this.read();
 | 
					      return this.read();
 | 
				
			||||||
@ -249,7 +249,7 @@ class BaseRangeReader {
 | 
				
			|||||||
      this.onProgress({ loaded: this._loaded });
 | 
					      this.onProgress({ loaded: this._loaded });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Ensure that `read()` method returns ArrayBuffer.
 | 
					    // Ensure that `read()` method returns ArrayBuffer.
 | 
				
			||||||
    let buffer = new Uint8Array(chunk).buffer;
 | 
					    const buffer = new Uint8Array(chunk).buffer;
 | 
				
			||||||
    return { value: buffer, done: false };
 | 
					    return { value: buffer, done: false };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -308,7 +308,7 @@ class PDFNodeStreamFullReader extends BaseFullReader {
 | 
				
			|||||||
  constructor(stream) {
 | 
					  constructor(stream) {
 | 
				
			||||||
    super(stream);
 | 
					    super(stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let handleResponse = response => {
 | 
					    const handleResponse = response => {
 | 
				
			||||||
      if (response.statusCode === 404) {
 | 
					      if (response.statusCode === 404) {
 | 
				
			||||||
        const error = new MissingPDFException(`Missing PDF "${this._url}".`);
 | 
					        const error = new MissingPDFException(`Missing PDF "${this._url}".`);
 | 
				
			||||||
        this._storedError = error;
 | 
					        this._storedError = error;
 | 
				
			||||||
@ -323,7 +323,7 @@ class PDFNodeStreamFullReader extends BaseFullReader {
 | 
				
			|||||||
        // here: https://nodejs.org/api/http.html#http_message_headers.
 | 
					        // here: https://nodejs.org/api/http.html#http_message_headers.
 | 
				
			||||||
        return this._readableStream.headers[name.toLowerCase()];
 | 
					        return this._readableStream.headers[name.toLowerCase()];
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      let {
 | 
					      const {
 | 
				
			||||||
        allowRangeRequests,
 | 
					        allowRangeRequests,
 | 
				
			||||||
        suggestedLength,
 | 
					        suggestedLength,
 | 
				
			||||||
      } = validateRangeRequestCapabilities({
 | 
					      } = validateRangeRequestCapabilities({
 | 
				
			||||||
@ -369,8 +369,8 @@ class PDFNodeStreamRangeReader extends BaseRangeReader {
 | 
				
			|||||||
    super(stream);
 | 
					    super(stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this._httpHeaders = {};
 | 
					    this._httpHeaders = {};
 | 
				
			||||||
    for (let property in stream.httpHeaders) {
 | 
					    for (const property in stream.httpHeaders) {
 | 
				
			||||||
      let value = stream.httpHeaders[property];
 | 
					      const value = stream.httpHeaders[property];
 | 
				
			||||||
      if (typeof value === "undefined") {
 | 
					      if (typeof value === "undefined") {
 | 
				
			||||||
        continue;
 | 
					        continue;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -378,7 +378,7 @@ class PDFNodeStreamRangeReader extends BaseRangeReader {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    this._httpHeaders["Range"] = `bytes=${start}-${end - 1}`;
 | 
					    this._httpHeaders["Range"] = `bytes=${start}-${end - 1}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let handleResponse = response => {
 | 
					    const handleResponse = response => {
 | 
				
			||||||
      if (response.statusCode === 404) {
 | 
					      if (response.statusCode === 404) {
 | 
				
			||||||
        const error = new MissingPDFException(`Missing PDF "${this._url}".`);
 | 
					        const error = new MissingPDFException(`Missing PDF "${this._url}".`);
 | 
				
			||||||
        this._storedError = error;
 | 
					        this._storedError = error;
 | 
				
			||||||
 | 
				
			|||||||
@ -555,7 +555,7 @@ var TilingPattern = (function TilingPatternClosure() {
 | 
				
			|||||||
      paintType,
 | 
					      paintType,
 | 
				
			||||||
      color
 | 
					      color
 | 
				
			||||||
    ) {
 | 
					    ) {
 | 
				
			||||||
      let context = graphics.ctx,
 | 
					      const context = graphics.ctx,
 | 
				
			||||||
        current = graphics.current;
 | 
					        current = graphics.current;
 | 
				
			||||||
      switch (paintType) {
 | 
					      switch (paintType) {
 | 
				
			||||||
        case PaintType.COLORED:
 | 
					        case PaintType.COLORED:
 | 
				
			||||||
 | 
				
			|||||||
@ -594,11 +594,11 @@ var renderTextLayer = (function renderTextLayerClosure() {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _render: function TextLayer_render(timeout) {
 | 
					    _render: function TextLayer_render(timeout) {
 | 
				
			||||||
      let capability = createPromiseCapability();
 | 
					      const capability = createPromiseCapability();
 | 
				
			||||||
      let styleCache = Object.create(null);
 | 
					      let styleCache = Object.create(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // The temporary canvas is used to measure text length in the DOM.
 | 
					      // The temporary canvas is used to measure text length in the DOM.
 | 
				
			||||||
      let canvas = document.createElement("canvas");
 | 
					      const canvas = document.createElement("canvas");
 | 
				
			||||||
      if (
 | 
					      if (
 | 
				
			||||||
        typeof PDFJSDev === "undefined" ||
 | 
					        typeof PDFJSDev === "undefined" ||
 | 
				
			||||||
        PDFJSDev.test("MOZCENTRAL || GENERIC")
 | 
					        PDFJSDev.test("MOZCENTRAL || GENERIC")
 | 
				
			||||||
@ -608,12 +608,12 @@ var renderTextLayer = (function renderTextLayerClosure() {
 | 
				
			|||||||
      this._layoutTextCtx = canvas.getContext("2d", { alpha: false });
 | 
					      this._layoutTextCtx = canvas.getContext("2d", { alpha: false });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (this._textContent) {
 | 
					      if (this._textContent) {
 | 
				
			||||||
        let textItems = this._textContent.items;
 | 
					        const textItems = this._textContent.items;
 | 
				
			||||||
        let textStyles = this._textContent.styles;
 | 
					        const textStyles = this._textContent.styles;
 | 
				
			||||||
        this._processItems(textItems, textStyles);
 | 
					        this._processItems(textItems, textStyles);
 | 
				
			||||||
        capability.resolve();
 | 
					        capability.resolve();
 | 
				
			||||||
      } else if (this._textContentStream) {
 | 
					      } else if (this._textContentStream) {
 | 
				
			||||||
        let pump = () => {
 | 
					        const pump = () => {
 | 
				
			||||||
          this._reader.read().then(({ value, done }) => {
 | 
					          this._reader.read().then(({ value, done }) => {
 | 
				
			||||||
            if (done) {
 | 
					            if (done) {
 | 
				
			||||||
              capability.resolve();
 | 
					              capability.resolve();
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/pdf.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/pdf.js
									
									
									
									
									
								
							@ -27,18 +27,18 @@ var pdfjsDisplayTextLayer = require("./display/text_layer.js");
 | 
				
			|||||||
var pdfjsDisplayAnnotationLayer = require("./display/annotation_layer.js");
 | 
					var pdfjsDisplayAnnotationLayer = require("./display/annotation_layer.js");
 | 
				
			||||||
var pdfjsDisplayDisplayUtils = require("./display/display_utils.js");
 | 
					var pdfjsDisplayDisplayUtils = require("./display/display_utils.js");
 | 
				
			||||||
var pdfjsDisplaySVG = require("./display/svg.js");
 | 
					var pdfjsDisplaySVG = require("./display/svg.js");
 | 
				
			||||||
let pdfjsDisplayWorkerOptions = require("./display/worker_options.js");
 | 
					const pdfjsDisplayWorkerOptions = require("./display/worker_options.js");
 | 
				
			||||||
let pdfjsDisplayAPICompatibility = require("./display/api_compatibility.js");
 | 
					const pdfjsDisplayAPICompatibility = require("./display/api_compatibility.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
					if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
				
			||||||
  const { isNodeJS } = require("./shared/is_node.js");
 | 
					  const { isNodeJS } = require("./shared/is_node.js");
 | 
				
			||||||
  if (isNodeJS) {
 | 
					  if (isNodeJS) {
 | 
				
			||||||
    let PDFNodeStream = require("./display/node_stream.js").PDFNodeStream;
 | 
					    const PDFNodeStream = require("./display/node_stream.js").PDFNodeStream;
 | 
				
			||||||
    pdfjsDisplayAPI.setPDFNetworkStreamFactory(params => {
 | 
					    pdfjsDisplayAPI.setPDFNetworkStreamFactory(params => {
 | 
				
			||||||
      return new PDFNodeStream(params);
 | 
					      return new PDFNodeStream(params);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    let PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
 | 
					    const PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
 | 
				
			||||||
    let PDFFetchStream;
 | 
					    let PDFFetchStream;
 | 
				
			||||||
    if (pdfjsDisplayDisplayUtils.isFetchSupported()) {
 | 
					    if (pdfjsDisplayDisplayUtils.isFetchSupported()) {
 | 
				
			||||||
      PDFFetchStream = require("./display/fetch_stream.js").PDFFetchStream;
 | 
					      PDFFetchStream = require("./display/fetch_stream.js").PDFFetchStream;
 | 
				
			||||||
@ -54,9 +54,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
} else if (PDFJSDev.test("CHROME")) {
 | 
					} else if (PDFJSDev.test("CHROME")) {
 | 
				
			||||||
  let PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
 | 
					  const PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
 | 
				
			||||||
  let PDFFetchStream;
 | 
					  let PDFFetchStream;
 | 
				
			||||||
  let isChromeWithFetchCredentials = function() {
 | 
					  const isChromeWithFetchCredentials = function() {
 | 
				
			||||||
    // fetch does not include credentials until Chrome 61.0.3138.0 and later.
 | 
					    // fetch does not include credentials until Chrome 61.0.3138.0 and later.
 | 
				
			||||||
    // https://chromium.googlesource.com/chromium/src/+/2e231cf052ca5e68e22baf0008ac9e5e29121707
 | 
					    // https://chromium.googlesource.com/chromium/src/+/2e231cf052ca5e68e22baf0008ac9e5e29121707
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
 | 
				
			|||||||
@ -93,12 +93,12 @@ if (
 | 
				
			|||||||
    const OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
 | 
					    const OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DOMTokenList.prototype.add = function(...tokens) {
 | 
					    DOMTokenList.prototype.add = function(...tokens) {
 | 
				
			||||||
      for (let token of tokens) {
 | 
					      for (const token of tokens) {
 | 
				
			||||||
        OriginalDOMTokenListAdd.call(this, token);
 | 
					        OriginalDOMTokenListAdd.call(this, token);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    DOMTokenList.prototype.remove = function(...tokens) {
 | 
					    DOMTokenList.prototype.remove = function(...tokens) {
 | 
				
			||||||
      for (let token of tokens) {
 | 
					      for (const token of tokens) {
 | 
				
			||||||
        OriginalDOMTokenListRemove.call(this, token);
 | 
					        OriginalDOMTokenListRemove.call(this, token);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@ -117,7 +117,8 @@ if (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DOMTokenList.prototype.toggle = function(token) {
 | 
					    DOMTokenList.prototype.toggle = function(token) {
 | 
				
			||||||
      let force = arguments.length > 1 ? !!arguments[1] : !this.contains(token);
 | 
					      const force =
 | 
				
			||||||
 | 
					        arguments.length > 1 ? !!arguments[1] : !this.contains(token);
 | 
				
			||||||
      return this[force ? "add" : "remove"](token), force;
 | 
					      return this[force ? "add" : "remove"](token), force;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  })();
 | 
					  })();
 | 
				
			||||||
 | 
				
			|||||||
@ -804,7 +804,7 @@ function utf8StringToString(str) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function isEmptyObj(obj) {
 | 
					function isEmptyObj(obj) {
 | 
				
			||||||
  for (let key in obj) {
 | 
					  for (const key in obj) {
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,7 @@ if (process.argv.length < 3) {
 | 
				
			|||||||
  process.exit(1);
 | 
					  process.exit(1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let file = process.argv[2];
 | 
					const file = process.argv[2];
 | 
				
			||||||
if (!file.startsWith(pdfFolder)) {
 | 
					if (!file.startsWith(pdfFolder)) {
 | 
				
			||||||
  throw new Error(`PDF file must be in '${pdfFolder}' directory.`);
 | 
					  throw new Error(`PDF file must be in '${pdfFolder}' directory.`);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -46,7 +46,7 @@ calculateMD5(file, (err, md5) => {
 | 
				
			|||||||
    throw new Error(err);
 | 
					    throw new Error(err);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  let contents = fs.readFileSync(gitIgnore, "utf8").split("\n");
 | 
					  let contents = fs.readFileSync(gitIgnore, "utf8").split("\n");
 | 
				
			||||||
  let randomLine = getRandomArbitrary(10, contents.length - 2);
 | 
					  const randomLine = getRandomArbitrary(10, contents.length - 2);
 | 
				
			||||||
  contents.splice(
 | 
					  contents.splice(
 | 
				
			||||||
    randomLine,
 | 
					    randomLine,
 | 
				
			||||||
    0,
 | 
					    0,
 | 
				
			||||||
@ -55,10 +55,10 @@ calculateMD5(file, (err, md5) => {
 | 
				
			|||||||
  fs.writeFileSync("test/pdfs/.gitignore", contents.join("\n"));
 | 
					  fs.writeFileSync("test/pdfs/.gitignore", contents.join("\n"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  contents = fs.readFileSync(testManifest, "utf8");
 | 
					  contents = fs.readFileSync(testManifest, "utf8");
 | 
				
			||||||
  let pdf = file.substring(file.lastIndexOf("/") + 1, file.length - 4);
 | 
					  const pdf = file.substring(file.lastIndexOf("/") + 1, file.length - 4);
 | 
				
			||||||
  let randomPoint = getRandomArbitrary(100, contents.length - 20);
 | 
					  const randomPoint = getRandomArbitrary(100, contents.length - 20);
 | 
				
			||||||
  let bracket = contents.indexOf("},\n", randomPoint);
 | 
					  const bracket = contents.indexOf("},\n", randomPoint);
 | 
				
			||||||
  let out =
 | 
					  const out =
 | 
				
			||||||
    contents.substring(0, bracket) +
 | 
					    contents.substring(0, bracket) +
 | 
				
			||||||
    "},\n" +
 | 
					    "},\n" +
 | 
				
			||||||
    `    {  "id": "${pdf}",\n` +
 | 
					    `    {  "id": "${pdf}",\n` +
 | 
				
			||||||
 | 
				
			|||||||
@ -119,7 +119,7 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
 | 
				
			|||||||
   * the overrides file because the browser does not resolve that when the
 | 
					   * the overrides file because the browser does not resolve that when the
 | 
				
			||||||
   * styles are inserted via XHR. Therefore, we load and combine them here.
 | 
					   * styles are inserted via XHR. Therefore, we load and combine them here.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  let styles = {
 | 
					  const styles = {
 | 
				
			||||||
    common: {
 | 
					    common: {
 | 
				
			||||||
      file: "../web/annotation_layer_builder.css",
 | 
					      file: "../web/annotation_layer_builder.css",
 | 
				
			||||||
      promise: null,
 | 
					      promise: null,
 | 
				
			||||||
@ -137,9 +137,9 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Load the style files and cache the results.
 | 
					    // Load the style files and cache the results.
 | 
				
			||||||
    for (let key in styles) {
 | 
					    for (const key in styles) {
 | 
				
			||||||
      styles[key].promise = new Promise(function(resolve, reject) {
 | 
					      styles[key].promise = new Promise(function(resolve, reject) {
 | 
				
			||||||
        let xhr = new XMLHttpRequest();
 | 
					        const xhr = new XMLHttpRequest();
 | 
				
			||||||
        xhr.open("GET", styles[key].file);
 | 
					        xhr.open("GET", styles[key].file);
 | 
				
			||||||
        xhr.onload = function() {
 | 
					        xhr.onload = function() {
 | 
				
			||||||
          resolve(xhr.responseText);
 | 
					          resolve(xhr.responseText);
 | 
				
			||||||
@ -379,14 +379,14 @@ var Driver = (function DriverClosure() {
 | 
				
			|||||||
          this._done();
 | 
					          this._done();
 | 
				
			||||||
          return;
 | 
					          return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let task = this.manifest[this.currentTask];
 | 
					        const task = this.manifest[this.currentTask];
 | 
				
			||||||
        task.round = 0;
 | 
					        task.round = 0;
 | 
				
			||||||
        task.pageNum = task.firstPage || 1;
 | 
					        task.pageNum = task.firstPage || 1;
 | 
				
			||||||
        task.stats = { times: [] };
 | 
					        task.stats = { times: [] };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this._log('Loading file "' + task.file + '"\n');
 | 
					        this._log('Loading file "' + task.file + '"\n');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let absoluteUrl = new URL(task.file, window.location).href;
 | 
					        const absoluteUrl = new URL(task.file, window.location).href;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
          const loadingTask = pdfjsLib.getDocument({
 | 
					          const loadingTask = pdfjsLib.getDocument({
 | 
				
			||||||
            url: absoluteUrl,
 | 
					            url: absoluteUrl,
 | 
				
			||||||
@ -419,18 +419,18 @@ var Driver = (function DriverClosure() {
 | 
				
			|||||||
    _cleanup() {
 | 
					    _cleanup() {
 | 
				
			||||||
      // Clear out all the stylesheets since a new one is created for each font.
 | 
					      // Clear out all the stylesheets since a new one is created for each font.
 | 
				
			||||||
      while (document.styleSheets.length > 0) {
 | 
					      while (document.styleSheets.length > 0) {
 | 
				
			||||||
        let styleSheet = document.styleSheets[0];
 | 
					        const styleSheet = document.styleSheets[0];
 | 
				
			||||||
        while (styleSheet.cssRules.length > 0) {
 | 
					        while (styleSheet.cssRules.length > 0) {
 | 
				
			||||||
          styleSheet.deleteRule(0);
 | 
					          styleSheet.deleteRule(0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        styleSheet.ownerNode.remove();
 | 
					        styleSheet.ownerNode.remove();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let body = document.body;
 | 
					      const body = document.body;
 | 
				
			||||||
      while (body.lastChild !== this.end) {
 | 
					      while (body.lastChild !== this.end) {
 | 
				
			||||||
        body.removeChild(body.lastChild);
 | 
					        body.removeChild(body.lastChild);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let destroyedPromises = [];
 | 
					      const destroyedPromises = [];
 | 
				
			||||||
      // Wipe out the link to the pdfdoc so it can be GC'ed.
 | 
					      // Wipe out the link to the pdfdoc so it can be GC'ed.
 | 
				
			||||||
      for (let i = 0; i < this.manifest.length; i++) {
 | 
					      for (let i = 0; i < this.manifest.length; i++) {
 | 
				
			||||||
        if (this.manifest[i].pdfDoc) {
 | 
					        if (this.manifest[i].pdfDoc) {
 | 
				
			||||||
 | 
				
			|||||||
@ -1174,20 +1174,22 @@ describe("annotation", function() {
 | 
				
			|||||||
      "should correctly parse a Dest, which violates the specification " +
 | 
					      "should correctly parse a Dest, which violates the specification " +
 | 
				
			||||||
        "by containing a dictionary",
 | 
					        "by containing a dictionary",
 | 
				
			||||||
      function(done) {
 | 
					      function(done) {
 | 
				
			||||||
        let destDict = new Dict();
 | 
					        const destDict = new Dict();
 | 
				
			||||||
        destDict.set("Type", Name.get("Action"));
 | 
					        destDict.set("Type", Name.get("Action"));
 | 
				
			||||||
        destDict.set("S", Name.get("GoTo"));
 | 
					        destDict.set("S", Name.get("GoTo"));
 | 
				
			||||||
        destDict.set("D", "page.157");
 | 
					        destDict.set("D", "page.157");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let annotationDict = new Dict();
 | 
					        const annotationDict = new Dict();
 | 
				
			||||||
        annotationDict.set("Type", Name.get("Annot"));
 | 
					        annotationDict.set("Type", Name.get("Annot"));
 | 
				
			||||||
        annotationDict.set("Subtype", Name.get("Link"));
 | 
					        annotationDict.set("Subtype", Name.get("Link"));
 | 
				
			||||||
        // The /Dest must be a Name or an Array, refer to ISO 32000-1:2008
 | 
					        // The /Dest must be a Name or an Array, refer to ISO 32000-1:2008
 | 
				
			||||||
        // section 12.3.3, but there are PDF files where it's a dictionary.
 | 
					        // section 12.3.3, but there are PDF files where it's a dictionary.
 | 
				
			||||||
        annotationDict.set("Dest", destDict);
 | 
					        annotationDict.set("Dest", destDict);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let annotationRef = Ref.get(798, 0);
 | 
					        const annotationRef = Ref.get(798, 0);
 | 
				
			||||||
        let xref = new XRefMock([{ ref: annotationRef, data: annotationDict }]);
 | 
					        const xref = new XRefMock([
 | 
				
			||||||
 | 
					          { ref: annotationRef, data: annotationDict },
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        AnnotationFactory.create(
 | 
					        AnnotationFactory.create(
 | 
				
			||||||
          xref,
 | 
					          xref,
 | 
				
			||||||
@ -1479,7 +1481,7 @@ describe("annotation", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should only accept comb fields when the flags are valid", function(done) {
 | 
					    it("should only accept comb fields when the flags are valid", function(done) {
 | 
				
			||||||
      let invalidFieldFlags = [
 | 
					      const invalidFieldFlags = [
 | 
				
			||||||
        AnnotationFieldFlag.MULTILINE,
 | 
					        AnnotationFieldFlag.MULTILINE,
 | 
				
			||||||
        AnnotationFieldFlag.PASSWORD,
 | 
					        AnnotationFieldFlag.PASSWORD,
 | 
				
			||||||
        AnnotationFieldFlag.FILESELECT,
 | 
					        AnnotationFieldFlag.FILESELECT,
 | 
				
			||||||
 | 
				
			|||||||
@ -50,9 +50,9 @@ import { isNodeJS } from "../../src/shared/is_node.js";
 | 
				
			|||||||
import { Metadata } from "../../src/display/metadata.js";
 | 
					import { Metadata } from "../../src/display/metadata.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe("api", function() {
 | 
					describe("api", function() {
 | 
				
			||||||
  let basicApiFileName = "basicapi.pdf";
 | 
					  const basicApiFileName = "basicapi.pdf";
 | 
				
			||||||
  let basicApiFileLength = 105779; // bytes
 | 
					  const basicApiFileLength = 105779; // bytes
 | 
				
			||||||
  let basicApiGetDocumentParams = buildGetDocumentParams(basicApiFileName);
 | 
					  const basicApiGetDocumentParams = buildGetDocumentParams(basicApiFileName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let CanvasFactory;
 | 
					  let CanvasFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -102,7 +102,7 @@ describe("api", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
    it("creates pdf doc from URL and aborts before worker initialized", function(done) {
 | 
					    it("creates pdf doc from URL and aborts before worker initialized", function(done) {
 | 
				
			||||||
      var loadingTask = getDocument(basicApiGetDocumentParams);
 | 
					      var loadingTask = getDocument(basicApiGetDocumentParams);
 | 
				
			||||||
      let destroyed = loadingTask.destroy();
 | 
					      const destroyed = loadingTask.destroy();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      loadingTask.promise
 | 
					      loadingTask.promise
 | 
				
			||||||
        .then(function(reason) {
 | 
					        .then(function(reason) {
 | 
				
			||||||
@ -473,7 +473,7 @@ describe("api", function() {
 | 
				
			|||||||
        pending("Worker is not supported in Node.js.");
 | 
					        pending("Worker is not supported in Node.js.");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let workerSrc = PDFWorker.getWorkerSrc();
 | 
					      const workerSrc = PDFWorker.getWorkerSrc();
 | 
				
			||||||
      expect(typeof workerSrc).toEqual("string");
 | 
					      expect(typeof workerSrc).toEqual("string");
 | 
				
			||||||
      expect(workerSrc).toEqual(GlobalWorkerOptions.workerSrc);
 | 
					      expect(workerSrc).toEqual(GlobalWorkerOptions.workerSrc);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -1339,8 +1339,8 @@ describe("api", function() {
 | 
				
			|||||||
    it('gets viewport respecting "dontFlip" argument', function() {
 | 
					    it('gets viewport respecting "dontFlip" argument', function() {
 | 
				
			||||||
      const scale = 1,
 | 
					      const scale = 1,
 | 
				
			||||||
        rotation = 0;
 | 
					        rotation = 0;
 | 
				
			||||||
      let viewport = page.getViewport({ scale, rotation });
 | 
					      const viewport = page.getViewport({ scale, rotation });
 | 
				
			||||||
      let dontFlipViewport = page.getViewport({
 | 
					      const dontFlipViewport = page.getViewport({
 | 
				
			||||||
        scale,
 | 
					        scale,
 | 
				
			||||||
        rotation,
 | 
					        rotation,
 | 
				
			||||||
        dontFlip: true,
 | 
					        dontFlip: true,
 | 
				
			||||||
@ -1511,15 +1511,15 @@ describe("api", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("gets operatorList with JPEG image (issue 4888)", function(done) {
 | 
					    it("gets operatorList with JPEG image (issue 4888)", function(done) {
 | 
				
			||||||
      let loadingTask = getDocument(buildGetDocumentParams("cmykjpeg.pdf"));
 | 
					      const loadingTask = getDocument(buildGetDocumentParams("cmykjpeg.pdf"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      loadingTask.promise
 | 
					      loadingTask.promise
 | 
				
			||||||
        .then(pdfDoc => {
 | 
					        .then(pdfDoc => {
 | 
				
			||||||
          pdfDoc.getPage(1).then(pdfPage => {
 | 
					          pdfDoc.getPage(1).then(pdfPage => {
 | 
				
			||||||
            pdfPage.getOperatorList().then(opList => {
 | 
					            pdfPage.getOperatorList().then(opList => {
 | 
				
			||||||
              let imgIndex = opList.fnArray.indexOf(OPS.paintImageXObject);
 | 
					              const imgIndex = opList.fnArray.indexOf(OPS.paintImageXObject);
 | 
				
			||||||
              let imgArgs = opList.argsArray[imgIndex];
 | 
					              const imgArgs = opList.argsArray[imgIndex];
 | 
				
			||||||
              let { data } = pdfPage.objs.get(imgArgs[0]);
 | 
					              const { data } = pdfPage.objs.get(imgArgs[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              expect(data instanceof Uint8ClampedArray).toEqual(true);
 | 
					              expect(data instanceof Uint8ClampedArray).toEqual(true);
 | 
				
			||||||
              expect(data.length).toEqual(90000);
 | 
					              expect(data.length).toEqual(90000);
 | 
				
			||||||
@ -1607,7 +1607,7 @@ describe("api", function() {
 | 
				
			|||||||
        }, done.fail);
 | 
					        }, done.fail);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    it("gets page stats after parsing page, with `pdfBug` set", function(done) {
 | 
					    it("gets page stats after parsing page, with `pdfBug` set", function(done) {
 | 
				
			||||||
      let loadingTask = getDocument(
 | 
					      const loadingTask = getDocument(
 | 
				
			||||||
        buildGetDocumentParams(basicApiFileName, { pdfBug: true })
 | 
					        buildGetDocumentParams(basicApiFileName, { pdfBug: true })
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1623,7 +1623,7 @@ describe("api", function() {
 | 
				
			|||||||
          expect(stats instanceof StatTimer).toEqual(true);
 | 
					          expect(stats instanceof StatTimer).toEqual(true);
 | 
				
			||||||
          expect(stats.times.length).toEqual(1);
 | 
					          expect(stats.times.length).toEqual(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          let [statEntry] = stats.times;
 | 
					          const [statEntry] = stats.times;
 | 
				
			||||||
          expect(statEntry.name).toEqual("Page Request");
 | 
					          expect(statEntry.name).toEqual("Page Request");
 | 
				
			||||||
          expect(statEntry.end - statEntry.start).toBeGreaterThanOrEqual(0);
 | 
					          expect(statEntry.end - statEntry.start).toBeGreaterThanOrEqual(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1631,7 +1631,7 @@ describe("api", function() {
 | 
				
			|||||||
        }, done.fail);
 | 
					        }, done.fail);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    it("gets page stats after rendering page, with `pdfBug` set", function(done) {
 | 
					    it("gets page stats after rendering page, with `pdfBug` set", function(done) {
 | 
				
			||||||
      let loadingTask = getDocument(
 | 
					      const loadingTask = getDocument(
 | 
				
			||||||
        buildGetDocumentParams(basicApiFileName, { pdfBug: true })
 | 
					        buildGetDocumentParams(basicApiFileName, { pdfBug: true })
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      let canvasAndCtx;
 | 
					      let canvasAndCtx;
 | 
				
			||||||
@ -1639,13 +1639,13 @@ describe("api", function() {
 | 
				
			|||||||
      loadingTask.promise
 | 
					      loadingTask.promise
 | 
				
			||||||
        .then(pdfDoc => {
 | 
					        .then(pdfDoc => {
 | 
				
			||||||
          return pdfDoc.getPage(1).then(pdfPage => {
 | 
					          return pdfDoc.getPage(1).then(pdfPage => {
 | 
				
			||||||
            let viewport = pdfPage.getViewport({ scale: 1 });
 | 
					            const viewport = pdfPage.getViewport({ scale: 1 });
 | 
				
			||||||
            canvasAndCtx = CanvasFactory.create(
 | 
					            canvasAndCtx = CanvasFactory.create(
 | 
				
			||||||
              viewport.width,
 | 
					              viewport.width,
 | 
				
			||||||
              viewport.height
 | 
					              viewport.height
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let renderTask = pdfPage.render({
 | 
					            const renderTask = pdfPage.render({
 | 
				
			||||||
              canvasContext: canvasAndCtx.context,
 | 
					              canvasContext: canvasAndCtx.context,
 | 
				
			||||||
              canvasFactory: CanvasFactory,
 | 
					              canvasFactory: CanvasFactory,
 | 
				
			||||||
              viewport,
 | 
					              viewport,
 | 
				
			||||||
@ -1659,7 +1659,7 @@ describe("api", function() {
 | 
				
			|||||||
          expect(stats instanceof StatTimer).toEqual(true);
 | 
					          expect(stats instanceof StatTimer).toEqual(true);
 | 
				
			||||||
          expect(stats.times.length).toEqual(3);
 | 
					          expect(stats.times.length).toEqual(3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          let [statEntryOne, statEntryTwo, statEntryThree] = stats.times;
 | 
					          const [statEntryOne, statEntryTwo, statEntryThree] = stats.times;
 | 
				
			||||||
          expect(statEntryOne.name).toEqual("Page Request");
 | 
					          expect(statEntryOne.name).toEqual("Page Request");
 | 
				
			||||||
          expect(statEntryOne.end - statEntryOne.start).toBeGreaterThanOrEqual(
 | 
					          expect(statEntryOne.end - statEntryOne.start).toBeGreaterThanOrEqual(
 | 
				
			||||||
            0
 | 
					            0
 | 
				
			||||||
@ -1700,10 +1700,13 @@ describe("api", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("re-render page, using the same canvas, after cancelling rendering", function(done) {
 | 
					    it("re-render page, using the same canvas, after cancelling rendering", function(done) {
 | 
				
			||||||
      let viewport = page.getViewport({ scale: 1 });
 | 
					      const viewport = page.getViewport({ scale: 1 });
 | 
				
			||||||
      let canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
 | 
					      const canvasAndCtx = CanvasFactory.create(
 | 
				
			||||||
 | 
					        viewport.width,
 | 
				
			||||||
 | 
					        viewport.height
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let renderTask = page.render({
 | 
					      const renderTask = page.render({
 | 
				
			||||||
        canvasContext: canvasAndCtx.context,
 | 
					        canvasContext: canvasAndCtx.context,
 | 
				
			||||||
        canvasFactory: CanvasFactory,
 | 
					        canvasFactory: CanvasFactory,
 | 
				
			||||||
        viewport,
 | 
					        viewport,
 | 
				
			||||||
@ -1720,7 +1723,7 @@ describe("api", function() {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        .then(() => {
 | 
					        .then(() => {
 | 
				
			||||||
          let reRenderTask = page.render({
 | 
					          const reRenderTask = page.render({
 | 
				
			||||||
            canvasContext: canvasAndCtx.context,
 | 
					            canvasContext: canvasAndCtx.context,
 | 
				
			||||||
            canvasFactory: CanvasFactory,
 | 
					            canvasFactory: CanvasFactory,
 | 
				
			||||||
            viewport,
 | 
					            viewport,
 | 
				
			||||||
 | 
				
			|||||||
@ -345,7 +345,7 @@ describe("cmap", function() {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let cmapPromise = CMapFactory.create({
 | 
					    const cmapPromise = CMapFactory.create({
 | 
				
			||||||
      encoding: Name.get("Adobe-Japan1-1"),
 | 
					      encoding: Name.get("Adobe-Japan1-1"),
 | 
				
			||||||
      fetchBuiltInCMap: tmpFetchBuiltInCMap,
 | 
					      fetchBuiltInCMap: tmpFetchBuiltInCMap,
 | 
				
			||||||
      useCMap: null,
 | 
					      useCMap: null,
 | 
				
			||||||
@ -356,7 +356,7 @@ describe("cmap", function() {
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
      function(reason) {
 | 
					      function(reason) {
 | 
				
			||||||
        expect(reason instanceof Error).toEqual(true);
 | 
					        expect(reason instanceof Error).toEqual(true);
 | 
				
			||||||
        let message = reason.message;
 | 
					        const message = reason.message;
 | 
				
			||||||
        expect(message.startsWith("Unable to load CMap at: ")).toEqual(true);
 | 
					        expect(message.startsWith("Unable to load CMap at: ")).toEqual(true);
 | 
				
			||||||
        expect(message.endsWith("/external/bcmaps/Adobe-Japan1-1")).toEqual(
 | 
					        expect(message.endsWith("/external/bcmaps/Adobe-Japan1-1")).toEqual(
 | 
				
			||||||
          true
 | 
					          true
 | 
				
			||||||
 | 
				
			|||||||
@ -48,24 +48,24 @@ describe("colorspace", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("DeviceGrayCS", function() {
 | 
					  describe("DeviceGrayCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is a Name object", function() {
 | 
					    it("should handle the case when cs is a Name object", function() {
 | 
				
			||||||
      let cs = Name.get("DeviceGray");
 | 
					      const cs = Name.get("DeviceGray");
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: Ref.get(10, 0),
 | 
					          ref: Ref.get(10, 0),
 | 
				
			||||||
          data: new Dict(),
 | 
					          data: new Dict(),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let testSrc = new Uint8Array([27, 125, 250, 131]);
 | 
					      const testSrc = new Uint8Array([27, 125, 250, 131]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
					      const testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        27, 27, 27,
 | 
					        27, 27, 27,
 | 
				
			||||||
        27, 27, 27,
 | 
					        27, 27, 27,
 | 
				
			||||||
        125, 125, 125,
 | 
					        125, 125, 125,
 | 
				
			||||||
@ -93,24 +93,24 @@ describe("colorspace", function() {
 | 
				
			|||||||
      expect(testDest).toEqual(expectedDest);
 | 
					      expect(testDest).toEqual(expectedDest);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    it("should handle the case when cs is an indirect object", function() {
 | 
					    it("should handle the case when cs is an indirect object", function() {
 | 
				
			||||||
      let cs = Ref.get(10, 0);
 | 
					      const cs = Ref.get(10, 0);
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: cs,
 | 
					          ref: cs,
 | 
				
			||||||
          data: Name.get("DeviceGray"),
 | 
					          data: Name.get("DeviceGray"),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let testSrc = new Uint8Array([27, 125, 250, 131]);
 | 
					      const testSrc = new Uint8Array([27, 125, 250, 131]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
					      const testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        27, 27, 27,
 | 
					        27, 27, 27,
 | 
				
			||||||
        27, 27, 27,
 | 
					        27, 27, 27,
 | 
				
			||||||
        125, 125, 125,
 | 
					        125, 125, 125,
 | 
				
			||||||
@ -134,30 +134,30 @@ describe("colorspace", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("DeviceRgbCS", function() {
 | 
					  describe("DeviceRgbCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is a Name object", function() {
 | 
					    it("should handle the case when cs is a Name object", function() {
 | 
				
			||||||
      let cs = Name.get("DeviceRGB");
 | 
					      const cs = Name.get("DeviceRGB");
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: Ref.get(10, 0),
 | 
					          ref: Ref.get(10, 0),
 | 
				
			||||||
          data: new Dict(),
 | 
					          data: new Dict(),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let testSrc = new Uint8Array([
 | 
					      const testSrc = new Uint8Array([
 | 
				
			||||||
        27, 125, 250,
 | 
					        27, 125, 250,
 | 
				
			||||||
        131, 139, 140,
 | 
					        131, 139, 140,
 | 
				
			||||||
        111, 25, 198,
 | 
					        111, 25, 198,
 | 
				
			||||||
        21, 147, 255
 | 
					        21, 147, 255
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
					      const testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        27, 125, 250,
 | 
					        27, 125, 250,
 | 
				
			||||||
        27, 125, 250,
 | 
					        27, 125, 250,
 | 
				
			||||||
        131, 139, 140,
 | 
					        131, 139, 140,
 | 
				
			||||||
@ -185,30 +185,30 @@ describe("colorspace", function() {
 | 
				
			|||||||
      expect(testDest).toEqual(expectedDest);
 | 
					      expect(testDest).toEqual(expectedDest);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    it("should handle the case when cs is an indirect object", function() {
 | 
					    it("should handle the case when cs is an indirect object", function() {
 | 
				
			||||||
      let cs = Ref.get(10, 0);
 | 
					      const cs = Ref.get(10, 0);
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: cs,
 | 
					          ref: cs,
 | 
				
			||||||
          data: Name.get("DeviceRGB"),
 | 
					          data: Name.get("DeviceRGB"),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let testSrc = new Uint8Array([
 | 
					      const testSrc = new Uint8Array([
 | 
				
			||||||
        27, 125, 250,
 | 
					        27, 125, 250,
 | 
				
			||||||
        131, 139, 140,
 | 
					        131, 139, 140,
 | 
				
			||||||
        111, 25, 198,
 | 
					        111, 25, 198,
 | 
				
			||||||
        21, 147, 255
 | 
					        21, 147, 255
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
					      const testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        27, 125, 250,
 | 
					        27, 125, 250,
 | 
				
			||||||
        27, 125, 250,
 | 
					        27, 125, 250,
 | 
				
			||||||
        131, 139, 140,
 | 
					        131, 139, 140,
 | 
				
			||||||
@ -232,30 +232,30 @@ describe("colorspace", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("DeviceCmykCS", function() {
 | 
					  describe("DeviceCmykCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is a Name object", function() {
 | 
					    it("should handle the case when cs is a Name object", function() {
 | 
				
			||||||
      let cs = Name.get("DeviceCMYK");
 | 
					      const cs = Name.get("DeviceCMYK");
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: Ref.get(10, 0),
 | 
					          ref: Ref.get(10, 0),
 | 
				
			||||||
          data: new Dict(),
 | 
					          data: new Dict(),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let testSrc = new Uint8Array([
 | 
					      const testSrc = new Uint8Array([
 | 
				
			||||||
        27, 125, 250, 128,
 | 
					        27, 125, 250, 128,
 | 
				
			||||||
        131, 139, 140, 45,
 | 
					        131, 139, 140, 45,
 | 
				
			||||||
        111, 25, 198, 78,
 | 
					        111, 25, 198, 78,
 | 
				
			||||||
        21, 147, 255, 69
 | 
					        21, 147, 255, 69
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
					      const testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        135, 81, 18,
 | 
					        135, 81, 18,
 | 
				
			||||||
        135, 81, 18,
 | 
					        135, 81, 18,
 | 
				
			||||||
        114, 102, 97,
 | 
					        114, 102, 97,
 | 
				
			||||||
@ -283,30 +283,30 @@ describe("colorspace", function() {
 | 
				
			|||||||
      expect(testDest).toEqual(expectedDest);
 | 
					      expect(testDest).toEqual(expectedDest);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    it("should handle the case when cs is an indirect object", function() {
 | 
					    it("should handle the case when cs is an indirect object", function() {
 | 
				
			||||||
      let cs = Ref.get(10, 0);
 | 
					      const cs = Ref.get(10, 0);
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: cs,
 | 
					          ref: cs,
 | 
				
			||||||
          data: Name.get("DeviceCMYK"),
 | 
					          data: Name.get("DeviceCMYK"),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let testSrc = new Uint8Array([
 | 
					      const testSrc = new Uint8Array([
 | 
				
			||||||
        27, 125, 250, 128,
 | 
					        27, 125, 250, 128,
 | 
				
			||||||
        131, 139, 140, 45,
 | 
					        131, 139, 140, 45,
 | 
				
			||||||
        111, 25, 198, 78,
 | 
					        111, 25, 198, 78,
 | 
				
			||||||
        21, 147, 255, 69
 | 
					        21, 147, 255, 69
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
					      const testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        135, 81, 18,
 | 
					        135, 81, 18,
 | 
				
			||||||
        135, 81, 18,
 | 
					        135, 81, 18,
 | 
				
			||||||
        114, 102, 97,
 | 
					        114, 102, 97,
 | 
				
			||||||
@ -330,29 +330,29 @@ describe("colorspace", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("CalGrayCS", function() {
 | 
					  describe("CalGrayCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is an array", function() {
 | 
					    it("should handle the case when cs is an array", function() {
 | 
				
			||||||
      let params = new Dict();
 | 
					      const params = new Dict();
 | 
				
			||||||
      params.set("WhitePoint", [1, 1, 1]);
 | 
					      params.set("WhitePoint", [1, 1, 1]);
 | 
				
			||||||
      params.set("BlackPoint", [0, 0, 0]);
 | 
					      params.set("BlackPoint", [0, 0, 0]);
 | 
				
			||||||
      params.set("Gamma", 2.0);
 | 
					      params.set("Gamma", 2.0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let cs = [Name.get("CalGray"), params];
 | 
					      const cs = [Name.get("CalGray"), params];
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: Ref.get(10, 0),
 | 
					          ref: Ref.get(10, 0),
 | 
				
			||||||
          data: new Dict(),
 | 
					          data: new Dict(),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let testSrc = new Uint8Array([27, 125, 250, 131]);
 | 
					      const testSrc = new Uint8Array([27, 125, 250, 131]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
					      const testDest = new Uint8ClampedArray(4 * 4 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        25, 25, 25,
 | 
					        25, 25, 25,
 | 
				
			||||||
        25, 25, 25,
 | 
					        25, 25, 25,
 | 
				
			||||||
        143, 143, 143,
 | 
					        143, 143, 143,
 | 
				
			||||||
@ -383,36 +383,36 @@ describe("colorspace", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("CalRGBCS", function() {
 | 
					  describe("CalRGBCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is an array", function() {
 | 
					    it("should handle the case when cs is an array", function() {
 | 
				
			||||||
      let params = new Dict();
 | 
					      const params = new Dict();
 | 
				
			||||||
      params.set("WhitePoint", [1, 1, 1]);
 | 
					      params.set("WhitePoint", [1, 1, 1]);
 | 
				
			||||||
      params.set("BlackPoint", [0, 0, 0]);
 | 
					      params.set("BlackPoint", [0, 0, 0]);
 | 
				
			||||||
      params.set("Gamma", [1, 1, 1]);
 | 
					      params.set("Gamma", [1, 1, 1]);
 | 
				
			||||||
      params.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
 | 
					      params.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let cs = [Name.get("CalRGB"), params];
 | 
					      const cs = [Name.get("CalRGB"), params];
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: Ref.get(10, 0),
 | 
					          ref: Ref.get(10, 0),
 | 
				
			||||||
          data: new Dict(),
 | 
					          data: new Dict(),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let testSrc = new Uint8Array([
 | 
					      const testSrc = new Uint8Array([
 | 
				
			||||||
        27, 125, 250,
 | 
					        27, 125, 250,
 | 
				
			||||||
        131, 139, 140,
 | 
					        131, 139, 140,
 | 
				
			||||||
        111, 25, 198,
 | 
					        111, 25, 198,
 | 
				
			||||||
        21, 147, 255
 | 
					        21, 147, 255
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
					      const testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        0, 238, 255,
 | 
					        0, 238, 255,
 | 
				
			||||||
        0, 238, 255,
 | 
					        0, 238, 255,
 | 
				
			||||||
        185, 196, 195,
 | 
					        185, 196, 195,
 | 
				
			||||||
@ -436,35 +436,35 @@ describe("colorspace", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("LabCS", function() {
 | 
					  describe("LabCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is an array", function() {
 | 
					    it("should handle the case when cs is an array", function() {
 | 
				
			||||||
      let params = new Dict();
 | 
					      const params = new Dict();
 | 
				
			||||||
      params.set("WhitePoint", [1, 1, 1]);
 | 
					      params.set("WhitePoint", [1, 1, 1]);
 | 
				
			||||||
      params.set("BlackPoint", [0, 0, 0]);
 | 
					      params.set("BlackPoint", [0, 0, 0]);
 | 
				
			||||||
      params.set("Range", [-100, 100, -100, 100]);
 | 
					      params.set("Range", [-100, 100, -100, 100]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let cs = [Name.get("Lab"), params];
 | 
					      const cs = [Name.get("Lab"), params];
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: Ref.get(10, 0),
 | 
					          ref: Ref.get(10, 0),
 | 
				
			||||||
          data: new Dict(),
 | 
					          data: new Dict(),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let testSrc = new Uint8Array([
 | 
					      const testSrc = new Uint8Array([
 | 
				
			||||||
        27, 25, 50,
 | 
					        27, 25, 50,
 | 
				
			||||||
        31, 19, 40,
 | 
					        31, 19, 40,
 | 
				
			||||||
        11, 25, 98,
 | 
					        11, 25, 98,
 | 
				
			||||||
        21, 47, 55
 | 
					        21, 47, 55
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
					      const testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        0, 49, 101,
 | 
					        0, 49, 101,
 | 
				
			||||||
        0, 49, 101,
 | 
					        0, 49, 101,
 | 
				
			||||||
        0, 53, 117,
 | 
					        0, 53, 117,
 | 
				
			||||||
@ -490,29 +490,29 @@ describe("colorspace", function() {
 | 
				
			|||||||
  describe("IndexedCS", function() {
 | 
					  describe("IndexedCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is an array", function() {
 | 
					    it("should handle the case when cs is an array", function() {
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let lookup = new Uint8Array([
 | 
					      const lookup = new Uint8Array([
 | 
				
			||||||
        23, 155, 35,
 | 
					        23, 155, 35,
 | 
				
			||||||
        147, 69, 93,
 | 
					        147, 69, 93,
 | 
				
			||||||
        255, 109, 70
 | 
					        255, 109, 70
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let cs = [Name.get("Indexed"), Name.get("DeviceRGB"), 2, lookup];
 | 
					      const cs = [Name.get("Indexed"), Name.get("DeviceRGB"), 2, lookup];
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: Ref.get(10, 0),
 | 
					          ref: Ref.get(10, 0),
 | 
				
			||||||
          data: new Dict(),
 | 
					          data: new Dict(),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let testSrc = new Uint8Array([2, 2, 0, 1]);
 | 
					      const testSrc = new Uint8Array([2, 2, 0, 1]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
					      const testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        255, 109, 70,
 | 
					        255, 109, 70,
 | 
				
			||||||
        255, 109, 70,
 | 
					        255, 109, 70,
 | 
				
			||||||
        255, 109, 70,
 | 
					        255, 109, 70,
 | 
				
			||||||
@ -536,7 +536,7 @@ describe("colorspace", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("AlternateCS", function() {
 | 
					  describe("AlternateCS", function() {
 | 
				
			||||||
    it("should handle the case when cs is an array", function() {
 | 
					    it("should handle the case when cs is an array", function() {
 | 
				
			||||||
      let fnDict = new Dict();
 | 
					      const fnDict = new Dict();
 | 
				
			||||||
      fnDict.set("FunctionType", 4);
 | 
					      fnDict.set("FunctionType", 4);
 | 
				
			||||||
      fnDict.set("Domain", [0.0, 1.0]);
 | 
					      fnDict.set("Domain", [0.0, 1.0]);
 | 
				
			||||||
      fnDict.set("Range", [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);
 | 
					      fnDict.set("Range", [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);
 | 
				
			||||||
@ -550,31 +550,31 @@ describe("colorspace", function() {
 | 
				
			|||||||
      );
 | 
					      );
 | 
				
			||||||
      fn = new Stream(fn.bytes, 0, 58, fnDict);
 | 
					      fn = new Stream(fn.bytes, 0, 58, fnDict);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let fnRef = Ref.get(10, 0);
 | 
					      const fnRef = Ref.get(10, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let cs = [
 | 
					      const cs = [
 | 
				
			||||||
        Name.get("Separation"),
 | 
					        Name.get("Separation"),
 | 
				
			||||||
        Name.get("LogoGreen"),
 | 
					        Name.get("LogoGreen"),
 | 
				
			||||||
        Name.get("DeviceCMYK"),
 | 
					        Name.get("DeviceCMYK"),
 | 
				
			||||||
        fnRef,
 | 
					        fnRef,
 | 
				
			||||||
      ];
 | 
					      ];
 | 
				
			||||||
      let xref = new XRefMock([
 | 
					      const xref = new XRefMock([
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          ref: fnRef,
 | 
					          ref: fnRef,
 | 
				
			||||||
          data: fn,
 | 
					          data: fn,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ]);
 | 
					      ]);
 | 
				
			||||||
      let res = new Dict();
 | 
					      const res = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let pdfFunctionFactory = new PDFFunctionFactory({
 | 
					      const pdfFunctionFactory = new PDFFunctionFactory({
 | 
				
			||||||
        xref,
 | 
					        xref,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
					      const colorSpace = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let testSrc = new Uint8Array([27, 25, 50, 31]);
 | 
					      const testSrc = new Uint8Array([27, 25, 50, 31]);
 | 
				
			||||||
      let testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
					      const testDest = new Uint8ClampedArray(3 * 3 * 3);
 | 
				
			||||||
      // prettier-ignore
 | 
					      // prettier-ignore
 | 
				
			||||||
      let expectedDest = new Uint8ClampedArray([
 | 
					      const expectedDest = new Uint8ClampedArray([
 | 
				
			||||||
        226, 242, 241,
 | 
					        226, 242, 241,
 | 
				
			||||||
        226, 242, 241,
 | 
					        226, 242, 241,
 | 
				
			||||||
        229, 244, 242,
 | 
					        229, 244, 242,
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,7 @@ import { getDocument } from "../../src/display/api.js";
 | 
				
			|||||||
import { isNodeJS } from "../../src/shared/is_node.js";
 | 
					import { isNodeJS } from "../../src/shared/is_node.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getTopLeftPixel(canvasContext) {
 | 
					function getTopLeftPixel(canvasContext) {
 | 
				
			||||||
  let imgData = canvasContext.getImageData(0, 0, 1, 1);
 | 
					  const imgData = canvasContext.getImageData(0, 0, 1, 1);
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    r: imgData.data[0],
 | 
					    r: imgData.data[0],
 | 
				
			||||||
    g: imgData.data[1],
 | 
					    g: imgData.data[1],
 | 
				
			||||||
@ -29,7 +29,9 @@ function getTopLeftPixel(canvasContext) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe("custom canvas rendering", function() {
 | 
					describe("custom canvas rendering", function() {
 | 
				
			||||||
  let transparentGetDocumentParams = buildGetDocumentParams("transparent.pdf");
 | 
					  const transparentGetDocumentParams = buildGetDocumentParams(
 | 
				
			||||||
 | 
					    "transparent.pdf"
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let CanvasFactory;
 | 
					  let CanvasFactory;
 | 
				
			||||||
  let loadingTask;
 | 
					  let loadingTask;
 | 
				
			||||||
 | 
				
			|||||||
@ -86,7 +86,7 @@ describe("fetch_stream", function() {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
    const rangeReader2 = stream.getRangeReader(pdfLength - tailSize, pdfLength);
 | 
					    const rangeReader2 = stream.getRangeReader(pdfLength - tailSize, pdfLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let result1 = { value: 0 },
 | 
					    const result1 = { value: 0 },
 | 
				
			||||||
      result2 = { value: 0 };
 | 
					      result2 = { value: 0 };
 | 
				
			||||||
    const read = function(reader, lenResult) {
 | 
					    const read = function(reader, lenResult) {
 | 
				
			||||||
      return reader.read().then(function(result) {
 | 
					      return reader.read().then(function(result) {
 | 
				
			||||||
 | 
				
			|||||||
@ -31,9 +31,9 @@ describe("message_handler", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("sendWithStream", function() {
 | 
					  describe("sendWithStream", function() {
 | 
				
			||||||
    it("should return a ReadableStream", function() {
 | 
					    it("should return a ReadableStream", function() {
 | 
				
			||||||
      let port = new LoopbackPort();
 | 
					      const port = new LoopbackPort();
 | 
				
			||||||
      let messageHandler1 = new MessageHandler("main", "worker", port);
 | 
					      const messageHandler1 = new MessageHandler("main", "worker", port);
 | 
				
			||||||
      let readable = messageHandler1.sendWithStream("fakeHandler");
 | 
					      const readable = messageHandler1.sendWithStream("fakeHandler");
 | 
				
			||||||
      // Check if readable is an instance of ReadableStream.
 | 
					      // Check if readable is an instance of ReadableStream.
 | 
				
			||||||
      expect(typeof readable).toEqual("object");
 | 
					      expect(typeof readable).toEqual("object");
 | 
				
			||||||
      expect(typeof readable.getReader).toEqual("function");
 | 
					      expect(typeof readable.getReader).toEqual("function");
 | 
				
			||||||
@ -41,9 +41,9 @@ describe("message_handler", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    it("should read using a reader", function(done) {
 | 
					    it("should read using a reader", function(done) {
 | 
				
			||||||
      let log = "";
 | 
					      let log = "";
 | 
				
			||||||
      let port = new LoopbackPort();
 | 
					      const port = new LoopbackPort();
 | 
				
			||||||
      let messageHandler1 = new MessageHandler("main", "worker", port);
 | 
					      const messageHandler1 = new MessageHandler("main", "worker", port);
 | 
				
			||||||
      let messageHandler2 = new MessageHandler("worker", "main", port);
 | 
					      const messageHandler2 = new MessageHandler("worker", "main", port);
 | 
				
			||||||
      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
					      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
				
			||||||
        sink.onPull = function() {
 | 
					        sink.onPull = function() {
 | 
				
			||||||
          log += "p";
 | 
					          log += "p";
 | 
				
			||||||
@ -61,7 +61,7 @@ describe("message_handler", function() {
 | 
				
			|||||||
          });
 | 
					          });
 | 
				
			||||||
        return sleep(5);
 | 
					        return sleep(5);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let readable = messageHandler1.sendWithStream(
 | 
					      const readable = messageHandler1.sendWithStream(
 | 
				
			||||||
        "fakeHandler",
 | 
					        "fakeHandler",
 | 
				
			||||||
        {},
 | 
					        {},
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -71,7 +71,7 @@ describe("message_handler", function() {
 | 
				
			|||||||
          },
 | 
					          },
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      let reader = readable.getReader();
 | 
					      const reader = readable.getReader();
 | 
				
			||||||
      sleep(10)
 | 
					      sleep(10)
 | 
				
			||||||
        .then(() => {
 | 
					        .then(() => {
 | 
				
			||||||
          expect(log).toEqual("");
 | 
					          expect(log).toEqual("");
 | 
				
			||||||
@ -95,8 +95,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    it("should not read any data when cancelled", function(done) {
 | 
					    it("should not read any data when cancelled", function(done) {
 | 
				
			||||||
      let log = "";
 | 
					      let log = "";
 | 
				
			||||||
      let port = new LoopbackPort();
 | 
					      const port = new LoopbackPort();
 | 
				
			||||||
      let messageHandler2 = new MessageHandler("worker", "main", port);
 | 
					      const messageHandler2 = new MessageHandler("worker", "main", port);
 | 
				
			||||||
      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
					      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
				
			||||||
        sink.onPull = function() {
 | 
					        sink.onPull = function() {
 | 
				
			||||||
          log += "p";
 | 
					          log += "p";
 | 
				
			||||||
@ -126,8 +126,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let messageHandler1 = new MessageHandler("main", "worker", port);
 | 
					      const messageHandler1 = new MessageHandler("main", "worker", port);
 | 
				
			||||||
      let readable = messageHandler1.sendWithStream(
 | 
					      const readable = messageHandler1.sendWithStream(
 | 
				
			||||||
        "fakeHandler",
 | 
					        "fakeHandler",
 | 
				
			||||||
        {},
 | 
					        {},
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -138,7 +138,7 @@ describe("message_handler", function() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let reader = readable.getReader();
 | 
					      const reader = readable.getReader();
 | 
				
			||||||
      sleep(10)
 | 
					      sleep(10)
 | 
				
			||||||
        .then(() => {
 | 
					        .then(() => {
 | 
				
			||||||
          expect(log).toEqual("01");
 | 
					          expect(log).toEqual("01");
 | 
				
			||||||
@ -161,8 +161,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    it("should not read when errored", function(done) {
 | 
					    it("should not read when errored", function(done) {
 | 
				
			||||||
      let log = "";
 | 
					      let log = "";
 | 
				
			||||||
      let port = new LoopbackPort();
 | 
					      const port = new LoopbackPort();
 | 
				
			||||||
      let messageHandler2 = new MessageHandler("worker", "main", port);
 | 
					      const messageHandler2 = new MessageHandler("worker", "main", port);
 | 
				
			||||||
      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
					      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
				
			||||||
        sink.onPull = function() {
 | 
					        sink.onPull = function() {
 | 
				
			||||||
          log += "p";
 | 
					          log += "p";
 | 
				
			||||||
@ -182,8 +182,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
            sink.error(new Error("should not read when errored"));
 | 
					            sink.error(new Error("should not read when errored"));
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      let messageHandler1 = new MessageHandler("main", "worker", port);
 | 
					      const messageHandler1 = new MessageHandler("main", "worker", port);
 | 
				
			||||||
      let readable = messageHandler1.sendWithStream(
 | 
					      const readable = messageHandler1.sendWithStream(
 | 
				
			||||||
        "fakeHandler",
 | 
					        "fakeHandler",
 | 
				
			||||||
        {},
 | 
					        {},
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -194,7 +194,7 @@ describe("message_handler", function() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let reader = readable.getReader();
 | 
					      const reader = readable.getReader();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      sleep(10)
 | 
					      sleep(10)
 | 
				
			||||||
        .then(() => {
 | 
					        .then(() => {
 | 
				
			||||||
@ -216,8 +216,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    it("should read data with blocking promise", function(done) {
 | 
					    it("should read data with blocking promise", function(done) {
 | 
				
			||||||
      let log = "";
 | 
					      let log = "";
 | 
				
			||||||
      let port = new LoopbackPort();
 | 
					      const port = new LoopbackPort();
 | 
				
			||||||
      let messageHandler2 = new MessageHandler("worker", "main", port);
 | 
					      const messageHandler2 = new MessageHandler("worker", "main", port);
 | 
				
			||||||
      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
					      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
				
			||||||
        sink.onPull = function() {
 | 
					        sink.onPull = function() {
 | 
				
			||||||
          log += "p";
 | 
					          log += "p";
 | 
				
			||||||
@ -242,8 +242,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
          });
 | 
					          });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let messageHandler1 = new MessageHandler("main", "worker", port);
 | 
					      const messageHandler1 = new MessageHandler("main", "worker", port);
 | 
				
			||||||
      let readable = messageHandler1.sendWithStream(
 | 
					      const readable = messageHandler1.sendWithStream(
 | 
				
			||||||
        "fakeHandler",
 | 
					        "fakeHandler",
 | 
				
			||||||
        {},
 | 
					        {},
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -254,7 +254,7 @@ describe("message_handler", function() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let reader = readable.getReader();
 | 
					      const reader = readable.getReader();
 | 
				
			||||||
      // Sleep for 10ms, so that read() is not unblocking the ready promise.
 | 
					      // Sleep for 10ms, so that read() is not unblocking the ready promise.
 | 
				
			||||||
      // Chain all read() to stream in sequence.
 | 
					      // Chain all read() to stream in sequence.
 | 
				
			||||||
      sleep(10)
 | 
					      sleep(10)
 | 
				
			||||||
@ -292,8 +292,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
        " into stream",
 | 
					        " into stream",
 | 
				
			||||||
      function(done) {
 | 
					      function(done) {
 | 
				
			||||||
        let log = "";
 | 
					        let log = "";
 | 
				
			||||||
        let port = new LoopbackPort();
 | 
					        const port = new LoopbackPort();
 | 
				
			||||||
        let messageHandler2 = new MessageHandler("worker", "main", port);
 | 
					        const messageHandler2 = new MessageHandler("worker", "main", port);
 | 
				
			||||||
        messageHandler2.on("fakeHandler", (data, sink) => {
 | 
					        messageHandler2.on("fakeHandler", (data, sink) => {
 | 
				
			||||||
          sink.onPull = function() {
 | 
					          sink.onPull = function() {
 | 
				
			||||||
            log += "p";
 | 
					            log += "p";
 | 
				
			||||||
@ -319,8 +319,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
          return sleep(10);
 | 
					          return sleep(10);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let messageHandler1 = new MessageHandler("main", "worker", port);
 | 
					        const messageHandler1 = new MessageHandler("main", "worker", port);
 | 
				
			||||||
        let readable = messageHandler1.sendWithStream(
 | 
					        const readable = messageHandler1.sendWithStream(
 | 
				
			||||||
          "fakeHandler",
 | 
					          "fakeHandler",
 | 
				
			||||||
          {},
 | 
					          {},
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
@ -331,7 +331,7 @@ describe("message_handler", function() {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let reader = readable.getReader();
 | 
					        const reader = readable.getReader();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        sleep(10)
 | 
					        sleep(10)
 | 
				
			||||||
          .then(() => {
 | 
					          .then(() => {
 | 
				
			||||||
@ -366,9 +366,9 @@ describe("message_handler", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    it("should ignore any pull after close is called", function(done) {
 | 
					    it("should ignore any pull after close is called", function(done) {
 | 
				
			||||||
      let log = "";
 | 
					      let log = "";
 | 
				
			||||||
      let port = new LoopbackPort();
 | 
					      const port = new LoopbackPort();
 | 
				
			||||||
      let capability = createPromiseCapability();
 | 
					      const capability = createPromiseCapability();
 | 
				
			||||||
      let messageHandler2 = new MessageHandler("worker", "main", port);
 | 
					      const messageHandler2 = new MessageHandler("worker", "main", port);
 | 
				
			||||||
      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
					      messageHandler2.on("fakeHandler", (data, sink) => {
 | 
				
			||||||
        sink.onPull = function() {
 | 
					        sink.onPull = function() {
 | 
				
			||||||
          log += "p";
 | 
					          log += "p";
 | 
				
			||||||
@ -386,8 +386,8 @@ describe("message_handler", function() {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let messageHandler1 = new MessageHandler("main", "worker", port);
 | 
					      const messageHandler1 = new MessageHandler("main", "worker", port);
 | 
				
			||||||
      let readable = messageHandler1.sendWithStream(
 | 
					      const readable = messageHandler1.sendWithStream(
 | 
				
			||||||
        "fakeHandler",
 | 
					        "fakeHandler",
 | 
				
			||||||
        {},
 | 
					        {},
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -398,7 +398,7 @@ describe("message_handler", function() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let reader = readable.getReader();
 | 
					      const reader = readable.getReader();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      sleep(10)
 | 
					      sleep(10)
 | 
				
			||||||
        .then(() => {
 | 
					        .then(() => {
 | 
				
			||||||
 | 
				
			|||||||
@ -21,26 +21,26 @@ import { PDFNodeStream } from "../../src/display/node_stream.js";
 | 
				
			|||||||
// Make sure that we only running this script is Node.js environments.
 | 
					// Make sure that we only running this script is Node.js environments.
 | 
				
			||||||
assert(isNodeJS);
 | 
					assert(isNodeJS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let path = __non_webpack_require__("path");
 | 
					const path = __non_webpack_require__("path");
 | 
				
			||||||
let url = __non_webpack_require__("url");
 | 
					const url = __non_webpack_require__("url");
 | 
				
			||||||
let http = __non_webpack_require__("http");
 | 
					const http = __non_webpack_require__("http");
 | 
				
			||||||
let fs = __non_webpack_require__("fs");
 | 
					const fs = __non_webpack_require__("fs");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe("node_stream", function() {
 | 
					describe("node_stream", function() {
 | 
				
			||||||
  let server = null;
 | 
					  let server = null;
 | 
				
			||||||
  let port = null;
 | 
					  let port = null;
 | 
				
			||||||
  let pdf = url.parse(
 | 
					  const pdf = url.parse(
 | 
				
			||||||
    encodeURI(
 | 
					    encodeURI(
 | 
				
			||||||
      "file://" + path.join(process.cwd(), "./test/pdfs/tracemonkey.pdf")
 | 
					      "file://" + path.join(process.cwd(), "./test/pdfs/tracemonkey.pdf")
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  ).href;
 | 
					  ).href;
 | 
				
			||||||
  let pdfLength = 1016315;
 | 
					  const pdfLength = 1016315;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  beforeAll(done => {
 | 
					  beforeAll(done => {
 | 
				
			||||||
    // Create http server to serve pdf data for tests.
 | 
					    // Create http server to serve pdf data for tests.
 | 
				
			||||||
    server = http
 | 
					    server = http
 | 
				
			||||||
      .createServer((request, response) => {
 | 
					      .createServer((request, response) => {
 | 
				
			||||||
        let filePath = process.cwd() + "/test/pdfs" + request.url;
 | 
					        const filePath = process.cwd() + "/test/pdfs" + request.url;
 | 
				
			||||||
        fs.lstat(filePath, (error, stat) => {
 | 
					        fs.lstat(filePath, (error, stat) => {
 | 
				
			||||||
          if (error) {
 | 
					          if (error) {
 | 
				
			||||||
            response.writeHead(404);
 | 
					            response.writeHead(404);
 | 
				
			||||||
@ -48,8 +48,8 @@ describe("node_stream", function() {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          if (!request.headers["range"]) {
 | 
					          if (!request.headers["range"]) {
 | 
				
			||||||
            let contentLength = stat.size;
 | 
					            const contentLength = stat.size;
 | 
				
			||||||
            let stream = fs.createReadStream(filePath);
 | 
					            const stream = fs.createReadStream(filePath);
 | 
				
			||||||
            response.writeHead(200, {
 | 
					            response.writeHead(200, {
 | 
				
			||||||
              "Content-Type": "application/pdf",
 | 
					              "Content-Type": "application/pdf",
 | 
				
			||||||
              "Content-Length": contentLength,
 | 
					              "Content-Length": contentLength,
 | 
				
			||||||
@ -57,13 +57,13 @@ describe("node_stream", function() {
 | 
				
			|||||||
            });
 | 
					            });
 | 
				
			||||||
            stream.pipe(response);
 | 
					            stream.pipe(response);
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            let [start, end] = request.headers["range"]
 | 
					            const [start, end] = request.headers["range"]
 | 
				
			||||||
              .split("=")[1]
 | 
					              .split("=")[1]
 | 
				
			||||||
              .split("-")
 | 
					              .split("-")
 | 
				
			||||||
              .map(x => {
 | 
					              .map(x => {
 | 
				
			||||||
                return Number(x);
 | 
					                return Number(x);
 | 
				
			||||||
              });
 | 
					              });
 | 
				
			||||||
            let stream = fs.createReadStream(filePath, { start, end });
 | 
					            const stream = fs.createReadStream(filePath, { start, end });
 | 
				
			||||||
            response.writeHead(206, {
 | 
					            response.writeHead(206, {
 | 
				
			||||||
              "Content-Type": "application/pdf",
 | 
					              "Content-Type": "application/pdf",
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@ -83,38 +83,38 @@ describe("node_stream", function() {
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it("read both http(s) and filesystem pdf files", function(done) {
 | 
					  it("read both http(s) and filesystem pdf files", function(done) {
 | 
				
			||||||
    let stream1 = new PDFNodeStream({
 | 
					    const stream1 = new PDFNodeStream({
 | 
				
			||||||
      url: `http://127.0.0.1:${port}/tracemonkey.pdf`,
 | 
					      url: `http://127.0.0.1:${port}/tracemonkey.pdf`,
 | 
				
			||||||
      rangeChunkSize: 65536,
 | 
					      rangeChunkSize: 65536,
 | 
				
			||||||
      disableStream: true,
 | 
					      disableStream: true,
 | 
				
			||||||
      disableRange: true,
 | 
					      disableRange: true,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let stream2 = new PDFNodeStream({
 | 
					    const stream2 = new PDFNodeStream({
 | 
				
			||||||
      url: pdf,
 | 
					      url: pdf,
 | 
				
			||||||
      rangeChunkSize: 65536,
 | 
					      rangeChunkSize: 65536,
 | 
				
			||||||
      disableStream: true,
 | 
					      disableStream: true,
 | 
				
			||||||
      disableRange: true,
 | 
					      disableRange: true,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let fullReader1 = stream1.getFullReader();
 | 
					    const fullReader1 = stream1.getFullReader();
 | 
				
			||||||
    let fullReader2 = stream2.getFullReader();
 | 
					    const fullReader2 = stream2.getFullReader();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let isStreamingSupported1, isRangeSupported1;
 | 
					    let isStreamingSupported1, isRangeSupported1;
 | 
				
			||||||
    let promise1 = fullReader1.headersReady.then(() => {
 | 
					    const promise1 = fullReader1.headersReady.then(() => {
 | 
				
			||||||
      isStreamingSupported1 = fullReader1.isStreamingSupported;
 | 
					      isStreamingSupported1 = fullReader1.isStreamingSupported;
 | 
				
			||||||
      isRangeSupported1 = fullReader1.isRangeSupported;
 | 
					      isRangeSupported1 = fullReader1.isRangeSupported;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let isStreamingSupported2, isRangeSupported2;
 | 
					    let isStreamingSupported2, isRangeSupported2;
 | 
				
			||||||
    let promise2 = fullReader2.headersReady.then(() => {
 | 
					    const promise2 = fullReader2.headersReady.then(() => {
 | 
				
			||||||
      isStreamingSupported2 = fullReader2.isStreamingSupported;
 | 
					      isStreamingSupported2 = fullReader2.isStreamingSupported;
 | 
				
			||||||
      isRangeSupported2 = fullReader2.isRangeSupported;
 | 
					      isRangeSupported2 = fullReader2.isRangeSupported;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let len1 = 0,
 | 
					    let len1 = 0,
 | 
				
			||||||
      len2 = 0;
 | 
					      len2 = 0;
 | 
				
			||||||
    let read1 = function() {
 | 
					    const read1 = function() {
 | 
				
			||||||
      return fullReader1.read().then(function(result) {
 | 
					      return fullReader1.read().then(function(result) {
 | 
				
			||||||
        if (result.done) {
 | 
					        if (result.done) {
 | 
				
			||||||
          return undefined;
 | 
					          return undefined;
 | 
				
			||||||
@ -123,7 +123,7 @@ describe("node_stream", function() {
 | 
				
			|||||||
        return read1();
 | 
					        return read1();
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    let read2 = function() {
 | 
					    const read2 = function() {
 | 
				
			||||||
      return fullReader2.read().then(function(result) {
 | 
					      return fullReader2.read().then(function(result) {
 | 
				
			||||||
        if (result.done) {
 | 
					        if (result.done) {
 | 
				
			||||||
          return undefined;
 | 
					          return undefined;
 | 
				
			||||||
@ -133,7 +133,7 @@ describe("node_stream", function() {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let readPromise = Promise.all([read1(), read2(), promise1, promise2]);
 | 
					    const readPromise = Promise.all([read1(), read2(), promise1, promise2]);
 | 
				
			||||||
    readPromise
 | 
					    readPromise
 | 
				
			||||||
      .then(result => {
 | 
					      .then(result => {
 | 
				
			||||||
        expect(isStreamingSupported1).toEqual(false);
 | 
					        expect(isStreamingSupported1).toEqual(false);
 | 
				
			||||||
@ -150,15 +150,15 @@ describe("node_stream", function() {
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it("read custom ranges for both http(s) and filesystem urls", function(done) {
 | 
					  it("read custom ranges for both http(s) and filesystem urls", function(done) {
 | 
				
			||||||
    let rangeSize = 32768;
 | 
					    const rangeSize = 32768;
 | 
				
			||||||
    let stream1 = new PDFNodeStream({
 | 
					    const stream1 = new PDFNodeStream({
 | 
				
			||||||
      url: `http://127.0.0.1:${port}/tracemonkey.pdf`,
 | 
					      url: `http://127.0.0.1:${port}/tracemonkey.pdf`,
 | 
				
			||||||
      length: pdfLength,
 | 
					      length: pdfLength,
 | 
				
			||||||
      rangeChunkSize: rangeSize,
 | 
					      rangeChunkSize: rangeSize,
 | 
				
			||||||
      disableStream: true,
 | 
					      disableStream: true,
 | 
				
			||||||
      disableRange: false,
 | 
					      disableRange: false,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    let stream2 = new PDFNodeStream({
 | 
					    const stream2 = new PDFNodeStream({
 | 
				
			||||||
      url: pdf,
 | 
					      url: pdf,
 | 
				
			||||||
      length: pdfLength,
 | 
					      length: pdfLength,
 | 
				
			||||||
      rangeChunkSize: rangeSize,
 | 
					      rangeChunkSize: rangeSize,
 | 
				
			||||||
@ -166,13 +166,13 @@ describe("node_stream", function() {
 | 
				
			|||||||
      disableRange: false,
 | 
					      disableRange: false,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let fullReader1 = stream1.getFullReader();
 | 
					    const fullReader1 = stream1.getFullReader();
 | 
				
			||||||
    let fullReader2 = stream2.getFullReader();
 | 
					    const fullReader2 = stream2.getFullReader();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let isStreamingSupported1, isRangeSupported1, fullReaderCancelled1;
 | 
					    let isStreamingSupported1, isRangeSupported1, fullReaderCancelled1;
 | 
				
			||||||
    let isStreamingSupported2, isRangeSupported2, fullReaderCancelled2;
 | 
					    let isStreamingSupported2, isRangeSupported2, fullReaderCancelled2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let promise1 = fullReader1.headersReady.then(function() {
 | 
					    const promise1 = fullReader1.headersReady.then(function() {
 | 
				
			||||||
      isStreamingSupported1 = fullReader1.isStreamingSupported;
 | 
					      isStreamingSupported1 = fullReader1.isStreamingSupported;
 | 
				
			||||||
      isRangeSupported1 = fullReader1.isRangeSupported;
 | 
					      isRangeSupported1 = fullReader1.isRangeSupported;
 | 
				
			||||||
      // we shall be able to close the full reader without issues
 | 
					      // we shall be able to close the full reader without issues
 | 
				
			||||||
@ -180,7 +180,7 @@ describe("node_stream", function() {
 | 
				
			|||||||
      fullReaderCancelled1 = true;
 | 
					      fullReaderCancelled1 = true;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let promise2 = fullReader2.headersReady.then(function() {
 | 
					    const promise2 = fullReader2.headersReady.then(function() {
 | 
				
			||||||
      isStreamingSupported2 = fullReader2.isStreamingSupported;
 | 
					      isStreamingSupported2 = fullReader2.isStreamingSupported;
 | 
				
			||||||
      isRangeSupported2 = fullReader2.isRangeSupported;
 | 
					      isRangeSupported2 = fullReader2.isRangeSupported;
 | 
				
			||||||
      fullReader2.cancel(new AbortException("Don't need fullReader2."));
 | 
					      fullReader2.cancel(new AbortException("Don't need fullReader2."));
 | 
				
			||||||
@ -188,26 +188,32 @@ describe("node_stream", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Skipping fullReader results, requesting something from the PDF end.
 | 
					    // Skipping fullReader results, requesting something from the PDF end.
 | 
				
			||||||
    let tailSize = pdfLength % rangeSize || rangeSize;
 | 
					    const tailSize = pdfLength % rangeSize || rangeSize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let range11Reader = stream1.getRangeReader(
 | 
					    const range11Reader = stream1.getRangeReader(
 | 
				
			||||||
      pdfLength - tailSize - rangeSize,
 | 
					      pdfLength - tailSize - rangeSize,
 | 
				
			||||||
      pdfLength - tailSize
 | 
					      pdfLength - tailSize
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    let range12Reader = stream1.getRangeReader(pdfLength - tailSize, pdfLength);
 | 
					    const range12Reader = stream1.getRangeReader(
 | 
				
			||||||
 | 
					      pdfLength - tailSize,
 | 
				
			||||||
 | 
					      pdfLength
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let range21Reader = stream2.getRangeReader(
 | 
					    const range21Reader = stream2.getRangeReader(
 | 
				
			||||||
      pdfLength - tailSize - rangeSize,
 | 
					      pdfLength - tailSize - rangeSize,
 | 
				
			||||||
      pdfLength - tailSize
 | 
					      pdfLength - tailSize
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    let range22Reader = stream2.getRangeReader(pdfLength - tailSize, pdfLength);
 | 
					    const range22Reader = stream2.getRangeReader(
 | 
				
			||||||
 | 
					      pdfLength - tailSize,
 | 
				
			||||||
 | 
					      pdfLength
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let result11 = { value: 0 },
 | 
					    const result11 = { value: 0 },
 | 
				
			||||||
      result12 = { value: 0 };
 | 
					      result12 = { value: 0 };
 | 
				
			||||||
    let result21 = { value: 0 },
 | 
					    const result21 = { value: 0 },
 | 
				
			||||||
      result22 = { value: 0 };
 | 
					      result22 = { value: 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let read = function(reader, lenResult) {
 | 
					    const read = function(reader, lenResult) {
 | 
				
			||||||
      return reader.read().then(function(result) {
 | 
					      return reader.read().then(function(result) {
 | 
				
			||||||
        if (result.done) {
 | 
					        if (result.done) {
 | 
				
			||||||
          return undefined;
 | 
					          return undefined;
 | 
				
			||||||
@ -217,7 +223,7 @@ describe("node_stream", function() {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let readPromises = Promise.all([
 | 
					    const readPromises = Promise.all([
 | 
				
			||||||
      read(range11Reader, result11),
 | 
					      read(range11Reader, result11),
 | 
				
			||||||
      read(range12Reader, result12),
 | 
					      read(range12Reader, result12),
 | 
				
			||||||
      read(range21Reader, result21),
 | 
					      read(range21Reader, result21),
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@ describe("pdf_history", function() {
 | 
				
			|||||||
        false
 | 
					        false
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let destArrayString = JSON.stringify([
 | 
					      const destArrayString = JSON.stringify([
 | 
				
			||||||
        { num: 3757, gen: 0 },
 | 
					        { num: 3757, gen: 0 },
 | 
				
			||||||
        { name: "XYZ" },
 | 
					        { name: "XYZ" },
 | 
				
			||||||
        92.918,
 | 
					        92.918,
 | 
				
			||||||
@ -51,11 +51,11 @@ describe("pdf_history", function() {
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe("isDestArraysEqual", function() {
 | 
					  describe("isDestArraysEqual", function() {
 | 
				
			||||||
    let firstDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 0, 375, null];
 | 
					    const firstDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 0, 375, null];
 | 
				
			||||||
    let secondDest = [{ num: 5, gen: 0 }, { name: "XYZ" }, 0, 375, null];
 | 
					    const secondDest = [{ num: 5, gen: 0 }, { name: "XYZ" }, 0, 375, null];
 | 
				
			||||||
    let thirdDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 750, 0, null];
 | 
					    const thirdDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 750, 0, null];
 | 
				
			||||||
    let fourthDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 0, 375, 1.0];
 | 
					    const fourthDest = [{ num: 1, gen: 0 }, { name: "XYZ" }, 0, 375, 1.0];
 | 
				
			||||||
    let fifthDest = [{ gen: 0, num: 1 }, { name: "XYZ" }, 0, 375, null];
 | 
					    const fifthDest = [{ gen: 0, num: 1 }, { name: "XYZ" }, 0, 375, null];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should reject non-equal destination arrays", function() {
 | 
					    it("should reject non-equal destination arrays", function() {
 | 
				
			||||||
      expect(isDestArraysEqual(firstDest, undefined)).toEqual(false);
 | 
					      expect(isDestArraysEqual(firstDest, undefined)).toEqual(false);
 | 
				
			||||||
@ -70,7 +70,7 @@ describe("pdf_history", function() {
 | 
				
			|||||||
      expect(isDestArraysEqual(firstDest, firstDest)).toEqual(true);
 | 
					      expect(isDestArraysEqual(firstDest, firstDest)).toEqual(true);
 | 
				
			||||||
      expect(isDestArraysEqual(firstDest, fifthDest)).toEqual(true);
 | 
					      expect(isDestArraysEqual(firstDest, fifthDest)).toEqual(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let firstDestCopy = firstDest.slice();
 | 
					      const firstDestCopy = firstDest.slice();
 | 
				
			||||||
      expect(firstDest).not.toBe(firstDestCopy);
 | 
					      expect(firstDest).not.toBe(firstDestCopy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      expect(isDestArraysEqual(firstDest, firstDestCopy)).toEqual(true);
 | 
					      expect(isDestArraysEqual(firstDest, firstDestCopy)).toEqual(true);
 | 
				
			||||||
 | 
				
			|||||||
@ -69,7 +69,7 @@ describe("stream", function() {
 | 
				
			|||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      predictor.reset();
 | 
					      predictor.reset();
 | 
				
			||||||
      let clampedResult = predictor.getBytes(6, /* forceClamped = */ true);
 | 
					      const clampedResult = predictor.getBytes(6, /* forceClamped = */ true);
 | 
				
			||||||
      expect(clampedResult).toEqual(
 | 
					      expect(clampedResult).toEqual(
 | 
				
			||||||
        new Uint8ClampedArray([100, 3, 101, 2, 102, 1])
 | 
					        new Uint8ClampedArray([100, 3, 101, 2, 102, 1])
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
				
			|||||||
@ -50,13 +50,13 @@ const TEST_PDFS_PATH = {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function buildGetDocumentParams(filename, options) {
 | 
					function buildGetDocumentParams(filename, options) {
 | 
				
			||||||
  let params = Object.create(null);
 | 
					  const params = Object.create(null);
 | 
				
			||||||
  if (isNodeJS) {
 | 
					  if (isNodeJS) {
 | 
				
			||||||
    params.url = TEST_PDFS_PATH.node + filename;
 | 
					    params.url = TEST_PDFS_PATH.node + filename;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;
 | 
					    params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  for (let option in options) {
 | 
					  for (const option in options) {
 | 
				
			||||||
    params[option] = options[option];
 | 
					    params[option] = options[option];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return params;
 | 
					  return params;
 | 
				
			||||||
@ -137,8 +137,8 @@ class XRefMock {
 | 
				
			|||||||
  constructor(array) {
 | 
					  constructor(array) {
 | 
				
			||||||
    this._map = Object.create(null);
 | 
					    this._map = Object.create(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (let key in array) {
 | 
					    for (const key in array) {
 | 
				
			||||||
      let obj = array[key];
 | 
					      const obj = array[key];
 | 
				
			||||||
      this._map[obj.ref.toString()] = obj.data;
 | 
					      this._map[obj.ref.toString()] = obj.data;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -449,7 +449,7 @@ describe("ui_utils", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should reject invalid parameters", function(done) {
 | 
					    it("should reject invalid parameters", function(done) {
 | 
				
			||||||
      let invalidTarget = waitOnEventOrTimeout({
 | 
					      const invalidTarget = waitOnEventOrTimeout({
 | 
				
			||||||
        target: "window",
 | 
					        target: "window",
 | 
				
			||||||
        name: "DOMContentLoaded",
 | 
					        name: "DOMContentLoaded",
 | 
				
			||||||
      }).then(
 | 
					      }).then(
 | 
				
			||||||
@ -461,7 +461,7 @@ describe("ui_utils", function() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let invalidName = waitOnEventOrTimeout({
 | 
					      const invalidName = waitOnEventOrTimeout({
 | 
				
			||||||
        target: eventBus,
 | 
					        target: eventBus,
 | 
				
			||||||
        name: "",
 | 
					        name: "",
 | 
				
			||||||
      }).then(
 | 
					      }).then(
 | 
				
			||||||
@ -473,7 +473,7 @@ describe("ui_utils", function() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let invalidDelay = waitOnEventOrTimeout({
 | 
					      const invalidDelay = waitOnEventOrTimeout({
 | 
				
			||||||
        target: eventBus,
 | 
					        target: eventBus,
 | 
				
			||||||
        name: "pagerendered",
 | 
					        name: "pagerendered",
 | 
				
			||||||
        delay: -1000,
 | 
					        delay: -1000,
 | 
				
			||||||
@ -496,9 +496,9 @@ describe("ui_utils", function() {
 | 
				
			|||||||
      if (isNodeJS) {
 | 
					      if (isNodeJS) {
 | 
				
			||||||
        pending("Document in not supported in Node.js.");
 | 
					        pending("Document in not supported in Node.js.");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let button = document.createElement("button");
 | 
					      const button = document.createElement("button");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let buttonClicked = waitOnEventOrTimeout({
 | 
					      const buttonClicked = waitOnEventOrTimeout({
 | 
				
			||||||
        target: button,
 | 
					        target: button,
 | 
				
			||||||
        name: "click",
 | 
					        name: "click",
 | 
				
			||||||
        delay: 10000,
 | 
					        delay: 10000,
 | 
				
			||||||
@ -516,9 +516,9 @@ describe("ui_utils", function() {
 | 
				
			|||||||
      if (isNodeJS) {
 | 
					      if (isNodeJS) {
 | 
				
			||||||
        pending("Document in not supported in Node.js.");
 | 
					        pending("Document in not supported in Node.js.");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      let button = document.createElement("button");
 | 
					      const button = document.createElement("button");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let buttonClicked = waitOnEventOrTimeout({
 | 
					      const buttonClicked = waitOnEventOrTimeout({
 | 
				
			||||||
        target: button,
 | 
					        target: button,
 | 
				
			||||||
        name: "click",
 | 
					        name: "click",
 | 
				
			||||||
        delay: 10,
 | 
					        delay: 10,
 | 
				
			||||||
@ -532,7 +532,7 @@ describe("ui_utils", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should resolve on event, using the EventBus", function(done) {
 | 
					    it("should resolve on event, using the EventBus", function(done) {
 | 
				
			||||||
      let pageRendered = waitOnEventOrTimeout({
 | 
					      const pageRendered = waitOnEventOrTimeout({
 | 
				
			||||||
        target: eventBus,
 | 
					        target: eventBus,
 | 
				
			||||||
        name: "pagerendered",
 | 
					        name: "pagerendered",
 | 
				
			||||||
        delay: 10000,
 | 
					        delay: 10000,
 | 
				
			||||||
@ -547,7 +547,7 @@ describe("ui_utils", function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should resolve on timeout, using the EventBus", function(done) {
 | 
					    it("should resolve on timeout, using the EventBus", function(done) {
 | 
				
			||||||
      let pageRendered = waitOnEventOrTimeout({
 | 
					      const pageRendered = waitOnEventOrTimeout({
 | 
				
			||||||
        target: eventBus,
 | 
					        target: eventBus,
 | 
				
			||||||
        name: "pagerendered",
 | 
					        name: "pagerendered",
 | 
				
			||||||
        delay: 10,
 | 
					        delay: 10,
 | 
				
			||||||
 | 
				
			|||||||
@ -48,14 +48,14 @@ describe("util", function() {
 | 
				
			|||||||
      const length = 10000; // Larger than MAX_ARGUMENT_COUNT = 8192.
 | 
					      const length = 10000; // Larger than MAX_ARGUMENT_COUNT = 8192.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Create an array with `length` 'a' character codes.
 | 
					      // Create an array with `length` 'a' character codes.
 | 
				
			||||||
      let bytes = new Uint8Array(length);
 | 
					      const bytes = new Uint8Array(length);
 | 
				
			||||||
      for (let i = 0; i < length; i++) {
 | 
					      for (let i = 0; i < length; i++) {
 | 
				
			||||||
        bytes[i] = "a".charCodeAt(0);
 | 
					        bytes[i] = "a".charCodeAt(0);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Create a string with `length` 'a' characters. We need an array of size
 | 
					      // Create a string with `length` 'a' characters. We need an array of size
 | 
				
			||||||
      // `length + 1` since `join` puts the argument between the array elements.
 | 
					      // `length + 1` since `join` puts the argument between the array elements.
 | 
				
			||||||
      let string = Array(length + 1).join("a");
 | 
					      const string = Array(length + 1).join("a");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      expect(bytesToString(bytes)).toEqual(string);
 | 
					      expect(bytesToString(bytes)).toEqual(string);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -184,55 +184,55 @@ describe("util", function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  describe("stringToPDFString", function() {
 | 
					  describe("stringToPDFString", function() {
 | 
				
			||||||
    it("handles ISO Latin 1 strings", function() {
 | 
					    it("handles ISO Latin 1 strings", function() {
 | 
				
			||||||
      let str = "\x8Dstring\x8E";
 | 
					      const str = "\x8Dstring\x8E";
 | 
				
			||||||
      expect(stringToPDFString(str)).toEqual("\u201Cstring\u201D");
 | 
					      expect(stringToPDFString(str)).toEqual("\u201Cstring\u201D");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("handles UTF-16 big-endian strings", function() {
 | 
					    it("handles UTF-16 big-endian strings", function() {
 | 
				
			||||||
      let str = "\xFE\xFF\x00\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67";
 | 
					      const str = "\xFE\xFF\x00\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67";
 | 
				
			||||||
      expect(stringToPDFString(str)).toEqual("string");
 | 
					      expect(stringToPDFString(str)).toEqual("string");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("handles UTF-16 little-endian strings", function() {
 | 
					    it("handles UTF-16 little-endian strings", function() {
 | 
				
			||||||
      let str = "\xFF\xFE\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67\x00";
 | 
					      const str = "\xFF\xFE\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67\x00";
 | 
				
			||||||
      expect(stringToPDFString(str)).toEqual("string");
 | 
					      expect(stringToPDFString(str)).toEqual("string");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("handles empty strings", function() {
 | 
					    it("handles empty strings", function() {
 | 
				
			||||||
      // ISO Latin 1
 | 
					      // ISO Latin 1
 | 
				
			||||||
      let str1 = "";
 | 
					      const str1 = "";
 | 
				
			||||||
      expect(stringToPDFString(str1)).toEqual("");
 | 
					      expect(stringToPDFString(str1)).toEqual("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // UTF-16BE
 | 
					      // UTF-16BE
 | 
				
			||||||
      let str2 = "\xFE\xFF";
 | 
					      const str2 = "\xFE\xFF";
 | 
				
			||||||
      expect(stringToPDFString(str2)).toEqual("");
 | 
					      expect(stringToPDFString(str2)).toEqual("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // UTF-16LE
 | 
					      // UTF-16LE
 | 
				
			||||||
      let str3 = "\xFF\xFE";
 | 
					      const str3 = "\xFF\xFE";
 | 
				
			||||||
      expect(stringToPDFString(str3)).toEqual("");
 | 
					      expect(stringToPDFString(str3)).toEqual("");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe("removeNullCharacters", function() {
 | 
					  describe("removeNullCharacters", function() {
 | 
				
			||||||
    it("should not modify string without null characters", function() {
 | 
					    it("should not modify string without null characters", function() {
 | 
				
			||||||
      let str = "string without null chars";
 | 
					      const str = "string without null chars";
 | 
				
			||||||
      expect(removeNullCharacters(str)).toEqual("string without null chars");
 | 
					      expect(removeNullCharacters(str)).toEqual("string without null chars");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should modify string with null characters", function() {
 | 
					    it("should modify string with null characters", function() {
 | 
				
			||||||
      let str = "string\x00With\x00Null\x00Chars";
 | 
					      const str = "string\x00With\x00Null\x00Chars";
 | 
				
			||||||
      expect(removeNullCharacters(str)).toEqual("stringWithNullChars");
 | 
					      expect(removeNullCharacters(str)).toEqual("stringWithNullChars");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe("ReadableStream", function() {
 | 
					  describe("ReadableStream", function() {
 | 
				
			||||||
    it("should return an Object", function() {
 | 
					    it("should return an Object", function() {
 | 
				
			||||||
      let readable = new ReadableStream();
 | 
					      const readable = new ReadableStream();
 | 
				
			||||||
      expect(typeof readable).toEqual("object");
 | 
					      expect(typeof readable).toEqual("object");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("should have property getReader", function() {
 | 
					    it("should have property getReader", function() {
 | 
				
			||||||
      let readable = new ReadableStream();
 | 
					      const readable = new ReadableStream();
 | 
				
			||||||
      expect(typeof readable.getReader).toEqual("function");
 | 
					      expect(typeof readable.getReader).toEqual("function");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,5 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // ECMAScript 6
 | 
					    // ECMAScript 6
 | 
				
			||||||
    "no-var": "error",
 | 
					    "no-var": "error",
 | 
				
			||||||
    "prefer-const": "error",
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user