Skip to content

Commit

Permalink
web app types
Browse files Browse the repository at this point in the history
  • Loading branch information
ex37 committed Apr 3, 2024
1 parent 2e52829 commit b94c654
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 13 deletions.
23 changes: 21 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,27 @@
"display-node_utils": ["./src/display/node_utils"],
"fluent-bundle": ["./node_modules/@fluent/bundle/esm/index.js"],
"fluent-dom": ["./node_modules/@fluent/dom/esm/index.js"],
"web-null_l10n": ["../web/genericl10n.js"]

"web-null_l10n": ["./web/genericl10n"],
"web-alt_text_manager": ["./web/alt_text_manager"],
"web-annotation_editor_params": ["./web/annotation_editor_params"],
"web-pdf_attachment_viewer": ["./web/pdf_attachment_viewer"],
"web-pdf_cursor_tools": ["./web/pdf_cursor_tools"],
"web-pdf_document_properties": ["./web/pdf_document_properties"],
"web-pdf_find_bar": ["./web/pdf_find_bar"],
"web-pdf_layer_viewer": ["./web/pdf_layer_viewer"],
"web-pdf_outline_viewer": ["./web/pdf_outline_viewer"],
"web-pdf_presentation_mode": ["./web/pdf_presentation_mode"],
"web-pdf_sidebar": ["./web/pdf_sidebar"],
"web-pdf_thumbnail_viewer": ["./web/pdf_thumbnail_viewer"],
"web-secondary_toolbar": ["./web/secondary_toolbar"],
"web-toolbar": ["./web/toolbar"],
"web-com": ["./web/genericcom"],
"web-print_service": ["./web/pdf_print_service"],
"web-download_manager": ["./web/download_manager"],
"web-external_services": ["./web/genericcom"],
"web-preferences": ["./web/genericcom"]
}
},
"files": ["src/pdf.js", "web/pdf_viewer.component.js"]
"files": ["src/pdf.js", "web/pdf_viewer.component.js", "web/app.js"]
}
17 changes: 17 additions & 0 deletions web/annotation_editor_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@

import { AnnotationEditorParamsType } from "pdfjs-lib";

/** @typedef {import("./event_utils.js").EventBus} EventBus */

/**
* @typedef {Object} AnnotationEditorParamsOptions
* @property {HTMLInputElement} editorFreeTextFontSize
* @property {HTMLInputElement} editorFreeTextColor
* @property {HTMLInputElement} editorInkColor
* @property {HTMLInputElement} editorInkThickness
* @property {HTMLInputElement} editorInkOpacity
* @property {HTMLElement} editorStampAddImage
* @property {HTMLInputElement} editorFreeHighlightThickness
* @property {HTMLElement} editorHighlightShowAll
*/

class AnnotationEditorParams {
/**
* @param {AnnotationEditorParamsOptions} options
Expand All @@ -25,6 +39,9 @@ class AnnotationEditorParams {
this.#bindListeners(options);
}

/**
* @param {AnnotationEditorParamsOptions} options
*/
#bindListeners({
editorFreeTextFontSize,
editorFreeTextColor,
Expand Down
2 changes: 2 additions & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ import { SecondaryToolbar } from "web-secondary_toolbar";
import { Toolbar } from "web-toolbar";
import { ViewHistory } from "./view_history.js";

/** @typedef {import("./interfaces.js").IL10n} IL10n */

const FORCE_PAGES_LOADED_TIMEOUT = 10000; // ms
const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000; // ms

Expand Down
8 changes: 5 additions & 3 deletions web/base_tree_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class BaseTreeViewer {
}

/**
* @private
* @protected
*/
_dispatchEvent(count) {
throw new Error("Not implemented: _dispatchEvent");
}

/**
* @private
* @protected
*/
_bindLink(element, params) {
throw new Error("Not implemented: _bindLink");
Expand All @@ -71,7 +71,9 @@ class BaseTreeViewer {
/**
* Prepend a button before a tree item which allows the user to collapse or
* expand all tree items at that level; see `_toggleTreeItem`.
* @private
* @protected
* @param {Element} div
* @param {any} [hidden=false]
*/
_addToggleButton(div, hidden = false) {
const toggler = document.createElement("div");
Expand Down
5 changes: 5 additions & 0 deletions web/external_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* limitations under the License.
*/

/** @typedef {import("./l10n.js").L10n} L10n */

class BaseExternalServices {
constructor() {
if (this.constructor === BaseExternalServices) {
Expand All @@ -28,6 +30,9 @@ class BaseExternalServices {

reportTelemetry(data) {}

/**
* @returns {Promise<L10n>}
*/
async createL10n() {
throw new Error("Not implemented: createL10n");
}
Expand Down
8 changes: 6 additions & 2 deletions web/pdf_attachment_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { BaseTreeViewer } from "./base_tree_viewer.js";
import { getFilenameFromUrl } from "pdfjs-lib";
import { waitOnEventOrTimeout } from "./event_utils.js";

/** @typedef {import("./event_utils.js").EventBus} EventBus */
/** @typedef {import("./download_manager.js").DownloadManager} DownloadManager */

/**
* @typedef {Object} PDFAttachmentViewerOptions
* @property {HTMLDivElement} container - The viewer element.
Expand All @@ -27,6 +30,7 @@ import { waitOnEventOrTimeout } from "./event_utils.js";
/**
* @typedef {Object} PDFAttachmentViewerRenderParameters
* @property {Object|null} attachments - A lookup table of attachment objects.
* @property {boolean} keepRenderedCapability
*/

class PDFAttachmentViewer extends BaseTreeViewer {
Expand Down Expand Up @@ -56,7 +60,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
async _dispatchEvent(attachmentsCount) {
this._renderedCapability.resolve();
Expand Down Expand Up @@ -87,7 +91,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
_bindLink(element, { content, filename }) {
element.onclick = () => {
Expand Down
2 changes: 2 additions & 0 deletions web/pdf_cursor_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { AnnotationEditorType, shadow } from "pdfjs-lib";
import { CursorTool, PresentationModeState } from "./ui_utils.js";
import { GrabToPan } from "./grab_to_pan.js";

/** @typedef {import("./event_utils.js").EventBus} EventBus */

/**
* @typedef {Object} PDFCursorToolsOptions
* @property {HTMLDivElement} container - The document container.
Expand Down
5 changes: 5 additions & 0 deletions web/pdf_document_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
import { getPageSizeInches, isPortraitOrientation } from "./ui_utils.js";
import { PDFDateString } from "pdfjs-lib";

/** @typedef {import("./event_utils.js").EventBus} EventBus */
/** @typedef {import("./interfaces.js").IL10n} IL10n */
/** @typedef {import("./overlay_manager.js").OverlayManager} OverlayManager */
/** @typedef {import("../src/display/api").PDFDocumentProxy} PDFDocumentProxy */

const DEFAULT_FIELD_CONTENT = "-";

// See https://en.wikibooks.org/wiki/Lentis/Conversion_to_the_Metric_Standard_in_the_United_States
Expand Down
10 changes: 7 additions & 3 deletions web/pdf_layer_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

import { BaseTreeViewer } from "./base_tree_viewer.js";

/** @typedef {import("./event_utils.js").EventBus} EventBus */
/** @typedef {import("../src/optional_content_config.js").OptionalContentConfig} OptionalContentConfig */
/** @typedef {import("../src/document.js").PDFDocument} PDFDocument */

/**
* @typedef {Object} PDFLayerViewerOptions
* @property {HTMLDivElement} container - The viewer element.
Expand Down Expand Up @@ -48,7 +52,7 @@ class PDFLayerViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
_dispatchEvent(layersCount) {
this.eventBus.dispatch("layersloaded", {
Expand All @@ -58,7 +62,7 @@ class PDFLayerViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
_bindLink(element, { groupId, input }) {
const setVisibility = () => {
Expand Down Expand Up @@ -97,7 +101,7 @@ class PDFLayerViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
_addToggleButton(div, { name = null }) {
super._addToggleButton(div, /* hidden = */ name === null);
Expand Down
11 changes: 8 additions & 3 deletions web/pdf_outline_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
import { BaseTreeViewer } from "./base_tree_viewer.js";
import { SidebarView } from "./ui_utils.js";

/** @typedef {import("./event_utils.js").EventBus} EventBus */
/** @typedef {import("./download_manager.js").DownloadManager} DownloadManager */
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
/** @typedef {import("../src/document.js").PDFDocument} PDFDocument */

/**
* @typedef {Object} PDFOutlineViewerOptions
* @property {HTMLDivElement} container - The viewer element.
Expand Down Expand Up @@ -75,7 +80,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
_dispatchEvent(outlineCount) {
this._currentOutlineItemCapability = Promise.withResolvers();
Expand All @@ -98,7 +103,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
_bindLink(
element,
Expand Down Expand Up @@ -162,7 +167,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
}

/**
* @private
* @protected
*/
_addToggleButton(div, { count, items }) {
let hidden = false;
Expand Down
3 changes: 3 additions & 0 deletions web/pdf_presentation_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import {
} from "./ui_utils.js";
import { AnnotationEditorType } from "pdfjs-lib";

/** @typedef {import("./event_utils.js").EventBus} EventBus */
/** @typedef {import("./pdf_viewer.js").PDFViewer} PDFViewer */

const DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms
const ACTIVE_SELECTOR = "pdfPresentationMode";
const CONTROLS_SELECTOR = "pdfPresentationModeControls";
Expand Down
3 changes: 3 additions & 0 deletions web/pdf_sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const SIDEBAR_MIN_WIDTH = 200; // pixels
const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";

/** @typedef {import("./event_utils.js").EventBus} EventBus */
/** @typedef {import("./interfaces.js").IL10n} IL10n */

/**
* @typedef {Object} PDFSidebarOptions
* @property {PDFSidebarElements} elements - The DOM elements.
Expand Down
2 changes: 2 additions & 0 deletions web/secondary_toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
} from "./ui_utils.js";
import { PagesCountLimit } from "./pdf_viewer.js";

/** @typedef {import("./event_utils.js").EventBus} EventBus */

/**
* @typedef {Object} SecondaryToolbarOptions
* @property {HTMLDivElement} toolbar - Container for the secondary toolbar.
Expand Down
2 changes: 2 additions & 0 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
toggleCheckedBtn,
} from "./ui_utils.js";

/** @typedef {import("./event_utils.js").EventBus} EventBus */

/**
* @typedef {Object} ToolbarOptions
* @property {HTMLDivElement} container - Container for the secondary toolbar.
Expand Down

0 comments on commit b94c654

Please sign in to comment.