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

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
This commit is contained in:
Jonas Jenwald 2021-05-16 10:58:34 +02:00
parent 30908451b4
commit 8943bcd3c3
28 changed files with 127 additions and 192 deletions

View file

@ -1589,11 +1589,8 @@ class WidgetAnnotation extends Annotation {
"Expected `_defaultAppearanceData` to have been set."
);
}
const {
localResources,
appearanceResources,
acroFormResources,
} = this._fieldResources;
const { localResources, appearanceResources, acroFormResources } =
this._fieldResources;
const fontName =
this.data.defaultAppearanceData &&

View file

@ -3205,9 +3205,8 @@ class PartialEvaluator {
// text-extraction. For simple fonts, containing encoding information,
// use a fallback ToUnicode map to improve this (fixes issue8229.pdf).
if (!properties.composite && properties.hasEncoding) {
properties.fallbackToUnicode = this._buildSimpleFontToUnicode(
properties
);
properties.fallbackToUnicode =
this._buildSimpleFontToUnicode(properties);
}
return Promise.resolve(properties.toUnicode);

View file

@ -999,12 +999,14 @@ class Font {
map[+charCode] = GlyphMapForStandardFonts[charCode];
}
if (/Arial-?Black/i.test(name)) {
const SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
const SupplementalGlyphMapForArialBlack =
getSupplementalGlyphMapForArialBlack();
for (const charCode in SupplementalGlyphMapForArialBlack) {
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
}
} else if (/Calibri/i.test(name)) {
const SupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri();
const SupplementalGlyphMapForCalibri =
getSupplementalGlyphMapForCalibri();
for (const charCode in SupplementalGlyphMapForCalibri) {
map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
}
@ -1801,22 +1803,7 @@ class Font {
// glyf table cannot be empty -- redoing the glyf and loca tables
// to have single glyph with one point
const simpleGlyph = new Uint8Array([
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
49,
0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0,
]);
for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
itemEncode(locaData, j, simpleGlyph.length);
@ -2707,9 +2694,8 @@ class Font {
return charCode | 0;
}
}
newMapping.charCodeToGlyphId[
newMapping.nextAvailableFontCharCode
] = glyphId;
newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
glyphId;
return newMapping.nextAvailableFontCharCode++;
}

View file

@ -117,9 +117,8 @@ function mapStyle(styleStr) {
style.transform = newValue;
}
} else {
style[
key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())
] = newValue;
style[key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())] =
newValue;
}
}
return style;

View file

@ -3070,13 +3070,8 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
this.stepper.init(this.operatorList);
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
}
const {
canvasContext,
viewport,
transform,
imageLayer,
background,
} = this.params;
const { canvasContext, viewport, transform, imageLayer, background } =
this.params;
this.gfx = new CanvasGraphics(
canvasContext,

View file

@ -141,15 +141,13 @@ class PDFFetchStreamReader {
const getResponseHeader = name => {
return response.headers.get(name);
};
const {
allowRangeRequests,
suggestedLength,
} = validateRangeRequestCapabilities({
getResponseHeader,
isHttp: this._stream.isHttp,
rangeChunkSize: this._rangeChunkSize,
disableRange: this._disableRange,
});
const { allowRangeRequests, suggestedLength } =
validateRangeRequestCapabilities({
getResponseHeader,
isHttp: this._stream.isHttp,
rangeChunkSize: this._rangeChunkSize,
disableRange: this._disableRange,
});
this._isRangeSupported = allowRangeRequests;
// Setting right content length.

View file

@ -305,15 +305,13 @@ class PDFNetworkStreamFullRequestReader {
const getResponseHeader = name => {
return fullRequestXhr.getResponseHeader(name);
};
const {
allowRangeRequests,
suggestedLength,
} = validateRangeRequestCapabilities({
getResponseHeader,
isHttp: this._manager.isHttp,
rangeChunkSize: this._rangeChunkSize,
disableRange: this._disableRange,
});
const { allowRangeRequests, suggestedLength } =
validateRangeRequestCapabilities({
getResponseHeader,
isHttp: this._manager.isHttp,
rangeChunkSize: this._rangeChunkSize,
disableRange: this._disableRange,
});
if (allowRangeRequests) {
this._isRangeSupported = true;

View file

@ -330,15 +330,13 @@ class PDFNodeStreamFullReader extends BaseFullReader {
// here: https://nodejs.org/api/http.html#http_message_headers.
return this._readableStream.headers[name.toLowerCase()];
};
const {
allowRangeRequests,
suggestedLength,
} = validateRangeRequestCapabilities({
getResponseHeader,
isHttp: stream.isHttp,
rangeChunkSize: this._rangeChunkSize,
disableRange: this._disableRange,
});
const { allowRangeRequests, suggestedLength } =
validateRangeRequestCapabilities({
getResponseHeader,
isHttp: stream.isHttp,
rangeChunkSize: this._rangeChunkSize,
disableRange: this._disableRange,
});
this._isRangeSupported = allowRangeRequests;
// Setting right content length.

View file

@ -52,14 +52,7 @@ if (
const convertImgDataToPng = (function () {
const PNG_HEADER = new Uint8Array([
0x89,
0x50,
0x4e,
0x47,
0x0d,
0x0a,
0x1a,
0x0a,
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
]);
const CHUNK_WRAPPER_SIZE = 12;

View file

@ -75,8 +75,12 @@ function getAscent(fontFamily, ctx) {
ctx.strokeStyle = "red";
ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
ctx.strokeText("g", 0, 0);
let pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE)
.data;
let pixels = ctx.getImageData(
0,
0,
DEFAULT_FONT_SIZE,
DEFAULT_FONT_SIZE
).data;
descent = 0;
for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
if (pixels[i] > 0) {

View file

@ -284,7 +284,8 @@ class Util extends PDFObject {
seconds: oDate.getSeconds(),
};
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\.)/g;
const patterns =
/(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\.)/g;
return cFormat.replace(patterns, function (match, pattern) {
if (pattern in handlers) {
return handlers[pattern](data);
@ -517,7 +518,8 @@ class Util extends PDFObject {
// escape the string
const escapedFormat = cFormat.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
const patterns =
/(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
const actions = [];
const re = escapedFormat.replace(

View file

@ -100,6 +100,7 @@ if (
if (isReadableStreamSupported) {
return;
}
globalThis.ReadableStream = require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
globalThis.ReadableStream =
require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
})();
}