mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00
Added type declarations
This commit is contained in:
parent
0da286b0a2
commit
6bfcd1e4eb
50 changed files with 1837 additions and 54 deletions
9
types/utils/constants.d.ts
vendored
Normal file
9
types/utils/constants.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
export const EPUBJS_VERSION: string;
|
||||
|
||||
export const DOM_EVENTS: Array<string>;
|
||||
|
||||
export const EVENTS: {
|
||||
[key: string]: {
|
||||
[key: string]: string
|
||||
}
|
||||
}
|
79
types/utils/core.d.ts
vendored
Normal file
79
types/utils/core.d.ts
vendored
Normal file
|
@ -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 {
|
||||
|
||||
}
|
16
types/utils/hook.d.ts
vendored
Normal file
16
types/utils/hook.d.ts
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
interface HooksObject {
|
||||
[key: string]: Hook
|
||||
}
|
||||
|
||||
export default class Hook {
|
||||
constructor(context: any);
|
||||
|
||||
register(func: Function): void;
|
||||
register(arr: Array<Function>): void;
|
||||
|
||||
trigger(...args: any[]): Promise<any>;
|
||||
|
||||
list(): Array<any>;
|
||||
|
||||
clear(): void;
|
||||
}
|
17
types/utils/path.d.ts
vendored
Normal file
17
types/utils/path.d.ts
vendored
Normal file
|
@ -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;
|
||||
}
|
34
types/utils/queue.d.ts
vendored
Normal file
34
types/utils/queue.d.ts
vendored
Normal file
|
@ -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);
|
||||
}
|
12
types/utils/replacements.d.ts
vendored
Normal file
12
types/utils/replacements.d.ts
vendored
Normal file
|
@ -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;
|
1
types/utils/request.d.ts
vendored
Normal file
1
types/utils/request.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export default function request(url: string, type: string, withCredentials: boolean, headers: object): Promise<Blob | string | JSON | Document | XMLDocument>;
|
13
types/utils/url.d.ts
vendored
Normal file
13
types/utils/url.d.ts
vendored
Normal file
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue