Socket
Socket
Sign inDemoInstall

pdfjs-dist

Package Overview
Dependencies
82
Maintainers
3
Versions
1538
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.7.570 to 2.8.335

build/pdf.sandbox.js

2

bower.json
{
"name": "pdfjs-dist",
"version": "2.7.570",
"version": "2.8.335",
"main": [

@@ -5,0 +5,0 @@ "build/pdf.js",

@@ -1,2 +0,2 @@

/* Copyright 2020 Mozilla Foundation
/* Copyright 2021 Mozilla Foundation
*

@@ -3,0 +3,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -50,9 +50,9 @@ * Licensed under the Apache License, Version 2.0 (the "License");

class AnnotationFactory {
static create(xref, ref, pdfManager, idFactory) {
static create(xref, ref, pdfManager, idFactory, collectFields) {
return pdfManager.ensureCatalog("acroForm").then(acroForm => {
return pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory, acroForm]);
return pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory, acroForm, collectFields]);
});
}
static _create(xref, ref, pdfManager, idFactory, acroForm) {
static _create(xref, ref, pdfManager, idFactory, acroForm, collectFields) {
const dict = xref.fetchIfRef(ref);

@@ -74,3 +74,4 @@

pdfManager,
acroForm: acroForm instanceof _primitives.Dict ? acroForm : _primitives.Dict.empty
acroForm: acroForm instanceof _primitives.Dict ? acroForm : _primitives.Dict.empty,
collectFields
};

@@ -103,3 +104,3 @@

(0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + "falling back to base field type.");
(0, _util.warn)(`Unimplemented widget field type "${fieldType}", ` + "falling back to base field type.");
return new WidgetAnnotation(parameters);

@@ -153,6 +154,8 @@

default:
if (!subtype) {
(0, _util.warn)("Annotation is missing the required /Subtype.");
} else {
(0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + "falling back to base annotation.");
if (!collectFields) {
if (!subtype) {
(0, _util.warn)("Annotation is missing the required /Subtype.");
} else {
(0, _util.warn)(`Unimplemented annotation type "${subtype}", ` + "falling back to base annotation.");
}
}

@@ -168,2 +171,33 @@

function getRgbColor(color) {
const rgbColor = new Uint8ClampedArray(3);
if (!Array.isArray(color)) {
return rgbColor;
}
switch (color.length) {
case 0:
return null;
case 1:
_colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
return rgbColor;
case 3:
_colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
return rgbColor;
case 4:
_colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
return rgbColor;
default:
return rgbColor;
}
}
function getQuadPoints(dict, rect) {

@@ -257,2 +291,24 @@ if (!dict.has("QuadPoints")) {

};
if (params.collectFields) {
const kids = dict.get("Kids");
if (Array.isArray(kids)) {
const kidIds = [];
for (const kid of kids) {
if ((0, _primitives.isRef)(kid)) {
kidIds.push(kid.toString());
}
}
if (kidIds.length !== 0) {
this.data.kidIds = kidIds;
}
}
this.data.actions = (0, _core_utils.collectActions)(params.xref, dict, _util.AnnotationActionEventType);
this.data.fieldName = this._constructFieldName(dict);
}
this._fallbackFontDict = null;

@@ -274,6 +330,6 @@ }

isHidden(annotationStorage) {
const data = annotationStorage && annotationStorage[this.data.id];
const storageEntry = annotationStorage && annotationStorage.get(this.data.id);
if (data && "hidden" in data) {
return data.hidden;
if (storageEntry && storageEntry.hidden !== undefined) {
return storageEntry.hidden;
}

@@ -333,36 +389,3 @@

setColor(color) {
const rgbColor = new Uint8ClampedArray(3);
if (!Array.isArray(color)) {
this.color = rgbColor;
return;
}
switch (color.length) {
case 0:
this.color = null;
break;
case 1:
_colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
this.color = rgbColor;
break;
case 3:
_colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
this.color = rgbColor;
break;
case 4:
_colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
this.color = rgbColor;
break;
default:
this.color = rgbColor;
break;
}
this.color = getRgbColor(color);
}

@@ -478,2 +501,12 @@

getFieldObject() {
if (this.data.kidIds) {
return {
id: this.data.id,
actions: this.data.actions,
name: this.data.fieldName,
type: "",
kidIds: this.data.kidIds
};
}
return null;

@@ -488,2 +521,44 @@ }

_constructFieldName(dict) {
if (!dict.has("T") && !dict.has("Parent")) {
(0, _util.warn)("Unknown field name, falling back to empty field name.");
return "";
}
if (!dict.has("Parent")) {
return (0, _util.stringToPDFString)(dict.get("T"));
}
const fieldName = [];
if (dict.has("T")) {
fieldName.unshift((0, _util.stringToPDFString)(dict.get("T")));
}
let loopDict = dict;
const visited = new _primitives.RefSet();
if (dict.objId) {
visited.put(dict.objId);
}
while (loopDict.has("Parent")) {
loopDict = loopDict.get("Parent");
if (!(loopDict instanceof _primitives.Dict) || loopDict.objId && visited.has(loopDict.objId)) {
break;
}
if (loopDict.objId) {
visited.put(loopDict.objId);
}
if (loopDict.has("T")) {
fieldName.unshift((0, _util.stringToPDFString)(loopDict.get("T")));
}
}
return fieldName.join(".");
}
}

@@ -678,3 +753,21 @@

for (const points of this.data.quadPoints) {
let pointsArray = this.data.quadPoints;
if (!pointsArray) {
pointsArray = [[{
x: this.rectangle[0],
y: this.rectangle[3]
}, {
x: this.rectangle[2],
y: this.rectangle[3]
}, {
x: this.rectangle[0],
y: this.rectangle[1]
}, {
x: this.rectangle[2],
y: this.rectangle[1]
}]];
}
for (const points of pointsArray) {
const [mX, MX, mY, MY] = pointsCallback(buffer, points);

@@ -726,4 +819,11 @@ minX = Math.min(minX, mX);

data.annotationType = _util.AnnotationType.WIDGET;
data.fieldName = this._constructFieldName(dict);
data.actions = (0, _core_utils.collectActions)(params.xref, dict, _util.AnnotationActionEventType);
if (data.fieldName === undefined) {
data.fieldName = this._constructFieldName(dict);
}
if (data.actions === undefined) {
data.actions = (0, _core_utils.collectActions)(params.xref, dict, _util.AnnotationActionEventType);
}
const fieldValue = (0, _core_utils.getInheritableProperty)({

@@ -745,5 +845,5 @@ dict,

key: "DA"
}) || params.acroForm.get("DA") || "";
data.defaultAppearance = (0, _util.isString)(defaultAppearance) ? defaultAppearance : "";
data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(data.defaultAppearance);
}) || params.acroForm.get("DA");
this._defaultAppearance = (0, _util.isString)(defaultAppearance) ? defaultAppearance : "";
data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance);
const fieldType = (0, _core_utils.getInheritableProperty)({

@@ -789,35 +889,2 @@ dict,

_constructFieldName(dict) {
if (!dict.has("T") && !dict.has("Parent")) {
(0, _util.warn)("Unknown field name, falling back to empty field name.");
return "";
}
if (!dict.has("Parent")) {
return (0, _util.stringToPDFString)(dict.get("T"));
}
const fieldName = [];
if (dict.has("T")) {
fieldName.unshift((0, _util.stringToPDFString)(dict.get("T")));
}
let loopDict = dict;
while (loopDict.has("Parent")) {
loopDict = loopDict.get("Parent");
if (!(0, _primitives.isDict)(loopDict)) {
break;
}
if (loopDict.has("T")) {
fieldName.unshift((0, _util.stringToPDFString)(loopDict.get("T")));
}
}
return fieldName.join(".");
}
_decodeFormValue(formValue) {

@@ -855,3 +922,3 @@ if (Array.isArray(formValue)) {

if (!this.data.defaultAppearance || content === null) {
if (!this._defaultAppearance || content === null) {
return operatorList;

@@ -878,4 +945,9 @@ }

async save(evaluator, task, annotationStorage) {
const value = annotationStorage[this.data.id] && annotationStorage[this.data.id].value;
if (!annotationStorage) {
return null;
}
const storageEntry = annotationStorage.get(this.data.id);
const value = storageEntry && storageEntry.value;
if (value === this.data.fieldValue || value === undefined) {

@@ -952,3 +1024,4 @@ return null;

const value = annotationStorage[this.data.id] && annotationStorage[this.data.id].value;
const storageEntry = annotationStorage.get(this.data.id);
let value = storageEntry && storageEntry.value;

@@ -959,2 +1032,4 @@ if (value === undefined) {

value = value.trim();
if (value === "") {

@@ -964,2 +1039,8 @@ return "";

let lineCount = -1;
if (this.data.multiLine) {
lineCount = value.split(/\r\n|\r|\n/).length;
}
const defaultPadding = 2;

@@ -970,11 +1051,9 @@ const hPadding = defaultPadding;

if (!this.data.defaultAppearance) {
this.data.defaultAppearance = "/Helvetica 0 Tf 0 g";
this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this.data.defaultAppearance);
if (!this._defaultAppearance) {
this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance = "/Helvetica 0 Tf 0 g");
}
const [defaultAppearance, fontSize] = this._computeFontSize(totalHeight, lineCount);
const font = await this._getFontData(evaluator, task);
const fontSize = this._computeFontSize(font, totalHeight);
let descent = font.descent;

@@ -987,3 +1066,2 @@

const vPadding = defaultPadding + Math.abs(descent) * fontSize;
const defaultAppearance = this.data.defaultAppearance;
const alignment = this.data.textAlignment;

@@ -1024,31 +1102,32 @@

} = this.data.defaultAppearanceData;
await evaluator.handleSetFont(this._fieldResources.mergedResources, [fontName, fontSize], null, operatorList, task, initialState, null);
await evaluator.handleSetFont(this._fieldResources.mergedResources, [fontName && _primitives.Name.get(fontName), fontSize], null, operatorList, task, initialState, null);
return initialState.font;
}
_computeFontSize(font, height) {
let fontSize = this.data.defaultAppearanceData.fontSize;
_computeFontSize(height, lineCount) {
let {
fontSize
} = this.data.defaultAppearanceData;
if (!fontSize) {
const {
fontColor,
fontName
} = this.data.defaultAppearanceData;
let capHeight;
const roundWithOneDigit = x => Math.round(x * 10) / 10;
if (font.capHeight) {
capHeight = font.capHeight;
const FONT_FACTOR = 0.8;
if (lineCount === -1) {
fontSize = roundWithOneDigit(FONT_FACTOR * height);
} else {
const glyphs = font.charsToGlyphs(font.encodeString("M").join(""));
if (glyphs.length === 1 && glyphs[0].width) {
const em = glyphs[0].width / 1000;
capHeight = 0.7 * em;
} else {
capHeight = 0.7;
}
fontSize = 10;
let lineHeight = fontSize / FONT_FACTOR;
let numberOfLines = Math.round(height / lineHeight);
numberOfLines = Math.max(numberOfLines, lineCount);
lineHeight = height / numberOfLines;
fontSize = roundWithOneDigit(FONT_FACTOR * lineHeight);
}
fontSize = Math.max(1, Math.floor(height / (1.5 * capHeight)));
this.data.defaultAppearance = (0, _default_appearance.createDefaultAppearance)({
const {
fontName,
fontColor
} = this.data.defaultAppearanceData;
this._defaultAppearance = (0, _default_appearance.createDefaultAppearance)({
fontSize,

@@ -1060,3 +1139,3 @@ fontName,

return fontSize;
return [this._defaultAppearance, fontSize];
}

@@ -1094,5 +1173,5 @@

} = this._fieldResources;
const fontNameStr = this.data.defaultAppearanceData && this.data.defaultAppearanceData.fontName.name;
const fontName = this.data.defaultAppearanceData && this.data.defaultAppearanceData.fontName;
if (!fontNameStr) {
if (!fontName) {
return localResources || _primitives.Dict.empty;

@@ -1105,3 +1184,3 @@ }

if (localFont instanceof _primitives.Dict && localFont.has(fontNameStr)) {
if (localFont instanceof _primitives.Dict && localFont.has(fontName)) {
return resources;

@@ -1115,5 +1194,5 @@ }

if (acroFormFont instanceof _primitives.Dict && acroFormFont.has(fontNameStr)) {
if (acroFormFont instanceof _primitives.Dict && acroFormFont.has(fontName)) {
const subFontDict = new _primitives.Dict(xref);
subFontDict.set(fontNameStr, acroFormFont.getRaw(fontNameStr));
subFontDict.set(fontName, acroFormFont.getRaw(fontName));
const subResourcesDict = new _primitives.Dict(xref);

@@ -1319,3 +1398,4 @@ subResourcesDict.set("Font", subFontDict);

if (annotationStorage) {
const value = annotationStorage[this.data.id] && annotationStorage[this.data.id].value;
const storageEntry = annotationStorage.get(this.data.id);
const value = storageEntry && storageEntry.value;

@@ -1361,4 +1441,9 @@ if (value === undefined) {

async _saveCheckbox(evaluator, task, annotationStorage) {
const value = annotationStorage[this.data.id] && annotationStorage[this.data.id].value;
if (!annotationStorage) {
return null;
}
const storageEntry = annotationStorage.get(this.data.id);
const value = storageEntry && storageEntry.value;
if (value === undefined) {

@@ -1408,4 +1493,9 @@ return null;

async _saveRadioButton(evaluator, task, annotationStorage) {
const value = annotationStorage[this.data.id] && annotationStorage[this.data.id].value;
if (!annotationStorage) {
return null;
}
const storageEntry = annotationStorage.get(this.data.id);
const value = storageEntry && storageEntry.value;
if (value === undefined) {

@@ -1662,2 +1752,3 @@ return null;

actions: this.data.actions,
items: this.data.options,
type

@@ -1783,3 +1874,25 @@ };

this.data.annotationType = _util.AnnotationType.LINE;
this.data.lineCoordinates = _util.Util.normalizeRect(parameters.dict.getArray("L"));
const lineCoordinates = parameters.dict.getArray("L");
this.data.lineCoordinates = _util.Util.normalizeRect(lineCoordinates);
if (!this.appearance) {
const strokeColor = this.color ? Array.from(this.color).map(c => c / 255) : [0, 0, 0];
const borderWidth = this.borderStyle.width;
if ((0, _util.isArrayEqual)(this.rectangle, [0, 0, 0, 0])) {
this.rectangle = [this.data.lineCoordinates[0] - 2 * borderWidth, this.data.lineCoordinates[1] - 2 * borderWidth, this.data.lineCoordinates[2] + 2 * borderWidth, this.data.lineCoordinates[3] + 2 * borderWidth];
}
this._setDefaultAppearance({
xref: parameters.xref,
extra: `${borderWidth} w`,
strokeColor,
pointsCallback: (buffer, points) => {
buffer.push(`${lineCoordinates[0]} ${lineCoordinates[1]} m`);
buffer.push(`${lineCoordinates[2]} ${lineCoordinates[3]} l`);
buffer.push("S");
return [points[0].x - borderWidth, points[1].x + borderWidth, points[3].y - borderWidth, points[1].y + borderWidth];
}
});
}
}

@@ -1793,2 +1906,35 @@

this.data.annotationType = _util.AnnotationType.SQUARE;
if (!this.appearance) {
const strokeColor = this.color ? Array.from(this.color).map(c => c / 255) : [0, 0, 0];
let fillColor = null;
let interiorColor = parameters.dict.getArray("IC");
if (interiorColor) {
interiorColor = getRgbColor(interiorColor);
fillColor = interiorColor ? Array.from(interiorColor).map(c => c / 255) : null;
}
this._setDefaultAppearance({
xref: parameters.xref,
extra: `${this.borderStyle.width} w`,
strokeColor,
fillColor,
pointsCallback: (buffer, points) => {
const x = points[2].x + this.borderStyle.width / 2;
const y = points[2].y + this.borderStyle.width / 2;
const width = points[3].x - points[2].x - this.borderStyle.width;
const height = points[1].y - points[3].y - this.borderStyle.width;
buffer.push(`${x} ${y} ${width} ${height} re`);
if (fillColor) {
buffer.push("B");
} else {
buffer.push("S");
}
return [points[0].x, points[1].x, points[3].y, points[1].y];
}
});
}
}

@@ -1802,2 +1948,46 @@

this.data.annotationType = _util.AnnotationType.CIRCLE;
if (!this.appearance) {
const strokeColor = this.color ? Array.from(this.color).map(c => c / 255) : [0, 0, 0];
let fillColor = null;
let interiorColor = parameters.dict.getArray("IC");
if (interiorColor) {
interiorColor = getRgbColor(interiorColor);
fillColor = interiorColor ? Array.from(interiorColor).map(c => c / 255) : null;
}
const controlPointsDistance = 4 / 3 * Math.tan(Math.PI / (2 * 4));
this._setDefaultAppearance({
xref: parameters.xref,
extra: `${this.borderStyle.width} w`,
strokeColor,
fillColor,
pointsCallback: (buffer, points) => {
const x0 = points[0].x + this.borderStyle.width / 2;
const y0 = points[0].y - this.borderStyle.width / 2;
const x1 = points[3].x - this.borderStyle.width / 2;
const y1 = points[3].y + this.borderStyle.width / 2;
const xMid = x0 + (x1 - x0) / 2;
const yMid = y0 + (y1 - y0) / 2;
const xOffset = (x1 - x0) / 2 * controlPointsDistance;
const yOffset = (y1 - y0) / 2 * controlPointsDistance;
buffer.push(`${xMid} ${y1} m`);
buffer.push(`${xMid + xOffset} ${y1} ${x1} ${yMid + yOffset} ${x1} ${yMid} c`);
buffer.push(`${x1} ${yMid - yOffset} ${xMid + xOffset} ${y0} ${xMid} ${y0} c`);
buffer.push(`${xMid - xOffset} ${y0} ${x0} ${yMid - yOffset} ${x0} ${yMid} c`);
buffer.push(`${x0} ${yMid + yOffset} ${xMid - xOffset} ${y1} ${xMid} ${y1} c`);
buffer.push("h");
if (fillColor) {
buffer.push("B");
} else {
buffer.push("S");
}
return [points[0].x, points[1].x, points[3].y, points[1].y];
}
});
}
}

@@ -1804,0 +1994,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -36,3 +36,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var CCITTFaxStream = function CCITTFaxStreamClosure() {
const CCITTFaxStream = function CCITTFaxStreamClosure() {
function CCITTFaxStream(str, maybeLength, params) {

@@ -39,0 +39,0 @@ this.str = str;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -36,9 +36,9 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var MAX_SUBR_NESTING = 10;
var CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
const MAX_SUBR_NESTING = 10;
const CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
exports.CFFStandardStrings = CFFStandardStrings;
const NUM_STANDARD_CFF_STRINGS = 391;
var CFFParser = function CFFParserClosure() {
var CharstringValidationData = [null, {
const CFFParser = function CFFParserClosure() {
const CharstringValidationData = [null, {
id: "hstem",

@@ -140,3 +140,3 @@ min: 2,

}];
var CharstringValidationData12 = [null, null, null, {
const CharstringValidationData12 = [null, null, null, {
id: "and",

@@ -262,12 +262,12 @@ min: 2,

parse() {
var properties = this.properties;
var cff = new CFF();
const properties = this.properties;
const cff = new CFF();
this.cff = cff;
var header = this.parseHeader();
var nameIndex = this.parseIndex(header.endPos);
var topDictIndex = this.parseIndex(nameIndex.endPos);
var stringIndex = this.parseIndex(topDictIndex.endPos);
var globalSubrIndex = this.parseIndex(stringIndex.endPos);
var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
const header = this.parseHeader();
const nameIndex = this.parseIndex(header.endPos);
const topDictIndex = this.parseIndex(nameIndex.endPos);
const stringIndex = this.parseIndex(topDictIndex.endPos);
const globalSubrIndex = this.parseIndex(stringIndex.endPos);
const topDictParsed = this.parseDict(topDictIndex.obj.get(0));
const topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
cff.header = header.obj;

@@ -280,5 +280,5 @@ cff.names = this.parseNameIndex(nameIndex.obj);

cff.isCIDFont = topDict.hasName("ROS");
var charStringOffset = topDict.getByName("CharStrings");
var charStringIndex = this.parseIndex(charStringOffset).obj;
var fontMatrix = topDict.getByName("FontMatrix");
const charStringOffset = topDict.getByName("CharStrings");
const charStringIndex = this.parseIndex(charStringOffset).obj;
const fontMatrix = topDict.getByName("FontMatrix");

@@ -289,3 +289,3 @@ if (fontMatrix) {

var fontBBox = topDict.getByName("FontBBox");
const fontBBox = topDict.getByName("FontBBox");

@@ -298,10 +298,10 @@ if (fontBBox) {

var charset, encoding;
let charset, encoding;
if (cff.isCIDFont) {
var fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
const fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
var dictRaw = fdArrayIndex.get(i);
var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
for (let i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
const dictRaw = fdArrayIndex.get(i);
const fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
this.parsePrivateDict(fontDict);

@@ -321,3 +321,3 @@ cff.fdArray.push(fontDict);

cff.encoding = encoding;
var charStringsAndSeacs = this.parseCharStrings({
const charStringsAndSeacs = this.parseCharStrings({
charStrings: charStringIndex,

@@ -337,5 +337,5 @@ localSubrIndex: topDict.privateDict.subrsIndex,

parseHeader() {
var bytes = this.bytes;
var bytesLength = bytes.length;
var offset = 0;
let bytes = this.bytes;
const bytesLength = bytes.length;
let offset = 0;

@@ -356,7 +356,7 @@ while (offset < bytesLength && bytes[offset] !== 1) {

var major = bytes[0];
var minor = bytes[1];
var hdrSize = bytes[2];
var offSize = bytes[3];
var header = new CFFHeader(major, minor, hdrSize, offSize);
const major = bytes[0];
const minor = bytes[1];
const hdrSize = bytes[2];
const offSize = bytes[3];
const header = new CFFHeader(major, minor, hdrSize, offSize);
return {

@@ -369,6 +369,6 @@ obj: header,

parseDict(dict) {
var pos = 0;
let pos = 0;
function parseOperand() {
var value = dict[pos++];
let value = dict[pos++];

@@ -400,11 +400,11 @@ if (value === 30) {

function parseFloatOperand() {
var str = "";
var eof = 15;
let str = "";
const eof = 15;
const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
var length = dict.length;
const length = dict.length;
while (pos < length) {
var b = dict[pos++];
var b1 = b >> 4;
var b2 = b & 15;
const b = dict[pos++];
const b1 = b >> 4;
const b2 = b & 15;

@@ -427,9 +427,9 @@ if (b1 === eof) {

var operands = [];
var entries = [];
let operands = [];
const entries = [];
pos = 0;
var end = dict.length;
const end = dict.length;
while (pos < end) {
var b = dict[pos];
let b = dict[pos];

@@ -453,17 +453,17 @@ if (b <= 21) {

parseIndex(pos) {
var cffIndex = new CFFIndex();
var bytes = this.bytes;
var count = bytes[pos++] << 8 | bytes[pos++];
var offsets = [];
var end = pos;
var i, ii;
const cffIndex = new CFFIndex();
const bytes = this.bytes;
const count = bytes[pos++] << 8 | bytes[pos++];
const offsets = [];
let end = pos;
let i, ii;
if (count !== 0) {
var offsetSize = bytes[pos++];
var startPos = pos + (count + 1) * offsetSize - 1;
const offsetSize = bytes[pos++];
const startPos = pos + (count + 1) * offsetSize - 1;
for (i = 0, ii = count + 1; i < ii; ++i) {
var offset = 0;
let offset = 0;
for (var j = 0; j < offsetSize; ++j) {
for (let j = 0; j < offsetSize; ++j) {
offset <<= 8;

@@ -480,4 +480,4 @@ offset += bytes[pos++];

for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
var offsetStart = offsets[i];
var offsetEnd = offsets[i + 1];
const offsetStart = offsets[i];
const offsetEnd = offsets[i + 1];
cffIndex.add(bytes.subarray(offsetStart, offsetEnd));

@@ -493,6 +493,6 @@ }

parseNameIndex(index) {
var names = [];
const names = [];
for (var i = 0, ii = index.count; i < ii; ++i) {
var name = index.get(i);
for (let i = 0, ii = index.count; i < ii; ++i) {
const name = index.get(i);
names.push((0, _util.bytesToString)(name));

@@ -505,6 +505,6 @@ }

parseStringIndex(index) {
var strings = new CFFStrings();
const strings = new CFFStrings();
for (var i = 0, ii = index.count; i < ii; ++i) {
var data = index.get(i);
for (let i = 0, ii = index.count; i < ii; ++i) {
const data = index.get(i);
strings.add((0, _util.bytesToString)(data));

@@ -517,8 +517,8 @@ }

createDict(Type, dict, strings) {
var cffDict = new Type(strings);
const cffDict = new Type(strings);
for (var i = 0, ii = dict.length; i < ii; ++i) {
var pair = dict[i];
var key = pair[0];
var value = pair[1];
for (let i = 0, ii = dict.length; i < ii; ++i) {
const pair = dict[i];
const key = pair[0];
const value = pair[1];
cffDict.setByKey(key, value);

@@ -535,12 +535,12 @@ }

var stackSize = state.stackSize;
var stack = state.stack;
var length = data.length;
let stackSize = state.stackSize;
const stack = state.stack;
const length = data.length;
for (var j = 0; j < length;) {
var value = data[j++];
var validationCommand = null;
for (let j = 0; j < length;) {
const value = data[j++];
let validationCommand = null;
if (value === 12) {
var q = data[j++];
const q = data[j++];

@@ -586,3 +586,3 @@ if (q === 0) {

} else if (value === 10 || value === 29) {
var subrsIndex;
let subrsIndex;

@@ -601,3 +601,3 @@ if (value === 10) {

var bias = 32768;
let bias = 32768;

@@ -610,3 +610,3 @@ if (subrsIndex.count < 1240) {

var subrNumber = stack[--stackSize] + bias;
const subrNumber = stack[--stackSize] + bias;

@@ -621,3 +621,3 @@ if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {

state.callDepth++;
var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
const valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);

@@ -703,9 +703,9 @@ if (!valid) {

}) {
var seacs = [];
var widths = [];
var count = charStrings.count;
const seacs = [];
const widths = [];
const count = charStrings.count;
for (var i = 0; i < count; i++) {
var charstring = charStrings.get(i);
var state = {
for (let i = 0; i < count; i++) {
const charstring = charStrings.get(i);
const state = {
callDepth: 0,

@@ -721,8 +721,8 @@ stackSize: 0,

};
var valid = true;
var localSubrToUse = null;
var privateDictToUse = privateDict;
let valid = true;
let localSubrToUse = null;
let privateDictToUse = privateDict;
if (fdSelect && fdArray.length) {
var fdIndex = fdSelect.getFDIndex(i);
const fdIndex = fdSelect.getFDIndex(i);

@@ -776,3 +776,3 @@ if (fdIndex === -1) {

emptyPrivateDictionary(parentDict) {
var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
const privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
parentDict.setByKey(18, [0, 0]);

@@ -788,3 +788,3 @@ parentDict.privateDict = privateDict;

var privateOffset = parentDict.getByName("Private");
const privateOffset = parentDict.getByName("Private");

@@ -796,4 +796,4 @@ if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {

var size = privateOffset[0];
var offset = privateOffset[1];
const size = privateOffset[0];
const offset = privateOffset[1];

@@ -805,6 +805,6 @@ if (size === 0 || offset >= this.bytes.length) {

var privateDictEnd = offset + size;
var dictData = this.bytes.subarray(offset, privateDictEnd);
var dict = this.parseDict(dictData);
var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
const privateDictEnd = offset + size;
const dictData = this.bytes.subarray(offset, privateDictEnd);
const dict = this.parseDict(dictData);
const privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
parentDict.privateDict = privateDict;

@@ -816,4 +816,4 @@

var subrsOffset = privateDict.getByName("Subrs");
var relativeOffset = offset + subrsOffset;
const subrsOffset = privateDict.getByName("Subrs");
const relativeOffset = offset + subrsOffset;

@@ -825,3 +825,3 @@ if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {

var subrsIndex = this.parseIndex(relativeOffset);
const subrsIndex = this.parseIndex(relativeOffset);
privateDict.subrsIndex = subrsIndex.obj;

@@ -839,7 +839,7 @@ }

var bytes = this.bytes;
var start = pos;
var format = bytes[pos++];
const bytes = this.bytes;
const start = pos;
const format = bytes[pos++];
const charset = [cid ? 0 : ".notdef"];
var id, count, i;
let id, count, i;
length -= 1;

@@ -884,4 +884,4 @@

var end = pos;
var raw = bytes.subarray(start, end);
const end = pos;
const raw = bytes.subarray(start, end);
return new CFFCharset(false, format, charset, raw);

@@ -891,14 +891,14 @@ }

parseEncoding(pos, properties, strings, charset) {
var encoding = Object.create(null);
var bytes = this.bytes;
var predefined = false;
var format, i, ii;
var raw = null;
const encoding = Object.create(null);
const bytes = this.bytes;
let predefined = false;
let format, i, ii;
let raw = null;
function readSupplement() {
var supplementsCount = bytes[pos++];
const supplementsCount = bytes[pos++];
for (i = 0; i < supplementsCount; i++) {
var code = bytes[pos++];
var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
const code = bytes[pos++];
const sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
encoding[code] = charset.indexOf(strings.get(sid));

@@ -911,6 +911,6 @@ }

format = pos;
var baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
const baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
for (i = 0, ii = charset.length; i < ii; i++) {
var index = baseEncoding.indexOf(charset[i]);
const index = baseEncoding.indexOf(charset[i]);

@@ -922,3 +922,3 @@ if (index !== -1) {

} else {
var dataStart = pos;
const dataStart = pos;
format = bytes[pos++];

@@ -928,3 +928,3 @@

case 0:
var glyphsCount = bytes[pos++];
const glyphsCount = bytes[pos++];

@@ -938,10 +938,10 @@ for (i = 1; i <= glyphsCount; i++) {

case 1:
var rangesCount = bytes[pos++];
var gid = 1;
const rangesCount = bytes[pos++];
let gid = 1;
for (i = 0; i < rangesCount; i++) {
var start = bytes[pos++];
var left = bytes[pos++];
const start = bytes[pos++];
const left = bytes[pos++];
for (var j = start; j <= start + left; j++) {
for (let j = start; j <= start + left; j++) {
encoding[j] = gid++;

@@ -957,3 +957,3 @@ }

var dataEnd = pos;
const dataEnd = pos;

@@ -973,6 +973,6 @@ if (format & 0x80) {

parseFDSelect(pos, length) {
var bytes = this.bytes;
var format = bytes[pos++];
var fdSelect = [];
var i;
const bytes = this.bytes;
const format = bytes[pos++];
const fdSelect = [];
let i;

@@ -982,3 +982,3 @@ switch (format) {

for (i = 0; i < length; ++i) {
var id = bytes[pos++];
const id = bytes[pos++];
fdSelect.push(id);

@@ -990,6 +990,6 @@ }

case 3:
var rangesCount = bytes[pos++] << 8 | bytes[pos++];
const rangesCount = bytes[pos++] << 8 | bytes[pos++];
for (i = 0; i < rangesCount; ++i) {
var first = bytes[pos++] << 8 | bytes[pos++];
let first = bytes[pos++] << 8 | bytes[pos++];

@@ -1001,6 +1001,6 @@ if (i === 0 && first !== 0) {

var fdIndex = bytes[pos++];
var next = bytes[pos] << 8 | bytes[pos + 1];
const fdIndex = bytes[pos++];
const next = bytes[pos] << 8 | bytes[pos + 1];
for (var j = first; j < next; ++j) {
for (let j = first; j < next; ++j) {
fdSelect.push(fdIndex);

@@ -1052,3 +1052,3 @@ }

var glyphZero = this.charStrings.get(0);
const glyphZero = this.charStrings.get(0);
this.charStrings.add(glyphZero);

@@ -1066,3 +1066,3 @@

var glyph = this.charStrings.get(id);
const glyph = this.charStrings.get(id);
return glyph.length > 0;

@@ -1177,3 +1177,3 @@ }

var valueLength = value.length;
const valueLength = value.length;

@@ -1184,3 +1184,3 @@ if (valueLength === 0) {

for (var i = 0; i < valueLength; i++) {
for (let i = 0; i < valueLength; i++) {
if (isNaN(value[i])) {

@@ -1192,3 +1192,3 @@ (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');

var type = this.types[key];
const type = this.types[key];

@@ -1220,3 +1220,3 @@ if (type === "num" || type === "sid" || type === "offset") {

var key = this.nameToKeyMap[name];
const key = this.nameToKeyMap[name];

@@ -1235,3 +1235,3 @@ if (!(key in this.values)) {

static createTables(layout) {
var tables = {
const tables = {
keyToNameMap: {},

@@ -1245,5 +1245,5 @@ nameToKeyMap: {},

for (var i = 0, ii = layout.length; i < ii; ++i) {
var entry = layout[i];
var key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
for (let i = 0, ii = layout.length; i < ii; ++i) {
const entry = layout[i];
const key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
tables.keyToNameMap[key] = entry[1];

@@ -1262,5 +1262,5 @@ tables.nameToKeyMap[entry[1]] = key;

var CFFTopDict = function CFFTopDictClosure() {
var layout = [[[12, 30], "ROS", ["sid", "sid", "num"], null], [[12, 20], "SyntheticBase", "num", null], [0, "version", "sid", null], [1, "Notice", "sid", null], [[12, 0], "Copyright", "sid", null], [2, "FullName", "sid", null], [3, "FamilyName", "sid", null], [4, "Weight", "sid", null], [[12, 1], "isFixedPitch", "num", 0], [[12, 2], "ItalicAngle", "num", 0], [[12, 3], "UnderlinePosition", "num", -100], [[12, 4], "UnderlineThickness", "num", 50], [[12, 5], "PaintType", "num", 0], [[12, 6], "CharstringType", "num", 2], [[12, 7], "FontMatrix", ["num", "num", "num", "num", "num", "num"], [0.001, 0, 0, 0.001, 0, 0]], [13, "UniqueID", "num", null], [5, "FontBBox", ["num", "num", "num", "num"], [0, 0, 0, 0]], [[12, 8], "StrokeWidth", "num", 0], [14, "XUID", "array", null], [15, "charset", "offset", 0], [16, "Encoding", "offset", 0], [17, "CharStrings", "offset", 0], [18, "Private", ["offset", "offset"], null], [[12, 21], "PostScript", "sid", null], [[12, 22], "BaseFontName", "sid", null], [[12, 23], "BaseFontBlend", "delta", null], [[12, 31], "CIDFontVersion", "num", 0], [[12, 32], "CIDFontRevision", "num", 0], [[12, 33], "CIDFontType", "num", 0], [[12, 34], "CIDCount", "num", 8720], [[12, 35], "UIDBase", "num", null], [[12, 37], "FDSelect", "offset", null], [[12, 36], "FDArray", "offset", null], [[12, 38], "FontName", "sid", null]];
var tables = null;
const CFFTopDict = function CFFTopDictClosure() {
const layout = [[[12, 30], "ROS", ["sid", "sid", "num"], null], [[12, 20], "SyntheticBase", "num", null], [0, "version", "sid", null], [1, "Notice", "sid", null], [[12, 0], "Copyright", "sid", null], [2, "FullName", "sid", null], [3, "FamilyName", "sid", null], [4, "Weight", "sid", null], [[12, 1], "isFixedPitch", "num", 0], [[12, 2], "ItalicAngle", "num", 0], [[12, 3], "UnderlinePosition", "num", -100], [[12, 4], "UnderlineThickness", "num", 50], [[12, 5], "PaintType", "num", 0], [[12, 6], "CharstringType", "num", 2], [[12, 7], "FontMatrix", ["num", "num", "num", "num", "num", "num"], [0.001, 0, 0, 0.001, 0, 0]], [13, "UniqueID", "num", null], [5, "FontBBox", ["num", "num", "num", "num"], [0, 0, 0, 0]], [[12, 8], "StrokeWidth", "num", 0], [14, "XUID", "array", null], [15, "charset", "offset", 0], [16, "Encoding", "offset", 0], [17, "CharStrings", "offset", 0], [18, "Private", ["offset", "offset"], null], [[12, 21], "PostScript", "sid", null], [[12, 22], "BaseFontName", "sid", null], [[12, 23], "BaseFontBlend", "delta", null], [[12, 31], "CIDFontVersion", "num", 0], [[12, 32], "CIDFontRevision", "num", 0], [[12, 33], "CIDFontType", "num", 0], [[12, 34], "CIDCount", "num", 8720], [[12, 35], "UIDBase", "num", null], [[12, 37], "FDSelect", "offset", null], [[12, 36], "FDArray", "offset", null], [[12, 38], "FontName", "sid", null]];
let tables = null;

@@ -1284,5 +1284,5 @@ class CFFTopDict extends CFFDict {

var CFFPrivateDict = function CFFPrivateDictClosure() {
var layout = [[6, "BlueValues", "delta", null], [7, "OtherBlues", "delta", null], [8, "FamilyBlues", "delta", null], [9, "FamilyOtherBlues", "delta", null], [[12, 9], "BlueScale", "num", 0.039625], [[12, 10], "BlueShift", "num", 7], [[12, 11], "BlueFuzz", "num", 1], [10, "StdHW", "num", null], [11, "StdVW", "num", null], [[12, 12], "StemSnapH", "delta", null], [[12, 13], "StemSnapV", "delta", null], [[12, 14], "ForceBold", "num", 0], [[12, 17], "LanguageGroup", "num", 0], [[12, 18], "ExpansionFactor", "num", 0.06], [[12, 19], "initialRandomSeed", "num", 0], [20, "defaultWidthX", "num", 0], [21, "nominalWidthX", "num", 0], [19, "Subrs", "offset", null]];
var tables = null;
const CFFPrivateDict = function CFFPrivateDictClosure() {
const layout = [[6, "BlueValues", "delta", null], [7, "OtherBlues", "delta", null], [8, "FamilyBlues", "delta", null], [9, "FamilyOtherBlues", "delta", null], [[12, 9], "BlueScale", "num", 0.039625], [[12, 10], "BlueShift", "num", 7], [[12, 11], "BlueFuzz", "num", 1], [10, "StdHW", "num", null], [11, "StdVW", "num", null], [[12, 12], "StemSnapH", "delta", null], [[12, 13], "StemSnapV", "delta", null], [[12, 14], "ForceBold", "num", 0], [[12, 17], "LanguageGroup", "num", 0], [[12, 18], "ExpansionFactor", "num", 0.06], [[12, 19], "initialRandomSeed", "num", 0], [20, "defaultWidthX", "num", 0], [21, "nominalWidthX", "num", 0], [19, "Subrs", "offset", null]];
let tables = null;

@@ -1305,3 +1305,3 @@ class CFFPrivateDict extends CFFDict {

exports.CFFPrivateDict = CFFPrivateDict;
var CFFCharsetPredefinedTypes = {
const CFFCharsetPredefinedTypes = {
ISO_ADOBE: 0,

@@ -1370,3 +1370,3 @@ EXPERT: 1,

offset(value) {
for (var key in this.offsets) {
for (const key in this.offsets) {
this.offsets[key] += value;

@@ -1381,12 +1381,12 @@ }

var data = output.data;
var dataOffset = this.offsets[key];
var size = 5;
const data = output.data;
const dataOffset = this.offsets[key];
const size = 5;
for (var i = 0, ii = values.length; i < ii; ++i) {
var offset0 = i * size + dataOffset;
var offset1 = offset0 + 1;
var offset2 = offset0 + 2;
var offset3 = offset0 + 3;
var offset4 = offset0 + 4;
for (let i = 0, ii = values.length; i < ii; ++i) {
const offset0 = i * size + dataOffset;
const offset1 = offset0 + 1;
const offset2 = offset0 + 2;
const offset3 = offset0 + 3;
const offset4 = offset0 + 4;

@@ -1397,3 +1397,3 @@ if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {

var value = values[i];
const value = values[i];
data[offset0] = 0x1d;

@@ -1415,4 +1415,4 @@ data[offset1] = value >> 24 & 0xff;

compile() {
var cff = this.cff;
var output = {
const cff = this.cff;
const output = {
data: [],

@@ -1425,5 +1425,5 @@ length: 0,

};
var header = this.compileHeader(cff.header);
const header = this.compileHeader(cff.header);
output.add(header);
var nameIndex = this.compileNameIndex(cff.names);
const nameIndex = this.compileNameIndex(cff.names);
output.add(nameIndex);

@@ -1433,8 +1433,8 @@

if (cff.topDict.hasName("FontMatrix")) {
var base = cff.topDict.getByName("FontMatrix");
const base = cff.topDict.getByName("FontMatrix");
cff.topDict.removeByName("FontMatrix");
for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
var subDict = cff.fdArray[i];
var matrix = base.slice(0);
for (let i = 0, ii = cff.fdArray.length; i < ii; i++) {
const subDict = cff.fdArray[i];
let matrix = base.slice(0);

@@ -1457,8 +1457,8 @@ if (subDict.hasName("FontMatrix")) {

cff.topDict.setByName("charset", 0);
var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
let compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
output.add(compiled.output);
var topDictTracker = compiled.trackers[0];
var stringIndex = this.compileStringIndex(cff.strings.strings);
const topDictTracker = compiled.trackers[0];
const stringIndex = this.compileStringIndex(cff.strings.strings);
output.add(stringIndex);
var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
const globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
output.add(globalSubrIndex);

@@ -1470,3 +1470,3 @@

} else {
var encoding = this.compileEncoding(cff.encoding);
const encoding = this.compileEncoding(cff.encoding);
topDictTracker.setEntryLocation("Encoding", [output.length], output);

@@ -1477,6 +1477,6 @@ output.add(encoding);

var charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
const charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
topDictTracker.setEntryLocation("charset", [output.length], output);
output.add(charset);
var charStrings = this.compileCharStrings(cff.charStrings);
const charStrings = this.compileCharStrings(cff.charStrings);
topDictTracker.setEntryLocation("CharStrings", [output.length], output);

@@ -1487,3 +1487,3 @@ output.add(charStrings);

topDictTracker.setEntryLocation("FDSelect", [output.length], output);
var fdSelect = this.compileFDSelect(cff.fdSelect);
const fdSelect = this.compileFDSelect(cff.fdSelect);
output.add(fdSelect);

@@ -1493,3 +1493,3 @@ compiled = this.compileTopDicts(cff.fdArray, output.length, true);

output.add(compiled.output);
var fontDictTrackers = compiled.trackers;
const fontDictTrackers = compiled.trackers;
this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);

@@ -1516,15 +1516,15 @@ }

encodeFloat(num) {
var value = num.toString();
var m = CFFCompiler.EncodeFloatRegExp.exec(value);
let value = num.toString();
const m = CFFCompiler.EncodeFloatRegExp.exec(value);
if (m) {
var epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
const epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
value = (Math.round(num * epsilon) / epsilon).toString();
}
var nibbles = "";
var i, ii;
let nibbles = "";
let i, ii;
for (i = 0, ii = value.length; i < ii; ++i) {
var a = value[i];
const a = value[i];

@@ -1543,3 +1543,3 @@ if (a === "e") {

nibbles += nibbles.length & 1 ? "f" : "ff";
var out = [30];
const out = [30];

@@ -1554,3 +1554,3 @@ for (i = 0, ii = nibbles.length; i < ii; i += 2) {

encodeInteger(value) {
var code;
let code;

@@ -1575,15 +1575,15 @@ if (value >= -107 && value <= 107) {

compileHeader(header) {
return [header.major, header.minor, header.hdrSize, header.offSize];
return [header.major, header.minor, 4, header.offSize];
}
compileNameIndex(names) {
var nameIndex = new CFFIndex();
const nameIndex = new CFFIndex();
for (var i = 0, ii = names.length; i < ii; ++i) {
var name = names[i];
var length = Math.min(name.length, 127);
var sanitizedName = new Array(length);
for (let i = 0, ii = names.length; i < ii; ++i) {
const name = names[i];
const length = Math.min(name.length, 127);
let sanitizedName = new Array(length);
for (var j = 0; j < length; j++) {
var char = name[j];
for (let j = 0; j < length; j++) {
let char = name[j];

@@ -1610,7 +1610,7 @@ if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {

compileTopDicts(dicts, length, removeCidKeys) {
var fontDictTrackers = [];
var fdArrayIndex = new CFFIndex();
const fontDictTrackers = [];
let fdArrayIndex = new CFFIndex();
for (var i = 0, ii = dicts.length; i < ii; ++i) {
var fontDict = dicts[i];
for (let i = 0, ii = dicts.length; i < ii; ++i) {
const fontDict = dicts[i];

@@ -1625,4 +1625,4 @@ if (removeCidKeys) {

var fontDictTracker = new CFFOffsetTracker();
var fontDictData = this.compileDict(fontDict, fontDictTracker);
const fontDictTracker = new CFFOffsetTracker();
const fontDictData = this.compileDict(fontDict, fontDictTracker);
fontDictTrackers.push(fontDictTracker);

@@ -1641,5 +1641,5 @@ fdArrayIndex.add(fontDictData);

compilePrivateDicts(dicts, trackers, output) {
for (var i = 0, ii = dicts.length; i < ii; ++i) {
var fontDict = dicts[i];
var privateDict = fontDict.privateDict;
for (let i = 0, ii = dicts.length; i < ii; ++i) {
const fontDict = dicts[i];
const privateDict = fontDict.privateDict;

@@ -1650,5 +1650,5 @@ if (!privateDict || !fontDict.hasName("Private")) {

var privateDictTracker = new CFFOffsetTracker();
var privateDictData = this.compileDict(privateDict, privateDictTracker);
var outputLength = output.length;
const privateDictTracker = new CFFOffsetTracker();
const privateDictData = this.compileDict(privateDict, privateDictTracker);
let outputLength = output.length;
privateDictTracker.offset(outputLength);

@@ -1664,3 +1664,3 @@

if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
var subrs = this.compileIndex(privateDict.subrsIndex);
const subrs = this.compileIndex(privateDict.subrsIndex);
privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);

@@ -1673,7 +1673,7 @@ output.add(subrs);

compileDict(dict, offsetTracker) {
var out = [];
var order = dict.order;
let out = [];
const order = dict.order;
for (var i = 0; i < order.length; ++i) {
var key = order[i];
for (let i = 0; i < order.length; ++i) {
const key = order[i];

@@ -1684,4 +1684,4 @@ if (!(key in dict.values)) {

var values = dict.values[key];
var types = dict.types[key];
let values = dict.values[key];
let types = dict.types[key];

@@ -1700,5 +1700,5 @@ if (!Array.isArray(types)) {

for (var j = 0, jj = types.length; j < jj; ++j) {
var type = types[j];
var value = values[j];
for (let j = 0, jj = types.length; j < jj; ++j) {
const type = types[j];
const value = values[j];

@@ -1712,3 +1712,3 @@ switch (type) {

case "offset":
var name = dict.keyToNameMap[key];
const name = dict.keyToNameMap[key];

@@ -1726,3 +1726,3 @@ if (!offsetTracker.isTracking(name)) {

for (var k = 1, kk = values.length; k < kk; ++k) {
for (let k = 1, kk = values.length; k < kk; ++k) {
out = out.concat(this.encodeNumber(values[k]));

@@ -1745,5 +1745,5 @@ }

compileStringIndex(strings) {
var stringIndex = new CFFIndex();
const stringIndex = new CFFIndex();
for (var i = 0, ii = strings.length; i < ii; ++i) {
for (let i = 0, ii = strings.length; i < ii; ++i) {
stringIndex.add((0, _util.stringToBytes)(strings[i]));

@@ -1756,3 +1756,3 @@ }

compileGlobalSubrIndex() {
var globalSubrIndex = this.cff.globalSubrIndex;
const globalSubrIndex = this.cff.globalSubrIndex;
this.out.writeByteArray(this.compileIndex(globalSubrIndex));

@@ -1762,6 +1762,6 @@ }

compileCharStrings(charStrings) {
var charStringsIndex = new CFFIndex();
const charStringsIndex = new CFFIndex();
for (var i = 0; i < charStrings.count; i++) {
var glyph = charStrings.get(i);
for (let i = 0; i < charStrings.count; i++) {
const glyph = charStrings.get(i);

@@ -1863,5 +1863,5 @@ if (glyph.length === 0) {

compileTypedArray(data) {
var out = [];
const out = [];
for (var i = 0, ii = data.length; i < ii; ++i) {
for (let i = 0, ii = data.length; i < ii; ++i) {
out[i] = data[i];

@@ -1874,4 +1874,4 @@ }

compileIndex(index, trackers = []) {
var objects = index.objects;
var count = objects.length;
const objects = index.objects;
const count = objects.length;

@@ -1882,4 +1882,4 @@ if (count === 0) {

var data = [count >> 8 & 0xff, count & 0xff];
var lastOffset = 1,
const data = [count >> 8 & 0xff, count & 0xff];
let lastOffset = 1,
i;

@@ -1891,3 +1891,3 @@

var offsetSize;
let offsetSize;

@@ -1905,3 +1905,3 @@ if (lastOffset < 0x100) {

data.push(offsetSize);
var relativeOffset = 1;
let relativeOffset = 1;

@@ -1929,3 +1929,3 @@ for (i = 0; i < count + 1; i++) {

for (var j = 0, jj = objects[i].length; j < jj; j++) {
for (let j = 0, jj = objects[i].length; j < jj; j++) {
data.push(objects[i][j]);

@@ -1932,0 +1932,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -323,10 +323,10 @@ * Licensed under the Apache License, Version 2.0 (the "License");

function BinaryCMapStream(data) {
this.buffer = data;
this.pos = 0;
this.end = data.length;
this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
}
class BinaryCMapStream {
constructor(data) {
this.buffer = data;
this.pos = 0;
this.end = data.length;
this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
}
BinaryCMapStream.prototype = {
readByte() {

@@ -338,3 +338,3 @@ if (this.pos >= this.end) {

return this.buffer[this.pos++];
},
}

@@ -357,3 +357,3 @@ readNumber() {

return n;
},
}

@@ -363,3 +363,3 @@ readSigned() {

return n & 1 ? ~(n >>> 1) : n >>> 1;
},
}

@@ -369,3 +369,3 @@ readHex(num, size) {

this.pos += size + 1;
},
}

@@ -403,3 +403,3 @@ readHexNumber(num, size) {

}
},
}

@@ -415,3 +415,3 @@ readHexSigned(num, size) {

}
},
}

@@ -429,6 +429,6 @@ readString() {

};
}
function processBinaryCMap(data, cMap, extend) {
return new Promise(function (resolve, reject) {
class BinaryCMapReader {
async process(data, cMap, extend) {
var stream = new BinaryCMapStream(data);

@@ -467,3 +467,3 @@ var header = stream.readByte();

if (dataSize + 1 > MAX_NUM_SIZE) {
throw new Error("processBinaryCMap: Invalid dataSize.");
throw new Error("BinaryCMapReader.process: Invalid dataSize.");
}

@@ -601,4 +601,3 @@

default:
reject(new Error("processBinaryCMap: Unknown type: " + type));
return;
throw new Error(`BinaryCMapReader.process - unknown type: ${type}`);
}

@@ -608,15 +607,10 @@ }

if (useCMap) {
resolve(extend(useCMap));
return;
return extend(useCMap);
}
resolve(cMap);
});
return cMap;
}
}
function BinaryCMapReader() {}
BinaryCMapReader.prototype = {
process: processBinaryCMap
};
return BinaryCMapReader;

@@ -800,3 +794,3 @@ }();

function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
async function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
var previous;

@@ -870,61 +864,59 @@ var embeddedUseCMap;

return Promise.resolve(cMap);
return cMap;
}
function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
cMap.useCMap = newCMap;
async function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
cMap.useCMap = await createBuiltInCMap(useCMap, fetchBuiltInCMap);
if (cMap.numCodespaceRanges === 0) {
var useCodespaceRanges = cMap.useCMap.codespaceRanges;
if (cMap.numCodespaceRanges === 0) {
var useCodespaceRanges = cMap.useCMap.codespaceRanges;
for (var i = 0; i < useCodespaceRanges.length; i++) {
cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
}
for (var i = 0; i < useCodespaceRanges.length; i++) {
cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
}
cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
}
cMap.useCMap.forEach(function (key, value) {
if (!cMap.contains(key)) {
cMap.mapOne(key, cMap.useCMap.lookup(key));
}
cMap.useCMap.forEach(function (key, value) {
if (!cMap.contains(key)) {
cMap.mapOne(key, cMap.useCMap.lookup(key));
}
});
return cMap;
});
return cMap;
}
function createBuiltInCMap(name, fetchBuiltInCMap) {
async function createBuiltInCMap(name, fetchBuiltInCMap) {
if (name === "Identity-H") {
return Promise.resolve(new IdentityCMap(false, 2));
return new IdentityCMap(false, 2);
} else if (name === "Identity-V") {
return Promise.resolve(new IdentityCMap(true, 2));
return new IdentityCMap(true, 2);
}
if (!BUILT_IN_CMAPS.includes(name)) {
return Promise.reject(new Error("Unknown CMap name: " + name));
throw new Error("Unknown CMap name: " + name);
}
if (!fetchBuiltInCMap) {
return Promise.reject(new Error("Built-in CMap parameters are not provided."));
throw new Error("Built-in CMap parameters are not provided.");
}
return fetchBuiltInCMap(name).then(function (data) {
var cMapData = data.cMapData,
compressionType = data.compressionType;
var cMap = new CMap(true);
const {
cMapData,
compressionType
} = await fetchBuiltInCMap(name);
var cMap = new CMap(true);
if (compressionType === _util.CMapCompressionType.BINARY) {
return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
});
}
if (compressionType === _util.CMapCompressionType.BINARY) {
return new BinaryCMapReader().process(cMapData, cMap, useCMap => {
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
});
}
if (compressionType === _util.CMapCompressionType.NONE) {
var lexer = new _parser.Lexer(new _stream.Stream(cMapData));
return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
}
if (compressionType === _util.CMapCompressionType.NONE) {
var lexer = new _parser.Lexer(new _stream.Stream(cMapData));
return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
}
return Promise.reject(new Error("TODO: Only BINARY/NONE CMap compression is currently supported."));
});
throw new Error("TODO: Only BINARY/NONE CMap compression is currently supported.");
}

@@ -941,11 +933,9 @@

} else if ((0, _primitives.isStream)(encoding)) {
var cMap = new CMap();
var lexer = new _parser.Lexer(encoding);
return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
if (parsedCMap.isIdentityCMap) {
return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
}
const parsedCMap = await parseCMap(new CMap(), new _parser.Lexer(encoding), fetchBuiltInCMap, useCMap);
return parsedCMap;
});
if (parsedCMap.isIdentityCMap) {
return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
}
return parsedCMap;
}

@@ -952,0 +942,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -958,3 +958,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

if (x >= 6 / 29) {
result = x * x * x;
result = x ** 3;
} else {

@@ -961,0 +961,0 @@ result = 108 / 841 * (x - 4 / 29);

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -29,2 +29,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

exports.collectActions = collectActions;
exports.encodeToXmlString = encodeToXmlString;
exports.escapePDFName = escapePDFName;

@@ -104,7 +105,10 @@ exports.getArrayLookupTableFactory = getArrayLookupTableFactory;

}) {
const LOOP_LIMIT = 100;
let loopCount = 0;
let values;
const visited = new _primitives.RefSet();
while (dict) {
while (dict instanceof _primitives.Dict && !(dict.objId && visited.has(dict.objId))) {
if (dict.objId) {
visited.put(dict.objId);
}
const value = getArray ? dict.getArray(key) : dict.get(key);

@@ -124,7 +128,2 @@

if (++loopCount > LOOP_LIMIT) {
(0, _util.warn)(`getInheritableProperty: maximum loop count exceeded for "${key}"`);
break;
}
dict = dict.get("Parent");

@@ -279,21 +278,32 @@ }

const actions = Object.create(null);
const additionalActionsDicts = getInheritableProperty({
dict,
key: "AA",
stopWhenFound: false
});
if (dict.has("AA")) {
const additionalActions = dict.get("AA");
if (additionalActionsDicts) {
for (let i = additionalActionsDicts.length - 1; i >= 0; i--) {
const additionalActions = additionalActionsDicts[i];
for (const key of additionalActions.getKeys()) {
const action = eventType[key];
if (!action) {
if (!(additionalActions instanceof _primitives.Dict)) {
continue;
}
const actionDict = additionalActions.getRaw(key);
const parents = new _primitives.RefSet();
const list = [];
for (const key of additionalActions.getKeys()) {
const action = eventType[key];
_collectJS(actionDict, xref, list, parents);
if (!action) {
continue;
}
if (list.length > 0) {
actions[action] = list;
const actionDict = additionalActions.getRaw(key);
const parents = new _primitives.RefSet();
const list = [];
_collectJS(actionDict, xref, list, parents);
if (list.length > 0) {
actions[action] = list;
}
}

@@ -316,2 +326,54 @@ }

return (0, _util.objectSize)(actions) > 0 ? actions : null;
}
const XMLEntities = {
0x3c: "&lt;",
0x3e: "&gt;",
0x26: "&amp;",
0x22: "&quot;",
0x27: "&apos;"
};
function encodeToXmlString(str) {
const buffer = [];
let start = 0;
for (let i = 0, ii = str.length; i < ii; i++) {
const char = str.codePointAt(i);
if (0x20 <= char && char <= 0x7e) {
const entity = XMLEntities[char];
if (entity) {
if (start < i) {
buffer.push(str.substring(start, i));
}
buffer.push(entity);
start = i + 1;
}
} else {
if (start < i) {
buffer.push(str.substring(start, i));
}
buffer.push(`&#x${char.toString(16).toUpperCase()};`);
if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
i++;
}
start = i + 1;
}
}
if (buffer.length === 0) {
return str;
}
if (start < str.length) {
buffer.push(str.substring(start, str.length));
}
return buffer.join("");
}

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -28,3 +28,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.calculateSHA512 = exports.calculateSHA384 = exports.calculateSHA256 = exports.calculateMD5 = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = void 0;
exports.calculateSHA384 = calculateSHA384;
exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.calculateSHA512 = exports.calculateSHA256 = exports.calculateMD5 = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = void 0;

@@ -37,4 +38,4 @@ var _util = require("../shared/util.js");

var ARCFourCipher = function ARCFourCipherClosure() {
function ARCFourCipher(key) {
class ARCFourCipher {
constructor(key) {
this.a = 0;

@@ -62,33 +63,37 @@ this.b = 0;

ARCFourCipher.prototype = {
encryptBlock: function ARCFourCipher_encryptBlock(data) {
var i,
n = data.length,
tmp,
tmp2;
var a = this.a,
b = this.b,
s = this.s;
var output = new Uint8Array(n);
encryptBlock(data) {
var i,
n = data.length,
tmp,
tmp2;
var a = this.a,
b = this.b,
s = this.s;
var output = new Uint8Array(n);
for (i = 0; i < n; ++i) {
a = a + 1 & 0xff;
tmp = s[a];
b = b + tmp & 0xff;
tmp2 = s[b];
s[a] = tmp2;
s[b] = tmp;
output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
}
this.a = a;
this.b = b;
return output;
for (i = 0; i < n; ++i) {
a = a + 1 & 0xff;
tmp = s[a];
b = b + tmp & 0xff;
tmp2 = s[b];
s[a] = tmp2;
s[b] = tmp;
output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
}
};
ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
ARCFourCipher.prototype.encrypt = ARCFourCipher.prototype.encryptBlock;
return ARCFourCipher;
}();
this.a = a;
this.b = b;
return output;
}
decryptBlock(data) {
return this.encryptBlock(data);
}
encrypt(data) {
return this.encryptBlock(data);
}
}
exports.ARCFourCipher = ARCFourCipher;

@@ -180,4 +185,4 @@

var Word64 = function Word64Closure() {
function Word64(highInteger, lowInteger) {
class Word64 {
constructor(highInteger, lowInteger) {
this.high = highInteger | 0;

@@ -187,81 +192,88 @@ this.low = lowInteger | 0;

Word64.prototype = {
and: function Word64_and(word) {
this.high &= word.high;
this.low &= word.low;
},
xor: function Word64_xor(word) {
this.high ^= word.high;
this.low ^= word.low;
},
or: function Word64_or(word) {
this.high |= word.high;
this.low |= word.low;
},
shiftRight: function Word64_shiftRight(places) {
if (places >= 32) {
this.low = this.high >>> places - 32 | 0;
this.high = 0;
} else {
this.low = this.low >>> places | this.high << 32 - places;
this.high = this.high >>> places | 0;
}
},
shiftLeft: function Word64_shiftLeft(places) {
if (places >= 32) {
this.high = this.low << places - 32;
this.low = 0;
} else {
this.high = this.high << places | this.low >>> 32 - places;
this.low = this.low << places;
}
},
rotateRight: function Word64_rotateRight(places) {
var low, high;
and(word) {
this.high &= word.high;
this.low &= word.low;
}
if (places & 32) {
high = this.low;
low = this.high;
} else {
low = this.low;
high = this.high;
}
xor(word) {
this.high ^= word.high;
this.low ^= word.low;
}
places &= 31;
this.low = low >>> places | high << 32 - places;
this.high = high >>> places | low << 32 - places;
},
not: function Word64_not() {
this.high = ~this.high;
this.low = ~this.low;
},
add: function Word64_add(word) {
var lowAdd = (this.low >>> 0) + (word.low >>> 0);
var highAdd = (this.high >>> 0) + (word.high >>> 0);
or(word) {
this.high |= word.high;
this.low |= word.low;
}
if (lowAdd > 0xffffffff) {
highAdd += 1;
}
shiftRight(places) {
if (places >= 32) {
this.low = this.high >>> places - 32 | 0;
this.high = 0;
} else {
this.low = this.low >>> places | this.high << 32 - places;
this.high = this.high >>> places | 0;
}
}
this.low = lowAdd | 0;
this.high = highAdd | 0;
},
copyTo: function Word64_copyTo(bytes, offset) {
bytes[offset] = this.high >>> 24 & 0xff;
bytes[offset + 1] = this.high >> 16 & 0xff;
bytes[offset + 2] = this.high >> 8 & 0xff;
bytes[offset + 3] = this.high & 0xff;
bytes[offset + 4] = this.low >>> 24 & 0xff;
bytes[offset + 5] = this.low >> 16 & 0xff;
bytes[offset + 6] = this.low >> 8 & 0xff;
bytes[offset + 7] = this.low & 0xff;
},
assign: function Word64_assign(word) {
this.high = word.high;
this.low = word.low;
shiftLeft(places) {
if (places >= 32) {
this.high = this.low << places - 32;
this.low = 0;
} else {
this.high = this.high << places | this.low >>> 32 - places;
this.low = this.low << places;
}
};
return Word64;
}();
}
rotateRight(places) {
var low, high;
if (places & 32) {
high = this.low;
low = this.high;
} else {
low = this.low;
high = this.high;
}
places &= 31;
this.low = low >>> places | high << 32 - places;
this.high = high >>> places | low << 32 - places;
}
not() {
this.high = ~this.high;
this.low = ~this.low;
}
add(word) {
var lowAdd = (this.low >>> 0) + (word.low >>> 0);
var highAdd = (this.high >>> 0) + (word.high >>> 0);
if (lowAdd > 0xffffffff) {
highAdd += 1;
}
this.low = lowAdd | 0;
this.high = highAdd | 0;
}
copyTo(bytes, offset) {
bytes[offset] = this.high >>> 24 & 0xff;
bytes[offset + 1] = this.high >> 16 & 0xff;
bytes[offset + 2] = this.high >> 8 & 0xff;
bytes[offset + 3] = this.high & 0xff;
bytes[offset + 4] = this.low >>> 24 & 0xff;
bytes[offset + 5] = this.low >> 16 & 0xff;
bytes[offset + 6] = this.low >> 8 & 0xff;
bytes[offset + 7] = this.low & 0xff;
}
assign(word) {
this.high = word.high;
this.low = word.low;
}
}
var calculateSHA256 = function calculateSHA256Closure() {

@@ -451,4 +463,3 @@ function rotr(x, n) {

function hash(data, offset, length, mode384) {
mode384 = !!mode384;
function hash(data, offset, length, mode384 = false) {
var h0, h1, h2, h3, h4, h5, h6, h7;

@@ -617,26 +628,17 @@

var calculateSHA384 = function calculateSHA384Closure() {
function hash(data, offset, length) {
return calculateSHA512(data, offset, length, true);
function calculateSHA384(data, offset, length) {
return calculateSHA512(data, offset, length, true);
}
class NullCipher {
decryptBlock(data) {
return data;
}
return hash;
}();
encrypt(data) {
return data;
}
exports.calculateSHA384 = calculateSHA384;
}
var NullCipher = function NullCipherClosure() {
function NullCipher() {}
NullCipher.prototype = {
decryptBlock: function NullCipher_decryptBlock(data) {
return data;
},
encrypt: function NullCipher_encrypt(data) {
return data;
}
};
return NullCipher;
}();
class AESBaseCipher {

@@ -1070,55 +1072,40 @@ constructor() {

var PDF17 = function PDF17Closure() {
function compareByteArrays(array1, array2) {
if (array1.length !== array2.length) {
return false;
}
class PDF17 {
checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
var hashData = new Uint8Array(password.length + 56);
hashData.set(password, 0);
hashData.set(ownerValidationSalt, password.length);
hashData.set(userBytes, password.length + ownerValidationSalt.length);
var result = calculateSHA256(hashData, 0, hashData.length);
return (0, _util.isArrayEqual)(result, ownerPassword);
}
for (var i = 0; i < array1.length; i++) {
if (array1[i] !== array2[i]) {
return false;
}
}
checkUserPassword(password, userValidationSalt, userPassword) {
var hashData = new Uint8Array(password.length + 8);
hashData.set(password, 0);
hashData.set(userValidationSalt, password.length);
var result = calculateSHA256(hashData, 0, hashData.length);
return (0, _util.isArrayEqual)(result, userPassword);
}
return true;
getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
var hashData = new Uint8Array(password.length + 56);
hashData.set(password, 0);
hashData.set(ownerKeySalt, password.length);
hashData.set(userBytes, password.length + ownerKeySalt.length);
var key = calculateSHA256(hashData, 0, hashData.length);
var cipher = new AES256Cipher(key);
return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
}
function PDF17() {}
getUserKey(password, userKeySalt, userEncryption) {
var hashData = new Uint8Array(password.length + 8);
hashData.set(password, 0);
hashData.set(userKeySalt, password.length);
var key = calculateSHA256(hashData, 0, hashData.length);
var cipher = new AES256Cipher(key);
return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
}
PDF17.prototype = {
checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
var hashData = new Uint8Array(password.length + 56);
hashData.set(password, 0);
hashData.set(ownerValidationSalt, password.length);
hashData.set(userBytes, password.length + ownerValidationSalt.length);
var result = calculateSHA256(hashData, 0, hashData.length);
return compareByteArrays(result, ownerPassword);
},
checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
var hashData = new Uint8Array(password.length + 8);
hashData.set(password, 0);
hashData.set(userValidationSalt, password.length);
var result = calculateSHA256(hashData, 0, hashData.length);
return compareByteArrays(result, userPassword);
},
getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
var hashData = new Uint8Array(password.length + 56);
hashData.set(password, 0);
hashData.set(ownerKeySalt, password.length);
hashData.set(userBytes, password.length + ownerKeySalt.length);
var key = calculateSHA256(hashData, 0, hashData.length);
var cipher = new AES256Cipher(key);
return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
},
getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
var hashData = new Uint8Array(password.length + 8);
hashData.set(password, 0);
hashData.set(userKeySalt, password.length);
var key = calculateSHA256(hashData, 0, hashData.length);
var cipher = new AES256Cipher(key);
return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
}
};
return PDF17;
}();
}

@@ -1128,9 +1115,2 @@ exports.PDF17 = PDF17;

var PDF20 = function PDF20Closure() {
function concatArrays(array1, array2) {
var t = new Uint8Array(array1.length + array2.length);
t.set(array1, 0);
t.set(array2, array1.length);
return t;
}
function calculatePDF20Hash(password, input, userBytes) {

@@ -1142,9 +1122,14 @@ var k = calculateSHA256(input, 0, input.length).subarray(0, 32);

while (i < 64 || e[e.length - 1] > i - 32) {
var arrayLength = password.length + k.length + userBytes.length;
var k1 = new Uint8Array(arrayLength * 64);
var array = concatArrays(password, k);
array = concatArrays(array, userBytes);
const combinedLength = password.length + k.length + userBytes.length,
combinedArray = new Uint8Array(combinedLength);
let writeOffset = 0;
combinedArray.set(password, writeOffset);
writeOffset += password.length;
combinedArray.set(k, writeOffset);
writeOffset += k.length;
combinedArray.set(userBytes, writeOffset);
var k1 = new Uint8Array(combinedLength * 64);
for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
k1.set(array, pos);
for (var j = 0, pos = 0; j < 64; j++, pos += combinedLength) {
k1.set(combinedArray, pos);
}

@@ -1177,23 +1162,8 @@

function PDF20() {}
function compareByteArrays(array1, array2) {
if (array1.length !== array2.length) {
return false;
class PDF20 {
hash(password, concatBytes, userBytes) {
return calculatePDF20Hash(password, concatBytes, userBytes);
}
for (var i = 0; i < array1.length; i++) {
if (array1[i] !== array2[i]) {
return false;
}
}
return true;
}
PDF20.prototype = {
hash: function PDF20_hash(password, concatBytes, userBytes) {
return calculatePDF20Hash(password, concatBytes, userBytes);
},
checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
var hashData = new Uint8Array(password.length + 56);

@@ -1204,5 +1174,6 @@ hashData.set(password, 0);

var result = calculatePDF20Hash(password, hashData, userBytes);
return compareByteArrays(result, ownerPassword);
},
checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
return (0, _util.isArrayEqual)(result, ownerPassword);
}
checkUserPassword(password, userValidationSalt, userPassword) {
var hashData = new Uint8Array(password.length + 8);

@@ -1212,5 +1183,6 @@ hashData.set(password, 0);

var result = calculatePDF20Hash(password, hashData, []);
return compareByteArrays(result, userPassword);
},
getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
return (0, _util.isArrayEqual)(result, userPassword);
}
getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
var hashData = new Uint8Array(password.length + 56);

@@ -1223,4 +1195,5 @@ hashData.set(password, 0);

return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
},
getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
}
getUserKey(password, userKeySalt, userEncryption) {
var hashData = new Uint8Array(password.length + 8);

@@ -1233,3 +1206,5 @@ hashData.set(password, 0);

}
};
}
return PDF20;

@@ -1240,4 +1215,4 @@ }();

var CipherTransform = function CipherTransformClosure() {
function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
class CipherTransform {
constructor(stringCipherConstructor, streamCipherConstructor) {
this.StringCipherConstructor = stringCipherConstructor;

@@ -1247,52 +1222,52 @@ this.StreamCipherConstructor = streamCipherConstructor;

CipherTransform.prototype = {
createStream: function CipherTransform_createStream(stream, length) {
var cipher = new this.StreamCipherConstructor();
return new _stream.DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
return cipher.decryptBlock(data, finalize);
});
},
decryptString: function CipherTransform_decryptString(s) {
var cipher = new this.StringCipherConstructor();
var data = (0, _util.stringToBytes)(s);
data = cipher.decryptBlock(data, true);
return (0, _util.bytesToString)(data);
},
encryptString: function CipherTransform_encryptString(s) {
const cipher = new this.StringCipherConstructor();
createStream(stream, length) {
var cipher = new this.StreamCipherConstructor();
return new _stream.DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
return cipher.decryptBlock(data, finalize);
});
}
if (cipher instanceof AESBaseCipher) {
const strLen = s.length;
const pad = 16 - strLen % 16;
decryptString(s) {
var cipher = new this.StringCipherConstructor();
var data = (0, _util.stringToBytes)(s);
data = cipher.decryptBlock(data, true);
return (0, _util.bytesToString)(data);
}
if (pad !== 16) {
s = s.padEnd(16 * Math.ceil(strLen / 16), String.fromCharCode(pad));
}
encryptString(s) {
const cipher = new this.StringCipherConstructor();
const iv = new Uint8Array(16);
if (cipher instanceof AESBaseCipher) {
const strLen = s.length;
const pad = 16 - strLen % 16;
if (typeof crypto !== "undefined") {
crypto.getRandomValues(iv);
} else {
for (let i = 0; i < 16; i++) {
iv[i] = Math.floor(256 * Math.random());
}
if (pad !== 16) {
s = s.padEnd(16 * Math.ceil(strLen / 16), String.fromCharCode(pad));
}
const iv = new Uint8Array(16);
if (typeof crypto !== "undefined") {
crypto.getRandomValues(iv);
} else {
for (let i = 0; i < 16; i++) {
iv[i] = Math.floor(256 * Math.random());
}
let data = (0, _util.stringToBytes)(s);
data = cipher.encrypt(data, iv);
const buf = new Uint8Array(16 + data.length);
buf.set(iv);
buf.set(data, 16);
return (0, _util.bytesToString)(buf);
}
let data = (0, _util.stringToBytes)(s);
data = cipher.encrypt(data);
return (0, _util.bytesToString)(data);
data = cipher.encrypt(data, iv);
const buf = new Uint8Array(16 + data.length);
buf.set(iv);
buf.set(data, 16);
return (0, _util.bytesToString)(buf);
}
};
return CipherTransform;
}();
let data = (0, _util.stringToBytes)(s);
data = cipher.encrypt(data);
return (0, _util.bytesToString)(data);
}
}
var CipherTransformFactory = function CipherTransformFactoryClosure() {

@@ -1473,107 +1448,3 @@ var defaultPasswordBytes = new Uint8Array([0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A]);

function CipherTransformFactory(dict, fileId, password) {
var filter = dict.get("Filter");
if (!(0, _primitives.isName)(filter, "Standard")) {
throw new _util.FormatError("unknown encryption method");
}
this.dict = dict;
var algorithm = dict.get("V");
if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
throw new _util.FormatError("unsupported encryption algorithm");
}
this.algorithm = algorithm;
var keyLength = dict.get("Length");
if (!keyLength) {
if (algorithm <= 3) {
keyLength = 40;
} else {
var cfDict = dict.get("CF");
var streamCryptoName = dict.get("StmF");
if ((0, _primitives.isDict)(cfDict) && (0, _primitives.isName)(streamCryptoName)) {
cfDict.suppressEncryption = true;
var handlerDict = cfDict.get(streamCryptoName.name);
keyLength = handlerDict && handlerDict.get("Length") || 128;
if (keyLength < 40) {
keyLength <<= 3;
}
}
}
}
if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
throw new _util.FormatError("invalid key length");
}
var ownerPassword = (0, _util.stringToBytes)(dict.get("O")).subarray(0, 32);
var userPassword = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 32);
var flags = dict.get("P");
var revision = dict.get("R");
var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
this.encryptMetadata = encryptMetadata;
var fileIdBytes = (0, _util.stringToBytes)(fileId);
var passwordBytes;
if (password) {
if (revision === 6) {
try {
password = (0, _util.utf8StringToString)(password);
} catch (ex) {
(0, _util.warn)("CipherTransformFactory: " + "Unable to convert UTF8 encoded password.");
}
}
passwordBytes = (0, _util.stringToBytes)(password);
}
var encryptionKey;
if (algorithm !== 5) {
encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
} else {
var ownerValidationSalt = (0, _util.stringToBytes)(dict.get("O")).subarray(32, 40);
var ownerKeySalt = (0, _util.stringToBytes)(dict.get("O")).subarray(40, 48);
var uBytes = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 48);
var userValidationSalt = (0, _util.stringToBytes)(dict.get("U")).subarray(32, 40);
var userKeySalt = (0, _util.stringToBytes)(dict.get("U")).subarray(40, 48);
var ownerEncryption = (0, _util.stringToBytes)(dict.get("OE"));
var userEncryption = (0, _util.stringToBytes)(dict.get("UE"));
var perms = (0, _util.stringToBytes)(dict.get("Perms"));
encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
}
if (!encryptionKey && !password) {
throw new _util.PasswordException("No password given", _util.PasswordResponses.NEED_PASSWORD);
} else if (!encryptionKey && password) {
var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
}
if (!encryptionKey) {
throw new _util.PasswordException("Incorrect Password", _util.PasswordResponses.INCORRECT_PASSWORD);
}
this.encryptionKey = encryptionKey;
if (algorithm >= 4) {
var cf = dict.get("CF");
if ((0, _primitives.isDict)(cf)) {
cf.suppressEncryption = true;
}
this.cf = cf;
this.stmf = dict.get("StmF") || identityName;
this.strf = dict.get("StrF") || identityName;
this.eff = dict.get("EFF") || this.stmf;
}
}
function buildObjectKey(num, gen, encryptionKey, isAes) {
function buildObjectKey(num, gen, encryptionKey, isAes = false) {
var key = new Uint8Array(encryptionKey.length + 9),

@@ -1643,4 +1514,108 @@ i,

CipherTransformFactory.prototype = {
createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
class CipherTransformFactory {
constructor(dict, fileId, password) {
var filter = dict.get("Filter");
if (!(0, _primitives.isName)(filter, "Standard")) {
throw new _util.FormatError("unknown encryption method");
}
this.dict = dict;
var algorithm = dict.get("V");
if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
throw new _util.FormatError("unsupported encryption algorithm");
}
this.algorithm = algorithm;
var keyLength = dict.get("Length");
if (!keyLength) {
if (algorithm <= 3) {
keyLength = 40;
} else {
var cfDict = dict.get("CF");
var streamCryptoName = dict.get("StmF");
if ((0, _primitives.isDict)(cfDict) && (0, _primitives.isName)(streamCryptoName)) {
cfDict.suppressEncryption = true;
var handlerDict = cfDict.get(streamCryptoName.name);
keyLength = handlerDict && handlerDict.get("Length") || 128;
if (keyLength < 40) {
keyLength <<= 3;
}
}
}
}
if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
throw new _util.FormatError("invalid key length");
}
var ownerPassword = (0, _util.stringToBytes)(dict.get("O")).subarray(0, 32);
var userPassword = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 32);
var flags = dict.get("P");
var revision = dict.get("R");
var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
this.encryptMetadata = encryptMetadata;
var fileIdBytes = (0, _util.stringToBytes)(fileId);
var passwordBytes;
if (password) {
if (revision === 6) {
try {
password = (0, _util.utf8StringToString)(password);
} catch (ex) {
(0, _util.warn)("CipherTransformFactory: " + "Unable to convert UTF8 encoded password.");
}
}
passwordBytes = (0, _util.stringToBytes)(password);
}
var encryptionKey;
if (algorithm !== 5) {
encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
} else {
var ownerValidationSalt = (0, _util.stringToBytes)(dict.get("O")).subarray(32, 40);
var ownerKeySalt = (0, _util.stringToBytes)(dict.get("O")).subarray(40, 48);
var uBytes = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 48);
var userValidationSalt = (0, _util.stringToBytes)(dict.get("U")).subarray(32, 40);
var userKeySalt = (0, _util.stringToBytes)(dict.get("U")).subarray(40, 48);
var ownerEncryption = (0, _util.stringToBytes)(dict.get("OE"));
var userEncryption = (0, _util.stringToBytes)(dict.get("UE"));
var perms = (0, _util.stringToBytes)(dict.get("Perms"));
encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
}
if (!encryptionKey && !password) {
throw new _util.PasswordException("No password given", _util.PasswordResponses.NEED_PASSWORD);
} else if (!encryptionKey && password) {
var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
}
if (!encryptionKey) {
throw new _util.PasswordException("Incorrect Password", _util.PasswordResponses.INCORRECT_PASSWORD);
}
this.encryptionKey = encryptionKey;
if (algorithm >= 4) {
var cf = dict.get("CF");
if ((0, _primitives.isDict)(cf)) {
cf.suppressEncryption = true;
}
this.cf = cf;
this.stmf = dict.get("StmF") || identityName;
this.strf = dict.get("StrF") || identityName;
this.eff = dict.get("EFF") || this.stmf;
}
}
createCipherTransform(num, gen) {
if (this.algorithm === 4 || this.algorithm === 5) {

@@ -1658,3 +1633,5 @@ return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));

}
};
}
return CipherTransformFactory;

@@ -1661,0 +1638,0 @@ }();

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -31,4 +31,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _primitives = require("./primitives.js");
var _util = require("../shared/util.js");

@@ -42,2 +40,4 @@

var _primitives = require("./primitives.js");
var _stream = require("./stream.js");

@@ -57,4 +57,4 @@

fontSize: 0,
fontName: _primitives.Name.get(""),
fontColor: new Uint8ClampedArray([0, 0, 0])
fontName: "",
fontColor: new Uint8ClampedArray(3)
};

@@ -83,4 +83,4 @@

if ((0, _primitives.isName)(fontName)) {
result.fontName = fontName;
if (fontName instanceof _primitives.Name) {
result.fontName = fontName.name;
}

@@ -136,3 +136,3 @@

return `/${(0, _core_utils.escapePDFName)(fontName.name)} ${fontSize} Tf ${colorCmd}`;
return `/${(0, _core_utils.escapePDFName)(fontName)} ${fontSize} Tf ${colorCmd}`;
}

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -50,2 +50,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _factory = require("./xfa/factory.js");
const DEFAULT_USER_UNIT = 1.0;

@@ -69,3 +71,4 @@ const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];

globalImageCache,
nonBlendModesSet
nonBlendModesSet,
xfaFactory
}) {

@@ -83,2 +86,3 @@ this.pdfManager = pdfManager;

this.resourcesPromise = null;
this.xfaFactory = xfaFactory;
const idCounters = {

@@ -126,2 +130,10 @@ obj: 0

_getBoundingBox(name) {
if (this.xfaData) {
const {
width,
height
} = this.xfaData.attributes.style;
return [0, 0, parseInt(width), parseInt(height)];
}
const box = this._getInheritableProperty(name, true);

@@ -216,2 +228,10 @@

get xfaData() {
if (this.xfaFactory) {
return (0, _util.shadow)(this, "xfaData", this.xfaFactory.getPage(this.pageIndex));
}
return (0, _util.shadow)(this, "xfaData", null);
}
save(handler, task, annotationStorage) {

@@ -386,3 +406,3 @@ const partialEvaluator = new _evaluator.PartialEvaluator({

for (const annotationRef of this.annotations) {
annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this._localIdFactory).catch(function (reason) {
annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this._localIdFactory, false).catch(function (reason) {
(0, _util.warn)(`_parsedAnnotations: "${reason}".`);

@@ -613,2 +633,6 @@ return null;

get numPages() {
if (this.xfaFactory) {
return (0, _util.shadow)(this, "numPages", this.xfaFactory.numberPages);
}
const linearization = this.linearization;

@@ -649,2 +673,80 @@ const num = linearization ? linearization.numPages : this.catalog.numPages;

get xfaData() {
const acroForm = this.catalog.acroForm;
if (!acroForm) {
return null;
}
const xfa = acroForm.get("XFA");
const entries = {
"xdp:xdp": "",
template: "",
datasets: "",
config: "",
connectionSet: "",
localeSet: "",
stylesheet: "",
"/xdp:xdp": ""
};
if ((0, _primitives.isStream)(xfa) && !xfa.isEmpty) {
try {
entries["xdp:xdp"] = (0, _util.stringToUTF8String)((0, _util.bytesToString)(xfa.getBytes()));
return entries;
} catch (_) {
(0, _util.warn)("XFA - Invalid utf-8 string.");
return null;
}
}
if (!Array.isArray(xfa) || xfa.length === 0) {
return null;
}
for (let i = 0, ii = xfa.length; i < ii; i += 2) {
let name;
if (i === 0) {
name = "xdp:xdp";
} else if (i === ii - 2) {
name = "/xdp:xdp";
} else {
name = xfa[i];
}
if (!entries.hasOwnProperty(name)) {
continue;
}
const data = this.xref.fetchIfRef(xfa[i + 1]);
if (!(0, _primitives.isStream)(data) || data.isEmpty) {
continue;
}
try {
entries[name] = (0, _util.stringToUTF8String)((0, _util.bytesToString)(data.getBytes()));
} catch (_) {
(0, _util.warn)("XFA - Invalid utf-8 string.");
return null;
}
}
return entries;
}
get xfaFactory() {
if (this.pdfManager.enableXfa && this.formInfo.hasXfa && !this.formInfo.hasAcroForm) {
const data = this.xfaData;
return (0, _util.shadow)(this, "xfaFactory", data ? new _factory.XFAFactory(data) : null);
}
return (0, _util.shadow)(this, "xfaFaxtory", null);
}
get isPureXfa() {
return this.xfaFactory !== null;
}
get formInfo() {

@@ -809,2 +911,19 @@ const formInfo = {

} = this;
if (this.xfaFactory) {
return Promise.resolve(new Page({
pdfManager: this.pdfManager,
xref: this.xref,
pageIndex,
pageDict: _primitives.Dict.empty,
ref: null,
globalIdFactory: this._globalIdFactory,
fontCache: catalog.fontCache,
builtInCMapCache: catalog.builtInCMapCache,
globalImageCache: catalog.globalImageCache,
nonBlendModesSet: catalog.nonBlendModesSet,
xfaFactory: this.xfaFactory
}));
}
const promise = linearization && linearization.pageFirst === pageIndex ? this._getLinearizationPage(pageIndex) : catalog.getPageDict(pageIndex);

@@ -822,3 +941,4 @@ return this._pagePromises[pageIndex] = promise.then(([pageDict, ref]) => {

globalImageCache: catalog.globalImageCache,
nonBlendModesSet: catalog.nonBlendModesSet
nonBlendModesSet: catalog.nonBlendModesSet,
xfaFactory: null
});

@@ -863,3 +983,3 @@ });

promises.get(name).push(_annotation.AnnotationFactory.create(this.xref, fieldRef, this.pdfManager, this._localIdFactory).then(annotation => annotation && annotation.getFieldObject()).catch(function (reason) {
promises.get(name).push(_annotation.AnnotationFactory.create(this.xref, fieldRef, this.pdfManager, this._localIdFactory, true).then(annotation => annotation && annotation.getFieldObject()).catch(function (reason) {
(0, _util.warn)(`_collectFieldObjects: "${reason}".`);

@@ -866,0 +986,0 @@ return null;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -40,3 +40,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var FontRendererFactory = function FontRendererFactoryClosure() {
const FontRendererFactory = function FontRendererFactoryClosure() {
function getLong(data, offset) {

@@ -64,9 +64,9 @@ return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];

function parseCmap(data, start, end) {
var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
var format = getUshort(data, start + offset);
var ranges, p, i;
const offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
const format = getUshort(data, start + offset);
let ranges, p, i;
if (format === 4) {
getUshort(data, start + offset + 2);
var segCount = getUshort(data, start + offset + 6) >> 1;
const segCount = getUshort(data, start + offset + 6) >> 1;
p = start + offset + 14;

@@ -92,3 +92,3 @@ ranges = [];

for (i = 0; i < segCount; i++, p += 2) {
var idOffset = getUshort(data, p);
let idOffset = getUshort(data, p);

@@ -101,3 +101,3 @@ if (idOffset === 0) {

for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
for (let j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
ranges[i].ids[j] = getUshort(data, p + idOffset);

@@ -111,3 +111,3 @@ idOffset += 2;

getLong(data, start + offset + 4);
var groups = getLong(data, start + offset + 12);
const groups = getLong(data, start + offset + 12);
p = start + offset + 16;

@@ -132,5 +132,5 @@ ranges = [];

function parseCff(data, start, end, seacAnalysisEnabled) {
var properties = {};
var parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
var cff = parser.parse();
const properties = {};
const parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
const cff = parser.parse();
return {

@@ -147,3 +147,3 @@ glyphs: cff.charStrings.objects,

function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
var itemSize, itemDecode;
let itemSize, itemDecode;

@@ -164,7 +164,7 @@ if (isGlyphLocationsLong) {

var glyphs = [];
var startOffset = itemDecode(loca, 0);
const glyphs = [];
let startOffset = itemDecode(loca, 0);
for (var j = itemSize; j < loca.length; j += itemSize) {
var endOffset = itemDecode(loca, j);
for (let j = itemSize; j < loca.length; j += itemSize) {
const endOffset = itemDecode(loca, j);
glyphs.push(glyf.subarray(startOffset, endOffset));

@@ -178,9 +178,9 @@ startOffset = endOffset;

function lookupCmap(ranges, unicode) {
var code = unicode.codePointAt(0),
gid = 0;
var l = 0,
const code = unicode.codePointAt(0);
let gid = 0,
l = 0,
r = ranges.length - 1;
while (l < r) {
var c = l + r + 1 >> 1;
const c = l + r + 1 >> 1;

@@ -226,6 +226,6 @@ if (code < ranges[c].start) {

var i = 0;
var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
var flags;
var x = 0,
let i = 0;
const numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
let flags;
let x = 0,
y = 0;

@@ -237,5 +237,5 @@ i += 10;

flags = code[i] << 8 | code[i + 1];
var glyphIndex = code[i + 2] << 8 | code[i + 3];
const glyphIndex = code[i + 2] << 8 | code[i + 3];
i += 4;
var arg1, arg2;
let arg1, arg2;

@@ -259,3 +259,3 @@ if (flags & 0x01) {

var scaleX = 1,
let scaleX = 1,
scaleY = 1,

@@ -280,3 +280,3 @@ scale01 = 0,

var subglyph = font.glyphs[glyphIndex];
const subglyph = font.glyphs[glyphIndex];

@@ -298,4 +298,4 @@ if (subglyph) {

} else {
var endPtsOfContours = [];
var j, jj;
const endPtsOfContours = [];
let j, jj;

@@ -307,10 +307,10 @@ for (j = 0; j < numberOfContours; j++) {

var instructionLength = code[i] << 8 | code[i + 1];
const instructionLength = code[i] << 8 | code[i + 1];
i += 2 + instructionLength;
var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
var points = [];
const numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
const points = [];
while (points.length < numberOfPoints) {
flags = code[i++];
var repeat = 1;
let repeat = 1;

@@ -366,7 +366,7 @@ if (flags & 0x08) {

var startPoint = 0;
let startPoint = 0;
for (i = 0; i < numberOfContours; i++) {
var endPoint = endPtsOfContours[i];
var contour = points.slice(startPoint, endPoint + 1);
const endPoint = endPtsOfContours[i];
const contour = points.slice(startPoint, endPoint + 1);

@@ -378,3 +378,3 @@ if (contour[0].flags & 1) {

} else {
var p = {
const p = {
flags: 1,

@@ -428,14 +428,14 @@ x: (contour[0].x + contour[contour.length - 1].x) / 2,

var stack = [];
var x = 0,
const stack = [];
let x = 0,
y = 0;
var stems = 0;
let stems = 0;
function parse(code) {
var i = 0;
let i = 0;
while (i < code.length) {
var stackClean = false;
var v = code[i++];
var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
let stackClean = false;
let v = code[i++];
let xa, xb, ya, yb, y1, y2, y3, n, subrCode;

@@ -595,4 +595,4 @@ switch (v) {

case 37:
var x0 = x,
y0 = y;
const x0 = x,
y0 = y;
xa = x + stack.shift();

@@ -629,4 +629,4 @@ ya = y + stack.shift();

if (stack.length >= 4) {
var achar = stack.pop();
var bchar = stack.pop();
const achar = stack.pop();
const bchar = stack.pop();
y = stack.pop();

@@ -641,3 +641,3 @@ x = stack.pop();

});
var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
let cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);

@@ -960,10 +960,10 @@ cmds.push({

create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
var data = new Uint8Array(font.data);
var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
var numTables = getUshort(data, 4);
const data = new Uint8Array(font.data);
let cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
const numTables = getUshort(data, 4);
for (var i = 0, p = 12; i < numTables; i++, p += 16) {
var tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
var offset = getLong(data, p + 8);
var length = getLong(data, p + 12);
for (let i = 0, p = 12; i < numTables; i++, p += 16) {
const tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
const offset = getLong(data, p + 8);
const length = getLong(data, p + 12);

@@ -995,3 +995,3 @@ switch (tag) {

if (glyf) {
var fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
const fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);

@@ -998,0 +998,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -674,8 +674,8 @@ * Licensed under the Apache License, Version 2.0 (the "License");

function PostScriptStack(initialStack) {
this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
}
class PostScriptStack {
constructor(initialStack) {
this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
}
PostScriptStack.prototype = {
push: function PostScriptStack_push(value) {
push(value) {
if (this.stack.length >= MAX_STACK_SIZE) {

@@ -686,4 +686,5 @@ throw new Error("PostScript function stack overflow.");

this.stack.push(value);
},
pop: function PostScriptStack_pop() {
}
pop() {
if (this.stack.length <= 0) {

@@ -694,4 +695,5 @@ throw new Error("PostScript function stack underflow.");

return this.stack.pop();
},
copy: function PostScriptStack_copy(n) {
}
copy(n) {
if (this.stack.length + n >= MAX_STACK_SIZE) {

@@ -706,7 +708,9 @@ throw new Error("PostScript function stack overflow.");

}
},
index: function PostScriptStack_index(n) {
}
index(n) {
this.push(this.stack[this.stack.length - n - 1]);
},
roll: function PostScriptStack_roll(n, p) {
}
roll(n, p) {
var stack = this.stack;

@@ -738,402 +742,411 @@ var l = stack.length - n;

}
};
}
return PostScriptStack;
}();
var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
function PostScriptEvaluator(operators) {
class PostScriptEvaluator {
constructor(operators) {
this.operators = operators;
}
PostScriptEvaluator.prototype = {
execute: function PostScriptEvaluator_execute(initialStack) {
var stack = new PostScriptStack(initialStack);
var counter = 0;
var operators = this.operators;
var length = operators.length;
var operator, a, b;
execute(initialStack) {
var stack = new PostScriptStack(initialStack);
var counter = 0;
var operators = this.operators;
var length = operators.length;
var operator, a, b;
while (counter < length) {
operator = operators[counter++];
while (counter < length) {
operator = operators[counter++];
if (typeof operator === "number") {
stack.push(operator);
continue;
}
if (typeof operator === "number") {
stack.push(operator);
continue;
}
switch (operator) {
case "jz":
b = stack.pop();
a = stack.pop();
switch (operator) {
case "jz":
b = stack.pop();
a = stack.pop();
if (!a) {
counter = b;
}
if (!a) {
counter = b;
}
break;
break;
case "j":
a = stack.pop();
counter = a;
break;
case "j":
a = stack.pop();
counter = a;
break;
case "abs":
a = stack.pop();
stack.push(Math.abs(a));
break;
case "abs":
a = stack.pop();
stack.push(Math.abs(a));
break;
case "add":
b = stack.pop();
a = stack.pop();
stack.push(a + b);
break;
case "add":
b = stack.pop();
a = stack.pop();
stack.push(a + b);
break;
case "and":
b = stack.pop();
a = stack.pop();
case "and":
b = stack.pop();
a = stack.pop();
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
stack.push(a && b);
} else {
stack.push(a & b);
}
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
stack.push(a && b);
} else {
stack.push(a & b);
}
break;
break;
case "atan":
a = stack.pop();
stack.push(Math.atan(a));
break;
case "atan":
a = stack.pop();
stack.push(Math.atan(a));
break;
case "bitshift":
b = stack.pop();
a = stack.pop();
case "bitshift":
b = stack.pop();
a = stack.pop();
if (a > 0) {
stack.push(a << b);
} else {
stack.push(a >> b);
}
if (a > 0) {
stack.push(a << b);
} else {
stack.push(a >> b);
}
break;
break;
case "ceiling":
a = stack.pop();
stack.push(Math.ceil(a));
break;
case "ceiling":
a = stack.pop();
stack.push(Math.ceil(a));
break;
case "copy":
a = stack.pop();
stack.copy(a);
break;
case "copy":
a = stack.pop();
stack.copy(a);
break;
case "cos":
a = stack.pop();
stack.push(Math.cos(a));
break;
case "cos":
a = stack.pop();
stack.push(Math.cos(a));
break;
case "cvi":
a = stack.pop() | 0;
stack.push(a);
break;
case "cvi":
a = stack.pop() | 0;
stack.push(a);
break;
case "cvr":
break;
case "cvr":
break;
case "div":
b = stack.pop();
a = stack.pop();
stack.push(a / b);
break;
case "div":
b = stack.pop();
a = stack.pop();
stack.push(a / b);
break;
case "dup":
stack.copy(1);
break;
case "dup":
stack.copy(1);
break;
case "eq":
b = stack.pop();
a = stack.pop();
stack.push(a === b);
break;
case "eq":
b = stack.pop();
a = stack.pop();
stack.push(a === b);
break;
case "exch":
stack.roll(2, 1);
break;
case "exch":
stack.roll(2, 1);
break;
case "exp":
b = stack.pop();
a = stack.pop();
stack.push(a ** b);
break;
case "exp":
b = stack.pop();
a = stack.pop();
stack.push(a ** b);
break;
case "false":
stack.push(false);
break;
case "false":
stack.push(false);
break;
case "floor":
a = stack.pop();
stack.push(Math.floor(a));
break;
case "floor":
a = stack.pop();
stack.push(Math.floor(a));
break;
case "ge":
b = stack.pop();
a = stack.pop();
stack.push(a >= b);
break;
case "ge":
b = stack.pop();
a = stack.pop();
stack.push(a >= b);
break;
case "gt":
b = stack.pop();
a = stack.pop();
stack.push(a > b);
break;
case "gt":
b = stack.pop();
a = stack.pop();
stack.push(a > b);
break;
case "idiv":
b = stack.pop();
a = stack.pop();
stack.push(a / b | 0);
break;
case "idiv":
b = stack.pop();
a = stack.pop();
stack.push(a / b | 0);
break;
case "index":
a = stack.pop();
stack.index(a);
break;
case "index":
a = stack.pop();
stack.index(a);
break;
case "le":
b = stack.pop();
a = stack.pop();
stack.push(a <= b);
break;
case "le":
b = stack.pop();
a = stack.pop();
stack.push(a <= b);
break;
case "ln":
a = stack.pop();
stack.push(Math.log(a));
break;
case "ln":
a = stack.pop();
stack.push(Math.log(a));
break;
case "log":
a = stack.pop();
stack.push(Math.log(a) / Math.LN10);
break;
case "log":
a = stack.pop();
stack.push(Math.log(a) / Math.LN10);
break;
case "lt":
b = stack.pop();
a = stack.pop();
stack.push(a < b);
break;
case "lt":
b = stack.pop();
a = stack.pop();
stack.push(a < b);
break;
case "mod":
b = stack.pop();
a = stack.pop();
stack.push(a % b);
break;
case "mod":
b = stack.pop();
a = stack.pop();
stack.push(a % b);
break;
case "mul":
b = stack.pop();
a = stack.pop();
stack.push(a * b);
break;
case "mul":
b = stack.pop();
a = stack.pop();
stack.push(a * b);
break;
case "ne":
b = stack.pop();
a = stack.pop();
stack.push(a !== b);
break;
case "ne":
b = stack.pop();
a = stack.pop();
stack.push(a !== b);
break;
case "neg":
a = stack.pop();
stack.push(-a);
break;
case "neg":
a = stack.pop();
stack.push(-a);
break;
case "not":
a = stack.pop();
case "not":
a = stack.pop();
if ((0, _util.isBool)(a)) {
stack.push(!a);
} else {
stack.push(~a);
}
if ((0, _util.isBool)(a)) {
stack.push(!a);
} else {
stack.push(~a);
}
break;
break;
case "or":
b = stack.pop();
a = stack.pop();
case "or":
b = stack.pop();
a = stack.pop();
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
stack.push(a || b);
} else {
stack.push(a | b);
}
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
stack.push(a || b);
} else {
stack.push(a | b);
}
break;
break;
case "pop":
stack.pop();
break;
case "pop":
stack.pop();
break;
case "roll":
b = stack.pop();
a = stack.pop();
stack.roll(a, b);
break;
case "roll":
b = stack.pop();
a = stack.pop();
stack.roll(a, b);
break;
case "round":
a = stack.pop();
stack.push(Math.round(a));
break;
case "round":
a = stack.pop();
stack.push(Math.round(a));
break;
case "sin":
a = stack.pop();
stack.push(Math.sin(a));
break;
case "sin":
a = stack.pop();
stack.push(Math.sin(a));
break;
case "sqrt":
a = stack.pop();
stack.push(Math.sqrt(a));
break;
case "sqrt":
a = stack.pop();
stack.push(Math.sqrt(a));
break;
case "sub":
b = stack.pop();
a = stack.pop();
stack.push(a - b);
break;
case "sub":
b = stack.pop();
a = stack.pop();
stack.push(a - b);
break;
case "true":
stack.push(true);
break;
case "true":
stack.push(true);
break;
case "truncate":
a = stack.pop();
a = a < 0 ? Math.ceil(a) : Math.floor(a);
stack.push(a);
break;
case "truncate":
a = stack.pop();
a = a < 0 ? Math.ceil(a) : Math.floor(a);
stack.push(a);
break;
case "xor":
b = stack.pop();
a = stack.pop();
case "xor":
b = stack.pop();
a = stack.pop();
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
stack.push(a !== b);
} else {
stack.push(a ^ b);
}
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
stack.push(a !== b);
} else {
stack.push(a ^ b);
}
break;
break;
default:
throw new _util.FormatError(`Unknown operator ${operator}`);
}
default:
throw new _util.FormatError(`Unknown operator ${operator}`);
}
return stack.stack;
}
};
return PostScriptEvaluator;
}();
return stack.stack;
}
}
exports.PostScriptEvaluator = PostScriptEvaluator;
var PostScriptCompiler = function PostScriptCompilerClosure() {
function AstNode(type) {
this.type = type;
}
class AstNode {
constructor(type) {
this.type = type;
}
AstNode.prototype.visit = function (visitor) {
(0, _util.unreachable)("abstract method");
};
visit(visitor) {
(0, _util.unreachable)("abstract method");
}
function AstArgument(index, min, max) {
AstNode.call(this, "args");
this.index = index;
this.min = min;
this.max = max;
}
AstArgument.prototype = Object.create(AstNode.prototype);
class AstArgument extends AstNode {
constructor(index, min, max) {
super("args");
this.index = index;
this.min = min;
this.max = max;
}
AstArgument.prototype.visit = function (visitor) {
visitor.visitArgument(this);
};
visit(visitor) {
visitor.visitArgument(this);
}
function AstLiteral(number) {
AstNode.call(this, "literal");
this.number = number;
this.min = number;
this.max = number;
}
AstLiteral.prototype = Object.create(AstNode.prototype);
class AstLiteral extends AstNode {
constructor(number) {
super("literal");
this.number = number;
this.min = number;
this.max = number;
}
AstLiteral.prototype.visit = function (visitor) {
visitor.visitLiteral(this);
};
visit(visitor) {
visitor.visitLiteral(this);
}
function AstBinaryOperation(op, arg1, arg2, min, max) {
AstNode.call(this, "binary");
this.op = op;
this.arg1 = arg1;
this.arg2 = arg2;
this.min = min;
this.max = max;
}
AstBinaryOperation.prototype = Object.create(AstNode.prototype);
class AstBinaryOperation extends AstNode {
constructor(op, arg1, arg2, min, max) {
super("binary");
this.op = op;
this.arg1 = arg1;
this.arg2 = arg2;
this.min = min;
this.max = max;
}
AstBinaryOperation.prototype.visit = function (visitor) {
visitor.visitBinaryOperation(this);
};
visit(visitor) {
visitor.visitBinaryOperation(this);
}
function AstMin(arg, max) {
AstNode.call(this, "max");
this.arg = arg;
this.min = arg.min;
this.max = max;
}
AstMin.prototype = Object.create(AstNode.prototype);
class AstMin extends AstNode {
constructor(arg, max) {
super("max");
this.arg = arg;
this.min = arg.min;
this.max = max;
}
AstMin.prototype.visit = function (visitor) {
visitor.visitMin(this);
};
visit(visitor) {
visitor.visitMin(this);
}
function AstVariable(index, min, max) {
AstNode.call(this, "var");
this.index = index;
this.min = min;
this.max = max;
}
AstVariable.prototype = Object.create(AstNode.prototype);
class AstVariable extends AstNode {
constructor(index, min, max) {
super("var");
this.index = index;
this.min = min;
this.max = max;
}
AstVariable.prototype.visit = function (visitor) {
visitor.visitVariable(this);
};
visit(visitor) {
visitor.visitVariable(this);
}
function AstVariableDefinition(variable, arg) {
AstNode.call(this, "definition");
this.variable = variable;
this.arg = arg;
}
AstVariableDefinition.prototype = Object.create(AstNode.prototype);
class AstVariableDefinition extends AstNode {
constructor(variable, arg) {
super("definition");
this.variable = variable;
this.arg = arg;
}
AstVariableDefinition.prototype.visit = function (visitor) {
visitor.visitVariableDefinition(this);
};
visit(visitor) {
visitor.visitVariableDefinition(this);
}
function ExpressionBuilderVisitor() {
this.parts = [];
}
ExpressionBuilderVisitor.prototype = {
class ExpressionBuilderVisitor {
constructor() {
this.parts = [];
}
visitArgument(arg) {
this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
},
}
visitVariable(variable) {
this.parts.push("v", variable.index);
},
}
visitLiteral(literal) {
this.parts.push(literal.number);
},
}

@@ -1146,3 +1159,3 @@ visitBinaryOperation(operation) {

this.parts.push(")");
},
}

@@ -1155,3 +1168,3 @@ visitVariableDefinition(definition) {

this.parts.push(";");
},
}

@@ -1162,3 +1175,3 @@ visitMin(max) {

this.parts.push(", ", max.max, ")");
},
}

@@ -1169,3 +1182,3 @@ toString() {

};
}

@@ -1238,6 +1251,4 @@ function buildAddOperation(num1, num2) {

function PostScriptCompiler() {}
PostScriptCompiler.prototype = {
compile: function PostScriptCompiler_compile(code, domain, range) {
class PostScriptCompiler {
compile(code, domain, range) {
var stack = [];

@@ -1440,3 +1451,5 @@ var instructions = [];

}
};
}
return PostScriptCompiler;

@@ -1443,0 +1456,0 @@ }();

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -218,6 +218,10 @@ * Licensed under the Apache License, Version 2.0 (the "License");

static get MAX_IMAGES_TO_CACHE() {
return (0, _util.shadow)(this, "MAX_IMAGES_TO_CACHE", 10);
static get MIN_IMAGES_TO_CACHE() {
return (0, _util.shadow)(this, "MIN_IMAGES_TO_CACHE", 10);
}
static get MAX_BYTE_SIZE() {
return (0, _util.shadow)(this, "MAX_BYTE_SIZE", 40e6);
}
constructor() {

@@ -228,2 +232,24 @@ this._refCache = new _primitives.RefSetCache();

get _byteSize() {
let byteSize = 0;
this._imageCache.forEach(imageData => {
byteSize += imageData.byteSize;
});
return byteSize;
}
get _cacheLimitReached() {
if (this._imageCache.size < GlobalImageCache.MIN_IMAGES_TO_CACHE) {
return false;
}
if (this._byteSize < GlobalImageCache.MAX_BYTE_SIZE) {
return false;
}
return true;
}
shouldCache(ref, pageIndex) {

@@ -238,3 +264,3 @@ const pageIndexSet = this._refCache.get(ref);

if (!this._imageCache.has(ref) && this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
if (!this._imageCache.has(ref) && this._cacheLimitReached) {
return false;

@@ -258,2 +284,16 @@ }

addByteSize(ref, byteSize) {
const imageData = this._imageCache.get(ref);
if (!imageData) {
return;
}
if (imageData.byteSize) {
return;
}
imageData.byteSize = byteSize;
}
getData(ref, pageIndex) {

@@ -270,3 +310,5 @@ const pageIndexSet = this._refCache.get(ref);

if (!this._imageCache.has(ref)) {
const imageData = this._imageCache.get(ref);
if (!imageData) {
return null;

@@ -276,3 +318,3 @@ }

pageIndexSet.add(pageIndex);
return this._imageCache.get(ref);
return imageData;
}

@@ -289,4 +331,4 @@

if (this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
(0, _util.info)("GlobalImageCache.setData - ignoring image above MAX_IMAGES_TO_CACHE.");
if (this._cacheLimitReached) {
(0, _util.warn)("GlobalImageCache.setData - cache limit reached.");
return;

@@ -293,0 +335,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,3 +32,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var getMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
const getMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
t.Courier = 600;

@@ -35,0 +35,0 @@ t["Courier-Bold"] = 600;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,8 +32,8 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var QueueOptimizer = function QueueOptimizerClosure() {
const QueueOptimizer = function QueueOptimizerClosure() {
function addState(parentState, pattern, checkFn, iterateFn, processFn) {
var state = parentState;
let state = parentState;
for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
var item = pattern[i];
for (let i = 0, ii = pattern.length - 1; i < ii; i++) {
const item = pattern[i];
state = state[item] || (state[item] = []);

@@ -50,7 +50,8 @@ }

function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
var iFirstPIMXO = iFirstSave + 2;
const iFirstPIMXO = iFirstSave + 2;
let i;
for (var i = 0; i < count; i++) {
var arg = argsArray[iFirstPIMXO + 4 * i];
var imageMask = arg.length === 1 && arg[0];
for (i = 0; i < count; i++) {
const arg = argsArray[iFirstPIMXO + 4 * i];
const imageMask = arg.length === 1 && arg[0];

@@ -68,7 +69,7 @@ if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {

var InitialState = [];
const InitialState = [];
addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], null, function iterateInlineImageGroup(context, i) {
var fnArray = context.fnArray;
var iFirstSave = context.iCurr - 3;
var pos = (i - iFirstSave) % 4;
const fnArray = context.fnArray;
const iFirstSave = context.iCurr - 3;
const pos = (i - iFirstSave) % 4;

@@ -91,13 +92,13 @@ switch (pos) {

}, function foundInlineImageGroup(context, i) {
var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
var MAX_WIDTH = 1000;
var IMAGE_PADDING = 1;
var fnArray = context.fnArray,
argsArray = context.argsArray;
var curr = context.iCurr;
var iFirstSave = curr - 3;
var iFirstTransform = curr - 2;
var iFirstPIIXO = curr - 1;
var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
const MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
const MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
const MAX_WIDTH = 1000;
const IMAGE_PADDING = 1;
const fnArray = context.fnArray,
argsArray = context.argsArray;
const curr = context.iCurr;
const iFirstSave = curr - 3;
const iFirstTransform = curr - 2;
const iFirstPIIXO = curr - 1;
const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);

@@ -108,12 +109,11 @@ if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {

var maxX = 0;
var map = [],
maxLineHeight = 0;
var currentX = IMAGE_PADDING,
let maxX = 0;
const map = [];
let maxLineHeight = 0;
let currentX = IMAGE_PADDING,
currentY = IMAGE_PADDING;
var q;
for (q = 0; q < count; q++) {
var transform = argsArray[iFirstTransform + (q << 2)];
var img = argsArray[iFirstPIIXO + (q << 2)][0];
for (let q = 0; q < count; q++) {
const transform = argsArray[iFirstTransform + (q << 2)];
const img = argsArray[iFirstPIIXO + (q << 2)][0];

@@ -138,15 +138,15 @@ if (currentX + img.width > MAX_WIDTH) {

var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
var imgData = new Uint8ClampedArray(imgWidth * imgHeight * 4);
var imgRowSize = imgWidth << 2;
const imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
const imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
const imgData = new Uint8ClampedArray(imgWidth * imgHeight * 4);
const imgRowSize = imgWidth << 2;
for (q = 0; q < count; q++) {
var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
var rowSize = map[q].w << 2;
var dataOffset = 0;
var offset = map[q].x + map[q].y * imgWidth << 2;
for (let q = 0; q < count; q++) {
const data = argsArray[iFirstPIIXO + (q << 2)][0].data;
const rowSize = map[q].w << 2;
let dataOffset = 0;
let offset = map[q].x + map[q].y * imgWidth << 2;
imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
for (var k = 0, kk = map[q].h; k < kk; k++) {
for (let k = 0, kk = map[q].h; k < kk; k++) {
imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);

@@ -182,5 +182,5 @@ dataOffset += rowSize;

addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], null, function iterateImageMaskGroup(context, i) {
var fnArray = context.fnArray;
var iFirstSave = context.iCurr - 3;
var pos = (i - iFirstSave) % 4;
const fnArray = context.fnArray;
const iFirstSave = context.iCurr - 3;
const pos = (i - iFirstSave) % 4;

@@ -203,12 +203,12 @@ switch (pos) {

}, function foundImageMaskGroup(context, i) {
var MIN_IMAGES_IN_MASKS_BLOCK = 10;
var MAX_IMAGES_IN_MASKS_BLOCK = 100;
var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
var fnArray = context.fnArray,
argsArray = context.argsArray;
var curr = context.iCurr;
var iFirstSave = curr - 3;
var iFirstTransform = curr - 2;
var iFirstPIMXO = curr - 1;
var count = Math.floor((i - iFirstSave) / 4);
const MIN_IMAGES_IN_MASKS_BLOCK = 10;
const MAX_IMAGES_IN_MASKS_BLOCK = 100;
const MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
const fnArray = context.fnArray,
argsArray = context.argsArray;
const curr = context.iCurr;
const iFirstSave = curr - 3;
const iFirstTransform = curr - 2;
const iFirstPIMXO = curr - 1;
let count = Math.floor((i - iFirstSave) / 4);
count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);

@@ -220,6 +220,5 @@

var q;
var isSameImage = false;
var iTransform, transformArgs;
var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
let isSameImage = false;
let iTransform, transformArgs;
const firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
const firstTransformArg0 = argsArray[iFirstTransform][0],

@@ -233,5 +232,5 @@ firstTransformArg1 = argsArray[iFirstTransform][1],

iTransform = iFirstTransform + 4;
var iPIMXO = iFirstPIMXO + 4;
let iPIMXO = iFirstPIMXO + 4;
for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
for (let q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
transformArgs = argsArray[iTransform];

@@ -253,6 +252,6 @@

count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
var positions = new Float32Array(count * 2);
const positions = new Float32Array(count * 2);
iTransform = iFirstTransform;
for (q = 0; q < count; q++, iTransform += 4) {
for (let q = 0; q < count; q++, iTransform += 4) {
transformArgs = argsArray[iTransform];

@@ -267,7 +266,7 @@ positions[q << 1] = transformArgs[4];

count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
var images = [];
const images = [];
for (q = 0; q < count; q++) {
for (let q = 0; q < count; q++) {
transformArgs = argsArray[iFirstTransform + (q << 2)];
var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
const maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
images.push({

@@ -288,10 +287,10 @@ data: maskParams.data,

addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
var argsArray = context.argsArray;
var iFirstTransform = context.iCurr - 2;
const argsArray = context.argsArray;
const iFirstTransform = context.iCurr - 2;
return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
}, function iterateImageGroup(context, i) {
var fnArray = context.fnArray,
argsArray = context.argsArray;
var iFirstSave = context.iCurr - 3;
var pos = (i - iFirstSave) % 4;
const fnArray = context.fnArray,
argsArray = context.argsArray;
const iFirstSave = context.iCurr - 3;
const pos = (i - iFirstSave) % 4;

@@ -307,5 +306,5 @@ switch (pos) {

var iFirstTransform = context.iCurr - 2;
var firstTransformArg0 = argsArray[iFirstTransform][0];
var firstTransformArg3 = argsArray[iFirstTransform][3];
const iFirstTransform = context.iCurr - 2;
const firstTransformArg0 = argsArray[iFirstTransform][0];
const firstTransformArg3 = argsArray[iFirstTransform][3];

@@ -323,4 +322,4 @@ if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {

var iFirstPIXO = context.iCurr - 1;
var firstPIXOArg0 = argsArray[iFirstPIXO][0];
const iFirstPIXO = context.iCurr - 1;
const firstPIXOArg0 = argsArray[iFirstPIXO][0];

@@ -339,14 +338,14 @@ if (argsArray[i][0] !== firstPIXOArg0) {

}, function (context, i) {
var MIN_IMAGES_IN_BLOCK = 3;
var MAX_IMAGES_IN_BLOCK = 1000;
var fnArray = context.fnArray,
argsArray = context.argsArray;
var curr = context.iCurr;
var iFirstSave = curr - 3;
var iFirstTransform = curr - 2;
var iFirstPIXO = curr - 1;
var firstPIXOArg0 = argsArray[iFirstPIXO][0];
var firstTransformArg0 = argsArray[iFirstTransform][0];
var firstTransformArg3 = argsArray[iFirstTransform][3];
var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
const MIN_IMAGES_IN_BLOCK = 3;
const MAX_IMAGES_IN_BLOCK = 1000;
const fnArray = context.fnArray,
argsArray = context.argsArray;
const curr = context.iCurr;
const iFirstSave = curr - 3;
const iFirstTransform = curr - 2;
const iFirstPIXO = curr - 1;
const firstPIXOArg0 = argsArray[iFirstPIXO][0];
const firstTransformArg0 = argsArray[iFirstTransform][0];
const firstTransformArg3 = argsArray[iFirstTransform][3];
const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);

@@ -357,7 +356,7 @@ if (count < MIN_IMAGES_IN_BLOCK) {

var positions = new Float32Array(count * 2);
var iTransform = iFirstTransform;
const positions = new Float32Array(count * 2);
let iTransform = iFirstTransform;
for (var q = 0; q < count; q++, iTransform += 4) {
var transformArgs = argsArray[iTransform];
for (let q = 0; q < count; q++, iTransform += 4) {
const transformArgs = argsArray[iTransform];
positions[q << 1] = transformArgs[4];

@@ -367,3 +366,3 @@ positions[(q << 1) + 1] = transformArgs[5];

var args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
const args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);

@@ -374,6 +373,6 @@ argsArray.splice(iFirstSave, count * 4, args);

addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], null, function iterateShowTextGroup(context, i) {
var fnArray = context.fnArray,
argsArray = context.argsArray;
var iFirstSave = context.iCurr - 4;
var pos = (i - iFirstSave) % 5;
const fnArray = context.fnArray,
argsArray = context.argsArray;
const iFirstSave = context.iCurr - 4;
const pos = (i - iFirstSave) % 5;

@@ -395,5 +394,5 @@ switch (pos) {

var iFirstSetFont = context.iCurr - 3;
var firstSetFontArg0 = argsArray[iFirstSetFont][0];
var firstSetFontArg1 = argsArray[iFirstSetFont][1];
const iFirstSetFont = context.iCurr - 3;
const firstSetFontArg0 = argsArray[iFirstSetFont][0];
const firstSetFontArg1 = argsArray[iFirstSetFont][1];

@@ -412,15 +411,15 @@ if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {

}, function (context, i) {
var MIN_CHARS_IN_BLOCK = 3;
var MAX_CHARS_IN_BLOCK = 1000;
var fnArray = context.fnArray,
argsArray = context.argsArray;
var curr = context.iCurr;
var iFirstBeginText = curr - 4;
var iFirstSetFont = curr - 3;
var iFirstSetTextMatrix = curr - 2;
var iFirstShowText = curr - 1;
var iFirstEndText = curr;
var firstSetFontArg0 = argsArray[iFirstSetFont][0];
var firstSetFontArg1 = argsArray[iFirstSetFont][1];
var count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
const MIN_CHARS_IN_BLOCK = 3;
const MAX_CHARS_IN_BLOCK = 1000;
const fnArray = context.fnArray,
argsArray = context.argsArray;
const curr = context.iCurr;
const iFirstBeginText = curr - 4;
const iFirstSetFont = curr - 3;
const iFirstSetTextMatrix = curr - 2;
const iFirstShowText = curr - 1;
const iFirstEndText = curr;
const firstSetFontArg0 = argsArray[iFirstSetFont][0];
const firstSetFontArg1 = argsArray[iFirstSetFont][1];
let count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);

@@ -431,3 +430,3 @@ if (count < MIN_CHARS_IN_BLOCK) {

var iFirst = iFirstBeginText;
let iFirst = iFirstBeginText;

@@ -439,5 +438,5 @@ if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {

var iEndText = iFirst + 4;
let iEndText = iFirst + 4;
for (var q = 1; q < count; q++) {
for (let q = 1; q < count; q++) {
fnArray.splice(iEndText, 3);

@@ -549,3 +548,3 @@ argsArray.splice(iEndText, 3);

var NullOptimizer = function NullOptimizerClosure() {
const NullOptimizer = function NullOptimizerClosure() {
function NullOptimizer(queue) {

@@ -569,5 +568,5 @@ this.queue = queue;

var OperatorList = function OperatorListClosure() {
var CHUNK_SIZE = 1000;
var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
const OperatorList = function OperatorListClosure() {
const CHUNK_SIZE = 1000;
const CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;

@@ -642,3 +641,3 @@ function OperatorList(intent, streamSink) {

for (var i = 0, ii = opList.length; i < ii; i++) {
for (let i = 0, ii = opList.length; i < ii; i++) {
this.addOp(opList.fnArray[i], opList.argsArray[i]);

@@ -645,0 +644,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -39,3 +39,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var ShadingType = {
const ShadingType = {
FUNCTION_BASED: 1,

@@ -50,3 +50,3 @@ AXIAL: 2,

var Pattern = function PatternClosure() {
const Pattern = function PatternClosure() {
function Pattern() {

@@ -63,4 +63,4 @@ (0, _util.unreachable)("should not call Pattern constructor");

Pattern.parseShading = function (shading, matrix, xref, res, handler, pdfFunctionFactory, localColorSpaceCache) {
var dict = (0, _primitives.isStream)(shading) ? shading.dict : shading;
var type = dict.get("ShadingType");
const dict = (0, _primitives.isStream)(shading) ? shading.dict : shading;
const type = dict.get("ShadingType");

@@ -99,3 +99,3 @@ try {

exports.Pattern = Pattern;
var Shadings = {};
const Shadings = {};
Shadings.SMALL_NUMBER = 1e-6;

@@ -127,7 +127,7 @@

var t0 = 0.0,
let t0 = 0.0,
t1 = 1.0;
if (dict.has("Domain")) {
var domainArr = dict.getArray("Domain");
const domainArr = dict.getArray("Domain");
t0 = domainArr[0];

@@ -137,7 +137,7 @@ t1 = domainArr[1];

var extendStart = false,
let extendStart = false,
extendEnd = false;
if (dict.has("Extend")) {
var extendArr = dict.getArray("Extend");
const extendArr = dict.getArray("Extend");
extendStart = extendArr[0];

@@ -148,9 +148,4 @@ extendEnd = extendArr[1];

if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
var x1 = this.coordsArr[0];
var y1 = this.coordsArr[1];
var r1 = this.coordsArr[2];
var x2 = this.coordsArr[3];
var y2 = this.coordsArr[4];
var r2 = this.coordsArr[5];
var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
const [x1, y1, r1, x2, y2, r2] = this.coordsArr;
const distance = Math.hypot(x1 - x2, y1 - y2);

@@ -164,7 +159,7 @@ if (r1 <= r2 + distance && r2 <= r1 + distance) {

this.extendEnd = extendEnd;
var fnObj = dict.getRaw("Function");
var fn = pdfFunctionFactory.createFromArray(fnObj);
const fnObj = dict.getRaw("Function");
const fn = pdfFunctionFactory.createFromArray(fnObj);
const NUMBER_OF_SAMPLES = 10;
const step = (t1 - t0) / NUMBER_OF_SAMPLES;
var colorStops = this.colorStops = [];
const colorStops = this.colorStops = [];

@@ -176,5 +171,5 @@ if (t0 >= t1 || step <= 0) {

var color = new Float32Array(cs.numComps),
ratio = new Float32Array(1);
var rgbColor;
const color = new Float32Array(cs.numComps),
ratio = new Float32Array(1);
let rgbColor;

@@ -186,3 +181,3 @@ for (let i = 0; i <= NUMBER_OF_SAMPLES; i++) {

var cssColor = _util.Util.makeHexColor(rgbColor[0], rgbColor[1], rgbColor[2]);
const cssColor = _util.Util.makeHexColor(rgbColor[0], rgbColor[1], rgbColor[2]);

@@ -192,3 +187,3 @@ colorStops.push([i / NUMBER_OF_SAMPLES, cssColor]);

var background = "transparent";
let background = "transparent";

@@ -215,5 +210,5 @@ if (dict.has("Background")) {

getIR: function RadialAxial_getIR() {
var coordsArr = this.coordsArr;
var shadingType = this.shadingType;
var type, p0, p1, r0, r1;
const coordsArr = this.coordsArr;
const shadingType = this.shadingType;
let type, p0, p1, r0, r1;

@@ -236,3 +231,3 @@ if (shadingType === ShadingType.AXIAL) {

var matrix = this.matrix;
const matrix = this.matrix;

@@ -244,3 +239,3 @@ if (matrix) {

if (shadingType === ShadingType.RADIAL) {
var scale = _util.Util.singularValueDecompose2dScale(matrix);
const scale = _util.Util.singularValueDecompose2dScale(matrix);

@@ -264,5 +259,5 @@ r0 *= scale[0];

this.bufferLength = 0;
var numComps = context.numComps;
const numComps = context.numComps;
this.tmpCompsBuf = new Float32Array(numComps);
var csNumComps = context.colorSpace.numComps;
const csNumComps = context.colorSpace.numComps;
this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;

@@ -281,3 +276,3 @@ }

var nextByte = this.stream.getByte();
const nextByte = this.stream.getByte();

@@ -294,4 +289,4 @@ if (nextByte < 0) {

readBits: function MeshStreamReader_readBits(n) {
var buffer = this.buffer;
var bufferLength = this.bufferLength;
let buffer = this.buffer;
let bufferLength = this.bufferLength;

@@ -304,3 +299,3 @@ if (n === 32) {

buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
var nextByte = this.stream.getByte();
const nextByte = this.stream.getByte();
this.buffer = nextByte & (1 << bufferLength) - 1;

@@ -332,22 +327,22 @@ return (buffer << 8 - bufferLength | (nextByte & 0xff) >> bufferLength) >>> 0;

readCoordinate: function MeshStreamReader_readCoordinate() {
var bitsPerCoordinate = this.context.bitsPerCoordinate;
var xi = this.readBits(bitsPerCoordinate);
var yi = this.readBits(bitsPerCoordinate);
var decode = this.context.decode;
var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
const bitsPerCoordinate = this.context.bitsPerCoordinate;
const xi = this.readBits(bitsPerCoordinate);
const yi = this.readBits(bitsPerCoordinate);
const decode = this.context.decode;
const scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
return [xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2]];
},
readComponents: function MeshStreamReader_readComponents() {
var numComps = this.context.numComps;
var bitsPerComponent = this.context.bitsPerComponent;
var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
var decode = this.context.decode;
var components = this.tmpCompsBuf;
const numComps = this.context.numComps;
const bitsPerComponent = this.context.bitsPerComponent;
const scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
const decode = this.context.decode;
const components = this.tmpCompsBuf;
for (var i = 0, j = 4; i < numComps; i++, j += 2) {
var ci = this.readBits(bitsPerComponent);
for (let i = 0, j = 4; i < numComps; i++, j += 2) {
const ci = this.readBits(bitsPerComponent);
components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
}
var color = this.tmpCsCompsBuf;
const color = this.tmpCsCompsBuf;

@@ -363,12 +358,12 @@ if (this.context.colorFn) {

function decodeType4Shading(mesh, reader) {
var coords = mesh.coords;
var colors = mesh.colors;
var operators = [];
var ps = [];
var verticesLeft = 0;
const coords = mesh.coords;
const colors = mesh.colors;
const operators = [];
const ps = [];
let verticesLeft = 0;
while (reader.hasData) {
var f = reader.readFlag();
var coord = reader.readCoordinate();
var color = reader.readComponents();
const f = reader.readFlag();
const coord = reader.readCoordinate();
const color = reader.readComponents();

@@ -414,9 +409,9 @@ if (verticesLeft === 0) {

function decodeType5Shading(mesh, reader, verticesPerRow) {
var coords = mesh.coords;
var colors = mesh.colors;
var ps = [];
const coords = mesh.coords;
const colors = mesh.colors;
const ps = [];
while (reader.hasData) {
var coord = reader.readCoordinate();
var color = reader.readComponents();
const coord = reader.readCoordinate();
const color = reader.readComponents();
ps.push(coords.length);

@@ -435,13 +430,13 @@ coords.push(coord);

var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
var TRIANGLE_DENSITY = 20;
const MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
const MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
const TRIANGLE_DENSITY = 20;
var getB = function getBClosure() {
const getB = function getBClosure() {
function buildB(count) {
var lut = [];
const lut = [];
for (var i = 0; i <= count; i++) {
var t = i / count,
t_ = 1 - t;
for (let i = 0; i <= count; i++) {
const t = i / count,
t_ = 1 - t;
lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_, 3 * t * t * t_, t * t * t]));

@@ -453,3 +448,3 @@ }

var cache = [];
const cache = [];
return function getB(count) {

@@ -465,30 +460,30 @@ if (!cache[count]) {

function buildFigureFromPatch(mesh, index) {
var figure = mesh.figures[index];
const figure = mesh.figures[index];
(0, _util.assert)(figure.type === "patch", "Unexpected patch mesh figure");
var coords = mesh.coords,
colors = mesh.colors;
var pi = figure.coords;
var ci = figure.colors;
var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
const coords = mesh.coords,
colors = mesh.colors;
const pi = figure.coords;
const ci = figure.colors;
const figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
const figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
const figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
const figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
let splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
let splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
var verticesPerRow = splitXBy + 1;
var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
var k = 0;
var cl = new Uint8Array(3),
cr = new Uint8Array(3);
var c0 = colors[ci[0]],
c1 = colors[ci[1]],
c2 = colors[ci[2]],
c3 = colors[ci[3]];
var bRow = getB(splitYBy),
bCol = getB(splitXBy);
const verticesPerRow = splitXBy + 1;
const figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
const figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
let k = 0;
const cl = new Uint8Array(3),
cr = new Uint8Array(3);
const c0 = colors[ci[0]],
c1 = colors[ci[1]],
c2 = colors[ci[2]],
c3 = colors[ci[3]];
const bRow = getB(splitYBy),
bCol = getB(splitXBy);
for (var row = 0; row <= splitYBy; row++) {
for (let row = 0; row <= splitYBy; row++) {
cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;

@@ -501,3 +496,3 @@ cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;

for (var col = 0; col <= splitXBy; col++, k++) {
for (let col = 0; col <= splitXBy; col++, k++) {
if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {

@@ -507,9 +502,9 @@ continue;

var x = 0,
let x = 0,
y = 0;
var q = 0;
let q = 0;
for (var i = 0; i <= 3; i++) {
for (var j = 0; j <= 3; j++, q++) {
var m = bRow[row][i] * bCol[col][j];
for (let i = 0; i <= 3; i++) {
for (let j = 0; j <= 3; j++, q++) {
const m = bRow[row][i] * bCol[col][j];
x += coords[pi[q]][0] * m;

@@ -523,3 +518,3 @@ y += coords[pi[q]][1] * m;

figureColors[k] = colors.length;
var newColor = new Uint8Array(3);
const newColor = new Uint8Array(3);
newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;

@@ -549,9 +544,9 @@ newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;

function decodeType6Shading(mesh, reader) {
var coords = mesh.coords;
var colors = mesh.colors;
var ps = new Int32Array(16);
var cs = new Int32Array(4);
const coords = mesh.coords;
const colors = mesh.colors;
const ps = new Int32Array(16);
const cs = new Int32Array(4);
while (reader.hasData) {
var f = reader.readFlag();
const f = reader.readFlag();

@@ -562,16 +557,15 @@ if (!(0 <= f && f <= 3)) {

var i, ii;
var pi = coords.length;
const pi = coords.length;
for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
coords.push(reader.readCoordinate());
}
var ci = colors.length;
const ci = colors.length;
for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
colors.push(reader.readComponents());
}
var tmp1, tmp2, tmp3, tmp4;
let tmp1, tmp2, tmp3, tmp4;

@@ -682,9 +676,9 @@ switch (f) {

function decodeType7Shading(mesh, reader) {
var coords = mesh.coords;
var colors = mesh.colors;
var ps = new Int32Array(16);
var cs = new Int32Array(4);
const coords = mesh.coords;
const colors = mesh.colors;
const ps = new Int32Array(16);
const cs = new Int32Array(4);
while (reader.hasData) {
var f = reader.readFlag();
const f = reader.readFlag();

@@ -695,16 +689,15 @@ if (!(0 <= f && f <= 3)) {

var i, ii;
var pi = coords.length;
const pi = coords.length;
for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
coords.push(reader.readCoordinate());
}
var ci = colors.length;
const ci = colors.length;
for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
colors.push(reader.readComponents());
}
var tmp1, tmp2, tmp3, tmp4;
let tmp1, tmp2, tmp3, tmp4;

@@ -823,3 +816,3 @@ switch (f) {

function updateBounds(mesh) {
var minX = mesh.coords[0][0],
let minX = mesh.coords[0][0],
minY = mesh.coords[0][1],

@@ -829,5 +822,5 @@ maxX = minX,

for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
var x = mesh.coords[i][0],
y = mesh.coords[i][1];
for (let i = 1, ii = mesh.coords.length; i < ii; i++) {
const x = mesh.coords[i][0],
y = mesh.coords[i][1];
minX = minX > x ? x : minX;

@@ -843,8 +836,8 @@ minY = minY > y ? y : minY;

function packData(mesh) {
var i, ii, j, jj;
var coords = mesh.coords;
var coordsPacked = new Float32Array(coords.length * 2);
let i, ii, j, jj;
const coords = mesh.coords;
const coordsPacked = new Float32Array(coords.length * 2);
for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
var xy = coords[i];
const xy = coords[i];
coordsPacked[j++] = xy[0];

@@ -855,7 +848,7 @@ coordsPacked[j++] = xy[1];

mesh.coords = coordsPacked;
var colors = mesh.colors;
var colorsPacked = new Uint8Array(colors.length * 3);
const colors = mesh.colors;
const colorsPacked = new Uint8Array(colors.length * 3);
for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
var c = colors[i];
const c = colors[i];
colorsPacked[j++] = c[0];

@@ -867,8 +860,8 @@ colorsPacked[j++] = c[1];

mesh.colors = colorsPacked;
var figures = mesh.figures;
const figures = mesh.figures;
for (i = 0, ii = figures.length; i < ii; i++) {
var figure = figures[i],
ps = figure.coords,
cs = figure.colors;
const figure = figures[i],
ps = figure.coords,
cs = figure.colors;

@@ -887,3 +880,3 @@ for (j = 0, jj = ps.length; j < jj; j++) {

var dict = stream.dict;
const dict = stream.dict;
this.matrix = matrix;

@@ -910,8 +903,8 @@ this.shadingType = dict.get("ShadingType");

this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
var fnObj = dict.getRaw("Function");
var fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
const fnObj = dict.getRaw("Function");
const fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
this.coords = [];
this.colors = [];
this.figures = [];
var decodeContext = {
const decodeContext = {
bitsPerCoordinate: dict.get("BitsPerCoordinate"),

@@ -925,4 +918,4 @@ bitsPerComponent: dict.get("BitsPerComponent"),

};
var reader = new MeshStreamReader(stream, decodeContext);
var patchMesh = false;
const reader = new MeshStreamReader(stream, decodeContext);
let patchMesh = false;

@@ -935,3 +928,3 @@ switch (this.shadingType) {

case ShadingType.LATTICE_FORM_MESH:
var verticesPerRow = dict.get("VerticesPerRow") | 0;
const verticesPerRow = dict.get("VerticesPerRow") | 0;

@@ -963,3 +956,3 @@ if (verticesPerRow < 2) {

for (var i = 0, ii = this.figures.length; i < ii; i++) {
for (let i = 0, ii = this.figures.length; i < ii; i++) {
buildFigureFromPatch(this, i);

@@ -966,0 +959,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -40,2 +40,16 @@ * Licensed under the Apache License, Version 2.0 (the "License");

function parseDocBaseUrl(url) {
if (url) {
const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url);
if (absoluteUrl) {
return absoluteUrl.href;
}
(0, _util.warn)(`Invalid absolute docBaseUrl: "${url}".`);
}
return null;
}
class BasePdfManager {

@@ -57,15 +71,3 @@ constructor() {

get docBaseUrl() {
let docBaseUrl = null;
if (this._docBaseUrl) {
const absoluteUrl = (0, _util.createValidAbsoluteUrl)(this._docBaseUrl);
if (absoluteUrl) {
docBaseUrl = absoluteUrl.href;
} else {
(0, _util.warn)(`Invalid absolute docBaseUrl: "${this._docBaseUrl}".`);
}
}
return (0, _util.shadow)(this, "docBaseUrl", docBaseUrl);
return this._docBaseUrl;
}

@@ -128,8 +130,9 @@

class LocalPdfManager extends BasePdfManager {
constructor(docId, data, password, evaluatorOptions, docBaseUrl) {
constructor(docId, data, password, evaluatorOptions, enableXfa, docBaseUrl) {
super();
this._docId = docId;
this._password = password;
this._docBaseUrl = docBaseUrl;
this._docBaseUrl = parseDocBaseUrl(docBaseUrl);
this.evaluatorOptions = evaluatorOptions;
this.enableXfa = enableXfa;
const stream = new _stream.Stream(data);

@@ -167,9 +170,10 @@ this.pdfDocument = new _document.PDFDocument(this, stream);

class NetworkPdfManager extends BasePdfManager {
constructor(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
constructor(docId, pdfNetworkStream, args, evaluatorOptions, enableXfa, docBaseUrl) {
super();
this._docId = docId;
this._password = args.password;
this._docBaseUrl = docBaseUrl;
this._docBaseUrl = parseDocBaseUrl(docBaseUrl);
this.msgHandler = args.msgHandler;
this.evaluatorOptions = evaluatorOptions;
this.enableXfa = enableXfa;
this.streamManager = new _chunked_stream.ChunkedStreamManager(pdfNetworkStream, {

@@ -176,0 +180,0 @@ msgHandler: args.msgHandler,

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -40,6 +40,6 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var EOF = {};
const EOF = {};
exports.EOF = EOF;
var Name = function NameClosure() {
const Name = function NameClosure() {
let nameCache = Object.create(null);

@@ -54,3 +54,3 @@

Name.get = function Name_get(name) {
var nameValue = nameCache[name];
const nameValue = nameCache[name];
return nameValue ? nameValue : nameCache[name] = new Name(name);

@@ -68,3 +68,3 @@ };

var Cmd = function CmdClosure() {
const Cmd = function CmdClosure() {
let cmdCache = Object.create(null);

@@ -79,3 +79,3 @@

Cmd.get = function Cmd_get(cmd) {
var cmdValue = cmdCache[cmd];
const cmdValue = cmdCache[cmd];
return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);

@@ -93,4 +93,4 @@ };

var Dict = function DictClosure() {
var nonSerializable = function nonSerializableClosure() {
const Dict = function DictClosure() {
const nonSerializable = function nonSerializableClosure() {
return nonSerializable;

@@ -188,3 +188,3 @@ };

forEach: function Dict_forEach(callback) {
for (var key in this._map) {
for (const key in this._map) {
callback(key, this.get(key));

@@ -281,3 +281,3 @@ }

var Ref = function RefClosure() {
const Ref = function RefClosure() {
let refCache = Object.create(null);

@@ -284,0 +284,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -288,6 +288,12 @@ * Licensed under the Apache License, Version 2.0 (the "License");

makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
var end = start + length;
if (length === undefined) {
while (!this.eof) {
this.readBlock();
}
} else {
var end = start + length;
while (this.bufferLength <= end && !this.eof) {
this.readBlock();
while (this.bufferLength <= end && !this.eof) {
this.readBlock();
}
}

@@ -294,0 +300,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -38,6 +38,6 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var HINTING_ENABLED = false;
const HINTING_ENABLED = false;
var Type1CharString = function Type1CharStringClosure() {
var COMMAND_MAP = {
const Type1CharString = function Type1CharStringClosure() {
const COMMAND_MAP = {
hstem: [1],

@@ -60,18 +60,18 @@ vstem: [3],

function Type1CharString() {
this.width = 0;
this.lsb = 0;
this.flexing = false;
this.output = [];
this.stack = [];
}
class Type1CharString {
constructor() {
this.width = 0;
this.lsb = 0;
this.flexing = false;
this.output = [];
this.stack = [];
}
Type1CharString.prototype = {
convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
var count = encoded.length;
var error = false;
var wx, sbx, subrNumber;
convert(encoded, subrs, seacAnalysisEnabled) {
const count = encoded.length;
let error = false;
let wx, sbx, subrNumber;
for (var i = 0; i < count; i++) {
var value = encoded[i];
for (let i = 0; i < count; i++) {
let value = encoded[i];

@@ -109,3 +109,3 @@ if (value < 32) {

var dy = this.stack.pop();
const dy = this.stack.pop();
this.stack.push(0, dy);

@@ -242,3 +242,3 @@ break;

wx = this.stack.pop();
var sby = this.stack.pop();
const sby = this.stack.pop();
sbx = this.stack.pop();

@@ -257,4 +257,4 @@ this.lsb = sbx;

var num2 = this.stack.pop();
var num1 = this.stack.pop();
const num2 = this.stack.pop();
const num1 = this.stack.pop();
this.stack.push(num1 / num2);

@@ -270,6 +270,6 @@ break;

subrNumber = this.stack.pop();
var numArgs = this.stack.pop();
const numArgs = this.stack.pop();
if (subrNumber === 0 && numArgs === 3) {
var flexArgs = this.stack.splice(this.stack.length - 17, 17);
const flexArgs = this.stack.splice(this.stack.length - 17, 17);
this.stack.push(flexArgs[2] + flexArgs[0], flexArgs[3] + flexArgs[1], flexArgs[4], flexArgs[5], flexArgs[6], flexArgs[7], flexArgs[8], flexArgs[9], flexArgs[10], flexArgs[11], flexArgs[12], flexArgs[13], flexArgs[14]);

@@ -316,6 +316,6 @@ error = this.executeCommand(13, COMMAND_MAP.flex, true);

return error;
},
}
executeCommand(howManyArgs, command, keepStack) {
var stackLength = this.stack.length;
const stackLength = this.stack.length;

@@ -326,6 +326,6 @@ if (howManyArgs > stackLength) {

var start = stackLength - howManyArgs;
const start = stackLength - howManyArgs;
for (var i = start; i < stackLength; i++) {
var value = this.stack[i];
for (let i = start; i < stackLength; i++) {
let value = this.stack[i];

@@ -351,9 +351,10 @@ if (Number.isInteger(value)) {

};
}
return Type1CharString;
}();
var Type1Parser = function Type1ParserClosure() {
var EEXEC_ENCRYPT_KEY = 55665;
var CHAR_STRS_ENCRYPT_KEY = 4330;
const Type1Parser = function Type1ParserClosure() {
const EEXEC_ENCRYPT_KEY = 55665;
const CHAR_STRS_ENCRYPT_KEY = 4330;

@@ -369,5 +370,5 @@ function isHexDigit(code) {

var r = key | 0,
c1 = 52845,
c2 = 22719,
const c1 = 52845,
c2 = 22719;
let r = key | 0,
i,

@@ -380,7 +381,7 @@ j;

var count = data.length - discardNumber;
var decrypted = new Uint8Array(count);
const count = data.length - discardNumber;
const decrypted = new Uint8Array(count);
for (i = discardNumber, j = 0; j < count; i++, j++) {
var value = data[i];
const value = data[i];
decrypted[j] = value ^ r >> 8;

@@ -394,12 +395,12 @@ r = (value + r) * c1 + c2 & (1 << 16) - 1;

function decryptAscii(data, key, discardNumber) {
var r = key | 0,
c1 = 52845,
c2 = 22719;
var count = data.length,
maybeLength = count >>> 1;
var decrypted = new Uint8Array(maybeLength);
var i, j;
const c1 = 52845,
c2 = 22719;
let r = key | 0;
const count = data.length,
maybeLength = count >>> 1;
const decrypted = new Uint8Array(maybeLength);
let i, j;
for (i = 0, j = 0; i < count; i++) {
var digit1 = data[i];
const digit1 = data[i];

@@ -411,3 +412,3 @@ if (!isHexDigit(digit1)) {

i++;
var digit2;
let digit2;

@@ -419,3 +420,3 @@ while (i < count && !isHexDigit(digit2 = data[i])) {

if (i < count) {
var value = parseInt(String.fromCharCode(digit1, digit2), 16);
const value = parseInt(String.fromCharCode(digit1, digit2), 16);
decrypted[j++] = value ^ r >> 8;

@@ -433,21 +434,21 @@ r = (value + r) * c1 + c2 & (1 << 16) - 1;

function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
if (encrypted) {
var data = stream.getBytes();
var isBinary = !((isHexDigit(data[0]) || (0, _core_utils.isWhiteSpace)(data[0])) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]) && isHexDigit(data[4]) && isHexDigit(data[5]) && isHexDigit(data[6]) && isHexDigit(data[7]));
stream = new _stream.Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
class Type1Parser {
constructor(stream, encrypted, seacAnalysisEnabled) {
if (encrypted) {
const data = stream.getBytes();
const isBinary = !((isHexDigit(data[0]) || (0, _core_utils.isWhiteSpace)(data[0])) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]) && isHexDigit(data[4]) && isHexDigit(data[5]) && isHexDigit(data[6]) && isHexDigit(data[7]));
stream = new _stream.Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
}
this.seacAnalysisEnabled = !!seacAnalysisEnabled;
this.stream = stream;
this.nextChar();
}
this.seacAnalysisEnabled = !!seacAnalysisEnabled;
this.stream = stream;
this.nextChar();
}
Type1Parser.prototype = {
readNumberArray: function Type1Parser_readNumberArray() {
readNumberArray() {
this.getToken();
var array = [];
const array = [];
while (true) {
var token = this.getToken();
const token = this.getToken();

@@ -462,22 +463,27 @@ if (token === null || token === "]" || token === "}") {

return array;
},
readNumber: function Type1Parser_readNumber() {
var token = this.getToken();
}
readNumber() {
const token = this.getToken();
return parseFloat(token || 0);
},
readInt: function Type1Parser_readInt() {
var token = this.getToken();
}
readInt() {
const token = this.getToken();
return parseInt(token || 0, 10) | 0;
},
readBoolean: function Type1Parser_readBoolean() {
var token = this.getToken();
}
readBoolean() {
const token = this.getToken();
return token === "true" ? 1 : 0;
},
nextChar: function Type1_nextChar() {
}
nextChar() {
return this.currentChar = this.stream.getByte();
},
getToken: function Type1Parser_getToken() {
var comment = false;
var ch = this.currentChar;
}
getToken() {
let comment = false;
let ch = this.currentChar;
while (true) {

@@ -506,3 +512,3 @@ if (ch === -1) {

var token = "";
let token = "";

@@ -515,4 +521,5 @@ do {

return token;
},
readCharStrings: function Type1Parser_readCharStrings(bytes, lenIV) {
}
readCharStrings(bytes, lenIV) {
if (lenIV === -1) {

@@ -523,10 +530,11 @@ return bytes;

return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
},
extractFontProgram: function Type1Parser_extractFontProgram(properties) {
var stream = this.stream;
var subrs = [],
charstrings = [];
var privateData = Object.create(null);
}
extractFontProgram(properties) {
const stream = this.stream;
const subrs = [],
charstrings = [];
const privateData = Object.create(null);
privateData.lenIV = 4;
var program = {
const program = {
subrs: [],

@@ -538,3 +546,3 @@ charstrings: [],

};
var token, length, data, lenIV, encoded;
let token, length, data, lenIV, encoded;

@@ -566,3 +574,3 @@ while ((token = this.getToken()) !== null) {

var glyph = this.getToken();
const glyph = this.getToken();
length = this.readInt();

@@ -615,3 +623,3 @@ this.getToken();

case "FamilyOtherBlues":
var blueArray = this.readNumberArray();
const blueArray = this.readNumberArray();

@@ -649,8 +657,8 @@ if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {

for (var i = 0; i < charstrings.length; i++) {
glyph = charstrings[i].glyph;
for (let i = 0; i < charstrings.length; i++) {
const glyph = charstrings[i].glyph;
encoded = charstrings[i].encoded;
var charString = new Type1CharString();
var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
var output = charString.output;
const charString = new Type1CharString();
const error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
let output = charString.output;

@@ -685,6 +693,7 @@ if (error) {

return program;
},
extractFontHeader: function Type1Parser_extractFontHeader(properties) {
var token;
}
extractFontHeader(properties) {
let token;
while ((token = this.getToken()) !== null) {

@@ -699,3 +708,3 @@ if (token !== "/") {

case "FontMatrix":
var matrix = this.readNumberArray();
const matrix = this.readNumberArray();
properties.fontMatrix = matrix;

@@ -705,4 +714,4 @@ break;

case "Encoding":
var encodingArg = this.getToken();
var encoding;
const encodingArg = this.getToken();
let encoding;

@@ -713,6 +722,6 @@ if (!/^\d+$/.test(encodingArg)) {

encoding = [];
var size = parseInt(encodingArg, 10) | 0;
const size = parseInt(encodingArg, 10) | 0;
this.getToken();
for (var j = 0; j < size; j++) {
for (let j = 0; j < size; j++) {
token = this.getToken();

@@ -732,5 +741,5 @@

var index = this.readInt();
const index = this.readInt();
this.getToken();
var glyph = this.getToken();
const glyph = this.getToken();
encoding[index] = glyph;

@@ -745,3 +754,3 @@ this.getToken();

case "FontBBox":
var fontBBox = this.readNumberArray();
const fontBBox = this.readNumberArray();
properties.ascent = Math.max(fontBBox[3], fontBBox[1]);

@@ -754,3 +763,5 @@ properties.descent = Math.min(fontBBox[1], fontBBox[3]);

}
};
}
return Type1Parser;

@@ -757,0 +768,0 @@ }();

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -36,3 +36,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var getSpecialPUASymbols = (0, _core_utils.getLookupTableFactory)(function (t) {
const getSpecialPUASymbols = (0, _core_utils.getLookupTableFactory)(function (t) {
t[63721] = 0x00a9;

@@ -77,3 +77,3 @@ t[63193] = 0x00a9;

function getUnicodeForGlyph(name, glyphsUnicodeMap) {
var unicode = glyphsUnicodeMap[name];
let unicode = glyphsUnicodeMap[name];

@@ -89,4 +89,4 @@ if (unicode !== undefined) {

if (name[0] === "u") {
var nameLen = name.length,
hexStr;
const nameLen = name.length;
let hexStr;

@@ -113,3 +113,3 @@ if (nameLen === 7 && name[1] === "n" && name[2] === "i") {

var UnicodeRanges = [{
const UnicodeRanges = [{
begin: 0x0000,

@@ -486,4 +486,4 @@ end: 0x007f

function getUnicodeRangeFor(value) {
for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
var range = UnicodeRanges[i];
for (let i = 0, ii = UnicodeRanges.length; i < ii; i++) {
const range = UnicodeRanges[i];

@@ -499,3 +499,3 @@ if (value >= range.begin && value < range.end) {

function isRTLRangeFor(value) {
var range = UnicodeRanges[13];
let range = UnicodeRanges[13];

@@ -515,3 +515,3 @@ if (value >= range.begin && value < range.end) {

var getNormalizedUnicodes = (0, _core_utils.getArrayLookupTableFactory)(function () {
const getNormalizedUnicodes = (0, _core_utils.getArrayLookupTableFactory)(function () {
return ["\u00A8", "\u0020\u0308", "\u00AF", "\u0020\u0304", "\u00B4", "\u0020\u0301", "\u00B5", "\u03BC", "\u00B8", "\u0020\u0327", "\u0132", "\u0049\u004A", "\u0133", "\u0069\u006A", "\u013F", "\u004C\u00B7", "\u0140", "\u006C\u00B7", "\u0149", "\u02BC\u006E", "\u017F", "\u0073", "\u01C4", "\u0044\u017D", "\u01C5", "\u0044\u017E", "\u01C6", "\u0064\u017E", "\u01C7", "\u004C\u004A", "\u01C8", "\u004C\u006A", "\u01C9", "\u006C\u006A", "\u01CA", "\u004E\u004A", "\u01CB", "\u004E\u006A", "\u01CC", "\u006E\u006A", "\u01F1", "\u0044\u005A", "\u01F2", "\u0044\u007A", "\u01F3", "\u0064\u007A", "\u02D8", "\u0020\u0306", "\u02D9", "\u0020\u0307", "\u02DA", "\u0020\u030A", "\u02DB", "\u0020\u0328", "\u02DC", "\u0020\u0303", "\u02DD", "\u0020\u030B", "\u037A", "\u0020\u0345", "\u0384", "\u0020\u0301", "\u03D0", "\u03B2", "\u03D1", "\u03B8", "\u03D2", "\u03A5", "\u03D5", "\u03C6", "\u03D6", "\u03C0", "\u03F0", "\u03BA", "\u03F1", "\u03C1", "\u03F2", "\u03C2", "\u03F4", "\u0398", "\u03F5", "\u03B5", "\u03F9", "\u03A3", "\u0587", "\u0565\u0582", "\u0675", "\u0627\u0674", "\u0676", "\u0648\u0674", "\u0677", "\u06C7\u0674", "\u0678", "\u064A\u0674", "\u0E33", "\u0E4D\u0E32", "\u0EB3", "\u0ECD\u0EB2", "\u0EDC", "\u0EAB\u0E99", "\u0EDD", "\u0EAB\u0EA1", "\u0F77", "\u0FB2\u0F81", "\u0F79", "\u0FB3\u0F81", "\u1E9A", "\u0061\u02BE", "\u1FBD", "\u0020\u0313", "\u1FBF", "\u0020\u0313", "\u1FC0", "\u0020\u0342", "\u1FFE", "\u0020\u0314", "\u2002", "\u0020", "\u2003", "\u0020", "\u2004", "\u0020", "\u2005", "\u0020", "\u2006", "\u0020", "\u2008", "\u0020", "\u2009", "\u0020", "\u200A", "\u0020", "\u2017", "\u0020\u0333", "\u2024", "\u002E", "\u2025", "\u002E\u002E", "\u2026", "\u002E\u002E\u002E", "\u2033", "\u2032\u2032", "\u2034", "\u2032\u2032\u2032", "\u2036", "\u2035\u2035", "\u2037", "\u2035\u2035\u2035", "\u203C", "\u0021\u0021", "\u203E", "\u0020\u0305", "\u2047", "\u003F\u003F", "\u2048", "\u003F\u0021", "\u2049", "\u0021\u003F", "\u2057", "\u2032\u2032\u2032\u2032", "\u205F", "\u0020", "\u20A8", "\u0052\u0073", "\u2100", "\u0061\u002F\u0063", "\u2101", "\u0061\u002F\u0073", "\u2103", "\u00B0\u0043", "\u2105", "\u0063\u002F\u006F", "\u2106", "\u0063\u002F\u0075", "\u2107", "\u0190", "\u2109", "\u00B0\u0046", "\u2116", "\u004E\u006F", "\u2121", "\u0054\u0045\u004C", "\u2135", "\u05D0", "\u2136", "\u05D1", "\u2137", "\u05D2", "\u2138", "\u05D3", "\u213B", "\u0046\u0041\u0058", "\u2160", "\u0049", "\u2161", "\u0049\u0049", "\u2162", "\u0049\u0049\u0049", "\u2163", "\u0049\u0056", "\u2164", "\u0056", "\u2165", "\u0056\u0049", "\u2166", "\u0056\u0049\u0049", "\u2167", "\u0056\u0049\u0049\u0049", "\u2168", "\u0049\u0058", "\u2169", "\u0058", "\u216A", "\u0058\u0049", "\u216B", "\u0058\u0049\u0049", "\u216C", "\u004C", "\u216D", "\u0043", "\u216E", "\u0044", "\u216F", "\u004D", "\u2170", "\u0069", "\u2171", "\u0069\u0069", "\u2172", "\u0069\u0069\u0069", "\u2173", "\u0069\u0076", "\u2174", "\u0076", "\u2175", "\u0076\u0069", "\u2176", "\u0076\u0069\u0069", "\u2177", "\u0076\u0069\u0069\u0069", "\u2178", "\u0069\u0078", "\u2179", "\u0078", "\u217A", "\u0078\u0069", "\u217B", "\u0078\u0069\u0069", "\u217C", "\u006C", "\u217D", "\u0063", "\u217E", "\u0064", "\u217F", "\u006D", "\u222C", "\u222B\u222B", "\u222D", "\u222B\u222B\u222B", "\u222F", "\u222E\u222E", "\u2230", "\u222E\u222E\u222E", "\u2474", "\u0028\u0031\u0029", "\u2475", "\u0028\u0032\u0029", "\u2476", "\u0028\u0033\u0029", "\u2477", "\u0028\u0034\u0029", "\u2478", "\u0028\u0035\u0029", "\u2479", "\u0028\u0036\u0029", "\u247A", "\u0028\u0037\u0029", "\u247B", "\u0028\u0038\u0029", "\u247C", "\u0028\u0039\u0029", "\u247D", "\u0028\u0031\u0030\u0029", "\u247E", "\u0028\u0031\u0031\u0029", "\u247F", "\u0028\u0031\u0032\u0029", "\u2480", "\u0028\u0031\u0033\u0029", "\u2481", "\u0028\u0031\u0034\u0029", "\u2482", "\u0028\u0031\u0035\u0029", "\u2483", "\u0028\u0031\u0036\u0029", "\u2484", "\u0028\u0031\u0037\u0029", "\u2485", "\u0028\u0031\u0038\u0029", "\u2486", "\u0028\u0031\u0039\u0029", "\u2487", "\u0028\u0032\u0030\u0029", "\u2488", "\u0031\u002E", "\u2489", "\u0032\u002E", "\u248A", "\u0033\u002E", "\u248B", "\u0034\u002E", "\u248C", "\u0035\u002E", "\u248D", "\u0036\u002E", "\u248E", "\u0037\u002E", "\u248F", "\u0038\u002E", "\u2490", "\u0039\u002E", "\u2491", "\u0031\u0030\u002E", "\u2492", "\u0031\u0031\u002E", "\u2493", "\u0031\u0032\u002E", "\u2494", "\u0031\u0033\u002E", "\u2495", "\u0031\u0034\u002E", "\u2496", "\u0031\u0035\u002E", "\u2497", "\u0031\u0036\u002E", "\u2498", "\u0031\u0037\u002E", "\u2499", "\u0031\u0038\u002E", "\u249A", "\u0031\u0039\u002E", "\u249B", "\u0032\u0030\u002E", "\u249C", "\u0028\u0061\u0029", "\u249D", "\u0028\u0062\u0029", "\u249E", "\u0028\u0063\u0029", "\u249F", "\u0028\u0064\u0029", "\u24A0", "\u0028\u0065\u0029", "\u24A1", "\u0028\u0066\u0029", "\u24A2", "\u0028\u0067\u0029", "\u24A3", "\u0028\u0068\u0029", "\u24A4", "\u0028\u0069\u0029", "\u24A5", "\u0028\u006A\u0029", "\u24A6", "\u0028\u006B\u0029", "\u24A7", "\u0028\u006C\u0029", "\u24A8", "\u0028\u006D\u0029", "\u24A9", "\u0028\u006E\u0029", "\u24AA", "\u0028\u006F\u0029", "\u24AB", "\u0028\u0070\u0029", "\u24AC", "\u0028\u0071\u0029", "\u24AD", "\u0028\u0072\u0029", "\u24AE", "\u0028\u0073\u0029", "\u24AF", "\u0028\u0074\u0029", "\u24B0", "\u0028\u0075\u0029", "\u24B1", "\u0028\u0076\u0029", "\u24B2", "\u0028\u0077\u0029", "\u24B3", "\u0028\u0078\u0029", "\u24B4", "\u0028\u0079\u0029", "\u24B5", "\u0028\u007A\u0029", "\u2A0C", "\u222B\u222B\u222B\u222B", "\u2A74", "\u003A\u003A\u003D", "\u2A75", "\u003D\u003D", "\u2A76", "\u003D\u003D\u003D", "\u2E9F", "\u6BCD", "\u2EF3", "\u9F9F", "\u2F00", "\u4E00", "\u2F01", "\u4E28", "\u2F02", "\u4E36", "\u2F03", "\u4E3F", "\u2F04", "\u4E59", "\u2F05", "\u4E85", "\u2F06", "\u4E8C", "\u2F07", "\u4EA0", "\u2F08", "\u4EBA", "\u2F09", "\u513F", "\u2F0A", "\u5165", "\u2F0B", "\u516B", "\u2F0C", "\u5182", "\u2F0D", "\u5196", "\u2F0E", "\u51AB", "\u2F0F", "\u51E0", "\u2F10", "\u51F5", "\u2F11", "\u5200", "\u2F12", "\u529B", "\u2F13", "\u52F9", "\u2F14", "\u5315", "\u2F15", "\u531A", "\u2F16", "\u5338", "\u2F17", "\u5341", "\u2F18", "\u535C", "\u2F19", "\u5369", "\u2F1A", "\u5382", "\u2F1B", "\u53B6", "\u2F1C", "\u53C8", "\u2F1D", "\u53E3", "\u2F1E", "\u56D7", "\u2F1F", "\u571F", "\u2F20", "\u58EB", "\u2F21", "\u5902", "\u2F22", "\u590A", "\u2F23", "\u5915", "\u2F24", "\u5927", "\u2F25", "\u5973", "\u2F26", "\u5B50", "\u2F27", "\u5B80", "\u2F28", "\u5BF8", "\u2F29", "\u5C0F", "\u2F2A", "\u5C22", "\u2F2B", "\u5C38", "\u2F2C", "\u5C6E", "\u2F2D", "\u5C71", "\u2F2E", "\u5DDB", "\u2F2F", "\u5DE5", "\u2F30", "\u5DF1", "\u2F31", "\u5DFE", "\u2F32", "\u5E72", "\u2F33", "\u5E7A", "\u2F34", "\u5E7F", "\u2F35", "\u5EF4", "\u2F36", "\u5EFE", "\u2F37", "\u5F0B", "\u2F38", "\u5F13", "\u2F39", "\u5F50", "\u2F3A", "\u5F61", "\u2F3B", "\u5F73", "\u2F3C", "\u5FC3", "\u2F3D", "\u6208", "\u2F3E", "\u6236", "\u2F3F", "\u624B", "\u2F40", "\u652F", "\u2F41", "\u6534", "\u2F42", "\u6587", "\u2F43", "\u6597", "\u2F44", "\u65A4", "\u2F45", "\u65B9", "\u2F46", "\u65E0", "\u2F47", "\u65E5", "\u2F48", "\u66F0", "\u2F49", "\u6708", "\u2F4A", "\u6728", "\u2F4B", "\u6B20", "\u2F4C", "\u6B62", "\u2F4D", "\u6B79", "\u2F4E", "\u6BB3", "\u2F4F", "\u6BCB", "\u2F50", "\u6BD4", "\u2F51", "\u6BDB", "\u2F52", "\u6C0F", "\u2F53", "\u6C14", "\u2F54", "\u6C34", "\u2F55", "\u706B", "\u2F56", "\u722A", "\u2F57", "\u7236", "\u2F58", "\u723B", "\u2F59", "\u723F", "\u2F5A", "\u7247", "\u2F5B", "\u7259", "\u2F5C", "\u725B", "\u2F5D", "\u72AC", "\u2F5E", "\u7384", "\u2F5F", "\u7389", "\u2F60", "\u74DC", "\u2F61", "\u74E6", "\u2F62", "\u7518", "\u2F63", "\u751F", "\u2F64", "\u7528", "\u2F65", "\u7530", "\u2F66", "\u758B", "\u2F67", "\u7592", "\u2F68", "\u7676", "\u2F69", "\u767D", "\u2F6A", "\u76AE", "\u2F6B", "\u76BF", "\u2F6C", "\u76EE", "\u2F6D", "\u77DB", "\u2F6E", "\u77E2", "\u2F6F", "\u77F3", "\u2F70", "\u793A", "\u2F71", "\u79B8", "\u2F72", "\u79BE", "\u2F73", "\u7A74", "\u2F74", "\u7ACB", "\u2F75", "\u7AF9", "\u2F76", "\u7C73", "\u2F77", "\u7CF8", "\u2F78", "\u7F36", "\u2F79", "\u7F51", "\u2F7A", "\u7F8A", "\u2F7B", "\u7FBD", "\u2F7C", "\u8001", "\u2F7D", "\u800C", "\u2F7E", "\u8012", "\u2F7F", "\u8033", "\u2F80", "\u807F", "\u2F81", "\u8089", "\u2F82", "\u81E3", "\u2F83", "\u81EA", "\u2F84", "\u81F3", "\u2F85", "\u81FC", "\u2F86", "\u820C", "\u2F87", "\u821B", "\u2F88", "\u821F", "\u2F89", "\u826E", "\u2F8A", "\u8272", "\u2F8B", "\u8278", "\u2F8C", "\u864D", "\u2F8D", "\u866B", "\u2F8E", "\u8840", "\u2F8F", "\u884C", "\u2F90", "\u8863", "\u2F91", "\u897E", "\u2F92", "\u898B", "\u2F93", "\u89D2", "\u2F94", "\u8A00", "\u2F95", "\u8C37", "\u2F96", "\u8C46", "\u2F97", "\u8C55", "\u2F98", "\u8C78", "\u2F99", "\u8C9D", "\u2F9A", "\u8D64", "\u2F9B", "\u8D70", "\u2F9C", "\u8DB3", "\u2F9D", "\u8EAB", "\u2F9E", "\u8ECA", "\u2F9F", "\u8F9B", "\u2FA0", "\u8FB0", "\u2FA1", "\u8FB5", "\u2FA2", "\u9091", "\u2FA3", "\u9149", "\u2FA4", "\u91C6", "\u2FA5", "\u91CC", "\u2FA6", "\u91D1", "\u2FA7", "\u9577", "\u2FA8", "\u9580", "\u2FA9", "\u961C", "\u2FAA", "\u96B6", "\u2FAB", "\u96B9", "\u2FAC", "\u96E8", "\u2FAD", "\u9751", "\u2FAE", "\u975E", "\u2FAF", "\u9762", "\u2FB0", "\u9769", "\u2FB1", "\u97CB", "\u2FB2", "\u97ED", "\u2FB3", "\u97F3", "\u2FB4", "\u9801", "\u2FB5", "\u98A8", "\u2FB6", "\u98DB", "\u2FB7", "\u98DF", "\u2FB8", "\u9996", "\u2FB9", "\u9999", "\u2FBA", "\u99AC", "\u2FBB", "\u9AA8", "\u2FBC", "\u9AD8", "\u2FBD", "\u9ADF", "\u2FBE", "\u9B25", "\u2FBF", "\u9B2F", "\u2FC0", "\u9B32", "\u2FC1", "\u9B3C", "\u2FC2", "\u9B5A", "\u2FC3", "\u9CE5", "\u2FC4", "\u9E75", "\u2FC5", "\u9E7F", "\u2FC6", "\u9EA5", "\u2FC7", "\u9EBB", "\u2FC8", "\u9EC3", "\u2FC9", "\u9ECD", "\u2FCA", "\u9ED1", "\u2FCB", "\u9EF9", "\u2FCC", "\u9EFD", "\u2FCD", "\u9F0E", "\u2FCE", "\u9F13", "\u2FCF", "\u9F20", "\u2FD0", "\u9F3B", "\u2FD1", "\u9F4A", "\u2FD2", "\u9F52", "\u2FD3", "\u9F8D", "\u2FD4", "\u9F9C", "\u2FD5", "\u9FA0", "\u3036", "\u3012", "\u3038", "\u5341", "\u3039", "\u5344", "\u303A", "\u5345", "\u309B", "\u0020\u3099", "\u309C", "\u0020\u309A", "\u3131", "\u1100", "\u3132", "\u1101", "\u3133", "\u11AA", "\u3134", "\u1102", "\u3135", "\u11AC", "\u3136", "\u11AD", "\u3137", "\u1103", "\u3138", "\u1104", "\u3139", "\u1105", "\u313A", "\u11B0", "\u313B", "\u11B1", "\u313C", "\u11B2", "\u313D", "\u11B3", "\u313E", "\u11B4", "\u313F", "\u11B5", "\u3140", "\u111A", "\u3141", "\u1106", "\u3142", "\u1107", "\u3143", "\u1108", "\u3144", "\u1121", "\u3145", "\u1109", "\u3146", "\u110A", "\u3147", "\u110B", "\u3148", "\u110C", "\u3149", "\u110D", "\u314A", "\u110E", "\u314B", "\u110F", "\u314C", "\u1110", "\u314D", "\u1111", "\u314E", "\u1112", "\u314F", "\u1161", "\u3150", "\u1162", "\u3151", "\u1163", "\u3152", "\u1164", "\u3153", "\u1165", "\u3154", "\u1166", "\u3155", "\u1167", "\u3156", "\u1168", "\u3157", "\u1169", "\u3158", "\u116A", "\u3159", "\u116B", "\u315A", "\u116C", "\u315B", "\u116D", "\u315C", "\u116E", "\u315D", "\u116F", "\u315E", "\u1170", "\u315F", "\u1171", "\u3160", "\u1172", "\u3161", "\u1173", "\u3162", "\u1174", "\u3163", "\u1175", "\u3164", "\u1160", "\u3165", "\u1114", "\u3166", "\u1115", "\u3167", "\u11C7", "\u3168", "\u11C8", "\u3169", "\u11CC", "\u316A", "\u11CE", "\u316B", "\u11D3", "\u316C", "\u11D7", "\u316D", "\u11D9", "\u316E", "\u111C", "\u316F", "\u11DD", "\u3170", "\u11DF", "\u3171", "\u111D", "\u3172", "\u111E", "\u3173", "\u1120", "\u3174", "\u1122", "\u3175", "\u1123", "\u3176", "\u1127", "\u3177", "\u1129", "\u3178", "\u112B", "\u3179", "\u112C", "\u317A", "\u112D", "\u317B", "\u112E", "\u317C", "\u112F", "\u317D", "\u1132", "\u317E", "\u1136", "\u317F", "\u1140", "\u3180", "\u1147", "\u3181", "\u114C", "\u3182", "\u11F1", "\u3183", "\u11F2", "\u3184", "\u1157", "\u3185", "\u1158", "\u3186", "\u1159", "\u3187", "\u1184", "\u3188", "\u1185", "\u3189", "\u1188", "\u318A", "\u1191", "\u318B", "\u1192", "\u318C", "\u1194", "\u318D", "\u119E", "\u318E", "\u11A1", "\u3200", "\u0028\u1100\u0029", "\u3201", "\u0028\u1102\u0029", "\u3202", "\u0028\u1103\u0029", "\u3203", "\u0028\u1105\u0029", "\u3204", "\u0028\u1106\u0029", "\u3205", "\u0028\u1107\u0029", "\u3206", "\u0028\u1109\u0029", "\u3207", "\u0028\u110B\u0029", "\u3208", "\u0028\u110C\u0029", "\u3209", "\u0028\u110E\u0029", "\u320A", "\u0028\u110F\u0029", "\u320B", "\u0028\u1110\u0029", "\u320C", "\u0028\u1111\u0029", "\u320D", "\u0028\u1112\u0029", "\u320E", "\u0028\u1100\u1161\u0029", "\u320F", "\u0028\u1102\u1161\u0029", "\u3210", "\u0028\u1103\u1161\u0029", "\u3211", "\u0028\u1105\u1161\u0029", "\u3212", "\u0028\u1106\u1161\u0029", "\u3213", "\u0028\u1107\u1161\u0029", "\u3214", "\u0028\u1109\u1161\u0029", "\u3215", "\u0028\u110B\u1161\u0029", "\u3216", "\u0028\u110C\u1161\u0029", "\u3217", "\u0028\u110E\u1161\u0029", "\u3218", "\u0028\u110F\u1161\u0029", "\u3219", "\u0028\u1110\u1161\u0029", "\u321A", "\u0028\u1111\u1161\u0029", "\u321B", "\u0028\u1112\u1161\u0029", "\u321C", "\u0028\u110C\u116E\u0029", "\u321D", "\u0028\u110B\u1169\u110C\u1165\u11AB\u0029", "\u321E", "\u0028\u110B\u1169\u1112\u116E\u0029", "\u3220", "\u0028\u4E00\u0029", "\u3221", "\u0028\u4E8C\u0029", "\u3222", "\u0028\u4E09\u0029", "\u3223", "\u0028\u56DB\u0029", "\u3224", "\u0028\u4E94\u0029", "\u3225", "\u0028\u516D\u0029", "\u3226", "\u0028\u4E03\u0029", "\u3227", "\u0028\u516B\u0029", "\u3228", "\u0028\u4E5D\u0029", "\u3229", "\u0028\u5341\u0029", "\u322A", "\u0028\u6708\u0029", "\u322B", "\u0028\u706B\u0029", "\u322C", "\u0028\u6C34\u0029", "\u322D", "\u0028\u6728\u0029", "\u322E", "\u0028\u91D1\u0029", "\u322F", "\u0028\u571F\u0029", "\u3230", "\u0028\u65E5\u0029", "\u3231", "\u0028\u682A\u0029", "\u3232", "\u0028\u6709\u0029", "\u3233", "\u0028\u793E\u0029", "\u3234", "\u0028\u540D\u0029", "\u3235", "\u0028\u7279\u0029", "\u3236", "\u0028\u8CA1\u0029", "\u3237", "\u0028\u795D\u0029", "\u3238", "\u0028\u52B4\u0029", "\u3239", "\u0028\u4EE3\u0029", "\u323A", "\u0028\u547C\u0029", "\u323B", "\u0028\u5B66\u0029", "\u323C", "\u0028\u76E3\u0029", "\u323D", "\u0028\u4F01\u0029", "\u323E", "\u0028\u8CC7\u0029", "\u323F", "\u0028\u5354\u0029", "\u3240", "\u0028\u796D\u0029", "\u3241", "\u0028\u4F11\u0029", "\u3242", "\u0028\u81EA\u0029", "\u3243", "\u0028\u81F3\u0029", "\u32C0", "\u0031\u6708", "\u32C1", "\u0032\u6708", "\u32C2", "\u0033\u6708", "\u32C3", "\u0034\u6708", "\u32C4", "\u0035\u6708", "\u32C5", "\u0036\u6708", "\u32C6", "\u0037\u6708", "\u32C7", "\u0038\u6708", "\u32C8", "\u0039\u6708", "\u32C9", "\u0031\u0030\u6708", "\u32CA", "\u0031\u0031\u6708", "\u32CB", "\u0031\u0032\u6708", "\u3358", "\u0030\u70B9", "\u3359", "\u0031\u70B9", "\u335A", "\u0032\u70B9", "\u335B", "\u0033\u70B9", "\u335C", "\u0034\u70B9", "\u335D", "\u0035\u70B9", "\u335E", "\u0036\u70B9", "\u335F", "\u0037\u70B9", "\u3360", "\u0038\u70B9", "\u3361", "\u0039\u70B9", "\u3362", "\u0031\u0030\u70B9", "\u3363", "\u0031\u0031\u70B9", "\u3364", "\u0031\u0032\u70B9", "\u3365", "\u0031\u0033\u70B9", "\u3366", "\u0031\u0034\u70B9", "\u3367", "\u0031\u0035\u70B9", "\u3368", "\u0031\u0036\u70B9", "\u3369", "\u0031\u0037\u70B9", "\u336A", "\u0031\u0038\u70B9", "\u336B", "\u0031\u0039\u70B9", "\u336C", "\u0032\u0030\u70B9", "\u336D", "\u0032\u0031\u70B9", "\u336E", "\u0032\u0032\u70B9", "\u336F", "\u0032\u0033\u70B9", "\u3370", "\u0032\u0034\u70B9", "\u33E0", "\u0031\u65E5", "\u33E1", "\u0032\u65E5", "\u33E2", "\u0033\u65E5", "\u33E3", "\u0034\u65E5", "\u33E4", "\u0035\u65E5", "\u33E5", "\u0036\u65E5", "\u33E6", "\u0037\u65E5", "\u33E7", "\u0038\u65E5", "\u33E8", "\u0039\u65E5", "\u33E9", "\u0031\u0030\u65E5", "\u33EA", "\u0031\u0031\u65E5", "\u33EB", "\u0031\u0032\u65E5", "\u33EC", "\u0031\u0033\u65E5", "\u33ED", "\u0031\u0034\u65E5", "\u33EE", "\u0031\u0035\u65E5", "\u33EF", "\u0031\u0036\u65E5", "\u33F0", "\u0031\u0037\u65E5", "\u33F1", "\u0031\u0038\u65E5", "\u33F2", "\u0031\u0039\u65E5", "\u33F3", "\u0032\u0030\u65E5", "\u33F4", "\u0032\u0031\u65E5", "\u33F5", "\u0032\u0032\u65E5", "\u33F6", "\u0032\u0033\u65E5", "\u33F7", "\u0032\u0034\u65E5", "\u33F8", "\u0032\u0035\u65E5", "\u33F9", "\u0032\u0036\u65E5", "\u33FA", "\u0032\u0037\u65E5", "\u33FB", "\u0032\u0038\u65E5", "\u33FC", "\u0032\u0039\u65E5", "\u33FD", "\u0033\u0030\u65E5", "\u33FE", "\u0033\u0031\u65E5", "\uFB00", "\u0066\u0066", "\uFB01", "\u0066\u0069", "\uFB02", "\u0066\u006C", "\uFB03", "\u0066\u0066\u0069", "\uFB04", "\u0066\u0066\u006C", "\uFB05", "\u017F\u0074", "\uFB06", "\u0073\u0074", "\uFB13", "\u0574\u0576", "\uFB14", "\u0574\u0565", "\uFB15", "\u0574\u056B", "\uFB16", "\u057E\u0576", "\uFB17", "\u0574\u056D", "\uFB4F", "\u05D0\u05DC", "\uFB50", "\u0671", "\uFB51", "\u0671", "\uFB52", "\u067B", "\uFB53", "\u067B", "\uFB54", "\u067B", "\uFB55", "\u067B", "\uFB56", "\u067E", "\uFB57", "\u067E", "\uFB58", "\u067E", "\uFB59", "\u067E", "\uFB5A", "\u0680", "\uFB5B", "\u0680", "\uFB5C", "\u0680", "\uFB5D", "\u0680", "\uFB5E", "\u067A", "\uFB5F", "\u067A", "\uFB60", "\u067A", "\uFB61", "\u067A", "\uFB62", "\u067F", "\uFB63", "\u067F", "\uFB64", "\u067F", "\uFB65", "\u067F", "\uFB66", "\u0679", "\uFB67", "\u0679", "\uFB68", "\u0679", "\uFB69", "\u0679", "\uFB6A", "\u06A4", "\uFB6B", "\u06A4", "\uFB6C", "\u06A4", "\uFB6D", "\u06A4", "\uFB6E", "\u06A6", "\uFB6F", "\u06A6", "\uFB70", "\u06A6", "\uFB71", "\u06A6", "\uFB72", "\u0684", "\uFB73", "\u0684", "\uFB74", "\u0684", "\uFB75", "\u0684", "\uFB76", "\u0683", "\uFB77", "\u0683", "\uFB78", "\u0683", "\uFB79", "\u0683", "\uFB7A", "\u0686", "\uFB7B", "\u0686", "\uFB7C", "\u0686", "\uFB7D", "\u0686", "\uFB7E", "\u0687", "\uFB7F", "\u0687", "\uFB80", "\u0687", "\uFB81", "\u0687", "\uFB82", "\u068D", "\uFB83", "\u068D", "\uFB84", "\u068C", "\uFB85", "\u068C", "\uFB86", "\u068E", "\uFB87", "\u068E", "\uFB88", "\u0688", "\uFB89", "\u0688", "\uFB8A", "\u0698", "\uFB8B", "\u0698", "\uFB8C", "\u0691", "\uFB8D", "\u0691", "\uFB8E", "\u06A9", "\uFB8F", "\u06A9", "\uFB90", "\u06A9", "\uFB91", "\u06A9", "\uFB92", "\u06AF", "\uFB93", "\u06AF", "\uFB94", "\u06AF", "\uFB95", "\u06AF", "\uFB96", "\u06B3", "\uFB97", "\u06B3", "\uFB98", "\u06B3", "\uFB99", "\u06B3", "\uFB9A", "\u06B1", "\uFB9B", "\u06B1", "\uFB9C", "\u06B1", "\uFB9D", "\u06B1", "\uFB9E", "\u06BA", "\uFB9F", "\u06BA", "\uFBA0", "\u06BB", "\uFBA1", "\u06BB", "\uFBA2", "\u06BB", "\uFBA3", "\u06BB", "\uFBA4", "\u06C0", "\uFBA5", "\u06C0", "\uFBA6", "\u06C1", "\uFBA7", "\u06C1", "\uFBA8", "\u06C1", "\uFBA9", "\u06C1", "\uFBAA", "\u06BE", "\uFBAB", "\u06BE", "\uFBAC", "\u06BE", "\uFBAD", "\u06BE", "\uFBAE", "\u06D2", "\uFBAF", "\u06D2", "\uFBB0", "\u06D3", "\uFBB1", "\u06D3", "\uFBD3", "\u06AD", "\uFBD4", "\u06AD", "\uFBD5", "\u06AD", "\uFBD6", "\u06AD", "\uFBD7", "\u06C7", "\uFBD8", "\u06C7", "\uFBD9", "\u06C6", "\uFBDA", "\u06C6", "\uFBDB", "\u06C8", "\uFBDC", "\u06C8", "\uFBDD", "\u0677", "\uFBDE", "\u06CB", "\uFBDF", "\u06CB", "\uFBE0", "\u06C5", "\uFBE1", "\u06C5", "\uFBE2", "\u06C9", "\uFBE3", "\u06C9", "\uFBE4", "\u06D0", "\uFBE5", "\u06D0", "\uFBE6", "\u06D0", "\uFBE7", "\u06D0", "\uFBE8", "\u0649", "\uFBE9", "\u0649", "\uFBEA", "\u0626\u0627", "\uFBEB", "\u0626\u0627", "\uFBEC", "\u0626\u06D5", "\uFBED", "\u0626\u06D5", "\uFBEE", "\u0626\u0648", "\uFBEF", "\u0626\u0648", "\uFBF0", "\u0626\u06C7", "\uFBF1", "\u0626\u06C7", "\uFBF2", "\u0626\u06C6", "\uFBF3", "\u0626\u06C6", "\uFBF4", "\u0626\u06C8", "\uFBF5", "\u0626\u06C8", "\uFBF6", "\u0626\u06D0", "\uFBF7", "\u0626\u06D0", "\uFBF8", "\u0626\u06D0", "\uFBF9", "\u0626\u0649", "\uFBFA", "\u0626\u0649", "\uFBFB", "\u0626\u0649", "\uFBFC", "\u06CC", "\uFBFD", "\u06CC", "\uFBFE", "\u06CC", "\uFBFF", "\u06CC", "\uFC00", "\u0626\u062C", "\uFC01", "\u0626\u062D", "\uFC02", "\u0626\u0645", "\uFC03", "\u0626\u0649", "\uFC04", "\u0626\u064A", "\uFC05", "\u0628\u062C", "\uFC06", "\u0628\u062D", "\uFC07", "\u0628\u062E", "\uFC08", "\u0628\u0645", "\uFC09", "\u0628\u0649", "\uFC0A", "\u0628\u064A", "\uFC0B", "\u062A\u062C", "\uFC0C", "\u062A\u062D", "\uFC0D", "\u062A\u062E", "\uFC0E", "\u062A\u0645", "\uFC0F", "\u062A\u0649", "\uFC10", "\u062A\u064A", "\uFC11", "\u062B\u062C", "\uFC12", "\u062B\u0645", "\uFC13", "\u062B\u0649", "\uFC14", "\u062B\u064A", "\uFC15", "\u062C\u062D", "\uFC16", "\u062C\u0645", "\uFC17", "\u062D\u062C", "\uFC18", "\u062D\u0645", "\uFC19", "\u062E\u062C", "\uFC1A", "\u062E\u062D", "\uFC1B", "\u062E\u0645", "\uFC1C", "\u0633\u062C", "\uFC1D", "\u0633\u062D", "\uFC1E", "\u0633\u062E", "\uFC1F", "\u0633\u0645", "\uFC20", "\u0635\u062D", "\uFC21", "\u0635\u0645", "\uFC22", "\u0636\u062C", "\uFC23", "\u0636\u062D", "\uFC24", "\u0636\u062E", "\uFC25", "\u0636\u0645", "\uFC26", "\u0637\u062D", "\uFC27", "\u0637\u0645", "\uFC28", "\u0638\u0645", "\uFC29", "\u0639\u062C", "\uFC2A", "\u0639\u0645", "\uFC2B", "\u063A\u062C", "\uFC2C", "\u063A\u0645", "\uFC2D", "\u0641\u062C", "\uFC2E", "\u0641\u062D", "\uFC2F", "\u0641\u062E", "\uFC30", "\u0641\u0645", "\uFC31", "\u0641\u0649", "\uFC32", "\u0641\u064A", "\uFC33", "\u0642\u062D", "\uFC34", "\u0642\u0645", "\uFC35", "\u0642\u0649", "\uFC36", "\u0642\u064A", "\uFC37", "\u0643\u0627", "\uFC38", "\u0643\u062C", "\uFC39", "\u0643\u062D", "\uFC3A", "\u0643\u062E", "\uFC3B", "\u0643\u0644", "\uFC3C", "\u0643\u0645", "\uFC3D", "\u0643\u0649", "\uFC3E", "\u0643\u064A", "\uFC3F", "\u0644\u062C", "\uFC40", "\u0644\u062D", "\uFC41", "\u0644\u062E", "\uFC42", "\u0644\u0645", "\uFC43", "\u0644\u0649", "\uFC44", "\u0644\u064A", "\uFC45", "\u0645\u062C", "\uFC46", "\u0645\u062D", "\uFC47", "\u0645\u062E", "\uFC48", "\u0645\u0645", "\uFC49", "\u0645\u0649", "\uFC4A", "\u0645\u064A", "\uFC4B", "\u0646\u062C", "\uFC4C", "\u0646\u062D", "\uFC4D", "\u0646\u062E", "\uFC4E", "\u0646\u0645", "\uFC4F", "\u0646\u0649", "\uFC50", "\u0646\u064A", "\uFC51", "\u0647\u062C", "\uFC52", "\u0647\u0645", "\uFC53", "\u0647\u0649", "\uFC54", "\u0647\u064A", "\uFC55", "\u064A\u062C", "\uFC56", "\u064A\u062D", "\uFC57", "\u064A\u062E", "\uFC58", "\u064A\u0645", "\uFC59", "\u064A\u0649", "\uFC5A", "\u064A\u064A", "\uFC5B", "\u0630\u0670", "\uFC5C", "\u0631\u0670", "\uFC5D", "\u0649\u0670", "\uFC5E", "\u0020\u064C\u0651", "\uFC5F", "\u0020\u064D\u0651", "\uFC60", "\u0020\u064E\u0651", "\uFC61", "\u0020\u064F\u0651", "\uFC62", "\u0020\u0650\u0651", "\uFC63", "\u0020\u0651\u0670", "\uFC64", "\u0626\u0631", "\uFC65", "\u0626\u0632", "\uFC66", "\u0626\u0645", "\uFC67", "\u0626\u0646", "\uFC68", "\u0626\u0649", "\uFC69", "\u0626\u064A", "\uFC6A", "\u0628\u0631", "\uFC6B", "\u0628\u0632", "\uFC6C", "\u0628\u0645", "\uFC6D", "\u0628\u0646", "\uFC6E", "\u0628\u0649", "\uFC6F", "\u0628\u064A", "\uFC70", "\u062A\u0631", "\uFC71", "\u062A\u0632", "\uFC72", "\u062A\u0645", "\uFC73", "\u062A\u0646", "\uFC74", "\u062A\u0649", "\uFC75", "\u062A\u064A", "\uFC76", "\u062B\u0631", "\uFC77", "\u062B\u0632", "\uFC78", "\u062B\u0645", "\uFC79", "\u062B\u0646", "\uFC7A", "\u062B\u0649", "\uFC7B", "\u062B\u064A", "\uFC7C", "\u0641\u0649", "\uFC7D", "\u0641\u064A", "\uFC7E", "\u0642\u0649", "\uFC7F", "\u0642\u064A", "\uFC80", "\u0643\u0627", "\uFC81", "\u0643\u0644", "\uFC82", "\u0643\u0645", "\uFC83", "\u0643\u0649", "\uFC84", "\u0643\u064A", "\uFC85", "\u0644\u0645", "\uFC86", "\u0644\u0649", "\uFC87", "\u0644\u064A", "\uFC88", "\u0645\u0627", "\uFC89", "\u0645\u0645", "\uFC8A", "\u0646\u0631", "\uFC8B", "\u0646\u0632", "\uFC8C", "\u0646\u0645", "\uFC8D", "\u0646\u0646", "\uFC8E", "\u0646\u0649", "\uFC8F", "\u0646\u064A", "\uFC90", "\u0649\u0670", "\uFC91", "\u064A\u0631", "\uFC92", "\u064A\u0632", "\uFC93", "\u064A\u0645", "\uFC94", "\u064A\u0646", "\uFC95", "\u064A\u0649", "\uFC96", "\u064A\u064A", "\uFC97", "\u0626\u062C", "\uFC98", "\u0626\u062D", "\uFC99", "\u0626\u062E", "\uFC9A", "\u0626\u0645", "\uFC9B", "\u0626\u0647", "\uFC9C", "\u0628\u062C", "\uFC9D", "\u0628\u062D", "\uFC9E", "\u0628\u062E", "\uFC9F", "\u0628\u0645", "\uFCA0", "\u0628\u0647", "\uFCA1", "\u062A\u062C", "\uFCA2", "\u062A\u062D", "\uFCA3", "\u062A\u062E", "\uFCA4", "\u062A\u0645", "\uFCA5", "\u062A\u0647", "\uFCA6", "\u062B\u0645", "\uFCA7", "\u062C\u062D", "\uFCA8", "\u062C\u0645", "\uFCA9", "\u062D\u062C", "\uFCAA", "\u062D\u0645", "\uFCAB", "\u062E\u062C", "\uFCAC", "\u062E\u0645", "\uFCAD", "\u0633\u062C", "\uFCAE", "\u0633\u062D", "\uFCAF", "\u0633\u062E", "\uFCB0", "\u0633\u0645", "\uFCB1", "\u0635\u062D", "\uFCB2", "\u0635\u062E", "\uFCB3", "\u0635\u0645", "\uFCB4", "\u0636\u062C", "\uFCB5", "\u0636\u062D", "\uFCB6", "\u0636\u062E", "\uFCB7", "\u0636\u0645", "\uFCB8", "\u0637\u062D", "\uFCB9", "\u0638\u0645", "\uFCBA", "\u0639\u062C", "\uFCBB", "\u0639\u0645", "\uFCBC", "\u063A\u062C", "\uFCBD", "\u063A\u0645", "\uFCBE", "\u0641\u062C", "\uFCBF", "\u0641\u062D", "\uFCC0", "\u0641\u062E", "\uFCC1", "\u0641\u0645", "\uFCC2", "\u0642\u062D", "\uFCC3", "\u0642\u0645", "\uFCC4", "\u0643\u062C", "\uFCC5", "\u0643\u062D", "\uFCC6", "\u0643\u062E", "\uFCC7", "\u0643\u0644", "\uFCC8", "\u0643\u0645", "\uFCC9", "\u0644\u062C", "\uFCCA", "\u0644\u062D", "\uFCCB", "\u0644\u062E", "\uFCCC", "\u0644\u0645", "\uFCCD", "\u0644\u0647", "\uFCCE", "\u0645\u062C", "\uFCCF", "\u0645\u062D", "\uFCD0", "\u0645\u062E", "\uFCD1", "\u0645\u0645", "\uFCD2", "\u0646\u062C", "\uFCD3", "\u0646\u062D", "\uFCD4", "\u0646\u062E", "\uFCD5", "\u0646\u0645", "\uFCD6", "\u0646\u0647", "\uFCD7", "\u0647\u062C", "\uFCD8", "\u0647\u0645", "\uFCD9", "\u0647\u0670", "\uFCDA", "\u064A\u062C", "\uFCDB", "\u064A\u062D", "\uFCDC", "\u064A\u062E", "\uFCDD", "\u064A\u0645", "\uFCDE", "\u064A\u0647", "\uFCDF", "\u0626\u0645", "\uFCE0", "\u0626\u0647", "\uFCE1", "\u0628\u0645", "\uFCE2", "\u0628\u0647", "\uFCE3", "\u062A\u0645", "\uFCE4", "\u062A\u0647", "\uFCE5", "\u062B\u0645", "\uFCE6", "\u062B\u0647", "\uFCE7", "\u0633\u0645", "\uFCE8", "\u0633\u0647", "\uFCE9", "\u0634\u0645", "\uFCEA", "\u0634\u0647", "\uFCEB", "\u0643\u0644", "\uFCEC", "\u0643\u0645", "\uFCED", "\u0644\u0645", "\uFCEE", "\u0646\u0645", "\uFCEF", "\u0646\u0647", "\uFCF0", "\u064A\u0645", "\uFCF1", "\u064A\u0647", "\uFCF2", "\u0640\u064E\u0651", "\uFCF3", "\u0640\u064F\u0651", "\uFCF4", "\u0640\u0650\u0651", "\uFCF5", "\u0637\u0649", "\uFCF6", "\u0637\u064A", "\uFCF7", "\u0639\u0649", "\uFCF8", "\u0639\u064A", "\uFCF9", "\u063A\u0649", "\uFCFA", "\u063A\u064A", "\uFCFB", "\u0633\u0649", "\uFCFC", "\u0633\u064A", "\uFCFD", "\u0634\u0649", "\uFCFE", "\u0634\u064A", "\uFCFF", "\u062D\u0649", "\uFD00", "\u062D\u064A", "\uFD01", "\u062C\u0649", "\uFD02", "\u062C\u064A", "\uFD03", "\u062E\u0649", "\uFD04", "\u062E\u064A", "\uFD05", "\u0635\u0649", "\uFD06", "\u0635\u064A", "\uFD07", "\u0636\u0649", "\uFD08", "\u0636\u064A", "\uFD09", "\u0634\u062C", "\uFD0A", "\u0634\u062D", "\uFD0B", "\u0634\u062E", "\uFD0C", "\u0634\u0645", "\uFD0D", "\u0634\u0631", "\uFD0E", "\u0633\u0631", "\uFD0F", "\u0635\u0631", "\uFD10", "\u0636\u0631", "\uFD11", "\u0637\u0649", "\uFD12", "\u0637\u064A", "\uFD13", "\u0639\u0649", "\uFD14", "\u0639\u064A", "\uFD15", "\u063A\u0649", "\uFD16", "\u063A\u064A", "\uFD17", "\u0633\u0649", "\uFD18", "\u0633\u064A", "\uFD19", "\u0634\u0649", "\uFD1A", "\u0634\u064A", "\uFD1B", "\u062D\u0649", "\uFD1C", "\u062D\u064A", "\uFD1D", "\u062C\u0649", "\uFD1E", "\u062C\u064A", "\uFD1F", "\u062E\u0649", "\uFD20", "\u062E\u064A", "\uFD21", "\u0635\u0649", "\uFD22", "\u0635\u064A", "\uFD23", "\u0636\u0649", "\uFD24", "\u0636\u064A", "\uFD25", "\u0634\u062C", "\uFD26", "\u0634\u062D", "\uFD27", "\u0634\u062E", "\uFD28", "\u0634\u0645", "\uFD29", "\u0634\u0631", "\uFD2A", "\u0633\u0631", "\uFD2B", "\u0635\u0631", "\uFD2C", "\u0636\u0631", "\uFD2D", "\u0634\u062C", "\uFD2E", "\u0634\u062D", "\uFD2F", "\u0634\u062E", "\uFD30", "\u0634\u0645", "\uFD31", "\u0633\u0647", "\uFD32", "\u0634\u0647", "\uFD33", "\u0637\u0645", "\uFD34", "\u0633\u062C", "\uFD35", "\u0633\u062D", "\uFD36", "\u0633\u062E", "\uFD37", "\u0634\u062C", "\uFD38", "\u0634\u062D", "\uFD39", "\u0634\u062E", "\uFD3A", "\u0637\u0645", "\uFD3B", "\u0638\u0645", "\uFD3C", "\u0627\u064B", "\uFD3D", "\u0627\u064B", "\uFD50", "\u062A\u062C\u0645", "\uFD51", "\u062A\u062D\u062C", "\uFD52", "\u062A\u062D\u062C", "\uFD53", "\u062A\u062D\u0645", "\uFD54", "\u062A\u062E\u0645", "\uFD55", "\u062A\u0645\u062C", "\uFD56", "\u062A\u0645\u062D", "\uFD57", "\u062A\u0645\u062E", "\uFD58", "\u062C\u0645\u062D", "\uFD59", "\u062C\u0645\u062D", "\uFD5A", "\u062D\u0645\u064A", "\uFD5B", "\u062D\u0645\u0649", "\uFD5C", "\u0633\u062D\u062C", "\uFD5D", "\u0633\u062C\u062D", "\uFD5E", "\u0633\u062C\u0649", "\uFD5F", "\u0633\u0645\u062D", "\uFD60", "\u0633\u0645\u062D", "\uFD61", "\u0633\u0645\u062C", "\uFD62", "\u0633\u0645\u0645", "\uFD63", "\u0633\u0645\u0645", "\uFD64", "\u0635\u062D\u062D", "\uFD65", "\u0635\u062D\u062D", "\uFD66", "\u0635\u0645\u0645", "\uFD67", "\u0634\u062D\u0645", "\uFD68", "\u0634\u062D\u0645", "\uFD69", "\u0634\u062C\u064A", "\uFD6A", "\u0634\u0645\u062E", "\uFD6B", "\u0634\u0645\u062E", "\uFD6C", "\u0634\u0645\u0645", "\uFD6D", "\u0634\u0645\u0645", "\uFD6E", "\u0636\u062D\u0649", "\uFD6F", "\u0636\u062E\u0645", "\uFD70", "\u0636\u062E\u0645", "\uFD71", "\u0637\u0645\u062D", "\uFD72", "\u0637\u0645\u062D", "\uFD73", "\u0637\u0645\u0645", "\uFD74", "\u0637\u0645\u064A", "\uFD75", "\u0639\u062C\u0645", "\uFD76", "\u0639\u0645\u0645", "\uFD77", "\u0639\u0645\u0645", "\uFD78", "\u0639\u0645\u0649", "\uFD79", "\u063A\u0645\u0645", "\uFD7A", "\u063A\u0645\u064A", "\uFD7B", "\u063A\u0645\u0649", "\uFD7C", "\u0641\u062E\u0645", "\uFD7D", "\u0641\u062E\u0645", "\uFD7E", "\u0642\u0645\u062D", "\uFD7F", "\u0642\u0645\u0645", "\uFD80", "\u0644\u062D\u0645", "\uFD81", "\u0644\u062D\u064A", "\uFD82", "\u0644\u062D\u0649", "\uFD83", "\u0644\u062C\u062C", "\uFD84", "\u0644\u062C\u062C", "\uFD85", "\u0644\u062E\u0645", "\uFD86", "\u0644\u062E\u0645", "\uFD87", "\u0644\u0645\u062D", "\uFD88", "\u0644\u0645\u062D", "\uFD89", "\u0645\u062D\u062C", "\uFD8A", "\u0645\u062D\u0645", "\uFD8B", "\u0645\u062D\u064A", "\uFD8C", "\u0645\u062C\u062D", "\uFD8D", "\u0645\u062C\u0645", "\uFD8E", "\u0645\u062E\u062C", "\uFD8F", "\u0645\u062E\u0645", "\uFD92", "\u0645\u062C\u062E", "\uFD93", "\u0647\u0645\u062C", "\uFD94", "\u0647\u0645\u0645", "\uFD95", "\u0646\u062D\u0645", "\uFD96", "\u0646\u062D\u0649", "\uFD97", "\u0646\u062C\u0645", "\uFD98", "\u0646\u062C\u0645", "\uFD99", "\u0646\u062C\u0649", "\uFD9A", "\u0646\u0645\u064A", "\uFD9B", "\u0646\u0645\u0649", "\uFD9C", "\u064A\u0645\u0645", "\uFD9D", "\u064A\u0645\u0645", "\uFD9E", "\u0628\u062E\u064A", "\uFD9F", "\u062A\u062C\u064A", "\uFDA0", "\u062A\u062C\u0649", "\uFDA1", "\u062A\u062E\u064A", "\uFDA2", "\u062A\u062E\u0649", "\uFDA3", "\u062A\u0645\u064A", "\uFDA4", "\u062A\u0645\u0649", "\uFDA5", "\u062C\u0645\u064A", "\uFDA6", "\u062C\u062D\u0649", "\uFDA7", "\u062C\u0645\u0649", "\uFDA8", "\u0633\u062E\u0649", "\uFDA9", "\u0635\u062D\u064A", "\uFDAA", "\u0634\u062D\u064A", "\uFDAB", "\u0636\u062D\u064A", "\uFDAC", "\u0644\u062C\u064A", "\uFDAD", "\u0644\u0645\u064A", "\uFDAE", "\u064A\u062D\u064A", "\uFDAF", "\u064A\u062C\u064A", "\uFDB0", "\u064A\u0645\u064A", "\uFDB1", "\u0645\u0645\u064A", "\uFDB2", "\u0642\u0645\u064A", "\uFDB3", "\u0646\u062D\u064A", "\uFDB4", "\u0642\u0645\u062D", "\uFDB5", "\u0644\u062D\u0645", "\uFDB6", "\u0639\u0645\u064A", "\uFDB7", "\u0643\u0645\u064A", "\uFDB8", "\u0646\u062C\u062D", "\uFDB9", "\u0645\u062E\u064A", "\uFDBA", "\u0644\u062C\u0645", "\uFDBB", "\u0643\u0645\u0645", "\uFDBC", "\u0644\u062C\u0645", "\uFDBD", "\u0646\u062C\u062D", "\uFDBE", "\u062C\u062D\u064A", "\uFDBF", "\u062D\u062C\u064A", "\uFDC0", "\u0645\u062C\u064A", "\uFDC1", "\u0641\u0645\u064A", "\uFDC2", "\u0628\u062D\u064A", "\uFDC3", "\u0643\u0645\u0645", "\uFDC4", "\u0639\u062C\u0645", "\uFDC5", "\u0635\u0645\u0645", "\uFDC6", "\u0633\u062E\u064A", "\uFDC7", "\u0646\u062C\u064A", "\uFE49", "\u203E", "\uFE4A", "\u203E", "\uFE4B", "\u203E", "\uFE4C", "\u203E", "\uFE4D", "\u005F", "\uFE4E", "\u005F", "\uFE4F", "\u005F", "\uFE80", "\u0621", "\uFE81", "\u0622", "\uFE82", "\u0622", "\uFE83", "\u0623", "\uFE84", "\u0623", "\uFE85", "\u0624", "\uFE86", "\u0624", "\uFE87", "\u0625", "\uFE88", "\u0625", "\uFE89", "\u0626", "\uFE8A", "\u0626", "\uFE8B", "\u0626", "\uFE8C", "\u0626", "\uFE8D", "\u0627", "\uFE8E", "\u0627", "\uFE8F", "\u0628", "\uFE90", "\u0628", "\uFE91", "\u0628", "\uFE92", "\u0628", "\uFE93", "\u0629", "\uFE94", "\u0629", "\uFE95", "\u062A", "\uFE96", "\u062A", "\uFE97", "\u062A", "\uFE98", "\u062A", "\uFE99", "\u062B", "\uFE9A", "\u062B", "\uFE9B", "\u062B", "\uFE9C", "\u062B", "\uFE9D", "\u062C", "\uFE9E", "\u062C", "\uFE9F", "\u062C", "\uFEA0", "\u062C", "\uFEA1", "\u062D", "\uFEA2", "\u062D", "\uFEA3", "\u062D", "\uFEA4", "\u062D", "\uFEA5", "\u062E", "\uFEA6", "\u062E", "\uFEA7", "\u062E", "\uFEA8", "\u062E", "\uFEA9", "\u062F", "\uFEAA", "\u062F", "\uFEAB", "\u0630", "\uFEAC", "\u0630", "\uFEAD", "\u0631", "\uFEAE", "\u0631", "\uFEAF", "\u0632", "\uFEB0", "\u0632", "\uFEB1", "\u0633", "\uFEB2", "\u0633", "\uFEB3", "\u0633", "\uFEB4", "\u0633", "\uFEB5", "\u0634", "\uFEB6", "\u0634", "\uFEB7", "\u0634", "\uFEB8", "\u0634", "\uFEB9", "\u0635", "\uFEBA", "\u0635", "\uFEBB", "\u0635", "\uFEBC", "\u0635", "\uFEBD", "\u0636", "\uFEBE", "\u0636", "\uFEBF", "\u0636", "\uFEC0", "\u0636", "\uFEC1", "\u0637", "\uFEC2", "\u0637", "\uFEC3", "\u0637", "\uFEC4", "\u0637", "\uFEC5", "\u0638", "\uFEC6", "\u0638", "\uFEC7", "\u0638", "\uFEC8", "\u0638", "\uFEC9", "\u0639", "\uFECA", "\u0639", "\uFECB", "\u0639", "\uFECC", "\u0639", "\uFECD", "\u063A", "\uFECE", "\u063A", "\uFECF", "\u063A", "\uFED0", "\u063A", "\uFED1", "\u0641", "\uFED2", "\u0641", "\uFED3", "\u0641", "\uFED4", "\u0641", "\uFED5", "\u0642", "\uFED6", "\u0642", "\uFED7", "\u0642", "\uFED8", "\u0642", "\uFED9", "\u0643", "\uFEDA", "\u0643", "\uFEDB", "\u0643", "\uFEDC", "\u0643", "\uFEDD", "\u0644", "\uFEDE", "\u0644", "\uFEDF", "\u0644", "\uFEE0", "\u0644", "\uFEE1", "\u0645", "\uFEE2", "\u0645", "\uFEE3", "\u0645", "\uFEE4", "\u0645", "\uFEE5", "\u0646", "\uFEE6", "\u0646", "\uFEE7", "\u0646", "\uFEE8", "\u0646", "\uFEE9", "\u0647", "\uFEEA", "\u0647", "\uFEEB", "\u0647", "\uFEEC", "\u0647", "\uFEED", "\u0648", "\uFEEE", "\u0648", "\uFEEF", "\u0649", "\uFEF0", "\u0649", "\uFEF1", "\u064A", "\uFEF2", "\u064A", "\uFEF3", "\u064A", "\uFEF4", "\u064A", "\uFEF5", "\u0644\u0622", "\uFEF6", "\u0644\u0622", "\uFEF7", "\u0644\u0623", "\uFEF8", "\u0644\u0623", "\uFEF9", "\u0644\u0625", "\uFEFA", "\u0644\u0625", "\uFEFB", "\u0644\u0627", "\uFEFC", "\u0644\u0627"];

@@ -522,3 +522,3 @@ });

function reverseIfRtl(chars) {
var charsLength = chars.length;
const charsLength = chars.length;

@@ -529,9 +529,9 @@ if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {

var s = "";
const buf = [];
for (var ii = charsLength - 1; ii >= 0; ii--) {
s += chars[ii];
for (let ii = charsLength - 1; ii >= 0; ii--) {
buf.push(chars[ii]);
}
return s;
return buf.join("");
}

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -111,3 +111,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const apiVersion = docParams.apiVersion;
const workerVersion = '2.7.570';
const workerVersion = '2.8.335';

@@ -129,3 +129,3 @@ if (apiVersion !== workerVersion) {

if (typeof ReadableStream === "undefined") {
throw new Error("The browser/environment lacks native support for critical " + "functionality used by the PDF.js library (e.g. `ReadableStream`); " + "please use an `es5`-build instead.");
throw new Error("The browser/environment lacks native support for critical " + "functionality used by the PDF.js library (e.g. `ReadableStream`); " + "please use a `legacy`-build instead.");
}

@@ -164,10 +164,11 @@

const [numPages, fingerprint] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprint")]);
const [numPages, fingerprint, isPureXfa] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprint"), pdfManager.ensureDoc("isPureXfa")]);
return {
numPages,
fingerprint
fingerprint,
isPureXfa
};
}
function getPdfManager(data, evaluatorOptions) {
function getPdfManager(data, evaluatorOptions, enableXfa) {
var pdfManagerCapability = (0, _util.createPromiseCapability)();

@@ -179,3 +180,3 @@ let newPdfManager;

try {
newPdfManager = new _pdf_manager.LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
newPdfManager = new _pdf_manager.LocalPdfManager(docId, source.data, source.password, evaluatorOptions, enableXfa, docBaseUrl);
pdfManagerCapability.resolve(newPdfManager);

@@ -212,3 +213,3 @@ } catch (ex) {

rangeChunkSize: source.rangeChunkSize
}, evaluatorOptions, docBaseUrl);
}, evaluatorOptions, enableXfa, docBaseUrl);

@@ -236,3 +237,3 @@ for (let i = 0; i < cachedChunks.length; i++) {

try {
newPdfManager = new _pdf_manager.LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
newPdfManager = new _pdf_manager.LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, enableXfa, docBaseUrl);
pdfManagerCapability.resolve(newPdfManager);

@@ -355,3 +356,3 @@ } catch (ex) {

};
getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
getPdfManager(data, evaluatorOptions, data.enableXfa).then(function (newPdfManager) {
if (terminated) {

@@ -427,2 +428,12 @@ newPdfManager.terminate(new _util.AbortException("Worker was terminated."));

});
handler.on("GetPageXfa", function wphSetupGetXfa({
pageIndex
}) {
return pdfManager.getPage(pageIndex).then(function (page) {
return pdfManager.ensure(page, "xfaData");
});
});
handler.on("GetIsPureXfa", function wphSetupGetIsPureXfa(data) {
return pdfManager.ensureDoc("isPureXfa");
});
handler.on("GetOutline", function wphSetupGetOutline(data) {

@@ -429,0 +440,0 @@ return pdfManager.ensureCatalog("documentOutline");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -37,3 +37,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _xml_parser = require("../shared/xml_parser.js");
var _xml_parser = require("./xml_parser.js");

@@ -40,0 +40,0 @@ var _crypto = require("./crypto.js");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -461,2 +461,39 @@ * Licensed under the Apache License, Version 2.0 (the "License");

_setColor(event) {
const {
detail,
target
} = event;
const {
style
} = target;
for (const name of ["bgColor", "fillColor", "fgColor", "textColor", "borderColor", "strokeColor"]) {
let color = detail[name];
if (!color) {
continue;
}
color = _scripting_utils.ColorConverters[`${color[0]}_HTML`](color.slice(1));
switch (name) {
case "bgColor":
case "fillColor":
style.backgroundColor = color;
break;
case "fgColor":
case "textColor":
style.color = color;
break;
case "borderColor":
case "strokeColor":
style.borderColor = color;
break;
}
}
}
}

@@ -479,5 +516,7 @@

if (this.renderInteractiveForms) {
const textContent = storage.getOrCreateValue(id, {
value: this.data.fieldValue
}).value;
const storedData = storage.getValue(id, {
value: this.data.fieldValue,
valueAsString: this.data.fieldValue
});
const textContent = storedData.valueAsString || storedData.value || "";
const elementData = {

@@ -522,3 +561,3 @@ userValue: null,

});
element.addEventListener("updatefromsandbox", function (event) {
element.addEventListener("updatefromsandbox", event => {
const {

@@ -578,7 +617,2 @@ detail

}
},
strokeColor() {
const color = detail.strokeColor;
event.target.style.color = _scripting_utils.ColorConverters[`${color[0]}_HTML`](color.slice(1));
}

@@ -588,21 +622,39 @@

Object.keys(detail).filter(name => name in actions).forEach(name => actions[name]());
this._setColor(event);
});
element.addEventListener("keydown", event => {
elementData.beforeInputValue = event.target.value;
let commitKey = -1;
if (this.data.actions) {
element.addEventListener("keydown", event => {
elementData.beforeInputValue = event.target.value;
let commitKey = -1;
if (event.key === "Escape") {
commitKey = 0;
} else if (event.key === "Enter") {
commitKey = 2;
} else if (event.key === "Tab") {
commitKey = 3;
}
if (event.key === "Escape") {
commitKey = 0;
} else if (event.key === "Enter") {
commitKey = 2;
} else if (event.key === "Tab") {
commitKey = 3;
}
if (commitKey === -1) {
return;
}
if (commitKey === -1) {
return;
elementData.userValue = event.target.value;
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id,
name: "Keystroke",
value: event.target.value,
willCommit: true,
commitKey,
selStart: event.target.selectionStart,
selEnd: event.target.selectionEnd
}
});
});
const _blurListener = blurListener;
blurListener = null;
element.addEventListener("blur", event => {
if (this._mouseState.isDown) {
elementData.userValue = event.target.value;

@@ -616,3 +668,3 @@ this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {

willCommit: true,
commitKey,
commitKey: 1,
selStart: event.target.selectionStart,

@@ -622,63 +674,44 @@ selEnd: event.target.selectionEnd

});
});
const _blurListener = blurListener;
blurListener = null;
element.addEventListener("blur", event => {
if (this._mouseState.isDown) {
elementData.userValue = event.target.value;
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id,
name: "Keystroke",
value: event.target.value,
willCommit: true,
commitKey: 1,
selStart: event.target.selectionStart,
selEnd: event.target.selectionEnd
}
});
}
}
_blurListener(event);
});
element.addEventListener("mousedown", event => {
elementData.beforeInputValue = event.target.value;
_blurListener(event);
});
element.addEventListener("mousedown", event => {
elementData.beforeInputValue = event.target.value;
elementData.beforeInputSelectionRange = null;
});
element.addEventListener("keyup", event => {
if (event.target.selectionStart === event.target.selectionEnd) {
elementData.beforeInputSelectionRange = null;
});
element.addEventListener("keyup", event => {
if (event.target.selectionStart === event.target.selectionEnd) {
elementData.beforeInputSelectionRange = null;
}
});
element.addEventListener("select", event => {
elementData.beforeInputSelectionRange = [event.target.selectionStart, event.target.selectionEnd];
});
if (this.data.actions?.Keystroke) {
element.addEventListener("input", event => {
let selStart = -1;
let selEnd = -1;
if (elementData.beforeInputSelectionRange) {
[selStart, selEnd] = elementData.beforeInputSelectionRange;
}
});
element.addEventListener("select", event => {
elementData.beforeInputSelectionRange = [event.target.selectionStart, event.target.selectionEnd];
});
if ("Keystroke" in this.data.actions) {
element.addEventListener("input", event => {
let selStart = -1;
let selEnd = -1;
if (elementData.beforeInputSelectionRange) {
[selStart, selEnd] = elementData.beforeInputSelectionRange;
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id,
name: "Keystroke",
value: elementData.beforeInputValue,
change: event.data,
willCommit: false,
selStart,
selEnd
}
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id,
name: "Keystroke",
value: elementData.beforeInputValue,
change: event.data,
willCommit: false,
selStart,
selEnd
}
});
});
}
});
}
this._setEventListeners(element, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.value);
}
this._setEventListeners(element, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.value);
}

@@ -748,4 +781,4 @@

const id = data.id;
const value = storage.getOrCreateValue(id, {
value: data.fieldValue && data.fieldValue !== "Off"
const value = storage.getValue(id, {
value: data.fieldValue && (data.exportValue && data.exportValue === data.fieldValue || !data.exportValue && data.fieldValue !== "Off")
}).value;

@@ -812,2 +845,4 @@ this.container.className = "buttonWidgetAnnotation checkBox";

Object.keys(detail).filter(name => name in actions).forEach(name => actions[name]());
this._setColor(event);
});

@@ -836,3 +871,3 @@

const id = data.id;
const value = storage.getOrCreateValue(id, {
const value = storage.getValue(id, {
value: data.fieldValue === data.buttonValue

@@ -849,3 +884,2 @@ }).value;

element.setAttribute("pdfButtonValue", data.buttonValue);
element.setAttribute("id", id);

@@ -871,2 +905,3 @@ element.addEventListener("change", function (event) {

if (this.enableScripting && this.hasJSActions) {
const pdfButtonValue = data.buttonValue;
element.addEventListener("updatefromsandbox", event => {

@@ -878,17 +913,10 @@ const {

value() {
const fieldValue = detail.value;
const checked = pdfButtonValue === detail.value;
for (const radio of document.getElementsByName(event.target.name)) {
const radioId = radio.getAttribute("id");
if (fieldValue === radio.getAttribute("pdfButtonValue")) {
radio.setAttribute("checked", true);
storage.setValue(radioId, {
value: true
});
} else {
storage.setValue(radioId, {
value: false
});
}
radio.checked = radioId === id && checked;
storage.setValue(radioId, {
value: radio.checked
});
}

@@ -916,2 +944,4 @@ },

Object.keys(detail).filter(name => name in actions).forEach(name => actions[name]());
this._setColor(event);
});

@@ -953,3 +983,3 @@

const id = this.data.id;
storage.getOrCreateValue(id, {
storage.getValue(id, {
value: this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : undefined

@@ -982,7 +1012,23 @@ });

function getValue(event) {
const getValue = (event, isExport) => {
const name = isExport ? "value" : "textContent";
const options = event.target.options;
return options[options.selectedIndex].value;
}
if (!event.target.multiple) {
return options.selectedIndex === -1 ? null : options[options.selectedIndex][name];
}
return Array.prototype.filter.call(options, option => option.selected).map(option => option[name]);
};
const getItems = event => {
const options = event.target.options;
return Array.prototype.map.call(options, option => {
return {
displayValue: option.textContent,
exportValue: option.value
};
});
};
if (this.enableScripting && this.hasJSActions) {

@@ -995,14 +1041,105 @@ selectElement.addEventListener("updatefromsandbox", event => {

value() {
const options = event.target.options;
const options = selectElement.options;
const value = detail.value;
const i = options.indexOf(value);
const values = new Set(Array.isArray(value) ? value : [value]);
Array.prototype.forEach.call(options, option => {
option.selected = values.has(option.value);
});
storage.setValue(id, {
value: getValue(event, true)
});
},
if (i !== -1) {
options.selectedIndex = i;
storage.setValue(id, {
value
});
multipleSelection() {
selectElement.multiple = true;
},
remove() {
const options = selectElement.options;
const index = detail.remove;
options[index].selected = false;
selectElement.remove(index);
if (options.length > 0) {
const i = Array.prototype.findIndex.call(options, option => option.selected);
if (i === -1) {
options[0].selected = true;
}
}
storage.setValue(id, {
value: getValue(event, true),
items: getItems(event)
});
},
clear() {
while (selectElement.length !== 0) {
selectElement.remove(0);
}
storage.setValue(id, {
value: null,
items: []
});
},
insert() {
const {
index,
displayValue,
exportValue
} = detail.insert;
const optionElement = document.createElement("option");
optionElement.textContent = displayValue;
optionElement.value = exportValue;
selectElement.insertBefore(optionElement, selectElement.children[index]);
storage.setValue(id, {
value: getValue(event, true),
items: getItems(event)
});
},
items() {
const {
items
} = detail;
while (selectElement.length !== 0) {
selectElement.remove(0);
}
for (const item of items) {
const {
displayValue,
exportValue
} = item;
const optionElement = document.createElement("option");
optionElement.textContent = displayValue;
optionElement.value = exportValue;
selectElement.appendChild(optionElement);
}
if (selectElement.options.length > 0) {
selectElement.options[0].selected = true;
}
storage.setValue(id, {
value: getValue(event, true),
items: getItems(event)
});
},
indices() {
const indices = new Set(detail.indices);
const options = event.target.options;
Array.prototype.forEach.call(options, (option, i) => {
option.selected = indices.has(i);
});
storage.setValue(id, {
value: getValue(event, true)
});
},
focus() {

@@ -1027,7 +1164,10 @@ setTimeout(() => event.target.focus({

Object.keys(detail).filter(name => name in actions).forEach(name => actions[name]());
this._setColor(event);
});
selectElement.addEventListener("input", event => {
const value = getValue(event);
const exportValue = getValue(event, true);
const value = getValue(event, false);
storage.setValue(id, {
value
value: exportValue
});

@@ -1039,3 +1179,4 @@ this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {

name: "Keystroke",
changeEx: value,
value,
changeEx: exportValue,
willCommit: true,

@@ -1048,3 +1189,3 @@ commitKey: 1,

this._setEventListeners(selectElement, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
this._setEventListeners(selectElement, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"], ["input", "Action"]], event => event.target.checked);
} else {

@@ -1127,3 +1268,3 @@ selectElement.addEventListener("input", function (event) {

this.hideElement = this.hideWrapper ? wrapper : this.container;
this.hideElement.setAttribute("hidden", true);
this.hideElement.hidden = true;
const popup = document.createElement("div");

@@ -1204,4 +1345,4 @@ popup.className = "popup";

if (this.hideElement.hasAttribute("hidden")) {
this.hideElement.removeAttribute("hidden");
if (this.hideElement.hidden) {
this.hideElement.hidden = false;
this.container.style.zIndex += 1;

@@ -1216,4 +1357,4 @@ }

if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
this.hideElement.setAttribute("hidden", true);
if (!this.hideElement.hidden && !this.pinned) {
this.hideElement.hidden = true;
this.container.style.zIndex -= 1;

@@ -1618,8 +1759,3 @@ }

_download() {
if (!this.downloadManager) {
(0, _util.warn)("Download cannot be started due to unavailable download manager");
return;
}
this.downloadManager.downloadData(this.content, this.filename, "");
this.downloadManager?.openOrDownloadData(this.container, this.content, this.filename);
}

@@ -1660,3 +1796,3 @@

imageResourcesPath: parameters.imageResourcesPath || "",
renderInteractiveForms: typeof parameters.renderInteractiveForms === "boolean" ? parameters.renderInteractiveForms : true,
renderInteractiveForms: parameters.renderInteractiveForms !== false,
svgFactory: new _display_utils.DOMSVGFactory(),

@@ -1706,3 +1842,3 @@ annotationStorage: parameters.annotationStorage || new _annotation_storage.AnnotationStorage(),

parameters.div.removeAttribute("hidden");
parameters.div.hidden = false;
}

@@ -1709,0 +1845,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -30,2 +30,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _display_utils = require("./display_utils.js");
var _util = require("../shared/util.js");

@@ -41,3 +43,11 @@

getValue(key, defaultValue) {
const obj = this._storage.get(key);
return obj !== undefined ? obj : defaultValue;
}
getOrCreateValue(key, defaultValue) {
(0, _display_utils.deprecated)("Use getValue instead.");
if (this._storage.has(key)) {

@@ -76,7 +86,3 @@ return this._storage.get(key);

getAll() {
if (this._storage.size === 0) {
return null;
}
return (0, _util.objectFromEntries)(this._storage);
return this._storage.size > 0 ? (0, _util.objectFromMap)(this._storage) : null;
}

@@ -108,4 +114,8 @@

get serializable() {
return this._storage.size > 0 ? this._storage : null;
}
}
exports.AnnotationStorage = AnnotationStorage;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -76,3 +76,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

if (typeof src === "string") {
if (typeof src === "string" || src instanceof URL) {
source = {

@@ -91,3 +91,3 @@ url: src

if (typeof src !== "object") {
throw new Error("Invalid parameter in getDocument, " + "need either Uint8Array, string or a parameter object");
throw new Error("Invalid parameter in getDocument, " + "need either string, URL, Uint8Array, or parameter object.");
}

@@ -107,28 +107,47 @@

for (const key in source) {
if (key === "url" && typeof window !== "undefined") {
params[key] = new URL(source[key], window.location).href;
continue;
} else if (key === "range") {
rangeTransport = source[key];
continue;
} else if (key === "worker") {
worker = source[key];
continue;
} else if (key === "data" && !(source[key] instanceof Uint8Array)) {
const pdfBytes = source[key];
const value = source[key];
if (typeof pdfBytes === "string") {
params[key] = (0, _util.stringToBytes)(pdfBytes);
} else if (typeof pdfBytes === "object" && pdfBytes !== null && !isNaN(pdfBytes.length)) {
params[key] = new Uint8Array(pdfBytes);
} else if ((0, _util.isArrayBuffer)(pdfBytes)) {
params[key] = new Uint8Array(pdfBytes);
} else {
throw new Error("Invalid PDF binary data: either typed array, " + "string or array-like object is expected in the " + "data property.");
}
switch (key) {
case "url":
if (typeof window !== "undefined") {
try {
params[key] = new URL(value, window.location).href;
continue;
} catch (ex) {
(0, _util.warn)(`Cannot create valid URL: "${ex}".`);
}
} else if (typeof value === "string" || value instanceof URL) {
params[key] = value.toString();
continue;
}
continue;
throw new Error("Invalid PDF url data: " + "either string or URL-object is expected in the url property.");
case "range":
rangeTransport = value;
continue;
case "worker":
worker = value;
continue;
case "data":
if (_is_node.isNodeJS && typeof Buffer !== "undefined" && value instanceof Buffer) {
params[key] = new Uint8Array(value);
} else if (value instanceof Uint8Array) {
break;
} else if (typeof value === "string") {
params[key] = (0, _util.stringToBytes)(value);
} else if (typeof value === "object" && value !== null && !isNaN(value.length)) {
params[key] = new Uint8Array(value);
} else if ((0, _util.isArrayBuffer)(value)) {
params[key] = new Uint8Array(value);
} else {
throw new Error("Invalid PDF binary data: either typed array, " + "string, or array-like object is expected in the data property.");
}
continue;
}
params[key] = source[key];
params[key] = value;
}

@@ -141,3 +160,8 @@

params.pdfBug = params.pdfBug === true;
params.enableXfa = params.enableXfa === true;
if (typeof params.docBaseUrl !== "string" || (0, _display_utils.isDataScheme)(params.docBaseUrl)) {
params.docBaseUrl = null;
}
if (!Number.isInteger(params.maxImageSize)) {

@@ -198,2 +222,3 @@ params.maxImageSize = -1;

progressiveDone: params.progressiveDone,
contentDispositionFilename: params.contentDispositionFilename,
disableRange: params.disableRange,

@@ -240,2 +265,3 @@ disableStream: params.disableStream

source.progressiveDone = pdfDataRangeTransport.progressiveDone;
source.contentDispositionFilename = pdfDataRangeTransport.contentDispositionFilename;
}

@@ -245,3 +271,3 @@

docId,
apiVersion: '2.7.570',
apiVersion: '2.8.335',
source: {

@@ -261,3 +287,4 @@ data: source.data,

isEvalSupported: source.isEvalSupported,
fontExtraProperties: source.fontExtraProperties
fontExtraProperties: source.fontExtraProperties,
enableXfa: source.enableXfa
}).then(function (workerId) {

@@ -311,6 +338,7 @@ if (worker.destroyed) {

class PDFDataRangeTransport {
constructor(length, initialData, progressiveDone = false) {
constructor(length, initialData, progressiveDone = false, contentDispositionFilename = null) {
this.length = length;
this.initialData = initialData;
this.progressiveDone = progressiveDone;
this.contentDispositionFilename = contentDispositionFilename;
this._rangeListeners = [];

@@ -401,2 +429,6 @@ this._progressListeners = [];

get isPureXfa() {
return this._pdfInfo.isPureXfa;
}
getPage(pageNumber) {

@@ -482,4 +514,4 @@ return this._transport.getPage(pageNumber);

cleanup() {
return this._transport.startCleanup();
cleanup(keepLoadedFonts = false) {
return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
}

@@ -575,8 +607,8 @@

} = {}) {
if (!this.annotationsPromise || this.annotationsIntent !== intent) {
this.annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent);
this.annotationsIntent = intent;
if (!this._annotationsPromise || this._annotationsIntent !== intent) {
this._annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent);
this._annotationsIntent = intent;
}
return this.annotationsPromise;
return this._annotationsPromise;
}

@@ -588,2 +620,6 @@

getXfa() {
return this._xfaPromise || (this._xfaPromise = this._transport.getPageXfa(this._pageIndex));
}
render({

@@ -602,2 +638,4 @@ canvasContext,

}) {
var _intentState;
if (this._stats) {

@@ -650,3 +688,3 @@ this._stats.time("Overall");

renderInteractiveForms: renderInteractiveForms === true,
annotationStorage: annotationStorage?.getAll() || null
annotationStorage: annotationStorage?.serializable || null
});

@@ -656,8 +694,4 @@ }

const complete = error => {
const i = intentState.renderTasks.indexOf(internalRenderTask);
intentState.renderTasks.delete(internalRenderTask);
if (i >= 0) {
intentState.renderTasks.splice(i, 1);
}
if (this.cleanupAfterRender || renderingIntent === "print") {

@@ -705,8 +739,3 @@ this.pendingCleanup = true;

});
if (!intentState.renderTasks) {
intentState.renderTasks = [];
}
intentState.renderTasks.push(internalRenderTask);
((_intentState = intentState).renderTasks || (_intentState.renderTasks = new Set())).add(internalRenderTask);
const renderTask = internalRenderTask.task;

@@ -736,7 +765,3 @@ Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => {

intentState.opListReadCapability.resolve(intentState.operatorList);
const i = intentState.renderTasks.indexOf(opListTask);
if (i >= 0) {
intentState.renderTasks.splice(i, 1);
}
intentState.renderTasks.delete(opListTask);
}

@@ -758,7 +783,8 @@ }

if (!intentState.opListReadCapability) {
var _intentState2;
opListTask = Object.create(null);
opListTask.operatorListChanged = operatorListChanged;
intentState.opListReadCapability = (0, _util.createPromiseCapability)();
intentState.renderTasks = [];
intentState.renderTasks.push(opListTask);
((_intentState2 = intentState).renderTasks || (_intentState2.renderTasks = new Set())).add(opListTask);
intentState.operatorList = {

@@ -853,4 +879,5 @@ fnArray: [],

this.objs.clear();
this.annotationsPromise = null;
this._annotationsPromise = null;
this._jsActionsPromise = null;
this._xfaPromise = null;
this.pendingCleanup = false;

@@ -874,3 +901,3 @@ return Promise.all(waitOn);

} of this._intentStates.values()) {
if (renderTasks.length !== 0 || !operatorList.lastChunk) {
if (renderTasks.size > 0 || !operatorList.lastChunk) {
return false;

@@ -883,4 +910,5 @@ }

this.objs.clear();
this.annotationsPromise = null;
this._annotationsPromise = null;
this._jsActionsPromise = null;
this._xfaPromise = null;

@@ -919,4 +947,4 @@ if (resetStats && this._stats) {

for (let i = 0; i < intentState.renderTasks.length; i++) {
intentState.renderTasks[i].operatorListChanged();
for (const internalRenderTask of intentState.renderTasks) {
internalRenderTask.operatorListChanged();
}

@@ -967,4 +995,4 @@

for (let i = 0; i < intentState.renderTasks.length; i++) {
intentState.renderTasks[i].operatorListChanged();
for (const internalRenderTask of intentState.renderTasks) {
internalRenderTask.operatorListChanged();
}

@@ -1000,3 +1028,3 @@

if (!force) {
if (intentState.renderTasks.length !== 0) {
if (intentState.renderTasks.size > 0) {
return;

@@ -1046,5 +1074,4 @@ }

class LoopbackPort {
constructor(defer = true) {
constructor() {
this._listeners = [];
this._defer = defer;
this._deferred = Promise.resolve(undefined);

@@ -1076,2 +1103,24 @@ }

if (value instanceof Map) {
result = new Map();
cloned.set(value, result);
for (const [key, val] of value) {
result.set(key, cloneValue(val));
}
return result;
}
if (value instanceof Set) {
result = new Set();
cloned.set(value, result);
for (const val of value) {
result.add(cloneValue(val));
}
return result;
}
result = Array.isArray(value) ? [] : {};

@@ -1093,3 +1142,3 @@ cloned.set(value, result);

if (typeof desc.value === "function") {
if (value.hasOwnProperty && value.hasOwnProperty(i)) {
if (value.hasOwnProperty?.(i)) {
throw new Error(`LoopbackPort.postMessage - cannot clone: ${value[i]}`);

@@ -1107,14 +1156,4 @@ }

if (!this._defer) {
this._listeners.forEach(listener => {
listener.call(this, {
data: obj
});
});
return;
}
const cloned = new WeakMap();
const e = {
const event = {
data: cloneValue(obj)

@@ -1124,5 +1163,5 @@ };

this._deferred.then(() => {
this._listeners.forEach(listener => {
listener.call(this, e);
});
for (const listener of this._listeners) {
listener.call(this, event);
}
});

@@ -1905,3 +1944,3 @@ }

numPages: this._numPages,
annotationStorage: annotationStorage?.getAll() || null,
annotationStorage: annotationStorage?.serializable || null,
filename: this._fullReader?.filename ?? null

@@ -1979,2 +2018,8 @@ }).finally(() => {

getPageXfa(pageIndex) {
return this.messageHandler.sendWithPromise("GetPageXfa", {
pageIndex
});
}
getOutline() {

@@ -2013,20 +2058,30 @@ return this.messageHandler.sendWithPromise("GetOutline", null);

startCleanup() {
return this.messageHandler.sendWithPromise("Cleanup", null).then(() => {
for (let i = 0, ii = this.pageCache.length; i < ii; i++) {
const page = this.pageCache[i];
async startCleanup(keepLoadedFonts = false) {
await this.messageHandler.sendWithPromise("Cleanup", null);
if (page) {
const cleanupSuccessful = page.cleanup();
if (this.destroyed) {
return;
}
if (!cleanupSuccessful) {
throw new Error(`startCleanup: Page ${i + 1} is currently rendering.`);
}
}
for (let i = 0, ii = this.pageCache.length; i < ii; i++) {
const page = this.pageCache[i];
if (!page) {
continue;
}
this.commonObjs.clear();
const cleanupSuccessful = page.cleanup();
if (!cleanupSuccessful) {
throw new Error(`startCleanup: Page ${i + 1} is currently rendering.`);
}
}
this.commonObjs.clear();
if (!keepLoadedFonts) {
this.fontLoader.clear();
this._hasJSActionsPromise = null;
});
}
this._hasJSActionsPromise = null;
}

@@ -2145,2 +2200,3 @@

this.task = new RenderTask(this);
this._cancelBound = this.cancel.bind(this);
this._continueBound = this._continue.bind(this);

@@ -2252,6 +2308,6 @@ this._scheduleNextBound = this._scheduleNext.bind(this);

window.requestAnimationFrame(() => {
this._nextBound().catch(this.cancel.bind(this));
this._nextBound().catch(this._cancelBound);
});
} else {
Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this));
Promise.resolve().then(this._nextBound).catch(this._cancelBound);
}

@@ -2287,5 +2343,5 @@ }

const version = '2.7.570';
const version = '2.8.335';
exports.version = version;
const build = 'f2c7338b0';
const build = '228adbf67';
exports.build = build;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -31,3 +31,6 @@ * Licensed under the Apache License, Version 2.0 (the "License");

exports.getFilenameFromUrl = getFilenameFromUrl;
exports.getPdfFilenameFromUrl = getPdfFilenameFromUrl;
exports.isDataScheme = isDataScheme;
exports.isFetchSupported = isFetchSupported;
exports.isPdfFile = isPdfFile;
exports.isValidFetchUrl = isValidFetchUrl;

@@ -252,5 +255,8 @@ exports.loadScript = loadScript;

let rotateA, rotateB, rotateC, rotateD;
rotation = rotation % 360;
rotation = rotation < 0 ? rotation + 360 : rotation;
rotation %= 360;
if (rotation < 0) {
rotation += 360;
}
switch (rotation) {

@@ -416,2 +422,17 @@ case 180:

function isDataScheme(url) {
const ii = url.length;
let i = 0;
while (i < ii && url[i].trim() === "") {
i++;
}
return url.substring(i, i + 5).toLowerCase() === "data:";
}
function isPdfFile(filename) {
return typeof filename === "string" && /\.pdf$/i.test(filename);
}
function getFilenameFromUrl(url) {

@@ -424,2 +445,30 @@ const anchor = url.indexOf("#");

function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
if (typeof url !== "string") {
return defaultFilename;
}
if (isDataScheme(url)) {
(0, _util.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
return defaultFilename;
}
const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
const splitURI = reURI.exec(url);
let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
if (suggestedFilename) {
suggestedFilename = suggestedFilename[0];
if (suggestedFilename.includes("%")) {
try {
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
} catch (ex) {}
}
}
return suggestedFilename || defaultFilename;
}
class StatTimer {

@@ -426,0 +475,0 @@ constructor() {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -309,3 +309,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

ignoreErrors = false,
onUnsupportedFeature = null,
onUnsupportedFeature,
fontRegistry = null

@@ -370,7 +370,5 @@ }) {

if (this._onUnsupportedFeature) {
this._onUnsupportedFeature({
featureId: _util.UNSUPPORTED_FEATURES.errorFontGetPath
});
}
this._onUnsupportedFeature({
featureId: _util.UNSUPPORTED_FEATURES.errorFontGetPath
});

@@ -377,0 +375,0 @@ (0, _util.warn)(`getPathGenerator - ignoring character: "${ex}".`);

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,124 +32,11 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _xml_parser = require("../shared/xml_parser.js");
class Metadata {
constructor(data) {
(0, _util.assert)(typeof data === "string", "Metadata: input is not a string");
data = this._repair(data);
const parser = new _xml_parser.SimpleXMLParser({
lowerCaseName: true
});
const xmlDocument = parser.parseFromString(data);
this._metadataMap = new Map();
if (xmlDocument) {
this._parse(xmlDocument);
}
this._data = data;
constructor({
parsedData,
rawData
}) {
this._metadataMap = parsedData;
this._data = rawData;
}
_repair(data) {
return data.replace(/^[^<]+/, "").replace(/>\\376\\377([^<]+)/g, function (all, codes) {
const bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
}).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
switch (name) {
case "amp":
return "&";
case "apos":
return "'";
case "gt":
return ">";
case "lt":
return "<";
case "quot":
return '"';
}
throw new Error(`_repair: ${name} isn't defined.`);
});
let chars = "";
for (let i = 0, ii = bytes.length; i < ii; i += 2) {
const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
chars += String.fromCharCode(code);
} else {
chars += "&#x" + (0x10000 + code).toString(16).substring(1) + ";";
}
}
return ">" + chars;
});
}
_getSequence(entry) {
const name = entry.nodeName;
if (name !== "rdf:bag" && name !== "rdf:seq" && name !== "rdf:alt") {
return null;
}
return entry.childNodes.filter(node => node.nodeName === "rdf:li");
}
_getCreators(entry) {
if (entry.nodeName !== "dc:creator") {
return false;
}
if (!entry.hasChildNodes()) {
return true;
}
const seqNode = entry.childNodes[0];
const authors = this._getSequence(seqNode) || [];
this._metadataMap.set(entry.nodeName, authors.map(node => node.textContent.trim()));
return true;
}
_parse(xmlDocument) {
let rdf = xmlDocument.documentElement;
if (rdf.nodeName !== "rdf:rdf") {
rdf = rdf.firstChild;
while (rdf && rdf.nodeName !== "rdf:rdf") {
rdf = rdf.nextSibling;
}
}
if (!rdf || rdf.nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
return;
}
for (const desc of rdf.childNodes) {
if (desc.nodeName !== "rdf:description") {
continue;
}
for (const entry of desc.childNodes) {
const name = entry.nodeName;
if (name === "#text") {
continue;
}
if (this._getCreators(entry)) {
continue;
}
this._metadataMap.set(name, entry.textContent.trim());
}
}
}
getRaw() {

@@ -164,3 +51,3 @@ return this._data;

getAll() {
return (0, _util.objectFromEntries)(this._metadataMap);
return (0, _util.objectFromMap)(this._metadataMap);
}

@@ -167,0 +54,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -37,2 +37,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _display_utils = require("./display_utils.js");
function validateRangeRequestCapabilities({

@@ -91,3 +93,3 @@ getResponseHeader,

if (/\.pdf$/i.test(filename)) {
if ((0, _display_utils.isPdfFile)(filename)) {
return filename;

@@ -105,3 +107,3 @@ }

return new _util.UnexpectedResponseException("Unexpected server response (" + status + ') while retrieving PDF "' + url + '".', status);
return new _util.UnexpectedResponseException(`Unexpected server response (${status}) while retrieving PDF "${url}".`, status);
}

@@ -108,0 +110,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -172,7 +172,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

getGroups() {
if (!this._groups.size) {
return null;
}
return (0, _util.objectFromEntries)(this._groups);
return this._groups.size > 0 ? (0, _util.objectFromMap)(this._groups) : null;
}

@@ -179,0 +175,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -696,3 +696,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
current.textMatrixScale = Math.sqrt(a * a + b * b);
current.textMatrixScale = Math.hypot(a, b);
current.x = current.lineX = 0;

@@ -699,0 +699,0 @@ current.y = current.lineY = 0;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -34,2 +34,5 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const MAX_TEXT_DIVS_TO_RENDER = 100000;
const DEFAULT_FONT_SIZE = 30;
const DEFAULT_FONT_ASCENT = 0.8;
const ascentCache = new Map();
const NonWhitespaceRegexp = /\S/;

@@ -41,3 +44,60 @@

function appendText(task, geom, styles) {
function getAscent(fontFamily, ctx) {
const cachedAscent = ascentCache.get(fontFamily);
if (cachedAscent) {
return cachedAscent;
}
ctx.save();
ctx.font = `${DEFAULT_FONT_SIZE}px ${fontFamily}`;
const metrics = ctx.measureText("");
let ascent = metrics.fontBoundingBoxAscent;
let descent = Math.abs(metrics.fontBoundingBoxDescent);
if (ascent) {
ctx.restore();
const ratio = ascent / (ascent + descent);
ascentCache.set(fontFamily, ratio);
return ratio;
}
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;
descent = 0;
for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
if (pixels[i] > 0) {
descent = Math.ceil(i / 4 / DEFAULT_FONT_SIZE);
break;
}
}
ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
ctx.strokeText("A", 0, DEFAULT_FONT_SIZE);
pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE).data;
ascent = 0;
for (let i = 0, ii = pixels.length; i < ii; i += 4) {
if (pixels[i] > 0) {
ascent = DEFAULT_FONT_SIZE - Math.floor(i / 4 / DEFAULT_FONT_SIZE);
break;
}
}
ctx.restore();
if (ascent) {
const ratio = ascent / (ascent + descent);
ascentCache.set(fontFamily, ratio);
return ratio;
}
ascentCache.set(fontFamily, DEFAULT_FONT_ASCENT);
return DEFAULT_FONT_ASCENT;
}
function appendText(task, geom, styles, ctx) {
const textDiv = document.createElement("span");

@@ -75,11 +135,4 @@ const textDivProperties = {

const fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
let fontAscent = fontHeight;
if (style.ascent) {
fontAscent = style.ascent * fontAscent;
} else if (style.descent) {
fontAscent = (1 + style.descent) * fontAscent;
}
const fontHeight = Math.hypot(tx[2], tx[3]);
const fontAscent = fontHeight * getAscent(style.fontFamily, ctx);
let left, top;

@@ -100,2 +153,3 @@

textDiv.textContent = geom.str;
textDiv.dir = geom.dir;

@@ -522,3 +576,3 @@ if (task._fontInspectorEnabled) {

appendText(this, items[i], styleCache);
appendText(this, items[i], styleCache, this._layoutTextCtx);
}

@@ -581,2 +635,3 @@ },

canvas.height = canvas.width = DEFAULT_FONT_SIZE;
canvas.mozOpaque = true;

@@ -583,0 +638,0 @@ this._layoutTextCtx = canvas.getContext("2d", {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,2 +32,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _display_utils = require("./display_utils.js");
class PDFDataTransportStream {

@@ -38,2 +40,3 @@ constructor(params, pdfDataRangeTransport) {

this._progressiveDone = params.progressiveDone || false;
this._contentDispositionFilename = params.contentDispositionFilename || null;
const initialData = params.initialData;

@@ -150,3 +153,3 @@

this._queuedChunks = null;
return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone);
return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone, this._contentDispositionFilename);
}

@@ -187,6 +190,6 @@

class PDFDataTransportStreamReader {
constructor(stream, queuedChunks, progressiveDone = false) {
constructor(stream, queuedChunks, progressiveDone = false, contentDispositionFilename = null) {
this._stream = stream;
this._done = progressiveDone || false;
this._filename = null;
this._filename = (0, _display_utils.isPdfFile)(contentDispositionFilename) ? contentDispositionFilename : null;
this._queuedChunks = queuedChunks || [];

@@ -193,0 +196,0 @@ this._loaded = 0;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -26,3 +26,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

function xmlEncode(s) {
var i = 0,
let i = 0,
ch;

@@ -39,3 +39,3 @@ s = String(s);

var buf = s.substring(0, i);
let buf = s.substring(0, i);

@@ -111,5 +111,5 @@ while (i < s.length) {

if (NS) {
var suffix = ":" + name;
const suffix = ":" + name;
for (var fullName in this.attributes) {
for (const fullName in this.attributes) {
if (fullName.slice(-suffix.length) === suffix) {

@@ -132,3 +132,3 @@ return this.attributes[fullName];

appendChild: function DOMElement_appendChild(element) {
var childNodes = this.childNodes;
const childNodes = this.childNodes;

@@ -143,3 +143,3 @@ if (!childNodes.includes(element)) {

cloneNode: function DOMElement_cloneNode() {
var newNode = new DOMElement(this.nodeName);
const newNode = new DOMElement(this.nodeName);
newNode.childNodes = this.childNodes;

@@ -151,5 +151,5 @@ newNode.attributes = this.attributes;

toString: function DOMElement_toString() {
var buf = [];
var serializer = this.getSerializer();
var chunk;
const buf = [];
const serializer = this.getSerializer();
let chunk;

@@ -177,3 +177,3 @@ while ((chunk = serializer.getNext()) !== null) {

getNext: function DOMElementSerializer_getNext() {
var node = this._node;
const node = this._node;

@@ -199,3 +199,3 @@ switch (this._state) {

if (this._loopIndex < this._attributeKeys.length) {
var name = this._attributeKeys[this._loopIndex++];
const name = this._attributeKeys[this._loopIndex++];
return " " + name + '="' + xmlEncode(node.attributes[name]) + '"';

@@ -217,6 +217,4 @@ }

case 5:
var value;
while (true) {
value = this._childSerializer && this._childSerializer.getNext();
const value = this._childSerializer && this._childSerializer.getNext();

@@ -227,3 +225,3 @@ if (value !== null) {

var nextChild = node.childNodes[this._loopIndex++];
const nextChild = node.childNodes[this._loopIndex++];

@@ -265,3 +263,3 @@ if (nextChild) {

createElementNS(NS, element) {
var elObject = new DOMElement(element);
const elObject = new DOMElement(element);
return elObject;

@@ -305,3 +303,3 @@ },

exports.Image = Image;
var exported_symbols = Object.keys(exports);
const exported_symbols = Object.keys(exports);

@@ -308,0 +306,0 @@ exports.setStubs = function (namespace) {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -40,2 +40,14 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
Object.defineProperty(exports, "getPdfFilenameFromUrl", {
enumerable: true,
get: function () {
return _display_utils.getPdfFilenameFromUrl;
}
});
Object.defineProperty(exports, "isPdfFile", {
enumerable: true,
get: function () {
return _display_utils.isPdfFile;
}
});
Object.defineProperty(exports, "LinkTarget", {

@@ -221,2 +233,8 @@ enumerable: true,

});
Object.defineProperty(exports, "XfaLayer", {
enumerable: true,
get: function () {
return _xfa_layer.XfaLayer;
}
});

@@ -239,4 +257,6 @@ var _display_utils = require("./display/display_utils.js");

const pdfjsVersion = '2.7.570';
const pdfjsBuild = 'f2c7338b0';
var _xfa_layer = require("./display/xfa_layer.js");
const pdfjsVersion = '2.8.335';
const pdfjsBuild = '228adbf67';
{

@@ -243,0 +263,0 @@ const {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -37,3 +37,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const pdfjsVersion = '2.7.570';
const pdfjsBuild = 'f2c7338b0';
const pdfjsVersion = '2.8.335';
const pdfjsBuild = '228adbf67';

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,5 +32,5 @@ * Licensed under the Apache License, Version 2.0 (the "License");

exports.bytesToString = bytesToString;
exports.createObjectURL = createObjectURL;
exports.createPromiseCapability = createPromiseCapability;
exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
exports.encodeToXmlString = encodeToXmlString;
exports.escapeString = escapeString;

@@ -47,3 +47,3 @@ exports.getModificationDate = getModificationDate;

exports.isString = isString;
exports.objectFromEntries = objectFromEntries;
exports.objectFromMap = objectFromMap;
exports.objectSize = objectSize;

@@ -61,3 +61,3 @@ exports.removeNullCharacters = removeNullCharacters;

exports.warn = warn;
exports.VerbosityLevel = exports.Util = exports.UNSUPPORTED_FEATURES = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.PageActionEventType = exports.OPS = exports.MissingPDFException = exports.IsLittleEndianCached = exports.IsEvalSupportedCached = exports.InvalidPDFException = exports.ImageKind = exports.IDENTITY_MATRIX = exports.FormatError = exports.FontType = exports.FONT_IDENTITY_MATRIX = exports.DocumentActionEventType = exports.createObjectURL = exports.CMapCompressionType = exports.BaseException = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.AnnotationActionEventType = exports.AbortException = void 0;
exports.VerbosityLevel = exports.Util = exports.UNSUPPORTED_FEATURES = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.PageActionEventType = exports.OPS = exports.MissingPDFException = exports.IsLittleEndianCached = exports.IsEvalSupportedCached = exports.InvalidPDFException = exports.ImageKind = exports.IDENTITY_MATRIX = exports.FormatError = exports.FontType = exports.FONT_IDENTITY_MATRIX = exports.DocumentActionEventType = exports.CMapCompressionType = exports.BaseException = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.AnnotationActionEventType = exports.AbortException = void 0;

@@ -637,4 +637,10 @@ require("./compatibility.js");

function objectFromEntries(iterable) {
return Object.assign(Object.create(null), Object.fromEntries(iterable));
function objectFromMap(map) {
const obj = Object.create(null);
for (const [key, value] of map) {
obj[key] = value;
}
return obj;
}

@@ -721,3 +727,3 @@

const first = (a + d) / 2;
const second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
const sx = first + second || 1;

@@ -856,5 +862,9 @@ const sy = first - second || 1;

return arr1.every(function (element, index) {
return element === arr2[index];
});
for (let i = 0, ii = arr1.length; i < ii; i++) {
if (arr1[i] !== arr2[i]) {
return false;
}
}
return true;
}

@@ -890,80 +900,24 @@

const createObjectURL = function createObjectURLClosure() {
const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
return function createObjectURL(data, contentType, forceDataSchema = false) {
if (!forceDataSchema && URL.createObjectURL) {
const blob = new Blob([data], {
type: contentType
});
return URL.createObjectURL(blob);
}
let buffer = `data:${contentType};base64,`;
for (let i = 0, ii = data.length; i < ii; i += 3) {
const b1 = data[i] & 0xff;
const b2 = data[i + 1] & 0xff;
const b3 = data[i + 2] & 0xff;
const d1 = b1 >> 2,
d2 = (b1 & 3) << 4 | b2 >> 4;
const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
const d4 = i + 2 < ii ? b3 & 0x3f : 64;
buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
}
return buffer;
};
}();
exports.createObjectURL = createObjectURL;
const XMLEntities = {
0x3c: "&lt;",
0x3e: "&gt;",
0x26: "&amp;",
0x22: "&quot;",
0x27: "&apos;"
};
function encodeToXmlString(str) {
const buffer = [];
let start = 0;
for (let i = 0, ii = str.length; i < ii; i++) {
const char = str.codePointAt(i);
if (0x20 <= char && char <= 0x7e) {
const entity = XMLEntities[char];
if (entity) {
if (start < i) {
buffer.push(str.substring(start, i));
}
buffer.push(entity);
start = i + 1;
}
} else {
if (start < i) {
buffer.push(str.substring(start, i));
}
buffer.push(`&#x${char.toString(16).toUpperCase()};`);
if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
i++;
}
start = i + 1;
}
function createObjectURL(data, contentType = "", forceDataSchema = false) {
if (URL.createObjectURL && !forceDataSchema) {
return URL.createObjectURL(new Blob([data], {
type: contentType
}));
}
if (buffer.length === 0) {
return str;
}
const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
let buffer = `data:${contentType};base64,`;
if (start < str.length) {
buffer.push(str.substring(start, str.length));
for (let i = 0, ii = data.length; i < ii; i += 3) {
const b1 = data[i] & 0xff;
const b2 = data[i + 1] & 0xff;
const b3 = data[i + 2] & 0xff;
const d1 = b1 >> 2,
d2 = (b1 & 3) << 4 | b2 >> 4;
const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
const d4 = i + 2 < ii ? b3 & 0x3f : 64;
buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
}
return buffer.join("");
return buffer;
}

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -28,10 +28,13 @@ * Licensed under the Apache License, Version 2.0 (the "License");

describe("AnnotationStorage", function () {
describe("GetOrCreateValue", function () {
describe("GetOrDefaultValue", function () {
it("should get and set a new value in the annotation storage", function (done) {
const annotationStorage = new _annotation_storage.AnnotationStorage();
let value = annotationStorage.getOrCreateValue("123A", {
let value = annotationStorage.getValue("123A", {
value: "hello world"
}).value;
expect(value).toEqual("hello world");
value = annotationStorage.getOrCreateValue("123A", {
annotationStorage.setValue("123A", {
value: "hello world"
});
value = annotationStorage.getValue("123A", {
value: "an other string"

@@ -62,14 +65,15 @@ }).value;

annotationStorage.onSetModified = callback;
annotationStorage.getOrCreateValue("asdf", {
annotationStorage.setValue("asdf", {
value: "original"
});
expect(called).toBe(false);
expect(called).toBe(true);
annotationStorage.setValue("asdf", {
value: "original"
value: "modified"
});
expect(called).toBe(false);
expect(called).toBe(true);
called = false;
annotationStorage.setValue("asdf", {
value: "modified"
});
expect(called).toBe(true);
expect(called).toBe(false);
done();

@@ -88,5 +92,8 @@ });

annotationStorage.onResetModified = callback;
annotationStorage.getOrCreateValue("asdf", {
annotationStorage.setValue("asdf", {
value: "original"
});
annotationStorage.resetModified();
expect(called).toBe(true);
called = false;
annotationStorage.setValue("asdf", {

@@ -93,0 +100,0 @@ value: "original"

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -129,26 +129,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
it("stops searching when the loop limit is reached", function () {
const dict = new _primitives.Dict();
let currentDict = dict;
let parentDict = null;
for (let i = 0; i < 150; i++) {
parentDict = new _primitives.Dict();
currentDict.set("Parent", parentDict);
currentDict = parentDict;
}
parentDict.set("foo", "bar");
expect((0, _core_utils.getInheritableProperty)({
dict,
key: "foo"
})).toEqual(undefined);
dict.set("foo", "baz");
expect((0, _core_utils.getInheritableProperty)({
dict,
key: "foo",
getArray: false,
stopWhenFound: false
})).toEqual(["baz"]);
});
});

@@ -247,2 +223,12 @@ describe("toRomanNumerals", function () {

});
describe("encodeToXmlString", function () {
it("should get a correctly encoded string with some entities", function () {
const str = "\"\u0397ell😂' & <W😂rld>";
expect((0, _core_utils.encodeToXmlString)(str)).toEqual("&quot;&#x397;ell&#x1F602;&apos; &amp; &lt;W&#x1F602;rld&gt;");
});
it("should get a correctly encoded basic ascii string", function () {
const str = "hello world";
expect((0, _core_utils.encodeToXmlString)(str)).toEqual(str);
});
});
});

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -27,4 +27,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _primitives = require("../../core/primitives.js");
describe("Default appearance", function () {

@@ -36,3 +34,3 @@ describe("parseDefaultAppearance and createDefaultAppearance", function () {

fontSize: 12,
fontName: _primitives.Name.get("F1"),
fontName: "F1",
fontColor: new Uint8ClampedArray([26, 51, 76])

@@ -44,3 +42,3 @@ };

fontSize: 13,
fontName: _primitives.Name.get("F2"),
fontName: "F2",
fontColor: new Uint8ClampedArray([76, 51, 26])

@@ -53,3 +51,3 @@ });

fontSize: 12,
fontName: _primitives.Name.get("F1"),
fontName: "F1",
fontColor: new Uint8ClampedArray([26, 51, 76])

@@ -56,0 +54,0 @@ });

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -27,2 +27,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _util = require("../../shared/util.js");
var _is_node = require("../../shared/is_node.js");

@@ -181,2 +183,70 @@

});
describe("getPdfFilenameFromUrl", function () {
it("gets PDF filename", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/file1.pdf")).toEqual("file1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("http://www.example.com/pdfs/file2.pdf")).toEqual("file2.pdf");
});
it("gets fallback filename", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/file1.txt")).toEqual("document.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("http://www.example.com/pdfs/file2.txt")).toEqual("document.pdf");
});
it("gets custom fallback filename", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/file1.txt", "qwerty1.pdf")).toEqual("qwerty1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("http://www.example.com/pdfs/file2.txt", "qwerty2.pdf")).toEqual("qwerty2.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/file3.txt", "")).toEqual("");
});
it("gets fallback filename when url is not a string", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)(null)).toEqual("document.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)(null, "file.pdf")).toEqual("file.pdf");
});
it("gets PDF filename from URL containing leading/trailing whitespace", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)(" /pdfs/file1.pdf ")).toEqual("file1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)(" http://www.example.com/pdfs/file2.pdf ")).toEqual("file2.pdf");
});
it("gets PDF filename from query string", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/pdfs.html?name=file1.pdf")).toEqual("file1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("http://www.example.com/pdfs/pdf.html?file2.pdf")).toEqual("file2.pdf");
});
it("gets PDF filename from hash string", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/pdfs.html#name=file1.pdf")).toEqual("file1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("http://www.example.com/pdfs/pdf.html#file2.pdf")).toEqual("file2.pdf");
});
it("gets correct PDF filename when multiple ones are present", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/file1.pdf?name=file.pdf")).toEqual("file1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("http://www.example.com/pdfs/file2.pdf#file.pdf")).toEqual("file2.pdf");
});
it("gets PDF filename from URI-encoded data", function () {
const encodedUrl = encodeURIComponent("http://www.example.com/pdfs/file1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)(encodedUrl)).toEqual("file1.pdf");
const encodedUrlWithQuery = encodeURIComponent("http://www.example.com/pdfs/file.txt?file2.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)(encodedUrlWithQuery)).toEqual("file2.pdf");
});
it("gets PDF filename from data mistaken for URI-encoded", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/%AA.pdf")).toEqual("%AA.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("/pdfs/%2F.pdf")).toEqual("%2F.pdf");
});
it("gets PDF filename from (some) standard protocols", function () {
expect((0, _display_utils.getPdfFilenameFromUrl)("http://www.example.com/file1.pdf")).toEqual("file1.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("https://www.example.com/file2.pdf")).toEqual("file2.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("file:///path/to/files/file3.pdf")).toEqual("file3.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)("ftp://www.example.com/file4.pdf")).toEqual("file4.pdf");
});
it('gets PDF filename from query string appended to "blob:" URL', function () {
if (_is_node.isNodeJS) {
pending("Blob in not supported in Node.js.");
}
const typedArray = new Uint8Array([1, 2, 3, 4, 5]);
const blobUrl = (0, _util.createObjectURL)(typedArray, "application/pdf");
expect(blobUrl.startsWith("blob:")).toEqual(true);
expect((0, _display_utils.getPdfFilenameFromUrl)(blobUrl + "?file.pdf")).toEqual("file.pdf");
});
it('gets fallback filename from query string appended to "data:" URL', function () {
const typedArray = new Uint8Array([1, 2, 3, 4, 5]);
const dataUrl = (0, _util.createObjectURL)(typedArray, "application/pdf", true);
expect(dataUrl.startsWith("data:")).toEqual(true);
expect((0, _display_utils.getPdfFilenameFromUrl)(dataUrl + "?file1.pdf")).toEqual("document.pdf");
expect((0, _display_utils.getPdfFilenameFromUrl)(" " + dataUrl + "?file2.pdf")).toEqual("document.pdf");
});
});
describe("isValidFetchUrl", function () {

@@ -183,0 +253,0 @@ it("handles invalid Fetch URLs", function () {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -38,3 +38,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

async function initializePDFJS(callback) {
await Promise.all(["pdfjs-test/unit/annotation_spec.js", "pdfjs-test/unit/annotation_storage_spec.js", "pdfjs-test/unit/api_spec.js", "pdfjs-test/unit/bidi_spec.js", "pdfjs-test/unit/cff_parser_spec.js", "pdfjs-test/unit/cmap_spec.js", "pdfjs-test/unit/colorspace_spec.js", "pdfjs-test/unit/core_utils_spec.js", "pdfjs-test/unit/crypto_spec.js", "pdfjs-test/unit/custom_spec.js", "pdfjs-test/unit/default_appearance_spec.js", "pdfjs-test/unit/display_svg_spec.js", "pdfjs-test/unit/display_utils_spec.js", "pdfjs-test/unit/document_spec.js", "pdfjs-test/unit/encodings_spec.js", "pdfjs-test/unit/evaluator_spec.js", "pdfjs-test/unit/function_spec.js", "pdfjs-test/unit/fetch_stream_spec.js", "pdfjs-test/unit/message_handler_spec.js", "pdfjs-test/unit/metadata_spec.js", "pdfjs-test/unit/murmurhash3_spec.js", "pdfjs-test/unit/network_spec.js", "pdfjs-test/unit/network_utils_spec.js", "pdfjs-test/unit/parser_spec.js", "pdfjs-test/unit/pdf_find_controller_spec.js", "pdfjs-test/unit/pdf_find_utils_spec.js", "pdfjs-test/unit/pdf_history_spec.js", "pdfjs-test/unit/primitives_spec.js", "pdfjs-test/unit/scripting_spec.js", "pdfjs-test/unit/stream_spec.js", "pdfjs-test/unit/type1_parser_spec.js", "pdfjs-test/unit/ui_utils_spec.js", "pdfjs-test/unit/unicode_spec.js", "pdfjs-test/unit/util_spec.js", "pdfjs-test/unit/writer_spec.js", "pdfjs-test/unit/xml_spec.js"].map(function (moduleName) {
await Promise.all(["pdfjs-test/unit/annotation_spec.js", "pdfjs-test/unit/annotation_storage_spec.js", "pdfjs-test/unit/api_spec.js", "pdfjs-test/unit/bidi_spec.js", "pdfjs-test/unit/cff_parser_spec.js", "pdfjs-test/unit/cmap_spec.js", "pdfjs-test/unit/colorspace_spec.js", "pdfjs-test/unit/core_utils_spec.js", "pdfjs-test/unit/crypto_spec.js", "pdfjs-test/unit/custom_spec.js", "pdfjs-test/unit/default_appearance_spec.js", "pdfjs-test/unit/display_svg_spec.js", "pdfjs-test/unit/display_utils_spec.js", "pdfjs-test/unit/document_spec.js", "pdfjs-test/unit/encodings_spec.js", "pdfjs-test/unit/evaluator_spec.js", "pdfjs-test/unit/function_spec.js", "pdfjs-test/unit/fetch_stream_spec.js", "pdfjs-test/unit/message_handler_spec.js", "pdfjs-test/unit/metadata_spec.js", "pdfjs-test/unit/murmurhash3_spec.js", "pdfjs-test/unit/network_spec.js", "pdfjs-test/unit/network_utils_spec.js", "pdfjs-test/unit/parser_spec.js", "pdfjs-test/unit/pdf_find_controller_spec.js", "pdfjs-test/unit/pdf_find_utils_spec.js", "pdfjs-test/unit/pdf_history_spec.js", "pdfjs-test/unit/primitives_spec.js", "pdfjs-test/unit/scripting_spec.js", "pdfjs-test/unit/stream_spec.js", "pdfjs-test/unit/type1_parser_spec.js", "pdfjs-test/unit/ui_utils_spec.js", "pdfjs-test/unit/unicode_spec.js", "pdfjs-test/unit/util_spec.js", "pdfjs-test/unit/writer_spec.js", "pdfjs-test/unit/xfa_formcalc_spec.js", "pdfjs-test/unit/xfa_parser_spec.js", "pdfjs-test/unit/xfa_tohtml_spec.js", "pdfjs-test/unit/xml_spec.js"].map(function (moduleName) {
return import(moduleName);

@@ -41,0 +41,0 @@ }));

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -29,6 +29,13 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _metadata_parser = require("../../core/metadata_parser.js");
function createMetadata(data) {
const metadataParser = new _metadata_parser.MetadataParser(data);
return new _metadata.Metadata(metadataParser.serializable);
}
describe("metadata", function () {
it("should handle valid metadata", function () {
const data = "<x:xmpmeta xmlns:x='adobe:ns:meta/'>" + "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>" + "<rdf:Description xmlns:dc='http://purl.org/dc/elements/1.1/'>" + '<dc:title><rdf:Alt><rdf:li xml:lang="x-default">Foo bar baz</rdf:li>' + "</rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta>";
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect(metadata.has("dc:title")).toBeTruthy();

@@ -44,3 +51,3 @@ expect(metadata.has("dc:qux")).toBeFalsy();

const data = "<x:xmpmeta xmlns:x='adobe:ns:meta/'>" + "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>" + "<rdf:Description xmlns:dc='http://purl.org/dc/elements/1.1/'>" + "<dc:title>\\376\\377\\000P\\000D\\000F\\000&</dc:title>" + "</rdf:Description></rdf:RDF></x:xmpmeta>";
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect(metadata.has("dc:title")).toBeTruthy();

@@ -56,3 +63,3 @@ expect(metadata.has("dc:qux")).toBeFalsy();

const data = "<x:xmpmeta xmlns:x='adobe:ns:meta/' " + "x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>" + "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' " + "xmlns:iX='http://ns.adobe.com/iX/1.0/'>" + "<rdf:Description rdf:about='61652fa7-fc1f-11dd-0000-ce81d41f9ecf' " + "xmlns:pdf='http://ns.adobe.com/pdf/1.3/' " + "pdf:Producer='GPL Ghostscript 8.63'/>" + "<rdf:Description rdf:about='61652fa7-fc1f-11dd-0000-ce81d41f9ecf' " + "xmlns:xap='http://ns.adobe.com/xap/1.0/' " + "xap:ModifyDate='2009-02-13T12:42:54+01:00' " + "xap:CreateDate='2009-02-13T12:42:54+01:00'>" + "<xap:CreatorTool>\\376\\377\\000P\\000D\\000F\\000C\\000r\\000e\\000a" + "\\000t\\000o\\000r\\000 \\000V\\000e\\000r\\000s\\000i\\000o\\000n" + "\\000 \\0000\\000.\\0009\\000.\\0006</xap:CreatorTool>" + "</rdf:Description><rdf:Description " + "rdf:about='61652fa7-fc1f-11dd-0000-ce81d41f9ecf' " + "xmlns:xapMM='http://ns.adobe.com/xap/1.0/mm/' " + "xapMM:DocumentID='61652fa7-fc1f-11dd-0000-ce81d41f9ecf'/>" + "<rdf:Description rdf:about='61652fa7-fc1f-11dd-0000-ce81d41f9ecf' " + "xmlns:dc='http://purl.org/dc/elements/1.1/' " + "dc:format='application/pdf'><dc:title><rdf:Alt>" + "<rdf:li xml:lang='x-default'>\\376\\377\\000L\\000&apos;\\000O\\000d" + "\\000i\\000s\\000s\\000e\\000e\\000 \\000t\\000h\\000\\351\\000m\\000a" + "\\000t\\000i\\000q\\000u\\000e\\000 \\000l\\000o\\000g\\000o\\000 " + "\\000O\\000d\\000i\\000s\\000s\\000\\351\\000\\351\\000 \\000-\\000 " + "\\000d\\000\\351\\000c\\000e\\000m\\000b\\000r\\000e\\000 \\0002\\0000" + "\\0000\\0008\\000.\\000p\\000u\\000b</rdf:li></rdf:Alt></dc:title>" + "<dc:creator><rdf:Seq><rdf:li>\\376\\377\\000O\\000D\\000I\\000S" + "</rdf:li></rdf:Seq></dc:creator></rdf:Description></rdf:RDF>" + "</x:xmpmeta>";
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect(metadata.has("dc:title")).toBeTruthy();

@@ -70,3 +77,3 @@ expect(metadata.has("dc:qux")).toBeFalsy();

const data = '<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d' + '<x:xmpmeta xmlns:x="adobe:ns:meta/">' + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + '<rdf:Description rdf:about=""' + 'xmlns:pdfx="http://ns.adobe.com/pdfx/1.3/">' + "</rdf:Description>" + '<rdf:Description rdf:about=""' + 'xmlns:xap="http://ns.adobe.com/xap/1.0/">' + "<xap:ModifyDate>2010-03-25T11:20:09-04:00</xap:ModifyDate>" + "<xap:CreateDate>2010-03-25T11:20:09-04:00</xap:CreateDate>" + "<xap:MetadataDate>2010-03-25T11:20:09-04:00</xap:MetadataDate>" + "</rdf:Description>" + '<rdf:Description rdf:about=""' + 'xmlns:dc="http://purl.org/dc/elements/1.1/">' + "<dc:format>application/pdf</dc:format>" + "</rdf:Description>" + '<rdf:Description rdf:about=""' + 'xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/">' + "<pdfaid:part>1</pdfaid:part>" + "<pdfaid:conformance>A</pdfaid:conformance>" + "</rdf:Description>" + "</rdf:RDF>" + "</x:xmpmeta>" + '<?xpacket end="w"?>';
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect((0, _test_utils.isEmptyObj)(metadata.getAll())).toEqual(true);

@@ -76,3 +83,3 @@ });

const data = '<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>' + '<x:xmpmeta x:xmptk="TallComponents PDFObjects 1.0" ' + 'xmlns:x="adobe:ns:meta/">' + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + '<rdf:Description rdf:about="" ' + 'xmlns:pdf="http://ns.adobe.com/pdf/1.3/">' + "<pdf:Producer>PDFKit.NET 4.0.102.0</pdf:Producer>" + "<pdf:Keywords></pdf:Keywords>" + "<pdf:PDFVersion>1.7</pdf:PDFVersion></rdf:Description>" + '<rdf:Description rdf:about="" ' + 'xmlns:xap="http://ns.adobe.com/xap/1.0/">' + "<xap:CreateDate>2018-12-27T13:50:36-08:00</xap:CreateDate>" + "<xap:ModifyDate>2018-12-27T13:50:38-08:00</xap:ModifyDate>" + "<xap:CreatorTool></xap:CreatorTool>" + "<xap:MetadataDate>2018-12-27T13:50:38-08:00</xap:MetadataDate>" + '</rdf:Description><rdf:Description rdf:about="" ' + 'xmlns:dc="http://purl.org/dc/elements/1.1/">' + "<dc:creator><rdf:Seq><rdf:li></rdf:li></rdf:Seq></dc:creator>" + "<dc:subject><rdf:Bag /></dc:subject>" + '<dc:description><rdf:Alt><rdf:li xml:lang="x-default">' + "</rdf:li></rdf:Alt></dc:description>" + '<dc:title><rdf:Alt><rdf:li xml:lang="x-default"></rdf:li>' + "</rdf:Alt></dc:title><dc:format>application/pdf</dc:format>" + '</rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="w"?>';
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect(metadata.has("dc:title")).toBeTruthy();

@@ -86,3 +93,3 @@ expect(metadata.has("dc:qux")).toBeFalsy();

"dc:format": "application/pdf",
"dc:subject": "",
"dc:subject": [],
"dc:title": "",

@@ -100,3 +107,3 @@ "pdf:keywords": "",

const data = "<x:xmpmeta xmlns:x='adobe:ns:meta/'>" + "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>" + "<rdf:Description xmlns:dc='http://purl.org/dc/elements/1.1/'>" + "<dc:title><rdf:Alt>" + '<rdf:li xml:lang="x-default">&apos;Foo bar baz&apos;</rdf:li>' + "</rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta>";
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect(metadata.has("dc:title")).toBeTruthy();

@@ -112,3 +119,3 @@ expect(metadata.has("dc:qux")).toBeFalsy();

const data = '<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>' + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + '<rdf:Description rdf:about="" ' + 'xmlns:pdf="http://ns.adobe.com/pdf/1.3/">' + "<pdf:Producer>Soda PDF 5</pdf:Producer></rdf:Description>" + '<rdf:Description rdf:about="" ' + 'xmlns:xap="http://ns.adobe.com/xap/1.0/">' + "<xap:CreateDate>2018-10-02T08:14:49-05:00</xap:CreateDate>" + "<xap:CreatorTool>Soda PDF 5</xap:CreatorTool>" + "<xap:MetadataDate>2018-10-02T08:14:49-05:00</xap:MetadataDate> " + "<xap:ModifyDate>2018-10-02T08:14:49-05:00</xap:ModifyDate>" + '</rdf:Description><rdf:Description rdf:about="" ' + 'xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">' + "<xmpMM:DocumentID>uuid:00000000-1c84-3cf9-89ba-bef0e729c831" + "</xmpMM:DocumentID></rdf:Description>" + '</rdf:RDF></x:xmpmeta><?xpacket end="w"?>';
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect((0, _test_utils.isEmptyObj)(metadata.getAll())).toEqual(true);

@@ -118,3 +125,3 @@ });

const data = '<?xml version="1.0"?>' + "<!DOCTYPE lolz [" + ' <!ENTITY lol "lol">' + ' <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">' + ' <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">' + ' <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">' + ' <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">' + ' <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">' + ' <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">' + ' <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">' + ' <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">' + ' <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">' + "]>" + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + ' <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/">' + " <dc:title>" + " <rdf:Alt>" + ' <rdf:li xml:lang="x-default">a&lol9;b</rdf:li>' + " </rdf:Alt>" + " </dc:title>" + " </rdf:Description>" + "</rdf:RDF>";
const metadata = new _metadata.Metadata(data);
const metadata = createMetadata(data);
expect(metadata.has("dc:title")).toBeTruthy();

@@ -121,0 +128,0 @@ expect(metadata.has("dc:qux")).toBeFalsy();

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -29,3 +29,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

describe("Scripting", function () {
let sandbox, send_queue, test_id, ref;
let sandbox, send_queue, test_id, ref, windowAlert;

@@ -62,2 +62,4 @@ function getId() {

windowAlert = window.alert;
window.alert = value => {

@@ -98,5 +100,6 @@ const command = "alert";

send_queue = null;
window.alert = windowAlert;
});
describe("Sandbox", function () {
it("should send a value, execute an action and get back a new value", function (done) {
it("should send a value, execute an action and get back a new value", async () => {
function compute(n) {

@@ -133,3 +136,3 @@ let s = 0;

sandbox.createSandbox(data);
sandbox.dispatchEventInSandbox({
await sandbox.dispatchEventInSandbox({
id: refId,

@@ -139,14 +142,12 @@ value: `${number}`,

willCommit: true
}).then(() => {
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
valueAsString: expected
});
done();
}).catch(done.fail);
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
valueAsString: expected
});
});
});
describe("Doc", function () {
it("should treat globalThis as the doc", async function (done) {
it("should treat globalThis as the doc", async () => {
const refId = getId();

@@ -170,12 +171,49 @@ const data = {

sandbox.createSandbox(data);
await myeval(`(this.foobar = 123456, 0)`);
const value = await myeval(`this.getField("field").doc.foobar`);
expect(value).toEqual(123456);
});
it("should get field using a path", async () => {
const base = value => {
return {
id: getId(),
value,
actions: {},
type: "text"
};
};
try {
await myeval(`(this.foobar = 123456, 0)`);
await myeval(`this.getField("field").doc.foobar`).then(value => {
expect(value).toEqual(123456);
});
done();
} catch (ex) {
done.fail(ex);
}
const data = {
objects: {
A: [base(1)],
"A.B": [base(2)],
"A.B.C": [base(3)],
"A.B.C.D": [base(4)],
"A.B.C.D.E": [base(5)],
"A.B.C.D.E.F": [base(6)],
"A.B.C.D.G": [base(7)],
C: [base(8)]
},
appInfo: {
language: "en-US",
platform: "Linux x86_64"
},
calculationOrder: [],
dispatchEventName: "_dispatchMe"
};
sandbox.createSandbox(data);
let value = await myeval(`this.getField("A").value`);
expect(value).toEqual(1);
value = await myeval(`this.getField("B.C").value`);
expect(value).toEqual(3);
value = await myeval(`this.getField("B.C").value`);
expect(value).toEqual(3);
value = await myeval(`this.getField("B.C.D#0").value`);
expect(value).toEqual(5);
value = await myeval(`this.getField("B.C.D#1").value`);
expect(value).toEqual(7);
value = await myeval(`this.getField("C").value`);
expect(value).toEqual(8);
value = await myeval(`this.getField("A.B.C.D").getArray().map((x) => x.value)`);
expect(value).toEqual([5, 7]);
});

@@ -196,61 +234,55 @@ });

describe("printd", function () {
it("should print a date according to a format", function (done) {
it("should print a date according to a format", async () => {
const date = `new Date("Sun Apr 15 2007 03:14:15")`;
Promise.all([myeval(`util.printd(0, ${date})`).then(value => {
expect(value).toEqual("D:20070415031415");
}), myeval(`util.printd(1, ${date})`).then(value => {
expect(value).toEqual("2007.04.15 03:14:15");
}), myeval(`util.printd(2, ${date})`).then(value => {
expect(value).toEqual("4/15/07 3:14:15 am");
}), myeval(`util.printd("mmmm mmm mm m", ${date})`).then(value => {
expect(value).toEqual("April Apr 04 4");
}), myeval(`util.printd("dddd ddd dd d", ${date})`).then(value => {
expect(value).toEqual("Sunday Sun 15 15");
})]).then(() => done());
let value = await myeval(`util.printd(0, ${date})`);
expect(value).toEqual("D:20070415031415");
value = await myeval(`util.printd(1, ${date})`);
expect(value).toEqual("2007.04.15 03:14:15");
value = await myeval(`util.printd(2, ${date})`);
expect(value).toEqual("4/15/07 3:14:15 am");
value = await myeval(`util.printd("mmmm mmm mm m", ${date})`);
expect(value).toEqual("April Apr 04 4");
value = await myeval(`util.printd("dddd ddd dd d", ${date})`);
expect(value).toEqual("Sunday Sun 15 15");
});
});
describe("scand", function () {
it("should parse a date according to a format", function (done) {
it("should parse a date according to a format", async () => {
const date = new Date("Sun Apr 15 2007 03:14:15");
Promise.all([myeval(`util.scand(0, "D:20070415031415").toString()`).then(value => {
expect(new Date(value)).toEqual(date);
}), myeval(`util.scand(1, "2007.04.15 03:14:15").toString()`).then(value => {
expect(new Date(value)).toEqual(date);
}), myeval(`util.scand(2, "4/15/07 3:14:15 am").toString()`).then(value => {
expect(new Date(value)).toEqual(date);
})]).then(() => done());
let value = await myeval(`util.scand(0, "D:20070415031415").toString()`);
expect(new Date(value)).toEqual(date);
value = await myeval(`util.scand(1, "2007.04.15 03:14:15").toString()`);
expect(new Date(value)).toEqual(date);
value = await myeval(`util.scand(2, "4/15/07 3:14:15 am").toString()`);
expect(new Date(value)).toEqual(date);
});
});
describe("printf", function () {
it("should print some data according to a format", function (done) {
Promise.all([myeval(`util.printf("Integer numbers: %d, %d,...", 1.234, 56.789)`).then(value => {
expect(value).toEqual("Integer numbers: 1, 56,...");
}), myeval(`util.printf("Hex numbers: %x, %x,...", 1234, 56789)`).then(value => {
expect(value).toEqual("Hex numbers: 4D2, DDD5,...");
}), myeval(`util.printf("Hex numbers with 0x: %#x, %#x,...", 1234, 56789)`).then(value => {
expect(value).toEqual("Hex numbers with 0x: 0x4D2, 0xDDD5,...");
}), myeval(`util.printf("Decimal number: %,0+.3f", 1234567.89123)`).then(value => {
expect(value).toEqual("Decimal number: +1,234,567.891");
}), myeval(`util.printf("Decimal number: %,0+8.3f", 1.234567)`).then(value => {
expect(value).toEqual("Decimal number: + 1.235");
}), myeval(`util.printf("Decimal number: %,0.2f", -12.34567)`).then(value => {
expect(value).toEqual("Decimal number: -12.35");
})]).then(() => done());
it("should print some data according to a format", async () => {
let value = await myeval(`util.printf("Integer numbers: %d, %d,...", 1.234, 56.789)`);
expect(value).toEqual("Integer numbers: 1, 56,...");
value = await myeval(`util.printf("Hex numbers: %x, %x,...", 1234, 56789)`);
expect(value).toEqual("Hex numbers: 4D2, DDD5,...");
value = await myeval(`util.printf("Hex numbers with 0x: %#x, %#x,...", 1234, 56789)`);
expect(value).toEqual("Hex numbers with 0x: 0x4D2, 0xDDD5,...");
value = await myeval(`util.printf("Decimal number: %,0+.3f", 1234567.89123)`);
expect(value).toEqual("Decimal number: +1,234,567.891");
value = await myeval(`util.printf("Decimal number: %,0+8.3f", 1.234567)`);
expect(value).toEqual("Decimal number: + 1.235");
value = await myeval(`util.printf("Decimal number: %,0.2f", -12.34567)`);
expect(value).toEqual("Decimal number: -12.35");
});
it("should print a string with no argument", function (done) {
myeval(`util.printf("hello world")`).then(value => {
expect(value).toEqual("hello world");
}).then(() => done());
it("should print a string with no argument", async () => {
const value = await myeval(`util.printf("hello world")`);
expect(value).toEqual("hello world");
});
it("print a string with a percent", function (done) {
myeval(`util.printf("%%s")`).then(value => {
expect(value).toEqual("%%s");
}).then(() => done());
it("print a string with a percent", async () => {
const value = await myeval(`util.printf("%%s")`);
expect(value).toEqual("%%s");
});
});
describe("printx", function () {
it("should print some data according to a format", function (done) {
myeval(`util.printx("9 (999) 999-9999", "aaa14159697489zzz")`).then(value => {
expect(value).toEqual("1 (415) 969-7489");
}).then(() => done());
it("should print some data according to a format", async () => {
const value = await myeval(`util.printx("9 (999) 999-9999", "aaa14159697489zzz")`);
expect(value).toEqual("1 (415) 969-7489");
});

@@ -260,3 +292,3 @@ });

describe("Events", function () {
it("should trigger an event and modify the source", function (done) {
it("should trigger an event and modify the source", async () => {
const refId = getId();

@@ -281,3 +313,3 @@ const data = {

sandbox.createSandbox(data);
sandbox.dispatchEventInSandbox({
await sandbox.dispatchEventInSandbox({
id: refId,

@@ -287,12 +319,10 @@ value: "",

willCommit: true
}).then(() => {
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "123"
});
done();
}).catch(done.fail);
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "123"
});
});
it("should trigger a Keystroke event and invalidate it", function (done) {
it("should trigger a Keystroke event and invalidate it", async () => {
const refId = getId();

@@ -317,3 +347,3 @@ const data = {

sandbox.createSandbox(data);
sandbox.dispatchEventInSandbox({
await sandbox.dispatchEventInSandbox({
id: refId,

@@ -326,13 +356,11 @@ value: "hell",

selEnd: 4
}).then(() => {
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "hell",
selRange: [4, 4]
});
done();
}).catch(done.fail);
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "hell",
selRange: [4, 4]
});
});
it("should trigger a Keystroke event and change it", function (done) {
it("should trigger a Keystroke event and change it", async () => {
const refId = getId();

@@ -357,3 +385,3 @@ const data = {

sandbox.createSandbox(data);
sandbox.dispatchEventInSandbox({
await sandbox.dispatchEventInSandbox({
id: refId,

@@ -366,12 +394,10 @@ value: "hell",

selEnd: 4
}).then(() => {
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "hella"
});
done();
}).catch(done.fail);
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "hella"
});
});
it("should trigger an invalid commit Keystroke event", function (done) {
it("should trigger an invalid commit Keystroke event", async () => {
const refId = getId();

@@ -396,3 +422,3 @@ const data = {

sandbox.createSandbox(data);
sandbox.dispatchEventInSandbox({
await sandbox.dispatchEventInSandbox({
id: refId,

@@ -402,8 +428,6 @@ value: "",

willCommit: true
}).then(() => {
expect(send_queue.has(refId)).toEqual(false);
done();
}).catch(done.fail);
});
expect(send_queue.has(refId)).toEqual(false);
});
it("should trigger a valid commit Keystroke event", function (done) {
it("should trigger a valid commit Keystroke event", async () => {
const refId1 = getId();

@@ -437,3 +461,3 @@ const refId2 = getId();

sandbox.createSandbox(data);
sandbox.dispatchEventInSandbox({
await sandbox.dispatchEventInSandbox({
id: refId1,

@@ -443,11 +467,9 @@ value: "hello",

willCommit: true
}).then(() => {
expect(send_queue.has(refId1)).toEqual(true);
expect(send_queue.get(refId1)).toEqual({
id: refId1,
value: "world",
valueAsString: "world"
});
done();
}).catch(done.fail);
});
expect(send_queue.has(refId1)).toEqual(true);
expect(send_queue.get(refId1)).toEqual({
id: refId1,
value: "world",
valueAsString: "world"
});
});

@@ -472,45 +494,41 @@ });

it("should convert RGB color for different color spaces", function (done) {
Promise.all([myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "T")`).then(value => {
expect(round(value)).toEqual(["T"]);
}), myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "G")`).then(value => {
expect(round(value)).toEqual(["G", 0.181]);
}), myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "RGB")`).then(value => {
expect(round(value)).toEqual(["RGB", 0.1, 0.2, 0.3]);
}), myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "CMYK")`).then(value => {
expect(round(value)).toEqual(["CMYK", 0.9, 0.8, 0.7, 0.7]);
})]).then(() => done());
it("should convert RGB color for different color spaces", async () => {
let value = await myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "T")`);
expect(round(value)).toEqual(["T"]);
value = await myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "G")`);
expect(round(value)).toEqual(["G", 0.181]);
value = await myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "RGB")`);
expect(round(value)).toEqual(["RGB", 0.1, 0.2, 0.3]);
value = await myeval(`color.convert(["RGB", 0.1, 0.2, 0.3], "CMYK")`);
expect(round(value)).toEqual(["CMYK", 0.9, 0.8, 0.7, 0.7]);
});
it("should convert CMYK color for different color spaces", function (done) {
Promise.all([myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "T")`).then(value => {
expect(round(value)).toEqual(["T"]);
}), myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "G")`).then(value => {
expect(round(value)).toEqual(["G", 0.371]);
}), myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "RGB")`).then(value => {
expect(round(value)).toEqual(["RGB", 0.5, 0.3, 0.4]);
}), myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "CMYK")`).then(value => {
expect(round(value)).toEqual(["CMYK", 0.1, 0.2, 0.3, 0.4]);
})]).then(() => done());
it("should convert CMYK color for different color spaces", async () => {
let value = await myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "T")`);
expect(round(value)).toEqual(["T"]);
value = await myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "G")`);
expect(round(value)).toEqual(["G", 0.371]);
value = await myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "RGB")`);
expect(round(value)).toEqual(["RGB", 0.5, 0.3, 0.4]);
value = await myeval(`color.convert(["CMYK", 0.1, 0.2, 0.3, 0.4], "CMYK")`);
expect(round(value)).toEqual(["CMYK", 0.1, 0.2, 0.3, 0.4]);
});
it("should convert Gray color for different color spaces", function (done) {
Promise.all([myeval(`color.convert(["G", 0.1], "T")`).then(value => {
expect(round(value)).toEqual(["T"]);
}), myeval(`color.convert(["G", 0.1], "G")`).then(value => {
expect(round(value)).toEqual(["G", 0.1]);
}), myeval(`color.convert(["G", 0.1], "RGB")`).then(value => {
expect(round(value)).toEqual(["RGB", 0.1, 0.1, 0.1]);
}), myeval(`color.convert(["G", 0.1], "CMYK")`).then(value => {
expect(round(value)).toEqual(["CMYK", 0, 0, 0, 0.9]);
})]).then(() => done());
it("should convert Gray color for different color spaces", async () => {
let value = await myeval(`color.convert(["G", 0.1], "T")`);
expect(round(value)).toEqual(["T"]);
value = await myeval(`color.convert(["G", 0.1], "G")`);
expect(round(value)).toEqual(["G", 0.1]);
value = await myeval(`color.convert(["G", 0.1], "RGB")`);
expect(round(value)).toEqual(["RGB", 0.1, 0.1, 0.1]);
value = await myeval(`color.convert(["G", 0.1], "CMYK")`);
expect(round(value)).toEqual(["CMYK", 0, 0, 0, 0.9]);
});
it("should convert Transparent color for different color spaces", function (done) {
Promise.all([myeval(`color.convert(["T"], "T")`).then(value => {
expect(round(value)).toEqual(["T"]);
}), myeval(`color.convert(["T"], "G")`).then(value => {
expect(round(value)).toEqual(["G", 0]);
}), myeval(`color.convert(["T"], "RGB")`).then(value => {
expect(round(value)).toEqual(["RGB", 0, 0, 0]);
}), myeval(`color.convert(["T"], "CMYK")`).then(value => {
expect(round(value)).toEqual(["CMYK", 0, 0, 0, 1]);
})]).then(() => done());
it("should convert Transparent color for different color spaces", async () => {
let value = await myeval(`color.convert(["T"], "T")`);
expect(round(value)).toEqual(["T"]);
value = await myeval(`color.convert(["T"], "G")`);
expect(round(value)).toEqual(["G", 0]);
value = await myeval(`color.convert(["T"], "RGB")`);
expect(round(value)).toEqual(["RGB", 0, 0, 0]);
value = await myeval(`color.convert(["T"], "CMYK")`);
expect(round(value)).toEqual(["CMYK", 0, 0, 0, 1]);
});

@@ -530,15 +548,13 @@ });

});
it("should test language", function (done) {
Promise.all([myeval(`app.language`).then(value => {
expect(value).toEqual("ENU");
}), myeval(`app.language = "hello"`).then(value => {
expect(value).toEqual("app.language is read-only");
})]).then(() => done());
it("should test language", async () => {
let value = await myeval(`app.language`);
expect(value).toEqual("ENU");
value = await myeval(`app.language = "hello"`);
expect(value).toEqual("app.language is read-only");
});
it("should test platform", function (done) {
Promise.all([myeval(`app.platform`).then(value => {
expect(value).toEqual("UNIX");
}), myeval(`app.platform = "hello"`).then(value => {
expect(value).toEqual("app.platform is read-only");
})]).then(() => done());
it("should test platform", async () => {
let value = await myeval(`app.platform`);
expect(value).toEqual("UNIX");
value = await myeval(`app.platform = "hello"`);
expect(value).toEqual("app.platform is read-only");
});

@@ -560,40 +576,37 @@ });

describe("AFExtractNums", function () {
it("should extract numbers", function (done) {
Promise.all([myeval(`AFExtractNums("123 456 789")`).then(value => {
expect(value).toEqual(["123", "456", "789"]);
}), myeval(`AFExtractNums("123.456")`).then(value => {
expect(value).toEqual(["123", "456"]);
}), myeval(`AFExtractNums("123")`).then(value => {
expect(value).toEqual(["123"]);
}), myeval(`AFExtractNums(".123")`).then(value => {
expect(value).toEqual(["0", "123"]);
}), myeval(`AFExtractNums(",123")`).then(value => {
expect(value).toEqual(["0", "123"]);
})]).then(() => done());
it("should extract numbers", async () => {
let value = await myeval(`AFExtractNums("123 456 789")`);
expect(value).toEqual(["123", "456", "789"]);
value = await myeval(`AFExtractNums("123.456")`);
expect(value).toEqual(["123", "456"]);
value = await myeval(`AFExtractNums("123")`);
expect(value).toEqual(["123"]);
value = await myeval(`AFExtractNums(".123")`);
expect(value).toEqual(["0", "123"]);
value = await myeval(`AFExtractNums(",123")`);
expect(value).toEqual(["0", "123"]);
});
});
describe("AFMakeNumber", function () {
it("should convert string to number", function (done) {
Promise.all([myeval(`AFMakeNumber("123.456")`).then(value => {
expect(value).toEqual(123.456);
}), myeval(`AFMakeNumber(123.456)`).then(value => {
expect(value).toEqual(123.456);
}), myeval(`AFMakeNumber("-123.456")`).then(value => {
expect(value).toEqual(-123.456);
}), myeval(`AFMakeNumber("-123,456")`).then(value => {
expect(value).toEqual(-123.456);
}), myeval(`AFMakeNumber("not a number")`).then(value => {
expect(value).toEqual(null);
})]).then(() => done());
it("should convert string to number", async () => {
let value = await myeval(`AFMakeNumber("123.456")`);
expect(value).toEqual(123.456);
value = await myeval(`AFMakeNumber(123.456)`);
expect(value).toEqual(123.456);
value = await myeval(`AFMakeNumber("-123.456")`);
expect(value).toEqual(-123.456);
value = await myeval(`AFMakeNumber("-123,456")`);
expect(value).toEqual(-123.456);
value = await myeval(`AFMakeNumber("not a number")`);
expect(value).toEqual(null);
});
});
describe("AFMakeArrayFromList", function () {
it("should split a string into an array of strings", async function (done) {
it("should split a string into an array of strings", async () => {
const value = await myeval(`AFMakeArrayFromList("aaaa, bbbbbbb,cc,ddd, e")`);
expect(value).toEqual(["aaaa", " bbbbbbb", "cc", "ddd", "e"]);
done();
});
});
describe("AFNumber_format", function () {
it("should format a number", async function (done) {
it("should format a number", async () => {
const refId = getId();

@@ -622,69 +635,63 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "123456.789",
name: "test1"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "123,456.79€"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "223456.789",
name: "test2"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "$223456,8"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "-323456.789",
name: "test3"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "323,456.79€",
textColor: ["RGB", 1, 0, 0]
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "-423456.789",
name: "test4"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "(423,456.79€)"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "-52345.678",
name: "test5"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "(52,345.68€)",
textColor: ["RGB", 1, 0, 0]
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "123456.789",
name: "test1"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "123,456.79€"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "223456.789",
name: "test2"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "$223456,8"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "-323456.789",
name: "test3"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "323,456.79€",
textColor: ["RGB", 1, 0, 0]
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "-423456.789",
name: "test4"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "(423,456.79€)"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "-52345.678",
name: "test5"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "(52,345.68€)",
textColor: ["RGB", 1, 0, 0]
});
});
});
describe("AFNumber_Keystroke", function () {
it("should validate a number on a keystroke event", async function (done) {
it("should validate a number on a keystroke event", async () => {
const refId = getId();

@@ -710,23 +717,17 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "123456.789",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "123456.789",
valueAsString: "123456.789"
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "123456.789",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "123456.789",
valueAsString: "123456.789"
});
});
it("should not validate a number on a keystroke event", async function (done) {
it("should not validate a number on a keystroke event", async () => {
const refId = getId();

@@ -752,24 +753,18 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "123s456.789",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has("alert")).toEqual(true);
expect(send_queue.get("alert")).toEqual({
command: "alert",
value: "The value entered does not match the format of the field [ MyField ]"
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "123s456.789",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has("alert")).toEqual(true);
expect(send_queue.get("alert")).toEqual({
command: "alert",
value: "The value entered does not match the format of the field [ MyField ]"
});
});
});
describe("AFPercent_Format", function () {
it("should format a percentage", async function (done) {
it("should format a percentage", async () => {
const refId = getId();

@@ -795,34 +790,28 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "0.456789",
name: "test1"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "45.68%"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "0.456789",
name: "test2"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "%45.68"
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "0.456789",
name: "test1"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "45.68%"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "0.456789",
name: "test2"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "%45.68"
});
});
});
describe("AFDate_Format", function () {
it("should format a date", async function (done) {
it("should format a date", async () => {
const refId = getId();

@@ -848,34 +837,28 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "Sun Apr 15 2007 03:14:15",
name: "test1"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "4/15"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "Sun Apr 15 2007 03:14:15",
name: "test2"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "4/15/07 3:14 am"
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "Sun Apr 15 2007 03:14:15",
name: "test1"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "4/15"
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "Sun Apr 15 2007 03:14:15",
name: "test2"
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "4/15/07 3:14 am"
});
});
});
describe("AFRange_Validate", function () {
it("should validate a number in range [a, b]", async function (done) {
it("should validate a number in range [a, b]", async () => {
const refId = getId();

@@ -900,23 +883,17 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "321",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "321",
valueAsString: "321"
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "321",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "321",
valueAsString: "321"
});
});
it("should invalidate a number out of range [a, b]", async function (done) {
it("should invalidate a number out of range [a, b]", async () => {
const refId = getId();

@@ -941,24 +918,18 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "12",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has("alert")).toEqual(true);
expect(send_queue.get("alert")).toEqual({
command: "alert",
value: "Invalid value: must be greater than or equal to 123 and less than or equal to 456."
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "12",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has("alert")).toEqual(true);
expect(send_queue.get("alert")).toEqual({
command: "alert",
value: "Invalid value: must be greater than or equal to 123 and less than or equal to 456."
});
});
});
describe("ASSimple_Calculate", function () {
it("should compute the sum of several fields", async function (done) {
it("should compute the sum of several fields", async () => {
const refIds = [0, 1, 2, 3].map(_ => getId());

@@ -1001,49 +972,43 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refIds[0],
value: "1",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refIds[3])).toEqual(true);
expect(send_queue.get(refIds[3])).toEqual({
id: refIds[3],
value: 1,
valueAsString: "1"
});
await sandbox.dispatchEventInSandbox({
id: refIds[1],
value: "2",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refIds[3])).toEqual(true);
expect(send_queue.get(refIds[3])).toEqual({
id: refIds[3],
value: 3,
valueAsString: "3"
});
await sandbox.dispatchEventInSandbox({
id: refIds[2],
value: "3",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refIds[3])).toEqual(true);
expect(send_queue.get(refIds[3])).toEqual({
id: refIds[3],
value: 6,
valueAsString: "6"
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refIds[0],
value: "1",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refIds[3])).toEqual(true);
expect(send_queue.get(refIds[3])).toEqual({
id: refIds[3],
value: 1,
valueAsString: "1"
});
await sandbox.dispatchEventInSandbox({
id: refIds[1],
value: "2",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refIds[3])).toEqual(true);
expect(send_queue.get(refIds[3])).toEqual({
id: refIds[3],
value: 3,
valueAsString: "3"
});
await sandbox.dispatchEventInSandbox({
id: refIds[2],
value: "3",
name: "Keystroke",
willCommit: true
});
expect(send_queue.has(refIds[3])).toEqual(true);
expect(send_queue.get(refIds[3])).toEqual({
id: refIds[3],
value: 6,
valueAsString: "6"
});
});
});
describe("AFSpecial_KeystrokeEx", function () {
it("should validate a phone number on a keystroke event", async function (done) {
it("should validate a phone number on a keystroke event", async () => {
const refId = getId();

@@ -1068,65 +1033,69 @@ const data = {

};
try {
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "",
change: "3",
name: "Keystroke",
willCommit: false,
selStart: 0,
selEnd: 0
});
expect(send_queue.has(refId)).toEqual(false);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "3",
change: "F",
name: "Keystroke",
willCommit: false,
selStart: 1,
selEnd: 1
});
expect(send_queue.has(refId)).toEqual(false);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "3F",
change: "?",
name: "Keystroke",
willCommit: false,
selStart: 2,
selEnd: 2
});
expect(send_queue.has(refId)).toEqual(false);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "3F?",
change: "@",
name: "Keystroke",
willCommit: false,
selStart: 3,
selEnd: 3
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "3F?",
selRange: [3, 3]
});
done();
} catch (ex) {
done.fail(ex);
}
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "",
change: "3",
name: "Keystroke",
willCommit: false,
selStart: 0,
selEnd: 0
});
expect(send_queue.has(refId)).toEqual(false);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "3",
change: "F",
name: "Keystroke",
willCommit: false,
selStart: 1,
selEnd: 1
});
expect(send_queue.has(refId)).toEqual(false);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "3F",
change: "?",
name: "Keystroke",
willCommit: false,
selStart: 2,
selEnd: 2
});
expect(send_queue.has(refId)).toEqual(false);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "3F?",
change: "@",
name: "Keystroke",
willCommit: false,
selStart: 3,
selEnd: 3
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
value: "3F?",
selRange: [3, 3]
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "3F?",
change: "0",
name: "Keystroke",
willCommit: true,
selStart: 3,
selEnd: 3
});
expect(send_queue.has(refId)).toEqual(false);
});
});
describe("eMailValidate", function () {
it("should validate an e-mail address", function (done) {
Promise.all([myeval(`eMailValidate(123)`).then(value => {
expect(value).toEqual(false);
}), myeval(`eMailValidate("foo@bar.com")`).then(value => {
expect(value).toEqual(true);
}), myeval(`eMailValidate("foo bar")`).then(value => {
expect(value).toEqual(false);
})]).then(() => done());
it("should validate an e-mail address", async () => {
let value = await myeval(`eMailValidate(123)`);
expect(value).toEqual(false);
value = await myeval(`eMailValidate("foo@bar.com")`);
expect(value).toEqual(true);
value = await myeval(`eMailValidate("foo bar")`);
expect(value).toEqual(false);
});

@@ -1133,0 +1102,0 @@ });

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -76,3 +76,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

this.now = function () {
return new Date().getTime();
return Date.now();
};

@@ -79,0 +79,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -27,4 +27,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _util = require("../../shared/util.js");
var _is_node = require("../../shared/is_node.js");

@@ -61,70 +59,2 @@

});
describe("getPDFFileNameFromURL", function () {
it("gets PDF filename", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/file1.pdf")).toEqual("file1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("http://www.example.com/pdfs/file2.pdf")).toEqual("file2.pdf");
});
it("gets fallback filename", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/file1.txt")).toEqual("document.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("http://www.example.com/pdfs/file2.txt")).toEqual("document.pdf");
});
it("gets custom fallback filename", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/file1.txt", "qwerty1.pdf")).toEqual("qwerty1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("http://www.example.com/pdfs/file2.txt", "qwerty2.pdf")).toEqual("qwerty2.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/file3.txt", "")).toEqual("");
});
it("gets fallback filename when url is not a string", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)(null)).toEqual("document.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)(null, "file.pdf")).toEqual("file.pdf");
});
it("gets PDF filename from URL containing leading/trailing whitespace", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)(" /pdfs/file1.pdf ")).toEqual("file1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)(" http://www.example.com/pdfs/file2.pdf ")).toEqual("file2.pdf");
});
it("gets PDF filename from query string", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/pdfs.html?name=file1.pdf")).toEqual("file1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("http://www.example.com/pdfs/pdf.html?file2.pdf")).toEqual("file2.pdf");
});
it("gets PDF filename from hash string", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/pdfs.html#name=file1.pdf")).toEqual("file1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("http://www.example.com/pdfs/pdf.html#file2.pdf")).toEqual("file2.pdf");
});
it("gets correct PDF filename when multiple ones are present", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/file1.pdf?name=file.pdf")).toEqual("file1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("http://www.example.com/pdfs/file2.pdf#file.pdf")).toEqual("file2.pdf");
});
it("gets PDF filename from URI-encoded data", function () {
const encodedUrl = encodeURIComponent("http://www.example.com/pdfs/file1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)(encodedUrl)).toEqual("file1.pdf");
const encodedUrlWithQuery = encodeURIComponent("http://www.example.com/pdfs/file.txt?file2.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)(encodedUrlWithQuery)).toEqual("file2.pdf");
});
it("gets PDF filename from data mistaken for URI-encoded", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/%AA.pdf")).toEqual("%AA.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("/pdfs/%2F.pdf")).toEqual("%2F.pdf");
});
it("gets PDF filename from (some) standard protocols", function () {
expect((0, _ui_utils.getPDFFileNameFromURL)("http://www.example.com/file1.pdf")).toEqual("file1.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("https://www.example.com/file2.pdf")).toEqual("file2.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("file:///path/to/files/file3.pdf")).toEqual("file3.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)("ftp://www.example.com/file4.pdf")).toEqual("file4.pdf");
});
it('gets PDF filename from query string appended to "blob:" URL', function () {
if (_is_node.isNodeJS) {
pending("Blob in not supported in Node.js.");
}
const typedArray = new Uint8Array([1, 2, 3, 4, 5]);
const blobUrl = (0, _util.createObjectURL)(typedArray, "application/pdf");
expect(blobUrl.startsWith("blob:")).toEqual(true);
expect((0, _ui_utils.getPDFFileNameFromURL)(blobUrl + "?file.pdf")).toEqual("file.pdf");
});
it('gets fallback filename from query string appended to "data:" URL', function () {
const typedArray = new Uint8Array([1, 2, 3, 4, 5]);
const dataUrl = (0, _util.createObjectURL)(typedArray, "application/pdf", true);
expect(dataUrl.startsWith("data:")).toEqual(true);
expect((0, _ui_utils.getPDFFileNameFromURL)(dataUrl + "?file1.pdf")).toEqual("document.pdf");
expect((0, _ui_utils.getPDFFileNameFromURL)(" " + dataUrl + "?file2.pdf")).toEqual("document.pdf");
});
});
describe("EventBus", function () {

@@ -131,0 +61,0 @@ it("dispatch event", function () {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -243,12 +243,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
describe("encodeToXmlString", function () {
it("should get a correctly encoded string with some entities", function () {
const str = "\"\u0397ell😂' & <W😂rld>";
expect((0, _util.encodeToXmlString)(str)).toEqual("&quot;&#x397;ell&#x1F602;&apos; &amp; &lt;W&#x1F602;rld&gt;");
});
it("should get a correctly encoded basic ascii string", function () {
const str = "hello world";
expect((0, _util.encodeToXmlString)(str)).toEqual(str);
});
});
describe("isAscii", function () {

@@ -255,0 +245,0 @@ it("handles ascii/non-ascii strings", function () {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -27,3 +27,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _xml_parser = require("../../shared/xml_parser.js");
var _xml_parser = require("../../core/xml_parser.js");

@@ -30,0 +30,0 @@ describe("XML", function () {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,3 +32,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _ui_utils = require("./ui_utils.js");
var _l10n_utils = require("./l10n_utils.js");

@@ -46,3 +46,3 @@ var _pdf_link_service = require("./pdf_link_service.js");

renderInteractiveForms = true,
l10n = _ui_utils.NullL10n,
l10n = _l10n_utils.NullL10n,
enableScripting = false,

@@ -120,3 +120,3 @@ hasJSActionsPromise = null,

this.div.setAttribute("hidden", "true");
this.div.hidden = true;
}

@@ -129,3 +129,3 @@

class DefaultAnnotationLayerFactory {
createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = true, l10n = _ui_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = true, l10n = _l10n_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
return new AnnotationLayerBuilder({

@@ -132,0 +132,0 @@ pageDiv,

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -65,7 +65,7 @@ * Licensed under the Apache License, Version 2.0 (the "License");

enablePrintAutoRotate: {
value: false,
value: true,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
},
enableScripting: {
value: false,
value: true,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE

@@ -174,2 +174,6 @@ },

},
enableXfa: {
value: false,
kind: OptionKind.API
},
fontExtraProperties: {

@@ -204,3 +208,16 @@ value: false,

};
;
{
defaultOptions.disablePreferences = {
value: false,
kind: OptionKind.VIEWER
};
defaultOptions.locale = {
value: typeof navigator !== "undefined" ? navigator.language : "en-US",
kind: OptionKind.VIEWER
};
defaultOptions.sandboxBundleSrc = {
value: "../build/pdf.sandbox.js",
kind: OptionKind.VIEWER
};
}
const userOptions = Object.create(null);

@@ -223,3 +240,3 @@

if (defaultOption !== undefined) {
return defaultOption.compatibility || defaultOption.value;
return defaultOption.compatibility ?? defaultOption.value;
}

@@ -255,3 +272,3 @@

const userOption = userOptions[name];
options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
options[name] = userOption !== undefined ? userOption : defaultOption.compatibility ?? defaultOption.value;
}

@@ -258,0 +275,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -38,2 +38,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _l10n_utils = require("./l10n_utils.js");
var _pdf_page_view = require("./pdf_page_view.js");

@@ -45,2 +47,4 @@

var _xfa_layer_builder = require("./xfa_layer_builder.js");
const DEFAULT_CACHE_SIZE = 10;

@@ -108,3 +112,3 @@

const viewerVersion = '2.7.570';
const viewerVersion = '2.8.335';

@@ -123,3 +127,3 @@ if (_pdf.version !== viewerVersion) {

if (getComputedStyle(this.container).position !== "absolute") {
if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
throw new Error("The `container` must be absolutely positioned.");

@@ -132,6 +136,7 @@ }

this.findController = options.findController || null;
this._scriptingManager = options.scriptingManager || null;
this.removePageBorders = options.removePageBorders || false;
this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
this.imageResourcesPath = options.imageResourcesPath || "";
this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
this.renderInteractiveForms = options.renderInteractiveForms !== false;
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;

@@ -142,5 +147,4 @@ this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;

this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.enableScripting = options.enableScripting || false;
this._mouseState = options.mouseState || null;
this.l10n = options.l10n || _l10n_utils.NullL10n;
this.enableScripting = options.enableScripting === true && !!this._scriptingManager;
this.defaultRenderingQueue = !options.renderingQueue;

@@ -186,3 +190,3 @@

return this._pages.every(function (pageView) {
return pageView && pageView.pdfPage;
return pageView?.pdfPage;
});

@@ -227,3 +231,3 @@ }

pageNumber: val,
pageLabel: this._pageLabels && this._pageLabels[val - 1],
pageLabel: this._pageLabels?.[val - 1] ?? null,
previous

@@ -240,3 +244,3 @@ });

get currentPageLabel() {
return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
}

@@ -305,2 +309,8 @@

rotation %= 360;
if (rotation < 0) {
rotation += 360;
}
if (this._pagesRotation === rotation) {

@@ -370,2 +380,6 @@ return;

}
if (this._scriptingManager) {
this._scriptingManager.setDocument(null);
}
}

@@ -379,2 +393,3 @@

const isPureXfa = pdfDocument.isPureXfa;
const pagesCount = pdfDocument.numPages;

@@ -426,2 +441,3 @@ const firstPagePromise = pdfDocument.getPage(1);

const textLayerFactory = this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? this : null;
const xfaLayerFactory = isPureXfa ? this : null;

@@ -440,2 +456,3 @@ for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {

annotationLayerFactory: this,
xfaLayerFactory,
imageResourcesPath: this.imageResourcesPath,

@@ -470,2 +487,6 @@ renderInteractiveForms: this.renderInteractiveForms,

if (this.enableScripting) {
this._scriptingManager.setDocument(pdfDocument);
}
if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {

@@ -535,5 +556,3 @@ this._pagesCapability.resolve();

for (let i = 0, ii = this._pages.length; i < ii; i++) {
const pageView = this._pages[i];
const label = this._pageLabels && this._pageLabels[i];
pageView.setPageLabel(label);
this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
}

@@ -571,4 +590,2 @@ }

this._resetScriptingEvents();
this.viewer.textContent = "";

@@ -646,3 +663,3 @@

get _pageWidthScaleFactor() {
if (this.spreadMode !== _ui_utils.SpreadMode.NONE && this.scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
return 2;

@@ -1080,3 +1097,3 @@ }

createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _ui_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _l10n_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
return new _annotation_layer_builder.AnnotationLayerBuilder({

@@ -1093,6 +1110,13 @@ pageDiv,

hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
mouseState: mouseState || this._mouseState
mouseState: mouseState || this._scriptingManager?.mouseState
});
}
createXfaLayerBuilder(pageDiv, pdfPage) {
return new _xfa_layer_builder.XfaLayerBuilder({
pageDiv,
pdfPage
});
}
get hasEqualPageSizes() {

@@ -1113,26 +1137,19 @@ const firstPageView = this._pages[0];

getPagesOverview() {
const pagesOverview = this._pages.map(function (pageView) {
return this._pages.map(pageView => {
const viewport = pageView.pdfPage.getViewport({
scale: 1
});
return {
width: viewport.width,
height: viewport.height,
rotation: viewport.rotation
};
});
if (!this.enablePrintAutoRotate) {
return pagesOverview;
}
return pagesOverview.map(function (size) {
if ((0, _ui_utils.isPortraitOrientation)(size)) {
return size;
if (!this.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
return {
width: viewport.width,
height: viewport.height,
rotation: viewport.rotation
};
}
return {
width: size.height,
height: size.width,
rotation: (size.rotation + 90) % 360
width: viewport.height,
height: viewport.width,
rotation: (viewport.rotation - 90) % 360
};

@@ -1444,100 +1461,4 @@ });

initializeScriptingEvents() {
if (!this.enableScripting || this._pageOpenPendingSet) {
return;
}
const eventBus = this.eventBus,
pageOpenPendingSet = this._pageOpenPendingSet = new Set(),
scriptingEvents = this._scriptingEvents || (this._scriptingEvents = Object.create(null));
const dispatchPageClose = pageNumber => {
if (pageOpenPendingSet.has(pageNumber)) {
return;
}
eventBus.dispatch("pageclose", {
source: this,
pageNumber
});
};
const dispatchPageOpen = pageNumber => {
const pageView = this._pages[pageNumber - 1];
if (pageView?.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
pageOpenPendingSet.delete(pageNumber);
eventBus.dispatch("pageopen", {
source: this,
pageNumber,
actionsPromise: pageView.pdfPage?.getJSActions()
});
} else {
pageOpenPendingSet.add(pageNumber);
}
};
scriptingEvents.onPageChanging = ({
pageNumber,
previous
}) => {
if (pageNumber === previous) {
return;
}
dispatchPageClose(previous);
dispatchPageOpen(pageNumber);
};
eventBus._on("pagechanging", scriptingEvents.onPageChanging);
scriptingEvents.onPageRendered = ({
pageNumber
}) => {
if (!pageOpenPendingSet.has(pageNumber)) {
return;
}
if (pageNumber !== this._currentPageNumber) {
return;
}
dispatchPageOpen(pageNumber);
};
eventBus._on("pagerendered", scriptingEvents.onPageRendered);
scriptingEvents.onPagesDestroy = () => {
dispatchPageClose(this._currentPageNumber);
};
eventBus._on("pagesdestroy", scriptingEvents.onPagesDestroy);
dispatchPageOpen(this._currentPageNumber);
}
_resetScriptingEvents() {
if (!this.enableScripting || !this._pageOpenPendingSet) {
return;
}
const eventBus = this.eventBus,
scriptingEvents = this._scriptingEvents;
eventBus._off("pagechanging", scriptingEvents.onPageChanging);
scriptingEvents.onPageChanging = null;
eventBus._off("pagerendered", scriptingEvents.onPageRendered);
scriptingEvents.onPageRendered = null;
eventBus._off("pagesdestroy", scriptingEvents.onPagesDestroy);
scriptingEvents.onPagesDestroy = null;
this._pageOpenPendingSet = null;
}
}
exports.BaseViewer = BaseViewer;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -78,3 +78,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

if (origin && !/^file:|^chrome-extension:/.test(origin)) {
_app.PDFViewerApplication.error("Blocked " + origin + " from loading " + file + ". Refused to load a local file in a non-local page " + "for security reasons.");
_app.PDFViewerApplication._documentError("Blocked " + origin + " from loading " + file + ". Refused to load a local file in a non-local page " + "for security reasons.");

@@ -121,3 +121,3 @@ return;

try {
if (chrome.runtime && chrome.runtime.getManifest()) {
if (chrome.runtime?.getManifest()) {
return true;

@@ -211,3 +211,3 @@ }

"zh-TW": "\u5141\u8a31\u5b58\u53d6\u6a94\u6848\u7db2\u5740"
}[chrome.i18n.getUILanguage && chrome.i18n.getUILanguage()];
}[chrome.i18n.getUILanguage?.()];

@@ -277,3 +277,3 @@ if (i18nFileAccessLabel) {

port.postMessage({
referer: window.history.state && window.history.state.chromecomState,
referer: window.history.state?.chromecomState,
requestUrl: url

@@ -280,0 +280,0 @@ });

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -220,3 +220,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

debug.id = "stepper" + pageIndex;
debug.setAttribute("hidden", true);
debug.hidden = true;
debug.className = "stepper";

@@ -248,8 +248,3 @@ stepperDiv.appendChild(debug);

var stepper = steppers[i];
if (stepper.pageIndex === pageIndex) {
stepper.panel.removeAttribute("hidden");
} else {
stepper.panel.setAttribute("hidden", true);
}
stepper.panel.hidden = stepper.pageIndex !== pageIndex;
}

@@ -659,11 +654,6 @@

for (var j = 0; j < tools.length; ++j) {
if (j === index) {
buttons[j].setAttribute("class", "active");
tools[j].active = true;
tools[j].panel.removeAttribute("hidden");
} else {
buttons[j].setAttribute("class", "");
tools[j].active = false;
tools[j].panel.setAttribute("hidden", "true");
}
var isActive = j === index;
buttons[j].classList.toggle("active", isActive);
tools[j].active = isActive;
tools[j].panel.hidden = !isActive;
}

@@ -670,0 +660,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -56,2 +56,6 @@ * Licensed under the Apache License, Version 2.0 (the "License");

class DownloadManager {
constructor() {
this._openBlobUrls = new WeakMap();
}
downloadUrl(url, filename) {

@@ -70,2 +74,35 @@ if (!(0, _pdf.createValidAbsoluteUrl)(url, "http://example.com")) {

openOrDownloadData(element, data, filename) {
const isPdfData = (0, _pdf.isPdfFile)(filename);
const contentType = isPdfData ? "application/pdf" : "";
if (isPdfData && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
let blobUrl = this._openBlobUrls.get(element);
if (!blobUrl) {
blobUrl = URL.createObjectURL(new Blob([data], {
type: contentType
}));
this._openBlobUrls.set(element, blobUrl);
}
let viewerUrl;
viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
try {
window.open(viewerUrl);
return true;
} catch (ex) {
console.error(`openOrDownloadData: ${ex}`);
URL.revokeObjectURL(blobUrl);
this._openBlobUrls.delete(element);
}
}
this.downloadData(data, filename, contentType);
return false;
}
download(blob, url, filename, sourceEventType = "download") {

@@ -72,0 +109,0 @@ if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,4 +32,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _ui_utils = require("./ui_utils.js");
var _app = require("./app.js");

@@ -42,4 +40,2 @@

canvas.height = Math.floor(size.height * PRINT_UNITS);
canvas.style.width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
canvas.style.height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
const canvasWrapper = document.createElement("div");

@@ -46,0 +42,0 @@ canvasWrapper.appendChild(canvas);

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -40,2 +40,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _l10n_utils = require("./l10n_utils.js");
{

@@ -96,2 +98,6 @@ throw new Error('Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.');

class DownloadManager {
constructor() {
this._openBlobUrls = new WeakMap();
}
downloadUrl(url, filename) {

@@ -118,2 +124,34 @@ FirefoxCom.request("download", {

openOrDownloadData(element, data, filename) {
const isPdfData = (0, _pdf.isPdfFile)(filename);
const contentType = isPdfData ? "application/pdf" : "";
if (isPdfData) {
let blobUrl = this._openBlobUrls.get(element);
if (!blobUrl) {
blobUrl = URL.createObjectURL(new Blob([data], {
type: contentType
}));
this._openBlobUrls.set(element, blobUrl);
}
const viewerUrl = blobUrl + "#filename=" + encodeURIComponent(filename);
try {
window.open(viewerUrl);
return true;
} catch (ex) {
console.error(`openOrDownloadData: ${ex}`);
URL.revokeObjectURL(blobUrl);
this._openBlobUrls.delete(element);
}
}
this.downloadData(data, filename, contentType);
return false;
}
download(blob, url, filename, sourceEventType = "download") {

@@ -164,4 +202,4 @@ const blobUrl = URL.createObjectURL(blob);

async get(property, args, fallback) {
return this.mozL10n.get(property, args, fallback);
async get(key, args = null, fallback = (0, _l10n_utils.getL10nFallback)(key, args)) {
return this.mozL10n.get(key, args, fallback);
}

@@ -311,3 +349,3 @@

case "supportsRangedLoading":
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done);
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done, args.filename);
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);

@@ -346,3 +384,3 @@ break;

callbacks.onOpenWithData(args.data);
callbacks.onOpenWithData(args.data, args.filename);
break;

@@ -349,0 +387,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -28,2 +28,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
exports.docPropertiesLookup = docPropertiesLookup;
exports.GenericScripting = void 0;

@@ -33,2 +34,30 @@

async function docPropertiesLookup(pdfDocument) {
const url = "",
baseUrl = url.split("#")[0];
let {
info,
metadata,
contentDispositionFilename,
contentLength
} = await pdfDocument.getMetadata();
if (!contentLength) {
const {
length
} = await pdfDocument.getDownloadInfo();
contentLength = length;
}
return { ...info,
baseURL: baseUrl,
filesize: contentLength,
filename: contentDispositionFilename || (0, _pdf.getPdfFilenameFromUrl)(url),
metadata: metadata?.getRaw(),
authors: metadata?.get("dc:creator"),
numPages: pdfDocument.numPages,
URL: url
};
}
class GenericScripting {

@@ -35,0 +64,0 @@ constructor(sandboxBundleSrc) {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,2 +32,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _l10n_utils = require("./l10n_utils.js");
const webL10n = document.webL10n;

@@ -55,5 +57,5 @@

async get(property, args, fallback) {
async get(key, args = null, fallback = (0, _l10n_utils.getL10nFallback)(key, args)) {
const l10n = await this._ready;
return l10n.get(property, args, fallback);
return l10n.get(key, args, fallback);
}

@@ -60,0 +62,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -84,3 +84,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

ignoreTarget: function GrabToPan_ignoreTarget(node) {
return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
},

@@ -151,28 +151,12 @@ _onmousedown: function GrabToPan__onmousedown(event) {

};
let matchesSelector;
["webkitM", "mozM", "m"].some(function (prefix) {
let name = prefix + "atches";
if (name in document.documentElement) {
matchesSelector = name;
}
name += "Selector";
if (name in document.documentElement) {
matchesSelector = name;
}
return matchesSelector;
});
const isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
const chrome = window.chrome;
const isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
const isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
function isLeftMouseReleased(event) {
if ("buttons" in event && isNotIEorIsIE10plus) {
if ("buttons" in event) {
return !(event.buttons & 1);
}
const chrome = window.chrome;
const isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
const isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
if (isChrome15OrOpera15plus || isSafari6plus) {

@@ -179,0 +163,0 @@ return event.which === 0;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -28,3 +28,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
exports.IRenderableView = exports.IPDFTextLayerFactory = exports.IPDFLinkService = exports.IPDFHistory = exports.IPDFAnnotationLayerFactory = exports.IL10n = void 0;
exports.IRenderableView = exports.IPDFXfaLayerFactory = exports.IPDFTextLayerFactory = exports.IPDFLinkService = exports.IPDFHistory = exports.IPDFAnnotationLayerFactory = exports.IL10n = void 0;

@@ -122,2 +122,9 @@ class IPDFLinkService {

class IPDFXfaLayerFactory {
createXfaLayerBuilder(pageDiv, pdfPage) {}
}
exports.IPDFXfaLayerFactory = IPDFXfaLayerFactory;
class IL10n {

@@ -124,0 +131,0 @@ async getLanguage() {}

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -30,8 +30,6 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _ui_utils = require("./ui_utils.js");
var _pdf = require("../pdf");
class PasswordPrompt {
constructor(options, overlayManager, l10n = _ui_utils.NullL10n) {
constructor(options, overlayManager, l10n, isViewerEmbedded = false) {
this.overlayName = options.overlayName;

@@ -45,2 +43,3 @@ this.container = options.container;

this.l10n = l10n;
this._isViewerEmbedded = isViewerEmbedded;
this.updateCallback = null;

@@ -58,17 +57,11 @@ this.reason = null;

open() {
this.overlayManager.open(this.overlayName).then(() => {
async open() {
await this.overlayManager.open(this.overlayName);
const passwordIncorrect = this.reason === _pdf.PasswordResponses.INCORRECT_PASSWORD;
if (!this._isViewerEmbedded || passwordIncorrect) {
this.input.focus();
let promptString;
}
if (this.reason === _pdf.PasswordResponses.INCORRECT_PASSWORD) {
promptString = this.l10n.get("password_invalid", null, "Invalid password. Please try again.");
} else {
promptString = this.l10n.get("password_label", null, "Enter the password to open this PDF file.");
}
promptString.then(msg => {
this.label.textContent = msg;
});
});
this.label.textContent = await this.l10n.get(`password_${passwordIncorrect ? "invalid" : "label"}`);
}

@@ -85,3 +78,3 @@

if (password && password.length > 0) {
if (password?.length > 0) {
this.close();

@@ -88,0 +81,0 @@ this.updateCallback(password);

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -34,6 +34,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _viewer_compatibility = require("./viewer_compatibility.js");
const PdfFileRegExp = /\.pdf$/i;
class PDFAttachmentViewer extends _base_tree_viewer.BaseTreeViewer {

@@ -87,31 +83,2 @@ constructor(options) {

_bindPdfLink(element, {
content,
filename
}) {
let blobUrl;
element.onclick = () => {
if (!blobUrl) {
blobUrl = URL.createObjectURL(new Blob([content], {
type: "application/pdf"
}));
}
let viewerUrl;
viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
try {
window.open(viewerUrl);
} catch (ex) {
console.error(`_bindPdfLink: ${ex}`);
URL.revokeObjectURL(blobUrl);
blobUrl = null;
this.downloadManager.downloadData(content, filename, "application/pdf");
}
return false;
};
}
_bindLink(element, {

@@ -122,4 +89,3 @@ content,

element.onclick = () => {
const contentType = PdfFileRegExp.test(filename) ? "application/pdf" : "";
this.downloadManager.downloadData(content, filename, contentType);
this.downloadManager.openOrDownloadData(element, content, filename);
return false;

@@ -153,3 +119,4 @@ };

const item = attachments[name];
const filename = (0, _pdf.getFilenameFromUrl)(item.filename);
const content = item.content,
filename = (0, _pdf.getFilenameFromUrl)(item.filename);
const div = document.createElement("div");

@@ -159,13 +126,6 @@ div.className = "treeItem";

if (PdfFileRegExp.test(filename) && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
this._bindPdfLink(element, {
content: item.content,
filename
});
} else {
this._bindLink(element, {
content: item.content,
filename
});
}
this._bindLink(element, {
content,
filename
});

@@ -172,0 +132,0 @@ element.textContent = this._normalizeTextContent(filename);

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -123,5 +123,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

switch (evt.state) {
case _ui_utils.PresentationModeState.CHANGING:
break;
case _ui_utils.PresentationModeState.FULLSCREEN:

@@ -128,0 +125,0 @@ {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -57,3 +57,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

closeButton
}, overlayManager, eventBus, l10n = _ui_utils.NullL10n) {
}, overlayManager, eventBus, l10n) {
this.overlayName = overlayName;

@@ -109,3 +109,3 @@ this.fields = fields;

} = await this.pdfDocument.getMetadata();
const [fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized] = await Promise.all([contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url), this._parseFileSize(contentLength), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
const [fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized] = await Promise.all([contentDispositionFilename || (0, _pdf.getPdfFilenameFromUrl)(this.url), this._parseFileSize(contentLength), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
return this._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);

@@ -199,17 +199,14 @@ }), this._parseLinearization(info.IsLinearized)]);

async _parseFileSize(fileSize = 0) {
const kb = fileSize / 1024;
const kb = fileSize / 1024,
mb = kb / 1024;
if (!kb) {
return undefined;
} else if (kb < 1024) {
return this.l10n.get("document_properties_kb", {
size_kb: (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, "{{size_kb}} KB ({{size_b}} bytes)");
}
return this.l10n.get("document_properties_mb", {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, "{{size_mb}} MB ({{size_b}} bytes)");
});
}

@@ -238,3 +235,2 @@

};
let pageName = null;
let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);

@@ -265,17 +261,12 @@

if (rawName) {
pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
}
return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(([{
const [{
width,
height
}, unit, name, orientation]) => {
return this.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
width: width.toLocaleString(),
height: height.toLocaleString(),
unit,
name,
orientation
}, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
}, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get(`document_properties_page_size_unit_${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.l10n.get(`document_properties_page_size_name_${rawName.toLowerCase()}`), this.l10n.get(`document_properties_page_size_orientation_${isPortrait ? "portrait" : "landscape"}`)]);
return this.l10n.get(`document_properties_page_size_dimension_${name ? "name_" : ""}string`, {
width: width.toLocaleString(),
height: height.toLocaleString(),
unit,
name,
orientation
});

@@ -294,7 +285,7 @@ }

time: dateObject.toLocaleTimeString()
}, "{{date}}, {{time}}");
});
}
_parseLinearization(isLinearized) {
return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
return this.l10n.get(`document_properties_linearized_${isLinearized ? "yes" : "no"}`);
}

@@ -301,0 +292,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -32,19 +32,17 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _ui_utils = require("./ui_utils.js");
const MATCHES_COUNT_LIMIT = 1000;
class PDFFindBar {
constructor(options, eventBus, l10n = _ui_utils.NullL10n) {
constructor(options, eventBus, l10n) {
this.opened = false;
this.bar = options.bar || null;
this.toggleButton = options.toggleButton || null;
this.findField = options.findField || null;
this.highlightAll = options.highlightAllCheckbox || null;
this.caseSensitive = options.caseSensitiveCheckbox || null;
this.entireWord = options.entireWordCheckbox || null;
this.findMsg = options.findMsg || null;
this.findResultsCount = options.findResultsCount || null;
this.findPreviousButton = options.findPreviousButton || null;
this.findNextButton = options.findNextButton || null;
this.bar = options.bar;
this.toggleButton = options.toggleButton;
this.findField = options.findField;
this.highlightAll = options.highlightAllCheckbox;
this.caseSensitive = options.caseSensitiveCheckbox;
this.entireWord = options.entireWordCheckbox;
this.findMsg = options.findMsg;
this.findResultsCount = options.findResultsCount;
this.findPreviousButton = options.findPreviousButton;
this.findNextButton = options.findNextButton;
this.eventBus = eventBus;

@@ -109,3 +107,3 @@ this.l10n = l10n;

updateUIState(state, previous, matchesCount) {
let findMsg = "";
let findMsg = Promise.resolve("");
let status = "";

@@ -122,3 +120,3 @@

case _pdf_find_controller.FindState.NOT_FOUND:
findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
findMsg = this.l10n.get("find_not_found");
status = "notFound";

@@ -128,8 +126,3 @@ break;

case _pdf_find_controller.FindState.WRAPPED:
if (previous) {
findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
} else {
findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
}
findMsg = this.l10n.get(`find_reached_${previous ? "top" : "bottom"}`);
break;

@@ -139,3 +132,3 @@ }

this.findField.setAttribute("data-status", status);
Promise.resolve(findMsg).then(msg => {
findMsg.then(msg => {
this.findMsg.textContent = msg;

@@ -152,23 +145,21 @@

} = {}) {
if (!this.findResultsCount) {
return;
}
const limit = MATCHES_COUNT_LIMIT;
let matchesCountMsg = "";
let matchCountMsg = Promise.resolve("");
if (total > 0) {
if (total > limit) {
matchesCountMsg = this.l10n.get("find_match_count_limit", {
let key = "find_match_count_limit";
matchCountMsg = this.l10n.get(key, {
limit
}, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
});
} else {
matchesCountMsg = this.l10n.get("find_match_count", {
let key = "find_match_count";
matchCountMsg = this.l10n.get(key, {
current,
total
}, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
});
}
}
Promise.resolve(matchesCountMsg).then(msg => {
matchCountMsg.then(msg => {
this.findResultsCount.textContent = msg;

@@ -185,2 +176,3 @@ this.findResultsCount.classList.toggle("hidden", !total);

this.toggleButton.classList.add("toggled");
this.toggleButton.setAttribute("aria-expanded", "true");
this.bar.classList.remove("hidden");

@@ -202,2 +194,3 @@ }

this.toggleButton.classList.remove("toggled");
this.toggleButton.setAttribute("aria-expanded", "false");
this.bar.classList.add("hidden");

@@ -204,0 +197,0 @@ this.eventBus.dispatch("findbarclose", {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -709,3 +709,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

for (let i = 0; i < pageIdx; i++) {
current += this._pageMatches[i] && this._pageMatches[i].length || 0;
current += this._pageMatches[i]?.length || 0;
}

@@ -739,3 +739,3 @@

matchesCount: this._requestMatchesCount(),
rawQuery: this._state ? this._state.query : null
rawQuery: this._state?.query ?? null
});

@@ -742,0 +742,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -173,3 +173,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

return;
} else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
} else if (!this._isValidPage(pageNumber)) {
if (pageNumber !== null || this._destination) {

@@ -221,3 +221,3 @@ console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);

if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
if (!this._isValidPage(pageNumber)) {
console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);

@@ -236,2 +236,3 @@ return;

this._pushOrReplaceState({
dest: null,
hash: `page=${pageNumber}`,

@@ -356,3 +357,3 @@ page: pageNumber,

if (this._destination.page >= position.first && this._destination.page <= position.page) {
if (this._destination.dest || !this._destination.first) {
if (this._destination.dest !== undefined || !this._destination.first) {
return;

@@ -367,2 +368,6 @@ }

_isValidPage(val) {
return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
}
_isValidState(state, checkReload = false) {

@@ -422,3 +427,3 @@ if (!state) {

if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
page = null;

@@ -425,0 +430,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -89,3 +89,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

element.textContent = await this.l10n.get("additional_layers", null, "Additional Layers");
element.textContent = await this.l10n.get("additional_layers");
element.style.fontStyle = "italic";

@@ -118,3 +118,3 @@ }

this._pdfDocument = pdfDocument || null;
const groups = optionalContentConfig && optionalContentConfig.getOrder();
const groups = optionalContentConfig?.getOrder();

@@ -121,0 +121,0 @@ if (!groups) {

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -348,3 +348,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
return this._pagesRefCache && this._pagesRefCache[refStr] || null;
return this._pagesRefCache?.[refStr] || null;
}

@@ -351,0 +351,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -298,3 +298,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

if (typeof destRef === "object") {
if (destRef instanceof Object) {
pageNumber = this.linkService._cachedPageNumber(destRef);

@@ -301,0 +301,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -34,2 +34,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _l10n_utils = require("./l10n_utils.js");
var _pdf_rendering_queue = require("./pdf_rendering_queue.js");

@@ -57,3 +59,3 @@

this.imageResourcesPath = options.imageResourcesPath || "";
this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
this.renderInteractiveForms = options.renderInteractiveForms !== false;
this.useOnlyCssZoom = options.useOnlyCssZoom || false;

@@ -65,6 +67,7 @@ this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;

this.annotationLayerFactory = options.annotationLayerFactory;
this.xfaLayerFactory = options.xfaLayerFactory;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.enableWebGL = options.enableWebGL || false;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.enableScripting = options.enableScripting || false;
this.l10n = options.l10n || _l10n_utils.NullL10n;
this.enableScripting = options.enableScripting === true;
this.paintTask = null;

@@ -78,2 +81,3 @@ this.paintedViewportMap = new WeakMap();

this.zoomLayer = null;
this.xfaLayer = null;
const div = document.createElement("div");

@@ -84,2 +88,8 @@ div.className = "page";

div.setAttribute("data-page-number", this.id);
div.setAttribute("role", "region");
this.l10n.get("page_landmark", {
page: this.id
}).then(msg => {
div.setAttribute("aria-label", msg);
});
this.div = div;

@@ -124,2 +134,18 @@ container.appendChild(div);

async _renderXfaLayer() {
let error = null;
try {
await this.xfaLayer.render(this.viewport, "display");
} catch (ex) {
error = ex;
} finally {
this.eventBus.dispatch("xfalayerrendered", {
source: this,
pageNumber: this.id,
error
});
}
}
_resetZoomLayer(removeFromDOM = false) {

@@ -150,3 +176,4 @@ if (!this.zoomLayer) {

const currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
const currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
const currentAnnotationNode = keepAnnotations && this.annotationLayer?.div || null;
const currentXfaLayerNode = this.xfaLayer?.div || null;

@@ -156,3 +183,3 @@ for (let i = childNodes.length - 1; i >= 0; i--) {

if (currentZoomLayerNode === node || currentAnnotationNode === node) {
if (currentZoomLayerNode === node || currentAnnotationNode === node || currentXfaLayerNode === node) {
continue;

@@ -191,2 +218,6 @@ }

this.loadingIconDiv.className = "loadingIcon";
this.loadingIconDiv.setAttribute("role", "img");
this.l10n.get("loading").then(msg => {
this.loadingIconDiv?.setAttribute("aria-label", msg);
});
div.appendChild(this.loadingIconDiv);

@@ -247,3 +278,3 @@ }

if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
if (!this.zoomLayer && !this.canvas.hidden) {
this.zoomLayer = this.canvas.parentNode;

@@ -343,2 +374,6 @@ this.zoomLayer.style.position = "absolute";

}
if (this.xfaLayer) {
this._renderXfaLayer();
}
}

@@ -386,3 +421,3 @@

if (this.annotationLayer && this.annotationLayer.div) {
if (this.annotationLayer?.div) {
div.insertBefore(canvasWrapper, this.annotationLayer.div);

@@ -401,3 +436,3 @@ } else {

if (this.annotationLayer && this.annotationLayer.div) {
if (this.annotationLayer?.div) {
div.insertBefore(textLayerDiv, this.annotationLayer.div);

@@ -489,2 +524,10 @@ } else {

if (this.xfaLayerFactory) {
if (!this.xfaLayer) {
this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder(div, pdfPage);
}
this._renderXfaLayer();
}
div.setAttribute("data-loaded", true);

@@ -514,8 +557,3 @@ this.eventBus.dispatch("pagerender", {

const canvas = document.createElement("canvas");
this.l10n.get("page_canvas", {
page: this.id
}, "Page {{page}}").then(msg => {
canvas.setAttribute("aria-label", msg);
});
canvas.setAttribute("hidden", "hidden");
canvas.hidden = true;
let isCanvasHidden = true;

@@ -525,3 +563,3 @@

if (isCanvasHidden) {
canvas.removeAttribute("hidden");
canvas.hidden = false;
isCanvasHidden = false;

@@ -616,3 +654,3 @@ }

ensureNotCancelled();
const svgGfx = new _pdf.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
const svgGfx = new _pdf.SVGGraphics(pdfPage.commonObjs, pdfPage.objs, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {

@@ -619,0 +657,0 @@ ensureNotCancelled();

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -45,4 +45,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

pdfViewer,
eventBus,
contextMenuItems = null
eventBus
}) {

@@ -58,29 +57,2 @@ this.container = container;

this.touchSwipeState = null;
if (contextMenuItems) {
contextMenuItems.contextFirstPage.addEventListener("click", () => {
this.contextMenuOpen = false;
this.eventBus.dispatch("firstpage", {
source: this
});
});
contextMenuItems.contextLastPage.addEventListener("click", () => {
this.contextMenuOpen = false;
this.eventBus.dispatch("lastpage", {
source: this
});
});
contextMenuItems.contextPageRotateCw.addEventListener("click", () => {
this.contextMenuOpen = false;
this.eventBus.dispatch("rotatecw", {
source: this
});
});
contextMenuItems.contextPageRotateCcw.addEventListener("click", () => {
this.contextMenuOpen = false;
this.eventBus.dispatch("rotateccw", {
source: this
});
});
}
}

@@ -123,3 +95,3 @@

const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
const currentTime = new Date().getTime();
const currentTime = Date.now();
const storedTime = this.mouseScrollTimeStamp;

@@ -217,3 +189,2 @@

this.contextMenuOpen = false;
this.container.setAttribute("contextmenu", "viewerContextMenu");
window.getSelection().removeAllRanges();

@@ -243,3 +214,2 @@ }

this.container.removeAttribute("contextmenu");
this.contextMenuOpen = false;

@@ -246,0 +216,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -30,4 +30,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var _ui_utils = require("./ui_utils.js");
var _app = require("./app.js");

@@ -45,4 +43,2 @@

scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
const width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
const height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
const ctx = scratchCanvas.getContext("2d");

@@ -66,7 +62,2 @@ ctx.save();

return pdfPage.render(renderContext).promise;
}).then(function () {
return {
width,
height
};
});

@@ -81,3 +72,3 @@ }

this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
this.l10n = l10n || _ui_utils.NullL10n;
this.l10n = l10n;
this.currentPage = -1;

@@ -102,3 +93,3 @@ this.scratchCanvas = document.createElement("canvas");

const pageSize = this.pagesOverview[0];
this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
this.pageStyleSheet.textContent = "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}";
body.appendChild(this.pageStyleSheet);

@@ -155,7 +146,5 @@ },

useRenderedPage(printItem) {
useRenderedPage() {
this.throwIfInactive();
const img = document.createElement("img");
img.style.width = printItem.width;
img.style.height = printItem.height;
const scratchCanvas = this.scratchCanvas;

@@ -265,3 +254,3 @@

progress
}, progress + "%").then(msg => {
}).then(msg => {
progressPerc.textContent = msg;

@@ -268,0 +257,0 @@ });

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -29,5 +29,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

exports.PDFSidebarResizer = void 0;
var _ui_utils = require("./ui_utils.js");
const SIDEBAR_WIDTH_VAR = "--sidebar-width";

@@ -38,3 +35,3 @@ const SIDEBAR_MIN_WIDTH = 200;

class PDFSidebarResizer {
constructor(options, eventBus, l10n = _ui_utils.NullL10n) {
constructor(options, eventBus, l10n) {
this.isRTL = false;

@@ -57,7 +54,3 @@ this.sidebarOpen = false;

get outerContainerWidth() {
if (!this._outerContainerWidth) {
this._outerContainerWidth = this.outerContainer.clientWidth;
}
return this._outerContainerWidth;
return this._outerContainerWidth || (this._outerContainerWidth = this.outerContainer.clientWidth);
}

@@ -120,7 +113,7 @@

this.eventBus._on("sidebarviewchanged", evt => {
this.sidebarOpen = !!(evt && evt.view);
this.sidebarOpen = !!evt?.view;
});
this.eventBus._on("resize", evt => {
if (!evt || evt.source !== window) {
if (evt?.source !== window) {
return;

@@ -127,0 +120,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -42,3 +42,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

eventBus,
l10n = _ui_utils.NullL10n
l10n
}) {

@@ -207,2 +207,3 @@ this.isOpen = false;

this.toggleButton.classList.add("toggled");
this.toggleButton.setAttribute("aria-expanded", "true");
this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");

@@ -228,2 +229,3 @@

this.toggleButton.classList.remove("toggled");
this.toggleButton.setAttribute("aria-expanded", "false");
this.outerContainer.classList.add("sidebarMoving");

@@ -271,3 +273,3 @@ this.outerContainer.classList.remove("sidebarOpen");

if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
if (pageView?.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
const thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);

@@ -282,3 +284,3 @@ thumbnailView.setImage(pageView);

_showUINotification() {
this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(msg => {
this.l10n.get("toggle_sidebar_notification2.title").then(msg => {
this.toggleButton.title = msg;

@@ -298,3 +300,3 @@ });

if (reset) {
this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(msg => {
this.l10n.get("toggle_sidebar.title").then(msg => {
this.toggleButton.title = msg;

@@ -301,0 +303,0 @@ });

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -90,3 +90,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

disableCanvasToImageConversion = false,
l10n = _ui_utils.NullL10n
l10n
}) {

@@ -409,3 +409,3 @@ this.id = id;

page: this.pageLabel ?? this.id
}, "Page {{page}}");
});
}

@@ -416,3 +416,3 @@

page: this.pageLabel ?? this.id
}, "Thumbnail of Page {{page}}");
});
}

@@ -419,0 +419,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -45,3 +45,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

renderingQueue,
l10n = _ui_utils.NullL10n
l10n
}) {

@@ -249,5 +249,3 @@ this.container = container;

for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
const label = this._pageLabels && this._pageLabels[i];
this._thumbnails[i].setPageLabel(label);
this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
}

@@ -254,0 +252,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -58,8 +58,2 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
Object.defineProperty(exports, "NullL10n", {
enumerable: true,
get: function () {
return _ui_utils.NullL10n;
}
});
Object.defineProperty(exports, "ProgressBar", {

@@ -95,2 +89,8 @@ enumerable: true,

});
Object.defineProperty(exports, "NullL10n", {
enumerable: true,
get: function () {
return _l10n_utils.NullL10n;
}
});
Object.defineProperty(exports, "PDFFindController", {

@@ -114,2 +114,8 @@ enumerable: true,

});
Object.defineProperty(exports, "PDFScriptingManager", {
enumerable: true,
get: function () {
return _pdf_scripting_manager.PDFScriptingManager;
}
});
Object.defineProperty(exports, "PDFSinglePageViewer", {

@@ -140,2 +146,4 @@ enumerable: true,

var _l10n_utils = require("./l10n_utils.js");
var _pdf_find_controller = require("./pdf_find_controller.js");

@@ -147,2 +155,4 @@

var _pdf_scripting_manager = require("./pdf_scripting_manager.js");
var _pdf_single_page_viewer = require("./pdf_single_page_viewer.js");

@@ -152,3 +162,3 @@

const pdfjsVersion = '2.7.570';
const pdfjsBuild = 'f2c7338b0';
const pdfjsVersion = '2.8.335';
const pdfjsBuild = '228adbf67';

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -44,4 +44,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

"enablePermissions": false,
"enablePrintAutoRotate": false,
"enableScripting": false,
"enablePrintAutoRotate": true,
"enableScripting": true,
"enableWebGL": false,

@@ -70,17 +70,10 @@ "externalLinkTarget": 0,

});
this.prefs = Object.assign(Object.create(null), this.defaults);
this.prefs = Object.create(null);
this._initializedPromise = this._readFromStorage(this.defaults).then(prefs => {
if (!prefs) {
return;
}
for (const name in this.defaults) {
const prefValue = prefs?.[name];
for (const name in prefs) {
const defaultValue = this.defaults[name],
prefValue = prefs[name];
if (defaultValue === undefined || typeof prefValue !== typeof defaultValue) {
continue;
if (typeof prefValue === typeof this.defaults[name]) {
this.prefs[name] = prefValue;
}
this.prefs[name] = prefValue;
}

@@ -100,3 +93,3 @@ });

await this._initializedPromise;
this.prefs = Object.assign(Object.create(null), this.defaults);
this.prefs = Object.create(null);
return this._writeToStorage(this.defaults);

@@ -122,3 +115,3 @@ }

} else {
throw new Error(`Set preference: "${value}" is a ${valueType}, ` + `expected a ${defaultType}.`);
throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
}

@@ -137,15 +130,10 @@ } else {

await this._initializedPromise;
const defaultValue = this.defaults[name];
const defaultValue = this.defaults[name],
prefValue = this.prefs[name];
if (defaultValue === undefined) {
throw new Error(`Get preference: "${name}" is undefined.`);
} else {
const prefValue = this.prefs[name];
if (prefValue !== undefined) {
return prefValue;
}
}
return defaultValue;
return prefValue !== undefined ? prefValue : defaultValue;
}

@@ -155,3 +143,10 @@

await this._initializedPromise;
return Object.assign(Object.create(null), this.defaults, this.prefs);
const obj = Object.create(null);
for (const name in this.defaults) {
const prefValue = this.prefs[name];
obj[name] = prefValue !== undefined ? prefValue : this.defaults[name];
}
return obj;
}

@@ -158,0 +153,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -296,2 +296,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

this.toggleButton.classList.add("toggled");
this.toggleButton.setAttribute("aria-expanded", "true");
this.toolbar.classList.remove("hidden");

@@ -308,2 +309,3 @@ }

this.toggleButton.classList.remove("toggled");
this.toggleButton.setAttribute("aria-expanded", "false");
}

@@ -310,0 +312,0 @@

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -310,3 +310,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

if (!findController || !findController.highlightMatches) {
if (!findController?.highlightMatches) {
return;

@@ -313,0 +313,0 @@ }

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -37,3 +37,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

class Toolbar {
constructor(options, eventBus, l10n = _ui_utils.NullL10n) {
constructor(options, eventBus, l10n) {
this.toolbar = options.container;

@@ -191,3 +191,3 @@ this.eventBus = eventBus;

pagesCount
}, "of {{pagesCount}}").then(msg => {
}).then(msg => {
items.numPages.textContent = msg;

@@ -205,3 +205,3 @@ });

pagesCount
}, "({{pageNumber}} of {{pagesCount}})").then(msg => {
}).then(msg => {
items.numPages.textContent = msg;

@@ -217,6 +217,5 @@ });

items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
const customScale = Math.round(pageScale * 10000) / 100;
this.l10n.get("page_scale_percent", {
scale: customScale
}, "{{scale}}%").then(msg => {
scale: Math.round(pageScale * 10000) / 100
}).then(msg => {
let predefinedValueFound = false;

@@ -251,3 +250,3 @@

} = this;
const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto", null, "Automatic Zoom"), l10n.get("page_scale_actual", null, "Actual Size"), l10n.get("page_scale_fit", null, "Page Fit"), l10n.get("page_scale_width", null, "Page Width")]);
const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get("page_scale_actual"), l10n.get("page_scale_fit"), l10n.get("page_scale_width")]);
let canvas = document.createElement("canvas");

@@ -254,0 +253,0 @@ canvas.mozOpaque = true;

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -28,2 +28,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

});
exports.apiPageLayoutToSpreadMode = apiPageLayoutToSpreadMode;
exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
exports.approximateFraction = approximateFraction;

@@ -35,3 +37,2 @@ exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;

exports.getPageSizeInches = getPageSizeInches;
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
exports.getVisibleElements = getVisibleElements;

@@ -51,3 +52,3 @@ exports.isPortraitOrientation = isPortraitOrientation;

exports.watchScroll = watchScroll;
exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.NullL10n = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
const CSS_UNITS = 96.0 / 72.0;

@@ -116,30 +117,2 @@ exports.CSS_UNITS = CSS_UNITS;

function formatL10nValue(text, args) {
if (!args) {
return text;
}
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
return name in args ? args[name] : "{{" + name + "}}";
});
}
const NullL10n = {
async getLanguage() {
return "en-us";
},
async getDirection() {
return "ltr";
},
async get(property, args, fallback) {
return formatL10nValue(fallback, args);
},
async translate(element) {}
};
exports.NullL10n = NullL10n;
function getOutputScale(ctx) {

@@ -468,43 +441,4 @@ const devicePixelRatio = window.devicePixelRatio || 1;

function isDataSchema(url) {
let i = 0;
const ii = url.length;
while (i < ii && url[i].trim() === "") {
i++;
}
return url.substring(i, i + 5).toLowerCase() === "data:";
}
function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
if (typeof url !== "string") {
return defaultFilename;
}
if (isDataSchema(url)) {
console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
return defaultFilename;
}
const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
const splitURI = reURI.exec(url);
let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
if (suggestedFilename) {
suggestedFilename = suggestedFilename[0];
if (suggestedFilename.includes("%")) {
try {
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
} catch (ex) {}
}
}
return suggestedFilename || defaultFilename;
}
function normalizeWheelEventDirection(evt) {
let delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
let delta = Math.hypot(evt.deltaX, evt.deltaY);
const angle = Math.atan2(evt.deltaY, evt.deltaX);

@@ -595,2 +529,7 @@

const animationStarted = new Promise(function (resolve) {
if (typeof window === "undefined") {
setTimeout(resolve, 20);
return;
}
window.requestAnimationFrame(resolve);

@@ -789,3 +728,3 @@ });

while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
while (curActiveOrFocused?.shadowRoot) {
curRoot = curActiveOrFocused.shadowRoot;

@@ -796,2 +735,41 @@ curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");

return curActiveOrFocused;
}
function apiPageLayoutToSpreadMode(layout) {
switch (layout) {
case "SinglePage":
case "OneColumn":
return SpreadMode.NONE;
case "TwoColumnLeft":
case "TwoPageLeft":
return SpreadMode.ODD;
case "TwoColumnRight":
case "TwoPageRight":
return SpreadMode.EVEN;
}
return SpreadMode.NONE;
}
function apiPageModeToSidebarView(mode) {
switch (mode) {
case "UseNone":
return SidebarView.NONE;
case "UseThumbs":
return SidebarView.THUMBS;
case "UseOutlines":
return SidebarView.OUTLINE;
case "UseAttachments":
return SidebarView.ATTACHMENTS;
case "UseOC":
return SidebarView.LAYERS;
}
return SidebarView.NONE;
}

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

@@ -5,3 +5,3 @@ /**

*
* Copyright 2020 Mozilla Foundation
* Copyright 2021 Mozilla Foundation
*

@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

{
"name": "pdfjs-dist",
"version": "2.7.570",
"version": "2.8.335",
"main": "build/pdf.js",

@@ -5,0 +5,0 @@ "types": "types/pdf.d.ts",

@@ -12,4 +12,4 @@ # PDF.js

features such as e.g. `async`/`await`, `ReadableStream`, optional chaining, and
nullish coalescing; please see the `es5` folder.
nullish coalescing; please see the `legacy` folder.
See https://github.com/mozilla/pdf.js for learning and contributing.

@@ -10,4 +10,3 @@ /**

/**
* Get the value for a given key if it exists
* or store and return the default value
* Get the value for a given key if it exists, or return the default value.
*

@@ -20,4 +19,8 @@ * @public

*/
public getOrCreateValue(key: string, defaultValue: Object): Object;
public getValue(key: string, defaultValue: Object): Object;
/**
* @deprecated
*/
getOrCreateValue(key: any, defaultValue: any): any;
/**
* Set the value for a given key

@@ -38,2 +41,7 @@ *

resetModified(): void;
/**
* PLEASE NOTE: Only intended for usage within the API itself.
* @ignore
*/
get serializable(): Map<any, any> | null;
}

@@ -9,3 +9,3 @@ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;

*/
url?: string | undefined;
url?: string | URL | undefined;
/**

@@ -16,3 +16,3 @@ * - Binary PDF data. Use

*/
data?: string | number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | undefined;
data?: string | number[] | TypedArray | undefined;
/**

@@ -37,3 +37,3 @@ * - Basic authentication headers.

*/
initialData?: Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | undefined;
initialData?: TypedArray | undefined;
/**

@@ -122,2 +122,7 @@ * - The PDF file length. It's used for progress

/**
* - Render Xfa forms if any.
* The default value is `false`.
*/
enableXfa?: boolean | undefined;
/**
* - Specify an explicit document

@@ -156,20 +161,2 @@ * context to create elements with and to load resources, such as fonts,

};
export type PDFDocumentStats = {
/**
* - Used stream types in the
* document (an item is set to true if specific stream ID was used in the
* document).
*/
streamTypes: {
[x: string]: boolean;
};
/**
* - Used font types in the
* document (an item is set to true if specific font ID was used in the
* document).
*/
fontTypes: {
[x: string]: boolean;
};
};
export type IPDFStreamFactory = Function;

@@ -222,3 +209,45 @@ /**

};
export type OutlineNode = {
title: string;
bold: boolean;
italic: boolean;
/**
* - The color in RGB format to use for
* display purposes.
*/
color: Uint8ClampedArray;
dest: string | Array<any> | null;
url: string | null;
unsafeUrl: string | undefined;
newWindow: boolean | undefined;
count: number | undefined;
items: Array<OutlineNode>;
};
/**
* Properties correspond to Table 321 of the PDF 32000-1:2008 spec.
*/
export type MarkInfo = {
Marked: boolean;
UserProperties: boolean;
Suspects: boolean;
};
export type PDFDocumentStats = {
/**
* - Used stream types in the
* document (an item is set to true if specific stream ID was used in the
* document).
*/
streamTypes: {
[x: string]: boolean;
};
/**
* - Used font types in the
* document (an item is set to true if specific font ID was used in the
* document).
*/
fontTypes: {
[x: string]: boolean;
};
};
/**
* Page getViewport parameters.

@@ -458,3 +487,3 @@ */

* @typedef {Object} DocumentInitParameters
* @property {string} [url] - The URL of the PDF.
* @property {string|URL} [url] - The URL of the PDF.
* @property {TypedArray|Array<number>|string} [data] - Binary PDF data. Use

@@ -511,2 +540,4 @@ * typed arrays (Uint8Array) to improve the memory usage. If PDF data is

* increased memory usage. The default value is `false`.
* @property {boolean} [enableXfa] - Render Xfa forms if any.
* The default value is `false`.
* @property {HTMLDocument} [ownerDocument] - Specify an explicit document

@@ -532,11 +563,2 @@ * context to create elements with and to load resources, such as fonts,

/**
* @typedef {Object} PDFDocumentStats
* @property {Object<string, boolean>} streamTypes - Used stream types in the
* document (an item is set to true if specific stream ID was used in the
* document).
* @property {Object<string, boolean>} fontTypes - Used font types in the
* document (an item is set to true if specific font ID was used in the
* document).
*/
/**
* This is the main entry point for loading a PDF and interacting with it.

@@ -548,12 +570,10 @@ *

*
* @param {string|TypedArray|DocumentInitParameters|PDFDataRangeTransport} src -
* Can be a URL to where a PDF file is located, a typed array (Uint8Array)
* already populated with data or parameter object.
* @param {string|URL|TypedArray|PDFDataRangeTransport|DocumentInitParameters}
* src - Can be a URL where a PDF file is located, a typed array (Uint8Array)
* already populated with data, or a parameter object.
* @returns {PDFDocumentLoadingTask}
*/
export function getDocument(src: string | TypedArray | DocumentInitParameters | PDFDataRangeTransport): PDFDocumentLoadingTask;
export function getDocument(src: string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters): PDFDocumentLoadingTask;
export class LoopbackPort {
constructor(defer?: boolean);
_listeners: any[];
_defer: boolean;
_deferred: Promise<undefined>;

@@ -573,7 +593,9 @@ postMessage(obj: any, transfers: any): void;

* @param {boolean} [progressiveDone]
* @param {string} [contentDispositionFilename]
*/
constructor(length: number, initialData: Uint8Array, progressiveDone?: boolean | undefined);
constructor(length: number, initialData: Uint8Array, progressiveDone?: boolean | undefined, contentDispositionFilename?: string | undefined);
length: number;
initialData: Uint8Array;
progressiveDone: boolean;
contentDispositionFilename: string;
_rangeListeners: any[];

@@ -616,2 +638,6 @@ _progressListeners: any[];

/**
* @type {boolean} True if only XFA form.
*/
get isPureXfa(): boolean;
/**
* @param {number} pageNumber - The page number to get. The first page is 1.

@@ -716,18 +742,3 @@ * @returns {Promise<PDFPageProxy>} A promise that is resolved with

*/
getOutline(): Promise<{
title: string;
bold: boolean;
italic: boolean;
/**
* - The color in RGB format to use for
* display purposes.
*/
color: Uint8ClampedArray;
dest: string | Array<any> | null;
url: string | null;
unsafeUrl: string | undefined;
newWindow: boolean | undefined;
count: number | undefined;
items: any[];
}[]>;
getOutline(): Promise<Array<OutlineNode>>;
/**

@@ -768,7 +779,3 @@ * @returns {Promise<OptionalContentConfig>} A promise that is resolved with

*/
getMarkInfo(): Promise<{
Marked: boolean;
UserProperties: boolean;
Suspects: boolean;
} | null>;
getMarkInfo(): Promise<MarkInfo | null>;
/**

@@ -788,2 +795,11 @@ * @returns {Promise<TypedArray>} A promise that is resolved with a

/**
* @typedef {Object} PDFDocumentStats
* @property {Object<string, boolean>} streamTypes - Used stream types in the
* document (an item is set to true if specific stream ID was used in the
* document).
* @property {Object<string, boolean>} fontTypes - Used font types in the
* document (an item is set to true if specific font ID was used in the
* document).
*/
/**
* @returns {Promise<PDFDocumentStats>} A promise this is resolved with

@@ -801,5 +817,8 @@ * current statistics about document structures (see

*
* @param {boolean} [keepLoadedFonts] - Let fonts remain attached to the DOM.
* NOTE: This will increase persistent memory usage, hence don't use this
* option unless absolutely necessary. The default value is `false`.
* @returns {Promise} A promise that is resolved when clean-up has finished.
*/
cleanup(): Promise<any>;
cleanup(keepLoadedFonts?: boolean | undefined): Promise<any>;
/**

@@ -995,4 +1014,4 @@ * Destroys the current document instance and terminates the worker.

getAnnotations({ intent }?: GetAnnotationsParameters): Promise<Array<any>>;
annotationsPromise: any;
annotationsIntent: string | undefined;
_annotationsPromise: any;
_annotationsIntent: string | undefined;
/**

@@ -1004,2 +1023,9 @@ * @returns {Promise<Object>} A promise that is resolved with an

/**
* @returns {Promise<Object | null>} A promise that is resolved with
* an {Object} with a fake DOM object (a tree structure where elements
* are {Object} with a name, attributes (class, style, ...), value and
* children, very similar to a HTML DOM tree), or `null` if no XFA exists.
*/
getXfa(): Promise<Object | null>;
/**
* Begins the process of rendering a page to the desired context.

@@ -1034,2 +1060,3 @@ *

_jsActionsPromise: any;
_xfaPromise: any;
/**

@@ -1036,0 +1063,0 @@ * Cleans up resources allocated by the page.

@@ -105,6 +105,2 @@ export type ExternalLinkParameters = any;

export class DOMCMapReaderFactory extends BaseCMapReaderFactory {
constructor({ baseUrl, isCompressed }: {
baseUrl?: any;
isCompressed?: boolean | undefined;
});
}

@@ -116,7 +112,18 @@ export class DOMSVGFactory {

/**
* Gets the file name from a given URL.
* Gets the filename from a given URL.
* @param {string} url
* @returns {string}
*/
export function getFilenameFromUrl(url: string): string;
/**
* Returns the filename or guessed filename from the url (see issue 3455).
* @param {string} url - The original PDF location.
* @param {string} defaultFilename - The value returned if the filename is
* unknown, or the protocol is unsupported.
* @returns {string} Guessed PDF filename.
*/
export function getPdfFilenameFromUrl(url: string, defaultFilename?: string): string;
export function isDataScheme(url: any): boolean;
export function isFetchSupported(): boolean;
export function isPdfFile(filename: any): boolean;
export function isValidFetchUrl(url: any, baseUrl: any): boolean;

@@ -123,0 +130,0 @@ export namespace LinkTarget {

/** @implements {IPDFStream} */
export class PDFFetchStream {
export class PDFFetchStream implements IPDFStream {
constructor(source: any);

@@ -15,3 +15,3 @@ source: any;

/** @implements {IPDFStreamReader} */
declare class PDFFetchStreamReader {
declare class PDFFetchStreamReader implements IPDFStreamReader {
constructor(stream: any);

@@ -47,3 +47,3 @@ _stream: any;

/** @implements {IPDFStreamRangeReader} */
declare class PDFFetchStreamRangeReader {
declare class PDFFetchStreamRangeReader implements IPDFStreamRangeReader {
constructor(stream: any, begin: any, end: any);

@@ -50,0 +50,0 @@ _stream: any;

@@ -6,3 +6,3 @@ export class FontFaceObject {

ignoreErrors?: boolean | undefined;
onUnsupportedFeature?: any;
onUnsupportedFeature: any;
fontRegistry?: any;

@@ -9,0 +9,0 @@ });

export class Metadata {
constructor(data: any);
_metadataMap: Map<any, any>;
constructor({ parsedData, rawData }: {
parsedData: any;
rawData: any;
});
_metadataMap: any;
_data: any;
_repair(data: any): any;
_getSequence(entry: any): any;
_getCreators(entry: any): boolean;
_parse(xmlDocument: any): void;
getRaw(): any;
get(name: any): any;
getAll(): any;
has(name: any): boolean;
has(name: any): any;
}
/** @implements {IPDFStream} */
export class PDFNetworkStream {
export class PDFNetworkStream implements IPDFStream {
constructor(source: any);

@@ -33,3 +33,3 @@ _source: any;

/** @implements {IPDFStreamReader} */
declare class PDFNetworkStreamFullRequestReader {
declare class PDFNetworkStreamFullRequestReader implements IPDFStreamReader {
constructor(manager: any, source: any);

@@ -65,3 +65,3 @@ _manager: any;

/** @implements {IPDFStreamRangeReader} */
declare class PDFNetworkStreamRangeRequestReader {
declare class PDFNetworkStreamRangeRequestReader implements IPDFStreamRangeReader {
constructor(manager: any, begin: any, end: any);

@@ -68,0 +68,0 @@ _manager: any;

@@ -16,6 +16,4 @@ export class PDFNodeStream {

declare class PDFNodeStreamFsFullReader extends BaseFullReader {
constructor(stream: any);
}
declare class PDFNodeStreamFullReader extends BaseFullReader {
constructor(stream: any);
_request: any;

@@ -22,0 +20,0 @@ }

@@ -9,3 +9,3 @@ /**

*/
textContent?: import("./api.js").TextContent | undefined;
textContent?: import("./api").TextContent | undefined;
/**

@@ -12,0 +12,0 @@ * - Text content stream to

/** @implements {IPDFStream} */
export class PDFDataTransportStream {
export class PDFDataTransportStream implements IPDFStream {
constructor(params: any, pdfDataRangeTransport: any);
_queuedChunks: ArrayBuffer[];
_progressiveDone: any;
_contentDispositionFilename: any;
_pdfDataRangeTransport: any;

@@ -22,4 +23,4 @@ _isStreamingSupported: boolean;

/** @implements {IPDFStreamReader} */
declare class PDFDataTransportStreamReader {
constructor(stream: any, queuedChunks: any, progressiveDone?: boolean);
declare class PDFDataTransportStreamReader implements IPDFStreamReader {
constructor(stream: any, queuedChunks: any, progressiveDone?: boolean, contentDispositionFilename?: any);
_stream: any;

@@ -44,3 +45,3 @@ _done: boolean;

/** @implements {IPDFStreamRangeReader} */
declare class PDFDataTransportStreamRangeReader {
declare class PDFDataTransportStreamRangeReader implements IPDFStreamRangeReader {
constructor(stream: any, begin: any, end: any);

@@ -47,0 +48,0 @@ _stream: any;

import { addLinkAttributes } from "./display/display_utils.js";
import { getFilenameFromUrl } from "./display/display_utils.js";
import { getPdfFilenameFromUrl } from "./display/display_utils.js";
import { isPdfFile } from "./display/display_utils.js";
import { LinkTarget } from "./display/display_utils.js";

@@ -33,2 +35,3 @@ import { loadScript } from "./display/display_utils.js";

import { SVGGraphics } from "./display/svg.js";
export { addLinkAttributes, getFilenameFromUrl, LinkTarget, loadScript, PDFDateString, RenderingCancelledException, build, getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker, version, CMapCompressionType, createObjectURL, createPromiseCapability, createValidAbsoluteUrl, InvalidPDFException, MissingPDFException, OPS, PasswordResponses, PermissionFlag, removeNullCharacters, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, Util, VerbosityLevel, AnnotationLayer, apiCompatibilityParams, GlobalWorkerOptions, renderTextLayer, SVGGraphics };
import { XfaLayer } from "./display/xfa_layer.js";
export { addLinkAttributes, getFilenameFromUrl, getPdfFilenameFromUrl, isPdfFile, LinkTarget, loadScript, PDFDateString, RenderingCancelledException, build, getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker, version, CMapCompressionType, createObjectURL, createPromiseCapability, createValidAbsoluteUrl, InvalidPDFException, MissingPDFException, OPS, PasswordResponses, PermissionFlag, removeNullCharacters, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, Util, VerbosityLevel, AnnotationLayer, apiCompatibilityParams, GlobalWorkerOptions, renderTextLayer, SVGGraphics, XfaLayer };

@@ -160,3 +160,3 @@ /**

}
export function createObjectURL(data: any, contentType: any, forceDataSchema?: boolean): string;
export function createObjectURL(data: any, contentType?: string, forceDataSchema?: boolean): string;
/**

@@ -193,3 +193,2 @@ * Promise Capability object.

}
export function encodeToXmlString(str: any): any;
export function escapeString(str: any): any;

@@ -231,3 +230,3 @@ export const FONT_IDENTITY_MATRIX: number[];

export function isArrayBuffer(v: any): boolean;
export function isArrayEqual(arr1: any, arr2: any): any;
export function isArrayEqual(arr1: any, arr2: any): boolean;
export function isAscii(str: any): boolean;

@@ -244,3 +243,3 @@ export function isBool(v: any): boolean;

}
export function objectFromEntries(iterable: any): any;
export function objectFromMap(map: any): any;
export function objectSize(obj: any): number;

@@ -247,0 +246,0 @@ export namespace OPS {

@@ -1,2 +0,2 @@

/* Copyright 2020 Mozilla Foundation
/* Copyright 2021 Mozilla Foundation
*

@@ -18,4 +18,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var pdfjs = require("./build/pdf.js");
var PdfjsWorker = require("worker-loader?esModule=false&filename=[name].js!./build/pdf.worker.js");
const pdfjs = require("./build/pdf.js");
const PdfjsWorker = require("worker-loader?esModule=false&filename=[name].js!./build/pdf.worker.js");

@@ -22,0 +22,0 @@ if (typeof window !== "undefined" && "Worker" in window) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc