Skip to content

Commit

Permalink
Update pdf.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Dec 8, 2024
1 parent abf587a commit 72a4e28
Show file tree
Hide file tree
Showing 44 changed files with 1,518 additions and 364 deletions.
335 changes: 259 additions & 76 deletions build/pdf.mjs

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/pdf.sandbox.mjs

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

71 changes: 37 additions & 34 deletions build/pdf.worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,13 @@ function fromBase64Util(str) {
}
return stringToBytes(atob(str));
}
if (typeof Promise.try !== "function") {
Promise.try = function (fn, ...args) {
return new Promise(resolve => {
resolve(fn(...args));
});
};
}

;// ./src/core/primitives.js

Expand Down Expand Up @@ -17430,7 +17437,7 @@ class ToUnicodeMap {
}
forEach(callback) {
for (const charCode in this._map) {
callback(charCode, this._map[charCode].charCodeAt(0));
callback(charCode, this._map[charCode].codePointAt(0));
}
}
has(i) {
Expand Down Expand Up @@ -51176,7 +51183,7 @@ class InkAnnotation extends MarkupAnnotation {
} = params;
this.data.annotationType = AnnotationType.INK;
this.data.inkLists = [];
this.data.isEditable = !this.data.noHTML && this.data.it === "InkHighlight";
this.data.isEditable = !this.data.noHTML;
this.data.noHTML = false;
this.data.opacity = dict.get("CA") || 1;
const rawInkLists = dict.getArray("InkList");
Expand Down Expand Up @@ -51237,22 +51244,27 @@ class InkAnnotation extends MarkupAnnotation {
ap
}) {
const {
oldAnnotation,
color,
opacity,
paths,
outlines,
rect,
rotation,
thickness
thickness,
user
} = annotation;
const ink = new Dict(xref);
const ink = oldAnnotation || new Dict(xref);
ink.set("Type", Name.get("Annot"));
ink.set("Subtype", Name.get("Ink"));
ink.set("CreationDate", `D:${getModificationDate()}`);
ink.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate()}`);
ink.set("Rect", rect);
ink.set("InkList", outlines?.points || paths.points);
ink.set("F", 4);
ink.set("Rotate", rotation);
if (user) {
ink.set("T", stringToAsciiOrUTF16BE(user));
}
if (outlines) {
ink.set("IT", Name.get("InkHighlight"));
}
Expand Down Expand Up @@ -51286,9 +51298,10 @@ class InkAnnotation extends MarkupAnnotation {
appearanceBuffer.push("/R0 gs");
}
for (const outline of paths.lines) {
for (let i = 0, ii = outline.length; i < ii; i += 6) {
appearanceBuffer.push(`${numberToString(outline[4])} ${numberToString(outline[5])} m`);
for (let i = 6, ii = outline.length; i < ii; i += 6) {
if (isNaN(outline[i])) {
appearanceBuffer.push(`${numberToString(outline[i + 4])} ${numberToString(outline[i + 5])} m`);
appearanceBuffer.push(`${numberToString(outline[i + 4])} ${numberToString(outline[i + 5])} l`);
} else {
const [c1x, c1y, c2x, c2y, x, y] = outline.slice(i, i + 6);
appearanceBuffer.push([c1x, c1y, c2x, c2y, x, y].map(numberToString).join(" ") + " c");
Expand Down Expand Up @@ -51670,7 +51683,6 @@ class StampAnnotation extends MarkupAnnotation {
stamp.set("Type", Name.get("Annot"));
stamp.set("Subtype", Name.get("Stamp"));
stamp.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate()}`);
stamp.set("CreationDate", `D:${getModificationDate()}`);
stamp.set("Rect", rect);
stamp.set("F", 4);
stamp.set("Border", [0, 0, 0]);
Expand Down Expand Up @@ -55787,6 +55799,7 @@ const StreamKind = {
PULL_COMPLETE: 7,
START_COMPLETE: 8
};
function onFn() {}
function wrapReason(reason) {
if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) {
unreachable('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
Expand Down Expand Up @@ -55856,9 +55869,7 @@ class MessageHandler {
const sourceName = this.sourceName,
targetName = data.sourceName,
comObj = this.comObj;
new Promise(function (resolve) {
resolve(action(data.data));
}).then(function (result) {
Promise.try(action, data.data).then(function (result) {
comObj.postMessage({
sourceName,
targetName,
Expand Down Expand Up @@ -56031,9 +56042,7 @@ class MessageHandler {
streamSink.sinkCapability.resolve();
streamSink.ready = streamSink.sinkCapability.promise;
this.streamSinks[streamId] = streamSink;
new Promise(function (resolve) {
resolve(action(data.data, streamSink));
}).then(function () {
Promise.try(action, data.data, streamSink).then(function () {
comObj.postMessage({
sourceName,
targetName,
Expand Down Expand Up @@ -56088,9 +56097,7 @@ class MessageHandler {
streamSink.sinkCapability.resolve();
}
streamSink.desiredSize = data.desiredSize;
new Promise(function (resolve) {
resolve(streamSink.onPull?.());
}).then(function () {
Promise.try(streamSink.onPull || onFn).then(function () {
comObj.postMessage({
sourceName,
targetName,
Expand Down Expand Up @@ -56141,9 +56148,8 @@ class MessageHandler {
if (!streamSink) {
break;
}
new Promise(function (resolve) {
resolve(streamSink.onCancel?.(wrapReason(data.reason)));
}).then(function () {
const dataReason = wrapReason(data.reason);
Promise.try(streamSink.onCancel || onFn, dataReason).then(function () {
comObj.postMessage({
sourceName,
targetName,
Expand All @@ -56160,7 +56166,7 @@ class MessageHandler {
reason: wrapReason(reason)
});
});
streamSink.sinkCapability.reject(wrapReason(data.reason));
streamSink.sinkCapability.reject(dataReason);
streamSink.isCancelled = true;
delete this.streamSinks[streamId];
break;
Expand Down Expand Up @@ -56318,21 +56324,24 @@ class WorkerTask {
}
}
class WorkerMessageHandler {
static {
if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" && typeof self.postMessage === "function" && "onmessage" in self) {
this.initializeFromPort(self);
}
}
static setup(handler, port) {
let testMessageProcessed = false;
handler.on("test", function (data) {
handler.on("test", data => {
if (testMessageProcessed) {
return;
}
testMessageProcessed = true;
handler.send("test", data instanceof Uint8Array);
});
handler.on("configure", function (data) {
handler.on("configure", data => {
setVerbosityLevel(data.verbosity);
});
handler.on("GetDocRequest", function (data) {
return WorkerMessageHandler.createDocumentHandler(data, port);
});
handler.on("GetDocRequest", data => this.createDocumentHandler(data, port));
}
static createDocumentHandler(docParams, port) {
let pdfManager;
Expand Down Expand Up @@ -56876,21 +56885,15 @@ class WorkerMessageHandler {
}
static initializeFromPort(port) {
const handler = new MessageHandler("worker", "main", port);
WorkerMessageHandler.setup(handler, port);
this.setup(handler, port);
handler.send("ready", null);
}
}
function isMessagePort(maybePort) {
return typeof maybePort.postMessage === "function" && "onmessage" in maybePort;
}
if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" && isMessagePort(self)) {
WorkerMessageHandler.initializeFromPort(self);
}

;// ./src/pdf.worker.js

const pdfjsVersion = "4.9.0";
const pdfjsBuild = "8f08ca2";
const pdfjsBuild = "3f1d07a";

var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };
Expand Down
2 changes: 1 addition & 1 deletion build/pdf.worker.mjs.map

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion web/locale/be/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ pdfjs-editor-stamp-add-image-button-label = Дадаць выяву
pdfjs-editor-free-highlight-thickness-input = Таўшчыня
pdfjs-editor-free-highlight-thickness-title =
.title = Змяняць таўшчыню пры вылучэнні іншых элементаў, акрамя тэксту
# .default-content is used as a placeholder in an empty text editor.
pdfjs-free-text2 =
.aria-label = Тэкставы рэдактар
.default-content = Пачніце ўводзіць…
pdfjs-free-text =
.aria-label = Тэкставы рэдактар
pdfjs-free-text-default-content = Пачніце набор тэксту…
Expand All @@ -355,8 +359,9 @@ pdfjs-ink-canvas =
## Alt-text dialog

# Alternative text (alt text) helps when people can't see the image.
pdfjs-editor-alt-text-button-label = Альтэрнатыўны тэкст
pdfjs-editor-alt-text-edit-button =
.aria-label = Змяніць альтэрнатыўны тэкст
pdfjs-editor-alt-text-edit-button-label = Змяніць альтэрнатыўны тэкст
pdfjs-editor-alt-text-dialog-label = Выберыце варыянт
pdfjs-editor-alt-text-dialog-description = Альтэрнатыўны тэкст дапамагае, калі людзі не бачаць выяву або калі яна не загружаецца.
Expand All @@ -370,6 +375,9 @@ pdfjs-editor-alt-text-decorative-tooltip = Пазначаны як дэкара
# .placeholder: This is a placeholder for the alt text input area
pdfjs-editor-alt-text-textarea =
.placeholder = Напрыклад, «Малады чалавек садзіцца за стол есці»
# Alternative text (alt text) helps when people can't see the image.
pdfjs-editor-alt-text-button =
.aria-label = Альтэрнатыўны тэкст
## Editor resizers
## This is used in an aria label to help to understand the role of the resizer.
Expand Down Expand Up @@ -451,10 +459,16 @@ pdfjs-editor-new-alt-text-error-close-button = Закрыць
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Сцягванне мадэлі ШІ для тэксту для атрыбута alt ({ $downloadedSize } з { $totalSize } МБ)
.aria-valuetext = Сцягванне мадэлі ШІ для тэксту для атрыбута alt ({ $downloadedSize } з { $totalSize } МБ)
# This is a button that users can click to edit the alt text they have already added.
pdfjs-editor-new-alt-text-added-button =
.aria-label = Тэкст для атрыбута alt дададзены
pdfjs-editor-new-alt-text-added-button-label = Тэкст для атрыбута alt дададзены
# This is a button that users can click to open the alt text editor and add alt text when it is not present.
pdfjs-editor-new-alt-text-missing-button =
.aria-label = Адсутнічае тэкст для атрыбута alt
pdfjs-editor-new-alt-text-missing-button-label = Адсутнічае тэкст для атрыбута alt
# This is a button that opens up the alt text modal where users should review the alt text that was automatically generated.
pdfjs-editor-new-alt-text-to-review-button =
.aria-label = Водгук на тэкст для атрыбута alt
pdfjs-editor-new-alt-text-to-review-button-label = Водгук на тэкст для атрыбута alt
# "Created automatically" is a prefix that will be added to the beginning of any alt text that has been automatically generated. After the colon, the user will see/hear the actual alt text description. If the alt text has been edited by a human, this prefix will not appear.
# Variables:
Expand Down
9 changes: 9 additions & 0 deletions web/locale/cs/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,12 @@ pdfjs-editor-alt-text-settings-editor-title = Editor alternativního textu
pdfjs-editor-alt-text-settings-show-dialog-button-label = Při přidávání obrázku hned zobrazit editor alternativního textu
pdfjs-editor-alt-text-settings-show-dialog-description = Pomůže vám zajistit, aby všechny vaše obrázky obsahovaly alternativní text.
pdfjs-editor-alt-text-settings-close-button = Zavřít
## "Annotations removed" bar

pdfjs-editor-undo-bar-undo-button =
.title = Zpět
pdfjs-editor-undo-bar-undo-button-label = Zpět
pdfjs-editor-undo-bar-close-button =
.title = Zavřít
pdfjs-editor-undo-bar-close-button-label = Zavřít
12 changes: 12 additions & 0 deletions web/locale/da/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ pdfjs-editor-stamp-add-image-button-label = Tilføj billede
pdfjs-editor-free-highlight-thickness-input = Tykkelse
pdfjs-editor-free-highlight-thickness-title =
.title = Ændr tykkelse, når andre elementer end tekst fremhæves
# .default-content is used as a placeholder in an empty text editor.
pdfjs-free-text2 =
.aria-label = Teksteditor
.default-content = Begynd at skrive…
pdfjs-free-text =
.aria-label = Teksteditor
pdfjs-free-text-default-content = Begynd at skrive…
Expand All @@ -354,6 +358,8 @@ pdfjs-ink-canvas =
## Alt-text dialog

pdfjs-editor-alt-text-button-label = Alternativ tekst
pdfjs-editor-alt-text-edit-button =
.aria-label = Rediger alternativ tekst
pdfjs-editor-alt-text-edit-button-label = Rediger alternativ tekst
pdfjs-editor-alt-text-dialog-label = Vælg en indstilling
pdfjs-editor-alt-text-dialog-description = Alternativ tekst hjælper folk, som ikke kan se billedet eller når det ikke indlæses.
Expand All @@ -367,6 +373,9 @@ pdfjs-editor-alt-text-decorative-tooltip = Markeret som dekorativ
# .placeholder: This is a placeholder for the alt text input area
pdfjs-editor-alt-text-textarea =
.placeholder = For eksempel: "En ung mand sætter sig ved et bord for at spise et måltid mad"
# Alternative text (alt text) helps when people can't see the image.
pdfjs-editor-alt-text-button =
.aria-label = Alternativ tekst
## Editor resizers
## This is used in an aria label to help to understand the role of the resizer.
Expand Down Expand Up @@ -447,6 +456,9 @@ pdfjs-editor-new-alt-text-error-close-button = Luk
# $percent (Number) - the percentage of the downloaded size.
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Henter alternativ tekst AI-model ({ $downloadedSize } af { $totalSize } MB)
.aria-valuetext = Henter alternativ tekst AI-model ({ $downloadedSize } af { $totalSize } MB)
# This is a button that users can click to edit the alt text they have already added.
pdfjs-editor-new-alt-text-added-button =
.aria-label = Alternativ tekst tilføjet
pdfjs-editor-new-alt-text-added-button-label = Alternativ tekst tilføjet
# This is a button that users can click to open the alt text editor and add alt text when it is not present.
pdfjs-editor-new-alt-text-missing-button =
Expand Down
22 changes: 22 additions & 0 deletions web/locale/dsb/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,25 @@ pdfjs-editor-alt-text-settings-editor-title = Editor za alternatiwny tekst
pdfjs-editor-alt-text-settings-show-dialog-button-label = Editor alternatiwnego teksta ned pokazaś, gaž se wobraz pśidawa
pdfjs-editor-alt-text-settings-show-dialog-description = Pomaga, wam wšym swójim wobrazam alternatiwny tekst pśidaś.
pdfjs-editor-alt-text-settings-close-button = Zacyniś
## "Annotations removed" bar

pdfjs-editor-undo-bar-message-highlight = Wótwónoźone wuzwignuś
pdfjs-editor-undo-bar-message-freetext = Tekst jo se wótwónoźeł
pdfjs-editor-undo-bar-message-ink = Kreslanka jo se wótwónoźeła
pdfjs-editor-undo-bar-message-stamp = Wobraz jo se wótwónoźeł
# Variables:
# $count (Number) - the number of removed annotations.
pdfjs-editor-undo-bar-message-multiple =
{ $count ->
[one] { $count } pśipisk jo se wótwónoźeł
[two] { $count } pśipiska stej se wótwónoźełej
[few] { $count } pśipiski su se wótwónoźeli
*[other] { $count } pśipiskow jo se wótwónoźeło
}
pdfjs-editor-undo-bar-undo-button =
.title = Anulěrowaś
pdfjs-editor-undo-bar-undo-button-label = Anulěrowaś
pdfjs-editor-undo-bar-close-button =
.title = Zacyniś
pdfjs-editor-undo-bar-close-button-label = Zacyniś
2 changes: 1 addition & 1 deletion web/locale/el/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pdfjs-editor-free-highlight-thickness-title =
# .default-content is used as a placeholder in an empty text editor.
pdfjs-free-text2 =
.aria-label = Επεξεργασία κειμένου
.default-content = Ξεκινήστε την πληκτρολόγηση
.default-content = Ξεκινήστε να πληκτρολογείτε
pdfjs-free-text =
.aria-label = Επεξεργασία κειμένου
pdfjs-free-text-default-content = Ξεκινήστε να πληκτρολογείτε…
Expand Down
16 changes: 15 additions & 1 deletion web/locale/en-CA/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ pdfjs-editor-stamp-add-image-button-label = Add image
pdfjs-editor-free-highlight-thickness-input = Thickness
pdfjs-editor-free-highlight-thickness-title =
.title = Change thickness when highlighting items other than text
# .default-content is used as a placeholder in an empty text editor.
pdfjs-free-text2 =
.aria-label = Text Editor
.default-content = Start typing…
pdfjs-free-text =
.aria-label = Text Editor
pdfjs-free-text-default-content = Start typing…
Expand All @@ -353,8 +357,9 @@ pdfjs-ink-canvas =
## Alt-text dialog

# Alternative text (alt text) helps when people can't see the image.
pdfjs-editor-alt-text-button-label = Alt text
pdfjs-editor-alt-text-edit-button =
.aria-label = Edit alt text
pdfjs-editor-alt-text-edit-button-label = Edit alt text
pdfjs-editor-alt-text-dialog-label = Choose an option
pdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.
Expand All @@ -368,6 +373,9 @@ pdfjs-editor-alt-text-decorative-tooltip = Marked as decorative
# .placeholder: This is a placeholder for the alt text input area
pdfjs-editor-alt-text-textarea =
.placeholder = For example, “A young man sits down at a table to eat a meal”
# Alternative text (alt text) helps when people can't see the image.
pdfjs-editor-alt-text-button =
.aria-label = Alt text
## Editor resizers
## This is used in an aria label to help to understand the role of the resizer.
Expand Down Expand Up @@ -449,10 +457,16 @@ pdfjs-editor-new-alt-text-error-close-button = Close
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
.aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
# This is a button that users can click to edit the alt text they have already added.
pdfjs-editor-new-alt-text-added-button =
.aria-label = Alt text added
pdfjs-editor-new-alt-text-added-button-label = Alt text added
# This is a button that users can click to open the alt text editor and add alt text when it is not present.
pdfjs-editor-new-alt-text-missing-button =
.aria-label = Missing alt text
pdfjs-editor-new-alt-text-missing-button-label = Missing alt text
# This is a button that opens up the alt text modal where users should review the alt text that was automatically generated.
pdfjs-editor-new-alt-text-to-review-button =
.aria-label = Review alt text
pdfjs-editor-new-alt-text-to-review-button-label = Review alt text
# "Created automatically" is a prefix that will be added to the beginning of any alt text that has been automatically generated. After the colon, the user will see/hear the actual alt text description. If the alt text has been edited by a human, this prefix will not appear.
# Variables:
Expand Down
Loading

0 comments on commit 72a4e28

Please sign in to comment.