Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/image_decoders/jpeg_viewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const jpegData = jpegImage.getData({
//
const imageData = jpegCtx.createImageData(width, height);
const imageBytes = imageData.data;
for (let j = 0, k = 0, jj = width * height * 4; j < jj; ) {
for (let j = 0, k = 0, jj = width * height * 4; j < jj;) {
imageBytes[j++] = jpegData[k++];
imageBytes[j++] = jpegData[k++];
imageBytes[j++] = jpegData[k++];
Expand Down
346 changes: 201 additions & 145 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
"@babel/core": "^8.0.1",
"@babel/preset-env": "^8.0.2",
"@babel/runtime": "^8.0.0",
"@eslint/json": "^2.0.0",
"@eslint/json": "^2.0.1",
"@fluent/bundle": "^0.19.1",
"@fluent/dom": "^0.10.2",
"@metalsmith/layouts": "^3.0.0",
"@metalsmith/markdown": "^1.10.0",
"@napi-rs/canvas": "^1.0.0",
"@types/node": "^26.0.0",
"autoprefixer": "^10.5.1",
"@napi-rs/canvas": "^1.0.2",
"@types/node": "^26.1.0",
"autoprefixer": "^10.5.2",
"babel-loader": "^10.1.1",
"babel-plugin-istanbul": "^8.0.2",
"babel-plugin-polyfill-corejs3": "^1.0.0",
"cached-iterable": "^0.3.0",
"caniuse-lite": "^1.0.30001799",
"caniuse-lite": "^1.0.30001800",
"core-js": "^3.49.0",
"eslint": "^10.5.0",
"eslint": "^10.6.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import-x": "^4.17.0",
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-jasmine": "^4.2.2",
"eslint-plugin-no-unsanitized": "^4.1.5",
"eslint-plugin-perfectionist": "^5.9.1",
"eslint-plugin-prettier": "^5.5.6",
"eslint-plugin-regexp": "^3.1.0",
"eslint-plugin-unicorn": "^68.0.0",
"eslint-plugin-regexp": "^3.1.1",
"eslint-plugin-unicorn": "^70.0.0",
"globals": "^17.7.0",
"gulp": "^5.0.1",
"gulp-cli": "^3.1.0",
Expand All @@ -47,20 +47,20 @@
"metalsmith-html-relative": "^2.0.12",
"ordered-read-streams": "^2.0.0",
"pngjs": "^7.0.0",
"postcss": "^8.5.15",
"postcss": "^8.5.16",
"postcss-discard-comments": "^8.0.1",
"postcss-values-parser": "^8.0.0",
"prettier": "^3.8.4",
"puppeteer": "^25.2.0",
"stylelint": "^17.13.0",
"prettier": "^3.9.4",
"puppeteer": "^25.3.0",
"stylelint": "^17.14.0",
"stylelint-prettier": "^5.0.3",
"svglint": "^4.2.1",
"terser-webpack-plugin": "^5.6.1",
"tsc-alias": "^1.8.17",
"tsc-alias": "^1.9.0",
"ttest": "^4.0.0",
"typescript": "^6.0.3",
"vinyl": "^3.0.1",
"webpack": "^5.107.2",
"webpack": "^5.108.3",
"webpack-stream": "^7.0.0"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/calculate_md5.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function calculateMD5(data, offset, length) {
i += 3;
const w = new Int32Array(16);
const { k, r } = PARAMS;
for (i = 0; i < paddedLength; ) {
for (i = 0; i < paddedLength;) {
for (j = 0; j < 16; ++j, i += 4) {
w[j] =
padded[i] |
Expand Down
2 changes: 1 addition & 1 deletion src/core/calculate_sha256.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function calculateSHA256(data, offset, length) {
const w = new Uint32Array(64);
const { k } = PARAMS;
// for each 512 bit block
for (i = 0; i < paddedLength; ) {
for (i = 0; i < paddedLength;) {
for (j = 0; j < 16; ++j) {
w[j] =
(padded[i] << 24) |
Expand Down
2 changes: 1 addition & 1 deletion src/core/calculate_sha_other.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function calculateSHA512(data, offset, length, mode384 = false) {
let tmp3;

// for each 1024 bit block
for (i = 0; i < paddedLength; ) {
for (i = 0; i < paddedLength;) {
for (j = 0; j < 16; ++j) {
w[j].high =
(padded[i] << 24) |
Expand Down
2 changes: 1 addition & 1 deletion src/core/cff_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class CFFParser {

let length = data.length;

for (let j = 0; j < length; ) {
for (let j = 0; j < length;) {
const value = data[j++];
let validationCommand = null;
if (value === 12) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/cmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class CMap {
c = ((c << 8) | str.charCodeAt(offset + n)) >>> 0;
// Check each codespace range to see if it falls within.
const codespaceRange = codespaceRanges[n];
for (let k = 0, kk = codespaceRange.length; k < kk; ) {
for (let k = 0, kk = codespaceRange.length; k < kk;) {
const low = codespaceRange[k++];
const high = codespaceRange[k++];
if (c >= low && c <= high) {
Expand All @@ -345,7 +345,7 @@ class CMap {
for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
// Check each codespace range to see if it falls within.
const codespaceRange = codespaceRanges[n];
for (let k = 0, kk = codespaceRange.length; k < kk; ) {
for (let k = 0, kk = codespaceRange.length; k < kk;) {
const low = codespaceRange[k++];
const high = codespaceRange[k++];
if (charCode >= low && charCode <= high) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ function getRanges(glyphs, toUnicodeExtraMap, numGlyphs) {
// Split the sorted codes into ranges.
const ranges = [];
const length = codes.length;
for (let n = 0; n < length; ) {
for (let n = 0; n < length;) {
const start = codes[n].fontCharCode;
const codeIndices = [codes[n].glyphId];
++n;
Expand Down Expand Up @@ -2449,7 +2449,7 @@ class Font {
let inFDEF = false,
ifLevel = 0,
inELSE = 0;
for (let ii = data.length; i < ii; ) {
for (let ii = data.length; i < ii;) {
const op = data[i++];
// The TrueType instruction set docs can be found at
// https://developer.apple.com/fonts/TTRefMan/RM05/Chap5.html
Expand Down
56 changes: 24 additions & 32 deletions src/core/glyf.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,24 +610,20 @@ class CompositeGlyph {
size += 2;
if (this.flags & 2) {
// Arguments are signed.
if (
!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)
) {
if (!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)) {
size += 2;
}
} else if (
!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)
) {
} else if (!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)) {
size += 2;
}

Expand All @@ -639,24 +635,20 @@ class CompositeGlyph {

if (this.flags & ARGS_ARE_XY_VALUES) {
// Arguments are signed.
if (
!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)
) {
if (!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
}
} else if (
!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)
) {
} else if (!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
}

Expand Down
28 changes: 12 additions & 16 deletions src/core/intersector.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,24 @@ class SingleIntersector {

if (this.#lastIntersectingQuadIndex >= 0) {
const i = this.#lastIntersectingQuadIndex;
if (
!(
quadPoints[i] >= x ||
quadPoints[i + 2] <= x ||
quadPoints[i + 5] >= y ||
quadPoints[i + 1] <= y
)
) {
if (!(
quadPoints[i] >= x ||
quadPoints[i + 2] <= x ||
quadPoints[i + 5] >= y ||
quadPoints[i + 1] <= y
)) {
return true;
}
this.#lastIntersectingQuadIndex = -1;
}

for (let i = 0, ii = quadPoints.length; i < ii; i += 8) {
if (
!(
quadPoints[i] >= x ||
quadPoints[i + 2] <= x ||
quadPoints[i + 5] >= y ||
quadPoints[i + 1] <= y
)
) {
if (!(
quadPoints[i] >= x ||
quadPoints[i + 2] <= x ||
quadPoints[i + 5] >= y ||
quadPoints[i + 1] <= y
)) {
this.#lastIntersectingQuadIndex = i;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/jpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ class JpegImage {
case 0xffc4: // DHT (Define Huffman Tables)
const huffmanLength = view.getUint16(offset);
offset += 2;
for (i = 2; i < huffmanLength; ) {
for (i = 2; i < huffmanLength;) {
const huffmanTableSpec = data[offset++];
const codeLengths = new Uint8Array(16);
let codeLengthSum = 0;
Expand Down Expand Up @@ -1272,7 +1272,7 @@ class JpegImage {
}

if (transform) {
for (i = 0; i < dataLength; ) {
for (i = 0; i < dataLength;) {
for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
data[i] = ((data[i] * transform[k]) >> 8) + transform[k + 1];
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/operator_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ addState(
const newBBox = F32_BBOX_INIT.slice();
Util.axialAlignedBoundingBox(minMax, transform, newBBox);
minMax.set(newBBox);
for (let k = 0, kk = buffer.length; k < kk; ) {
for (let k = 0, kk = buffer.length; k < kk;) {
switch (buffer[k++]) {
case DrawOPS.moveTo:
case DrawOPS.lineTo:
Expand Down
18 changes: 8 additions & 10 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1467,16 +1467,14 @@ class Linearization {
const obj3 = parser.getObj();
const linDict = parser.getObj();
let obj, length;
if (
!(
Number.isInteger(obj1) &&
Number.isInteger(obj2) &&
isCmd(obj3, "obj") &&
linDict instanceof Dict &&
typeof (obj = linDict.get("Linearized")) === "number" &&
obj > 0
)
) {
if (!(
Number.isInteger(obj1) &&
Number.isInteger(obj2) &&
isCmd(obj3, "obj") &&
linDict instanceof Dict &&
typeof (obj = linDict.get("Linearized")) === "number" &&
obj > 0
)) {
return null; // No valid linearization dictionary found.
} else if ((length = getInt(linDict, "L")) !== stream.length) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/display/display_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ function makePathFromDrawOPS(data) {
if (!data) {
return path;
}
for (let i = 0, ii = data.length; i < ii; ) {
for (let i = 0, ii = data.length; i < ii;) {
switch (data[i++]) {
case DrawOPS.moveTo:
path.moveTo(data[i++], data[i++]);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/reorganize_pages_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async function drawInkLine(page, pageNumber) {
async function waitForHavingContents(page, expected) {
await page.evaluate(() => {
// Make sure all the pages will be visible.
window.PDFViewerApplication.pdfViewer.scrollMode = 2 /* = ScrollMode.WRAPPED = */;
window.PDFViewerApplication.pdfViewer.scrollMode = 2; /* = ScrollMode.WRAPPED = */
window.PDFViewerApplication.pdfViewer.updateScale({
drawingDelay: 0,
scaleFactor: 0.01,
Expand Down
1 change: 1 addition & 0 deletions test/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"outDir": "../../build/tmp",
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "bundler",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"rootDir": ".",
"target": "ES2022",
"allowJs": true,
"declaration": true,
Expand Down
12 changes: 5 additions & 7 deletions web/pdf_link_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,11 @@ class PDFLinkService {
const pageNumber =
(typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val)) ||
val | 0;
if (
!(
Number.isInteger(pageNumber) &&
pageNumber > 0 &&
pageNumber <= this.pagesCount
)
) {
if (!(
Number.isInteger(pageNumber) &&
pageNumber > 0 &&
pageNumber <= this.pagesCount
)) {
console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions web/pdf_thumbnail_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ class PDFThumbnailViewer {
}
if (!labels) {
this._pageLabels = null;
} else if (
!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)
) {
} else if (!(
Array.isArray(labels) && this.pdfDocument.numPages === labels.length
)) {
this._pageLabels = null;
console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
} else {
Expand Down
6 changes: 3 additions & 3 deletions web/pdf_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1333,9 +1333,9 @@ class PDFViewer {
}
if (!labels) {
this._pageLabels = null;
} else if (
!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)
) {
} else if (!(
Array.isArray(labels) && this.pdfDocument.numPages === labels.length
)) {
this._pageLabels = null;
console.error(`setPageLabels: Invalid page labels.`);
} else {
Expand Down