Skip to content

Commit be979f2

Browse files
committed
Account for formatting changes in Prettier version 2.3.0
With the exception of one tweaked `eslint-disable` comment, in `web/generic_scripting.js`, this patch was generated automatically using `gulp lint --fix`. Please find additional information at: - https://github.com/prettier/prettier/releases/tag/2.3.0 - https://prettier.io/blog/2021/05/09/2.3.0.html
1 parent 0c2c97a commit be979f2

28 files changed

+127
-192
lines changed

external/builder/builder.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ function preprocess(inFilename, outFilename, defines) {
122122
let line;
123123
let state = STATE_NONE;
124124
const stack = [];
125-
const control = /^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/;
125+
const control =
126+
/^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/;
126127

127128
while ((line = readLine()) !== null) {
128129
++lineNumber;

external/cmapscompress/parse.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ exports.parseAdobeCMap = function (content) {
3636
if (m) {
3737
result.usecmap = m[1];
3838
}
39-
const re = /(\d+)\s+(begincodespacerange|beginnotdefrange|begincidchar|begincidrange|beginbfchar|beginbfrange)\n([\s\S]*?)\n(endcodespacerange|endnotdefrange|endcidchar|endcidrange|endbfchar|endbfrange)/g;
39+
const re =
40+
/(\d+)\s+(begincodespacerange|beginnotdefrange|begincidchar|begincidrange|beginbfchar|beginbfrange)\n([\s\S]*?)\n(endcodespacerange|endnotdefrange|endcidchar|endcidrange|endbfchar|endbfrange)/g;
4041
while ((m = re.exec(body))) {
4142
const lines = m[3].toLowerCase().split("\n");
4243

gulpfile.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ gulp.task("cmaps", function (done) {
756756
}
757757
});
758758

759-
const compressCmaps = require("./external/cmapscompress/compress.js")
760-
.compressCmaps;
759+
const compressCmaps =
760+
require("./external/cmapscompress/compress.js").compressCmaps;
761761
compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
762762
done();
763763
});
@@ -1415,7 +1415,8 @@ function buildLibHelper(bundleDefines, inputStream, outputDir) {
14151415
babelPluginReplaceNonWebPackRequire,
14161416
],
14171417
}).code;
1418-
const removeCjsSrc = /^(var\s+\w+\s*=\s*(_interopRequireDefault\()?require\(".*?)(?:\/src)(\/[^"]*"\)\)?;)$/gm;
1418+
const removeCjsSrc =
1419+
/^(var\s+\w+\s*=\s*(_interopRequireDefault\()?require\(".*?)(?:\/src)(\/[^"]*"\)\)?;)$/gm;
14191420
content = content.replace(removeCjsSrc, (all, prefix, interop, suffix) => {
14201421
return prefix + suffix;
14211422
});
@@ -2176,9 +2177,8 @@ gulp.task(
21762177
let reason = process.env.PDFJS_UPDATE_REASON;
21772178
// Attempt to work-around the broken link, see https://github.com/mozilla/pdf.js/issues/10391
21782179
if (typeof reason === "string") {
2179-
const reasonParts = /^(See )(mozilla\/pdf\.js)@tags\/(v\d+\.\d+\.\d+)\s*$/.exec(
2180-
reason
2181-
);
2180+
const reasonParts =
2181+
/^(See )(mozilla\/pdf\.js)@tags\/(v\d+\.\d+\.\d+)\s*$/.exec(reason);
21822182

21832183
if (reasonParts) {
21842184
reason =

src/core/annotation.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1589,11 +1589,8 @@ class WidgetAnnotation extends Annotation {
15891589
"Expected `_defaultAppearanceData` to have been set."
15901590
);
15911591
}
1592-
const {
1593-
localResources,
1594-
appearanceResources,
1595-
acroFormResources,
1596-
} = this._fieldResources;
1592+
const { localResources, appearanceResources, acroFormResources } =
1593+
this._fieldResources;
15971594

15981595
const fontName =
15991596
this.data.defaultAppearanceData &&

src/core/evaluator.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3205,9 +3205,8 @@ class PartialEvaluator {
32053205
// text-extraction. For simple fonts, containing encoding information,
32063206
// use a fallback ToUnicode map to improve this (fixes issue8229.pdf).
32073207
if (!properties.composite && properties.hasEncoding) {
3208-
properties.fallbackToUnicode = this._buildSimpleFontToUnicode(
3209-
properties
3210-
);
3208+
properties.fallbackToUnicode =
3209+
this._buildSimpleFontToUnicode(properties);
32113210
}
32123211

32133212
return Promise.resolve(properties.toUnicode);

src/core/fonts.js

+7-21
Original file line numberDiff line numberDiff line change
@@ -999,12 +999,14 @@ class Font {
999999
map[+charCode] = GlyphMapForStandardFonts[charCode];
10001000
}
10011001
if (/Arial-?Black/i.test(name)) {
1002-
const SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
1002+
const SupplementalGlyphMapForArialBlack =
1003+
getSupplementalGlyphMapForArialBlack();
10031004
for (const charCode in SupplementalGlyphMapForArialBlack) {
10041005
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
10051006
}
10061007
} else if (/Calibri/i.test(name)) {
1007-
const SupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri();
1008+
const SupplementalGlyphMapForCalibri =
1009+
getSupplementalGlyphMapForCalibri();
10081010
for (const charCode in SupplementalGlyphMapForCalibri) {
10091011
map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
10101012
}
@@ -1801,22 +1803,7 @@ class Font {
18011803
// glyf table cannot be empty -- redoing the glyf and loca tables
18021804
// to have single glyph with one point
18031805
const simpleGlyph = new Uint8Array([
1804-
0,
1805-
1,
1806-
0,
1807-
0,
1808-
0,
1809-
0,
1810-
0,
1811-
0,
1812-
0,
1813-
0,
1814-
0,
1815-
0,
1816-
0,
1817-
0,
1818-
49,
1819-
0,
1806+
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0,
18201807
]);
18211808
for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
18221809
itemEncode(locaData, j, simpleGlyph.length);
@@ -2707,9 +2694,8 @@ class Font {
27072694
return charCode | 0;
27082695
}
27092696
}
2710-
newMapping.charCodeToGlyphId[
2711-
newMapping.nextAvailableFontCharCode
2712-
] = glyphId;
2697+
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
2698+
glyphId;
27132699
return newMapping.nextAvailableFontCharCode++;
27142700
}
27152701

src/core/xfa/xhtml.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ function mapStyle(styleStr) {
117117
style.transform = newValue;
118118
}
119119
} else {
120-
style[
121-
key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())
122-
] = newValue;
120+
style[key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())] =
121+
newValue;
123122
}
124123
}
125124
return style;

src/display/api.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -3070,13 +3070,8 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
30703070
this.stepper.init(this.operatorList);
30713071
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
30723072
}
3073-
const {
3074-
canvasContext,
3075-
viewport,
3076-
transform,
3077-
imageLayer,
3078-
background,
3079-
} = this.params;
3073+
const { canvasContext, viewport, transform, imageLayer, background } =
3074+
this.params;
30803075

30813076
this.gfx = new CanvasGraphics(
30823077
canvasContext,

src/display/fetch_stream.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,13 @@ class PDFFetchStreamReader {
141141
const getResponseHeader = name => {
142142
return response.headers.get(name);
143143
};
144-
const {
145-
allowRangeRequests,
146-
suggestedLength,
147-
} = validateRangeRequestCapabilities({
148-
getResponseHeader,
149-
isHttp: this._stream.isHttp,
150-
rangeChunkSize: this._rangeChunkSize,
151-
disableRange: this._disableRange,
152-
});
144+
const { allowRangeRequests, suggestedLength } =
145+
validateRangeRequestCapabilities({
146+
getResponseHeader,
147+
isHttp: this._stream.isHttp,
148+
rangeChunkSize: this._rangeChunkSize,
149+
disableRange: this._disableRange,
150+
});
153151

154152
this._isRangeSupported = allowRangeRequests;
155153
// Setting right content length.

src/display/network.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,13 @@ class PDFNetworkStreamFullRequestReader {
305305
const getResponseHeader = name => {
306306
return fullRequestXhr.getResponseHeader(name);
307307
};
308-
const {
309-
allowRangeRequests,
310-
suggestedLength,
311-
} = validateRangeRequestCapabilities({
312-
getResponseHeader,
313-
isHttp: this._manager.isHttp,
314-
rangeChunkSize: this._rangeChunkSize,
315-
disableRange: this._disableRange,
316-
});
308+
const { allowRangeRequests, suggestedLength } =
309+
validateRangeRequestCapabilities({
310+
getResponseHeader,
311+
isHttp: this._manager.isHttp,
312+
rangeChunkSize: this._rangeChunkSize,
313+
disableRange: this._disableRange,
314+
});
317315

318316
if (allowRangeRequests) {
319317
this._isRangeSupported = true;

src/display/node_stream.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,13 @@ class PDFNodeStreamFullReader extends BaseFullReader {
330330
// here: https://nodejs.org/api/http.html#http_message_headers.
331331
return this._readableStream.headers[name.toLowerCase()];
332332
};
333-
const {
334-
allowRangeRequests,
335-
suggestedLength,
336-
} = validateRangeRequestCapabilities({
337-
getResponseHeader,
338-
isHttp: stream.isHttp,
339-
rangeChunkSize: this._rangeChunkSize,
340-
disableRange: this._disableRange,
341-
});
333+
const { allowRangeRequests, suggestedLength } =
334+
validateRangeRequestCapabilities({
335+
getResponseHeader,
336+
isHttp: stream.isHttp,
337+
rangeChunkSize: this._rangeChunkSize,
338+
disableRange: this._disableRange,
339+
});
342340

343341
this._isRangeSupported = allowRangeRequests;
344342
// Setting right content length.

src/display/svg.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,7 @@ if (
5252

5353
const convertImgDataToPng = (function () {
5454
const PNG_HEADER = new Uint8Array([
55-
0x89,
56-
0x50,
57-
0x4e,
58-
0x47,
59-
0x0d,
60-
0x0a,
61-
0x1a,
62-
0x0a,
55+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
6356
]);
6457
const CHUNK_WRAPPER_SIZE = 12;
6558

src/display/text_layer.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,12 @@ function getAscent(fontFamily, ctx) {
7575
ctx.strokeStyle = "red";
7676
ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
7777
ctx.strokeText("g", 0, 0);
78-
let pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE)
79-
.data;
78+
let pixels = ctx.getImageData(
79+
0,
80+
0,
81+
DEFAULT_FONT_SIZE,
82+
DEFAULT_FONT_SIZE
83+
).data;
8084
descent = 0;
8185
for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
8286
if (pixels[i] > 0) {

src/scripting_api/util.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ class Util extends PDFObject {
284284
seconds: oDate.getSeconds(),
285285
};
286286

287-
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\.)/g;
287+
const patterns =
288+
/(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\.)/g;
288289
return cFormat.replace(patterns, function (match, pattern) {
289290
if (pattern in handlers) {
290291
return handlers[pattern](data);
@@ -517,7 +518,8 @@ class Util extends PDFObject {
517518

518519
// escape the string
519520
const escapedFormat = cFormat.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
520-
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
521+
const patterns =
522+
/(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
521523
const actions = [];
522524

523525
const re = escapedFormat.replace(

src/shared/compatibility.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ if (
100100
if (isReadableStreamSupported) {
101101
return;
102102
}
103-
globalThis.ReadableStream = require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
103+
globalThis.ReadableStream =
104+
require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
104105
})();
105106
}

test/downloadutils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function rewriteWebArchiveUrl(url) {
2626
// Web Archive URLs need to be transformed to add `if_` after the ID.
2727
// Without this, an HTML page containing an iframe with the PDF file
2828
// will be served instead (issue 8920).
29-
var webArchiveRegex = /(^https?:\/\/web\.archive\.org\/web\/)(\d+)(\/https?:\/\/.+)/g;
29+
var webArchiveRegex =
30+
/(^https?:\/\/web\.archive\.org\/web\/)(\d+)(\/https?:\/\/.+)/g;
3031
var urlParts = webArchiveRegex.exec(url);
3132
if (urlParts) {
3233
return urlParts[1] + (urlParts[2] + "if_") + urlParts[3];

test/driver.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ var Driver = (function DriverClosure() {
422422
loadingTask.promise.then(
423423
doc => {
424424
task.pdfDoc = doc;
425-
task.optionalContentConfigPromise = doc.getOptionalContentConfig();
425+
task.optionalContentConfigPromise =
426+
doc.getOptionalContentConfig();
426427

427428
this._nextPage(task, failure);
428429
},
@@ -600,9 +601,8 @@ var Driver = (function DriverClosure() {
600601
}
601602
annotationLayerCanvas.width = viewport.width;
602603
annotationLayerCanvas.height = viewport.height;
603-
var annotationLayerContext = annotationLayerCanvas.getContext(
604-
"2d"
605-
);
604+
var annotationLayerContext =
605+
annotationLayerCanvas.getContext("2d");
606606
annotationLayerContext.clearRect(
607607
0,
608608
0,

test/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ function unitTestPostHandler(req, res) {
843843
}
844844

845845
async function startBrowser(browserName, startUrl = "") {
846-
const revisions = require("puppeteer/lib/cjs/puppeteer/revisions.js")
847-
.PUPPETEER_REVISIONS;
846+
const revisions =
847+
require("puppeteer/lib/cjs/puppeteer/revisions.js").PUPPETEER_REVISIONS;
848848
const wantedRevision =
849849
browserName === "chrome" ? revisions.chromium : revisions.firefox;
850850

test/unit/annotation_spec.js

+4-18
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,10 @@ describe("annotation", function () {
230230

231231
it("should process quadpoints in the standard order", function () {
232232
rect = [10, 10, 20, 20];
233-
dict.set("QuadPoints", [
234-
10,
235-
20,
236-
20,
237-
20,
238-
10,
239-
10,
240-
20,
241-
10,
242-
11,
243-
19,
244-
19,
245-
19,
246-
11,
247-
11,
248-
19,
249-
11,
250-
]);
233+
dict.set(
234+
"QuadPoints",
235+
[10, 20, 20, 20, 10, 10, 20, 10, 11, 19, 19, 19, 11, 11, 19, 11]
236+
);
251237
expect(getQuadPoints(dict, rect)).toEqual([
252238
[
253239
{ x: 10, y: 20 },

0 commit comments

Comments
 (0)