1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Update Prettier to version 2.0

Please note that these changes were done automatically, using `gulp lint --fix`.

Given that the major version number was increased, there's a fair number of (primarily whitespace) changes; please see https://prettier.io/blog/2020/03/21/2.0.0.html
In order to reduce the size of these changes somewhat, this patch maintains the old "arrowParens" style for now (once mozilla-central updates Prettier we can simply choose the same formatting, assuming it will differ here).
This commit is contained in:
Jonas Jenwald 2020-04-14 12:28:14 +02:00
parent a4dd081d7b
commit 426945b480
145 changed files with 2005 additions and 2009 deletions

View file

@ -503,7 +503,7 @@ class Annotation {
}
const objectLoader = new ObjectLoader(resources, keys, resources.xref);
return objectLoader.load().then(function() {
return objectLoader.load().then(function () {
return resources;
});
});
@ -941,7 +941,7 @@ class TextWidgetAnnotation extends WidgetAnnotation {
resources: this.fieldResources,
operatorList,
})
.then(function() {
.then(function () {
return operatorList;
});
}

View file

@ -47,7 +47,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
CCITTFaxStream.prototype.readBlock = function() {
CCITTFaxStream.prototype.readBlock = function () {
while (!this.eof) {
const c = this.ccittFaxDecoder.readNextChar();
if (c === -1) {

View file

@ -280,7 +280,7 @@ class ChunkedStream {
function ChunkedStreamSubstream() {}
ChunkedStreamSubstream.prototype = Object.create(this);
ChunkedStreamSubstream.prototype.getMissingChunks = function() {
ChunkedStreamSubstream.prototype.getMissingChunks = function () {
const chunkSize = this.chunkSize;
const beginChunk = Math.floor(this.start / chunkSize);
const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
@ -292,7 +292,7 @@ class ChunkedStream {
}
return missingChunks;
};
ChunkedStreamSubstream.prototype.allChunksLoaded = function() {
ChunkedStreamSubstream.prototype.allChunksLoaded = function () {
if (this.numChunksLoaded === this.numChunks) {
return true;
}
@ -454,7 +454,7 @@ class ChunkedStreamManager {
}
}
chunksToRequest.sort(function(a, b) {
chunksToRequest.sort(function (a, b) {
return a - b;
});
return this._requestChunks(chunksToRequest);

View file

@ -530,7 +530,7 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
};
function processBinaryCMap(data, cMap, extend) {
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
var stream = new BinaryCMapStream(data);
var header = stream.readByte();
cMap.vertical = !!(header & 1);
@ -934,7 +934,9 @@ var CMapFactory = (function CMapFactoryClosure() {
}
function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function(newCMap) {
return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (
newCMap
) {
cMap.useCMap = newCMap;
// If there aren't any code space ranges defined clone all the parent ones
// into this cMap.
@ -947,7 +949,7 @@ var CMapFactory = (function CMapFactoryClosure() {
}
// Merge the map into the current one, making sure not to override
// any previously defined entries.
cMap.useCMap.forEach(function(key, value) {
cMap.useCMap.forEach(function (key, value) {
if (!cMap.contains(key)) {
cMap.mapOne(key, cMap.useCMap.lookup(key));
}
@ -972,13 +974,13 @@ var CMapFactory = (function CMapFactoryClosure() {
);
}
return fetchBuiltInCMap(name).then(function(data) {
return fetchBuiltInCMap(name).then(function (data) {
var cMapData = data.cMapData,
compressionType = data.compressionType;
var cMap = new CMap(true);
if (compressionType === CMapCompressionType.BINARY) {
return new BinaryCMapReader().process(cMapData, cMap, function(
return new BinaryCMapReader().process(cMapData, cMap, function (
useCMap
) {
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
@ -1007,7 +1009,7 @@ var CMapFactory = (function CMapFactoryClosure() {
} else if (isStream(encoding)) {
var cMap = new CMap();
var lexer = new Lexer(encoding);
return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function(
return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (
parsedCMap
) {
if (parsedCMap.isIdentityCMap) {

View file

@ -18,7 +18,7 @@ import { assert, BaseException, warn } from "../shared/util.js";
function getLookupTableFactory(initializer) {
let lookup;
return function() {
return function () {
if (initializer) {
lookup = Object.create(null);
initializer(lookup);

View file

@ -282,7 +282,7 @@ class Page {
resources: this.resources,
operatorList: opList,
})
.then(function() {
.then(function () {
return opList;
});
});
@ -290,7 +290,7 @@ class Page {
// Fetch the page's annotations and add their operator lists to the
// page's operator list to render them.
return Promise.all([pageListPromise, this._parsedAnnotations]).then(
function([pageOpList, annotations]) {
function ([pageOpList, annotations]) {
if (annotations.length === 0) {
pageOpList.flush(true);
return { length: pageOpList.totalLength };
@ -311,7 +311,7 @@ class Page {
}
}
return Promise.all(opListPromises).then(function(opLists) {
return Promise.all(opListPromises).then(function (opLists) {
pageOpList.addOp(OPS.beginAnnotations, []);
for (const opList of opLists) {
pageOpList.addOpList(opList);
@ -366,7 +366,7 @@ class Page {
}
getAnnotationsData(intent) {
return this._parsedAnnotations.then(function(annotations) {
return this._parsedAnnotations.then(function (annotations) {
const annotationsData = [];
for (let i = 0, ii = annotations.length; i < ii; i++) {
if (!intent || isAnnotationRenderable(annotations[i], intent)) {
@ -403,12 +403,12 @@ class Page {
}
return Promise.all(annotationPromises).then(
function(annotations) {
function (annotations) {
return annotations.filter(function isDefined(annotation) {
return !!annotation;
});
},
function(reason) {
function (reason) {
warn(`_parsedAnnotations: "${reason}".`);
return [];
}

View file

@ -127,9 +127,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
});
const reader = readableStream.getReader();
const data = await new Promise(function(resolve, reject) {
const data = await new Promise(function (resolve, reject) {
function pump() {
reader.read().then(function({ value, done }) {
reader.read().then(function ({ value, done }) {
if (done) {
return;
}
@ -432,7 +432,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
resources: dict.get("Resources") || resources,
operatorList,
initialState,
}).then(function() {
}).then(function () {
operatorList.addOp(OPS.paintFormXObjectEnd, []);
if (group) {
@ -566,7 +566,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
image.getIR(this.options.forceDataSchema),
])
.then(
function() {
function () {
// Only add the dependency once we know that the native JPEG
// decoding succeeded, to ensure that rendering will always
// complete.
@ -738,7 +738,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
resources: patternResources,
operatorList: tilingOpList,
})
.then(function() {
.then(function () {
return getTilingPatternIR(
{
fnArray: tilingOpList.fnArray,
@ -749,7 +749,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
);
})
.then(
function(tilingPatternIR) {
function (tilingPatternIR) {
// Add the dependencies to the parent operator list so they are
// resolved before the sub operator list is executed synchronously.
operatorList.addDependencies(tilingOpList.dependencies);
@ -795,7 +795,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
return translated
.loadType3Data(this, resources, operatorList, task)
.then(function() {
.then(function () {
return translated;
})
.catch(reason => {
@ -896,7 +896,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
operatorList,
task,
stateManager.state
).then(function(loadedName) {
).then(function (loadedName) {
operatorList.addDependency(loadedName);
gStateObj.push([key, [loadedName, value[1]]]);
});
@ -950,7 +950,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
break;
}
}
return promise.then(function() {
return promise.then(function () {
if (gStateObj.length > 0) {
operatorList.addOp(OPS.setGState, [gStateObj]);
}
@ -985,8 +985,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
}
if (!fontRef) {
const partialMsg = `Font "${fontName ||
(font && font.toString())}" is not available`;
const partialMsg = `Font "${
fontName || (font && font.toString())
}" is not available`;
if (!this.options.ignoreErrors && !this.parsingType3Font) {
warn(`${partialMsg}.`);
@ -1275,8 +1276,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
return new Promise(function promiseBody(resolve, reject) {
const next = function(promise) {
Promise.all([promise, operatorList.ready]).then(function() {
const next = function (promise) {
Promise.all([promise, operatorList.ready]).then(function () {
try {
promiseBody(resolve, reject);
} catch (ex) {
@ -1314,7 +1315,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
next(
new Promise(function(resolveXObject, rejectXObject) {
new Promise(function (resolveXObject, rejectXObject) {
if (!name) {
throw new FormatError(
"XObject must be referred to by name."
@ -1347,7 +1348,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
task,
stateManager.state.clone()
)
.then(function() {
.then(function () {
stateManager.restore();
resolveXObject();
}, rejectXObject);
@ -1373,7 +1374,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
);
}
resolveXObject();
}).catch(function(reason) {
}).catch(function (reason) {
if (reason instanceof AbortException) {
return;
}
@ -1403,7 +1404,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
task,
stateManager.state
)
.then(function(loadedName) {
.then(function (loadedName) {
operatorList.addDependency(loadedName);
operatorList.addOp(OPS.setFont, [loadedName, fontSize]);
})
@ -1497,7 +1498,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
cs: args[0],
resources,
})
.then(function(colorSpace) {
.then(function (colorSpace) {
if (colorSpace) {
stateManager.state.fillColorSpace = colorSpace;
}
@ -1511,7 +1512,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
cs: args[0],
resources,
})
.then(function(colorSpace) {
.then(function (colorSpace) {
if (colorSpace) {
stateManager.state.strokeColorSpace = colorSpace;
}
@ -1875,7 +1876,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
function handleSetFont(fontName, fontRef) {
return self
.loadFont(fontName, fontRef, resources)
.then(function(translated) {
.then(function (translated) {
textState.font = translated.font;
textState.fontMatrix =
translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
@ -1983,9 +1984,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var timeSlotManager = new TimeSlotManager();
return new Promise(function promiseBody(resolve, reject) {
const next = function(promise) {
const next = function (promise) {
enqueueChunk();
Promise.all([promise, sink.ready]).then(function() {
Promise.all([promise, sink.ready]).then(function () {
try {
promiseBody(resolve, reject);
} catch (ex) {
@ -2236,7 +2237,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
next(
new Promise(function(resolveXObject, rejectXObject) {
new Promise(function (resolveXObject, rejectXObject) {
if (!name) {
throw new FormatError(
"XObject must be referred to by name."
@ -2307,13 +2308,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
sink: sinkWrapper,
seenStyles,
})
.then(function() {
.then(function () {
if (!sinkWrapper.enqueueInvoked) {
skipEmptyXObjs[name] = true;
}
resolveXObject();
}, rejectXObject);
}).catch(function(reason) {
}).catch(function (reason) {
if (reason instanceof AbortException) {
return;
}
@ -2673,10 +2674,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
encoding: ucs2CMapName,
fetchBuiltInCMap: this.fetchBuiltInCMap,
useCMap: null,
}).then(function(ucs2CMap) {
}).then(function (ucs2CMap) {
const cMap = properties.cMap;
const toUnicode = [];
cMap.forEach(function(charcode, cid) {
cMap.forEach(function (charcode, cid) {
if (cid > 0xffff) {
throw new FormatError("Max size of CID is 65,535");
}
@ -2706,7 +2707,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
encoding: cmapObj,
fetchBuiltInCMap: this.fetchBuiltInCMap,
useCMap: null,
}).then(function(cmap) {
}).then(function (cmap) {
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xffff);
}
@ -2718,7 +2719,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
fetchBuiltInCMap: this.fetchBuiltInCMap,
useCMap: null,
}).then(
function(cmap) {
function (cmap) {
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xffff);
}
@ -2726,7 +2727,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Convert UTF-16BE
// NOTE: cmap can be a sparse array, so use forEach instead of
// `for(;;)` to iterate over all keys.
cmap.forEach(function(charCode, token) {
cmap.forEach(function (charCode, token) {
var str = [];
for (var k = 0; k < token.length; k += 2) {
var w1 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1);
@ -3212,7 +3213,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
encoding: cidEncoding,
fetchBuiltInCMap: this.fetchBuiltInCMap,
useCMap: null,
}).then(function(cMap) {
}).then(function (cMap) {
properties.cMap = cMap;
properties.vertical = properties.cMap.vertical;
});
@ -3235,7 +3236,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
},
};
PartialEvaluator.buildFontPaths = function(font, glyphs, handler) {
PartialEvaluator.buildFontPaths = function (font, glyphs, handler) {
function buildPath(fontChar) {
if (font.renderer.hasBuiltPath(fontChar)) {
return;
@ -3261,7 +3262,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// TODO: Change this to a `static` getter, using shadowing, once
// `PartialEvaluator` is converted to a proper class.
PartialEvaluator.getFallbackFontDict = function() {
PartialEvaluator.getFallbackFontDict = function () {
if (this._fallbackFontDict) {
return this._fallbackFontDict;
}
@ -3346,7 +3347,7 @@ class TranslatedFont {
for (var i = 0, n = charProcKeys.length; i < n; ++i) {
const key = charProcKeys[i];
loadCharProcsPromise = loadCharProcsPromise.then(function() {
loadCharProcsPromise = loadCharProcsPromise.then(function () {
var glyphStream = charProcs.get(key);
var operatorList = new OperatorList();
return type3Evaluator
@ -3356,21 +3357,21 @@ class TranslatedFont {
resources: fontResources,
operatorList,
})
.then(function() {
.then(function () {
charProcOperatorList[key] = operatorList.getIR();
// Add the dependencies to the parent operator list so they are
// resolved before sub operator list is executed synchronously.
parentOperatorList.addDependencies(operatorList.dependencies);
})
.catch(function(reason) {
.catch(function (reason) {
warn(`Type3 font resource "${key}" is not available.`);
const dummyOperatorList = new OperatorList();
charProcOperatorList[key] = dummyOperatorList.getIR();
});
});
}
this.type3Loaded = loadCharProcsPromise.then(function() {
this.type3Loaded = loadCharProcsPromise.then(function () {
translatedFont.charProcOperatorList = charProcOperatorList;
});
return this.type3Loaded;
@ -3530,7 +3531,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
//
// If variableArgs === true: [0, `numArgs`] expected
// If variableArgs === false: exactly `numArgs` expected
var getOPMap = getLookupTableFactory(function(t) {
var getOPMap = getLookupTableFactory(function (t) {
// Graphic state
t["w"] = { id: OPS.setLineWidth, numArgs: 1, variableArgs: false };
t["J"] = { id: OPS.setLineCap, numArgs: 1, variableArgs: false };

View file

@ -283,7 +283,7 @@ var Glyph = (function GlyphClosure() {
this.isInFont = isInFont;
}
Glyph.prototype.matchesForCache = function(
Glyph.prototype.matchesForCache = function (
fontChar,
unicode,
accent,
@ -694,7 +694,7 @@ var Font = (function FontClosure() {
this.seacMap = properties.seacMap;
}
Font.getFontID = (function() {
Font.getFontID = (function () {
var ID = 1;
return function Font_getFontID() {
return String(ID++);
@ -1367,7 +1367,7 @@ var Font = (function FontClosure() {
var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
if (!isIdentityUnicode) {
this.toUnicode.forEach(function(charCode, unicodeCharCode) {
this.toUnicode.forEach(function (charCode, unicodeCharCode) {
map[+charCode] = unicodeCharCode;
});
}
@ -1775,7 +1775,7 @@ var Font = (function FontClosure() {
}
// removing duplicate entries
mappings.sort(function(a, b) {
mappings.sort(function (a, b) {
return a.charCode - b.charCode;
});
for (i = 1; i < mappings.length; i++) {
@ -2764,7 +2764,7 @@ var Font = (function FontClosure() {
var cidToGidMap = properties.cidToGidMap || [];
var isCidToGidMapEmpty = cidToGidMap.length === 0;
properties.cMap.forEach(function(charCode, cid) {
properties.cMap.forEach(function (charCode, cid) {
if (cid > 0xffff) {
throw new FormatError("Max size of CID is 65,535");
}

View file

@ -159,7 +159,7 @@ var PDFFunction = (function PDFFunctionClosure() {
this.parse({ xref, isEvalSupported, fn: xref.fetchIfRef(fnObj[j]) })
);
}
return function(src, srcOffset, dest, destOffset) {
return function (src, srcOffset, dest, destOffset) {
for (var i = 0, ii = fnArray.length; i < ii; i++) {
fnArray[i](src, srcOffset, dest, destOffset + i);
}
@ -873,7 +873,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
function AstNode(type) {
this.type = type;
}
AstNode.prototype.visit = function(visitor) {
AstNode.prototype.visit = function (visitor) {
unreachable("abstract method");
};
@ -884,7 +884,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
this.max = max;
}
AstArgument.prototype = Object.create(AstNode.prototype);
AstArgument.prototype.visit = function(visitor) {
AstArgument.prototype.visit = function (visitor) {
visitor.visitArgument(this);
};
@ -895,7 +895,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
this.max = number;
}
AstLiteral.prototype = Object.create(AstNode.prototype);
AstLiteral.prototype.visit = function(visitor) {
AstLiteral.prototype.visit = function (visitor) {
visitor.visitLiteral(this);
};
@ -908,7 +908,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
this.max = max;
}
AstBinaryOperation.prototype = Object.create(AstNode.prototype);
AstBinaryOperation.prototype.visit = function(visitor) {
AstBinaryOperation.prototype.visit = function (visitor) {
visitor.visitBinaryOperation(this);
};
@ -919,7 +919,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
this.max = max;
}
AstMin.prototype = Object.create(AstNode.prototype);
AstMin.prototype.visit = function(visitor) {
AstMin.prototype.visit = function (visitor) {
visitor.visitMin(this);
};
@ -930,7 +930,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
this.max = max;
}
AstVariable.prototype = Object.create(AstNode.prototype);
AstVariable.prototype.visit = function(visitor) {
AstVariable.prototype.visit = function (visitor) {
visitor.visitVariable(this);
};
@ -940,7 +940,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
this.arg = arg;
}
AstVariableDefinition.prototype = Object.create(AstNode.prototype);
AstVariableDefinition.prototype.visit = function(visitor) {
AstVariableDefinition.prototype.visit = function (visitor) {
visitor.visitVariableDefinition(this);
};
@ -1245,12 +1245,12 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
}
var result = [];
instructions.forEach(function(instruction) {
instructions.forEach(function (instruction) {
var statementBuilder = new ExpressionBuilderVisitor();
instruction.visit(statementBuilder);
result.push(statementBuilder.toString());
});
stack.forEach(function(expr, i) {
stack.forEach(function (expr, i) {
var statementBuilder = new ExpressionBuilderVisitor();
expr.visit(statementBuilder);
var min = range[i * 2],

View file

@ -16,7 +16,7 @@
var getLookupTableFactory = require("./core_utils.js").getLookupTableFactory;
var getGlyphsUnicode = getLookupTableFactory(function(t) {
var getGlyphsUnicode = getLookupTableFactory(function (t) {
t["A"] = 0x0041;
t["AE"] = 0x00c6;
t["AEacute"] = 0x01fc;
@ -4343,7 +4343,7 @@ var getGlyphsUnicode = getLookupTableFactory(function(t) {
t["vextendsingle"] = 0x2223;
});
var getDingbatsGlyphsUnicode = getLookupTableFactory(function(t) {
var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
t["space"] = 0x0020;
t["a1"] = 0x2701;
t["a2"] = 0x2702;

View file

@ -265,7 +265,7 @@ var PDFImage = (function PDFImageClosure() {
* Handles processing of image data and returns the Promise that is resolved
* with a PDFImage when the image is ready to be used.
*/
PDFImage.buildImage = function({
PDFImage.buildImage = function ({
handler,
xref,
res,
@ -300,7 +300,7 @@ var PDFImage = (function PDFImageClosure() {
}
}
return Promise.all([imagePromise, smaskPromise, maskPromise]).then(
function([imageData, smaskData, maskData]) {
function ([imageData, smaskData, maskData]) {
return new PDFImage({
xref,
res,
@ -314,7 +314,7 @@ var PDFImage = (function PDFImageClosure() {
);
};
PDFImage.createMask = function({
PDFImage.createMask = function ({
imgArray,
width,
height,

View file

@ -62,7 +62,7 @@ class NativeImageDecoder {
image.getIR(this.forceDataSchema),
colorSpace.numComps,
])
.then(function({ data, width, height }) {
.then(function ({ data, width, height }) {
return new Stream(data, 0, data.length, dict);
});
}

View file

@ -371,7 +371,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
// Sorting is non-standard, and it is not required. But sorting increases
// the number of template bits that can be reused from the previous
// contextLabel in the main loop.
template.sort(function(a, b) {
template.sort(function (a, b) {
return a.y - b.y || a.x - b.x;
});

View file

@ -43,12 +43,12 @@ const Jbig2Stream = (function Jbig2StreamClosure() {
configurable: true,
});
Jbig2Stream.prototype.ensureBuffer = function(requested) {
Jbig2Stream.prototype.ensureBuffer = function (requested) {
// No-op, since `this.readBlock` will always parse the entire image and
// directly insert all of its data into `this.buffer`.
};
Jbig2Stream.prototype.readBlock = function() {
Jbig2Stream.prototype.readBlock = function () {
if (this.eof) {
return;
}

View file

@ -56,12 +56,12 @@ const JpegStream = (function JpegStreamClosure() {
configurable: true,
});
JpegStream.prototype.ensureBuffer = function(requested) {
JpegStream.prototype.ensureBuffer = function (requested) {
// No-op, since `this.readBlock` will always parse the entire image and
// directly insert all of its data into `this.buffer`.
};
JpegStream.prototype.readBlock = function() {
JpegStream.prototype.readBlock = function () {
if (this.eof) {
return;
}
@ -250,7 +250,7 @@ const JpegStream = (function JpegStreamClosure() {
configurable: true,
});
JpegStream.prototype.getIR = function(forceDataSchema = false) {
JpegStream.prototype.getIR = function (forceDataSchema = false) {
return createObjectURL(this.bytes, "image/jpeg", forceDataSchema);
};

View file

@ -42,12 +42,12 @@ const JpxStream = (function JpxStreamClosure() {
configurable: true,
});
JpxStream.prototype.ensureBuffer = function(requested) {
JpxStream.prototype.ensureBuffer = function (requested) {
// No-op, since `this.readBlock` will always parse the entire image and
// directly insert all of its data into `this.buffer`.
};
JpxStream.prototype.readBlock = function() {
JpxStream.prototype.readBlock = function () {
if (this.eof) {
return;
}

View file

@ -18,13 +18,13 @@ import { getLookupTableFactory } from "./core_utils.js";
// The Metrics object contains glyph widths (in glyph space units).
// As per PDF spec, for most fonts (Type 3 being an exception) a glyph
// space unit corresponds to 1/1000th of text space unit.
var getMetrics = getLookupTableFactory(function(t) {
var getMetrics = getLookupTableFactory(function (t) {
t["Courier"] = 600;
t["Courier-Bold"] = 600;
t["Courier-BoldOblique"] = 600;
t["Courier-Oblique"] = 600;
// eslint-disable-next-line no-shadow
t["Helvetica"] = getLookupTableFactory(function(t) {
t["Helvetica"] = getLookupTableFactory(function (t) {
t["space"] = 278;
t["exclam"] = 278;
t["quotedbl"] = 355;
@ -342,7 +342,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Helvetica-Bold"] = getLookupTableFactory(function(t) {
t["Helvetica-Bold"] = getLookupTableFactory(function (t) {
t["space"] = 278;
t["exclam"] = 333;
t["quotedbl"] = 474;
@ -660,7 +660,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Helvetica-BoldOblique"] = getLookupTableFactory(function(t) {
t["Helvetica-BoldOblique"] = getLookupTableFactory(function (t) {
t["space"] = 278;
t["exclam"] = 333;
t["quotedbl"] = 474;
@ -978,7 +978,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Helvetica-Oblique"] = getLookupTableFactory(function(t) {
t["Helvetica-Oblique"] = getLookupTableFactory(function (t) {
t["space"] = 278;
t["exclam"] = 278;
t["quotedbl"] = 355;
@ -1296,7 +1296,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 556;
});
// eslint-disable-next-line no-shadow
t["Symbol"] = getLookupTableFactory(function(t) {
t["Symbol"] = getLookupTableFactory(function (t) {
t["space"] = 250;
t["exclam"] = 333;
t["universal"] = 713;
@ -1489,7 +1489,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["apple"] = 790;
});
// eslint-disable-next-line no-shadow
t["Times-Roman"] = getLookupTableFactory(function(t) {
t["Times-Roman"] = getLookupTableFactory(function (t) {
t["space"] = 250;
t["exclam"] = 333;
t["quotedbl"] = 408;
@ -1807,7 +1807,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["Times-Bold"] = getLookupTableFactory(function(t) {
t["Times-Bold"] = getLookupTableFactory(function (t) {
t["space"] = 250;
t["exclam"] = 333;
t["quotedbl"] = 555;
@ -2125,7 +2125,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["Times-BoldItalic"] = getLookupTableFactory(function(t) {
t["Times-BoldItalic"] = getLookupTableFactory(function (t) {
t["space"] = 250;
t["exclam"] = 389;
t["quotedbl"] = 555;
@ -2443,7 +2443,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["Times-Italic"] = getLookupTableFactory(function(t) {
t["Times-Italic"] = getLookupTableFactory(function (t) {
t["space"] = 250;
t["exclam"] = 333;
t["quotedbl"] = 420;
@ -2761,7 +2761,7 @@ var getMetrics = getLookupTableFactory(function(t) {
t["Euro"] = 500;
});
// eslint-disable-next-line no-shadow
t["ZapfDingbats"] = getLookupTableFactory(function(t) {
t["ZapfDingbats"] = getLookupTableFactory(function (t) {
t["space"] = 278;
t["a1"] = 974;
t["a2"] = 961;

View file

@ -271,7 +271,7 @@ class Catalog {
dests[name] = fetchDestination(names[name]);
}
} else if (obj instanceof Dict) {
obj.forEach(function(key, value) {
obj.forEach(function (key, value) {
if (value) {
dests[key] = fetchDestination(value);
}
@ -693,7 +693,7 @@ class Catalog {
fontFallback(id, handler) {
const promises = [];
this.fontCache.forEach(function(promise) {
this.fontCache.forEach(function (promise) {
promises.push(promise);
});
@ -712,7 +712,7 @@ class Catalog {
this.pageKidsCountCache.clear();
const promises = [];
this.fontCache.forEach(function(promise) {
this.fontCache.forEach(function (promise) {
promises.push(promise);
});
@ -754,7 +754,7 @@ class Catalog {
}
visitedNodes.put(currentNode);
xref.fetchAsync(currentNode).then(function(obj) {
xref.fetchAsync(currentNode).then(function (obj) {
if (isDict(obj, "Page") || (isDict(obj) && !obj.has("Kids"))) {
if (pageIndex === currentPageIndex) {
// Cache the Page reference, since it can *greatly* improve
@ -849,7 +849,7 @@ class Catalog {
return xref
.fetchAsync(kidRef)
.then(function(node) {
.then(function (node) {
if (
isRefsEqual(kidRef, pageRef) &&
!isDict(node, "Page") &&
@ -868,7 +868,7 @@ class Catalog {
parentRef = node.getRaw("Parent");
return node.getAsync("Parent");
})
.then(function(parent) {
.then(function (parent) {
if (!parent) {
return null;
}
@ -877,7 +877,7 @@ class Catalog {
}
return parent.getAsync("Kids");
})
.then(function(kids) {
.then(function (kids) {
if (!kids) {
return null;
}
@ -894,7 +894,7 @@ class Catalog {
break;
}
kidPromises.push(
xref.fetchAsync(kid).then(function(obj) {
xref.fetchAsync(kid).then(function (obj) {
if (!isDict(obj)) {
throw new FormatError("Kid node must be a dictionary.");
}
@ -910,7 +910,7 @@ class Catalog {
if (!found) {
throw new FormatError("Kid reference not found in parent's kids.");
}
return Promise.all(kidPromises).then(function() {
return Promise.all(kidPromises).then(function () {
return [total, parentRef];
});
});
@ -918,7 +918,7 @@ class Catalog {
let total = 0;
function next(ref) {
return pagesBeforeRef(ref).then(function(args) {
return pagesBeforeRef(ref).then(function (args) {
if (!args) {
return total;
}
@ -1069,9 +1069,7 @@ class Catalog {
const URL_OPEN_METHODS = ["app.launchURL", "window.open"];
const regex = new RegExp(
"^\\s*(" +
URL_OPEN_METHODS.join("|")
.split(".")
.join("\\.") +
URL_OPEN_METHODS.join("|").split(".").join("\\.") +
")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))",
"i"
);
@ -2186,7 +2184,7 @@ var FileSpec = (function FileSpecClosure() {
* that have references to the catalog or other pages since that will cause the
* entire PDF document object graph to be traversed.
*/
const ObjectLoader = (function() {
const ObjectLoader = (function () {
function mayHaveChildren(value) {
return (
value instanceof Ref ||

View file

@ -304,7 +304,7 @@ var QueueOptimizer = (function QueueOptimizerClosure() {
addState(
InitialState,
[OPS.save, OPS.transform, OPS.paintImageXObject, OPS.restore],
function(context) {
function (context) {
var argsArray = context.argsArray;
var iFirstTransform = context.iCurr - 2;
return (
@ -351,7 +351,7 @@ var QueueOptimizer = (function QueueOptimizerClosure() {
}
throw new Error(`iterateImageGroup - invalid pos: ${pos}`);
},
function(context, i) {
function (context, i) {
var MIN_IMAGES_IN_BLOCK = 3;
var MAX_IMAGES_IN_BLOCK = 1000;
@ -436,7 +436,7 @@ var QueueOptimizer = (function QueueOptimizerClosure() {
}
throw new Error(`iterateShowTextGroup - invalid pos: ${pos}`);
},
function(context, i) {
function (context, i) {
var MIN_CHARS_IN_BLOCK = 3;
var MAX_CHARS_IN_BLOCK = 1000;

View file

@ -51,7 +51,7 @@ var Pattern = (function PatternClosure() {
},
};
Pattern.parseShading = function(
Pattern.parseShading = function (
shading,
matrix,
xref,

View file

@ -34,7 +34,7 @@ var Name = (function NameClosure() {
return nameValue ? nameValue : (nameCache[name] = new Name(name));
};
Name._clearCache = function() {
Name._clearCache = function () {
nameCache = Object.create(null);
};
@ -57,7 +57,7 @@ var Cmd = (function CmdClosure() {
return cmdValue ? cmdValue : (cmdCache[cmd] = new Cmd(cmd));
};
Cmd._clearCache = function() {
Cmd._clearCache = function () {
cmdCache = Object.create(null);
};
@ -164,7 +164,7 @@ var Dict = (function DictClosure() {
Dict.empty = new Dict(null);
Dict.merge = function(xref, dictArray) {
Dict.merge = function (xref, dictArray) {
const mergedDict = new Dict(xref);
for (let i = 0, ii = dictArray.length; i < ii; i++) {
@ -205,14 +205,14 @@ var Ref = (function RefClosure() {
},
};
Ref.get = function(num, gen) {
Ref.get = function (num, gen) {
const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
const refValue = refCache[key];
// eslint-disable-next-line no-restricted-syntax
return refValue ? refValue : (refCache[key] = new Ref(num, gen));
};
Ref._clearCache = function() {
Ref._clearCache = function () {
refCache = Object.create(null);
};

View file

@ -20,7 +20,7 @@ import { getLookupTableFactory } from "./core_utils.js";
* Hold a map of decoded fonts and of the standard fourteen Type1
* fonts and their acronyms.
*/
const getStdFontMap = getLookupTableFactory(function(t) {
const getStdFontMap = getLookupTableFactory(function (t) {
t["ArialNarrow"] = "Helvetica";
t["ArialNarrow-Bold"] = "Helvetica-Bold";
t["ArialNarrow-BoldItalic"] = "Helvetica-BoldOblique";
@ -82,7 +82,7 @@ const getStdFontMap = getLookupTableFactory(function(t) {
* Holds the map of the non-standard fonts that might be included as
* a standard fonts without glyph data.
*/
const getNonStdFontMap = getLookupTableFactory(function(t) {
const getNonStdFontMap = getLookupTableFactory(function (t) {
t["Calibri"] = "Helvetica";
t["Calibri-Bold"] = "Helvetica-Bold";
t["Calibri-BoldItalic"] = "Helvetica-BoldOblique";
@ -122,7 +122,7 @@ const getNonStdFontMap = getLookupTableFactory(function(t) {
t["Wingdings-Regular"] = "ZapfDingbats";
});
const getSerifFonts = getLookupTableFactory(function(t) {
const getSerifFonts = getLookupTableFactory(function (t) {
t["Adobe Jenson"] = true;
t["Adobe Text"] = true;
t["Albertus"] = true;
@ -258,7 +258,7 @@ const getSerifFonts = getLookupTableFactory(function(t) {
t["XITS"] = true;
});
const getSymbolsFonts = getLookupTableFactory(function(t) {
const getSymbolsFonts = getLookupTableFactory(function (t) {
t["Dingbats"] = true;
t["Symbol"] = true;
t["ZapfDingbats"] = true;
@ -267,7 +267,7 @@ const getSymbolsFonts = getLookupTableFactory(function(t) {
// Glyph map for well-known standard fonts. Sometimes Ghostscript uses CID
// fonts, but does not embed the CID to GID mapping. The mapping is incomplete
// for all glyphs, but common for some set of the standard fonts.
const getGlyphMapForStandardFonts = getLookupTableFactory(function(t) {
const getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
t[2] = 10;
t[3] = 32;
t[4] = 33;
@ -666,7 +666,9 @@ const getGlyphMapForStandardFonts = getLookupTableFactory(function(t) {
// The glyph map for ArialBlack differs slightly from the glyph map used for
// other well-known standard fonts. Hence we use this (incomplete) CID to GID
// mapping to adjust the glyph map for non-embedded ArialBlack fonts.
const getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function(t) {
const getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (
t
) {
t[227] = 322;
t[264] = 261;
t[291] = 346;
@ -675,7 +677,7 @@ const getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function(t) {
// The glyph map for Calibri (a Windows font) differs from the glyph map used
// in the standard fonts. Hence we use this (incomplete) CID to GID mapping to
// adjust the glyph map for non-embedded Calibri fonts.
const getSupplementalGlyphMapForCalibri = getLookupTableFactory(function(t) {
const getSupplementalGlyphMapForCalibri = getLookupTableFactory(function (t) {
t[1] = 32;
t[4] = 65;
t[17] = 66;

View file

@ -19,7 +19,7 @@ var getLookupTableFactory = require("./core_utils.js").getLookupTableFactory;
// Some characters, e.g. copyrightserif, are mapped to the private use area
// and might not be displayed using standard fonts. Mapping/hacking well-known
// chars to the similar equivalents in the normal characters range.
var getSpecialPUASymbols = getLookupTableFactory(function(t) {
var getSpecialPUASymbols = getLookupTableFactory(function (t) {
t[63721] = 0x00a9; // copyrightsans (0xF8E9) => copyright
t[63193] = 0x00a9; // copyrightserif (0xF6D9) => copyright
t[63720] = 0x00ae; // registersans (0xF8E8) => registered
@ -241,7 +241,7 @@ function isRTLRangeFor(value) {
// The normalization table is obtained by filtering the Unicode characters
// database with <compat> entries.
var getNormalizedUnicodes = getLookupTableFactory(function(t) {
var getNormalizedUnicodes = getLookupTableFactory(function (t) {
t["\u00A8"] = "\u0020\u0308";
t["\u00AF"] = "\u0020\u0304";
t["\u00B4"] = "\u0020\u0301";

View file

@ -230,7 +230,7 @@ var WorkerMessageHandler = {
var fullRequest = pdfStream.getFullReader();
fullRequest.headersReady
.then(function() {
.then(function () {
if (!fullRequest.isRangeSupported) {
return;
}
@ -262,13 +262,13 @@ var WorkerMessageHandler = {
pdfManagerCapability.resolve(newPdfManager);
cancelXHRs = null;
})
.catch(function(reason) {
.catch(function (reason) {
pdfManagerCapability.reject(reason);
cancelXHRs = null;
});
var loaded = 0;
var flushChunks = function() {
var flushChunks = function () {
var pdfFile = arraysToBytes(cachedChunks);
if (source.length && pdfFile.length !== source.length) {
warn("reported HTTP length is different from actual");
@ -288,8 +288,8 @@ var WorkerMessageHandler = {
}
cachedChunks = [];
};
var readPromise = new Promise(function(resolve, reject) {
var readChunk = function({ value, done }) {
var readPromise = new Promise(function (resolve, reject) {
var readChunk = function ({ value, done }) {
try {
ensureNotTerminated();
if (done) {
@ -321,12 +321,12 @@ var WorkerMessageHandler = {
};
fullRequest.read().then(readChunk, reject);
});
readPromise.catch(function(e) {
readPromise.catch(function (e) {
pdfManagerCapability.reject(e);
cancelXHRs = null;
});
cancelXHRs = function(reason) {
cancelXHRs = function (reason) {
pdfStream.cancelAllRequests(reason);
};
@ -348,12 +348,12 @@ var WorkerMessageHandler = {
handler
.sendWithPromise("PasswordRequest", ex)
.then(function({ password }) {
.then(function ({ password }) {
finishWorkerTask(task);
pdfManager.updatePassword(password);
pdfManagerReady();
})
.catch(function() {
.catch(function () {
finishWorkerTask(task);
handler.send("DocException", ex);
});
@ -386,7 +386,7 @@ var WorkerMessageHandler = {
return;
}
pdfManager.requestLoadedStream();
pdfManager.onLoadedStream().then(function() {
pdfManager.onLoadedStream().then(function () {
ensureNotTerminated();
loadDocument(true).then(onSuccess, onFailure);
@ -409,7 +409,7 @@ var WorkerMessageHandler = {
};
getPdfManager(data, evaluatorOptions)
.then(function(newPdfManager) {
.then(function (newPdfManager) {
if (terminated) {
// We were in a process of setting up the manager, but it got
// terminated in the middle.
@ -420,7 +420,7 @@ var WorkerMessageHandler = {
}
pdfManager = newPdfManager;
pdfManager.onLoadedStream().then(function(stream) {
pdfManager.onLoadedStream().then(function (stream) {
handler.send("DataLoaded", { length: stream.bytes.byteLength });
});
})
@ -428,13 +428,13 @@ var WorkerMessageHandler = {
}
handler.on("GetPage", function wphSetupGetPage(data) {
return pdfManager.getPage(data.pageIndex).then(function(page) {
return pdfManager.getPage(data.pageIndex).then(function (page) {
return Promise.all([
pdfManager.ensure(page, "rotate"),
pdfManager.ensure(page, "ref"),
pdfManager.ensure(page, "userUnit"),
pdfManager.ensure(page, "view"),
]).then(function([rotate, ref, userUnit, view]) {
]).then(function ([rotate, ref, userUnit, view]) {
return {
rotate,
ref,
@ -471,11 +471,11 @@ var WorkerMessageHandler = {
return pdfManager.ensureCatalog("pageMode");
});
handler.on("GetViewerPreferences", function(data) {
handler.on("GetViewerPreferences", function (data) {
return pdfManager.ensureCatalog("viewerPreferences");
});
handler.on("GetOpenAction", function(data) {
handler.on("GetOpenAction", function (data) {
return pdfManager.ensureCatalog("openAction");
});
@ -491,7 +491,7 @@ var WorkerMessageHandler = {
return pdfManager.ensureCatalog("documentOutline");
});
handler.on("GetPermissions", function(data) {
handler.on("GetPermissions", function (data) {
return pdfManager.ensureCatalog("permissions");
});
@ -504,7 +504,7 @@ var WorkerMessageHandler = {
handler.on("GetData", function wphSetupGetData(data) {
pdfManager.requestLoadedStream();
return pdfManager.onLoadedStream().then(function(stream) {
return pdfManager.onLoadedStream().then(function (stream) {
return stream.bytes;
});
});
@ -513,8 +513,8 @@ var WorkerMessageHandler = {
return pdfManager.pdfDocument.xref.stats;
});
handler.on("GetAnnotations", function({ pageIndex, intent }) {
return pdfManager.getPage(pageIndex).then(function(page) {
handler.on("GetAnnotations", function ({ pageIndex, intent }) {
return pdfManager.getPage(pageIndex).then(function (page) {
return page.getAnnotationsData(intent);
});
});
@ -523,7 +523,7 @@ var WorkerMessageHandler = {
"GetOperatorList",
function wphSetupRenderPage(data, sink) {
var pageIndex = data.pageIndex;
pdfManager.getPage(pageIndex).then(function(page) {
pdfManager.getPage(pageIndex).then(function (page) {
var task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
startWorkerTask(task);
@ -540,7 +540,7 @@ var WorkerMessageHandler = {
renderInteractiveForms: data.renderInteractiveForms,
})
.then(
function(operatorListInfo) {
function (operatorListInfo) {
finishWorkerTask(task);
if (start) {
@ -551,7 +551,7 @@ var WorkerMessageHandler = {
}
sink.close();
},
function(reason) {
function (reason) {
finishWorkerTask(task);
if (task.terminated) {
return; // ignoring errors from the terminated thread
@ -576,10 +576,10 @@ var WorkerMessageHandler = {
handler.on("GetTextContent", function wphExtractText(data, sink) {
var pageIndex = data.pageIndex;
sink.onPull = function(desiredSize) {};
sink.onCancel = function(reason) {};
sink.onPull = function (desiredSize) {};
sink.onCancel = function (reason) {};
pdfManager.getPage(pageIndex).then(function(page) {
pdfManager.getPage(pageIndex).then(function (page) {
var task = new WorkerTask("GetTextContent: page " + pageIndex);
startWorkerTask(task);
@ -595,7 +595,7 @@ var WorkerMessageHandler = {
combineTextItems: data.combineTextItems,
})
.then(
function() {
function () {
finishWorkerTask(task);
if (start) {
@ -606,7 +606,7 @@ var WorkerMessageHandler = {
}
sink.close();
},
function(reason) {
function (reason) {
finishWorkerTask(task);
if (task.terminated) {
return; // ignoring errors from the terminated thread
@ -620,7 +620,7 @@ var WorkerMessageHandler = {
});
});
handler.on("FontFallback", function(data) {
handler.on("FontFallback", function (data) {
return pdfManager.fontFallback(data.id, handler);
});
@ -646,12 +646,12 @@ var WorkerMessageHandler = {
cancelXHRs(new AbortException("Worker was terminated."));
}
WorkerTasks.forEach(function(task) {
WorkerTasks.forEach(function (task) {
waitOn.push(task.finished);
task.terminate();
});
return Promise.all(waitOn).then(function() {
return Promise.all(waitOn).then(function () {
// Notice that even if we destroying handler, resolved response promise
// must be sent back.
handler.destroy();

View file

@ -42,7 +42,7 @@ class PDFWorkerStream {
this._fullRequestReader.cancel(reason);
}
const readers = this._rangeRequestReaders.slice(0);
readers.forEach(function(reader) {
readers.forEach(function (reader) {
reader.cancel(reason);
});
}

View file

@ -309,12 +309,12 @@ function getDocument(src) {
}
const docId = task.docId;
worker.promise
.then(function() {
.then(function () {
if (task.destroyed) {
throw new Error("Loading aborted");
}
return _fetchDocument(worker, params, rangeTransport, docId).then(
function(workerId) {
function (workerId) {
if (task.destroyed) {
throw new Error("Loading aborted");
}
@ -411,7 +411,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
isEvalSupported: source.isEvalSupported,
fontExtraProperties: source.fontExtraProperties,
})
.then(function(workerId) {
.then(function (workerId) {
if (worker.destroyed) {
throw new Error("Worker was destroyed");
}
@ -679,7 +679,7 @@ class PDFDocumentProxy {
getOpenActionDestination() {
deprecated("getOpenActionDestination, use getOpenAction instead.");
return this.getOpenAction().then(function(openAction) {
return this.getOpenAction().then(function (openAction) {
return openAction && openAction.dest ? openAction.dest : null;
});
}
@ -1214,9 +1214,9 @@ class PDFPageProxy {
getTextContent(params = {}) {
const readableStream = this.streamTextContent(params);
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
function pump() {
reader.read().then(function({ value, done }) {
reader.read().then(function ({ value, done }) {
if (done) {
resolve(textContent);
return;
@ -1257,9 +1257,9 @@ class PDFPageProxy {
// Avoid errors below, since the renderTasks are just stubs.
return;
}
intentState.renderTasks.forEach(function(renderTask) {
intentState.renderTasks.forEach(function (renderTask) {
const renderCompleted = renderTask.capability.promise.catch(
function() {}
function () {}
); // ignoring failures
waitOn.push(renderCompleted);
renderTask.cancel();
@ -1629,7 +1629,7 @@ const PDFWorker = (function PDFWorkerClosure() {
}
fakeWorkerCapability = createPromiseCapability();
const loader = async function() {
const loader = async function () {
const mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
if (mainWorkerMessageHandler) {
@ -1734,7 +1734,7 @@ const PDFWorker = (function PDFWorkerClosure() {
_initializeFromPort(port) {
this._port = port;
this._messageHandler = new MessageHandler("main", "worker", port);
this._messageHandler.on("ready", function() {
this._messageHandler.on("ready", function () {
// Ignoring 'ready' event -- MessageHandler shall be already initialized
// and ready to accept the messages.
});
@ -1991,7 +1991,7 @@ class WorkerTransport {
const waitOn = [];
// We need to wait for all renderings to be completed, e.g.
// timeout/rAF can take a long time.
this.pageCache.forEach(function(page) {
this.pageCache.forEach(function (page) {
if (page) {
waitOn.push(page._destroy());
}
@ -2033,7 +2033,7 @@ class WorkerTransport {
sink.onPull = () => {
this._fullReader
.read()
.then(function({ value, done }) {
.then(function ({ value, done }) {
if (done) {
sink.close();
return;
@ -2108,7 +2108,7 @@ class WorkerTransport {
sink.onPull = () => {
rangeReader
.read()
.then(function({ value, done }) {
.then(function ({ value, done }) {
if (done) {
sink.close();
return;
@ -2131,7 +2131,7 @@ class WorkerTransport {
loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
});
messageHandler.on("DocException", function(ex) {
messageHandler.on("DocException", function (ex) {
let reason;
switch (ex.name) {
case "PasswordException":
@ -2283,10 +2283,10 @@ class WorkerTransport {
case "JpegStream":
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = function() {
img.onload = function () {
resolve(img);
};
img.onerror = function() {
img.onerror = function () {
// Note that when the browser image loading/decoding fails,
// we'll fallback to the built-in PDF.js JPEG decoder; see
// `PartialEvaluator.buildPaintImageXObject` in the
@ -2354,9 +2354,9 @@ class WorkerTransport {
);
}
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
const img = new Image();
img.onload = function() {
img.onload = function () {
const { width, height } = img;
const size = width * height;
const rgbaLength = size * 4;
@ -2390,7 +2390,7 @@ class WorkerTransport {
tmpCanvas = null;
tmpCtx = null;
};
img.onerror = function() {
img.onerror = function () {
reject(new Error("JpegDecode failed to load image"));
// Always remember to release the image data if errors occurred.
@ -2415,10 +2415,10 @@ class WorkerTransport {
fetched = true;
this.CMapReaderFactory.fetch(data)
.then(function(builtInCMap) {
.then(function (builtInCMap) {
sink.enqueue(builtInCMap, 1, [builtInCMap.cMapData.buffer]);
})
.catch(function(reason) {
.catch(function (reason) {
sink.error(reason);
});
};
@ -2477,7 +2477,7 @@ class WorkerTransport {
.sendWithPromise("GetPageIndex", {
ref,
})
.catch(function(reason) {
.catch(function (reason) {
return Promise.reject(new Error(reason));
});
}
@ -2856,9 +2856,7 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
this._nextBound().catch(this.cancel.bind(this));
});
} else {
Promise.resolve()
.then(this._nextBound)
.catch(this.cancel.bind(this));
Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this));
}
}

View file

@ -362,7 +362,7 @@ function compileType3Glyph(imgData) {
--i;
}
var drawOutline = function(c) {
var drawOutline = function (c) {
c.save();
// the path shall be painted in [0..1]x[0..1] space
c.scale(1 / width, -1 / height);

View file

@ -85,7 +85,7 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
}
try {
const decoder = new TextDecoder(encoding, { fatal: true });
const bytes = Array.from(value, function(ch) {
const bytes = Array.from(value, function (ch) {
return ch.charCodeAt(0) & 0xff;
});
value = decoder.decode(new Uint8Array(bytes));
@ -205,11 +205,11 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
// ... but Firefox permits ? and space.
return value.replace(
/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,
function(matches, charset, encoding, text) {
function (matches, charset, encoding, text) {
if (encoding === "q" || encoding === "Q") {
// RFC 2047 section 4.2.
text = text.replace(/_/g, " ");
text = text.replace(/=([0-9a-fA-F]{2})/g, function(match, hex) {
text = text.replace(/=([0-9a-fA-F]{2})/g, function (match, hex) {
return String.fromCharCode(parseInt(hex, 16));
});
return textdecode(charset, text);

View file

@ -502,7 +502,7 @@ function loadScript(src) {
script.src = src;
script.onload = resolve;
script.onerror = function() {
script.onerror = function () {
reject(new Error(`Cannot load script at: ${script.src}`));
};
(document.head || document.documentElement).appendChild(script);

View file

@ -84,7 +84,7 @@ class PDFFetchStream {
this._fullRequestReader.cancel(reason);
}
const readers = this._rangeRequestReaders.slice(0);
readers.forEach(function(reader) {
readers.forEach(function (reader) {
reader.cancel(reason);
});
}

View file

@ -56,7 +56,7 @@ class BaseFontLoader {
}
clear() {
this.nativeFontFaces.forEach(function(nativeFontFace) {
this.nativeFontFaces.forEach(function (nativeFontFace) {
document.fonts.delete(nativeFontFace);
});
this.nativeFontFaces.length = 0;
@ -198,7 +198,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
}
get _loadTestFont() {
const getLoadTestFont = function() {
const getLoadTestFont = function () {
// This is a CFF font with 1 glyph for '.' that fills its entire width
// and height.
return atob(
@ -328,7 +328,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
}
document.body.appendChild(div);
isFontReady(loadTestFontId, function() {
isFontReady(loadTestFontId, function () {
document.body.removeChild(div);
request.complete();
});
@ -404,7 +404,7 @@ class FontFaceObject {
}
warn(`getPathGenerator - ignoring character: "${ex}".`);
return (this.compiledGlyphs[character] = function(c, size) {
return (this.compiledGlyphs[character] = function (c, size) {
// No-op function, to allow rendering to continue.
});
}
@ -428,7 +428,7 @@ class FontFaceObject {
}
// ... but fall back on using Function.prototype.apply() if we're
// blocked from using eval() for whatever reason (like CSP policies).
return (this.compiledGlyphs[character] = function(c, size) {
return (this.compiledGlyphs[character] = function (c, size) {
for (let i = 0, ii = cmds.length; i < ii; i++) {
current = cmds[i];

View file

@ -38,12 +38,12 @@ class Metadata {
// Start by removing any "junk" before the first tag (see issue 10395).
return data
.replace(/^[^<]+/, "")
.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
.replace(/>\\376\\377([^<]+)/g, function (all, 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);
})
.replace(/&(amp|apos|gt|lt|quot);/g, function(str, name) {
.replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
switch (name) {
case "amp":
return "&";

View file

@ -100,7 +100,7 @@ class NetworkManager {
xhr.responseType = "arraybuffer";
if (args.onError) {
xhr.onerror = function(evt) {
xhr.onerror = function (evt) {
args.onError(xhr.status);
};
}
@ -271,7 +271,7 @@ class PDFNetworkStream {
this._fullRequestReader.cancel(reason);
}
const readers = this._rangeRequestReaders.slice(0);
readers.forEach(function(reader) {
readers.forEach(function (reader) {
reader.cancel(reason);
});
}
@ -359,7 +359,7 @@ class PDFNetworkStreamFullRequestReader {
if (this._cachedChunks.length > 0) {
return;
}
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({ value: undefined, done: true });
});
this._requests = [];
@ -370,7 +370,7 @@ class PDFNetworkStreamFullRequestReader {
const exception = createResponseStatusError(status, url);
this._storedError = exception;
this._headersReceivedCapability.reject(exception);
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.reject(exception);
});
this._requests = [];
@ -425,7 +425,7 @@ class PDFNetworkStreamFullRequestReader {
cancel(reason) {
this._done = true;
this._headersReceivedCapability.reject(reason);
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({ value: undefined, done: true });
});
this._requests = [];
@ -468,7 +468,7 @@ class PDFNetworkStreamRangeRequestReader {
this._queuedChunk = chunk;
}
this._done = true;
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({ value: undefined, done: true });
});
this._requests = [];
@ -503,7 +503,7 @@ class PDFNetworkStreamRangeRequestReader {
cancel(reason) {
this._done = true;
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({ value: undefined, done: true });
});
this._requests = [];

View file

@ -91,7 +91,7 @@ class PDFNodeStream {
}
const readers = this._rangeRequestReaders.slice(0);
readers.forEach(function(reader) {
readers.forEach(function (reader) {
reader.cancel(reason);
});
}

View file

@ -29,7 +29,7 @@ import {
import { DOMSVGFactory } from "./display_utils.js";
import { isNodeJS } from "../shared/is_node.js";
let SVGGraphics = function() {
let SVGGraphics = function () {
throw new Error("Not implemented: SVGGraphics");
};
@ -44,7 +44,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const LINE_CAP_STYLES = ["butt", "round", "square"];
const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
const convertImgDataToPng = (function() {
const convertImgDataToPng = (function () {
const PNG_HEADER = new Uint8Array([
0x89,
0x50,
@ -1327,7 +1327,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
// The previous clipping group content can go out of order -- resetting
// cached clipGroups.
current.clipGroup = null;
this.extraStack.forEach(function(prev) {
this.extraStack.forEach(function (prev) {
prev.clipGroup = null;
});
// Intersect with the previous clipping path.
@ -1439,7 +1439,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const current = this.current;
let dashArray = current.dashArray;
if (lineWidthScale !== 1 && dashArray.length > 0) {
dashArray = dashArray.map(function(value) {
dashArray = dashArray.map(function (value) {
return lineWidthScale * value;
});
}

View file

@ -234,7 +234,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
// Finding intersections with expanded box.
var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
var ts = new Float64Array(64);
points.forEach(function(p, j) {
points.forEach(function (p, j) {
var t = Util.applyTransform(p, m);
ts[j + 0] = c && (e.left - t[0]) / c;
ts[j + 4] = s && (e.top - t[1]) / s;
@ -268,7 +268,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
}
function expandBounds(width, height, boxes) {
var bounds = boxes.map(function(box, i) {
var bounds = boxes.map(function (box, i) {
return {
x1: box.left,
y1: box.top,
@ -281,7 +281,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
});
expandBoundsLTR(width, bounds);
var expanded = new Array(boxes.length);
bounds.forEach(function(b) {
bounds.forEach(function (b) {
var i = b.index;
expanded[i] = {
left: b.x1New,
@ -293,7 +293,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
// Rotating on 90 degrees and extending extended boxes. Reusing the bounds
// array and objects.
boxes.map(function(box, i) {
boxes.map(function (box, i) {
var e = expanded[i],
b = bounds[i];
b.x1 = box.top;
@ -306,7 +306,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
});
expandBoundsLTR(height, bounds);
bounds.forEach(function(b) {
bounds.forEach(function (b) {
var i = b.index;
expanded[i].top = b.x1New;
expanded[i].bottom = b.x2New;
@ -316,7 +316,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
function expandBoundsLTR(width, bounds) {
// Sorting by x1 coordinate and walk by the bounds in the same order.
bounds.sort(function(a, b) {
bounds.sort(function (a, b) {
return a.x1 - b.x1 || a.index - b.index;
});
@ -338,7 +338,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
},
];
bounds.forEach(function(boundary) {
bounds.forEach(function (boundary) {
// Searching for the affected part of horizon.
// TODO red-black tree or simple binary search
var i = 0;
@ -480,7 +480,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
});
// Set new x2 for all unset boundaries.
horizon.forEach(function(horizonPart) {
horizon.forEach(function (horizonPart) {
var affectedBoundary = horizonPart.boundary;
if (affectedBoundary.x2New === undefined) {
affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);

View file

@ -66,7 +66,7 @@ class PDFDataTransportStream {
this._queuedChunks.push(buffer);
}
} else {
const found = this._rangeReaders.some(function(rangeReader) {
const found = this._rangeReaders.some(function (rangeReader) {
if (rangeReader._begin !== args.begin) {
return false;
}
@ -136,7 +136,7 @@ class PDFDataTransportStream {
this._fullRequestReader.cancel(reason);
}
const readers = this._rangeReaders.slice(0);
readers.forEach(function(rangeReader) {
readers.forEach(function (rangeReader) {
rangeReader.cancel(reason);
});
this._pdfDataRangeTransport.abort();
@ -209,7 +209,7 @@ class PDFDataTransportStreamReader {
cancel(reason) {
this._done = true;
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({ value: undefined, done: true });
});
this._requests = [];
@ -245,7 +245,7 @@ class PDFDataTransportStreamRangeReader {
} else {
const requestsCapability = this._requests.shift();
requestsCapability.resolve({ value: chunk, done: false });
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({ value: undefined, done: true });
});
this._requests = [];
@ -274,7 +274,7 @@ class PDFDataTransportStreamRangeReader {
cancel(reason) {
this._done = true;
this._requests.forEach(function(requestCapability) {
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({ value: undefined, done: true });
});
this._requests = [];

View file

@ -317,7 +317,7 @@ class SimpleDOMNode {
return this.nodeValue || "";
}
return this.childNodes
.map(function(child) {
.map(function (child) {
return child.textContent;
})
.join("");

View file

@ -56,7 +56,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
} else if (PDFJSDev.test("CHROME")) {
const PDFNetworkStream = require("./display/network.js").PDFNetworkStream;
let PDFFetchStream;
const isChromeWithFetchCredentials = function() {
const isChromeWithFetchCredentials = function () {
// fetch does not include credentials until Chrome 61.0.3138.0 and later.
// https://chromium.googlesource.com/chromium/src/+/2e231cf052ca5e68e22baf0008ac9e5e29121707
try {

View file

@ -39,7 +39,7 @@ if (
if (globalThis.btoa || !isNodeJS) {
return;
}
globalThis.btoa = function(chars) {
globalThis.btoa = function (chars) {
// eslint-disable-next-line no-undef
return Buffer.from(chars, "binary").toString("base64");
};
@ -50,7 +50,7 @@ if (
if (globalThis.atob || !isNodeJS) {
return;
}
globalThis.atob = function(input) {
globalThis.atob = function (input) {
// eslint-disable-next-line no-undef
return Buffer.from(input, "base64").toString("binary");
};
@ -65,7 +65,7 @@ if (
if (typeof Element.prototype.remove !== "undefined") {
return;
}
Element.prototype.remove = function() {
Element.prototype.remove = function () {
if (this.parentNode) {
// eslint-disable-next-line mozilla/avoid-removeChild
this.parentNode.removeChild(this);
@ -92,12 +92,12 @@ if (
const OriginalDOMTokenListAdd = DOMTokenList.prototype.add;
const OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
DOMTokenList.prototype.add = function(...tokens) {
DOMTokenList.prototype.add = function (...tokens) {
for (const token of tokens) {
OriginalDOMTokenListAdd.call(this, token);
}
};
DOMTokenList.prototype.remove = function(...tokens) {
DOMTokenList.prototype.remove = function (...tokens) {
for (const token of tokens) {
OriginalDOMTokenListRemove.call(this, token);
}
@ -116,7 +116,7 @@ if (
return;
}
DOMTokenList.prototype.toggle = function(token) {
DOMTokenList.prototype.toggle = function (token) {
const force =
arguments.length > 1 ? !!arguments[1] : !this.contains(token);
return this[force ? "add" : "remove"](token), force;
@ -133,11 +133,11 @@ if (
const OriginalPushState = window.history.pushState;
const OriginalReplaceState = window.history.replaceState;
window.history.pushState = function(state, title, url) {
window.history.pushState = function (state, title, url) {
const args = url === undefined ? [state, title] : [state, title, url];
OriginalPushState.apply(this, args);
};
window.history.replaceState = function(state, title, url) {
window.history.replaceState = function (state, title, url) {
const args = url === undefined ? [state, title] : [state, title, url];
OriginalReplaceState.apply(this, args);
};

View file

@ -116,10 +116,10 @@ class MessageHandler {
if (data.callbackId) {
const cbSourceName = this.sourceName;
const cbTargetName = data.sourceName;
new Promise(function(resolve) {
new Promise(function (resolve) {
resolve(action(data.data));
}).then(
function(result) {
function (result) {
comObj.postMessage({
sourceName: cbSourceName,
targetName: cbTargetName,
@ -128,7 +128,7 @@ class MessageHandler {
data: result,
});
},
function(reason) {
function (reason) {
comObj.postMessage({
sourceName: cbSourceName,
targetName: cbTargetName,
@ -367,10 +367,10 @@ class MessageHandler {
streamSink.sinkCapability.resolve();
streamSink.ready = streamSink.sinkCapability.promise;
this.streamSinks[streamId] = streamSink;
new Promise(function(resolve) {
new Promise(function (resolve) {
resolve(action(data.data, streamSink));
}).then(
function() {
function () {
comObj.postMessage({
sourceName,
targetName,
@ -379,7 +379,7 @@ class MessageHandler {
success: true,
});
},
function(reason) {
function (reason) {
comObj.postMessage({
sourceName,
targetName,
@ -443,10 +443,10 @@ class MessageHandler {
// Reset desiredSize property of sink on every pull.
this.streamSinks[streamId].desiredSize = data.desiredSize;
const { onPull } = this.streamSinks[data.streamId];
new Promise(function(resolve) {
new Promise(function (resolve) {
resolve(onPull && onPull());
}).then(
function() {
function () {
comObj.postMessage({
sourceName,
targetName,
@ -455,7 +455,7 @@ class MessageHandler {
success: true,
});
},
function(reason) {
function (reason) {
comObj.postMessage({
sourceName,
targetName,
@ -513,10 +513,10 @@ class MessageHandler {
break;
}
const { onCancel } = this.streamSinks[data.streamId];
new Promise(function(resolve) {
new Promise(function (resolve) {
resolve(onCancel && onCancel(wrapReason(data.reason)));
}).then(
function() {
function () {
comObj.postMessage({
sourceName,
targetName,
@ -525,7 +525,7 @@ class MessageHandler {
success: true,
});
},
function(reason) {
function (reason) {
comObj.postMessage({
sourceName,
targetName,
@ -557,7 +557,7 @@ class MessageHandler {
this.streamControllers[streamId].startCall,
this.streamControllers[streamId].pullCall,
this.streamControllers[streamId].cancelCall,
].map(function(capability) {
].map(function (capability) {
return capability && capability.promise;
})
);

View file

@ -812,7 +812,7 @@ function isArrayEqual(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
return arr1.every(function(element, index) {
return arr1.every(function (element, index) {
return element === arr2[index];
});
}
@ -842,12 +842,12 @@ function createPromiseCapability() {
return isSettled;
},
});
capability.promise = new Promise(function(resolve, reject) {
capability.resolve = function(data) {
capability.promise = new Promise(function (resolve, reject) {
capability.resolve = function (data) {
isSettled = true;
resolve(data);
};
capability.reject = function(reason) {
capability.reject = function (reason) {
isSettled = true;
reject(reason);
};

View file

@ -17,9 +17,9 @@
// Patch importScripts to work around a bug in WebKit and Chrome 48-.
// See https://crbug.com/572225 and https://webkit.org/b/153317.
self.importScripts = (function(importScripts) {
return function() {
setTimeout(function() {}, 0);
self.importScripts = (function (importScripts) {
return function () {
setTimeout(function () {}, 0);
return importScripts.apply(this, arguments);
};
})(importScripts);
@ -27,6 +27,6 @@ self.importScripts = (function(importScripts) {
importScripts("../node_modules/systemjs/dist/system.js");
importScripts("../systemjs.config.js");
SystemJS.import("pdfjs/core/worker.js").then(function() {
SystemJS.import("pdfjs/core/worker.js").then(function () {
// Worker is loaded at this point.
});