1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +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);
});
}