pdfjs-dist
Advanced tools
Comparing version 2.12.313 to 2.13.216
{ | ||
"name": "pdfjs-dist", | ||
"version": "2.12.313", | ||
"version": "2.13.216", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "build/pdf.js", |
@@ -1,2 +0,2 @@ | ||
/* Copyright 2021 Mozilla Foundation | ||
/* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -3,0 +3,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -1,2 +0,2 @@ | ||
/* Copyright 2021 Mozilla Foundation | ||
/* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -3,0 +3,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -30,4 +30,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _primitives = require("./primitives.js"); | ||
var _core_utils = require("./core_utils.js"); | ||
@@ -37,2 +35,4 @@ | ||
var _primitives = require("./primitives.js"); | ||
var _name_number_tree = require("./name_number_tree.js"); | ||
@@ -42,2 +42,4 @@ | ||
var _cleanup_helper = require("./cleanup_helper.js"); | ||
var _colorspace = require("./colorspace.js"); | ||
@@ -106,3 +108,3 @@ | ||
if ((0, _primitives.isDict)(obj) && obj.size > 0) { | ||
if (obj instanceof _primitives.Dict && obj.size > 0) { | ||
collection = obj; | ||
@@ -127,3 +129,3 @@ } | ||
if ((0, _primitives.isDict)(obj) && obj.size > 0) { | ||
if (obj instanceof _primitives.Dict && obj.size > 0) { | ||
acroForm = obj; | ||
@@ -145,3 +147,3 @@ } | ||
return (0, _util.shadow)(this, "acroFormRef", (0, _primitives.isRef)(value) ? value : null); | ||
return (0, _util.shadow)(this, "acroFormRef", value instanceof _primitives.Ref ? value : null); | ||
} | ||
@@ -204,3 +206,3 @@ | ||
if (!(0, _primitives.isDict)(obj)) { | ||
if (!(obj instanceof _primitives.Dict)) { | ||
return null; | ||
@@ -222,3 +224,3 @@ } | ||
if (!(0, _util.isBool)(value)) { | ||
if (typeof value !== "boolean") { | ||
continue; | ||
@@ -252,3 +254,3 @@ } | ||
if (!(0, _primitives.isDict)(obj)) { | ||
if (!(obj instanceof _primitives.Dict)) { | ||
return null; | ||
@@ -265,3 +267,3 @@ } | ||
if (!(0, _primitives.isDict)(pagesObj)) { | ||
if (!(pagesObj instanceof _primitives.Dict)) { | ||
throw new _util.FormatError("Invalid top-level pages dictionary."); | ||
@@ -292,3 +294,3 @@ } | ||
if (!(0, _primitives.isDict)(obj)) { | ||
if (!(obj instanceof _primitives.Dict)) { | ||
return null; | ||
@@ -299,3 +301,3 @@ } | ||
if (!(0, _primitives.isRef)(obj)) { | ||
if (!(obj instanceof _primitives.Ref)) { | ||
return null; | ||
@@ -362,3 +364,3 @@ } | ||
if ((0, _primitives.isRef)(obj) && !processed.has(obj)) { | ||
if (obj instanceof _primitives.Ref && !processed.has(obj)) { | ||
queue.push({ | ||
@@ -373,3 +375,3 @@ obj, | ||
if ((0, _primitives.isRef)(obj) && !processed.has(obj)) { | ||
if (obj instanceof _primitives.Ref && !processed.has(obj)) { | ||
queue.push({ | ||
@@ -405,3 +407,3 @@ obj, | ||
if (!(0, _primitives.isDict)(encrypt)) { | ||
if (!(encrypt instanceof _primitives.Dict)) { | ||
return null; | ||
@@ -412,3 +414,3 @@ } | ||
if (!(0, _util.isNum)(flags)) { | ||
if (typeof flags !== "number") { | ||
return null; | ||
@@ -457,3 +459,3 @@ } | ||
for (const groupRef of groupsData) { | ||
if (!(0, _primitives.isRef)(groupRef)) { | ||
if (!(groupRef instanceof _primitives.Ref)) { | ||
continue; | ||
@@ -466,4 +468,4 @@ } | ||
id: groupRef.toString(), | ||
name: (0, _util.isString)(group.get("Name")) ? (0, _util.stringToPDFString)(group.get("Name")) : null, | ||
intent: (0, _util.isString)(group.get("Intent")) ? (0, _util.stringToPDFString)(group.get("Intent")) : null | ||
name: typeof group.get("Name") === "string" ? (0, _util.stringToPDFString)(group.get("Name")) : null, | ||
intent: typeof group.get("Intent") === "string" ? (0, _util.stringToPDFString)(group.get("Intent")) : null | ||
}); | ||
@@ -491,3 +493,3 @@ } | ||
for (const value of refs) { | ||
if (!(0, _primitives.isRef)(value)) { | ||
if (!(value instanceof _primitives.Ref)) { | ||
continue; | ||
@@ -513,3 +515,3 @@ } | ||
for (const value of refs) { | ||
if ((0, _primitives.isRef)(value) && contentGroupRefs.includes(value)) { | ||
if (value instanceof _primitives.Ref && contentGroupRefs.includes(value)) { | ||
parsedOrderRefs.put(value); | ||
@@ -585,5 +587,5 @@ order.push(value.toString()); | ||
return { | ||
name: (0, _util.isString)(config.get("Name")) ? (0, _util.stringToPDFString)(config.get("Name")) : null, | ||
creator: (0, _util.isString)(config.get("Creator")) ? (0, _util.stringToPDFString)(config.get("Creator")) : null, | ||
baseState: (0, _primitives.isName)(config.get("BaseState")) ? config.get("BaseState").name : null, | ||
name: typeof config.get("Name") === "string" ? (0, _util.stringToPDFString)(config.get("Name")) : null, | ||
creator: typeof config.get("Creator") === "string" ? (0, _util.stringToPDFString)(config.get("Creator")) : null, | ||
baseState: config.get("BaseState") instanceof _primitives.Name ? config.get("BaseState").name : null, | ||
on: parseOnOff(config.get("ON")), | ||
@@ -717,3 +719,3 @@ off: parseOnOff(config.get("OFF")), | ||
if (labelDict !== undefined) { | ||
if (!(0, _primitives.isDict)(labelDict)) { | ||
if (!(labelDict instanceof _primitives.Dict)) { | ||
throw new _util.FormatError("PageLabel is not a dictionary."); | ||
@@ -729,3 +731,3 @@ } | ||
if (!(0, _primitives.isName)(s)) { | ||
if (!(s instanceof _primitives.Name)) { | ||
throw new _util.FormatError("Invalid style in PageLabel dictionary."); | ||
@@ -742,3 +744,3 @@ } | ||
if (!(0, _util.isString)(p)) { | ||
if (typeof p !== "string") { | ||
throw new _util.FormatError("Invalid prefix in PageLabel dictionary."); | ||
@@ -812,3 +814,3 @@ } | ||
if ((0, _primitives.isName)(obj)) { | ||
if (obj instanceof _primitives.Name) { | ||
switch (obj.name) { | ||
@@ -833,3 +835,3 @@ case "SinglePage": | ||
if ((0, _primitives.isName)(obj)) { | ||
if (obj instanceof _primitives.Name) { | ||
switch (obj.name) { | ||
@@ -850,43 +852,30 @@ case "UseNone": | ||
get viewerPreferences() { | ||
const ViewerPreferencesValidators = { | ||
HideToolbar: _util.isBool, | ||
HideMenubar: _util.isBool, | ||
HideWindowUI: _util.isBool, | ||
FitWindow: _util.isBool, | ||
CenterWindow: _util.isBool, | ||
DisplayDocTitle: _util.isBool, | ||
NonFullScreenPageMode: _primitives.isName, | ||
Direction: _primitives.isName, | ||
ViewArea: _primitives.isName, | ||
ViewClip: _primitives.isName, | ||
PrintArea: _primitives.isName, | ||
PrintClip: _primitives.isName, | ||
PrintScaling: _primitives.isName, | ||
Duplex: _primitives.isName, | ||
PickTrayByPDFSize: _util.isBool, | ||
PrintPageRange: Array.isArray, | ||
NumCopies: Number.isInteger | ||
}; | ||
const obj = this._catDict.get("ViewerPreferences"); | ||
if (!(obj instanceof _primitives.Dict)) { | ||
return (0, _util.shadow)(this, "viewerPreferences", null); | ||
} | ||
let prefs = null; | ||
if ((0, _primitives.isDict)(obj)) { | ||
for (const key in ViewerPreferencesValidators) { | ||
if (!obj.has(key)) { | ||
continue; | ||
} | ||
for (const key of obj.getKeys()) { | ||
const value = obj.get(key); | ||
let prefValue; | ||
const value = obj.get(key); | ||
switch (key) { | ||
case "HideToolbar": | ||
case "HideMenubar": | ||
case "HideWindowUI": | ||
case "FitWindow": | ||
case "CenterWindow": | ||
case "DisplayDocTitle": | ||
case "PickTrayByPDFSize": | ||
if (typeof value === "boolean") { | ||
prefValue = value; | ||
} | ||
if (!ViewerPreferencesValidators[key](value)) { | ||
(0, _util.info)(`Bad value in ViewerPreferences for "${key}".`); | ||
continue; | ||
} | ||
break; | ||
let prefValue; | ||
switch (key) { | ||
case "NonFullScreenPageMode": | ||
case "NonFullScreenPageMode": | ||
if (value instanceof _primitives.Name) { | ||
switch (value.name) { | ||
@@ -903,6 +892,8 @@ case "UseNone": | ||
} | ||
} | ||
break; | ||
break; | ||
case "Direction": | ||
case "Direction": | ||
if (value instanceof _primitives.Name) { | ||
switch (value.name) { | ||
@@ -917,9 +908,11 @@ case "L2R": | ||
} | ||
} | ||
break; | ||
break; | ||
case "ViewArea": | ||
case "ViewClip": | ||
case "PrintArea": | ||
case "PrintClip": | ||
case "ViewArea": | ||
case "ViewClip": | ||
case "PrintArea": | ||
case "PrintClip": | ||
if (value instanceof _primitives.Name) { | ||
switch (value.name) { | ||
@@ -937,6 +930,8 @@ case "MediaBox": | ||
} | ||
} | ||
break; | ||
break; | ||
case "PrintScaling": | ||
case "PrintScaling": | ||
if (value instanceof _primitives.Name) { | ||
switch (value.name) { | ||
@@ -951,6 +946,8 @@ case "None": | ||
} | ||
} | ||
break; | ||
break; | ||
case "Duplex": | ||
case "Duplex": | ||
if (value instanceof _primitives.Name) { | ||
switch (value.name) { | ||
@@ -966,12 +963,8 @@ case "Simplex": | ||
} | ||
} | ||
break; | ||
break; | ||
case "PrintPageRange": | ||
const length = value.length; | ||
if (length % 2 !== 0) { | ||
break; | ||
} | ||
case "PrintPageRange": | ||
if (Array.isArray(value) && value.length % 2 === 0) { | ||
const isValid = value.every((page, i, arr) => { | ||
@@ -984,30 +977,28 @@ return Number.isInteger(page) && page > 0 && (i === 0 || page >= arr[i - 1]) && page <= this.numPages; | ||
} | ||
} | ||
break; | ||
break; | ||
case "NumCopies": | ||
if (value > 0) { | ||
prefValue = value; | ||
} | ||
case "NumCopies": | ||
if (Number.isInteger(value) && value > 0) { | ||
prefValue = value; | ||
} | ||
break; | ||
break; | ||
default: | ||
if (typeof value !== "boolean") { | ||
throw new _util.FormatError(`viewerPreferences - expected a boolean value for: ${key}`); | ||
} | ||
default: | ||
(0, _util.warn)(`Ignoring non-standard key in ViewerPreferences: ${key}.`); | ||
continue; | ||
} | ||
prefValue = value; | ||
} | ||
if (prefValue === undefined) { | ||
(0, _util.warn)(`Bad value, for key "${key}", in ViewerPreferences: ${value}.`); | ||
continue; | ||
} | ||
if (prefValue !== undefined) { | ||
if (!prefs) { | ||
prefs = Object.create(null); | ||
} | ||
if (!prefs) { | ||
prefs = Object.create(null); | ||
} | ||
prefs[key] = prefValue; | ||
} else { | ||
(0, _util.info)(`Bad value in ViewerPreferences for "${key}".`); | ||
} | ||
} | ||
prefs[key] = prefValue; | ||
} | ||
@@ -1023,3 +1014,3 @@ | ||
if ((0, _primitives.isDict)(obj)) { | ||
if (obj instanceof _primitives.Dict) { | ||
const destDict = new _primitives.Dict(this.xref); | ||
@@ -1107,3 +1098,3 @@ destDict.set("A", obj); | ||
if ((0, _primitives.isStream)(js)) { | ||
if (js instanceof _base_stream.BaseStream) { | ||
js = js.getString(); | ||
@@ -1182,3 +1173,3 @@ } else if (typeof js !== "string") { | ||
cleanup(manuallyTriggered = false) { | ||
(0, _primitives.clearPrimitiveCaches)(); | ||
(0, _cleanup_helper.clearGlobalCaches)(); | ||
this.globalImageCache.clear(manuallyTriggered); | ||
@@ -1205,4 +1196,3 @@ this.pageKidsCountCache.clear(); | ||
getPageDict(pageIndex) { | ||
const capability = (0, _util.createPromiseCapability)(); | ||
async getPageDict(pageIndex) { | ||
const nodesToVisit = [this.toplevelPagesDict]; | ||
@@ -1218,121 +1208,111 @@ const visitedNodes = new _primitives.RefSet(); | ||
const xref = this.xref, | ||
pageKidsCountCache = this.pageKidsCountCache; | ||
pageKidsCountCache = this.pageKidsCountCache, | ||
pageIndexCache = this.pageIndexCache; | ||
let currentPageIndex = 0; | ||
function next() { | ||
while (nodesToVisit.length) { | ||
const currentNode = nodesToVisit.pop(); | ||
while (nodesToVisit.length) { | ||
const currentNode = nodesToVisit.pop(); | ||
if (currentNode instanceof _primitives.Ref) { | ||
const count = pageKidsCountCache.get(currentNode); | ||
if (currentNode instanceof _primitives.Ref) { | ||
const count = pageKidsCountCache.get(currentNode); | ||
if (count >= 0 && currentPageIndex + count <= pageIndex) { | ||
currentPageIndex += count; | ||
continue; | ||
} | ||
if (count >= 0 && currentPageIndex + count <= pageIndex) { | ||
currentPageIndex += count; | ||
continue; | ||
} | ||
if (visitedNodes.has(currentNode)) { | ||
capability.reject(new _util.FormatError("Pages tree contains circular reference.")); | ||
return; | ||
if (visitedNodes.has(currentNode)) { | ||
throw new _util.FormatError("Pages tree contains circular reference."); | ||
} | ||
visitedNodes.put(currentNode); | ||
const obj = await xref.fetchAsync(currentNode); | ||
if (obj instanceof _primitives.Dict) { | ||
let type = obj.getRaw("Type"); | ||
if (type instanceof _primitives.Ref) { | ||
type = await xref.fetchAsync(type); | ||
} | ||
visitedNodes.put(currentNode); | ||
xref.fetchAsync(currentNode).then(function (obj) { | ||
if ((0, _primitives.isDict)(obj, "Page") || (0, _primitives.isDict)(obj) && !obj.has("Kids")) { | ||
if (currentNode && !pageKidsCountCache.has(currentNode)) { | ||
pageKidsCountCache.put(currentNode, 1); | ||
} | ||
if ((0, _primitives.isName)(type, "Page") || !obj.has("Kids")) { | ||
if (!pageKidsCountCache.has(currentNode)) { | ||
pageKidsCountCache.put(currentNode, 1); | ||
} | ||
if (pageIndex === currentPageIndex) { | ||
capability.resolve([obj, currentNode]); | ||
} else { | ||
currentPageIndex++; | ||
next(); | ||
} | ||
if (!pageIndexCache.has(currentNode)) { | ||
pageIndexCache.put(currentNode, currentPageIndex); | ||
} | ||
return; | ||
if (currentPageIndex === pageIndex) { | ||
return [obj, currentNode]; | ||
} | ||
nodesToVisit.push(obj); | ||
next(); | ||
}, capability.reject); | ||
return; | ||
currentPageIndex++; | ||
continue; | ||
} | ||
} | ||
if (!(currentNode instanceof _primitives.Dict)) { | ||
capability.reject(new _util.FormatError("Page dictionary kid reference points to wrong type of object.")); | ||
return; | ||
} | ||
nodesToVisit.push(obj); | ||
continue; | ||
} | ||
let count; | ||
if (!(currentNode instanceof _primitives.Dict)) { | ||
throw new _util.FormatError("Page dictionary kid reference points to wrong type of object."); | ||
} | ||
try { | ||
count = currentNode.get("Count"); | ||
} catch (ex) { | ||
if (ex instanceof _core_utils.MissingDataException) { | ||
throw ex; | ||
} | ||
} | ||
const { | ||
objId | ||
} = currentNode; | ||
let count = currentNode.getRaw("Count"); | ||
if (Number.isInteger(count) && count >= 0) { | ||
const objId = currentNode.objId; | ||
if (count instanceof _primitives.Ref) { | ||
count = await xref.fetchAsync(count); | ||
} | ||
if (objId && !pageKidsCountCache.has(objId)) { | ||
pageKidsCountCache.put(objId, count); | ||
} | ||
if (Number.isInteger(count) && count >= 0) { | ||
if (objId && !pageKidsCountCache.has(objId)) { | ||
pageKidsCountCache.put(objId, count); | ||
} | ||
if (currentPageIndex + count <= pageIndex) { | ||
currentPageIndex += count; | ||
continue; | ||
} | ||
if (currentPageIndex + count <= pageIndex) { | ||
currentPageIndex += count; | ||
continue; | ||
} | ||
} | ||
let kids; | ||
let kids = currentNode.getRaw("Kids"); | ||
try { | ||
kids = currentNode.get("Kids"); | ||
} catch (ex) { | ||
if (ex instanceof _core_utils.MissingDataException) { | ||
throw ex; | ||
} | ||
} | ||
if (kids instanceof _primitives.Ref) { | ||
kids = await xref.fetchAsync(kids); | ||
} | ||
if (!Array.isArray(kids)) { | ||
let type; | ||
if (!Array.isArray(kids)) { | ||
let type = currentNode.getRaw("Type"); | ||
try { | ||
type = currentNode.get("Type"); | ||
} catch (ex) { | ||
if (ex instanceof _core_utils.MissingDataException) { | ||
throw ex; | ||
} | ||
} | ||
if (type instanceof _primitives.Ref) { | ||
type = await xref.fetchAsync(type); | ||
} | ||
if ((0, _primitives.isName)(type, "Page") || !currentNode.has("Type") && currentNode.has("Contents")) { | ||
if (currentPageIndex === pageIndex) { | ||
capability.resolve([currentNode, null]); | ||
return; | ||
} | ||
currentPageIndex++; | ||
continue; | ||
if ((0, _primitives.isName)(type, "Page") || !currentNode.has("Kids")) { | ||
if (currentPageIndex === pageIndex) { | ||
return [currentNode, null]; | ||
} | ||
capability.reject(new _util.FormatError("Page dictionary kids object is not an array.")); | ||
return; | ||
currentPageIndex++; | ||
continue; | ||
} | ||
for (let last = kids.length - 1; last >= 0; last--) { | ||
nodesToVisit.push(kids[last]); | ||
} | ||
throw new _util.FormatError("Page dictionary kids object is not an array."); | ||
} | ||
capability.reject(new Error(`Page index ${pageIndex} not found.`)); | ||
for (let last = kids.length - 1; last >= 0; last--) { | ||
nodesToVisit.push(kids[last]); | ||
} | ||
} | ||
next(); | ||
return capability.promise; | ||
throw new Error(`Page index ${pageIndex} not found.`); | ||
} | ||
getAllPageDicts(recoveryMode = false) { | ||
async getAllPageDicts(recoveryMode = false) { | ||
const queue = [{ | ||
@@ -1350,6 +1330,12 @@ currentNode: this.toplevelPagesDict, | ||
const map = new Map(); | ||
const map = new Map(), | ||
xref = this.xref, | ||
pageIndexCache = this.pageIndexCache; | ||
let pageIndex = 0; | ||
function addPageDict(pageDict, pageRef) { | ||
if (pageRef && !pageIndexCache.has(pageRef)) { | ||
pageIndexCache.put(pageRef, pageIndex); | ||
} | ||
map.set(pageIndex++, [pageDict, pageRef]); | ||
@@ -1359,2 +1345,6 @@ } | ||
function addPageError(error) { | ||
if (error instanceof _core_utils.XRefEntryException && !recoveryMode) { | ||
throw error; | ||
} | ||
map.set(pageIndex++, [error, null]); | ||
@@ -1369,17 +1359,11 @@ } | ||
} = queueItem; | ||
let kids; | ||
let kids = currentNode.getRaw("Kids"); | ||
try { | ||
kids = currentNode.get("Kids"); | ||
} catch (ex) { | ||
if (ex instanceof _core_utils.MissingDataException) { | ||
throw ex; | ||
if (kids instanceof _primitives.Ref) { | ||
try { | ||
kids = await xref.fetchAsync(kids); | ||
} catch (ex) { | ||
addPageError(ex); | ||
break; | ||
} | ||
if (ex instanceof _core_utils.XRefEntryException && !recoveryMode) { | ||
throw ex; | ||
} | ||
addPageError(ex); | ||
break; | ||
} | ||
@@ -1401,17 +1385,2 @@ | ||
if (kidObj instanceof _primitives.Ref) { | ||
try { | ||
obj = this.xref.fetch(kidObj); | ||
} catch (ex) { | ||
if (ex instanceof _core_utils.MissingDataException) { | ||
throw ex; | ||
} | ||
if (ex instanceof _core_utils.XRefEntryException && !recoveryMode) { | ||
throw ex; | ||
} | ||
addPageError(ex); | ||
break; | ||
} | ||
if (visitedNodes.has(kidObj)) { | ||
@@ -1423,2 +1392,9 @@ addPageError(new _util.FormatError("Pages tree contains circular reference.")); | ||
visitedNodes.put(kidObj); | ||
try { | ||
obj = await xref.fetchAsync(kidObj); | ||
} catch (ex) { | ||
addPageError(ex); | ||
break; | ||
} | ||
} else { | ||
@@ -1433,3 +1409,14 @@ obj = kidObj; | ||
if ((0, _primitives.isDict)(obj, "Page") || !obj.has("Kids")) { | ||
let type = obj.getRaw("Type"); | ||
if (type instanceof _primitives.Ref) { | ||
try { | ||
type = await xref.fetchAsync(type); | ||
} catch (ex) { | ||
addPageError(ex); | ||
break; | ||
} | ||
} | ||
if ((0, _primitives.isName)(type, "Page") || !obj.has("Kids")) { | ||
addPageDict(obj, kidObj instanceof _primitives.Ref ? kidObj : null); | ||
@@ -1462,3 +1449,3 @@ } else { | ||
return xref.fetchAsync(kidRef).then(function (node) { | ||
if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, "Page") && !((0, _primitives.isDict)(node) && !node.has("Type") && node.has("Contents"))) { | ||
if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, "Page") && !(node instanceof _primitives.Dict && !node.has("Type") && node.has("Contents"))) { | ||
throw new _util.FormatError("The reference does not point to a /Page dictionary."); | ||
@@ -1471,3 +1458,3 @@ } | ||
if (!(0, _primitives.isDict)(node)) { | ||
if (!(node instanceof _primitives.Dict)) { | ||
throw new _util.FormatError("Node must be a dictionary."); | ||
@@ -1483,3 +1470,3 @@ } | ||
if (!(0, _primitives.isDict)(parent)) { | ||
if (!(parent instanceof _primitives.Dict)) { | ||
throw new _util.FormatError("Parent must be a dictionary."); | ||
@@ -1500,3 +1487,3 @@ } | ||
if (!(0, _primitives.isRef)(kid)) { | ||
if (!(kid instanceof _primitives.Ref)) { | ||
throw new _util.FormatError("Kid must be a reference."); | ||
@@ -1511,3 +1498,3 @@ } | ||
kidPromises.push(xref.fetchAsync(kid).then(function (obj) { | ||
if (!(0, _primitives.isDict)(obj)) { | ||
if (!(obj instanceof _primitives.Dict)) { | ||
throw new _util.FormatError("Kid node must be a dictionary."); | ||
@@ -1553,3 +1540,3 @@ } | ||
if (!(0, _primitives.isDict)(destDict)) { | ||
if (!(destDict instanceof _primitives.Dict)) { | ||
(0, _util.warn)("parseDestDictionary: `destDict` must be a dictionary."); | ||
@@ -1571,3 +1558,3 @@ return; | ||
if (!(0, _primitives.isDict)(action)) { | ||
if (!(action instanceof _primitives.Dict)) { | ||
if (destDict.has("Dest")) { | ||
@@ -1578,3 +1565,3 @@ action = destDict.get("Dest"); | ||
if ((0, _primitives.isDict)(action)) { | ||
if (action instanceof _primitives.Dict) { | ||
if (action.has("D")) { | ||
@@ -1589,6 +1576,6 @@ action = action.get("D"); | ||
if ((0, _primitives.isDict)(action)) { | ||
if (action instanceof _primitives.Dict) { | ||
const actionType = action.get("S"); | ||
if (!(0, _primitives.isName)(actionType)) { | ||
if (!(actionType instanceof _primitives.Name)) { | ||
(0, _util.warn)("parseDestDictionary: Invalid type in Action dictionary."); | ||
@@ -1603,3 +1590,3 @@ return; | ||
const flags = action.get("Flags"); | ||
const include = (((0, _util.isNum)(flags) ? flags : 0) & 1) === 0; | ||
const include = ((typeof flags === "number" ? flags : 0) & 1) === 0; | ||
const fields = []; | ||
@@ -1609,5 +1596,5 @@ const refs = []; | ||
for (const obj of action.get("Fields") || []) { | ||
if ((0, _primitives.isRef)(obj)) { | ||
if (obj instanceof _primitives.Ref) { | ||
refs.push(obj.toString()); | ||
} else if ((0, _util.isString)(obj)) { | ||
} else if (typeof obj === "string") { | ||
fields.push((0, _util.stringToPDFString)(obj)); | ||
@@ -1641,5 +1628,5 @@ } | ||
if ((0, _primitives.isDict)(urlDict)) { | ||
if (urlDict instanceof _primitives.Dict) { | ||
url = urlDict.get("F") || null; | ||
} else if ((0, _util.isString)(urlDict)) { | ||
} else if (typeof urlDict === "string") { | ||
url = urlDict; | ||
@@ -1651,10 +1638,10 @@ } | ||
if (remoteDest) { | ||
if ((0, _primitives.isName)(remoteDest)) { | ||
if (remoteDest instanceof _primitives.Name) { | ||
remoteDest = remoteDest.name; | ||
} | ||
if ((0, _util.isString)(url)) { | ||
if (typeof url === "string") { | ||
const baseUrl = url.split("#")[0]; | ||
if ((0, _util.isString)(remoteDest)) { | ||
if (typeof remoteDest === "string") { | ||
url = baseUrl + "#" + remoteDest; | ||
@@ -1669,3 +1656,3 @@ } else if (Array.isArray(remoteDest)) { | ||
if ((0, _util.isBool)(newWindow)) { | ||
if (typeof newWindow === "boolean") { | ||
resultObj.newWindow = newWindow; | ||
@@ -1679,3 +1666,3 @@ } | ||
if ((0, _primitives.isName)(namedAction)) { | ||
if (namedAction instanceof _primitives.Name) { | ||
resultObj.action = namedAction.name; | ||
@@ -1690,5 +1677,5 @@ } | ||
if ((0, _primitives.isStream)(jsAction)) { | ||
if (jsAction instanceof _base_stream.BaseStream) { | ||
js = jsAction.getString(); | ||
} else if ((0, _util.isString)(jsAction)) { | ||
} else if (typeof jsAction === "string") { | ||
js = jsAction; | ||
@@ -1717,3 +1704,3 @@ } | ||
if ((0, _util.isString)(url)) { | ||
if (typeof url === "string") { | ||
const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl, { | ||
@@ -1732,7 +1719,7 @@ addDefaultProtocol: true, | ||
if (dest) { | ||
if ((0, _primitives.isName)(dest)) { | ||
if (dest instanceof _primitives.Name) { | ||
dest = dest.name; | ||
} | ||
if ((0, _util.isString)(dest) || Array.isArray(dest)) { | ||
if (typeof dest === "string" || Array.isArray(dest)) { | ||
resultObj.dest = dest; | ||
@@ -1739,0 +1726,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -30,4 +30,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _primitives = require("./primitives.js"); | ||
var _ccitt = require("./ccitt.js"); | ||
@@ -37,2 +35,4 @@ | ||
var _primitives = require("./primitives.js"); | ||
class CCITTFaxStream extends _decode_stream.DecodeStream { | ||
@@ -44,3 +44,3 @@ constructor(str, maybeLength, params) { | ||
if (!(0, _primitives.isDict)(params)) { | ||
if (!(params instanceof _primitives.Dict)) { | ||
params = _primitives.Dict.empty; | ||
@@ -47,0 +47,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -34,2 +34,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _parser = require("./parser.js"); | ||
@@ -627,3 +629,3 @@ | ||
function expectString(obj) { | ||
if (!(0, _util.isString)(obj)) { | ||
if (typeof obj !== "string") { | ||
throw new _util.FormatError("Malformed CMap: expected string."); | ||
@@ -679,3 +681,3 @@ } | ||
if (Number.isInteger(obj) || (0, _util.isString)(obj)) { | ||
if (Number.isInteger(obj) || typeof obj === "string") { | ||
const dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj; | ||
@@ -758,3 +760,3 @@ cMap.mapBfRange(low, high, dstLow); | ||
if (!(0, _util.isString)(obj)) { | ||
if (typeof obj !== "string") { | ||
break; | ||
@@ -766,3 +768,3 @@ } | ||
if (!(0, _util.isString)(obj)) { | ||
if (typeof obj !== "string") { | ||
break; | ||
@@ -789,3 +791,3 @@ } | ||
if ((0, _primitives.isName)(obj) && (0, _util.isString)(obj.name)) { | ||
if (obj instanceof _primitives.Name) { | ||
cMap.name = obj.name; | ||
@@ -804,3 +806,3 @@ } | ||
break; | ||
} else if ((0, _primitives.isName)(obj)) { | ||
} else if (obj instanceof _primitives.Name) { | ||
if (obj.name === "WMode") { | ||
@@ -813,3 +815,3 @@ parseWMode(cMap, lexer); | ||
previous = obj; | ||
} else if ((0, _primitives.isCmd)(obj)) { | ||
} else if (obj instanceof _primitives.Cmd) { | ||
switch (obj.cmd) { | ||
@@ -820,3 +822,3 @@ case "endcmap": | ||
case "usecmap": | ||
if ((0, _primitives.isName)(previous)) { | ||
if (previous instanceof _primitives.Name) { | ||
embeddedUseCMap = previous.name; | ||
@@ -931,5 +933,5 @@ } | ||
if ((0, _primitives.isName)(encoding)) { | ||
if (encoding instanceof _primitives.Name) { | ||
return createBuiltInCMap(encoding.name, fetchBuiltInCMap); | ||
} else if ((0, _primitives.isStream)(encoding)) { | ||
} else if (encoding instanceof _base_stream.BaseStream) { | ||
const parsedCMap = await parseCMap(new CMap(), new _parser.Lexer(encoding), fetchBuiltInCMap, useCMap); | ||
@@ -936,0 +938,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -34,2 +34,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _core_utils = require("./core_utils.js"); | ||
@@ -263,3 +265,3 @@ | ||
if ((0, _primitives.isName)(cs)) { | ||
if (cs instanceof _primitives.Name) { | ||
switch (cs.name) { | ||
@@ -282,10 +284,10 @@ case "G": | ||
default: | ||
if ((0, _primitives.isDict)(resources)) { | ||
if (resources instanceof _primitives.Dict) { | ||
const colorSpaces = resources.get("ColorSpace"); | ||
if ((0, _primitives.isDict)(colorSpaces)) { | ||
if (colorSpaces instanceof _primitives.Dict) { | ||
const resourcesCS = colorSpaces.get(cs.name); | ||
if (resourcesCS) { | ||
if ((0, _primitives.isName)(resourcesCS)) { | ||
if (resourcesCS instanceof _primitives.Name) { | ||
return this._parse(resourcesCS, xref, resources, pdfFunctionFactory); | ||
@@ -517,3 +519,3 @@ } | ||
if ((0, _primitives.isStream)(lookup)) { | ||
if (lookup instanceof _base_stream.BaseStream) { | ||
const bytes = lookup.getBytes(length); | ||
@@ -520,0 +522,0 @@ this.lookup.set(bytes); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -49,2 +49,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _base_stream = require("./base_stream.js"); | ||
function getLookupTableFactory(initializer) { | ||
@@ -304,3 +306,3 @@ let lookup; | ||
if ((0, _primitives.isRef)(entry)) { | ||
if (entry instanceof _primitives.Ref) { | ||
if (parents.has(entry)) { | ||
@@ -320,13 +322,13 @@ return; | ||
} else if (entry instanceof _primitives.Dict) { | ||
if ((0, _primitives.isName)(entry.get("S"), "JavaScript") && entry.has("JS")) { | ||
if ((0, _primitives.isName)(entry.get("S"), "JavaScript")) { | ||
const js = entry.get("JS"); | ||
let code; | ||
if ((0, _primitives.isStream)(js)) { | ||
if (js instanceof _base_stream.BaseStream) { | ||
code = js.getString(); | ||
} else { | ||
} else if (typeof js === "string") { | ||
code = js; | ||
} | ||
code = (0, _util.stringToPDFString)(code); | ||
code = code && (0, _util.stringToPDFString)(code); | ||
@@ -333,0 +335,0 @@ if (code) { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -1445,3 +1445,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
function buildCipherConstructor(cf, name, num, gen, key) { | ||
if (!(0, _primitives.isName)(name)) { | ||
if (!(name instanceof _primitives.Name)) { | ||
throw new _util.FormatError("Invalid crypt filter name."); | ||
@@ -1510,3 +1510,3 @@ } | ||
if ((0, _primitives.isDict)(cfDict) && (0, _primitives.isName)(streamCryptoName)) { | ||
if (cfDict instanceof _primitives.Dict && streamCryptoName instanceof _primitives.Name) { | ||
cfDict.suppressEncryption = true; | ||
@@ -1580,3 +1580,3 @@ const handlerDict = cfDict.get(streamCryptoName.name); | ||
if ((0, _primitives.isDict)(cf)) { | ||
if (cf instanceof _primitives.Dict) { | ||
cf.suppressEncryption = true; | ||
@@ -1583,0 +1583,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,6 +32,6 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _core_utils = require("./core_utils.js"); | ||
var _primitives = require("./primitives.js"); | ||
var _core_utils = require("./core_utils.js"); | ||
var _xfa_fonts = require("./xfa_fonts.js"); | ||
@@ -49,2 +49,4 @@ | ||
var _cleanup_helper = require("./cleanup_helper.js"); | ||
var _parser = require("./parser.js"); | ||
@@ -124,3 +126,3 @@ | ||
if (value.length === 1 || !(0, _primitives.isDict)(value[0])) { | ||
if (value.length === 1 || !(value[0] instanceof _primitives.Dict)) { | ||
return value[0]; | ||
@@ -172,3 +174,3 @@ } | ||
if (!(0, _util.isNum)(obj) || obj <= 0) { | ||
if (typeof obj !== "number" || obj <= 0) { | ||
obj = DEFAULT_USER_UNIT; | ||
@@ -369,3 +371,2 @@ } | ||
task, | ||
normalizeWhitespace, | ||
includeMarkedContent, | ||
@@ -394,6 +395,6 @@ sink, | ||
resources: this.resources, | ||
normalizeWhitespace, | ||
includeMarkedContent, | ||
combineTextItems, | ||
sink | ||
sink, | ||
viewBox: this.view | ||
}); | ||
@@ -534,3 +535,3 @@ }); | ||
if ((0, _primitives.isStream)(arg)) { | ||
if (arg instanceof _base_stream.BaseStream) { | ||
stream = arg; | ||
@@ -748,3 +749,3 @@ } else if ((0, _util.isArrayBuffer)(arg)) { | ||
if ((0, _primitives.isStream)(xfa) && !xfa.isEmpty) { | ||
if (xfa instanceof _base_stream.BaseStream && !xfa.isEmpty) { | ||
try { | ||
@@ -780,3 +781,3 @@ entries["xdp:xdp"] = (0, _util.stringToUTF8String)(xfa.getString()); | ||
if (!(0, _primitives.isStream)(data) || data.isEmpty) { | ||
if (!(data instanceof _base_stream.BaseStream) || data.isEmpty) { | ||
continue; | ||
@@ -829,7 +830,5 @@ } | ||
if (!(0, _primitives.isStream)(stream)) { | ||
continue; | ||
if (stream instanceof _base_stream.BaseStream) { | ||
xfaImages.set(key, stream.getBytes()); | ||
} | ||
xfaImages.set(key, stream.getBytes()); | ||
} | ||
@@ -1005,3 +1004,3 @@ | ||
const xfa = acroForm.get("XFA"); | ||
formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || (0, _primitives.isStream)(xfa) && !xfa.isEmpty; | ||
formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || xfa instanceof _base_stream.BaseStream && !xfa.isEmpty; | ||
const sigFlags = acroForm.get("SigFlags"); | ||
@@ -1026,13 +1025,2 @@ const hasSignatures = !!(sigFlags & 0x1); | ||
get documentInfo() { | ||
const DocumentInfoValidators = { | ||
Title: _util.isString, | ||
Author: _util.isString, | ||
Subject: _util.isString, | ||
Keywords: _util.isString, | ||
Creator: _util.isString, | ||
Producer: _util.isString, | ||
CreationDate: _util.isString, | ||
ModDate: _util.isString, | ||
Trapped: _primitives.isName | ||
}; | ||
let version = this._version; | ||
@@ -1067,21 +1055,56 @@ | ||
if ((0, _primitives.isDict)(infoDict)) { | ||
for (const key of infoDict.getKeys()) { | ||
const value = infoDict.get(key); | ||
if (!(infoDict instanceof _primitives.Dict)) { | ||
return (0, _util.shadow)(this, "documentInfo", docInfo); | ||
} | ||
if (DocumentInfoValidators[key]) { | ||
if (DocumentInfoValidators[key](value)) { | ||
docInfo[key] = typeof value !== "string" ? value : (0, _util.stringToPDFString)(value); | ||
} else { | ||
(0, _util.info)(`Bad value in document info for "${key}".`); | ||
for (const key of infoDict.getKeys()) { | ||
const value = infoDict.get(key); | ||
switch (key) { | ||
case "Title": | ||
case "Author": | ||
case "Subject": | ||
case "Keywords": | ||
case "Creator": | ||
case "Producer": | ||
case "CreationDate": | ||
case "ModDate": | ||
if (typeof value === "string") { | ||
docInfo[key] = (0, _util.stringToPDFString)(value); | ||
continue; | ||
} | ||
} else if (typeof key === "string") { | ||
break; | ||
case "Trapped": | ||
if (value instanceof _primitives.Name) { | ||
docInfo[key] = value; | ||
continue; | ||
} | ||
break; | ||
default: | ||
let customValue; | ||
if ((0, _util.isString)(value)) { | ||
customValue = (0, _util.stringToPDFString)(value); | ||
} else if ((0, _primitives.isName)(value) || (0, _util.isNum)(value) || (0, _util.isBool)(value)) { | ||
customValue = value; | ||
} else { | ||
(0, _util.info)(`Unsupported value in document info for (custom) "${key}".`); | ||
switch (typeof value) { | ||
case "string": | ||
customValue = (0, _util.stringToPDFString)(value); | ||
break; | ||
case "number": | ||
case "boolean": | ||
customValue = value; | ||
break; | ||
default: | ||
if (value instanceof _primitives.Name) { | ||
customValue = value; | ||
} | ||
break; | ||
} | ||
if (customValue === undefined) { | ||
(0, _util.warn)(`Bad value, for custom key "${key}", in Info: ${value}.`); | ||
continue; | ||
@@ -1095,4 +1118,6 @@ } | ||
docInfo.Custom[key] = customValue; | ||
} | ||
continue; | ||
} | ||
(0, _util.warn)(`Bad value, for key "${key}", in Info: ${value}.`); | ||
} | ||
@@ -1138,3 +1163,4 @@ | ||
catalog, | ||
linearization | ||
linearization, | ||
xref | ||
} = this; | ||
@@ -1145,10 +1171,22 @@ | ||
try { | ||
const obj = await this.xref.fetchAsync(ref); | ||
const obj = await xref.fetchAsync(ref); | ||
if ((0, _primitives.isDict)(obj, "Page") || (0, _primitives.isDict)(obj) && !obj.has("Type") && obj.has("Contents")) { | ||
if (ref && !catalog.pageKidsCountCache.has(ref)) { | ||
catalog.pageKidsCountCache.put(ref, 1); | ||
if (obj instanceof _primitives.Dict) { | ||
let type = obj.getRaw("Type"); | ||
if (type instanceof _primitives.Ref) { | ||
type = await xref.fetchAsync(type); | ||
} | ||
return [obj, ref]; | ||
if ((0, _primitives.isName)(type, "Page") || !obj.has("Type") && !obj.has("Kids")) { | ||
if (!catalog.pageKidsCountCache.has(ref)) { | ||
catalog.pageKidsCountCache.put(ref, 1); | ||
} | ||
if (!catalog.pageIndexCache.has(ref)) { | ||
catalog.pageIndexCache.put(ref, 0); | ||
} | ||
return [obj, ref]; | ||
} | ||
} | ||
@@ -1158,3 +1196,3 @@ | ||
} catch (reason) { | ||
(0, _util.info)(reason); | ||
(0, _util.warn)(`_getLinearizationPage: "${reason.message}".`); | ||
return catalog.getPageDict(pageIndex); | ||
@@ -1264,3 +1302,3 @@ } | ||
try { | ||
pagesTree = await pdfManager.ensureCatalog("getAllPageDicts", [recoveryMode]); | ||
pagesTree = await catalog.getAllPageDicts(recoveryMode); | ||
} catch (reasonAll) { | ||
@@ -1310,3 +1348,3 @@ if (reasonAll instanceof _core_utils.XRefEntryException && !recoveryMode) { | ||
async cleanup(manuallyTriggered = false) { | ||
return this.catalog ? this.catalog.cleanup(manuallyTriggered) : (0, _primitives.clearPrimitiveCaches)(); | ||
return this.catalog ? this.catalog.cleanup(manuallyTriggered) : (0, _cleanup_helper.clearGlobalCaches)(); | ||
} | ||
@@ -1404,4 +1442,10 @@ | ||
const ids = calculationOrder.filter(_primitives.isRef).map(ref => ref.toString()); | ||
const ids = []; | ||
for (const id of calculationOrder) { | ||
if (id instanceof _primitives.Ref) { | ||
ids.push(id.toString()); | ||
} | ||
} | ||
if (ids.length === 0) { | ||
@@ -1408,0 +1452,0 @@ return (0, _util.shadow)(this, "calculationOrderIds", null); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -30,6 +30,8 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _util = require("../shared/util.js"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _primitives = require("./primitives.js"); | ||
var _util = require("../shared/util.js"); | ||
function pickPlatformItem(dict) { | ||
@@ -53,3 +55,3 @@ if (dict.has("UF")) { | ||
constructor(root, xref) { | ||
if (!root || !(0, _primitives.isDict)(root)) { | ||
if (!(root instanceof _primitives.Dict)) { | ||
return; | ||
@@ -102,3 +104,3 @@ } | ||
if (fileObj && (0, _primitives.isStream)(fileObj)) { | ||
if (fileObj instanceof _base_stream.BaseStream) { | ||
content = fileObj.getBytes(); | ||
@@ -105,0 +107,0 @@ } else { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -40,10 +40,22 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
function getLong(data, offset) { | ||
return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]; | ||
function getUint32(data, offset) { | ||
return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0; | ||
} | ||
function getUshort(data, offset) { | ||
function getUint16(data, offset) { | ||
return data[offset] << 8 | data[offset + 1]; | ||
} | ||
function getInt16(data, offset) { | ||
return (data[offset] << 24 | data[offset + 1] << 16) >> 16; | ||
} | ||
function getInt8(data, offset) { | ||
return data[offset] << 24 >> 24; | ||
} | ||
function getFloat214(data, offset) { | ||
return getInt16(data, offset) / 16384; | ||
} | ||
function getSubroutineBias(subrs) { | ||
@@ -63,9 +75,9 @@ const numSubrs = subrs.length; | ||
function parseCmap(data, start, end) { | ||
const offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16); | ||
const format = getUshort(data, start + offset); | ||
const offset = getUint16(data, start + 2) === 1 ? getUint32(data, start + 8) : getUint32(data, start + 16); | ||
const format = getUint16(data, start + offset); | ||
let ranges, p, i; | ||
if (format === 4) { | ||
getUshort(data, start + offset + 2); | ||
const segCount = getUshort(data, start + offset + 6) >> 1; | ||
getUint16(data, start + offset + 2); | ||
const segCount = getUint16(data, start + offset + 6) >> 1; | ||
p = start + offset + 14; | ||
@@ -76,3 +88,3 @@ ranges = []; | ||
ranges[i] = { | ||
end: getUshort(data, p) | ||
end: getUint16(data, p) | ||
}; | ||
@@ -84,11 +96,11 @@ } | ||
for (i = 0; i < segCount; i++, p += 2) { | ||
ranges[i].start = getUshort(data, p); | ||
ranges[i].start = getUint16(data, p); | ||
} | ||
for (i = 0; i < segCount; i++, p += 2) { | ||
ranges[i].idDelta = getUshort(data, p); | ||
ranges[i].idDelta = getUint16(data, p); | ||
} | ||
for (i = 0; i < segCount; i++, p += 2) { | ||
let idOffset = getUshort(data, p); | ||
let idOffset = getUint16(data, p); | ||
@@ -102,3 +114,3 @@ if (idOffset === 0) { | ||
for (let j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) { | ||
ranges[i].ids[j] = getUshort(data, p + idOffset); | ||
ranges[i].ids[j] = getUint16(data, p + idOffset); | ||
idOffset += 2; | ||
@@ -110,4 +122,3 @@ } | ||
} else if (format === 12) { | ||
getLong(data, start + offset + 4); | ||
const groups = getLong(data, start + offset + 12); | ||
const groups = getUint32(data, start + offset + 12); | ||
p = start + offset + 16; | ||
@@ -117,6 +128,7 @@ ranges = []; | ||
for (i = 0; i < groups; i++) { | ||
start = getUint32(data, p); | ||
ranges.push({ | ||
start: getLong(data, p), | ||
end: getLong(data, p + 4), | ||
idDelta: getLong(data, p + 8) - getLong(data, p) | ||
start, | ||
end: getUint32(data, p + 4), | ||
idDelta: getUint32(data, p + 8) - start | ||
}); | ||
@@ -151,12 +163,7 @@ p += 12; | ||
itemSize = 4; | ||
itemDecode = function fontItemDecodeLong(data, offset) { | ||
return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]; | ||
}; | ||
itemDecode = getUint32; | ||
} else { | ||
itemSize = 2; | ||
itemDecode = function fontItemDecode(data, offset) { | ||
return data[offset] << 9 | data[offset + 1] << 1; | ||
}; | ||
itemDecode = (data, offset) => 2 * getUint16(data, offset); | ||
} | ||
@@ -225,3 +232,3 @@ | ||
let i = 0; | ||
const numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16; | ||
const numberOfContours = getInt16(code, i); | ||
let flags; | ||
@@ -234,4 +241,4 @@ let x = 0, | ||
do { | ||
flags = code[i] << 8 | code[i + 1]; | ||
const glyphIndex = code[i + 2] << 8 | code[i + 3]; | ||
flags = getUint16(code, i); | ||
const glyphIndex = getUint16(code, i + 2); | ||
i += 4; | ||
@@ -241,8 +248,19 @@ let arg1, arg2; | ||
if (flags & 0x01) { | ||
arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16; | ||
arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16; | ||
if (flags & 0x02) { | ||
arg1 = getInt16(code, i); | ||
arg2 = getInt16(code, i + 2); | ||
} else { | ||
arg1 = getUint16(code, i); | ||
arg2 = getUint16(code, i + 2); | ||
} | ||
i += 4; | ||
} else { | ||
arg1 = code[i++]; | ||
arg2 = code[i++]; | ||
if (flags & 0x02) { | ||
arg1 = getInt8(code, i++); | ||
arg2 = getInt8(code, i++); | ||
} else { | ||
arg1 = code[i++]; | ||
arg2 = code[i++]; | ||
} | ||
} | ||
@@ -264,13 +282,13 @@ | ||
if (flags & 0x08) { | ||
scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824; | ||
scaleX = scaleY = getFloat214(code, i); | ||
i += 2; | ||
} else if (flags & 0x40) { | ||
scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824; | ||
scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824; | ||
scaleX = getFloat214(code, i); | ||
scaleY = getFloat214(code, i + 2); | ||
i += 4; | ||
} else if (flags & 0x80) { | ||
scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824; | ||
scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824; | ||
scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824; | ||
scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824; | ||
scaleX = getFloat214(code, i); | ||
scale01 = getFloat214(code, i + 2); | ||
scale10 = getFloat214(code, i + 4); | ||
scaleY = getFloat214(code, i + 6); | ||
i += 8; | ||
@@ -288,2 +306,5 @@ } | ||
}); | ||
if (!(flags & 0x02)) {} | ||
compileGlyf(subglyph, cmds, font); | ||
@@ -300,7 +321,7 @@ cmds.push({ | ||
for (j = 0; j < numberOfContours; j++) { | ||
endPtsOfContours.push(code[i] << 8 | code[i + 1]); | ||
endPtsOfContours.push(getUint16(code, i)); | ||
i += 2; | ||
} | ||
const instructionLength = code[i] << 8 | code[i + 1]; | ||
const instructionLength = getUint16(code, i); | ||
i += 2 + instructionLength; | ||
@@ -328,3 +349,3 @@ const numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1; | ||
case 0x00: | ||
x += (code[i] << 24 | code[i + 1] << 16) >> 16; | ||
x += getInt16(code, i); | ||
i += 2; | ||
@@ -348,3 +369,3 @@ break; | ||
case 0x00: | ||
y += (code[i] << 24 | code[i + 1] << 16) >> 16; | ||
y += getInt16(code, i); | ||
i += 2; | ||
@@ -967,8 +988,8 @@ break; | ||
let cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm; | ||
const numTables = getUshort(data, 4); | ||
const numTables = getUint16(data, 4); | ||
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); | ||
const offset = getUint32(data, p + 8); | ||
const length = getUint32(data, p + 12); | ||
@@ -989,4 +1010,4 @@ switch (tag) { | ||
case "head": | ||
unitsPerEm = getUshort(data, offset + 18); | ||
indexToLocFormat = getUshort(data, offset + 50); | ||
unitsPerEm = getUint16(data, offset + 18); | ||
indexToLocFormat = getUint16(data, offset + 50); | ||
break; | ||
@@ -993,0 +1014,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -37,2 +37,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _image_utils = require("./image_utils.js"); | ||
@@ -92,3 +94,3 @@ | ||
fnRef = cacheKey.objId; | ||
} else if ((0, _primitives.isStream)(cacheKey)) { | ||
} else if (cacheKey instanceof _base_stream.BaseStream) { | ||
fnRef = cacheKey.dict && cacheKey.dict.objId; | ||
@@ -119,3 +121,3 @@ } | ||
fnRef = cacheKey.objId; | ||
} else if ((0, _primitives.isStream)(cacheKey)) { | ||
} else if (cacheKey instanceof _base_stream.BaseStream) { | ||
fnRef = cacheKey.dict && cacheKey.dict.objId; | ||
@@ -569,5 +571,5 @@ } | ||
return false; | ||
} else if ((0, _primitives.isDict)(v)) { | ||
} else if (v instanceof _primitives.Dict) { | ||
fnDict = v; | ||
} else if ((0, _primitives.isStream)(v)) { | ||
} else if (v instanceof _base_stream.BaseStream) { | ||
fnDict = v.dict; | ||
@@ -700,3 +702,3 @@ } else { | ||
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) { | ||
if (typeof a === "boolean" && typeof b === "boolean") { | ||
stack.push(a && b); | ||
@@ -855,3 +857,3 @@ } else { | ||
if ((0, _util.isBool)(a)) { | ||
if (typeof a === "boolean") { | ||
stack.push(!a); | ||
@@ -868,3 +870,3 @@ } else { | ||
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) { | ||
if (typeof a === "boolean" && typeof b === "boolean") { | ||
stack.push(a || b); | ||
@@ -922,3 +924,3 @@ } else { | ||
if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) { | ||
if (typeof a === "boolean" && typeof b === "boolean") { | ||
stack.push(a !== b); | ||
@@ -925,0 +927,0 @@ } else { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -560,10 +560,8 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
} else { | ||
argument1 = glyf.getUint8(pos); | ||
argument2 = glyf.getUint8(pos + 1); | ||
if (flags & ARGS_ARE_XY_VALUES) { | ||
const abs1 = argument1 & 0x7f; | ||
argument1 = argument1 & 0x80 ? -abs1 : abs1; | ||
const abs2 = argument2 & 0x7f; | ||
argument2 = argument2 & 0x80 ? -abs2 : abs2; | ||
argument1 = glyf.getInt8(pos); | ||
argument2 = glyf.getInt8(pos + 1); | ||
} else { | ||
argument1 = glyf.getUint8(pos); | ||
argument2 = glyf.getUint8(pos + 1); | ||
} | ||
@@ -570,0 +568,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,3 +32,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _primitives = require("./primitives.js"); | ||
var _base_stream = require("./base_stream.js"); | ||
@@ -43,2 +43,4 @@ var _colorspace = require("./colorspace.js"); | ||
var _primitives = require("./primitives.js"); | ||
function decodeAndClamp(value, addend, coefficient, max) { | ||
@@ -110,3 +112,3 @@ value = addend + value * coefficient; | ||
if ((0, _primitives.isName)(filter)) { | ||
if (filter instanceof _primitives.Name) { | ||
switch (filter.name) { | ||
@@ -226,3 +228,3 @@ case "JPXDecode": | ||
} else if (mask) { | ||
if ((0, _primitives.isStream)(mask)) { | ||
if (mask instanceof _base_stream.BaseStream) { | ||
const maskDict = mask.dict, | ||
@@ -267,3 +269,3 @@ imageMask = maskDict.get("IM", "ImageMask"); | ||
} else if (mask) { | ||
if ((0, _primitives.isStream)(mask) || Array.isArray(mask)) { | ||
if (mask instanceof _base_stream.BaseStream || Array.isArray(mask)) { | ||
maskData = mask; | ||
@@ -270,0 +272,0 @@ } else { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -30,6 +30,8 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _primitives = require("./primitives.js"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _decode_stream = require("./decode_stream.js"); | ||
var _primitives = require("./primitives.js"); | ||
var _jbig = require("./jbig2.js"); | ||
@@ -62,6 +64,6 @@ | ||
if ((0, _primitives.isDict)(this.params)) { | ||
if (this.params instanceof _primitives.Dict) { | ||
const globalsStream = this.params.get("JBIG2Globals"); | ||
if ((0, _primitives.isStream)(globalsStream)) { | ||
if (globalsStream instanceof _base_stream.BaseStream) { | ||
const globals = globalsStream.getBytes(); | ||
@@ -68,0 +70,0 @@ chunks.push({ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -94,3 +94,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
if ((0, _primitives.isDict)(this.params)) { | ||
if (this.params instanceof _primitives.Dict) { | ||
const colorTransform = this.params.get("ColorTransform"); | ||
@@ -97,0 +97,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -28,3 +28,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
exports.getMetrics = void 0; | ||
exports.getMetrics = exports.getFontBasicMetrics = void 0; | ||
@@ -2971,2 +2971,89 @@ var _core_utils = require("./core_utils.js"); | ||
}); | ||
exports.getMetrics = getMetrics; | ||
exports.getMetrics = getMetrics; | ||
const getFontBasicMetrics = (0, _core_utils.getLookupTableFactory)(function (t) { | ||
t.Courier = { | ||
ascent: 629, | ||
descent: -157, | ||
capHeight: 562, | ||
xHeight: -426 | ||
}; | ||
t["Courier-Bold"] = { | ||
ascent: 629, | ||
descent: -157, | ||
capHeight: 562, | ||
xHeight: 439 | ||
}; | ||
t["Courier-Oblique"] = { | ||
ascent: 629, | ||
descent: -157, | ||
capHeight: 562, | ||
xHeight: 426 | ||
}; | ||
t["Courier-BoldOblique"] = { | ||
ascent: 629, | ||
descent: -157, | ||
capHeight: 562, | ||
xHeight: 426 | ||
}; | ||
t.Helvetica = { | ||
ascent: 718, | ||
descent: -207, | ||
capHeight: 718, | ||
xHeight: 523 | ||
}; | ||
t["Helvetica-Bold"] = { | ||
ascent: 718, | ||
descent: -207, | ||
capHeight: 718, | ||
xHeight: 532 | ||
}; | ||
t["Helvetica-Oblique"] = { | ||
ascent: 718, | ||
descent: -207, | ||
capHeight: 718, | ||
xHeight: 523 | ||
}; | ||
t["Helvetica-BoldOblique"] = { | ||
ascent: 718, | ||
descent: -207, | ||
capHeight: 718, | ||
xHeight: 532 | ||
}; | ||
t["Times-Roman"] = { | ||
ascent: 683, | ||
descent: -217, | ||
capHeight: 662, | ||
xHeight: 450 | ||
}; | ||
t["Times-Bold"] = { | ||
ascent: 683, | ||
descent: -217, | ||
capHeight: 676, | ||
xHeight: 461 | ||
}; | ||
t["Times-Italic"] = { | ||
ascent: 683, | ||
descent: -217, | ||
capHeight: 653, | ||
xHeight: 441 | ||
}; | ||
t["Times-BoldItalic"] = { | ||
ascent: 683, | ||
descent: -217, | ||
capHeight: 669, | ||
xHeight: 462 | ||
}; | ||
t.Symbol = { | ||
ascent: Math.NaN, | ||
descent: Math.NaN, | ||
capHeight: Math.NaN, | ||
xHeight: Math.NaN | ||
}; | ||
t.ZapfDingbats = { | ||
ascent: Math.NaN, | ||
descent: Math.NaN, | ||
capHeight: Math.NaN, | ||
xHeight: Math.NaN | ||
}; | ||
}); | ||
exports.getFontBasicMetrics = getFontBasicMetrics; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -45,3 +45,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
if ((0, _util.isString)(input)) { | ||
if (typeof input === "string") { | ||
data = new Uint8Array(input.length * 2); | ||
@@ -48,0 +48,0 @@ length = 0; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -30,6 +30,6 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _primitives = require("./primitives.js"); | ||
var _util = require("../shared/util.js"); | ||
var _primitives = require("./primitives.js"); | ||
class NameOrNumberTree { | ||
@@ -61,3 +61,3 @@ constructor(root, xref, type) { | ||
if (!(0, _primitives.isDict)(obj)) { | ||
if (!(obj instanceof _primitives.Dict)) { | ||
continue; | ||
@@ -64,0 +64,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,2 +32,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _core_utils = require("./core_utils.js"); | ||
@@ -38,3 +40,3 @@ | ||
function mayHaveChildren(value) { | ||
return value instanceof _primitives.Ref || value instanceof _primitives.Dict || Array.isArray(value) || (0, _primitives.isStream)(value); | ||
return value instanceof _primitives.Ref || value instanceof _primitives.Dict || value instanceof _base_stream.BaseStream || Array.isArray(value); | ||
} | ||
@@ -45,3 +47,3 @@ | ||
node = node.getRawValues(); | ||
} else if ((0, _primitives.isStream)(node)) { | ||
} else if (node instanceof _base_stream.BaseStream) { | ||
node = node.dict.getRawValues(); | ||
@@ -123,3 +125,3 @@ } else if (!Array.isArray(node)) { | ||
if ((0, _primitives.isStream)(currentNode)) { | ||
if (currentNode instanceof _base_stream.BaseStream) { | ||
const baseStreams = currentNode.getBaseStreams(); | ||
@@ -126,0 +128,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -148,3 +148,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
while (!(0, _primitives.isCmd)(this.buf1, ">>") && this.buf1 !== _primitives.EOF) { | ||
if (!(0, _primitives.isName)(this.buf1)) { | ||
if (!(this.buf1 instanceof _primitives.Name)) { | ||
(0, _util.info)("Malformed dictionary: key must be a name object"); | ||
@@ -470,3 +470,3 @@ this.shift(); | ||
while (!(0, _primitives.isCmd)(this.buf1, "ID") && this.buf1 !== _primitives.EOF) { | ||
if (!(0, _primitives.isName)(this.buf1)) { | ||
if (!(this.buf1 instanceof _primitives.Name)) { | ||
throw new _util.FormatError("Dictionary key must be a name object"); | ||
@@ -492,3 +492,3 @@ } | ||
if ((0, _primitives.isName)(filter)) { | ||
if (filter instanceof _primitives.Name) { | ||
filterName = filter.name; | ||
@@ -498,3 +498,3 @@ } else if (Array.isArray(filter)) { | ||
if ((0, _primitives.isName)(filterZero)) { | ||
if (filterZero instanceof _primitives.Name) { | ||
filterName = filterZero.name; | ||
@@ -675,3 +675,3 @@ } | ||
if ((0, _primitives.isName)(filter)) { | ||
if (filter instanceof _primitives.Name) { | ||
if (Array.isArray(params)) { | ||
@@ -693,3 +693,3 @@ (0, _util.warn)("/DecodeParms should not be an Array, when /Filter is a Name."); | ||
if (!(0, _primitives.isName)(filter)) { | ||
if (!(filter instanceof _primitives.Name)) { | ||
throw new _util.FormatError(`Bad filter name "${filter}"`); | ||
@@ -859,5 +859,12 @@ } | ||
if (ch < 0x30 || ch > 0x39) { | ||
if (divideBy === 10 && sign === 0 && ((0, _core_utils.isWhiteSpace)(ch) || ch === -1)) { | ||
(0, _util.warn)("Lexer.getNumber - treating a single decimal point as zero."); | ||
return 0; | ||
if ((0, _core_utils.isWhiteSpace)(ch) || ch === -1) { | ||
if (divideBy === 10 && sign === 0) { | ||
(0, _util.warn)("Lexer.getNumber - treating a single decimal point as zero."); | ||
return 0; | ||
} | ||
if (divideBy === 0 && sign === -1) { | ||
(0, _util.warn)("Lexer.getNumber - treating a single minus sign as zero."); | ||
return 0; | ||
} | ||
} | ||
@@ -1381,3 +1388,3 @@ | ||
if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, "obj") && (0, _primitives.isDict)(linDict) && (0, _util.isNum)(obj = linDict.get("Linearized")) && obj > 0)) { | ||
if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, "obj") && linDict instanceof _primitives.Dict && typeof (obj = linDict.get("Linearized")) === "number" && obj > 0)) { | ||
return null; | ||
@@ -1384,0 +1391,0 @@ } else if ((length = getInt(linDict, "L")) !== stream.length) { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -33,6 +33,6 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _colorspace = require("./colorspace.js"); | ||
var _primitives = require("./primitives.js"); | ||
var _core_utils = require("./core_utils.js"); | ||
@@ -56,3 +56,3 @@ | ||
static parseShading(shading, xref, res, handler, pdfFunctionFactory, localColorSpaceCache) { | ||
const dict = (0, _primitives.isStream)(shading) ? shading.dict : shading; | ||
const dict = shading instanceof _base_stream.BaseStream ? shading.dict : shading; | ||
const type = dict.get("ShadingType"); | ||
@@ -373,3 +373,3 @@ | ||
if (!(0, _primitives.isStream)(stream)) { | ||
if (!(stream instanceof _base_stream.BaseStream)) { | ||
throw new _util.FormatError("Mesh data is not a stream"); | ||
@@ -376,0 +376,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,6 +32,6 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _primitives = require("./primitives.js"); | ||
var _util = require("../shared/util.js"); | ||
var _primitives = require("./primitives.js"); | ||
class PredictorStream extends _decode_stream.DecodeStream { | ||
@@ -41,3 +41,3 @@ constructor(str, maybeLength, params) { | ||
if (!(0, _primitives.isDict)(params)) { | ||
if (!(params instanceof _primitives.Dict)) { | ||
return str; | ||
@@ -44,0 +44,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -33,10 +33,6 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
exports.isName = isName; | ||
exports.isRef = isRef; | ||
exports.isRefsEqual = isRefsEqual; | ||
exports.isStream = isStream; | ||
var _util = require("../shared/util.js"); | ||
var _base_stream = require("./base_stream.js"); | ||
const CIRCULAR_REF = Symbol("CIRCULAR_REF"); | ||
@@ -388,6 +384,2 @@ exports.CIRCULAR_REF = CIRCULAR_REF; | ||
function isRef(v) { | ||
return v instanceof Ref; | ||
} | ||
function isRefsEqual(v1, v2) { | ||
@@ -397,6 +389,2 @@ return v1.num === v2.num && v1.gen === v2.gen; | ||
function isStream(v) { | ||
return v instanceof _base_stream.BaseStream; | ||
} | ||
function clearPrimitiveCaches() { | ||
@@ -403,0 +391,0 @@ Cmd._clearCache(); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -57,3 +57,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
if (!(0, _primitives.isDict)(roleMapDict)) { | ||
if (!(roleMapDict instanceof _primitives.Dict)) { | ||
return; | ||
@@ -63,3 +63,3 @@ } | ||
roleMapDict.forEach((key, value) => { | ||
if (!(0, _primitives.isName)(value)) { | ||
if (!(value instanceof _primitives.Name)) { | ||
return; | ||
@@ -86,3 +86,3 @@ } | ||
const nameObj = this.dict.get("S"); | ||
const name = (0, _primitives.isName)(nameObj) ? nameObj.name : ""; | ||
const name = nameObj instanceof _primitives.Name ? nameObj.name : ""; | ||
const { | ||
@@ -103,3 +103,3 @@ root | ||
if ((0, _primitives.isRef)(objRef)) { | ||
if (objRef instanceof _primitives.Ref) { | ||
pageObjId = objRef.toString(); | ||
@@ -142,5 +142,5 @@ } | ||
if ((0, _primitives.isRef)(kid)) { | ||
if (kid instanceof _primitives.Ref) { | ||
kidDict = this.dict.xref.fetch(kid); | ||
} else if ((0, _primitives.isDict)(kid)) { | ||
} else if (kid instanceof _primitives.Dict) { | ||
kidDict = kid; | ||
@@ -155,7 +155,7 @@ } | ||
if ((0, _primitives.isRef)(pageRef)) { | ||
if (pageRef instanceof _primitives.Ref) { | ||
pageObjId = pageRef.toString(); | ||
} | ||
const type = (0, _primitives.isName)(kidDict.get("Type")) ? kidDict.get("Type").name : null; | ||
const type = kidDict.get("Type") instanceof _primitives.Name ? kidDict.get("Type").name : null; | ||
@@ -169,3 +169,3 @@ if (type === "MCR") { | ||
type: StructElementType.STREAM_CONTENT, | ||
refObjId: (0, _primitives.isRef)(kidDict.getRaw("Stm")) ? kidDict.getRaw("Stm").toString() : null, | ||
refObjId: kidDict.getRaw("Stm") instanceof _primitives.Ref ? kidDict.getRaw("Stm").toString() : null, | ||
pageObjId, | ||
@@ -183,3 +183,3 @@ mcid: kidDict.get("MCID") | ||
type: StructElementType.OBJECT, | ||
refObjId: (0, _primitives.isRef)(kidDict.getRaw("Obj")) ? kidDict.getRaw("Obj").toString() : null, | ||
refObjId: kidDict.getRaw("Obj") instanceof _primitives.Ref ? kidDict.getRaw("Obj").toString() : null, | ||
pageObjId | ||
@@ -250,3 +250,3 @@ }); | ||
for (const ref of parentArray) { | ||
if ((0, _primitives.isRef)(ref)) { | ||
if (ref instanceof _primitives.Ref) { | ||
this.addNode(this.rootDict.xref.fetch(ref), map); | ||
@@ -308,3 +308,3 @@ } | ||
if ((0, _primitives.isDict)(obj)) { | ||
if (obj instanceof _primitives.Dict) { | ||
if (obj.objId !== dict.objId) { | ||
@@ -349,3 +349,3 @@ return false; | ||
if ((0, _util.isString)(alt)) { | ||
if (typeof alt === "string") { | ||
obj.alt = (0, _util.stringToPDFString)(alt); | ||
@@ -356,3 +356,3 @@ } | ||
if ((0, _util.isString)(lang)) { | ||
if (typeof lang === "string") { | ||
obj.lang = (0, _util.stringToPDFString)(lang); | ||
@@ -359,0 +359,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -469,2 +469,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
prevChar() { | ||
this.stream.skip(-2); | ||
return this.currentChar = this.stream.getByte(); | ||
} | ||
getToken() { | ||
@@ -566,2 +571,4 @@ let comment = false; | ||
this.getToken(); | ||
} else if (token === "/") { | ||
this.prevChar(); | ||
} | ||
@@ -568,0 +575,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -28,2 +28,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
exports.clearUnicodeCaches = clearUnicodeCaches; | ||
exports.getCharUnicodeCategory = getCharUnicodeCategory; | ||
exports.getNormalizedUnicodes = void 0; | ||
@@ -529,2 +531,26 @@ exports.getUnicodeForGlyph = getUnicodeForGlyph; | ||
return buf.join(""); | ||
} | ||
const SpecialCharRegExp = new RegExp("^(\\s)|(\\p{Mn})|(\\p{Cf})$", "u"); | ||
const CategoryCache = new Map(); | ||
function getCharUnicodeCategory(char) { | ||
const cachedCategory = CategoryCache.get(char); | ||
if (cachedCategory) { | ||
return cachedCategory; | ||
} | ||
const groups = char.match(SpecialCharRegExp); | ||
const category = { | ||
isWhitespace: !!(groups && groups[1]), | ||
isZeroWidthDiacritic: !!(groups && groups[2]), | ||
isInvisibleFormatMark: !!(groups && groups[3]) | ||
}; | ||
CategoryCache.set(char, category); | ||
return category; | ||
} | ||
function clearUnicodeCaches() { | ||
CategoryCache.clear(); | ||
} |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -36,2 +36,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _cleanup_helper = require("./cleanup_helper.js"); | ||
var _writer = require("./writer.js"); | ||
@@ -102,3 +104,3 @@ | ||
const apiVersion = docParams.apiVersion; | ||
const workerVersion = '2.12.313'; | ||
const workerVersion = '2.13.216'; | ||
@@ -120,3 +122,9 @@ 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 a `legacy`-build instead."); | ||
const partialMsg = "The browser/environment lacks native support for critical " + "functionality used by the PDF.js library (e.g. `ReadableStream`); "; | ||
if (_is_node.isNodeJS) { | ||
throw new Error(partialMsg + "please use a `legacy`-build instead."); | ||
} | ||
throw new Error(partialMsg + "please update to a supported browser."); | ||
} | ||
@@ -378,6 +386,4 @@ | ||
}); | ||
handler.on("GetPageIndex", function wphSetupGetPageIndex({ | ||
ref | ||
}) { | ||
const pageRef = _primitives.Ref.get(ref.num, ref.gen); | ||
handler.on("GetPageIndex", function wphSetupGetPageIndex(data) { | ||
const pageRef = _primitives.Ref.get(data.num, data.gen); | ||
@@ -532,3 +538,3 @@ return pdfManager.ensureCatalog("getPageIndex", [pageRef]); | ||
xrefInfo.forEach((key, value) => { | ||
if ((0, _util.isString)(key) && (0, _util.isString)(value)) { | ||
if (typeof value === "string") { | ||
infoObj[key] = (0, _util.stringToPDFString)(value); | ||
@@ -611,3 +617,2 @@ } | ||
sink, | ||
normalizeWhitespace: data.normalizeWhitespace, | ||
includeMarkedContent: data.includeMarkedContent, | ||
@@ -655,3 +660,3 @@ combineTextItems: data.combineTextItems | ||
} else { | ||
(0, _primitives.clearPrimitiveCaches)(); | ||
(0, _cleanup_helper.clearGlobalCaches)(); | ||
} | ||
@@ -658,0 +663,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -39,2 +39,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _base_stream = require("./base_stream.js"); | ||
var _crypto = require("./crypto.js"); | ||
@@ -101,5 +103,5 @@ | ||
function writeValue(value, buffer, transform) { | ||
if ((0, _primitives.isName)(value)) { | ||
if (value instanceof _primitives.Name) { | ||
buffer.push(`/${(0, _core_utils.escapePDFName)(value.name)}`); | ||
} else if ((0, _primitives.isRef)(value)) { | ||
} else if (value instanceof _primitives.Ref) { | ||
buffer.push(`${value.num} ${value.gen} R`); | ||
@@ -118,5 +120,5 @@ } else if (Array.isArray(value)) { | ||
buffer.push(value.toString()); | ||
} else if ((0, _primitives.isDict)(value)) { | ||
} else if (value instanceof _primitives.Dict) { | ||
writeDict(value, buffer, transform); | ||
} else if ((0, _primitives.isStream)(value)) { | ||
} else if (value instanceof _base_stream.BaseStream) { | ||
writeStream(value, buffer, transform); | ||
@@ -123,0 +125,0 @@ } else if (value === null) { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -78,10 +78,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
needsEncodingFixup = false; | ||
} catch (e) { | ||
if (/^utf-?8$/i.test(encoding)) { | ||
try { | ||
value = decodeURIComponent(escape(value)); | ||
needsEncodingFixup = false; | ||
} catch (err) {} | ||
} | ||
} | ||
} catch (e) {} | ||
} | ||
@@ -88,0 +81,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -28,4 +28,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
exports.StatTimer = exports.RenderingCancelledException = exports.PixelsPerInch = exports.PageViewport = exports.PDFDateString = exports.LinkTarget = exports.DOMStandardFontDataFactory = exports.DOMSVGFactory = exports.DOMCanvasFactory = exports.DOMCMapReaderFactory = void 0; | ||
exports.addLinkAttributes = addLinkAttributes; | ||
exports.StatTimer = exports.RenderingCancelledException = exports.PixelsPerInch = exports.PageViewport = exports.PDFDateString = exports.DOMStandardFontDataFactory = exports.DOMSVGFactory = exports.DOMCanvasFactory = exports.DOMCMapReaderFactory = void 0; | ||
exports.deprecated = deprecated; | ||
@@ -40,17 +39,14 @@ exports.getFilenameFromUrl = getFilenameFromUrl; | ||
var _base_factory = require("./base_factory.js"); | ||
var _util = require("../shared/util.js"); | ||
var _base_factory = require("./base_factory.js"); | ||
const DEFAULT_LINK_REL = "noopener noreferrer nofollow"; | ||
const SVG_NS = "http://www.w3.org/2000/svg"; | ||
const PixelsPerInch = { | ||
CSS: 96.0, | ||
PDF: 72.0, | ||
get PDF_TO_CSS_UNITS() { | ||
return (0, _util.shadow)(this, "PDF_TO_CSS_UNITS", this.CSS / this.PDF); | ||
} | ||
class PixelsPerInch { | ||
static CSS = 96.0; | ||
static PDF = 72.0; | ||
static PDF_TO_CSS_UNITS = this.CSS / this.PDF; | ||
} | ||
}; | ||
exports.PixelsPerInch = PixelsPerInch; | ||
@@ -283,58 +279,3 @@ | ||
exports.RenderingCancelledException = RenderingCancelledException; | ||
const LinkTarget = { | ||
NONE: 0, | ||
SELF: 1, | ||
BLANK: 2, | ||
PARENT: 3, | ||
TOP: 4 | ||
}; | ||
exports.LinkTarget = LinkTarget; | ||
function addLinkAttributes(link, { | ||
url, | ||
target, | ||
rel, | ||
enabled = true | ||
} = {}) { | ||
(0, _util.assert)(url && typeof url === "string", 'addLinkAttributes: A valid "url" parameter must provided.'); | ||
const urlNullRemoved = (0, _util.removeNullCharacters)(url); | ||
if (enabled) { | ||
link.href = link.title = urlNullRemoved; | ||
} else { | ||
link.href = ""; | ||
link.title = `Disabled: ${urlNullRemoved}`; | ||
link.onclick = () => { | ||
return false; | ||
}; | ||
} | ||
let targetStr = ""; | ||
switch (target) { | ||
case LinkTarget.NONE: | ||
break; | ||
case LinkTarget.SELF: | ||
targetStr = "_self"; | ||
break; | ||
case LinkTarget.BLANK: | ||
targetStr = "_blank"; | ||
break; | ||
case LinkTarget.PARENT: | ||
targetStr = "_parent"; | ||
break; | ||
case LinkTarget.TOP: | ||
targetStr = "_top"; | ||
break; | ||
} | ||
link.target = targetStr; | ||
link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL; | ||
} | ||
function isDataScheme(url) { | ||
@@ -481,3 +422,3 @@ const ii = url.length; | ||
static toDateObject(input) { | ||
if (!input || !(0, _util.isString)(input)) { | ||
if (!input || typeof input !== "string") { | ||
return null; | ||
@@ -484,0 +425,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -481,2 +481,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0); | ||
tmpCtx.save(); | ||
this.clipBbox(graphics, adjustedX0, adjustedY0, adjustedX1, adjustedY1); | ||
@@ -483,0 +484,0 @@ graphics.baseTransform = graphics.ctx.mozCurrentTransform.slice(); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -54,2 +54,26 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
const createObjectURL = function (data, contentType = "", forceDataSchema = false) { | ||
if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) { | ||
return URL.createObjectURL(new Blob([data], { | ||
type: contentType | ||
})); | ||
} | ||
const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | ||
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; | ||
}; | ||
const convertImgDataToPng = function () { | ||
@@ -247,3 +271,3 @@ const PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); | ||
writePngChunk("IEND", new Uint8Array(0), data, offset); | ||
return (0, _util.createObjectURL)(data, "image/png", forceDataSchema); | ||
return createObjectURL(data, "image/png", forceDataSchema); | ||
} | ||
@@ -763,3 +787,3 @@ | ||
continue; | ||
} else if ((0, _util.isNum)(glyph)) { | ||
} else if (typeof glyph === "number") { | ||
x += spacingDir * glyph * fontSize / 1000; | ||
@@ -887,3 +911,3 @@ continue; | ||
const url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema); | ||
const url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema); | ||
this.cssStyle.textContent += `@font-face { font-family: "${fontObj.loadedName}";` + ` src: url(${url}); }\n`; | ||
@@ -890,0 +914,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -58,8 +58,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
Object.defineProperty(exports, "LinkTarget", { | ||
enumerable: true, | ||
get: function () { | ||
return _display_utils.LinkTarget; | ||
} | ||
}); | ||
Object.defineProperty(exports, "LoopbackPort", { | ||
@@ -161,8 +155,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "addLinkAttributes", { | ||
enumerable: true, | ||
get: function () { | ||
return _display_utils.addLinkAttributes; | ||
} | ||
}); | ||
Object.defineProperty(exports, "build", { | ||
@@ -174,8 +162,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "createObjectURL", { | ||
enumerable: true, | ||
get: function () { | ||
return _util.createObjectURL; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createPromiseCapability", { | ||
@@ -229,8 +211,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "removeNullCharacters", { | ||
enumerable: true, | ||
get: function () { | ||
return _util.removeNullCharacters; | ||
} | ||
}); | ||
Object.defineProperty(exports, "renderTextLayer", { | ||
@@ -255,4 +231,2 @@ enumerable: true, | ||
var _display_utils = require("./display/display_utils.js"); | ||
var _util = require("./shared/util.js"); | ||
@@ -262,2 +236,4 @@ | ||
var _display_utils = require("./display/display_utils.js"); | ||
var _annotation_layer = require("./display/annotation_layer.js"); | ||
@@ -275,4 +251,4 @@ | ||
const pdfjsVersion = '2.12.313'; | ||
const pdfjsBuild = 'a2ae56f39'; | ||
const pdfjsVersion = '2.13.216'; | ||
const pdfjsBuild = '399a0ec60'; | ||
{ | ||
@@ -279,0 +255,0 @@ if (_is_node.isNodeJS) { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -37,3 +37,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
const pdfjsVersion = '2.12.313'; | ||
const pdfjsBuild = 'a2ae56f39'; | ||
const pdfjsVersion = '2.13.216'; | ||
const pdfjsBuild = '399a0ec60'; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -51,4 +51,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) { | ||
(0, _util.warn)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'); | ||
return reason; | ||
(0, _util.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'); | ||
} | ||
@@ -55,0 +54,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -33,3 +33,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
exports.bytesToString = bytesToString; | ||
exports.createObjectURL = createObjectURL; | ||
exports.createPromiseCapability = createPromiseCapability; | ||
@@ -44,9 +43,5 @@ exports.createValidAbsoluteUrl = createValidAbsoluteUrl; | ||
exports.isAscii = isAscii; | ||
exports.isBool = isBool; | ||
exports.isNum = isNum; | ||
exports.isSameOrigin = isSameOrigin; | ||
exports.isString = isString; | ||
exports.objectFromMap = objectFromMap; | ||
exports.objectSize = objectSize; | ||
exports.removeNullCharacters = removeNullCharacters; | ||
exports.setVerbosityLevel = setVerbosityLevel; | ||
@@ -598,20 +593,8 @@ exports.shadow = shadow; | ||
exports.AbortException = AbortException; | ||
const NullCharactersRegExp = /\x00+/g; | ||
const InvisibleCharactersRegExp = /[\x01-\x1F]/g; | ||
function removeNullCharacters(str, replaceInvisible = false) { | ||
if (typeof str !== "string") { | ||
warn("The argument for removeNullCharacters must be a string."); | ||
return str; | ||
function bytesToString(bytes) { | ||
if (typeof bytes !== "object" || bytes === null || bytes.length === undefined) { | ||
unreachable("Invalid argument for bytesToString"); | ||
} | ||
if (replaceInvisible) { | ||
str = str.replace(InvisibleCharactersRegExp, " "); | ||
} | ||
return str.replace(NullCharactersRegExp, ""); | ||
} | ||
function bytesToString(bytes) { | ||
assert(bytes !== null && typeof bytes === "object" && bytes.length !== undefined, "Invalid argument for bytesToString"); | ||
const length = bytes.length; | ||
@@ -636,3 +619,6 @@ const MAX_ARGUMENT_COUNT = 8192; | ||
function stringToBytes(str) { | ||
assert(typeof str === "string", "Invalid argument for stringToBytes"); | ||
if (typeof str !== "string") { | ||
unreachable("Invalid argument for stringToBytes"); | ||
} | ||
const length = str.length; | ||
@@ -653,4 +639,7 @@ const bytes = new Uint8Array(length); | ||
assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument."); | ||
return arr.byteLength; | ||
if (arr.byteLength !== undefined) { | ||
return arr.byteLength; | ||
} | ||
unreachable("Invalid argument for arrayByteLength"); | ||
} | ||
@@ -915,20 +904,33 @@ | ||
function stringToPDFString(str) { | ||
const length = str.length, | ||
strBuf = []; | ||
if (str[0] >= "\xEF") { | ||
let encoding; | ||
if (str[0] === "\xFE" && str[1] === "\xFF") { | ||
for (let i = 2; i < length; i += 2) { | ||
strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1))); | ||
if (str[0] === "\xFE" && str[1] === "\xFF") { | ||
encoding = "utf-16be"; | ||
} else if (str[0] === "\xFF" && str[1] === "\xFE") { | ||
encoding = "utf-16le"; | ||
} else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") { | ||
encoding = "utf-8"; | ||
} | ||
} else if (str[0] === "\xFF" && str[1] === "\xFE") { | ||
for (let i = 2; i < length; i += 2) { | ||
strBuf.push(String.fromCharCode(str.charCodeAt(i + 1) << 8 | str.charCodeAt(i))); | ||
if (encoding) { | ||
try { | ||
const decoder = new TextDecoder(encoding, { | ||
fatal: true | ||
}); | ||
const buffer = stringToBytes(str); | ||
return decoder.decode(buffer); | ||
} catch (ex) { | ||
warn(`stringToPDFString: "${ex}".`); | ||
} | ||
} | ||
} else { | ||
for (let i = 0; i < length; ++i) { | ||
const code = PDFStringTranslateTable[str.charCodeAt(i)]; | ||
strBuf.push(code ? String.fromCharCode(code) : str.charAt(i)); | ||
} | ||
} | ||
const strBuf = []; | ||
for (let i = 0, ii = str.length; i < ii; i++) { | ||
const code = PDFStringTranslateTable[str.charCodeAt(i)]; | ||
strBuf.push(code ? String.fromCharCode(code) : str.charAt(i)); | ||
} | ||
return strBuf.join(""); | ||
@@ -972,14 +974,2 @@ } | ||
function isBool(v) { | ||
return typeof v === "boolean"; | ||
} | ||
function isNum(v) { | ||
return typeof v === "number"; | ||
} | ||
function isString(v) { | ||
return typeof v === "string"; | ||
} | ||
function isArrayBuffer(v) { | ||
@@ -1029,26 +1019,2 @@ return typeof v === "object" && v !== null && v.byteLength !== undefined; | ||
return capability; | ||
} | ||
function createObjectURL(data, contentType = "", forceDataSchema = false) { | ||
if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) { | ||
return URL.createObjectURL(new Blob([data], { | ||
type: contentType | ||
})); | ||
} | ||
const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | ||
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; | ||
} |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -236,3 +236,5 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
const typedArray = new Uint8Array([1, 2, 3, 4, 5]); | ||
const blobUrl = (0, _util.createObjectURL)(typedArray, "application/pdf"); | ||
const blobUrl = URL.createObjectURL(new Blob([typedArray], { | ||
type: "application/pdf" | ||
})); | ||
expect(blobUrl.startsWith("blob:")).toEqual(true); | ||
@@ -242,4 +244,5 @@ 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); | ||
const typedArray = new Uint8Array([1, 2, 3, 4, 5]), | ||
str = (0, _util.bytesToString)(typedArray); | ||
const dataUrl = `data:application/pdf;base64,${btoa(str)}`; | ||
expect(dataUrl.startsWith("data:")).toEqual(true); | ||
@@ -246,0 +249,0 @@ expect((0, _display_utils.getPdfFilenameFromUrl)(dataUrl + "?file1.pdf")).toEqual("document.pdf"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,52 +32,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
describe("function", function () { | ||
beforeEach(function () { | ||
jasmine.addMatchers({ | ||
toMatchArray(util, customEqualityTesters) { | ||
return { | ||
compare(actual, expected) { | ||
const result = {}; | ||
if (actual.length !== expected.length) { | ||
result.pass = false; | ||
result.message = "Array length: " + actual.length + ", expected: " + expected.length; | ||
return result; | ||
} | ||
result.pass = true; | ||
for (let i = 0; i < expected.length; i++) { | ||
const a = actual[i], | ||
b = expected[i]; | ||
if (Array.isArray(b)) { | ||
if (a.length !== b.length) { | ||
result.pass = false; | ||
break; | ||
} | ||
for (let j = 0; j < a.length; j++) { | ||
const suba = a[j], | ||
subb = b[j]; | ||
if (suba !== subb) { | ||
result.pass = false; | ||
break; | ||
} | ||
} | ||
} else { | ||
if (a !== b) { | ||
result.pass = false; | ||
break; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
}; | ||
} | ||
}); | ||
}); | ||
describe("PostScriptParser", function () { | ||
@@ -98,3 +48,3 @@ function parse(program) { | ||
const expectedProgram = [number]; | ||
expect(program).toMatchArray(expectedProgram); | ||
expect(program).toEqual(expectedProgram); | ||
}); | ||
@@ -105,3 +55,3 @@ it("parses negative numbers", function () { | ||
const expectedProgram = [number]; | ||
expect(program).toMatchArray(expectedProgram); | ||
expect(program).toEqual(expectedProgram); | ||
}); | ||
@@ -112,3 +62,3 @@ it("parses negative floats", function () { | ||
const expectedProgram = [number]; | ||
expect(program).toMatchArray(expectedProgram); | ||
expect(program).toEqual(expectedProgram); | ||
}); | ||
@@ -118,3 +68,3 @@ it("parses operators", function () { | ||
const expectedProgram = ["sub"]; | ||
expect(program).toMatchArray(expectedProgram); | ||
expect(program).toEqual(expectedProgram); | ||
}); | ||
@@ -124,3 +74,3 @@ it("parses if statements", function () { | ||
const expectedProgram = [3, "jz", 99]; | ||
expect(program).toMatchArray(expectedProgram); | ||
expect(program).toEqual(expectedProgram); | ||
}); | ||
@@ -130,3 +80,3 @@ it("parses ifelse statements", function () { | ||
const expectedProgram = [5, "jz", 99, 6, "j", 44]; | ||
expect(program).toMatchArray(expectedProgram); | ||
expect(program).toEqual(expectedProgram); | ||
}); | ||
@@ -142,3 +92,3 @@ it("handles missing brackets", function () { | ||
const expectedProgram = [number]; | ||
expect(program).toMatchArray(expectedProgram); | ||
expect(program).toEqual(expectedProgram); | ||
}); | ||
@@ -159,3 +109,3 @@ }); | ||
const expectedStack = [99]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -165,3 +115,3 @@ it("handles if with true", function () { | ||
const expectedStack = [99]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -171,3 +121,3 @@ it("handles if with false", function () { | ||
const expectedStack = []; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -177,3 +127,3 @@ it("handles ifelse with true", function () { | ||
const expectedStack = [99]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -183,3 +133,3 @@ it("handles ifelse with false", function () { | ||
const expectedStack = [77]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -189,3 +139,3 @@ it("handles nested if", function () { | ||
const expectedStack = [77]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -195,3 +145,3 @@ it("abs", function () { | ||
const expectedStack = [2]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -201,3 +151,3 @@ it("adds", function () { | ||
const expectedStack = [3]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -207,3 +157,3 @@ it("boolean and", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -213,3 +163,3 @@ it("bitwise and", function () { | ||
const expectedStack = [254 & 1]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -219,3 +169,3 @@ it("calculates the inverse tangent of a number", function () { | ||
const expectedStack = [Math.atan(90)]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -225,3 +175,3 @@ it("handles bitshifting ", function () { | ||
const expectedStack = [200]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -231,3 +181,3 @@ it("calculates the ceiling value", function () { | ||
const expectedStack = [10]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -237,3 +187,3 @@ it("copies", function () { | ||
const expectedStack = [99, 98, 99, 98]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -243,3 +193,3 @@ it("calculates the cosine of a number", function () { | ||
const expectedStack = [Math.cos(90)]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -249,3 +199,3 @@ it("converts to int", function () { | ||
const expectedStack = [9]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -255,3 +205,3 @@ it("converts negatives to int", function () { | ||
const expectedStack = [-9]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -261,3 +211,3 @@ it("converts to real", function () { | ||
const expectedStack = [55.34]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -267,3 +217,3 @@ it("divides", function () { | ||
const expectedStack = [1.2]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -273,3 +223,3 @@ it("maps division by zero to infinity", function () { | ||
const expectedStack = [Infinity]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -279,3 +229,3 @@ it("duplicates", function () { | ||
const expectedStack = [99, 99]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -285,3 +235,3 @@ it("accepts an equality", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -291,3 +241,3 @@ it("rejects an inequality", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -297,3 +247,3 @@ it("exchanges", function () { | ||
const expectedStack = [99, 44]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -303,3 +253,3 @@ it("handles exponentiation", function () { | ||
const expectedStack = [100]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -309,3 +259,3 @@ it("pushes false onto the stack", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -315,3 +265,3 @@ it("calculates the floor value", function () { | ||
const expectedStack = [9]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -321,3 +271,3 @@ it("handles greater than or equal to", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -327,3 +277,3 @@ it("rejects less than for greater than or equal to", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -333,3 +283,3 @@ it("handles greater than", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -339,3 +289,3 @@ it("rejects less than or equal for greater than", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -345,3 +295,3 @@ it("divides to integer", function () { | ||
const expectedStack = [0]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -351,3 +301,3 @@ it("divides to negative integer", function () { | ||
const expectedStack = [0]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -357,3 +307,3 @@ it("duplicates index", function () { | ||
const expectedStack = [4, 3, 2, 1, 3]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -363,3 +313,3 @@ it("handles less than or equal to", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -369,3 +319,3 @@ it("rejects greater than for less than or equal to", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -375,3 +325,3 @@ it("calculates the natural logarithm", function () { | ||
const expectedStack = [Math.log(10)]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -381,3 +331,3 @@ it("calculates the base 10 logarithm", function () { | ||
const expectedStack = [2]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -387,3 +337,3 @@ it("handles less than", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -393,3 +343,3 @@ it("rejects greater than or equal to for less than", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -399,3 +349,3 @@ it("performs the modulo operation", function () { | ||
const expectedStack = [1]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -405,3 +355,3 @@ it("multiplies two numbers (positive result)", function () { | ||
const expectedStack = [72]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -411,3 +361,3 @@ it("multiplies two numbers (negative result)", function () { | ||
const expectedStack = [-72]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -417,3 +367,3 @@ it("accepts an inequality", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -423,3 +373,3 @@ it("rejects an equality", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -429,3 +379,3 @@ it("negates", function () { | ||
const expectedStack = [-4.5]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -435,3 +385,3 @@ it("boolean not", function () { | ||
const expectedStack = [false]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -441,3 +391,3 @@ it("bitwise not", function () { | ||
const expectedStack = [-13]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -447,3 +397,3 @@ it("boolean or", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -453,3 +403,3 @@ it("bitwise or", function () { | ||
const expectedStack = [254 | 1]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -459,3 +409,3 @@ it("pops stack", function () { | ||
const expectedStack = [1]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -465,3 +415,3 @@ it("rolls stack right", function () { | ||
const expectedStack = [2, 1, 3, 2]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -471,3 +421,3 @@ it("rolls stack left", function () { | ||
const expectedStack = [3, 2, 2, 1]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -477,3 +427,3 @@ it("rounds a number", function () { | ||
const expectedStack = [10]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -483,3 +433,3 @@ it("calculates the sine of a number", function () { | ||
const expectedStack = [Math.sin(90)]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -489,3 +439,3 @@ it("calculates a square root (integer)", function () { | ||
const expectedStack = [10]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -495,3 +445,3 @@ it("calculates a square root (float)", function () { | ||
const expectedStack = [Math.sqrt(99)]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -501,3 +451,3 @@ it("subtracts (positive result)", function () { | ||
const expectedStack = [2]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -507,3 +457,3 @@ it("subtracts (negative result)", function () { | ||
const expectedStack = [-2]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -513,3 +463,3 @@ it("pushes true onto the stack", function () { | ||
const expectedStack = [true]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -519,3 +469,3 @@ it("truncates a number", function () { | ||
const expectedStack = [35]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -525,3 +475,3 @@ it("calculates an exclusive or value", function () { | ||
const expectedStack = [10]; | ||
expect(stack).toMatchArray(expectedStack); | ||
expect(stack).toEqual(expectedStack); | ||
}); | ||
@@ -543,3 +493,3 @@ }); | ||
fn(samples[i].input, 0, out, 0); | ||
expect(Array.prototype.slice.call(out, 0)).toMatchArray(samples[i].output); | ||
expect(Array.prototype.slice.call(out, 0)).toEqual(samples[i].output); | ||
} | ||
@@ -546,0 +496,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -133,6 +133,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
it("should treat a single decimal point as zero", function () { | ||
const input = new _stream.StringStream("."); | ||
const lexer = new _parser.Lexer(input); | ||
expect(lexer.getNumber()).toEqual(0); | ||
it("should treat a single decimal point, or minus sign, as zero", function () { | ||
const dotInput = new _stream.StringStream("."); | ||
const dotLexer = new _parser.Lexer(dotInput); | ||
expect(dotLexer.getNumber()).toEqual(0); | ||
const minusInput = new _stream.StringStream("-"); | ||
const minusLexer = new _parser.Lexer(minusInput); | ||
expect(minusLexer.getNumber()).toEqual(0); | ||
const numbers = ["..", "-.", "+.", "-\r\n.", "+\r\n."]; | ||
@@ -139,0 +142,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -31,2 +31,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _is_node = require("../../shared/is_node.js"); | ||
var _pdf_find_controller = require("../../web/pdf_find_controller.js"); | ||
@@ -97,3 +99,4 @@ | ||
phraseSearch: true, | ||
findPrevious: false | ||
findPrevious: false, | ||
matchDiacritics: false | ||
}, state); | ||
@@ -252,3 +255,286 @@ eventBus.dispatch("find", eventState); | ||
}); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "1/2" | ||
}, | ||
matchesPerPage: [2], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[27, 54]], | ||
pageMatchesLength: [[1, 1]] | ||
}); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "½" | ||
}, | ||
matchesPerPage: [2], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[27, 54]], | ||
pageMatchesLength: [[1, 1]] | ||
}); | ||
}); | ||
it("performs a normal search, where the text with diacritics is normalized", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController("french_diacritics.pdf"); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "a" | ||
}, | ||
matchesPerPage: [6], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[0, 2, 4, 6, 8, 10]], | ||
pageMatchesLength: [[1, 1, 1, 1, 1, 1]] | ||
}); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "u" | ||
}, | ||
matchesPerPage: [6], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[44, 46, 48, 50, 52, 54]], | ||
pageMatchesLength: [[1, 1, 1, 1, 1, 1]] | ||
}); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "ë", | ||
matchDiacritics: true | ||
}, | ||
matchesPerPage: [2], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[28, 30]], | ||
pageMatchesLength: [[1, 1]] | ||
}); | ||
}); | ||
it("performs a search where one of the results contains an hyphen", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "optimiz" | ||
}, | ||
matchesPerPage: [1, 4, 2, 3, 3, 0, 2, 9, 1, 0, 0, 6, 3, 4], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
} | ||
}); | ||
}); | ||
it("performs a search where the result is on two lines", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "user experience" | ||
}, | ||
matchesPerPage: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[2743]], | ||
pageMatchesLength: [[14]] | ||
}); | ||
}); | ||
it("performs a search where the result is on two lines with a punctuation at eol", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "version.the" | ||
}, | ||
matchesPerPage: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
selectedMatch: { | ||
pageIndex: 1, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[], [1493]], | ||
pageMatchesLength: [[], [11]] | ||
}); | ||
}); | ||
it("performs a search with a minus sign in the query", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "trace-based just-in-time" | ||
}, | ||
matchesPerPage: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[0], [], [], [], [], [], [], [], [], [], [], [], [], [2087]], | ||
pageMatchesLength: [[24], [], [], [], [], [], [], [], [], [], [], [], [], [24]] | ||
}); | ||
}); | ||
it("performs a search with square brackets in the query", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "[Programming Languages]" | ||
}, | ||
matchesPerPage: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[1501]], | ||
pageMatchesLength: [[25]] | ||
}); | ||
}); | ||
it("performs a search with parenthesis in the query", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "\t (checks)" | ||
}, | ||
matchesPerPage: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
selectedMatch: { | ||
pageIndex: 1, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[], [201]], | ||
pageMatchesLength: [[], [9]] | ||
}); | ||
}); | ||
it("performs a search with a final dot in the query", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
const query = "complex applications."; | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query | ||
}, | ||
matchesPerPage: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[1946]], | ||
pageMatchesLength: [[21]] | ||
}); | ||
}); | ||
it("performs a search with a dot in the query and a missing whitespace", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
const query = "complex applications.J"; | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query | ||
}, | ||
matchesPerPage: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[1946]], | ||
pageMatchesLength: [[23]] | ||
}); | ||
}); | ||
it("performs a search with a dot followed by a whitespace in the query", async function () { | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController(); | ||
const query = "complex applications. j"; | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query | ||
}, | ||
matchesPerPage: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[1946]], | ||
pageMatchesLength: [[23]] | ||
}); | ||
}); | ||
it("performs a search in a text containing diacritics before -\\n", async function () { | ||
if (_is_node.isNodeJS) { | ||
pending("Linked test-cases are not supported in Node.js."); | ||
} | ||
const { | ||
eventBus, | ||
pdfFindController | ||
} = await initPdfFindController("issue14562.pdf"); | ||
await testSearch({ | ||
eventBus, | ||
pdfFindController, | ||
state: { | ||
query: "ä", | ||
matchDiacritics: true | ||
}, | ||
matchesPerPage: [80], | ||
selectedMatch: { | ||
pageIndex: 0, | ||
matchIndex: 0 | ||
}, | ||
pageMatches: [[299, 337, 414, 476, 623, 797, 978, 984, 1010, 1058, 1079, 1144, 1152, 1274, 1343, 1391, 1399, 1421, 1497, 1521, 1527, 1684, 1774, 1786, 1857, 1879, 1909, 1946, 2064, 2074, 2161, 2178, 2213, 2227, 2272, 2322, 2359, 2401, 2412, 2423, 2462, 2532, 2538, 2553, 2562, 2576, 2602, 2613, 2638, 2668, 2792, 2805, 2836, 2848, 2859, 2896, 2902, 2916, 2940, 2960, 3091, 3239, 3249, 3339, 3387, 3394, 3468, 3477, 3485, 3502, 3690, 3696, 3711, 3758, 3789, 3865, 3977, 4052, 4058, 4071]], | ||
pageMatchesLength: [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] | ||
}); | ||
}); | ||
}); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -63,2 +63,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
it("should not accept to create a non-string name", function () { | ||
expect(function () { | ||
_primitives.Name.get(123); | ||
}).toThrow(new Error('Name: The "name" must be a string.')); | ||
}); | ||
}); | ||
@@ -86,2 +91,7 @@ describe("Cmd", function () { | ||
}); | ||
it("should not accept to create a non-string cmd", function () { | ||
expect(function () { | ||
_primitives.Cmd.get(123); | ||
}).toThrow(new Error('Cmd: The "cmd" must be a string.')); | ||
}); | ||
}); | ||
@@ -147,2 +157,10 @@ describe("Dict", function () { | ||
}); | ||
it("should not accept to set a non-string key", function () { | ||
const dict = new _primitives.Dict(); | ||
expect(function () { | ||
dict.set(123, "val"); | ||
}).toThrow(new Error('Dict.set: The "key" must be a string.')); | ||
expect(dict.has(123)).toBeFalsy(); | ||
checkInvalidKeyValues(dict); | ||
}); | ||
it("should not accept to set a key with an undefined value", function () { | ||
@@ -473,13 +491,2 @@ const dict = new _primitives.Dict(); | ||
}); | ||
describe("isRef", function () { | ||
it("handles non-refs", function () { | ||
const nonRef = {}; | ||
expect((0, _primitives.isRef)(nonRef)).toEqual(false); | ||
}); | ||
it("handles refs", function () { | ||
const ref = _primitives.Ref.get(1, 0); | ||
expect((0, _primitives.isRef)(ref)).toEqual(true); | ||
}); | ||
}); | ||
describe("isRefsEqual", function () { | ||
@@ -501,12 +508,2 @@ it("should handle Refs pointing to the same object", function () { | ||
}); | ||
describe("isStream", function () { | ||
it("handles non-streams", function () { | ||
const nonStream = {}; | ||
expect((0, _primitives.isStream)(nonStream)).toEqual(false); | ||
}); | ||
it("handles streams", function () { | ||
const stream = new _stream.StringStream("foo"); | ||
expect((0, _primitives.isStream)(stream)).toEqual(true); | ||
}); | ||
}); | ||
}); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -1051,3 +1051,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
name: "Keystroke", | ||
willCommit: true, | ||
willCommit: false, | ||
selStart: 3, | ||
@@ -1057,4 +1057,190 @@ selEnd: 3 | ||
expect(send_queue.has(refId)).toEqual(false); | ||
await sandbox.dispatchEventInSandbox({ | ||
id: refId, | ||
value: "3F?0", | ||
name: "Keystroke", | ||
willCommit: true, | ||
selStart: 4, | ||
selEnd: 4 | ||
}); | ||
expect(send_queue.has(refId)).toEqual(true); | ||
expect(send_queue.get(refId)).toEqual({ | ||
id: refId, | ||
valueAsString: "3F?0" | ||
}); | ||
}); | ||
}); | ||
describe("AFSpecial_Keystroke", function () { | ||
it("should validate a zip code on a keystroke event", async () => { | ||
const refId = getId(); | ||
const data = { | ||
objects: { | ||
field: [{ | ||
id: refId, | ||
value: "", | ||
actions: { | ||
Keystroke: [`AFSpecial_Keystroke(0);`] | ||
}, | ||
type: "text" | ||
}] | ||
}, | ||
appInfo: { | ||
language: "en-US", | ||
platform: "Linux x86_64" | ||
}, | ||
calculationOrder: [], | ||
dispatchEventName: "_dispatchMe" | ||
}; | ||
sandbox.createSandbox(data); | ||
let value = ""; | ||
const changes = "12345"; | ||
let i = 0; | ||
for (; i < changes.length; i++) { | ||
const change = changes.charAt(i); | ||
await sandbox.dispatchEventInSandbox({ | ||
id: refId, | ||
value, | ||
change, | ||
name: "Keystroke", | ||
willCommit: false, | ||
selStart: i, | ||
selEnd: i | ||
}); | ||
expect(send_queue.has(refId)).toEqual(false); | ||
value += change; | ||
} | ||
await sandbox.dispatchEventInSandbox({ | ||
id: refId, | ||
value, | ||
change: "A", | ||
name: "Keystroke", | ||
willCommit: false, | ||
selStart: i, | ||
selEnd: i | ||
}); | ||
expect(send_queue.has(refId)).toEqual(true); | ||
expect(send_queue.get(refId)).toEqual({ | ||
id: refId, | ||
value, | ||
selRange: [i, i] | ||
}); | ||
send_queue.delete(refId); | ||
}); | ||
it("should validate a US phone number (long) on a keystroke event", async () => { | ||
const refId = getId(); | ||
const data = { | ||
objects: { | ||
field: [{ | ||
id: refId, | ||
value: "", | ||
actions: { | ||
Keystroke: [`AFSpecial_Keystroke(2);`] | ||
}, | ||
type: "text" | ||
}] | ||
}, | ||
appInfo: { | ||
language: "en-US", | ||
platform: "Linux x86_64" | ||
}, | ||
calculationOrder: [], | ||
dispatchEventName: "_dispatchMe" | ||
}; | ||
sandbox.createSandbox(data); | ||
let value = ""; | ||
const changes = "(123) 456-7890"; | ||
let i = 0; | ||
for (; i < changes.length; i++) { | ||
const change = changes.charAt(i); | ||
await sandbox.dispatchEventInSandbox({ | ||
id: refId, | ||
value, | ||
change, | ||
name: "Keystroke", | ||
willCommit: false, | ||
selStart: i, | ||
selEnd: i | ||
}); | ||
expect(send_queue.has(refId)).toEqual(false); | ||
value += change; | ||
} | ||
await sandbox.dispatchEventInSandbox({ | ||
id: refId, | ||
value, | ||
change: "A", | ||
name: "Keystroke", | ||
willCommit: false, | ||
selStart: i, | ||
selEnd: i | ||
}); | ||
expect(send_queue.has(refId)).toEqual(true); | ||
expect(send_queue.get(refId)).toEqual({ | ||
id: refId, | ||
value, | ||
selRange: [i, i] | ||
}); | ||
send_queue.delete(refId); | ||
}); | ||
it("should validate a US phone number (short) on a keystroke event", async () => { | ||
const refId = getId(); | ||
const data = { | ||
objects: { | ||
field: [{ | ||
id: refId, | ||
value: "", | ||
actions: { | ||
Keystroke: [`AFSpecial_Keystroke(2);`] | ||
}, | ||
type: "text" | ||
}] | ||
}, | ||
appInfo: { | ||
language: "en-US", | ||
platform: "Linux x86_64" | ||
}, | ||
calculationOrder: [], | ||
dispatchEventName: "_dispatchMe" | ||
}; | ||
sandbox.createSandbox(data); | ||
let value = ""; | ||
const changes = "123-4567"; | ||
let i = 0; | ||
for (; i < changes.length; i++) { | ||
const change = changes.charAt(i); | ||
await sandbox.dispatchEventInSandbox({ | ||
id: refId, | ||
value, | ||
change, | ||
name: "Keystroke", | ||
willCommit: false, | ||
selStart: i, | ||
selEnd: i | ||
}); | ||
expect(send_queue.has(refId)).toEqual(false); | ||
value += change; | ||
} | ||
await sandbox.dispatchEventInSandbox({ | ||
id: refId, | ||
value, | ||
change: "A", | ||
name: "Keystroke", | ||
willCommit: false, | ||
selStart: i, | ||
selEnd: i | ||
}); | ||
expect(send_queue.has(refId)).toEqual(true); | ||
expect(send_queue.get(refId)).toEqual({ | ||
id: refId, | ||
value, | ||
selRange: [i, i] | ||
}); | ||
send_queue.delete(refId); | ||
}); | ||
}); | ||
describe("eMailValidate", function () { | ||
@@ -1061,0 +1247,0 @@ it("should validate an e-mail address", async () => { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,35 +32,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
describe("stream", function () { | ||
beforeEach(function () { | ||
jasmine.addMatchers({ | ||
toMatchTypedArray(util, customEqualityTesters) { | ||
return { | ||
compare(actual, expected) { | ||
const result = {}; | ||
if (actual.length !== expected.length) { | ||
result.pass = false; | ||
result.message = "Array length: " + actual.length + ", expected: " + expected.length; | ||
return result; | ||
} | ||
result.pass = true; | ||
for (let i = 0, ii = expected.length; i < ii; i++) { | ||
const a = actual[i], | ||
b = expected[i]; | ||
if (a !== b) { | ||
result.pass = false; | ||
break; | ||
} | ||
} | ||
return result; | ||
} | ||
}; | ||
} | ||
}); | ||
}); | ||
describe("PredictorStream", function () { | ||
@@ -76,3 +43,3 @@ it("should decode simple predictor data", function () { | ||
const result = predictor.getBytes(6); | ||
expect(result).toMatchTypedArray(new Uint8Array([100, 3, 101, 2, 102, 1])); | ||
expect(result).toEqual(new Uint8Array([100, 3, 101, 2, 102, 1])); | ||
predictor.reset(); | ||
@@ -79,0 +46,0 @@ const clampedResult = predictor.getBytes(6, true); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -33,4 +33,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _primitives = require("../../core/primitives.js"); | ||
var _document = require("../../core/document.js"); | ||
@@ -44,2 +42,4 @@ | ||
var _primitives = require("../../core/primitives.js"); | ||
var _stream = require("../../core/stream.js"); | ||
@@ -138,7 +138,7 @@ | ||
fetchIfRef(obj) { | ||
if (!(0, _primitives.isRef)(obj)) { | ||
return obj; | ||
if (obj instanceof _primitives.Ref) { | ||
return this.fetch(obj); | ||
} | ||
return this.fetch(obj); | ||
return obj; | ||
} | ||
@@ -145,0 +145,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -55,2 +55,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
it("three numeric entries and a start index", function () { | ||
expect((0, _ui_utils.binarySearchFirstItem)([0, 1, 2, 3, 4], isGreater3, 2)).toEqual(4); | ||
expect((0, _ui_utils.binarySearchFirstItem)([2, 3, 4], isGreater3, 2)).toEqual(2); | ||
expect((0, _ui_utils.binarySearchFirstItem)([4, 5, 6], isGreater3, 1)).toEqual(1); | ||
}); | ||
}); | ||
@@ -125,2 +130,17 @@ describe("isValidRotation", function () { | ||
}); | ||
describe("removeNullCharacters", function () { | ||
it("should not modify string without null characters", function () { | ||
const str = "string without null chars"; | ||
expect((0, _ui_utils.removeNullCharacters)(str)).toEqual("string without null chars"); | ||
}); | ||
it("should modify string with null characters", function () { | ||
const str = "string\x00With\x00Null\x00Chars"; | ||
expect((0, _ui_utils.removeNullCharacters)(str)).toEqual("stringWithNullChars"); | ||
}); | ||
it("should modify string with non-displayable characters", function () { | ||
const str = Array.from(Array(32).keys()).map(x => String.fromCharCode(x) + "a").join(""); | ||
const expected = "a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a"; | ||
expect((0, _ui_utils.removeNullCharacters)(str, true)).toEqual(expected); | ||
}); | ||
}); | ||
describe("getPageSizeInches", function () { | ||
@@ -127,0 +147,0 @@ it("gets page size (in inches)", function () { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -25,6 +25,6 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _unicode = require("../../core/unicode.js"); | ||
var _glyphlist = require("../../core/glyphlist.js"); | ||
var _unicode = require("../../core/unicode.js"); | ||
describe("unicode", function () { | ||
@@ -41,2 +41,67 @@ describe("mapSpecialUnicodeValues", function () { | ||
}); | ||
describe("getCharUnicodeCategory", function () { | ||
it("should correctly determine the character category", function () { | ||
const tests = { | ||
" ": { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: true | ||
}, | ||
"\t": { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: true | ||
}, | ||
"\u2001": { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: true | ||
}, | ||
"\uFEFF": { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: true | ||
}, | ||
"\u0302": { | ||
isZeroWidthDiacritic: true, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: false | ||
}, | ||
"\u0344": { | ||
isZeroWidthDiacritic: true, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: false | ||
}, | ||
"\u0361": { | ||
isZeroWidthDiacritic: true, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: false | ||
}, | ||
"\u200B": { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: true, | ||
isWhitespace: false | ||
}, | ||
"\u200D": { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: true, | ||
isWhitespace: false | ||
}, | ||
a: { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: false | ||
}, | ||
1: { | ||
isZeroWidthDiacritic: false, | ||
isInvisibleFormatMark: false, | ||
isWhitespace: false | ||
} | ||
}; | ||
for (const [character, expectation] of Object.entries(tests)) { | ||
expect((0, _unicode.getCharUnicodeCategory)(character)).toEqual(expectation); | ||
} | ||
}); | ||
}); | ||
describe("getUnicodeForGlyph", function () { | ||
@@ -43,0 +108,0 @@ let standardMap, dingbatsMap; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -62,43 +62,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
describe("isBool", function () { | ||
it("handles boolean values", function () { | ||
expect((0, _util.isBool)(true)).toEqual(true); | ||
expect((0, _util.isBool)(false)).toEqual(true); | ||
}); | ||
it("handles non-boolean values", function () { | ||
expect((0, _util.isBool)("true")).toEqual(false); | ||
expect((0, _util.isBool)("false")).toEqual(false); | ||
expect((0, _util.isBool)(1)).toEqual(false); | ||
expect((0, _util.isBool)(0)).toEqual(false); | ||
expect((0, _util.isBool)(null)).toEqual(false); | ||
expect((0, _util.isBool)(undefined)).toEqual(false); | ||
}); | ||
}); | ||
describe("isNum", function () { | ||
it("handles numeric values", function () { | ||
expect((0, _util.isNum)(1)).toEqual(true); | ||
expect((0, _util.isNum)(0)).toEqual(true); | ||
expect((0, _util.isNum)(-1)).toEqual(true); | ||
expect((0, _util.isNum)(1000000000000000000)).toEqual(true); | ||
expect((0, _util.isNum)(12.34)).toEqual(true); | ||
}); | ||
it("handles non-numeric values", function () { | ||
expect((0, _util.isNum)("true")).toEqual(false); | ||
expect((0, _util.isNum)(true)).toEqual(false); | ||
expect((0, _util.isNum)(null)).toEqual(false); | ||
expect((0, _util.isNum)(undefined)).toEqual(false); | ||
}); | ||
}); | ||
describe("isString", function () { | ||
it("handles string values", function () { | ||
expect((0, _util.isString)("foo")).toEqual(true); | ||
expect((0, _util.isString)("")).toEqual(true); | ||
}); | ||
it("handles non-string values", function () { | ||
expect((0, _util.isString)(true)).toEqual(false); | ||
expect((0, _util.isString)(1)).toEqual(false); | ||
expect((0, _util.isString)(null)).toEqual(false); | ||
expect((0, _util.isString)(undefined)).toEqual(false); | ||
}); | ||
}); | ||
describe("string32", function () { | ||
@@ -135,2 +94,8 @@ it("converts unsigned 32-bit integers to strings", function () { | ||
}); | ||
it("handles UTF-8 strings", function () { | ||
const simpleStr = "\xEF\xBB\xBF\x73\x74\x72\x69\x6E\x67"; | ||
expect((0, _util.stringToPDFString)(simpleStr)).toEqual("string"); | ||
const complexStr = "\xEF\xBB\xBF\xE8\xA1\xA8\xE3\x83\x9D\xE3\x81\x82\x41\xE9\xB7\x97" + "\xC5\x92\xC3\xA9\xEF\xBC\xA2\xE9\x80\x8D\xC3\x9C\xC3\x9F\xC2\xAA" + "\xC4\x85\xC3\xB1\xE4\xB8\x82\xE3\x90\x80\xF0\xA0\x80\x80"; | ||
expect((0, _util.stringToPDFString)(complexStr)).toEqual("表ポあA鷗ŒéB逍Üߪąñ丂㐀𠀀"); | ||
}); | ||
it("handles empty strings", function () { | ||
@@ -143,19 +108,6 @@ const str1 = ""; | ||
expect((0, _util.stringToPDFString)(str3)).toEqual(""); | ||
const str4 = "\xEF\xBB\xBF"; | ||
expect((0, _util.stringToPDFString)(str4)).toEqual(""); | ||
}); | ||
}); | ||
describe("removeNullCharacters", function () { | ||
it("should not modify string without null characters", function () { | ||
const str = "string without null chars"; | ||
expect((0, _util.removeNullCharacters)(str)).toEqual("string without null chars"); | ||
}); | ||
it("should modify string with null characters", function () { | ||
const str = "string\x00With\x00Null\x00Chars"; | ||
expect((0, _util.removeNullCharacters)(str)).toEqual("stringWithNullChars"); | ||
}); | ||
it("should modify string with non-displayable characters", function () { | ||
const str = Array.from(Array(32).keys()).map(x => String.fromCharCode(x) + "a").join(""); | ||
const expected = "a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a"; | ||
expect((0, _util.removeNullCharacters)(str, true)).toEqual(expected); | ||
}); | ||
}); | ||
describe("ReadableStream", function () { | ||
@@ -162,0 +114,0 @@ it("should return an Object", function () { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,15 +32,12 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
{ | ||
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || ""; | ||
const platform = typeof navigator !== "undefined" && navigator.platform || ""; | ||
const maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1; | ||
if (typeof navigator === "undefined") { | ||
globalThis.navigator = Object.create(null); | ||
} | ||
const userAgent = navigator.userAgent || ""; | ||
const platform = navigator.platform || ""; | ||
const maxTouchPoints = navigator.maxTouchPoints || 1; | ||
const isAndroid = /Android/.test(userAgent); | ||
const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1; | ||
const isIOSChrome = /CriOS/.test(userAgent); | ||
(function checkOnBlobSupport() { | ||
if (isIOSChrome) { | ||
compatibilityParams.disableCreateObjectURL = true; | ||
} | ||
})(); | ||
(function checkCanvasSizeLimitation() { | ||
@@ -232,3 +229,3 @@ if (isIOS || isAndroid) { | ||
defaultOptions.locale = { | ||
value: typeof navigator !== "undefined" ? navigator.language : "en-US", | ||
value: navigator.language || "en-US", | ||
kind: OptionKind.VIEWER | ||
@@ -235,0 +232,0 @@ }; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -30,3 +30,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _pdf = require("../pdf"); | ||
var _ui_utils = require("./ui_utils.js"); | ||
@@ -64,3 +64,3 @@ const TREEITEM_OFFSET_TOP = -100; | ||
_normalizeTextContent(str) { | ||
return (0, _pdf.removeNullCharacters)(str, true) || "\u2013"; | ||
return (0, _ui_utils.removeNullCharacters)(str, true) || "\u2013"; | ||
} | ||
@@ -67,0 +67,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -57,3 +57,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
FORCE_LAZY_PAGE_INIT: 7500, | ||
PAUSE_EAGER_PAGE_INIT: 500 | ||
PAUSE_EAGER_PAGE_INIT: 250 | ||
}; | ||
@@ -134,2 +134,3 @@ exports.PagesCountLimit = PagesCountLimit; | ||
#scrollModePageState = null; | ||
#onVisibilityChange = null; | ||
@@ -141,3 +142,3 @@ constructor(options) { | ||
const viewerVersion = '2.12.313'; | ||
const viewerVersion = '2.13.216'; | ||
@@ -404,7 +405,20 @@ if (_pdf.version !== viewerVersion) { | ||
#onePageRenderedOrForceFetch() { | ||
if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) { | ||
if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) { | ||
return Promise.resolve(); | ||
} | ||
return this._onePageRenderedCapability.promise; | ||
const visibilityChangePromise = new Promise(resolve => { | ||
this.#onVisibilityChange = () => { | ||
if (document.visibilityState !== "hidden") { | ||
return; | ||
} | ||
resolve(); | ||
document.removeEventListener("visibilitychange", this.#onVisibilityChange); | ||
this.#onVisibilityChange = null; | ||
}; | ||
document.addEventListener("visibilitychange", this.#onVisibilityChange); | ||
}); | ||
return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]); | ||
} | ||
@@ -483,2 +497,7 @@ | ||
this._onAfterDraw = null; | ||
if (this.#onVisibilityChange) { | ||
document.removeEventListener("visibilitychange", this.#onVisibilityChange); | ||
this.#onVisibilityChange = null; | ||
} | ||
}; | ||
@@ -672,2 +691,7 @@ | ||
if (this.#onVisibilityChange) { | ||
document.removeEventListener("visibilitychange", this.#onVisibilityChange); | ||
this.#onVisibilityChange = null; | ||
} | ||
this.viewer.textContent = ""; | ||
@@ -1270,3 +1294,3 @@ | ||
if (!this.linkService._cachedPageNumber(pdfPage.ref)) { | ||
if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) { | ||
this.linkService.cachePageRef(pageView.id, pdfPage.ref); | ||
@@ -1273,0 +1297,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -32,4 +32,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _app_options = require("./app_options.js"); | ||
; | ||
@@ -71,3 +69,5 @@ | ||
downloadData(data, filename, contentType) { | ||
const blobUrl = (0, _pdf.createObjectURL)(data, contentType, _app_options.compatibilityParams.disableCreateObjectURL); | ||
const blobUrl = URL.createObjectURL(new Blob([data], { | ||
type: contentType | ||
})); | ||
download(blobUrl, filename); | ||
@@ -80,3 +80,3 @@ } | ||
if (isPdfData && !_app_options.compatibilityParams.disableCreateObjectURL) { | ||
if (isPdfData) { | ||
let blobUrl = this._openBlobUrls.get(element); | ||
@@ -111,7 +111,2 @@ | ||
download(blob, url, filename, sourceEventType = "download") { | ||
if (_app_options.compatibilityParams.disableCreateObjectURL) { | ||
this.downloadUrl(url, filename); | ||
return; | ||
} | ||
const blobUrl = URL.createObjectURL(blob); | ||
@@ -118,0 +113,0 @@ download(blobUrl, filename); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -210,3 +210,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
(function listenFindEvents() { | ||
const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose"]; | ||
const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose", "finddiacriticmatchingchange"]; | ||
const findLen = "find".length; | ||
@@ -238,3 +238,4 @@ | ||
highlightAll: !!detail.highlightAll, | ||
findPrevious: !!detail.findPrevious | ||
findPrevious: !!detail.findPrevious, | ||
matchDiacritics: !!detail.matchDiacritics | ||
}); | ||
@@ -241,0 +242,0 @@ }; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -75,3 +75,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
const sandbox = await this._ready; | ||
sandbox.dispatchEvent(event); | ||
setTimeout(() => sandbox.dispatchEvent(event), 0); | ||
} | ||
@@ -78,0 +78,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -45,10 +45,10 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
this.reason = null; | ||
this.submitButton.addEventListener("click", this.verify.bind(this)); | ||
this.cancelButton.addEventListener("click", this.close.bind(this)); | ||
this.submitButton.addEventListener("click", this.#verify.bind(this)); | ||
this.cancelButton.addEventListener("click", this.#cancel.bind(this)); | ||
this.input.addEventListener("keydown", e => { | ||
if (e.keyCode === 13) { | ||
this.verify(); | ||
this.#verify(); | ||
} | ||
}); | ||
this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true); | ||
this.overlayManager.register(this.overlayName, this.container, this.#cancel.bind(this), true); | ||
} | ||
@@ -67,9 +67,8 @@ | ||
close() { | ||
this.overlayManager.close(this.overlayName).then(() => { | ||
this.input.value = ""; | ||
}); | ||
async close() { | ||
await this.overlayManager.close(this.overlayName); | ||
this.input.value = ""; | ||
} | ||
verify() { | ||
#verify() { | ||
const password = this.input.value; | ||
@@ -83,2 +82,7 @@ | ||
#cancel() { | ||
this.close(); | ||
this.updateCallback(new Error("PasswordPrompt cancelled.")); | ||
} | ||
setUpdateCallback(updateCallback, reason) { | ||
@@ -85,0 +89,0 @@ this.updateCallback = updateCallback; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -42,2 +42,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
this.caseSensitive = options.caseSensitiveCheckbox; | ||
this.matchDiacritics = options.matchDiacriticsCheckbox; | ||
this.entireWord = options.entireWordCheckbox; | ||
@@ -85,2 +86,5 @@ this.findMsg = options.findMsg; | ||
}); | ||
this.matchDiacritics.addEventListener("click", () => { | ||
this.dispatchEvent("diacriticmatchingchange"); | ||
}); | ||
@@ -103,3 +107,4 @@ this.eventBus._on("resize", this._adjustWidth.bind(this)); | ||
highlightAll: this.highlightAll.checked, | ||
findPrevious: findPrev | ||
findPrevious: findPrev, | ||
matchDiacritics: this.matchDiacritics.checked | ||
}); | ||
@@ -163,3 +168,2 @@ } | ||
this.findResultsCount.textContent = msg; | ||
this.findResultsCount.classList.toggle("hidden", !total); | ||
@@ -166,0 +170,0 @@ this._adjustWidth(); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -30,2 +30,4 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _ui_utils = require("./ui_utils.js"); | ||
var _pdf = require("../pdf"); | ||
@@ -35,4 +37,2 @@ | ||
var _ui_utils = require("./ui_utils.js"); | ||
const FindState = { | ||
@@ -62,2 +62,8 @@ FOUND: 0, | ||
}; | ||
const DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84, 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74]); | ||
const DIACRITICS_EXCEPTION_STR = [...DIACRITICS_EXCEPTION.values()].map(x => String.fromCharCode(x)).join(""); | ||
const DIACRITICS_REG_EXP = /\p{M}+/gu; | ||
const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu; | ||
const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u; | ||
const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u; | ||
let normalizationRegex = null; | ||
@@ -68,42 +74,102 @@ | ||
const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join(""); | ||
normalizationRegex = new RegExp(`[${replace}]`, "g"); | ||
normalizationRegex = new RegExp(`([${replace}])|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(\\n)`, "gum"); | ||
} | ||
let diffs = null; | ||
const normalizedText = text.replace(normalizationRegex, function (ch, index) { | ||
const normalizedCh = CHARACTERS_TO_NORMALIZE[ch], | ||
diff = normalizedCh.length - ch.length; | ||
const rawDiacriticsPositions = []; | ||
let m; | ||
if (diff !== 0) { | ||
(diffs ||= []).push([index, diff]); | ||
while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) { | ||
rawDiacriticsPositions.push([m[0].length, m.index]); | ||
} | ||
let normalized = text.normalize("NFD"); | ||
const positions = [[0, 0]]; | ||
let k = 0; | ||
let shift = 0; | ||
let shiftOrigin = 0; | ||
let eol = 0; | ||
let hasDiacritics = false; | ||
normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, i) => { | ||
i -= shiftOrigin; | ||
if (p1) { | ||
const replacement = CHARACTERS_TO_NORMALIZE[match]; | ||
const jj = replacement.length; | ||
for (let j = 1; j < jj; j++) { | ||
positions.push([i - shift + j, shift - j]); | ||
} | ||
shift -= jj - 1; | ||
return replacement; | ||
} | ||
return normalizedCh; | ||
if (p2) { | ||
const hasTrailingDashEOL = p2.endsWith("\n"); | ||
const len = hasTrailingDashEOL ? p2.length - 2 : p2.length; | ||
hasDiacritics = true; | ||
let jj = len; | ||
if (i + eol === rawDiacriticsPositions[k]?.[1]) { | ||
jj -= rawDiacriticsPositions[k][0]; | ||
++k; | ||
} | ||
for (let j = 1; j < jj + 1; j++) { | ||
positions.push([i - 1 - shift + j, shift - j]); | ||
} | ||
shift -= jj; | ||
shiftOrigin += jj; | ||
if (hasTrailingDashEOL) { | ||
i += len - 1; | ||
positions.push([i - shift + 1, 1 + shift]); | ||
shift += 1; | ||
shiftOrigin += 1; | ||
eol += 1; | ||
return p2.slice(0, len); | ||
} | ||
return p2; | ||
} | ||
if (p3) { | ||
positions.push([i - shift + 1, 1 + shift]); | ||
shift += 1; | ||
shiftOrigin += 1; | ||
eol += 1; | ||
return p3.charAt(0); | ||
} | ||
positions.push([i - shift + 1, shift - 1]); | ||
shift -= 1; | ||
shiftOrigin += 1; | ||
eol += 1; | ||
return " "; | ||
}); | ||
return [normalizedText, diffs]; | ||
positions.push([normalized.length, shift]); | ||
return [normalized, positions, hasDiacritics]; | ||
} | ||
function getOriginalIndex(matchIndex, diffs = null) { | ||
function getOriginalIndex(diffs, pos, len) { | ||
if (!diffs) { | ||
return matchIndex; | ||
return [pos, len]; | ||
} | ||
let totalDiff = 0; | ||
const start = pos; | ||
const end = pos + len; | ||
let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start); | ||
for (const [index, diff] of diffs) { | ||
const currentIndex = index + totalDiff; | ||
if (diffs[i][0] > start) { | ||
--i; | ||
} | ||
if (currentIndex >= matchIndex) { | ||
break; | ||
} | ||
let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i); | ||
if (currentIndex + diff > matchIndex) { | ||
totalDiff += matchIndex - currentIndex; | ||
break; | ||
} | ||
totalDiff += diff; | ||
if (diffs[j][0] > end) { | ||
--j; | ||
} | ||
return matchIndex - totalDiff; | ||
return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]]; | ||
} | ||
@@ -273,2 +339,3 @@ | ||
this._pageDiffs = []; | ||
this._hasDiacritics = []; | ||
this._matchesCountTotal = 0; | ||
@@ -316,50 +383,8 @@ this._pagesToSearch = null; | ||
_prepareMatches(matchesWithLength, matches, matchesLength) { | ||
function isSubTerm(currentIndex) { | ||
const currentElem = matchesWithLength[currentIndex]; | ||
const nextElem = matchesWithLength[currentIndex + 1]; | ||
_isEntireWord(content, startIdx, length) { | ||
let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP); | ||
if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) { | ||
currentElem.skipped = true; | ||
return true; | ||
} | ||
for (let i = currentIndex - 1; i >= 0; i--) { | ||
const prevElem = matchesWithLength[i]; | ||
if (prevElem.skipped) { | ||
continue; | ||
} | ||
if (prevElem.match + prevElem.matchLength < currentElem.match) { | ||
break; | ||
} | ||
if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) { | ||
currentElem.skipped = true; | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
matchesWithLength.sort(function (a, b) { | ||
return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match; | ||
}); | ||
for (let i = 0, len = matchesWithLength.length; i < len; i++) { | ||
if (isSubTerm(i)) { | ||
continue; | ||
} | ||
matches.push(matchesWithLength[i].match); | ||
matchesLength.push(matchesWithLength[i].matchLength); | ||
} | ||
} | ||
_isEntireWord(content, startIdx, length) { | ||
if (startIdx > 0) { | ||
if (match) { | ||
const first = content.charCodeAt(startIdx); | ||
const limit = content.charCodeAt(startIdx - 1); | ||
const limit = match[1].charCodeAt(0); | ||
@@ -371,7 +396,7 @@ if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) { | ||
const endIdx = startIdx + length - 1; | ||
match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP); | ||
if (endIdx < content.length - 1) { | ||
const last = content.charCodeAt(endIdx); | ||
const limit = content.charCodeAt(endIdx + 1); | ||
if (match) { | ||
const last = content.charCodeAt(startIdx + length - 1); | ||
const limit = match[1].charCodeAt(0); | ||
@@ -386,24 +411,19 @@ if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) { | ||
_calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) { | ||
_calculateRegExpMatch(query, entireWord, pageIndex, pageContent) { | ||
const matches = [], | ||
matchesLength = []; | ||
const queryLen = query.length; | ||
let matchIdx = -queryLen; | ||
const diffs = this._pageDiffs[pageIndex]; | ||
let match; | ||
while (true) { | ||
matchIdx = pageContent.indexOf(query, matchIdx + queryLen); | ||
if (matchIdx === -1) { | ||
break; | ||
while ((match = query.exec(pageContent)) !== null) { | ||
if (entireWord && !this._isEntireWord(pageContent, match.index, match[0].length)) { | ||
continue; | ||
} | ||
if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) { | ||
continue; | ||
const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length); | ||
if (matchLen) { | ||
matches.push(matchPos); | ||
matchesLength.push(matchLen); | ||
} | ||
const originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs), | ||
matchEnd = matchIdx + queryLen - 1, | ||
originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1; | ||
matches.push(originalMatchIdx); | ||
matchesLength.push(originalQueryLen); | ||
} | ||
@@ -415,43 +435,58 @@ | ||
_calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) { | ||
const matchesWithLength = []; | ||
const queryArray = query.match(/\S+/g); | ||
_convertToRegExpString(query, hasDiacritics) { | ||
const { | ||
matchDiacritics | ||
} = this._state; | ||
let isUnicode = false; | ||
query = query.replace(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => { | ||
if (p1) { | ||
return `[ ]*\\${p1}[ ]*`; | ||
} | ||
for (let i = 0, len = queryArray.length; i < len; i++) { | ||
const subquery = queryArray[i]; | ||
const subqueryLen = subquery.length; | ||
let matchIdx = -subqueryLen; | ||
if (p2) { | ||
return `[ ]*${p2}[ ]*`; | ||
} | ||
while (true) { | ||
matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen); | ||
if (p3) { | ||
return "[ ]+"; | ||
} | ||
if (matchIdx === -1) { | ||
break; | ||
} | ||
if (matchDiacritics) { | ||
return p4 || p5; | ||
} | ||
if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) { | ||
continue; | ||
} | ||
if (p4) { | ||
return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : ""; | ||
} | ||
const originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs), | ||
matchEnd = matchIdx + subqueryLen - 1, | ||
originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1; | ||
matchesWithLength.push({ | ||
match: originalMatchIdx, | ||
matchLength: originalQueryLen, | ||
skipped: false | ||
}); | ||
if (hasDiacritics) { | ||
isUnicode = true; | ||
return `${p5}\\p{M}*`; | ||
} | ||
return p5; | ||
}); | ||
const trailingSpaces = "[ ]*"; | ||
if (query.endsWith(trailingSpaces)) { | ||
query = query.slice(0, query.length - trailingSpaces.length); | ||
} | ||
this._pageMatchesLength[pageIndex] = []; | ||
this._pageMatches[pageIndex] = []; | ||
if (matchDiacritics) { | ||
if (hasDiacritics) { | ||
isUnicode = true; | ||
query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`; | ||
} | ||
} | ||
this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]); | ||
return [isUnicode, query]; | ||
} | ||
_calculateMatch(pageIndex) { | ||
let pageContent = this._pageContents[pageIndex]; | ||
const pageDiffs = this._pageDiffs[pageIndex]; | ||
let query = this._query; | ||
if (query.length === 0) { | ||
return; | ||
} | ||
const { | ||
@@ -462,18 +497,26 @@ caseSensitive, | ||
} = this._state; | ||
const pageContent = this._pageContents[pageIndex]; | ||
const hasDiacritics = this._hasDiacritics[pageIndex]; | ||
let isUnicode = false; | ||
if (query.length === 0) { | ||
return; | ||
} | ||
if (phraseSearch) { | ||
[isUnicode, query] = this._convertToRegExpString(query, hasDiacritics); | ||
} else { | ||
const match = query.match(/\S+/g); | ||
if (!caseSensitive) { | ||
pageContent = pageContent.toLowerCase(); | ||
query = query.toLowerCase(); | ||
} | ||
if (match) { | ||
query = match.sort().reverse().map(q => { | ||
const [isUnicodePart, queryPart] = this._convertToRegExpString(q, hasDiacritics); | ||
if (phraseSearch) { | ||
this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord); | ||
} else { | ||
this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord); | ||
isUnicode ||= isUnicodePart; | ||
return `(${queryPart})`; | ||
}).join("|"); | ||
} | ||
} | ||
const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`; | ||
query = new RegExp(query, flags); | ||
this._calculateRegExpMatch(query, entireWord, pageIndex, pageContent); | ||
if (this._state.highlightAll) { | ||
@@ -510,5 +553,3 @@ this._updatePage(pageIndex); | ||
return this._pdfDocument.getPage(i + 1).then(pdfPage => { | ||
return pdfPage.getTextContent({ | ||
normalizeWhitespace: true | ||
}); | ||
return pdfPage.getTextContent(); | ||
}).then(textContent => { | ||
@@ -520,5 +561,9 @@ const textItems = textContent.items; | ||
strBuf.push(textItems[j].str); | ||
if (textItems[j].hasEOL) { | ||
strBuf.push("\n"); | ||
} | ||
} | ||
[this._pageContents[i], this._pageDiffs[i]] = normalize(strBuf.join("")); | ||
[this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join("")); | ||
extractTextCapability.resolve(i); | ||
@@ -529,2 +574,3 @@ }, reason => { | ||
this._pageDiffs[i] = null; | ||
this._hasDiacritics[i] = false; | ||
extractTextCapability.resolve(i); | ||
@@ -531,0 +577,0 @@ }); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -28,9 +28,69 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
exports.SimpleLinkService = exports.PDFLinkService = void 0; | ||
exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0; | ||
var _pdf = require("../pdf"); | ||
var _ui_utils = require("./ui_utils.js"); | ||
const DEFAULT_LINK_REL = "noopener noreferrer nofollow"; | ||
const LinkTarget = { | ||
NONE: 0, | ||
SELF: 1, | ||
BLANK: 2, | ||
PARENT: 3, | ||
TOP: 4 | ||
}; | ||
exports.LinkTarget = LinkTarget; | ||
function addLinkAttributes(link, { | ||
url, | ||
target, | ||
rel, | ||
enabled = true | ||
} = {}) { | ||
if (!url || typeof url !== "string") { | ||
throw new Error('A valid "url" parameter must provided.'); | ||
} | ||
const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url); | ||
if (enabled) { | ||
link.href = link.title = urlNullRemoved; | ||
} else { | ||
link.href = ""; | ||
link.title = `Disabled: ${urlNullRemoved}`; | ||
link.onclick = () => { | ||
return false; | ||
}; | ||
} | ||
let targetStr = ""; | ||
switch (target) { | ||
case LinkTarget.NONE: | ||
break; | ||
case LinkTarget.SELF: | ||
targetStr = "_self"; | ||
break; | ||
case LinkTarget.BLANK: | ||
targetStr = "_blank"; | ||
break; | ||
case LinkTarget.PARENT: | ||
targetStr = "_parent"; | ||
break; | ||
case LinkTarget.TOP: | ||
targetStr = "_top"; | ||
break; | ||
} | ||
link.target = targetStr; | ||
link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL; | ||
} | ||
class PDFLinkService { | ||
#pagesRefCache = new Map(); | ||
constructor({ | ||
@@ -51,3 +111,2 @@ eventBus, | ||
this.pdfHistory = null; | ||
this._pagesRefCache = null; | ||
} | ||
@@ -58,3 +117,3 @@ | ||
this.pdfDocument = pdfDocument; | ||
this._pagesRefCache = Object.create(null); | ||
this.#pagesRefCache.clear(); | ||
} | ||
@@ -90,3 +149,3 @@ | ||
_goToDestinationHelper(rawDest, namedDest = null, explicitDest) { | ||
#goToDestinationHelper(rawDest, namedDest = null, explicitDest) { | ||
const destRef = explicitDest[0]; | ||
@@ -101,6 +160,5 @@ let pageNumber; | ||
this.cachePageRef(pageIndex + 1, destRef); | ||
this._goToDestinationHelper(rawDest, namedDest, explicitDest); | ||
this.#goToDestinationHelper(rawDest, namedDest, explicitDest); | ||
}).catch(() => { | ||
console.error(`PDFLinkService._goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`); | ||
console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`); | ||
}); | ||
@@ -112,3 +170,3 @@ return; | ||
} else { | ||
console.error(`PDFLinkService._goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`); | ||
console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`); | ||
return; | ||
@@ -118,3 +176,3 @@ } | ||
if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) { | ||
console.error(`PDFLinkService._goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`); | ||
console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`); | ||
return; | ||
@@ -159,3 +217,3 @@ } | ||
this._goToDestinationHelper(dest, namedDest, explicitDest); | ||
this.#goToDestinationHelper(dest, namedDest, explicitDest); | ||
} | ||
@@ -186,5 +244,5 @@ | ||
addLinkAttributes(link, url, newWindow = false) { | ||
(0, _pdf.addLinkAttributes)(link, { | ||
addLinkAttributes(link, { | ||
url, | ||
target: newWindow ? _pdf.LinkTarget.BLANK : this.externalLinkTarget, | ||
target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget, | ||
rel: this.externalLinkRel, | ||
@@ -264,3 +322,3 @@ enabled: this.externalLinkEnabled | ||
} else { | ||
console.error(`PDFLinkService.setHash: "${zoomArg}" is not ` + "a valid zoom value."); | ||
console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`); | ||
} | ||
@@ -301,3 +359,3 @@ } | ||
if (typeof dest === "string" || isValidExplicitDestination(dest)) { | ||
if (typeof dest === "string" || PDFLinkService.#isValidExplicitDestination(dest)) { | ||
this.goToDestination(dest); | ||
@@ -307,3 +365,3 @@ return; | ||
console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not ` + "a valid destination."); | ||
console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`); | ||
} | ||
@@ -354,3 +412,3 @@ } | ||
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`; | ||
this._pagesRefCache[refStr] = pageNum; | ||
this.#pagesRefCache.set(refStr, pageNum); | ||
} | ||
@@ -364,3 +422,3 @@ | ||
const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`; | ||
return this._pagesRefCache?.[refStr] || null; | ||
return this.#pagesRefCache.get(refStr) || null; | ||
} | ||
@@ -376,76 +434,76 @@ | ||
} | ||
static #isValidExplicitDestination(dest) { | ||
if (!Array.isArray(dest)) { | ||
return false; | ||
} | ||
exports.PDFLinkService = PDFLinkService; | ||
const destLength = dest.length; | ||
function isValidExplicitDestination(dest) { | ||
if (!Array.isArray(dest)) { | ||
return false; | ||
} | ||
if (destLength < 2) { | ||
return false; | ||
} | ||
const destLength = dest.length; | ||
const page = dest[0]; | ||
if (destLength < 2) { | ||
return false; | ||
} | ||
if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) { | ||
return false; | ||
} | ||
const page = dest[0]; | ||
const zoom = dest[1]; | ||
if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) { | ||
return false; | ||
} | ||
if (!(typeof zoom === "object" && typeof zoom.name === "string")) { | ||
return false; | ||
} | ||
const zoom = dest[1]; | ||
let allowNull = true; | ||
if (!(typeof zoom === "object" && typeof zoom.name === "string")) { | ||
return false; | ||
} | ||
switch (zoom.name) { | ||
case "XYZ": | ||
if (destLength !== 5) { | ||
return false; | ||
} | ||
let allowNull = true; | ||
break; | ||
switch (zoom.name) { | ||
case "XYZ": | ||
if (destLength !== 5) { | ||
return false; | ||
} | ||
case "Fit": | ||
case "FitB": | ||
return destLength === 2; | ||
break; | ||
case "FitH": | ||
case "FitBH": | ||
case "FitV": | ||
case "FitBV": | ||
if (destLength !== 3) { | ||
return false; | ||
} | ||
case "Fit": | ||
case "FitB": | ||
return destLength === 2; | ||
break; | ||
case "FitH": | ||
case "FitBH": | ||
case "FitV": | ||
case "FitBV": | ||
if (destLength !== 3) { | ||
case "FitR": | ||
if (destLength !== 6) { | ||
return false; | ||
} | ||
allowNull = false; | ||
break; | ||
default: | ||
return false; | ||
} | ||
} | ||
break; | ||
for (let i = 2; i < destLength; i++) { | ||
const param = dest[i]; | ||
case "FitR": | ||
if (destLength !== 6) { | ||
if (!(typeof param === "number" || allowNull && param === null)) { | ||
return false; | ||
} | ||
} | ||
allowNull = false; | ||
break; | ||
default: | ||
return false; | ||
return true; | ||
} | ||
for (let i = 2; i < destLength; i++) { | ||
const param = dest[i]; | ||
} | ||
if (!(typeof param === "number" || allowNull && param === null)) { | ||
return false; | ||
} | ||
} | ||
exports.PDFLinkService = PDFLinkService; | ||
return true; | ||
} | ||
class SimpleLinkService { | ||
@@ -477,3 +535,3 @@ constructor() { | ||
addLinkAttributes(link, url, newWindow = false) { | ||
(0, _pdf.addLinkAttributes)(link, { | ||
addLinkAttributes(link, { | ||
url, | ||
@@ -480,0 +538,0 @@ enabled: this.externalLinkEnabled |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -599,3 +599,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
const readableStream = pdfPage.streamTextContent({ | ||
normalizeWhitespace: true, | ||
includeMarkedContent: true | ||
@@ -697,4 +696,3 @@ }); | ||
}); | ||
const outputScale = (0, _ui_utils.getOutputScale)(ctx); | ||
this.outputScale = outputScale; | ||
const outputScale = this.outputScale = new _ui_utils.OutputScale(); | ||
@@ -707,3 +705,2 @@ if (this.useOnlyCssZoom) { | ||
outputScale.sy *= actualSizeViewport.height / viewport.height; | ||
outputScale.scaled = true; | ||
} | ||
@@ -718,3 +715,2 @@ | ||
outputScale.sy = maxScale; | ||
outputScale.scaled = true; | ||
this.hasRestrictedScaling = true; | ||
@@ -733,3 +729,3 @@ } else { | ||
this.paintedViewportMap.set(canvas, viewport); | ||
const transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0]; | ||
const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; | ||
const renderContext = { | ||
@@ -782,3 +778,3 @@ canvasContext: ctx, | ||
ensureNotCancelled(); | ||
const svgGfx = new _pdf.SVGGraphics(pdfPage.commonObjs, pdfPage.objs, _app_options.compatibilityParams.disableCreateObjectURL); | ||
const svgGfx = new _pdf.SVGGraphics(pdfPage.commonObjs, pdfPage.objs); | ||
return svgGfx.getSVG(opList, actualSizeViewport).then(svg => { | ||
@@ -785,0 +781,0 @@ ensureNotCancelled(); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -59,22 +59,10 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
request() { | ||
if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) { | ||
if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount || !this.container.requestFullscreen) { | ||
return false; | ||
} | ||
this._addFullscreenChangeListeners(); | ||
this._setSwitchInProgress(); | ||
this._notifyStateChange(); | ||
if (this.container.requestFullscreen) { | ||
this.container.requestFullscreen(); | ||
} else if (this.container.mozRequestFullScreen) { | ||
this.container.mozRequestFullScreen(); | ||
} else if (this.container.webkitRequestFullscreen) { | ||
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); | ||
} else { | ||
return false; | ||
} | ||
this.#addFullscreenChangeListeners(); | ||
this.#setSwitchInProgress(); | ||
this.#notifyStateChange(); | ||
this.container.requestFullscreen(); | ||
this.args = { | ||
@@ -89,3 +77,3 @@ pageNumber: this.pdfViewer.currentPageNumber, | ||
_mouseWheel(evt) { | ||
#mouseWheel(evt) { | ||
if (!this.active) { | ||
@@ -105,3 +93,3 @@ return; | ||
if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) { | ||
this._resetMouseScrollState(); | ||
this.#resetMouseScrollState(); | ||
} | ||
@@ -113,5 +101,3 @@ | ||
const totalDelta = this.mouseScrollDelta; | ||
this._resetMouseScrollState(); | ||
this.#resetMouseScrollState(); | ||
const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage(); | ||
@@ -125,7 +111,3 @@ | ||
get isFullscreen() { | ||
return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen); | ||
} | ||
_notifyStateChange() { | ||
#notifyStateChange() { | ||
let state = _ui_utils.PresentationModeState.NORMAL; | ||
@@ -145,3 +127,3 @@ | ||
_setSwitchInProgress() { | ||
#setSwitchInProgress() { | ||
if (this.switchInProgress) { | ||
@@ -152,11 +134,9 @@ clearTimeout(this.switchInProgress); | ||
this.switchInProgress = setTimeout(() => { | ||
this._removeFullscreenChangeListeners(); | ||
this.#removeFullscreenChangeListeners(); | ||
delete this.switchInProgress; | ||
this._notifyStateChange(); | ||
this.#notifyStateChange(); | ||
}, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS); | ||
} | ||
_resetSwitchInProgress() { | ||
#resetSwitchInProgress() { | ||
if (this.switchInProgress) { | ||
@@ -168,9 +148,6 @@ clearTimeout(this.switchInProgress); | ||
_enter() { | ||
#enter() { | ||
this.active = true; | ||
this._resetSwitchInProgress(); | ||
this._notifyStateChange(); | ||
this.#resetSwitchInProgress(); | ||
this.#notifyStateChange(); | ||
this.container.classList.add(ACTIVE_SELECTOR); | ||
@@ -183,7 +160,4 @@ setTimeout(() => { | ||
}, 0); | ||
this._addWindowListeners(); | ||
this._showControls(); | ||
this.#addWindowListeners(); | ||
this.#showControls(); | ||
this.contextMenuOpen = false; | ||
@@ -193,3 +167,3 @@ window.getSelection().removeAllRanges(); | ||
_exit() { | ||
#exit() { | ||
const pageNumber = this.pdfViewer.currentPageNumber; | ||
@@ -199,7 +173,4 @@ this.container.classList.remove(ACTIVE_SELECTOR); | ||
this.active = false; | ||
this._removeFullscreenChangeListeners(); | ||
this._notifyStateChange(); | ||
this.#removeFullscreenChangeListeners(); | ||
this.#notifyStateChange(); | ||
this.pdfViewer.scrollMode = this.args.scrollMode; | ||
@@ -211,13 +182,9 @@ this.pdfViewer.spreadMode = this.args.spreadMode; | ||
}, 0); | ||
this._removeWindowListeners(); | ||
this._hideControls(); | ||
this._resetMouseScrollState(); | ||
this.#removeWindowListeners(); | ||
this.#hideControls(); | ||
this.#resetMouseScrollState(); | ||
this.contextMenuOpen = false; | ||
} | ||
_mouseDown(evt) { | ||
#mouseDown(evt) { | ||
if (this.contextMenuOpen) { | ||
@@ -244,7 +211,7 @@ this.contextMenuOpen = false; | ||
_contextMenu() { | ||
#contextMenu() { | ||
this.contextMenuOpen = true; | ||
} | ||
_showControls() { | ||
#showControls() { | ||
if (this.controlsTimeout) { | ||
@@ -262,3 +229,3 @@ clearTimeout(this.controlsTimeout); | ||
_hideControls() { | ||
#hideControls() { | ||
if (!this.controlsTimeout) { | ||
@@ -273,3 +240,3 @@ return; | ||
_resetMouseScrollState() { | ||
#resetMouseScrollState() { | ||
this.mouseScrollTimeStamp = 0; | ||
@@ -279,3 +246,3 @@ this.mouseScrollDelta = 0; | ||
_touchSwipe(evt) { | ||
#touchSwipe(evt) { | ||
if (!this.active) { | ||
@@ -336,9 +303,9 @@ return; | ||
_addWindowListeners() { | ||
this.showControlsBind = this._showControls.bind(this); | ||
this.mouseDownBind = this._mouseDown.bind(this); | ||
this.mouseWheelBind = this._mouseWheel.bind(this); | ||
this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this); | ||
this.contextMenuBind = this._contextMenu.bind(this); | ||
this.touchSwipeBind = this._touchSwipe.bind(this); | ||
#addWindowListeners() { | ||
this.showControlsBind = this.#showControls.bind(this); | ||
this.mouseDownBind = this.#mouseDown.bind(this); | ||
this.mouseWheelBind = this.#mouseWheel.bind(this); | ||
this.resetMouseScrollStateBind = this.#resetMouseScrollState.bind(this); | ||
this.contextMenuBind = this.#contextMenu.bind(this); | ||
this.touchSwipeBind = this.#touchSwipe.bind(this); | ||
window.addEventListener("mousemove", this.showControlsBind); | ||
@@ -356,3 +323,3 @@ window.addEventListener("mousedown", this.mouseDownBind); | ||
_removeWindowListeners() { | ||
#removeWindowListeners() { | ||
window.removeEventListener("mousemove", this.showControlsBind); | ||
@@ -376,21 +343,17 @@ window.removeEventListener("mousedown", this.mouseDownBind); | ||
_fullscreenChange() { | ||
if (this.isFullscreen) { | ||
this._enter(); | ||
#fullscreenChange() { | ||
if (document.fullscreenElement) { | ||
this.#enter(); | ||
} else { | ||
this._exit(); | ||
this.#exit(); | ||
} | ||
} | ||
_addFullscreenChangeListeners() { | ||
this.fullscreenChangeBind = this._fullscreenChange.bind(this); | ||
#addFullscreenChangeListeners() { | ||
this.fullscreenChangeBind = this.#fullscreenChange.bind(this); | ||
window.addEventListener("fullscreenchange", this.fullscreenChangeBind); | ||
window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind); | ||
window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind); | ||
} | ||
_removeFullscreenChangeListeners() { | ||
#removeFullscreenChangeListeners() { | ||
window.removeEventListener("fullscreenchange", this.fullscreenChangeBind); | ||
window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind); | ||
window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind); | ||
delete this.fullscreenChangeBind; | ||
@@ -397,0 +360,0 @@ } |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -34,4 +34,2 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
var _app_options = require("./app_options.js"); | ||
var _print_utils = require("./print_utils.js"); | ||
@@ -156,3 +154,3 @@ | ||
if ("toBlob" in scratchCanvas && !_app_options.compatibilityParams.disableCreateObjectURL) { | ||
if ("toBlob" in scratchCanvas) { | ||
scratchCanvas.toBlob(function (blob) { | ||
@@ -159,0 +157,0 @@ img.src = URL.createObjectURL(blob); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -204,3 +204,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
const outputScale = (0, _ui_utils.getOutputScale)(ctx); | ||
const outputScale = new _ui_utils.OutputScale(); | ||
canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0; | ||
@@ -207,0 +207,0 @@ canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -76,2 +76,8 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
Object.defineProperty(exports, "LinkTarget", { | ||
enumerable: true, | ||
get: function () { | ||
return _pdf_link_service.LinkTarget; | ||
} | ||
}); | ||
Object.defineProperty(exports, "NullL10n", { | ||
@@ -155,2 +161,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "parseQueryString", { | ||
enumerable: true, | ||
get: function () { | ||
return _ui_utils.parseQueryString; | ||
} | ||
}); | ||
@@ -161,2 +173,4 @@ var _default_factory = require("./default_factory.js"); | ||
var _ui_utils = require("./ui_utils.js"); | ||
var _pdf_viewer = require("./pdf_viewer.js"); | ||
@@ -182,4 +196,2 @@ | ||
var _ui_utils = require("./ui_utils.js"); | ||
var _struct_tree_layer_builder = require("./struct_tree_layer_builder.js"); | ||
@@ -191,3 +203,3 @@ | ||
const pdfjsVersion = '2.12.313'; | ||
const pdfjsBuild = 'a2ae56f39'; | ||
const pdfjsVersion = '2.13.216'; | ||
const pdfjsBuild = '399a0ec60'; |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -28,3 +28,3 @@ * Licensed under the Apache License, Version 2.0 (the "License"); | ||
}); | ||
exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RenderingStates = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.AutoPrintRegExp = void 0; | ||
exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RenderingStates = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.OutputScale = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.AutoPrintRegExp = void 0; | ||
exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes; | ||
@@ -36,3 +36,2 @@ exports.apiPageModeToSidebarView = apiPageModeToSidebarView; | ||
exports.getActiveOrFocusedElement = getActiveOrFocusedElement; | ||
exports.getOutputScale = getOutputScale; | ||
exports.getPageSizeInches = getPageSizeInches; | ||
@@ -48,2 +47,3 @@ exports.getVisibleElements = getVisibleElements; | ||
exports.parseQueryString = parseQueryString; | ||
exports.removeNullCharacters = removeNullCharacters; | ||
exports.roundToDivide = roundToDivide; | ||
@@ -123,13 +123,17 @@ exports.scrollIntoView = scrollIntoView; | ||
function getOutputScale(ctx) { | ||
const devicePixelRatio = window.devicePixelRatio || 1; | ||
const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1; | ||
const pixelRatio = devicePixelRatio / backingStoreRatio; | ||
return { | ||
sx: pixelRatio, | ||
sy: pixelRatio, | ||
scaled: pixelRatio !== 1 | ||
}; | ||
class OutputScale { | ||
constructor() { | ||
const pixelRatio = window.devicePixelRatio || 1; | ||
this.sx = pixelRatio; | ||
this.sy = pixelRatio; | ||
} | ||
get scaled() { | ||
return this.sx !== 1 || this.sy !== 1; | ||
} | ||
} | ||
exports.OutputScale = OutputScale; | ||
function scrollIntoView(element, spot, scrollMatches = false) { | ||
@@ -220,4 +224,20 @@ let parent = element.offsetParent; | ||
function binarySearchFirstItem(items, condition) { | ||
let minIndex = 0; | ||
const NullCharactersRegExp = /\x00/g; | ||
const InvisibleCharactersRegExp = /[\x01-\x1F]/g; | ||
function removeNullCharacters(str, replaceInvisible = false) { | ||
if (typeof str !== "string") { | ||
console.error(`The argument must be a string.`); | ||
return str; | ||
} | ||
if (replaceInvisible) { | ||
str = str.replace(InvisibleCharactersRegExp, " "); | ||
} | ||
return str.replace(NullCharactersRegExp, ""); | ||
} | ||
function binarySearchFirstItem(items, condition, start = 0) { | ||
let minIndex = start; | ||
let maxIndex = items.length - 1; | ||
@@ -224,0 +244,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright 2021 Mozilla Foundation | ||
* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -8,0 +8,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
{ | ||
"name": "pdfjs-dist", | ||
"version": "2.12.313", | ||
"version": "2.13.216", | ||
"main": "build/pdf.js", | ||
@@ -15,2 +15,5 @@ "types": "types/src/pdf.d.ts", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"web-streams-polyfill": "^3.2.0" | ||
}, | ||
"peerDependencies": { | ||
@@ -17,0 +20,0 @@ "worker-loader": "^3.0.8" |
@@ -11,6 +11,5 @@ # PDF.js | ||
For usage with older browsers or environments, without support for modern | ||
features such as e.g. `async`/`await`, `ReadableStream`, optional chaining, | ||
nullish coalescing, and private `class` fields/methods; please see the `legacy` | ||
folder. | ||
features such as `async`/`await`, optional chaining, nullish coalescing, | ||
and private `class` fields/methods; please see the `legacy/` folder. | ||
See https://github.com/mozilla/pdf.js for learning and contributing. |
@@ -82,4 +82,4 @@ export type PDFPageProxy = import("./api").PDFPageProxy; | ||
public static update(parameters: AnnotationLayerParameters): void; | ||
static "__#3@#setAnnotationCanvasMap"(div: any, annotationCanvasMap: any): void; | ||
static "__#4@#setAnnotationCanvasMap"(div: any, annotationCanvasMap: any): void; | ||
} | ||
import { AnnotationStorage } from "./annotation_storage.js"; |
@@ -234,7 +234,2 @@ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; | ||
/** | ||
* - Replaces all occurrences of | ||
* whitespace with standard spaces (0x20). The default value is `false`. | ||
*/ | ||
normalizeWhitespace: boolean; | ||
/** | ||
* - Do not attempt to combine | ||
@@ -1022,4 +1017,2 @@ * same line {@link TextItem }'s. The default value is `false`. | ||
* @typedef {Object} getTextContentParameters | ||
* @property {boolean} normalizeWhitespace - Replaces all occurrences of | ||
* whitespace with standard spaces (0x20). The default value is `false`. | ||
* @property {boolean} disableCombineTextItems - Do not attempt to combine | ||
@@ -1174,3 +1167,4 @@ * same line {@link TextItem}'s. The default value is `false`. | ||
_pdfBug: boolean; | ||
commonObjs: any; | ||
/** @type {PDFObjects} */ | ||
commonObjs: PDFObjects; | ||
objs: PDFObjects; | ||
@@ -1243,7 +1237,13 @@ cleanupAfterRender: boolean; | ||
/** | ||
* NOTE: All occurrences of whitespace will be replaced by | ||
* standard spaces (0x20). | ||
* | ||
* @param {getTextContentParameters} params - getTextContent parameters. | ||
* @returns {ReadableStream} Stream for reading text content chunks. | ||
*/ | ||
streamTextContent({ normalizeWhitespace, disableCombineTextItems, includeMarkedContent, }?: getTextContentParameters): ReadableStream; | ||
streamTextContent({ disableCombineTextItems, includeMarkedContent, }?: getTextContentParameters): ReadableStream; | ||
/** | ||
* NOTE: All occurrences of whitespace will be replaced by | ||
* standard spaces (0x20). | ||
* | ||
* @param {getTextContentParameters} params - getTextContent parameters. | ||
@@ -1407,12 +1407,5 @@ * @returns {Promise<TextContent>} A promise that is resolved with a | ||
* a worker. This class implements some basic methods to manage these objects. | ||
* @ignore | ||
*/ | ||
declare class PDFObjects { | ||
_objs: any; | ||
/** | ||
* Ensures there is an object defined for `objId`. | ||
* @private | ||
*/ | ||
private _ensureObj; | ||
/** | ||
* If called *without* callback, this returns the data of `objId` but the | ||
@@ -1424,12 +1417,24 @@ * object needs to be resolved. If it isn't, this method throws. | ||
* and the object is already resolved, the callback gets called right away. | ||
* | ||
* @param {string} objId | ||
* @param {function} [callback] | ||
* @returns {any} | ||
*/ | ||
get(objId: any, callback?: null): any; | ||
has(objId: any): any; | ||
get(objId: string, callback?: Function | undefined): any; | ||
/** | ||
* @param {string} objId | ||
* @returns {boolean} | ||
*/ | ||
has(objId: string): boolean; | ||
/** | ||
* Resolves the object `objId` with optional `data`. | ||
* | ||
* @param {string} objId | ||
* @param {any} [data] | ||
*/ | ||
resolve(objId: any, data: any): void; | ||
resolve(objId: string, data?: any): void; | ||
clear(): void; | ||
#private; | ||
} | ||
import { MessageHandler } from "../shared/message_handler.js"; | ||
export {}; |
@@ -62,2 +62,3 @@ export class CanvasGraphics { | ||
setGState(states: any): void; | ||
get inSMaskMode(): boolean; | ||
checkSMaskState(): void; | ||
@@ -64,0 +65,0 @@ /** |
@@ -1,2 +0,1 @@ | ||
export type ExternalLinkParameters = any; | ||
export type PageViewportParameters = { | ||
@@ -59,19 +58,2 @@ /** | ||
}; | ||
/** | ||
* @typedef ExternalLinkParameters | ||
* @typedef {Object} ExternalLinkParameters | ||
* @property {string} url - An absolute URL. | ||
* @property {LinkTarget} [target] - The link target. The default value is | ||
* `LinkTarget.NONE`. | ||
* @property {string} [rel] - The link relationship. The default value is | ||
* `DEFAULT_LINK_REL`. | ||
* @property {boolean} [enabled] - Whether the link should be enabled. The | ||
* default value is true. | ||
*/ | ||
/** | ||
* Adds various attributes (href, title, target, rel) to hyperlinks. | ||
* @param {HTMLAnchorElement} link - The link element. | ||
* @param {ExternalLinkParameters} params | ||
*/ | ||
export function addLinkAttributes(link: HTMLAnchorElement, { url, target, rel, enabled }?: any): void; | ||
export function deprecated(details: any): void; | ||
@@ -114,9 +96,2 @@ export class DOMCanvasFactory extends BaseCanvasFactory { | ||
export function isValidFetchUrl(url: any, baseUrl: any): boolean; | ||
export namespace LinkTarget { | ||
const NONE: number; | ||
const SELF: number; | ||
const BLANK: number; | ||
const PARENT: number; | ||
const TOP: number; | ||
} | ||
/** | ||
@@ -225,5 +200,6 @@ * @param {string} src | ||
} | ||
export namespace PixelsPerInch { | ||
const CSS: number; | ||
const PDF: number; | ||
export class PixelsPerInch { | ||
static CSS: number; | ||
static PDF: number; | ||
static PDF_TO_CSS_UNITS: number; | ||
} | ||
@@ -230,0 +206,0 @@ declare const RenderingCancelledException_base: any; |
@@ -5,24 +5,30 @@ export type PDFDocumentLoadingTask = import("./display/api").PDFDocumentLoadingTask; | ||
export type RenderTask = import("./display/api").RenderTask; | ||
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"; | ||
import { loadScript } from "./display/display_utils.js"; | ||
import { PDFDateString } from "./display/display_utils.js"; | ||
import { PixelsPerInch } from "./display/display_utils.js"; | ||
import { RenderingCancelledException } from "./display/display_utils.js"; | ||
import { getXfaPageViewport } from "./display/display_utils.js"; | ||
export type PageViewport = import("./display/display_utils").PageViewport; | ||
import { AnnotationLayer } from "./display/annotation_layer.js"; | ||
import { AnnotationMode } from "./shared/util.js"; | ||
import { build } from "./display/api.js"; | ||
import { CMapCompressionType } from "./shared/util.js"; | ||
import { createObjectURL } from "./shared/util.js"; | ||
import { createPromiseCapability } from "./shared/util.js"; | ||
import { createValidAbsoluteUrl } from "./shared/util.js"; | ||
import { getDocument } from "./display/api.js"; | ||
import { getFilenameFromUrl } from "./display/display_utils.js"; | ||
import { getPdfFilenameFromUrl } from "./display/display_utils.js"; | ||
import { getXfaPageViewport } from "./display/display_utils.js"; | ||
import { GlobalWorkerOptions } from "./display/worker_options.js"; | ||
import { InvalidPDFException } from "./shared/util.js"; | ||
import { isPdfFile } from "./display/display_utils.js"; | ||
import { loadScript } from "./display/display_utils.js"; | ||
import { LoopbackPort } from "./display/api.js"; | ||
import { MissingPDFException } from "./shared/util.js"; | ||
import { OPS } from "./shared/util.js"; | ||
import { PasswordResponses } from "./shared/util.js"; | ||
import { PDFDataRangeTransport } from "./display/api.js"; | ||
import { PDFDateString } from "./display/display_utils.js"; | ||
import { PDFWorker } from "./display/api.js"; | ||
import { PermissionFlag } from "./shared/util.js"; | ||
import { removeNullCharacters } from "./shared/util.js"; | ||
import { PixelsPerInch } from "./display/display_utils.js"; | ||
import { RenderingCancelledException } from "./display/display_utils.js"; | ||
import { renderTextLayer } from "./display/text_layer.js"; | ||
import { shadow } from "./shared/util.js"; | ||
import { SVGGraphics } from "./display/svg.js"; | ||
import { UnexpectedResponseException } from "./shared/util.js"; | ||
@@ -32,13 +38,4 @@ import { UNSUPPORTED_FEATURES } from "./shared/util.js"; | ||
import { VerbosityLevel } from "./shared/util.js"; | ||
import { build } from "./display/api.js"; | ||
import { getDocument } from "./display/api.js"; | ||
import { LoopbackPort } from "./display/api.js"; | ||
import { PDFDataRangeTransport } from "./display/api.js"; | ||
import { PDFWorker } from "./display/api.js"; | ||
import { version } from "./display/api.js"; | ||
import { AnnotationLayer } from "./display/annotation_layer.js"; | ||
import { GlobalWorkerOptions } from "./display/worker_options.js"; | ||
import { renderTextLayer } from "./display/text_layer.js"; | ||
import { SVGGraphics } from "./display/svg.js"; | ||
import { XfaLayer } from "./display/xfa_layer.js"; | ||
export { addLinkAttributes, getFilenameFromUrl, getPdfFilenameFromUrl, isPdfFile, LinkTarget, loadScript, PDFDateString, PixelsPerInch, RenderingCancelledException, getXfaPageViewport, AnnotationMode, CMapCompressionType, createObjectURL, createPromiseCapability, createValidAbsoluteUrl, InvalidPDFException, MissingPDFException, OPS, PasswordResponses, PermissionFlag, removeNullCharacters, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, Util, VerbosityLevel, build, getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker, version, AnnotationLayer, GlobalWorkerOptions, renderTextLayer, SVGGraphics, XfaLayer }; | ||
export { AnnotationLayer, AnnotationMode, build, CMapCompressionType, createPromiseCapability, createValidAbsoluteUrl, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getXfaPageViewport, GlobalWorkerOptions, InvalidPDFException, isPdfFile, loadScript, LoopbackPort, MissingPDFException, OPS, PasswordResponses, PDFDataRangeTransport, PDFDateString, PDFWorker, PermissionFlag, PixelsPerInch, RenderingCancelledException, renderTextLayer, shadow, SVGGraphics, UnexpectedResponseException, UNSUPPORTED_FEATURES, Util, VerbosityLevel, version, XfaLayer }; |
@@ -167,3 +167,2 @@ /** | ||
} | ||
export function createObjectURL(data: any, contentType?: string, forceDataSchema?: boolean): string; | ||
/** | ||
@@ -242,8 +241,5 @@ * Promise Capability object. | ||
export function isAscii(str: any): boolean; | ||
export function isBool(v: any): boolean; | ||
export namespace IsEvalSupportedCached { } | ||
export namespace IsLittleEndianCached { } | ||
export function isNum(v: any): boolean; | ||
export function isSameOrigin(baseUrl: any, otherUrl: any): boolean; | ||
export function isString(v: any): boolean; | ||
declare const MissingPDFException_base: any; | ||
@@ -375,6 +371,2 @@ export class MissingPDFException extends MissingPDFException_base { | ||
} | ||
/** | ||
* @param {string} str | ||
*/ | ||
export function removeNullCharacters(str: string, replaceInvisible?: boolean): string; | ||
export namespace RenderingIntentFlag { | ||
@@ -381,0 +373,0 @@ export const ANY: number; |
@@ -82,2 +82,3 @@ export type PDFDocumentProxy = import("../src/display/api").PDFDocumentProxy; | ||
_pageDiffs: any[] | undefined; | ||
_hasDiacritics: any[] | undefined; | ||
_matchesCountTotal: number | undefined; | ||
@@ -95,9 +96,2 @@ _pagesToSearch: number | null | undefined; | ||
/** | ||
* Helper for multi-term search that fills the `matchesWithLength` array | ||
* and handles cases where one search term includes another search term (for | ||
* example, "tamed tame" or "this is"). It looks for intersecting terms in | ||
* the `matches` and keeps elements with a longer match length. | ||
*/ | ||
_prepareMatches(matchesWithLength: any, matches: any, matchesLength: any): void; | ||
/** | ||
* Determine if the search query constitutes a "whole word", by comparing the | ||
@@ -107,4 +101,4 @@ * first/last character type with the preceding/following character type. | ||
_isEntireWord(content: any, startIdx: any, length: any): boolean; | ||
_calculatePhraseMatch(query: any, pageIndex: any, pageContent: any, pageDiffs: any, entireWord: any): void; | ||
_calculateWordMatch(query: any, pageIndex: any, pageContent: any, pageDiffs: any, entireWord: any): void; | ||
_calculateRegExpMatch(query: any, entireWord: any, pageIndex: any, pageContent: any): void; | ||
_convertToRegExpString(query: any, hasDiacritics: any): any[]; | ||
_calculateMatch(pageIndex: any): void; | ||
@@ -111,0 +105,0 @@ _extractText(): void; |
@@ -0,1 +1,2 @@ | ||
export type ExternalLinkParameters = any; | ||
export type EventBus = import("./event_utils").EventBus; | ||
@@ -26,2 +27,9 @@ export type IPDFLinkService = import("./interfaces").IPDFLinkService; | ||
}; | ||
export namespace LinkTarget { | ||
const NONE: number; | ||
const SELF: number; | ||
const BLANK: number; | ||
const PARENT: number; | ||
const TOP: number; | ||
} | ||
/** | ||
@@ -45,2 +53,3 @@ * @typedef {Object} PDFLinkServiceOptions | ||
export class PDFLinkService implements IPDFLinkService { | ||
static "__#5@#isValidExplicitDestination"(dest: any): boolean; | ||
/** | ||
@@ -59,3 +68,2 @@ * @param {PDFLinkServiceOptions} options | ||
pdfHistory: any; | ||
_pagesRefCache: any; | ||
setDocument(pdfDocument: any, baseUrl?: null): void; | ||
@@ -85,6 +93,2 @@ setViewer(pdfViewer: any): void; | ||
/** | ||
* @private | ||
*/ | ||
private _goToDestinationHelper; | ||
/** | ||
* This method will, when available, also update the browser history. | ||
@@ -102,3 +106,3 @@ * | ||
/** | ||
* Wrapper around the `addLinkAttributes`-function in the API. | ||
* Wrapper around the `addLinkAttributes` helper function. | ||
* @param {HTMLAnchorElement} link | ||
@@ -135,5 +139,5 @@ * @param {string} url | ||
/** | ||
* @private | ||
* @ignore | ||
*/ | ||
private _cachedPageNumber; | ||
_cachedPageNumber(pageRef: any): any; | ||
/** | ||
@@ -147,2 +151,3 @@ * @param {number} pageNumber | ||
isPageCached(pageNumber: number): any; | ||
#private; | ||
} | ||
@@ -149,0 +154,0 @@ /** |
@@ -189,3 +189,3 @@ export type PageViewport = import("../src/display/display_utils").PageViewport; | ||
canvas: HTMLCanvasElement | undefined; | ||
outputScale: Object | undefined; | ||
outputScale: OutputScale | undefined; | ||
paintOnSvg(wrapper: any): { | ||
@@ -203,1 +203,2 @@ promise: any; | ||
} | ||
import { OutputScale } from "./ui_utils.js"; |
@@ -113,5 +113,5 @@ export type IL10n = import("./interfaces").IL10n; | ||
export class TempImageFactory { | ||
static "__#4@#tempCanvas": null; | ||
static "__#6@#tempCanvas": null; | ||
static getCanvas(width: any, height: any): (HTMLCanvasElement | CanvasRenderingContext2D | null)[]; | ||
static destroyCanvas(): void; | ||
} |
@@ -9,3 +9,5 @@ import { AnnotationLayerBuilder } from "./annotation_layer_builder.js"; | ||
import { GenericL10n } from "./genericl10n.js"; | ||
import { LinkTarget } from "./pdf_link_service.js"; | ||
import { NullL10n } from "./l10n_utils.js"; | ||
import { parseQueryString } from "./ui_utils.js"; | ||
import { PDFFindController } from "./pdf_find_controller.js"; | ||
@@ -23,2 +25,2 @@ import { PDFHistory } from "./pdf_history.js"; | ||
import { XfaLayerBuilder } from "./xfa_layer_builder.js"; | ||
export { AnnotationLayerBuilder, DefaultAnnotationLayerFactory, DefaultStructTreeLayerFactory, DefaultTextLayerFactory, DefaultXfaLayerFactory, DownloadManager, EventBus, GenericL10n, NullL10n, PDFFindController, PDFHistory, PDFLinkService, PDFPageView, PDFScriptingManager, PDFSinglePageViewer, PDFViewer, ProgressBar, SimpleLinkService, StructTreeLayerBuilder, TextLayerBuilder, XfaLayerBuilder }; | ||
export { AnnotationLayerBuilder, DefaultAnnotationLayerFactory, DefaultStructTreeLayerFactory, DefaultTextLayerFactory, DefaultXfaLayerFactory, DownloadManager, EventBus, GenericL10n, LinkTarget, NullL10n, parseQueryString, PDFFindController, PDFHistory, PDFLinkService, PDFPageView, PDFScriptingManager, PDFSinglePageViewer, PDFViewer, ProgressBar, SimpleLinkService, StructTreeLayerBuilder, TextLayerBuilder, XfaLayerBuilder }; |
@@ -96,3 +96,3 @@ export type GetPageSizeInchesParameters = { | ||
*/ | ||
export function binarySearchFirstItem(items: any, condition: any): number; | ||
export function binarySearchFirstItem(items: any, condition: any, start?: number): number; | ||
export const DEFAULT_SCALE: 1; | ||
@@ -111,9 +111,2 @@ export const DEFAULT_SCALE_DELTA: 1.1; | ||
/** | ||
* Returns scale factor for the canvas. It makes sense for the HiDPI displays. | ||
* @returns {Object} The object with horizontal (sx) and vertical (sy) | ||
* scales. The scaled property is set to false if scaling is | ||
* not required, true otherwise. | ||
*/ | ||
export function getOutputScale(ctx: any): Object; | ||
/** | ||
* @typedef {Object} GetPageSizeInchesParameters | ||
@@ -184,2 +177,19 @@ * @property {number[]} view | ||
/** | ||
* Scale factors for the canvas, necessary with HiDPI displays. | ||
*/ | ||
export class OutputScale { | ||
/** | ||
* @type {number} Horizontal scale. | ||
*/ | ||
sx: number; | ||
/** | ||
* @type {number} Vertical scale. | ||
*/ | ||
sy: number; | ||
/** | ||
* @type {boolean} Returns `true` when scaling is required, `false` otherwise. | ||
*/ | ||
get scaled(): boolean; | ||
} | ||
/** | ||
* Helper function to parse query string (e.g. ?param1=value¶m2=...). | ||
@@ -217,2 +227,7 @@ * @param {string} | ||
} | ||
/** | ||
* @param {string} str | ||
* @param {boolean} [replaceInvisible] | ||
*/ | ||
export function removeNullCharacters(str: string, replaceInvisible?: boolean | undefined): string; | ||
export namespace RendererType { | ||
@@ -219,0 +234,0 @@ const CANVAS: string; |
@@ -1,2 +0,2 @@ | ||
/* Copyright 2021 Mozilla Foundation | ||
/* Copyright 2022 Mozilla Foundation | ||
* | ||
@@ -3,0 +3,0 @@ * Licensed under the Apache License, Version 2.0 (the "License"); |
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 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 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 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
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
537
35465051
2
323673
4
15
80
+ Addedweb-streams-polyfill@^3.2.0
+ Addedbrowserslist@4.23.0(transitive)
+ Addedcaniuse-lite@1.0.30001629(transitive)
+ Addedelectron-to-chromium@1.4.790(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
- Removedbrowserslist@4.23.1(transitive)
- Removedcaniuse-lite@1.0.30001632(transitive)
- Removedelectron-to-chromium@1.4.796(transitive)