mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Fix broken/missing JSDocs and typedef
s, to allow updating TypeScript to the latest version (issue 14342)
This patch circumvents the issues seen when trying to update TypeScript to version `4.5`, by "simply" fixing the broken/missing JSDocs and `typedef`s such that `gulp typestest` now passes. As always, given that I don't really know anything about TypeScript, I cannot tell if this is a "correct" and/or proper way of doing things; we'll need TypeScript users to help out with testing! *Please note:* I'm sorry about the size of this patch, but given how intertwined all of this unfortunately is it just didn't seem easy to split this into smaller parts. However, one good thing about this TypeScript update is that it helped uncover a number of pre-existing bugs in our JSDocs comments.
This commit is contained in:
parent
d3e1d7090a
commit
e0dba504d2
23 changed files with 232 additions and 74 deletions
|
@ -13,6 +13,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @typedef {import("./api").PDFPageProxy} PDFPageProxy */
|
||||
/** @typedef {import("./display_utils").PageViewport} PageViewport */
|
||||
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
|
||||
/** @typedef {import("../../web/interfaces").IPDFLinkService} IPDFLinkService */
|
||||
|
||||
import {
|
||||
AnnotationBorderStyleType,
|
||||
AnnotationType,
|
||||
|
@ -39,10 +44,10 @@ const GetElementsByNameSet = new WeakSet();
|
|||
* @typedef {Object} AnnotationElementParameters
|
||||
* @property {Object} data
|
||||
* @property {HTMLDivElement} layer
|
||||
* @property {PDFPage} page
|
||||
* @property {PDFPageProxy} page
|
||||
* @property {PageViewport} viewport
|
||||
* @property {IPDFLinkService} linkService
|
||||
* @property {DownloadManager} downloadManager
|
||||
* @property {IDownloadManager} downloadManager
|
||||
* @property {AnnotationStorage} [annotationStorage]
|
||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||
* for annotation icons. Include trailing slash.
|
||||
|
@ -1700,7 +1705,7 @@ class PopupElement {
|
|||
(!this.contentsObj?.str || this.contentsObj.str === this.richText.str)
|
||||
) {
|
||||
XfaLayer.render({
|
||||
xfa: this.richText.html,
|
||||
xfaHtml: this.richText.html,
|
||||
intent: "richText",
|
||||
div: popup,
|
||||
});
|
||||
|
@ -2302,15 +2307,16 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||
* @property {PageViewport} viewport
|
||||
* @property {HTMLDivElement} div
|
||||
* @property {Array} annotations
|
||||
* @property {PDFPage} page
|
||||
* @property {PDFPageProxy} page
|
||||
* @property {IPDFLinkService} linkService
|
||||
* @property {DownloadManager} downloadManager
|
||||
* @property {IDownloadManager} downloadManager
|
||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||
* for annotation icons. Include trailing slash.
|
||||
* @property {boolean} renderForms
|
||||
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
||||
* @property {boolean} [hasJSActions] - Some fields have JS actions.
|
||||
* The default value is `false`.
|
||||
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
|
||||
*/
|
||||
|
||||
class AnnotationLayer {
|
||||
|
|
|
@ -1168,8 +1168,8 @@ class PDFDocumentProxy {
|
|||
* created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
|
||||
* the configuration will be fetched automatically with the default visibility
|
||||
* states set.
|
||||
* @property {Map<string, Canvas>} [annotationCanvasMap] - Map some annotation
|
||||
* ids with canvases used to render them.
|
||||
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some
|
||||
* annotation ids with canvases used to render them.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,9 +13,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @typedef {import("./display_utils").PageViewport} PageViewport */
|
||||
/** @typedef {import("../../web/interfaces").IPDFLinkService} IPDFLinkService */
|
||||
|
||||
import { warn } from "../shared/util.js";
|
||||
import { XfaText } from "./xfa_text.js";
|
||||
|
||||
/**
|
||||
* @typedef {Object} XfaLayerParameters
|
||||
* @property {PageViewport} viewport
|
||||
* @property {HTMLDivElement} div
|
||||
* @property {Object} xfaHtml
|
||||
* @property {AnnotationStorage} [annotationStorage]
|
||||
* @property {IPDFLinkService} linkService
|
||||
* @property {string} [intent] - (default value is 'display').
|
||||
*/
|
||||
|
||||
class XfaLayer {
|
||||
static setupStorage(html, id, element, storage, intent) {
|
||||
const storedData = storage.getValue(id, { value: null });
|
||||
|
@ -143,10 +156,15 @@ class XfaLayer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the XFA layer.
|
||||
*
|
||||
* @param {XfaLayerParameters} parameters
|
||||
*/
|
||||
static render(parameters) {
|
||||
const storage = parameters.annotationStorage;
|
||||
const linkService = parameters.linkService;
|
||||
const root = parameters.xfa;
|
||||
const root = parameters.xfaHtml;
|
||||
const intent = parameters.intent || "display";
|
||||
const rootHtml = document.createElement(root.name);
|
||||
if (root.attributes) {
|
||||
|
@ -252,11 +270,9 @@ class XfaLayer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the xfa layer.
|
||||
* Update the XFA layer.
|
||||
*
|
||||
* @public
|
||||
* @param {XfaLayerParameters} parameters
|
||||
* @memberof XfaLayer
|
||||
*/
|
||||
static update(parameters) {
|
||||
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue