interfaces.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* Copyright 2018 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. /* eslint-disable getter-return */
  16. /** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
  17. // eslint-disable-next-line max-len
  18. /** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
  19. /** @typedef {import("./ui_utils").RenderingStates} RenderingStates */
  20. /**
  21. * @interface
  22. */
  23. class IPDFLinkService {
  24. /**
  25. * @type {number}
  26. */
  27. get pagesCount() {}
  28. /**
  29. * @type {number}
  30. */
  31. get page() {}
  32. /**
  33. * @param {number} value
  34. */
  35. set page(value) {}
  36. /**
  37. * @type {number}
  38. */
  39. get rotation() {}
  40. /**
  41. * @param {number} value
  42. */
  43. set rotation(value) {}
  44. /**
  45. * @type {boolean}
  46. */
  47. get isInPresentationMode() {}
  48. /**
  49. * @type {boolean}
  50. */
  51. get externalLinkEnabled() {}
  52. /**
  53. * @param {boolean} value
  54. */
  55. set externalLinkEnabled(value) {}
  56. /**
  57. * @param {string|Array} dest - The named, or explicit, PDF destination.
  58. */
  59. async goToDestination(dest) {}
  60. /**
  61. * @param {number|string} val - The page number, or page label.
  62. */
  63. goToPage(val) {}
  64. /**
  65. * @param {HTMLAnchorElement} link
  66. * @param {string} url
  67. * @param {boolean} [newWindow]
  68. */
  69. addLinkAttributes(link, url, newWindow = false) {}
  70. /**
  71. * @param dest - The PDF destination object.
  72. * @returns {string} The hyperlink to the PDF object.
  73. */
  74. getDestinationHash(dest) {}
  75. /**
  76. * @param hash - The PDF parameters/hash.
  77. * @returns {string} The hyperlink to the PDF object.
  78. */
  79. getAnchorUrl(hash) {}
  80. /**
  81. * @param {string} hash
  82. */
  83. setHash(hash) {}
  84. /**
  85. * @param {string} action
  86. */
  87. executeNamedAction(action) {}
  88. /**
  89. * @param {Object} action
  90. */
  91. executeSetOCGState(action) {}
  92. /**
  93. * @param {number} pageNum - page number.
  94. * @param {Object} pageRef - reference to the page.
  95. */
  96. cachePageRef(pageNum, pageRef) {}
  97. /**
  98. * @param {number} pageNumber
  99. */
  100. isPageVisible(pageNumber) {}
  101. /**
  102. * @param {number} pageNumber
  103. */
  104. isPageCached(pageNumber) {}
  105. }
  106. /**
  107. * @interface
  108. */
  109. class IRenderableView {
  110. constructor() {
  111. /** @type {function | null} */
  112. this.resume = null;
  113. }
  114. /**
  115. * @type {string} - Unique ID for rendering queue.
  116. */
  117. get renderingId() {}
  118. /**
  119. * @type {RenderingStates}
  120. */
  121. get renderingState() {}
  122. /**
  123. * @returns {Promise} Resolved on draw completion.
  124. */
  125. draw() {}
  126. }
  127. /**
  128. * @interface
  129. */
  130. class IDownloadManager {
  131. /**
  132. * @param {string} url
  133. * @param {string} filename
  134. */
  135. downloadUrl(url, filename) {}
  136. /**
  137. * @param {Uint8Array} data
  138. * @param {string} filename
  139. * @param {string} [contentType]
  140. */
  141. downloadData(data, filename, contentType) {}
  142. /**
  143. * @param {HTMLElement} element
  144. * @param {Uint8Array} data
  145. * @param {string} filename
  146. * @returns {boolean} Indicating if the data was opened.
  147. */
  148. openOrDownloadData(element, data, filename) {}
  149. /**
  150. * @param {Blob} blob
  151. * @param {string} url
  152. * @param {string} filename
  153. */
  154. download(blob, url, filename) {}
  155. }
  156. /**
  157. * @interface
  158. */
  159. class IL10n {
  160. /**
  161. * @returns {Promise<string>} - Resolves to the current locale.
  162. */
  163. async getLanguage() {}
  164. /**
  165. * @returns {Promise<string>} - Resolves to 'rtl' or 'ltr'.
  166. */
  167. async getDirection() {}
  168. /**
  169. * Translates text identified by the key and adds/formats data using the args
  170. * property bag. If the key was not found, translation falls back to the
  171. * fallback text.
  172. * @param {string} key
  173. * @param {Object | null} [args]
  174. * @param {string} [fallback]
  175. * @returns {Promise<string>}
  176. */
  177. async get(key, args = null, fallback) {}
  178. /**
  179. * Translates HTML element.
  180. * @param {HTMLElement} element
  181. * @returns {Promise<void>}
  182. */
  183. async translate(element) {}
  184. }
  185. export { IDownloadManager, IL10n, IPDFLinkService, IRenderableView };