Skip to content

Commit b517b5c

Browse files
committed
Remove the IPDFLinkService interface
Given that `SimpleLinkService` now extends the regular `PDFLinkService` class, see PR 18013, it should no longer be necessary to keep the interface-definition. This should help reduce the maintenance burden of the code, since you no longer need to remember to update separate code when touching the `PDFLinkService` class.
1 parent e4cd317 commit b517b5c

12 files changed

Lines changed: 12 additions & 132 deletions

src/display/annotation_layer.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
/** @typedef {import("../../web/text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */
2020
// eslint-disable-next-line max-len
2121
/** @typedef {import("../../web/interfaces").IDownloadManager} IDownloadManager */
22-
/** @typedef {import("../../web/interfaces").IPDFLinkService} IPDFLinkService */
2322
// eslint-disable-next-line max-len
2423
/** @typedef {import("../src/display/editor/tools.js").AnnotationEditorUIManager} AnnotationEditorUIManager */
2524
// eslint-disable-next-line max-len
@@ -57,7 +56,7 @@ const TIMEZONE_OFFSET = new Date().getTimezoneOffset() * 60 * 1000;
5756
* @typedef {Object} AnnotationElementParameters
5857
* @property {Object} data
5958
* @property {HTMLDivElement} layer
60-
* @property {IPDFLinkService} linkService
59+
* @property {PDFLinkService} linkService
6160
* @property {IDownloadManager} [downloadManager]
6261
* @property {AnnotationStorage} [annotationStorage]
6362
* @property {string} [imageResourcesPath] - Path for image resources, mainly
@@ -3736,7 +3735,7 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
37363735
* @property {HTMLDivElement} div
37373736
* @property {Array} annotations
37383737
* @property {PDFPageProxy} page
3739-
* @property {IPDFLinkService} linkService
3738+
* @property {PDFLinkService} linkService
37403739
* @property {IDownloadManager} [downloadManager]
37413740
* @property {AnnotationStorage} [annotationStorage]
37423741
* @property {string} [imageResourcesPath] - Path for image resources, mainly
@@ -4018,8 +4017,6 @@ class AnnotationLayer {
40184017
* Add link annotations to the annotation layer.
40194018
*
40204019
* @param {Array<Object>} annotations
4021-
* @param {IPDFLinkService} linkService
4022-
* @memberof AnnotationLayer
40234020
*/
40244021
async addLinkAnnotations(annotations) {
40254022
const elementParams = {

src/display/xfa_layer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// eslint-disable-next-line max-len
1717
/** @typedef {import("./annotation_storage").AnnotationStorage} AnnotationStorage */
1818
/** @typedef {import("./display_utils").PageViewport} PageViewport */
19-
/** @typedef {import("../../web/interfaces").IPDFLinkService} IPDFLinkService */
2019

2120
import { XfaText } from "./xfa_text.js";
2221

@@ -26,7 +25,7 @@ import { XfaText } from "./xfa_text.js";
2625
* @property {HTMLDivElement} div
2726
* @property {Object} xfaHtml
2827
* @property {AnnotationStorage} [annotationStorage]
29-
* @property {IPDFLinkService} linkService
28+
* @property {PDFLinkService} linkService
3029
* @property {string} [intent] - (default value is 'display').
3130
*/
3231

web/annotation_layer_builder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// eslint-disable-next-line max-len
2020
/** @typedef {import("../src/display/annotation_storage").AnnotationStorage} AnnotationStorage */
2121
/** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
22-
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
2322
// eslint-disable-next-line max-len
2423
/** @typedef {import("./struct_tree_layer_builder.js").StructTreeLayerBuilder} StructTreeLayerBuilder */
2524
// eslint-disable-next-line max-len
@@ -43,7 +42,7 @@ import { PresentationModeState } from "./ui_utils.js";
4342
* @property {string} [imageResourcesPath] - Path for image resources, mainly
4443
* for annotation icons. Include trailing slash.
4544
* @property {boolean} renderForms
46-
* @property {IPDFLinkService} linkService
45+
* @property {PDFLinkService} linkService
4746
* @property {IDownloadManager} [downloadManager]
4847
* @property {boolean} [enableComment]
4948
* @property {boolean} [enableScripting]

web/interfaces.js

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -19,103 +19,6 @@
1919
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
2020
/** @typedef {import("./ui_utils").RenderingStates} RenderingStates */
2121

22-
/**
23-
* @interface
24-
*/
25-
class IPDFLinkService {
26-
/**
27-
* @type {number}
28-
*/
29-
get pagesCount() {}
30-
31-
/**
32-
* @type {number}
33-
*/
34-
get page() {}
35-
36-
/**
37-
* @param {number} value
38-
*/
39-
set page(value) {}
40-
41-
/**
42-
* @type {number}
43-
*/
44-
get rotation() {}
45-
46-
/**
47-
* @param {number} value
48-
*/
49-
set rotation(value) {}
50-
51-
/**
52-
* @type {boolean}
53-
*/
54-
get isInPresentationMode() {}
55-
56-
/**
57-
* @type {boolean}
58-
*/
59-
get externalLinkEnabled() {}
60-
61-
/**
62-
* @param {boolean} value
63-
*/
64-
set externalLinkEnabled(value) {}
65-
66-
/**
67-
* @param {string|Array} dest - The named, or explicit, PDF destination.
68-
*/
69-
async goToDestination(dest) {}
70-
71-
/**
72-
* @param {number|string} val - The page number, or page label.
73-
*/
74-
goToPage(val) {}
75-
76-
/**
77-
* Scrolls to a specific location in the PDF document.
78-
* @param {number} pageNumber - The page number to scroll to.
79-
* @param {number} x - The x-coordinate to scroll to in page coordinates.
80-
* @param {number} y - The y-coordinate to scroll to in page coordinates.
81-
*/
82-
goToXY(pageNumber, x, y) {}
83-
84-
/**
85-
* @param {HTMLAnchorElement} link
86-
* @param {string} url
87-
* @param {boolean} [newWindow]
88-
*/
89-
addLinkAttributes(link, url, newWindow = false) {}
90-
91-
/**
92-
* @param dest - The PDF destination object.
93-
* @returns {string} The hyperlink to the PDF object.
94-
*/
95-
getDestinationHash(dest) {}
96-
97-
/**
98-
* @param hash - The PDF parameters/hash.
99-
* @returns {string} The hyperlink to the PDF object.
100-
*/
101-
getAnchorUrl(hash) {}
102-
103-
/**
104-
* @param {string} hash
105-
*/
106-
setHash(hash) {}
107-
108-
/**
109-
* @param {string} action
110-
*/
111-
executeNamedAction(action) {}
112-
113-
/**
114-
* @param {Object} action
115-
*/
116-
executeSetOCGState(action) {}
117-
}
118-
11922
/**
12023
* @interface
12124
*/
@@ -226,10 +129,4 @@ class IPDFPrintServiceFactory {
226129
}
227130
}
228131

229-
export {
230-
IDownloadManager,
231-
IL10n,
232-
IPDFLinkService,
233-
IPDFPrintServiceFactory,
234-
IRenderableView,
235-
};
132+
export { IDownloadManager, IL10n, IPDFPrintServiceFactory, IRenderableView };

web/pdf_find_controller.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
/** @typedef {import("../src/display/api").PDFDocumentProxy} PDFDocumentProxy */
1717
/** @typedef {import("./event_utils").EventBus} EventBus */
18-
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
1918

2019
import { binarySearchFirstItem, scrollIntoView } from "./ui_utils.js";
2120
import { getCharacterType, getNormalizeWithNFKC } from "./pdf_find_utils.js";
@@ -405,7 +404,7 @@ function getOriginalIndex(diffs, pos, len) {
405404

406405
/**
407406
* @typedef {Object} PDFFindControllerOptions
408-
* @property {IPDFLinkService} linkService - The navigation/linking service.
407+
* @property {PDFLinkService} linkService - The navigation/linking service.
409408
* @property {EventBus} eventBus - The application event bus.
410409
* @property {boolean} [updateMatchesCountOnProgress] - True if the matches
411410
* count must be updated on progress or only when the last page is reached.

web/pdf_history.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
/** @typedef {import("./event_utils").EventBus} EventBus */
17-
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
1817

1918
import { isValidRotation, parseQueryString } from "./ui_utils.js";
2019
import { updateUrlHash } from "pdfjs-lib";
@@ -29,7 +28,7 @@ const UPDATE_VIEWAREA_TIMEOUT = 1000; // milliseconds
2928

3029
/**
3130
* @typedef {Object} PDFHistoryOptions
32-
* @property {IPDFLinkService} linkService - The navigation/linking service.
31+
* @property {PDFLinkService} linkService - The navigation/linking service.
3332
* @property {EventBus} eventBus - The application event bus.
3433
*/
3534

web/pdf_link_service.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
/** @typedef {import("./event_utils").EventBus} EventBus */
17-
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
1817

1918
import { isValidExplicitDest } from "pdfjs-lib";
2019
import { parseQueryString } from "./ui_utils.js";
@@ -45,7 +44,6 @@ const LinkTarget = {
4544
/**
4645
* Performs navigation functions inside PDF, such as opening specified page,
4746
* or destination.
48-
* @implements {IPDFLinkService}
4947
*/
5048
class PDFLinkService {
5149
externalLinkEnabled = true;
@@ -517,9 +515,6 @@ class PDFLinkService {
517515
}
518516
}
519517

520-
/**
521-
* @implements {IPDFLinkService}
522-
*/
523518
class SimpleLinkService extends PDFLinkService {
524519
setDocument(pdfDocument, baseUrl = null) {}
525520
}

web/pdf_outline_viewer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
/** @typedef {import("./event_utils.js").EventBus} EventBus */
1717
// eslint-disable-next-line max-len
1818
/** @typedef {import("./download_manager.js").DownloadManager} DownloadManager */
19-
/** @typedef {import("./interfaces.js").IPDFLinkService} IPDFLinkService */
2019
// eslint-disable-next-line max-len
2120
/** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */
2221

@@ -27,7 +26,7 @@ import { SidebarView } from "./ui_utils.js";
2726
* @typedef {Object} PDFOutlineViewerOptions
2827
* @property {HTMLDivElement} container - The viewer element.
2928
* @property {EventBus} eventBus - The application event bus.
30-
* @property {IPDFLinkService} linkService - The navigation/linking service.
29+
* @property {PDFLinkService} linkService - The navigation/linking service.
3130
* @property {DownloadManager} downloadManager - The download manager.
3231
*/
3332

web/pdf_thumbnail_view.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// eslint-disable-next-line max-len
1919
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
2020
/** @typedef {import("./event_utils").EventBus} EventBus */
21-
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
2221
/** @typedef {import("./interfaces").IRenderableView} IRenderableView */
2322
// eslint-disable-next-line max-len
2423
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
@@ -44,7 +43,7 @@ const THUMBNAIL_WIDTH = 126; // px
4443
* @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -
4544
* A promise that is resolved with an {@link OptionalContentConfig} instance.
4645
* The default value is `null`.
47-
* @property {IPDFLinkService} linkService - The navigation/linking service.
46+
* @property {PDFLinkService} linkService - The navigation/linking service.
4847
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object.
4948
* @property {number} [maxCanvasPixels] - The maximum supported canvas size in
5049
* total pixels, i.e. width * height. Use `-1` for no limit, or `0` for

web/pdf_thumbnail_viewer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
/** @typedef {import("../src/display/api").PDFDocumentProxy} PDFDocumentProxy */
1717
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
1818
/** @typedef {import("./event_utils").EventBus} EventBus */
19-
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
2019
// eslint-disable-next-line max-len
2120
/** @typedef {import("./pdf_rendering_queue").PDFRenderingQueue} PDFRenderingQueue */
2221

@@ -51,7 +50,7 @@ const SPACE_FOR_DRAG_MARKER_WHEN_NO_NEXT_ELEMENT = 15;
5150
* @property {HTMLDivElement} container - The container for the thumbnail
5251
* elements.
5352
* @property {EventBus} eventBus - The application event bus.
54-
* @property {IPDFLinkService} linkService - The navigation/linking service.
53+
* @property {PDFLinkService} linkService - The navigation/linking service.
5554
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object.
5655
* @property {number} [maxCanvasPixels] - The maximum supported canvas size in
5756
* total pixels, i.e. width * height. Use `-1` for no limit, or `0` for

0 commit comments

Comments
 (0)