Skip to content

Commit

Permalink
add: epubjs.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Aug 18, 2023
1 parent 861d02e commit cc5c235
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
13 changes: 6 additions & 7 deletions types/reader/dom/epub/epub-view.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
/// <reference path="flow.d.ts" />
/// <reference path="section-view.d.ts" />
/// <reference path="lib/page-mapping.d.ts" />

declare type Book = import("epubjs").Book;
/// <reference path="epubjs.d.ts" />

declare namespace _ZoteroTypes {
namespace Reader {
Expand All @@ -17,7 +16,7 @@ declare namespace _ZoteroTypes {
flowMode?: FlowMode;
}
interface EPUBViewData {
book?: Book;
book?: ePubJS.Book;
}

/**
Expand All @@ -31,7 +30,7 @@ declare namespace _ZoteroTypes {
*/
class EPUBView extends DOMView<EPUBViewState, EPUBViewData> {
protected _find: EPUBFindProcessor | null;
readonly book: Book;
readonly book: ePubJS.Book;
flow: Flow;
private _sectionsContainer: HTMLElement;
private readonly _sectionViews: SectionView[];
Expand All @@ -44,16 +43,16 @@ declare namespace _ZoteroTypes {
private _savedPageMapping: string;
constructor(options: DOMViewOptions<EPUBViewState, EPUBViewData>);
protected _getSrcDoc(): "<!DOCTYPE html><html><body></body></html>";
getData(): { book: Book };
getData(): { book: ePubJS.Book };
protected _onInitialDisplay(
viewState: Partial<Readonly<EPUBViewState>>
): Promise<void>;
private _initPageMapping(
viewState: Partial<Readonly<EPUBViewState>>
): Promise<void>;
private _initOutline(): void;
getCFI(rangeOrNode: Range | Node): EpubCFI | null;
getRange(cfi: EpubCFI | string): Range | null;
getCFI(rangeOrNode: Range | Node): ePubJS.EpubCFI | null;
getRange(cfi: ePubJS.EpubCFI | string): Range | null;
override toSelector(range: Range): FragmentSelector | null;
override toDisplayedRange(selector: Selector): Range | null;
readonly views: SectionView[];
Expand Down
5 changes: 5 additions & 0 deletions types/reader/dom/epub/epubjs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace ePubJS {
type Book = import("epubjs").Book;
type EpubCFI = import("epubjs").EpubCFI;
type Section = import("epubjs/types/section").default;
}
9 changes: 4 additions & 5 deletions types/reader/dom/epub/flow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
/// <reference types="./lib/page-mapping.d.ts" />
/// <reference types="../common/dom-view.d.ts" />
/// <reference types="../../common/lib/debounce.d.ts" />

declare type EpubCFI = import("epubjs").EpubCFI;
/// <reference path="epubjs.d.ts" />

declare namespace _ZoteroTypes {
namespace Reader {
interface Flow {
readonly startView: SectionView | null;
readonly startRange: Range | null;
readonly startCFI: EpubCFI | null;
readonly startCFI: ePubJS.EpubCFI | null;
readonly startCFIOffsetY: number | null;
readonly startRangeIsBeforeFirstMapping: boolean;
readonly endView: SectionView | null;
Expand All @@ -33,7 +32,7 @@ declare namespace _ZoteroTypes {
abstract class AbstractFlow implements Flow {
protected _cachedStartView: SectionView | null;
protected _cachedStartRange: Range | null;
protected _cachedStartCFI: EpubCFI | null;
protected _cachedStartCFI: ePubJS.EpubCFI | null;
protected _cachedStartCFIOffsetY: number | null;
protected _cachedEndView: SectionView | null;
protected _sectionViews: SectionView[];
Expand All @@ -58,7 +57,7 @@ declare namespace _ZoteroTypes {

readonly startView: SectionView | null;
readonly startRange: Range | null;
readonly startCFI: EpubCFI | null;
readonly startCFI: ePubJS.EpubCFI | null;
readonly startCFIOffsetY: number | null;
readonly startRangeIsBeforeFirstMapping: boolean;
readonly endView: SectionView | null;
Expand Down
7 changes: 3 additions & 4 deletions types/reader/dom/epub/section-view.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/// <reference types="../common/lib/dom-text-search.d.ts" />
/// <reference types="../epub/lib/sanitize-and-render.d.ts" />

declare type Section = import("epubjs/types/section").default;
/// <reference path="epubjs.d.ts" />

declare namespace _ZoteroTypes {
namespace Reader {
class SectionView {
readonly section: Section;
readonly section: ePubJS.Section;
readonly container: HTMLElement;
body: HTMLElement;
private readonly _window: Window & typeof globalThis;
private readonly _document: Document;
private readonly _styleScoper: StyleScoper;
private _searchContext: SearchContext | null;
constructor(options: {
section: Section;
section: ePubJS.Section;
container: HTMLElement;
window: Window & typeof globalThis;
document: Document;
Expand Down

0 comments on commit cc5c235

Please sign in to comment.