-
Notifications
You must be signed in to change notification settings - Fork 308
/
epub.d.ts
96 lines (82 loc) · 2.23 KB
/
epub.d.ts
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
// Type definitions for epub
// Project: https://github.com/julien-c/epub
// Definitions by: Julien Chaumond <https://github.com/julien-c>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/**
* new EPub(fname[, imageroot][, linkroot])
* - fname (String): filename for the ebook
* - imageroot (String): URL prefix for images
* - linkroot (String): URL prefix for links
*
* Creates an Event Emitter type object for parsing epub files
*
* var epub = new EPub("book.epub");
* epub.on("end", function () {
* console.log(epub.spine);
* });
* epub.on("error", function (error) { ... });
* epub.parse();
*
* Image and link URL format is:
*
* imageroot + img_id + img_zip_path
*
* So an image "logo.jpg" which resides in "OPT/" in the zip archive
* and is listed in the manifest with id "logo_img" will have the
* following url (providing that imageroot is "/images/"):
*
* /images/logo_img/OPT/logo.jpg
**/
import { EventEmitter } from 'events'
declare class EPub extends EventEmitter {
constructor(epubfile: string, imagewebroot?: string, chapterwebroot?: string)
metadata: EPub.Metadata
manifest: Object
spine: {
toc: { href: string; id: string }
contents: Array<EPub.TocElement>
}
flow: Array<EPub.TocElement>
toc: Array<EPub.TocElement>
parse(options?: EPub.parseOptions): void
getChapter(
chapterId: string,
callback: (error: Error, text: string) => void
): void
getChapterRaw(
chapterId: string,
callback: (error: Error, text: string) => void
): void
getImage(
id: string,
callback: (error: Error, data: Buffer, mimeType: string) => void
): void
getFile(
id: string,
callback: (error: Error, data: Buffer, mimeType: string) => void
): void
hasDRM(): boolean
}
export = EPub
declare namespace EPub {
export interface TocElement {
level: number
order: number
title: string
id: string
href: string
}
export interface Metadata {
creator: string
creatorFileAs: string
title: string
language: string
subject: string
date: string
description: string
}
export interface parseOptions {
xml2jsOptions: object
}
}