summaryrefslogtreecommitdiff
path: root/lib/epub.js/types
diff options
context:
space:
mode:
Diffstat (limited to 'lib/epub.js/types')
-rw-r--r--lib/epub.js/types/annotations.d.ts53
-rw-r--r--lib/epub.js/types/archive.d.ts27
-rw-r--r--lib/epub.js/types/book.d.ts122
-rw-r--r--lib/epub.js/types/container.d.ts7
-rw-r--r--lib/epub.js/types/contents.d.ts139
-rw-r--r--lib/epub.js/types/core.d.ts83
-rw-r--r--lib/epub.js/types/epub.d.ts6
-rw-r--r--lib/epub.js/types/epubcfi.d.ts97
-rw-r--r--lib/epub.js/types/epubjs-tests.ts9
-rw-r--r--lib/epub.js/types/index.d.ts20
-rw-r--r--lib/epub.js/types/layout.d.ts48
-rw-r--r--lib/epub.js/types/locations.d.ts41
-rw-r--r--lib/epub.js/types/managers/manager.d.ts90
-rw-r--r--lib/epub.js/types/managers/view.d.ts79
-rw-r--r--lib/epub.js/types/mapping.d.ts34
-rw-r--r--lib/epub.js/types/navigation.d.ts46
-rw-r--r--lib/epub.js/types/packaging.d.ts78
-rw-r--r--lib/epub.js/types/pagelist.d.ts29
-rw-r--r--lib/epub.js/types/rendition.d.ts151
-rw-r--r--lib/epub.js/types/resources.d.ts33
-rw-r--r--lib/epub.js/types/section.d.ts64
-rw-r--r--lib/epub.js/types/spine.d.ts30
-rw-r--r--lib/epub.js/types/store.d.ts30
-rw-r--r--lib/epub.js/types/themes.d.ts40
-rw-r--r--lib/epub.js/types/tsconfig.json24
-rw-r--r--lib/epub.js/types/tslint.json4
-rw-r--r--lib/epub.js/types/utils/constants.d.ts9
-rw-r--r--lib/epub.js/types/utils/core.d.ts79
-rw-r--r--lib/epub.js/types/utils/hook.d.ts18
-rw-r--r--lib/epub.js/types/utils/path.d.ts17
-rw-r--r--lib/epub.js/types/utils/queue.d.ts34
-rw-r--r--lib/epub.js/types/utils/replacements.d.ts12
-rw-r--r--lib/epub.js/types/utils/request.d.ts1
-rw-r--r--lib/epub.js/types/utils/scrolltype.d.ts3
-rw-r--r--lib/epub.js/types/utils/url.d.ts13
35 files changed, 1570 insertions, 0 deletions
diff --git a/lib/epub.js/types/annotations.d.ts b/lib/epub.js/types/annotations.d.ts
new file mode 100644
index 0000000..718319d
--- /dev/null
+++ b/lib/epub.js/types/annotations.d.ts
@@ -0,0 +1,53 @@
+import Rendition from "./rendition";
+import View from "./managers/view";
+
+export default class Annotations {
+ constructor(rendition: Rendition);
+
+ add(type: string, cfiRange: string, data?: object, cb?: Function, className?: string, styles?: object): Annotation;
+
+ remove(cfiRange: string, type: string): void;
+
+ highlight(cfiRange: string, data?: object, cb?: Function, className?: string, styles?: object): void;
+
+ underline(cfiRange: string, data?: object, cb?: Function, className?: string, styles?: object): void;
+
+ mark(cfiRange: string, data?: object, cb?: Function): void;
+
+ each(): Array<Annotation>
+
+ private _removeFromAnnotationBySectionIndex(sectionIndex: number, hash: string): void;
+
+ private _annotationsAt(index: number): void;
+
+ private inject(view: View): void;
+
+ private clear(view: View): void;
+}
+
+declare class Annotation {
+ constructor(options: {
+ type: string,
+ cfiRange: string,
+ data?: object,
+ sectionIndex?: number,
+ cb?: Function,
+ className?: string,
+ styles?: object
+ });
+
+ update(data: object): void;
+
+ attach(view: View): any;
+
+ detach(view: View): any;
+
+ // 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;
+}
diff --git a/lib/epub.js/types/archive.d.ts b/lib/epub.js/types/archive.d.ts
new file mode 100644
index 0000000..c705aa4
--- /dev/null
+++ b/lib/epub.js/types/archive.d.ts
@@ -0,0 +1,27 @@
+import JSZip = require('jszip');
+
+export default class Archive {
+ constructor();
+
+ open(input: BinaryType, isBase64?: boolean): Promise<JSZip>;
+
+ openUrl(zipUrl: string, isBase64?: boolean): Promise<JSZip>;
+
+ request(url: string, type?: string): Promise<Blob | string | JSON | Document | XMLDocument>;
+
+ getBlob(url: string, mimeType?: string): Promise<Blob>;
+
+ getText(url: string): Promise<string>;
+
+ getBase64(url: string, mimeType?: string): Promise<string>;
+
+ createUrl(url: string, options: { base64: boolean }): Promise<string>;
+
+ revokeUrl(url: string): void;
+
+ destroy(): void;
+
+ private checkRequirements(): void;
+
+ private handleResponse(response: any, type?: string): Blob | string | JSON | Document | XMLDocument;
+}
diff --git a/lib/epub.js/types/book.d.ts b/lib/epub.js/types/book.d.ts
new file mode 100644
index 0000000..7835053
--- /dev/null
+++ b/lib/epub.js/types/book.d.ts
@@ -0,0 +1,122 @@
+import {
+ PackagingManifestObject,
+ PackagingMetadataObject,
+ PackagingSpineItem,
+ PackagingObject
+} from "./packaging";
+import Rendition, { RenditionOptions } from "./rendition";
+import Section, { SpineItem } from "./section";
+import Archive from "./archive";
+import Navigation from "./navigation";
+import PageList, {PageListItem} from "./pagelist";
+import Spine from "./spine";
+import Locations from "./locations";
+import Url from "./utils/url";
+import Path from "./utils/path";
+import Resources from "./resources";
+import Container from "./container";
+import Packaging from "./packaging";
+import Store from "./store";
+
+export interface BookOptions {
+ requestMethod?: (url: string, type: string, withCredentials: object, headers: object) => Promise<object>;
+ requestCredentials?: object,
+ requestHeaders?: object,
+ encoding?: string,
+ replacements?: string,
+ canonical?: (path: string) => string,
+ openAs?: string,
+ store?: string
+}
+
+export default class Book {
+ constructor(url: string, options?: BookOptions);
+ constructor(options?: BookOptions);
+
+ settings: BookOptions;
+ opening: any; // should be core.defer
+ opened: Promise<Book>;
+ isOpen: boolean;
+ loaded: {
+ metadata: Promise<PackagingMetadataObject>,
+ spine: Promise<SpineItem[]>,
+ manifest: Promise<PackagingManifestObject>,
+ cover: Promise<string>,
+ navigation: Promise<Navigation>,
+ pageList: Promise<PageListItem[]>,
+ resources: Promise<string[]>,
+ }
+ ready: Promise<void>;
+ request: Function;
+ spine: Spine;
+ locations: Locations;
+ navigation: Navigation;
+ pageList: PageList;
+ url: Url;
+ path: Path;
+ archived: boolean;
+ archive: Archive;
+ resources: Resources;
+ rendition: Rendition
+ container: Container;
+ packaging: Packaging;
+ storage: Store;
+
+
+ canonical(path: string): string;
+
+ coverUrl(): Promise<string | null>;
+
+ destroy(): void;
+
+ determineType(input: string): string;
+
+ getRange(cfiRange: string): Promise<Range>;
+
+ key(identifier?: string): string;
+
+ load(path: string): Promise<object>;
+
+ loadNavigation(opf: XMLDocument): Promise<Navigation>;
+
+ open(input: string, what?: string): Promise<object>;
+ open(input: ArrayBuffer, what?: string): Promise<object>;
+
+ openContainer(url: string): Promise<string>;
+
+ openEpub(data: BinaryType, encoding?: string): Promise<Book>;
+
+ openManifest(url: string): Promise<Book>;
+
+ openPackaging(url: string): Promise<Book>;
+
+ renderTo(element: Element, options?: RenditionOptions): Rendition;
+ renderTo(element: string, options?: RenditionOptions): Rendition;
+
+ private replacements(): Promise<void>;
+
+ resolve(path: string, absolute?: boolean): string;
+
+ section(target: string): Section;
+ section(target: number): Section;
+
+ setRequestCredentials(credentials: object): void;
+
+ setRequestHeaders(headers: object): void;
+
+ unarchive(input: BinaryType, encoding?: string): Promise<Archive>;
+
+ store(name: string): Store;
+
+ unpack(opf: XMLDocument): Promise<Book>;
+
+ // 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;
+
+}
diff --git a/lib/epub.js/types/container.d.ts b/lib/epub.js/types/container.d.ts
new file mode 100644
index 0000000..139c941
--- /dev/null
+++ b/lib/epub.js/types/container.d.ts
@@ -0,0 +1,7 @@
+export default class Container {
+ constructor(containerDocument: Document);
+
+ parse(containerDocument: Document): void;
+
+ destroy(): void;
+}
diff --git a/lib/epub.js/types/contents.d.ts b/lib/epub.js/types/contents.d.ts
new file mode 100644
index 0000000..a0bb432
--- /dev/null
+++ b/lib/epub.js/types/contents.d.ts
@@ -0,0 +1,139 @@
+import EpubCFI from "./epubcfi";
+
+export interface ViewportSettings {
+ width: string,
+ height: string,
+ scale: string,
+ scalable: string,
+ minimum: string,
+ maximum: string
+}
+
+export default class Contents {
+ constructor(doc: Document, content: Element, cfiBase: string, sectionIndex: number);
+
+ epubcfi: EpubCFI;
+ document: Document;
+ documentElement: Element;
+ content: Element;
+ window: Window;
+ sectionIndex: number;
+ cfiBase: string;
+
+ static listenedEvents: string[];
+
+ addClass(className: string): void;
+
+ addScript(src: string): Promise<boolean>;
+
+ addStylesheet(src: string): Promise<boolean>;
+
+ addStylesheetRules(rules: Array<object> | object, key: string): Promise<boolean>;
+
+ addStylesheetCss(serializedCss: string, key: string): Promise<boolean>;
+
+ cfiFromNode(node: Node, ignoreClass?: string): string;
+
+ cfiFromRange(range: Range, ignoreClass?: string): string;
+
+ columns(width: number, height: number, columnWidth: number, gap: number, dir: string): void;
+
+ contentHeight(h: number): number;
+
+ contentWidth(w: number): number;
+
+ css(property: string, value: string, priority?: boolean): string;
+
+ destroy(): void;
+
+ direction(dir: string): void;
+
+ fit(width: number, height: number): void;
+
+ height(h: number): number;
+
+ locationOf(target: string | EpubCFI, ignoreClass?: string): Promise<{ top: number, left: number }>;
+
+ map(layout: any): any;
+
+ mapPage(cfiBase: string, layout: object, start: number, end: number, dev: boolean): any;
+
+ overflow(overflow: string): string;
+
+ overflowX(overflow: string): string;
+
+ overflowY(overflow: string): string;
+
+ range(cfi: string, ignoreClass?: string): Range;
+
+ removeClass(className: any): void;
+
+ root(): Element;
+
+ scaler(scale: number, offsetX: number, offsetY: number): void;
+
+ scrollHeight(): number;
+
+ scrollWidth(): number;
+
+ size(width: number, height: number): void;
+
+ textHeight(): number;
+
+ textWidth(): number;
+
+ viewport(options: ViewportSettings): ViewportSettings;
+
+ width(w: number): number;
+
+ writingMode(mode: string): string;
+
+ // 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 addEventListeners(): void;
+
+ private addSelectionListeners(): void;
+
+ private epubReadingSystem(name: string, version: string): object;
+
+ private expand(): void;
+
+ private fontLoadListeners(): void;
+
+ private imageLoadListeners(): void;
+
+ private layoutStyle(style: string): string;
+
+ private linksHandler(): void;
+
+ private listeners(): void;
+
+ private mediaQueryListeners(): void;
+
+ private onSelectionChange(e: Event): void;
+
+ private removeEventListeners(): void;
+
+ private removeListeners(): void;
+
+ private removeSelectionListeners(): void;
+
+ private resizeCheck(): void;
+
+ private resizeListeners(): void;
+
+ private resizeObservers(): void;
+
+ private transitionListeners(): void;
+
+ private triggerEvent(e: Event): void;
+
+ private triggerSelectedEvent(selection: Selection): void;
+}
diff --git a/lib/epub.js/types/core.d.ts b/lib/epub.js/types/core.d.ts
new file mode 100644
index 0000000..1858cd4
--- /dev/null
+++ b/lib/epub.js/types/core.d.ts
@@ -0,0 +1,83 @@
+export module Core {
+
+ export function uuid(): string;
+
+ export function documentHeight(): number;
+
+ export function isElement(obj: object): boolean;
+
+ export function isNumber(n: any): boolean;
+
+ export function isFloat(n: any): boolean;
+
+ export function prefixed(unprefixed: string): string;
+
+ export function defaults(obj: object): object;
+
+ export function extend(target: object): object;
+
+ export function insert(item: any, array: Array<any>, compareFunction: Function): number;
+
+ export function locationOf(item: any, array: Array<any>, compareFunction: Function, _start: Function, _end: Function): number;
+
+ export function indexOfSorted(item: any, array: Array<any>, compareFunction: Function, _start: Function, _end: Function): number;
+
+ export function bounds(el: Element): { width: Number, height: Number};
+
+ export function borders(el: Element): { width: Number, height: Number};
+
+ export function nodeBounds(node: Node): object;
+
+ export function windowBounds(): { width: Number, height: Number, top: Number, left: Number, right: Number, bottom: Number };
+
+ export function indexOfNode(node: Node, typeId: string): number;
+
+ export function indexOfTextNode(textNode: Node): number;
+
+ export function indexOfElementNode(elementNode: Element): number;
+
+ export function isXml(ext: string): boolean;
+
+ export function createBlob(content: any, mime: string): Blob;
+
+ export function createBlobUrl(content: any, mime: string): string;
+
+ export function revokeBlobUrl(url: string): void;
+
+ export function createBase64Url(content: any, mime: string): string
+
+ export function type(obj: object): string;
+
+ export function parse(markup: string, mime: string, forceXMLDom: boolean): Document;
+
+ export function qs(el: Element, sel: string): Element;
+
+ export function qsa(el: Element, sel: string): ArrayLike<Element>;
+
+ export function qsp(el: Element, sel: string, props: Array<object>): ArrayLike<Element>;
+
+ export function sprint(root: Node, func: Function): void;
+
+ export function treeWalker(root: Node, func: Function, filter: object | Function): void;
+
+ export function walk(node: Node, callback: Function): void;
+
+ export function blob2base64(blob: Blob): string;
+
+ export function defer(): Promise<any>;
+
+ export function querySelectorByType(html: Element, element: string, type: string): Array<Element>;
+
+ export function findChildren(el: Element): Array<Element>;
+
+ export function parents(node: Element): Array<Element>;
+
+ export function filterChildren(el: Element, nodeName: string, single: boolean): Array<Element>;
+
+ export function getParentByTagName(node: Element, tagname: string): Array<Element>;
+
+ export class RangeObject extends Range {
+
+ }
+
+}
diff --git a/lib/epub.js/types/epub.d.ts b/lib/epub.js/types/epub.d.ts
new file mode 100644
index 0000000..c87c9de
--- /dev/null
+++ b/lib/epub.js/types/epub.d.ts
@@ -0,0 +1,6 @@
+import Book, { BookOptions } from "./book";
+
+export default Epub;
+
+declare function Epub(urlOrData: string | ArrayBuffer, options?: BookOptions) : Book;
+declare function Epub(options?: BookOptions) : Book;
diff --git a/lib/epub.js/types/epubcfi.d.ts b/lib/epub.js/types/epubcfi.d.ts
new file mode 100644
index 0000000..f9748bb
--- /dev/null
+++ b/lib/epub.js/types/epubcfi.d.ts
@@ -0,0 +1,97 @@
+interface EpubCFISegment {
+ steps: Array<object>,
+ terminal: {
+ offset: number,
+ assertion: string
+ }
+}
+
+interface EpubCFIStep {
+ id: string,
+ tagName: string,
+ type: number,
+ index: number
+}
+
+interface EpubCFIComponent {
+ steps: Array<EpubCFIStep>,
+ terminal: {
+ offset: number,
+ assertion: string
+ }
+}
+
+export default class EpubCFI {
+ constructor(cfiFrom?: string | Range | Node, base?: string | object, ignoreClass?: string);
+
+ base: EpubCFIComponent;
+ spinePos: number;
+ range: boolean;
+
+ isCfiString(str: string): boolean;
+
+ fromNode(anchor: Node, base: string | object, ignoreClass?: string): EpubCFI;
+
+ fromRange(range: Range, base: string | object, ignoreClass?: string): EpubCFI;
+
+ parse(cfiStr: string): EpubCFI;
+
+ collapse(toStart?: boolean): void;
+
+ compare(cfiOne: string | EpubCFI, cfiTwo: string | EpubCFI): number;
+
+ equalStep(stepA: object, stepB: object): boolean;
+
+ filter(anchor: Element, ignoreClass?: string): Element | false;
+
+ toRange(_doc?: Document, ignoreClass?: string): Range;
+
+ toString(): string;
+
+ private filteredStep(node: Node, ignoreClass?: string): any;
+
+ private findNode(steps: Array<EpubCFIStep>, _doc?: Document, ignoreClass?: string): Node;
+
+ private fixMiss(steps: Array<EpubCFIStep>, offset: number, _doc?: Document, ignoreClass?: string): any;
+
+ private checkType(cfi: string | Range | Node): string | false;
+
+ private generateChapterComponent(_spineNodeIndex: number, _pos: number, id: string): string;
+
+ private getChapterComponent(cfiStr: string): string;
+
+ private getCharecterOffsetComponent(cfiStr: string): string;
+
+ private getPathComponent(cfiStr: string): string;
+
+ private getRange(cfiStr: string): string;
+
+ private joinSteps(steps: Array<EpubCFIStep>): Array<EpubCFIStep>;
+
+ private normalizedMap(children: Array<Node>, nodeType: number, ignoreClass?: string): object;
+
+ private parseComponent(componentStr: string): object;
+
+ private parseStep(stepStr: string): object;
+
+ private parseTerminal(termialStr: string): object;
+
+ private patchOffset(anchor: Node, offset: number, ignoreClass?: string): number;
+
+ private pathTo(node: Node, offset: number, ignoreClass?: string): EpubCFISegment;
+
+ private position(anchor: Node): number;
+
+ private segmentString(segment: EpubCFISegment): string;
+
+ private step(node: Node): EpubCFIStep;
+
+ private stepsToQuerySelector(steps: Array<EpubCFIStep>): string;
+
+ private stepsToXpath(steps: Array<EpubCFIStep>): string;
+
+ private textNodes(container: Node, ignoreClass?: string): Array<Node>;
+
+ private walkToNode(steps: Array<EpubCFIStep>, _doc?: Document, ignoreClass?: string): Node;
+
+}
diff --git a/lib/epub.js/types/epubjs-tests.ts b/lib/epub.js/types/epubjs-tests.ts
new file mode 100644
index 0000000..e64bb87
--- /dev/null
+++ b/lib/epub.js/types/epubjs-tests.ts
@@ -0,0 +1,9 @@
+import ePub, { Book } from '../';
+
+function testEpub() {
+ const epub = ePub("https://s3.amazonaws.com/moby-dick/moby-dick.epub");
+
+ const book = new Book("https://s3.amazonaws.com/moby-dick/moby-dick.epub", {});
+}
+
+testEpub();
diff --git a/lib/epub.js/types/index.d.ts b/lib/epub.js/types/index.d.ts
new file mode 100644
index 0000000..6a8ec9b
--- /dev/null
+++ b/lib/epub.js/types/index.d.ts
@@ -0,0 +1,20 @@
+// Type definitions for epubjs 0.3
+// Project: https://github.com/futurepress/epub.js#readme
+// Definitions by: Fred Chasen <https://github.com/fchasen>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+import Epub from "./epub";
+
+export as namespace ePub;
+
+export default Epub;
+
+export { default as Book } from './book';
+export { default as EpubCFI } from './epubcfi';
+export { default as Rendition, Location } from './rendition';
+export { default as Contents } from './contents';
+export { default as Layout } from './layout';
+export { NavItem } from './navigation';
+
+declare namespace ePub {
+
+}
diff --git a/lib/epub.js/types/layout.d.ts b/lib/epub.js/types/layout.d.ts
new file mode 100644
index 0000000..04d373d
--- /dev/null
+++ b/lib/epub.js/types/layout.d.ts
@@ -0,0 +1,48 @@
+import Contents from "./contents";
+
+interface LayoutSettings {
+ layout: string,
+ spread: string,
+ minSpreadWidth: number,
+ evenSpreads: boolean
+}
+
+export default class Layout {
+ constructor(settings: LayoutSettings);
+
+ settings: LayoutSettings;
+ name: string;
+ props: {
+ name: string,
+ spread: string,
+ flow: string,
+ width: number,
+ height: number,
+ spreadWidth: number,
+ delta: number,
+ columnWidth: number,
+ gap: number,
+ divisor: number
+ };
+
+ flow(flow: string): string;
+
+ spread(spread: string, min: number): boolean;
+
+ calculate(_width:number, _height:number, _gap?:number): void;
+
+ format(contents: Contents): void | Promise<void>;
+
+ count(totalLength: number, pageLength: number): {spreads: Number, pages: Number};
+
+ // 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 update(props: object): void;
+}
diff --git a/lib/epub.js/types/locations.d.ts b/lib/epub.js/types/locations.d.ts
new file mode 100644
index 0000000..be314da
--- /dev/null
+++ b/lib/epub.js/types/locations.d.ts
@@ -0,0 +1,41 @@
+import Spine from "./spine";
+import Section from "./section";
+import EpubCFI from "./epubcfi";
+
+export default class Locations {
+ constructor(spine: Spine, request?: Function, pause?: number);
+
+ generate(chars: number): object;
+
+ process(section: Section): Promise<Array<string>>;
+
+ locationFromCfi(cfi: string | EpubCFI): Location;
+
+ percentageFromCfi(cfi: string | EpubCFI): number;
+
+ percentageFromLocation(loc: number): number;
+
+ cfiFromLocation(loc: number): string;
+
+ cfiFromPercentage(percentage: number): string;
+
+ load(locations: string): Array<string>;
+
+ save(): string;
+
+ currentLocation(): Location;
+ currentLocation(curr: string | number): void;
+
+ length(): number;
+
+ destroy(): void;
+
+ private createRange(): {
+ startContainer: Element,
+ startOffset: number,
+ endContainer: Element,
+ endOffset: number
+ };
+
+ private parse(contents: Node, cfiBase: string, chars: number) : Array<string>;
+}
diff --git a/lib/epub.js/types/managers/manager.d.ts b/lib/epub.js/types/managers/manager.d.ts
new file mode 100644
index 0000000..5486fb1
--- /dev/null
+++ b/lib/epub.js/types/managers/manager.d.ts
@@ -0,0 +1,90 @@
+import Section from "../section";
+import Layout from "../layout";
+import Contents from "../contents";
+import View, { ViewSettings } from "./view";
+import { EpubCFIPair } from "../mapping";
+
+export interface ViewLocation {
+ index: number,
+ href: string,
+ pages: number[],
+ totalPages: number,
+ mapping: EpubCFIPair
+}
+
+export interface ManagerOptions extends ViewSettings {
+ infinite?: boolean,
+ overflow?: string,
+ [key: string]: any
+}
+
+export default class Manager {
+ constructor(options: object);
+
+ render(element: Element, size?: { width: Number, height: Number }): void;
+
+ resize(width: Number, height: Number): void;
+
+ onOrientationChange(e: Event): void;
+
+ private createView(section: Section): View;
+
+ display(section: Section, target: string | number): Promise<void>;
+
+ private afterDisplayed(view: View): void;
+
+ private afterResized(view: View): void;
+
+ private moveTo(offset: {top: Number, left: Number}): void;
+
+ private append(section: Section): Promise<void>;
+
+ private prepend(section: Section): Promise<void>;
+
+ next(): Promise<void>;
+
+ prev(): Promise<void>;
+
+ current(): View;
+
+ clear(): void;
+
+ currentLocation(): ViewLocation[];
+
+ visible(): View[];
+
+ private scrollBy(x: number, y: number, silent: boolean): void;
+
+ private scrollTo(x: number, y: number, silent: boolean): void;
+
+ private onScroll(): void;
+
+ bounds(): object;
+
+ applyLayout(layout: Layout): void;
+
+ updateLayout(): void;
+
+ setLayout(layout: Layout): void;
+
+ updateAxis(axis: string, forceUpdate: boolean): void;
+
+ updateFlow(flow: string): void;
+
+ getContents(): Contents[];
+
+ direction(dir: string): void;
+
+ isRendered(): boolean;
+
+ destroy(): void;
+
+ // 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;
+}
diff --git a/lib/epub.js/types/managers/view.d.ts b/lib/epub.js/types/managers/view.d.ts
new file mode 100644
index 0000000..559e954
--- /dev/null
+++ b/lib/epub.js/types/managers/view.d.ts
@@ -0,0 +1,79 @@
+import Section from "../section";
+import Contents from "../contents";
+import Layout from "../layout";
+
+export interface ViewSettings {
+ ignoreClass?: string,
+ axis?: string,
+ flow?: string,
+ layout?: Layout,
+ method?: string,
+ width?: number,
+ height?: number,
+ forceEvenPages?: boolean
+}
+
+export default class View {
+ constructor(section: Section, options: ViewSettings);
+
+ create(): any;
+
+ render(request?: Function, show?: boolean): Promise<void>;
+
+ reset(): void;
+
+ size(_width: Number, _height: Number): void;
+
+ load(content: Contents): Promise<any>;
+
+ setLayout(layout: Layout): void;
+
+ setAxis(axis: string): void;
+
+ display(request?: Function): Promise<any>;
+
+ show(): void;
+
+ hide(): void;
+
+ offset(): { top: Number, left: Number };
+
+ width(): Number;
+
+ height(): Number;
+
+ position(): object;
+
+ locationOf(target: string): { top: Number, left: Number };
+
+ onDisplayed(view: View): void;
+
+ onResize(view: View): void;
+
+ bounds(force?: boolean): object;
+
+ highlight(cfiRange: string, data?: object, cb?: Function, className?: string, styles?: object): void;
+
+ underline(cfiRange: string, data?: object, cb?: Function, className?: string, styles?: object): void;
+
+ mark(cfiRange: string, data?: object, cb?: Function): void;
+
+ unhighlight(cfiRange: string): void;
+
+ ununderline(cfiRange: string): void;
+
+ unmark(cfiRange: string): void;
+
+ destroy(): void;
+
+ private onLoad(event: Event, promise: Promise<any>): void;
+
+ // 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;
+}
diff --git a/lib/epub.js/types/mapping.d.ts b/lib/epub.js/types/mapping.d.ts
new file mode 100644
index 0000000..00f6bb4
--- /dev/null
+++ b/lib/epub.js/types/mapping.d.ts
@@ -0,0 +1,34 @@
+import Layout from "./layout";
+import Contents from "./contents";
+
+export interface EpubCFIPair {
+ start: string,
+ end: string
+}
+
+export interface RangePair {
+ start: Range,
+ end: Range
+}
+
+export default class Mapping {
+ constructor(layout: Layout, direction?: string, axis?: string, dev?: boolean);
+
+ page(contents: Contents, cfiBase: string, start: number, end: number): EpubCFIPair;
+
+ axis(axis: string): boolean;
+
+ private walk(root: Node, func: Function);
+
+ private findStart(root: Node, start: number, end: number): Range;
+
+ private findEnd(root: Node, start: number, end: number): Range;
+
+ private findTextStartRange(node: Node, start: number, end: number): Range;
+
+ private findTextEndRange(node: Node, start: number, end: number): Range;
+
+ private splitTextNodeIntoRanges(node: Node, _splitter?: string): Array<Range>;
+
+ private rangePairToCfiPair(cfiBase: string, rangePair: RangePair): EpubCFIPair;
+}
diff --git a/lib/epub.js/types/navigation.d.ts b/lib/epub.js/types/navigation.d.ts
new file mode 100644
index 0000000..8b4f8a0
--- /dev/null
+++ b/lib/epub.js/types/navigation.d.ts
@@ -0,0 +1,46 @@
+export interface NavItem {
+ id: string,
+ href: string,
+ label: string,
+ subitems?: Array<NavItem>,
+ parent?: string
+}
+
+export interface LandmarkItem {
+ href?: string,
+ label?: string,
+ type?: string
+}
+
+export default class Navigation {
+ constructor(xml: XMLDocument);
+
+ toc: Array<NavItem>;
+ landmarks: Array<LandmarkItem>;
+
+ parse(xml: XMLDocument): void;
+
+ get(target: string) : NavItem;
+
+ landmark(type: string) : LandmarkItem;
+
+ load(json: string): Array<NavItem>;
+
+ forEach(fn: (item: NavItem) => {}): any;
+
+ private unpack(toc: Array<NavItem>): void;
+
+ private parseNav(navHtml: XMLDocument): Array<NavItem>;
+
+ private navItem(item: Element): NavItem;
+
+ private parseLandmarks(navHtml: XMLDocument): Array<LandmarkItem>;
+
+ private landmarkItem(item: Element): LandmarkItem;
+
+ private parseNcx(navHtml: XMLDocument): Array<NavItem>;
+
+ private ncxItem(item: Element): NavItem;
+
+ private getByIndex(target: string, index: number, navItems: NavItem[]): NavItem;
+}
diff --git a/lib/epub.js/types/packaging.d.ts b/lib/epub.js/types/packaging.d.ts
new file mode 100644
index 0000000..7151956
--- /dev/null
+++ b/lib/epub.js/types/packaging.d.ts
@@ -0,0 +1,78 @@
+import { SpineItem } from "./section";
+
+export interface PackagingObject {
+ metadata: PackagingMetadataObject,
+ spine: Array<SpineItem>,
+ manifest: PackagingManifestObject,
+ navPath: string,
+ ncxPath: string,
+ coverPath: string,
+ spineNodeIndex: number
+}
+
+export interface PackagingMetadataObject {
+ title: string,
+ creator: string,
+ description: string,
+ pubdate: string,
+ publisher: string,
+ identifier: string,
+ language: string,
+ rights: string,
+ modified_date: string,
+ layout: string,
+ orientation: string,
+ flow: string,
+ viewport: string,
+ spread: string
+}
+
+export interface PackagingSpineItem {
+ idref: string,
+ properties: Array<string>,
+ index: number
+}
+
+export interface PackagingManifestItem {
+ href: string,
+ type: string,
+ properties: Array<string>
+}
+
+export interface PackagingManifestObject {
+ [key: string]: PackagingManifestItem
+}
+
+export default class Packaging {
+ constructor(packageDocument: XMLDocument);
+
+ manifest: PackagingManifestObject;
+ navPath: string;
+ ncxPath: string;
+ coverPath: string;
+ spineNodeIndex: number;
+ spine: Array<PackagingSpineItem>;
+ metadata: PackagingMetadataObject;
+
+ parse(packageDocument: XMLDocument): PackagingObject;
+
+ load(json: string): PackagingObject;
+
+ destroy(): void;
+
+ private parseMetadata(xml: Node): PackagingMetadataObject;
+
+ private parseManifest(xml: Node): PackagingManifestObject;
+
+ private parseSpine(xml: Node, manifest: PackagingManifestObject): Array<PackagingSpineItem>;
+
+ private findNavPath(manifestNode: Node): string | false;
+
+ private findNcxPath(manifestNode: Node, spineNode: Node): string | false;
+
+ private findCoverPath(packageXml: Node): string;
+
+ private getElementText(xml: Node, tag: string): string
+
+ private getPropertyText(xml: Node, property: string): string
+}
diff --git a/lib/epub.js/types/pagelist.d.ts b/lib/epub.js/types/pagelist.d.ts
new file mode 100644
index 0000000..5104098
--- /dev/null
+++ b/lib/epub.js/types/pagelist.d.ts
@@ -0,0 +1,29 @@
+export interface PageListItem {
+ href: string,
+ page: string,
+ cfi?: string,
+ packageUrl?: string
+}
+
+export default class Pagelist {
+ constructor(xml: XMLDocument);
+
+ parse(xml: XMLDocument): Array<PageListItem>;
+
+ pageFromCfi(cfi: string): number;
+
+ cfiFromPage(pg: string | number): string;
+
+ pageFromPercentage(percent: number): number;
+
+ percentageFromPage(pg: number): number;
+
+ destroy(): void;
+
+ private parseNav(navHtml: Node): Array<PageListItem>;
+
+ private item(item: Node): PageListItem;
+
+ private process(pageList: Array<PageListItem>): void;
+
+}
diff --git a/lib/epub.js/types/rendition.d.ts b/lib/epub.js/types/rendition.d.ts
new file mode 100644
index 0000000..434286c
--- /dev/null
+++ b/lib/epub.js/types/rendition.d.ts
@@ -0,0 +1,151 @@
+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,
+}
+
+export interface DisplayedLocation {
+ index: number,
+ href: string,
+ cfi: string,
+ 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;
+
+}
diff --git a/lib/epub.js/types/resources.d.ts b/lib/epub.js/types/resources.d.ts
new file mode 100644
index 0000000..f4bfb37
--- /dev/null
+++ b/lib/epub.js/types/resources.d.ts
@@ -0,0 +1,33 @@
+import { PackagingManifestObject } from "./packaging";
+import Archive from "./archive";
+
+export default class Resources {
+ constructor(manifest: PackagingManifestObject, options: {
+ replacements?: string,
+ archive?: Archive,
+ resolver?: Function,
+ request?: Function
+ });
+
+ process(manifest: PackagingManifestObject): void;
+
+ createUrl(url: string): Promise<string>;
+
+ replacements(): Promise<Array<string>>;
+
+ relativeTo(absolute: boolean, resolver?: Function): Array<string>;
+
+ get(path: string): string;
+
+ substitute(content: string, url?: string): string;
+
+ destroy(): void;
+
+ private split(): void;
+
+ private splitUrls(): void;
+
+ private replaceCss(archive: Archive, resolver?: Function): Promise<Array<string>>;
+
+ private createCssFile(href: string): Promise<string>;
+}
diff --git a/lib/epub.js/types/section.d.ts b/lib/epub.js/types/section.d.ts
new file mode 100644
index 0000000..075bef5
--- /dev/null
+++ b/lib/epub.js/types/section.d.ts
@@ -0,0 +1,64 @@
+import { HooksObject } from "./utils/hook";
+
+export interface GlobalLayout {
+ layout: string,
+ spread: string,
+ orientation: string
+}
+
+export interface LayoutSettings {
+ layout: string,
+ spread: string,
+ orientation: string
+}
+
+export interface SpineItem {
+ index: number,
+ cfiBase: string,
+ href?: string,
+ url?: string,
+ canonical?: string,
+ properties?: Array<string>,
+ linear?: string,
+ next: () => SpineItem,
+ prev: () => SpineItem,
+}
+
+export default class Section {
+ constructor(item: SpineItem, hooks: HooksObject);
+
+ idref: string;
+ linear: boolean;
+ properties: Array<string>;
+ index: number;
+ href: string;
+ url: string;
+ canonical: string;
+ next: () => SpineItem;
+ prev: () => SpineItem;
+ cfiBase: string;
+
+ document: Document;
+ contents: Element;
+ output: string;
+
+ hooks: HooksObject;
+
+ load(_request?: Function): Document;
+
+ render(_request?: Function): string;
+
+ find(_query: string): Array<Element>;
+
+ reconcileLayoutSettings(globalLayout: GlobalLayout): LayoutSettings;
+
+ cfiFromRange(_range: Range): string;
+
+ cfiFromElement(el: Element): string;
+
+ unload(): void;
+
+ destroy(): void;
+
+ private base(): void;
+}
diff --git a/lib/epub.js/types/spine.d.ts b/lib/epub.js/types/spine.d.ts
new file mode 100644
index 0000000..6cd59ce
--- /dev/null
+++ b/lib/epub.js/types/spine.d.ts
@@ -0,0 +1,30 @@
+import Packaging from "./packaging";
+import Section from "./section";
+import Hook from "./utils/hook";
+
+export default class Spine {
+ constructor();
+
+ hooks: {
+ serialize: Hook,
+ content: Hook
+ };
+
+ unpack(_package: Packaging, resolver: Function, canonical: Function): void;
+
+ get(target?: string | number): Section;
+
+ each(...args: any[]): any;
+
+ first(): Section;
+
+ last(): Section;
+
+ destroy(): void;
+
+ private append(section: Section): number;
+
+ private prepend(section: Section): number;
+
+ private remove(section: Section): number;
+}
diff --git a/lib/epub.js/types/store.d.ts b/lib/epub.js/types/store.d.ts
new file mode 100644
index 0000000..655a17d
--- /dev/null
+++ b/lib/epub.js/types/store.d.ts
@@ -0,0 +1,30 @@
+import localForage = require('localforage');
+import Resources from "./resources";
+
+export default class Store {
+ constructor(name: string, request?: Function, resolver?: Function);
+
+ add(resources: Resources, force?: boolean): Promise<Array<object>>;
+
+ put(url: string, withCredentials?: boolean, headers?: object): Promise<Blob>;
+
+ request(url: string, type?: string, withCredentials?: boolean, headers?: object): Promise<Blob | string | JSON | Document | XMLDocument>;
+
+ retrieve(url: string, type?: string): Promise<Blob | string | JSON | Document | XMLDocument>;
+
+ getBlob(url: string, mimeType?: string): Promise<Blob>;
+
+ getText(url: string): Promise<string>;
+
+ getBase64(url: string, mimeType?: string): Promise<string>;
+
+ createUrl(url: string, options: { base64: boolean }): Promise<string>;
+
+ revokeUrl(url: string): void;
+
+ destroy(): void;
+
+ private checkRequirements(): void;
+
+ private handleResponse(response: any, type?: string): Blob | string | JSON | Document | XMLDocument;
+}
diff --git a/lib/epub.js/types/themes.d.ts b/lib/epub.js/types/themes.d.ts
new file mode 100644
index 0000000..465a127
--- /dev/null
+++ b/lib/epub.js/types/themes.d.ts
@@ -0,0 +1,40 @@
+import Rendition from "./rendition";
+import Contents from "./contents";
+
+export default class Themes {
+ constructor(rendition: Rendition);
+
+ register( themeObject: object ): void;
+
+ register( theme: string, url: string ): void;
+
+ register( theme: string, themeObject: object ): void;
+
+ default( theme: object | string ): void;
+
+ registerThemes( themes: object ): void;
+
+ registerCss( name: string, css: string ): void;
+
+ registerUrl( name: string, input: string ): void;
+
+ registerRules( name: string, rules: object ): void;
+
+ select( name: string ): void;
+
+ update( name: string ): void;
+
+ inject( content: Contents ): void;
+
+ add( name: string, contents: Contents ): void;
+
+ override(name: string, value: string, priority?: boolean): void;
+
+ overrides(contents: Contents): void;
+
+ fontSize(size: string): void;
+
+ font(f: string): void;
+
+ destroy(): void;
+}
diff --git a/lib/epub.js/types/tsconfig.json b/lib/epub.js/types/tsconfig.json
new file mode 100644
index 0000000..546c5a3
--- /dev/null
+++ b/lib/epub.js/types/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6",
+ "dom"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.d.ts",
+ "epubjs-tests.ts"
+ ]
+}
diff --git a/lib/epub.js/types/tslint.json b/lib/epub.js/types/tslint.json
new file mode 100644
index 0000000..e26ec8f
--- /dev/null
+++ b/lib/epub.js/types/tslint.json
@@ -0,0 +1,4 @@
+{
+ "extends": "dtslint/dt.json",
+ "rules": {}
+}
diff --git a/lib/epub.js/types/utils/constants.d.ts b/lib/epub.js/types/utils/constants.d.ts
new file mode 100644
index 0000000..1c5c5c5
--- /dev/null
+++ b/lib/epub.js/types/utils/constants.d.ts
@@ -0,0 +1,9 @@
+export const EPUBJS_VERSION: string;
+
+export const DOM_EVENTS: Array<string>;
+
+export const EVENTS: {
+ [key: string]: {
+ [key: string]: string
+ }
+}
diff --git a/lib/epub.js/types/utils/core.d.ts b/lib/epub.js/types/utils/core.d.ts
new file mode 100644
index 0000000..6469a66
--- /dev/null
+++ b/lib/epub.js/types/utils/core.d.ts
@@ -0,0 +1,79 @@
+export function uuid(): string;
+
+export function documentHeight(): number;
+
+export function isElement(obj: object): boolean;
+
+export function isNumber(n: any): boolean;
+
+export function isFloat(n: any): boolean;
+
+export function prefixed(unprefixed: string): string;
+
+export function defaults(obj: object): object;
+
+export function extend(target: object): object;
+
+export function insert(item: any, array: Array<any>, compareFunction: Function): number;
+
+export function locationOf(item: any, array: Array<any>, compareFunction: Function, _start: Function, _end: Function): number;
+
+export function indexOfSorted(item: any, array: Array<any>, compareFunction: Function, _start: Function, _end: Function): number;
+
+export function bounds(el: Element): { width: Number, height: Number};
+
+export function borders(el: Element): { width: Number, height: Number};
+
+export function nodeBounds(node: Node): object;
+
+export function windowBounds(): { width: Number, height: Number, top: Number, left: Number, right: Number, bottom: Number };
+
+export function indexOfNode(node: Node, typeId: string): number;
+
+export function indexOfTextNode(textNode: Node): number;
+
+export function indexOfElementNode(elementNode: Element): number;
+
+export function isXml(ext: string): boolean;
+
+export function createBlob(content: any, mime: string): Blob;
+
+export function createBlobUrl(content: any, mime: string): string;
+
+export function revokeBlobUrl(url: string): void;
+
+export function createBase64Url(content: any, mime: string): string
+
+export function type(obj: object): string;
+
+export function parse(markup: string, mime: string, forceXMLDom: boolean): Document;
+
+export function qs(el: Element, sel: string): Element;
+
+export function qsa(el: Element, sel: string): ArrayLike<Element>;
+
+export function qsp(el: Element, sel: string, props: Array<object>): ArrayLike<Element>;
+
+export function sprint(root: Node, func: Function): void;
+
+export function treeWalker(root: Node, func: Function, filter: object | Function): void;
+
+export function walk(node: Node, callback: Function): void;
+
+export function blob2base64(blob: Blob): string;
+
+export function defer(): Promise<any>;
+
+export function querySelectorByType(html: Element, element: string, type: string): Array<Element>;
+
+export function findChildren(el: Element): Array<Element>;
+
+export function parents(node: Element): Array<Element>;
+
+export function filterChildren(el: Element, nodeName: string, single: boolean): Array<Element>;
+
+export function getParentByTagName(node: Element, tagname: string): Array<Element>;
+
+export class RangeObject extends Range {
+
+}
diff --git a/lib/epub.js/types/utils/hook.d.ts b/lib/epub.js/types/utils/hook.d.ts
new file mode 100644
index 0000000..9db1491
--- /dev/null
+++ b/lib/epub.js/types/utils/hook.d.ts
@@ -0,0 +1,18 @@
+interface HooksObject {
+ [key: string]: Hook
+}
+
+export default class Hook {
+ constructor(context: any);
+
+ register(func: Function): void;
+ register(arr: Array<Function>): void;
+
+ deregister(func: Function): void;
+
+ trigger(...args: any[]): Promise<any>;
+
+ list(): Array<any>;
+
+ clear(): void;
+}
diff --git a/lib/epub.js/types/utils/path.d.ts b/lib/epub.js/types/utils/path.d.ts
new file mode 100644
index 0000000..b91e88b
--- /dev/null
+++ b/lib/epub.js/types/utils/path.d.ts
@@ -0,0 +1,17 @@
+export default class Path {
+ constructor(pathString: string);
+
+ parse(what: string): object;
+
+ isAbsolute(what: string): boolean;
+
+ isDirectory(what: string): boolean;
+
+ resolve(what: string): string;
+
+ relative(what: string): string;
+
+ splitPath(filename: string): string;
+
+ toString(): string;
+}
diff --git a/lib/epub.js/types/utils/queue.d.ts b/lib/epub.js/types/utils/queue.d.ts
new file mode 100644
index 0000000..4813ef6
--- /dev/null
+++ b/lib/epub.js/types/utils/queue.d.ts
@@ -0,0 +1,34 @@
+import { defer } from "./core";
+
+export interface QueuedTask {
+ task: any | Task,
+ args: any[],
+ deferred: any, // should be defer, but not working
+ promise: Promise<any>
+}
+
+export default class Queue {
+ constructor(context: any);
+
+ enqueue(func: Promise<Function> | Function, ...args: any[]): Promise<any>;
+
+ dequeue(): Promise<QueuedTask>;
+
+ dump(): void;
+
+ run(): Promise<void>;
+
+ flush(): Promise<void>;
+
+ clear(): void;
+
+ length(): number;
+
+ pause(): void;
+
+ stop(): void;
+}
+
+declare class Task {
+ constructor(task: any, args: any[], context: any);
+}
diff --git a/lib/epub.js/types/utils/replacements.d.ts b/lib/epub.js/types/utils/replacements.d.ts
new file mode 100644
index 0000000..9728ee4
--- /dev/null
+++ b/lib/epub.js/types/utils/replacements.d.ts
@@ -0,0 +1,12 @@
+import Section from "../section";
+import Contents from "../contents";
+
+export function replaceBase(doc: Document, section: Section): void;
+
+export function replaceCanonical(doc: Document, section: Section): void;
+
+export function replaceMeta(doc: Document, section: Section): void;
+
+export function replaceLinks(contents: Contents, fn: Function): void;
+
+export function substitute(contents: Contents, urls: string[], replacements: string[]): void;
diff --git a/lib/epub.js/types/utils/request.d.ts b/lib/epub.js/types/utils/request.d.ts
new file mode 100644
index 0000000..e6c9653
--- /dev/null
+++ b/lib/epub.js/types/utils/request.d.ts
@@ -0,0 +1 @@
+export default function request(url: string, type?: string, withCredentials?: boolean, headers?: object): Promise<Blob | string | JSON | Document | XMLDocument>;
diff --git a/lib/epub.js/types/utils/scrolltype.d.ts b/lib/epub.js/types/utils/scrolltype.d.ts
new file mode 100644
index 0000000..f1dd74f
--- /dev/null
+++ b/lib/epub.js/types/utils/scrolltype.d.ts
@@ -0,0 +1,3 @@
+export default function scrollType(): string;
+
+export function createDefiner(): Node;
diff --git a/lib/epub.js/types/utils/url.d.ts b/lib/epub.js/types/utils/url.d.ts
new file mode 100644
index 0000000..bf30dfb
--- /dev/null
+++ b/lib/epub.js/types/utils/url.d.ts
@@ -0,0 +1,13 @@
+import Path from "./path";
+
+export default class Url {
+ constructor(urlString: string, baseString: string);
+
+ path(): Path;
+
+ resolve(what: string): string;
+
+ relative(what: string): string;
+
+ toString(): string;
+}