Improve the API documentation for PDFDocumentLoadingTask
This commit: - formats the documentation block according to the standards; - replaces the callback definitions with the `function` type (we have that for other definitions already and the callback type was not rendered correctly by JSDoc); - synchronizes the type documentation and the class documentation; - fixes the documentation by making it easier to read and making sure that all optional properties are indicated as such; - uses the `@link` tag to indicate links to other code. The `typestest` still passes and JSDoc now renders this class correctly.
This commit is contained in:
parent
7e759c6e2b
commit
3116216e1d
@ -429,39 +429,24 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
* after which individual pages can be rendered.
|
* after which individual pages can be rendered.
|
||||||
*
|
*
|
||||||
* @typedef {Object} PDFDocumentLoadingTask
|
* @typedef {Object} PDFDocumentLoadingTask
|
||||||
* @property {string} docId
|
* @property {string} docId - Unique identifier for the document loading task.
|
||||||
* Unique document loading task id -- used in MessageHandlers.
|
* @property {boolean} destroyed - Whether the loading task is destroyed or not.
|
||||||
* @property {boolean} destroyed
|
* @property {function} [onPassword] - Callback to request a password if a wrong
|
||||||
* Shows if loading task is destroyed.
|
* or no password was provided. The callback receives two parameters: a
|
||||||
* @property {cbOnPassword} [onPassword]
|
* function that should be called with the new password, and a reason (see
|
||||||
* Callback to request a password if wrong or no password was provided.
|
* {@link PasswordResponses}).
|
||||||
* The callback receives two parameters: function that needs to be called
|
* @property {function} [onProgress] - Callback to be able to monitor the
|
||||||
* with new password and reason (see {PasswordResponses}).
|
* loading progress of the PDF file (necessary to implement e.g. a loading
|
||||||
* @property {cbOnProgress} onProgress
|
* bar). The callback receives an {Object} with the properties `loaded`
|
||||||
* Callback to be able to monitor the loading progress of the PDF file
|
* ({number}) and `total` ({number}) that indicate how many bytes are loaded.
|
||||||
* (necessary to implement e.g. a loading bar). The callback receives
|
* @property {function} [onUnsupportedFeature] - Callback for when an
|
||||||
* an {Object} with the properties: {number} loaded and {number} total.
|
* unsupported feature is used in the PDF document. The callback receives an
|
||||||
* @property {cbOnUnsupportedFeature} onUnsupportedFeature
|
* {@link UNSUPPORTED_FEATURES} argument.
|
||||||
* Callback for when an unsupported feature is used in the PDF document.
|
* @property {Promise<PDFDocumentProxy>} promise - Promise for document loading
|
||||||
* The callback receives an {UNSUPPORTED_FEATURES} argument.
|
* task completion.
|
||||||
* @property {Promise<PDFDocumentProxy>} promise
|
* @property {Promise<void>} destroy - Abort all network requests and destroy
|
||||||
* Promise for document loading task completion.
|
* the worker. Returns a promise that is resolved when destruction is
|
||||||
* @property {cbDestroy} destroy
|
* completed.
|
||||||
* Aborts all network requests and destroys worker.
|
|
||||||
* Returns a promise that is resolved after destruction activity is completed.
|
|
||||||
*
|
|
||||||
* @callback cbOnPassword
|
|
||||||
* @param {string} password
|
|
||||||
* @param {number} reason
|
|
||||||
*
|
|
||||||
* @callback cbOnProgress
|
|
||||||
* @param {number} loaded
|
|
||||||
* @param {number} total
|
|
||||||
*
|
|
||||||
* @callback cbOnUnsupportedFeature
|
|
||||||
* @param {string} featureId
|
|
||||||
*
|
|
||||||
* @callback cbDestroy
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -484,34 +469,38 @@ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
|
|||||||
this._worker = null;
|
this._worker = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique document loading task id -- used in MessageHandlers.
|
* Unique identifier for the document loading task.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.docId = "d" + nextDocumentId++;
|
this.docId = "d" + nextDocumentId++;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows if loading task is destroyed.
|
* Whether the loading task is destroyed or not.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.destroyed = false;
|
this.destroyed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to request a password if wrong or no password was provided.
|
* Callback to request a password if a wrong or no password was provided.
|
||||||
* The callback receives two parameters: function that needs to be called
|
* The callback receives two parameters: a function that should be called
|
||||||
* with new password and reason (see {PasswordResponses}).
|
* with the new password, and a reason (see {@link PasswordResponses}).
|
||||||
|
* @type {function}
|
||||||
*/
|
*/
|
||||||
this.onPassword = null;
|
this.onPassword = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to be able to monitor the loading progress of the PDF file
|
* Callback to be able to monitor the loading progress of the PDF file
|
||||||
* (necessary to implement e.g. a loading bar). The callback receives
|
* (necessary to implement e.g. a loading bar). The callback receives
|
||||||
* an {Object} with the properties: {number} loaded and {number} total.
|
* an {Object} with the properties `loaded` ({number}) and `total`
|
||||||
|
* ({number}) that indicate how many bytes are loaded.
|
||||||
|
* @type {function}
|
||||||
*/
|
*/
|
||||||
this.onProgress = null;
|
this.onProgress = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to when unsupported feature is used. The callback receives
|
* Callback for when an unsupported feature is used in the PDF document.
|
||||||
* an {UNSUPPORTED_FEATURES} argument.
|
* The callback receives an {@link UNSUPPORTED_FEATURES} argument.
|
||||||
|
* @type {function}
|
||||||
*/
|
*/
|
||||||
this.onUnsupportedFeature = null;
|
this.onUnsupportedFeature = null;
|
||||||
}
|
}
|
||||||
@ -525,9 +514,8 @@ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aborts all network requests and destroys worker.
|
* @returns {Promise<void>} A promise that is resolved when destruction is
|
||||||
* @returns {Promise<void>} A promise that is resolved after destruction
|
* completed.
|
||||||
* activity is completed.
|
|
||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user