Skip to content

Update PDF.js to v2.14.137 #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2022
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
14 changes: 11 additions & 3 deletions tools/update-pdfjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ set -eu
#
# To update PDF.js to the latest version:
#
# 1. Create a new branch and run this script.
# 2. Rebuild the extension and verify that PDFs work as expected in Chrome
# 3. Commit the changes to the `src/vendor/` directory
# 1. Create a new branch and run this script. This will fetch the latest PDF.js
# release and commit the changes.
# 2. Check that PDF annotation works as expected. See the project README for
# steps to run this locally.

DEST_DIR=viewer/

Expand Down Expand Up @@ -52,3 +53,10 @@ cat <<END > $DEST_DIR/HYPOTHESIS-README.md

This is a build of the PDF.js viewer auto-generated by tools/update-pdfjs.
END

# Look for `const pdfjsVersion = '<VERSION>'` line in source and extract VERSION.
PDFJS_VERSION=$(grep pdfjsVersion $DEST_DIR/web/viewer.js | egrep -o '[0-9.]+')
git add $DEST_DIR
git commit -m "Update PDF.js to v$PDFJS_VERSION

Update PDF.js using $0."
23,730 changes: 10,872 additions & 12,858 deletions viewer/build/pdf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion viewer/build/pdf.js.map

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions viewer/build/pdf.sandbox.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion viewer/build/pdf.sandbox.js.map

Large diffs are not rendered by default.

31,777 changes: 15,569 additions & 16,208 deletions viewer/build/pdf.worker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion viewer/build/pdf.worker.js.map

Large diffs are not rendered by default.

125 changes: 56 additions & 69 deletions viewer/web/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* limitations under the License.
*/

"use strict";
let opMap;

// eslint-disable-next-line no-var
var FontInspector = (function FontInspectorClosure() {
const FontInspector = (function FontInspectorClosure() {
let fonts;
let active = false;
const fontAttribute = "data-font-name";
Expand Down Expand Up @@ -49,8 +48,7 @@ var FontInspector = (function FontInspectorClosure() {
}
const fontName = e.target.dataset.fontName;
const selects = document.getElementsByTagName("input");
for (let i = 0; i < selects.length; ++i) {
const select = selects[i];
for (const select of selects) {
if (select.dataset.fontName !== fontName) {
continue;
}
Expand All @@ -65,7 +63,7 @@ var FontInspector = (function FontInspectorClosure() {
name: "Font Inspector",
panel: null,
manager: null,
init: function init(pdfjsLib) {
init(pdfjsLib) {
const panel = this.panel;
const tmp = document.createElement("button");
tmp.addEventListener("click", resetSelection);
Expand All @@ -75,7 +73,7 @@ var FontInspector = (function FontInspectorClosure() {
fonts = document.createElement("div");
panel.appendChild(fonts);
},
cleanup: function cleanup() {
cleanup() {
fonts.textContent = "";
},
enabled: false,
Expand All @@ -93,16 +91,16 @@ var FontInspector = (function FontInspectorClosure() {
}
},
// FontInspector specific functions.
fontAdded: function fontAdded(fontObj, url) {
fontAdded(fontObj, url) {
function properties(obj, list) {
const moreInfo = document.createElement("table");
for (let i = 0; i < list.length; i++) {
for (const entry of list) {
const tr = document.createElement("tr");
const td1 = document.createElement("td");
td1.textContent = list[i];
td1.textContent = entry;
tr.appendChild(td1);
const td2 = document.createElement("td");
td2.textContent = obj[list[i]].toString();
td2.textContent = obj[entry].toString();
tr.appendChild(td2);
moreInfo.appendChild(tr);
}
Expand Down Expand Up @@ -155,12 +153,8 @@ var FontInspector = (function FontInspectorClosure() {
};
})();

let opMap;

// Manages all the page steppers.
//
// eslint-disable-next-line no-var
var StepperManager = (function StepperManagerClosure() {
const StepperManager = (function StepperManagerClosure() {
let steppers = [];
let stepperDiv = null;
let stepperControls = null;
Expand All @@ -172,7 +166,7 @@ var StepperManager = (function StepperManagerClosure() {
name: "Stepper",
panel: null,
manager: null,
init: function init(pdfjsLib) {
init(pdfjsLib) {
const self = this;
stepperControls = document.createElement("div");
stepperChooser = document.createElement("select");
Expand All @@ -192,15 +186,15 @@ var StepperManager = (function StepperManagerClosure() {
opMap[pdfjsLib.OPS[key]] = key;
}
},
cleanup: function cleanup() {
cleanup() {
stepperChooser.textContent = "";
stepperDiv.textContent = "";
steppers = [];
},
enabled: false,
active: false,
// Stepper specific functions.
create: function create(pageIndex) {
create(pageIndex) {
const debug = document.createElement("div");
debug.id = "stepper" + pageIndex;
debug.hidden = true;
Expand All @@ -218,23 +212,19 @@ var StepperManager = (function StepperManagerClosure() {
}
return stepper;
},
selectStepper: function selectStepper(pageIndex, selectPanel) {
let i;
selectStepper(pageIndex, selectPanel) {
pageIndex |= 0;
if (selectPanel) {
this.manager.selectPanel(this);
}
for (i = 0; i < steppers.length; ++i) {
const stepper = steppers[i];
for (const stepper of steppers) {
stepper.panel.hidden = stepper.pageIndex !== pageIndex;
}
const options = stepperChooser.options;
for (i = 0; i < options.length; ++i) {
const option = options[i];
for (const option of stepperChooser.options) {
option.selected = (option.value | 0) === pageIndex;
}
},
saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
saveBreakPoints(pageIndex, bps) {
breakPoints[pageIndex] = bps;
sessionStorage.setItem("pdfjsBreakPoints", JSON.stringify(breakPoints));
},
Expand Down Expand Up @@ -292,6 +282,7 @@ const Stepper = (function StepperClosure() {
this.breakPoints = initialBreakPoints;
this.currentIdx = -1;
this.operatorListIdx = 0;
this.indentLevel = 0;
}

init(operatorList) {
Expand Down Expand Up @@ -360,8 +351,7 @@ const Stepper = (function StepperClosure() {
const charCodeRow = c("tr");
const fontCharRow = c("tr");
const unicodeRow = c("tr");
for (let j = 0; j < glyphs.length; j++) {
const glyph = glyphs[j];
for (const glyph of glyphs) {
if (typeof glyph === "object" && glyph !== null) {
charCodeRow.appendChild(c("td", glyph.originalCharCode));
fontCharRow.appendChild(c("td", glyph.fontChar));
Expand All @@ -382,8 +372,14 @@ const Stepper = (function StepperClosure() {
table.appendChild(charCodeRow);
table.appendChild(fontCharRow);
table.appendChild(unicodeRow);
} else if (fn === "restore") {
this.indentLevel--;
}
line.appendChild(c("td", " ".repeat(this.indentLevel * 2) + fn));
if (fn === "save") {
this.indentLevel++;
}
line.appendChild(c("td", fn));

if (decArgs instanceof HTMLElement) {
line.appendChild(decArgs);
} else {
Expand All @@ -403,9 +399,9 @@ const Stepper = (function StepperClosure() {
this.breakPoints.sort(function (a, b) {
return a - b;
});
for (let i = 0; i < this.breakPoints.length; i++) {
if (this.breakPoints[i] > this.currentIdx) {
return this.breakPoints[i];
for (const breakPoint of this.breakPoints) {
if (breakPoint > this.currentIdx) {
return breakPoint;
}
}
return null;
Expand Down Expand Up @@ -437,8 +433,7 @@ const Stepper = (function StepperClosure() {

goTo(idx) {
const allRows = this.panel.getElementsByClassName("line");
for (let x = 0, xx = allRows.length; x < xx; ++x) {
const row = allRows[x];
for (const row of allRows) {
if ((row.dataset.idx | 0) === idx) {
row.style.backgroundColor = "rgb(251,250,207)";
row.scrollIntoView();
Expand All @@ -451,17 +446,14 @@ const Stepper = (function StepperClosure() {
return Stepper;
})();

// eslint-disable-next-line no-var
var Stats = (function Stats() {
const Stats = (function Stats() {
let stats = [];
function clear(node) {
while (node.hasChildNodes()) {
node.removeChild(node.lastChild);
}
node.textContent = ""; // Remove any `node` contents from the DOM.
}
function getStatIndex(pageNumber) {
for (let i = 0, ii = stats.length; i < ii; ++i) {
if (stats[i].pageNumber === pageNumber) {
for (const [i, stat] of stats.entries()) {
if (stat.pageNumber === pageNumber) {
return i;
}
}
Expand All @@ -483,8 +475,7 @@ var Stats = (function Stats() {
}
const statsIndex = getStatIndex(pageNumber);
if (statsIndex !== false) {
const b = stats[statsIndex];
this.panel.removeChild(b.div);
stats[statsIndex].div.remove();
stats.splice(statsIndex, 1);
}
const wrapper = document.createElement("div");
Expand All @@ -501,8 +492,8 @@ var Stats = (function Stats() {
return a.pageNumber - b.pageNumber;
});
clear(this.panel);
for (let i = 0, ii = stats.length; i < ii; ++i) {
this.panel.appendChild(stats[i].div);
for (const entry of stats) {
this.panel.appendChild(entry.div);
}
},
cleanup() {
Expand All @@ -513,7 +504,7 @@ var Stats = (function Stats() {
})();

// Manages all the debugging tools.
window.PDFBug = (function PDFBugClosure() {
const PDFBug = (function PDFBugClosure() {
const panelWidth = 300;
const buttons = [];
let activePanel = null;
Expand All @@ -523,8 +514,7 @@ window.PDFBug = (function PDFBugClosure() {
enable(ids) {
const all = ids.length === 1 && ids[0] === "all";
const tools = this.tools;
for (let i = 0; i < tools.length; ++i) {
const tool = tools[i];
for (const tool of tools) {
if (all || ids.includes(tool.id)) {
tool.enabled = true;
}
Expand Down Expand Up @@ -566,22 +556,14 @@ window.PDFBug = (function PDFBugClosure() {
container.style.right = panelWidth + "px";

// Initialize all the debugging tools.
const tools = this.tools;
const self = this;
for (let i = 0; i < tools.length; ++i) {
const tool = tools[i];
for (const tool of this.tools) {
const panel = document.createElement("div");
const panelButton = document.createElement("button");
panelButton.textContent = tool.name;
panelButton.addEventListener(
"click",
(function (selected) {
return function (event) {
event.preventDefault();
self.selectPanel(selected);
};
})(i)
);
panelButton.addEventListener("click", event => {
event.preventDefault();
this.selectPanel(tool);
});
controls.appendChild(panelButton);
panels.appendChild(panel);
tool.panel = panel;
Expand All @@ -598,9 +580,9 @@ window.PDFBug = (function PDFBugClosure() {
this.selectPanel(0);
},
cleanup() {
for (let i = 0, ii = this.tools.length; i < ii; i++) {
if (this.tools[i].enabled) {
this.tools[i].cleanup();
for (const tool of this.tools) {
if (tool.enabled) {
tool.cleanup();
}
}
},
Expand All @@ -612,13 +594,18 @@ window.PDFBug = (function PDFBugClosure() {
return;
}
activePanel = index;
const tools = this.tools;
for (let j = 0; j < tools.length; ++j) {
for (const [j, tool] of this.tools.entries()) {
const isActive = j === index;
buttons[j].classList.toggle("active", isActive);
tools[j].active = isActive;
tools[j].panel.hidden = !isActive;
tool.active = isActive;
tool.panel.hidden = !isActive;
}
},
};
})();

globalThis.FontInspector = FontInspector;
globalThis.StepperManager = StepperManager;
globalThis.Stats = Stats;

export { PDFBug };
Binary file removed viewer/web/images/grab.cur
Binary file not shown.
Binary file removed viewer/web/images/grabbing.cur
Binary file not shown.
1 change: 1 addition & 0 deletions viewer/web/images/secondaryToolbarButton-scrollPage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions viewer/web/locale/ach/viewer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,12 @@ bookmark_label=Neno ma kombedi
tools.title=Gintic
tools_label=Gintic
first_page.title=Cit i pot buk mukwongo
first_page.label=Cit i pot buk mukwongo
first_page_label=Cit i pot buk mukwongo
last_page.title=Cit i pot buk magiko
last_page.label=Cit i pot buk magiko
last_page_label=Cit i pot buk magiko
page_rotate_cw.title=Wire i tung lacuc
page_rotate_cw.label=Wire i tung lacuc
page_rotate_cw_label=Wire i tung lacuc
page_rotate_ccw.title=Wire i tung lacam
page_rotate_ccw.label=Wire i tung lacam
page_rotate_ccw_label=Wire i tung lacam

cursor_text_select_tool.title=Cak gitic me yero coc
Expand Down Expand Up @@ -124,7 +120,6 @@ print_progress_close=Juki
# (the _label strings are alt text for the buttons, the .title strings are
# tooltips)
toggle_sidebar.title=Lok gintic ma inget
toggle_sidebar_notification.title=Lok lanyut me nget (wiyewiye tye i gin acoya/attachments)
toggle_sidebar_label=Lok gintic ma inget
document_outline.title=Nyut Wiyewiye me Gin acoya (dii-kiryo me yaro/kano jami weng)
document_outline_label=Pek pa gin acoya
Expand Down Expand Up @@ -184,9 +179,6 @@ page_scale_actual=Dite kikome
# numerical scale value.
page_scale_percent={{scale}}%

# Loading indicator messages
loading_error_indicator=Bal

loading_error=Bal otime kun cano PDF.
invalid_file_error=Pwail me PDF ma pe atir onyo obale woko.
missing_file_error=Pwail me PDF tye ka rem.
Expand Down
Loading