summaryrefslogtreecommitdiff
path: root/lib/epub.js/types/rendition.d.ts
blob: 489f3faeba67da43bb1083fa5cb29381efbc400a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import Book from "./book";
import Contents from "./contents";
import Section from "./section";
import View from "./managers/view";
import Hook from "./utils/hook";
import Themes from "./themes";
import EpubCFI from "./epubcfi";
import Annotations from "./annotations";
import Queue from "./utils/queue";

export interface RenditionOptions {
  width?: number | string,
  height?: number | string,
  ignoreClass?: string,
  manager?: string | Function | object,
  view?: string | Function | object,
  flow?: string,
  layout?: string,
  spread?: string,
  minSpreadWidth?: number,
  stylesheet?: string,
  resizeOnOrientationChange?: boolean,
  script?: string,
  infinite?: boolean,
  overflow?: string,
  snap?: boolean | object,
  defaultDirection?: string,
  allowScriptedContent?: boolean
}

export interface DisplayedLocation {
  index: number,
  href: string,
  cfi: string,
  location: number,
  percentage: number,
  displayed: {
    page: number,
    total: number
  }
}

export interface Location {
  start: DisplayedLocation,
	end: DisplayedLocation,
  atStart: boolean,
  atEnd: boolean
}

export default class Rendition {
    constructor(book: Book, options: RenditionOptions);

    settings: RenditionOptions;
    book: Book;
    hooks: {
      display: Hook,
      serialize: Hook,
      content: Hook,
      unloaded: Hook,
      layout: Hook,
      render: Hook,
      show: Hook
    }
    themes: Themes;
    annotations: Annotations;
    epubcfi: EpubCFI;
    q: Queue;
    location: Location;
    started: Promise<void>;

    adjustImages(contents: Contents): Promise<void>;

    attachTo(element: Element): Promise<void>;

    clear(): void;

    currentLocation(): DisplayedLocation;
    currentLocation(): Promise<DisplayedLocation>;

    destroy(): void;

    determineLayoutProperties(metadata: object): object;

    direction(dir: string): void;

    display(target?: string): Promise<void>;
    display(target?: number): Promise<void>;

    flow(flow: string): void;

    getContents(): Contents;

    getRange(cfi: string, ignoreClass?: string): Range;

    handleLinks(contents: Contents): void;

    injectIdentifier(doc: Document, section: Section): void;

    injectScript(doc: Document, section: Section): void;

    injectStylesheet(doc: Document, section: Section): void;

    layout(settings: any): any;

    located(location: Location): DisplayedLocation;

    moveTo(offset: number): void;

    next(): Promise<void>;

    onOrientationChange(orientation: string): void;

    passEvents(contents: Contents): void;

    prev(): Promise<void>;

    reportLocation(): Promise<void>;

    requireManager(manager: string | Function | object): any;

    requireView(view: string | Function | object): any;

    resize(width: number, height: number): void;

    setManager(manager: Function): void;

    spread(spread: string, min?: number): void;

    start(): void;

    views(): Array<View>;

    // Event emitters
    emit(type: any, ...args: any[]): void;

    off(type: any, listener: any): any;

    on(type: any, listener: any): any;

    once(type: any, listener: any, ...args: any[]): any;

    private triggerMarkEvent(cfiRange: string, data: object, contents: Contents): void;

    private triggerSelectedEvent(cfirange: string, contents: Contents): void;

    private triggerViewEvent(e: Event, contents: Contents): void;

    private onResized(size: { width: number, height: number }): void;

    private afterDisplayed(view: any): void;

    private afterRemoved(view: any): void;

}