@likecoin/epub-ts 0.3.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/annotations.d.ts +159 -0
- package/dist/archive.d.ts +82 -0
- package/dist/book.d.ts +228 -0
- package/dist/container.d.ts +18 -0
- package/dist/contents.d.ts +351 -0
- package/dist/displayoptions.d.ts +20 -0
- package/dist/epub.cjs +10 -0
- package/dist/epub.cjs.map +1 -0
- package/dist/epub.d.ts +17 -0
- package/dist/epub.js +9500 -0
- package/dist/epub.js.map +1 -0
- package/dist/epub.umd.js +10 -0
- package/dist/epub.umd.js.map +1 -0
- package/dist/epubcfi.d.ts +116 -0
- package/dist/index.d.ts +8 -0
- package/dist/layout.d.ts +77 -0
- package/dist/locations.d.ts +117 -0
- package/dist/managers/continuous/index.d.ts +46 -0
- package/dist/managers/default/index.d.ts +117 -0
- package/dist/managers/helpers/snap.d.ts +63 -0
- package/dist/managers/helpers/stage.d.ts +41 -0
- package/dist/managers/helpers/views.d.ts +27 -0
- package/dist/managers/views/iframe.d.ts +114 -0
- package/dist/managers/views/inline.d.ts +65 -0
- package/dist/mapping.d.ts +97 -0
- package/dist/marks-pane/index.d.ts +40 -0
- package/dist/navigation.d.ts +108 -0
- package/dist/packaging.d.ts +104 -0
- package/dist/pagelist.d.ts +80 -0
- package/dist/rendition.d.ts +293 -0
- package/dist/resources.d.ts +97 -0
- package/dist/section.d.ts +88 -0
- package/dist/spine.d.ts +79 -0
- package/dist/store.d.ts +122 -0
- package/dist/themes.d.ts +103 -0
- package/dist/types.d.ts +269 -0
- package/dist/utils/constants.d.ts +59 -0
- package/dist/utils/core.d.ts +337 -0
- package/dist/utils/event-emitter.d.ts +6 -0
- package/dist/utils/hook.d.ts +30 -0
- package/dist/utils/mime.d.ts +5 -0
- package/dist/utils/path-utils.d.ts +14 -0
- package/dist/utils/path.d.ts +55 -0
- package/dist/utils/queue.d.ts +66 -0
- package/dist/utils/replacements.d.ts +11 -0
- package/dist/utils/request.d.ts +2 -0
- package/dist/utils/scrolltype.d.ts +2 -0
- package/dist/utils/url.d.ts +42 -0
- package/license +28 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# epub.ts (`@likecoin/epub-ts`)
|
|
2
|
+
|
|
3
|
+
A TypeScript fork of [epubjs](https://github.com/futurepress/epub.js) v0.3.93 by [Fred Chasen](https://github.com/fchasen) / [FuturePress](https://github.com/futurepress) — parse and render EPUB documents in the browser.
|
|
4
|
+
|
|
5
|
+
This library is primarily developed for internal use at [3ook.com](https://3ook.com) and is provided as-is. It was mainly built with AI-assisted development.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @likecoin/epub-ts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import ePub from "@likecoin/epub-ts";
|
|
17
|
+
|
|
18
|
+
// Same API as epubjs
|
|
19
|
+
const book = ePub("/path/to/book.epub");
|
|
20
|
+
const rendition = book.renderTo("viewer", { width: 600, height: 400 });
|
|
21
|
+
rendition.display();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Migration from epubjs
|
|
25
|
+
|
|
26
|
+
This is a drop-in replacement. Change your import:
|
|
27
|
+
|
|
28
|
+
```diff
|
|
29
|
+
- import ePub from "epubjs";
|
|
30
|
+
+ import ePub from "@likecoin/epub-ts";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
All APIs remain the same.
|
|
34
|
+
|
|
35
|
+
## Named Exports
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { Book, EpubCFI, Rendition, Contents, Layout } from "@likecoin/epub-ts";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## What's Changed
|
|
42
|
+
|
|
43
|
+
- Build: webpack + Babel → Vite
|
|
44
|
+
- Tests: Karma + Mocha → Vitest
|
|
45
|
+
- Source: JavaScript → TypeScript (incremental conversion)
|
|
46
|
+
- Removed dependencies: `core-js`, `lodash`, `path-webpack`
|
|
47
|
+
- Replaced `event-emitter` with inline typed emitter
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install
|
|
53
|
+
npm run build # Vite library build → dist/
|
|
54
|
+
npm test # Vitest
|
|
55
|
+
npm run typecheck # tsc --noEmit
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Contributing
|
|
59
|
+
|
|
60
|
+
See [PROJECT_STATUS.md](./PROJECT_STATUS.md) for current conversion progress and what to work on.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
BSD-2-Clause (same as epubjs)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { IEventEmitter } from './types';
|
|
2
|
+
import { default as Rendition } from './rendition';
|
|
3
|
+
interface AnnotationView {
|
|
4
|
+
index: number;
|
|
5
|
+
highlight: Function;
|
|
6
|
+
underline: Function;
|
|
7
|
+
mark: Function;
|
|
8
|
+
unhighlight: Function;
|
|
9
|
+
ununderline: Function;
|
|
10
|
+
unmark: Function;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Handles managing adding & removing Annotations
|
|
14
|
+
* @param {Rendition} rendition
|
|
15
|
+
* @class
|
|
16
|
+
*/
|
|
17
|
+
declare class Annotations {
|
|
18
|
+
rendition: Rendition;
|
|
19
|
+
highlights: Annotation[];
|
|
20
|
+
underlines: Annotation[];
|
|
21
|
+
marks: Annotation[];
|
|
22
|
+
_annotations: Record<string, Annotation>;
|
|
23
|
+
_annotationsBySectionIndex: Record<number, string[]>;
|
|
24
|
+
constructor(rendition: Rendition);
|
|
25
|
+
/**
|
|
26
|
+
* Add an annotation to store
|
|
27
|
+
* @param {string} type Type of annotation to add: "highlight", "underline", "mark"
|
|
28
|
+
* @param {EpubCFI} cfiRange EpubCFI range to attach annotation to
|
|
29
|
+
* @param {object} data Data to assign to annotation
|
|
30
|
+
* @param {function} [cb] Callback after annotation is added
|
|
31
|
+
* @param {string} className CSS class to assign to annotation
|
|
32
|
+
* @param {object} styles CSS styles to assign to annotation
|
|
33
|
+
* @returns {Annotation} annotation
|
|
34
|
+
*/
|
|
35
|
+
add(type: string, cfiRange: string, data?: Record<string, any>, cb?: Function, className?: string, styles?: Record<string, string>): Annotation;
|
|
36
|
+
/**
|
|
37
|
+
* Remove an annotation from store
|
|
38
|
+
* @param {EpubCFI} cfiRange EpubCFI range the annotation is attached to
|
|
39
|
+
* @param {string} type Type of annotation to add: "highlight", "underline", "mark"
|
|
40
|
+
*/
|
|
41
|
+
remove(cfiRange: string, type?: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Remove an annotations by Section Index
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
_removeFromAnnotationBySectionIndex(sectionIndex: number, hash: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Get annotations by Section Index
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
_annotationsAt(index: number): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Add a highlight to the store
|
|
54
|
+
* @param {EpubCFI} cfiRange EpubCFI range to attach annotation to
|
|
55
|
+
* @param {object} data Data to assign to annotation
|
|
56
|
+
* @param {function} cb Callback after annotation is clicked
|
|
57
|
+
* @param {string} className CSS class to assign to annotation
|
|
58
|
+
* @param {object} styles CSS styles to assign to annotation
|
|
59
|
+
*/
|
|
60
|
+
highlight(cfiRange: string, data?: Record<string, any>, cb?: Function, className?: string, styles?: Record<string, string>): Annotation;
|
|
61
|
+
/**
|
|
62
|
+
* Add a underline to the store
|
|
63
|
+
* @param {EpubCFI} cfiRange EpubCFI range to attach annotation to
|
|
64
|
+
* @param {object} data Data to assign to annotation
|
|
65
|
+
* @param {function} cb Callback after annotation is clicked
|
|
66
|
+
* @param {string} className CSS class to assign to annotation
|
|
67
|
+
* @param {object} styles CSS styles to assign to annotation
|
|
68
|
+
*/
|
|
69
|
+
underline(cfiRange: string, data?: Record<string, any>, cb?: Function, className?: string, styles?: Record<string, string>): Annotation;
|
|
70
|
+
/**
|
|
71
|
+
* Add a mark to the store
|
|
72
|
+
* @param {EpubCFI} cfiRange EpubCFI range to attach annotation to
|
|
73
|
+
* @param {object} data Data to assign to annotation
|
|
74
|
+
* @param {function} cb Callback after annotation is clicked
|
|
75
|
+
*/
|
|
76
|
+
mark(cfiRange: string, data?: Record<string, any>, cb?: Function): Annotation;
|
|
77
|
+
/**
|
|
78
|
+
* iterate over annotations in the store
|
|
79
|
+
*/
|
|
80
|
+
each(..._args: any[]): any;
|
|
81
|
+
/**
|
|
82
|
+
* Hook for injecting annotation into a view
|
|
83
|
+
* @param {View} view
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
inject(view: AnnotationView): void;
|
|
87
|
+
/**
|
|
88
|
+
* Hook for removing annotation from a view
|
|
89
|
+
* @param {View} view
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
clear(view: AnnotationView): void;
|
|
93
|
+
/**
|
|
94
|
+
* [Not Implemented] Show annotations
|
|
95
|
+
* @TODO: needs implementation in View
|
|
96
|
+
*/
|
|
97
|
+
show(): void;
|
|
98
|
+
/**
|
|
99
|
+
* [Not Implemented] Hide annotations
|
|
100
|
+
* @TODO: needs implementation in View
|
|
101
|
+
*/
|
|
102
|
+
hide(): void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Annotation object
|
|
106
|
+
* @class
|
|
107
|
+
* @param {object} options
|
|
108
|
+
* @param {string} options.type Type of annotation to add: "highlight", "underline", "mark"
|
|
109
|
+
* @param {EpubCFI} options.cfiRange EpubCFI range to attach annotation to
|
|
110
|
+
* @param {object} options.data Data to assign to annotation
|
|
111
|
+
* @param {int} options.sectionIndex Index in the Spine of the Section annotation belongs to
|
|
112
|
+
* @param {function} [options.cb] Callback after annotation is clicked
|
|
113
|
+
* @param {string} className CSS class to assign to annotation
|
|
114
|
+
* @param {object} styles CSS styles to assign to annotation
|
|
115
|
+
* @returns {Annotation} annotation
|
|
116
|
+
*/
|
|
117
|
+
declare class Annotation implements IEventEmitter {
|
|
118
|
+
type: string;
|
|
119
|
+
cfiRange: string;
|
|
120
|
+
data: Record<string, any>;
|
|
121
|
+
sectionIndex: number;
|
|
122
|
+
mark: object | undefined;
|
|
123
|
+
cb: Function;
|
|
124
|
+
className: string;
|
|
125
|
+
styles: Record<string, string>;
|
|
126
|
+
on: IEventEmitter["on"];
|
|
127
|
+
off: IEventEmitter["off"];
|
|
128
|
+
emit: IEventEmitter["emit"];
|
|
129
|
+
constructor({ type, cfiRange, data, sectionIndex, cb, className, styles }: {
|
|
130
|
+
type: string;
|
|
131
|
+
cfiRange: string;
|
|
132
|
+
data?: Record<string, any>;
|
|
133
|
+
sectionIndex?: number;
|
|
134
|
+
cb?: Function;
|
|
135
|
+
className?: string;
|
|
136
|
+
styles?: Record<string, string>;
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* Update stored data
|
|
140
|
+
* @param {object} data
|
|
141
|
+
*/
|
|
142
|
+
update(data: Record<string, any>): void;
|
|
143
|
+
/**
|
|
144
|
+
* Add to a view
|
|
145
|
+
* @param {View} view
|
|
146
|
+
*/
|
|
147
|
+
attach(view: AnnotationView): object | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Remove from a view
|
|
150
|
+
* @param {View} view
|
|
151
|
+
*/
|
|
152
|
+
detach(view: AnnotationView): object | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* [Not Implemented] Get text of an annotation
|
|
155
|
+
* @TODO: needs implementation in contents
|
|
156
|
+
*/
|
|
157
|
+
text(): void;
|
|
158
|
+
}
|
|
159
|
+
export default Annotations;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { default as JSZip } from 'jszip';
|
|
2
|
+
/**
|
|
3
|
+
* Handles Unzipping a requesting files from an Epub Archive
|
|
4
|
+
* @class
|
|
5
|
+
*/
|
|
6
|
+
declare class Archive {
|
|
7
|
+
zip: JSZip;
|
|
8
|
+
urlCache: Record<string, string>;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Checks to see if JSZip exists in global namspace,
|
|
12
|
+
* Requires JSZip if it isn't there
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
checkRequirements(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Open an archive
|
|
18
|
+
* @param {binary} input
|
|
19
|
+
* @param {boolean} [isBase64] tells JSZip if the input data is base64 encoded
|
|
20
|
+
* @return {Promise} zipfile
|
|
21
|
+
*/
|
|
22
|
+
open(input: ArrayBuffer | string | Blob, isBase64?: boolean): Promise<JSZip>;
|
|
23
|
+
/**
|
|
24
|
+
* Load and Open an archive
|
|
25
|
+
* @param {string} zipUrl
|
|
26
|
+
* @param {boolean} [isBase64] tells JSZip if the input data is base64 encoded
|
|
27
|
+
* @return {Promise} zipfile
|
|
28
|
+
*/
|
|
29
|
+
openUrl(zipUrl: string, isBase64?: boolean): Promise<JSZip>;
|
|
30
|
+
/**
|
|
31
|
+
* Request a url from the archive
|
|
32
|
+
* @param {string} url a url to request from the archive
|
|
33
|
+
* @param {string} [type] specify the type of the returned result
|
|
34
|
+
* @return {Promise<Blob | string | JSON | Document | XMLDocument>}
|
|
35
|
+
*/
|
|
36
|
+
request(url: string, type?: string): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* Handle the response from request
|
|
39
|
+
* @private
|
|
40
|
+
* @param {any} response
|
|
41
|
+
* @param {string} [type]
|
|
42
|
+
* @return {any} the parsed result
|
|
43
|
+
*/
|
|
44
|
+
handleResponse(response: any, type?: string): any;
|
|
45
|
+
/**
|
|
46
|
+
* Get a Blob from Archive by Url
|
|
47
|
+
* @param {string} url
|
|
48
|
+
* @param {string} [mimeType]
|
|
49
|
+
* @return {Blob}
|
|
50
|
+
*/
|
|
51
|
+
getBlob(url: string, mimeType?: string): Promise<Blob> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get Text from Archive by Url
|
|
54
|
+
* @param {string} url
|
|
55
|
+
* @param {string} [encoding]
|
|
56
|
+
* @return {string}
|
|
57
|
+
*/
|
|
58
|
+
getText(url: string, _encoding?: string): Promise<string> | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Get a base64 encoded result from Archive by Url
|
|
61
|
+
* @param {string} url
|
|
62
|
+
* @param {string} [mimeType]
|
|
63
|
+
* @return {string} base64 encoded
|
|
64
|
+
*/
|
|
65
|
+
getBase64(url: string, mimeType?: string): Promise<string> | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Create a Url from an unarchived item
|
|
68
|
+
* @param {string} url
|
|
69
|
+
* @param {object} [options.base64] use base64 encoding or blob url
|
|
70
|
+
* @return {Promise} url promise with Url string
|
|
71
|
+
*/
|
|
72
|
+
createUrl(url: string, options?: {
|
|
73
|
+
base64?: boolean;
|
|
74
|
+
}): Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Revoke Temp Url for a archive item
|
|
77
|
+
* @param {string} url url of the item in the archive
|
|
78
|
+
*/
|
|
79
|
+
revokeUrl(url: string): void;
|
|
80
|
+
destroy(): void;
|
|
81
|
+
}
|
|
82
|
+
export default Archive;
|
package/dist/book.d.ts
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { defer } from './utils/core';
|
|
2
|
+
import { default as Url } from './utils/url';
|
|
3
|
+
import { default as Path } from './utils/path';
|
|
4
|
+
import { default as Spine } from './spine';
|
|
5
|
+
import { default as Locations } from './locations';
|
|
6
|
+
import { default as Container } from './container';
|
|
7
|
+
import { default as Packaging } from './packaging';
|
|
8
|
+
import { default as Navigation } from './navigation';
|
|
9
|
+
import { default as Resources } from './resources';
|
|
10
|
+
import { default as PageList } from './pagelist';
|
|
11
|
+
import { default as Rendition } from './rendition';
|
|
12
|
+
import { default as Archive } from './archive';
|
|
13
|
+
import { default as Store } from './store';
|
|
14
|
+
import { default as DisplayOptions } from './displayoptions';
|
|
15
|
+
import { IEventEmitter, BookOptions, RenditionOptions, RequestFunction } from './types';
|
|
16
|
+
import { default as Section } from './section';
|
|
17
|
+
interface BookLoadingState {
|
|
18
|
+
manifest: defer;
|
|
19
|
+
spine: defer;
|
|
20
|
+
metadata: defer;
|
|
21
|
+
cover: defer;
|
|
22
|
+
navigation: defer;
|
|
23
|
+
pageList: defer;
|
|
24
|
+
resources: defer;
|
|
25
|
+
displayOptions: defer;
|
|
26
|
+
}
|
|
27
|
+
interface BookLoadedState {
|
|
28
|
+
manifest: Promise<any>;
|
|
29
|
+
spine: Promise<any>;
|
|
30
|
+
metadata: Promise<any>;
|
|
31
|
+
cover: Promise<any>;
|
|
32
|
+
navigation: Promise<any>;
|
|
33
|
+
pageList: Promise<any>;
|
|
34
|
+
resources: Promise<any>;
|
|
35
|
+
displayOptions: Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* An Epub representation with methods for the loading, parsing and manipulation
|
|
39
|
+
* of its contents.
|
|
40
|
+
* @class
|
|
41
|
+
* @param {string} [url]
|
|
42
|
+
* @param {object} [options]
|
|
43
|
+
* @param {method} [options.requestMethod] a request function to use instead of the default
|
|
44
|
+
* @param {boolean} [options.requestCredentials=undefined] send the xhr request withCredentials
|
|
45
|
+
* @param {object} [options.requestHeaders=undefined] send the xhr request headers
|
|
46
|
+
* @param {string} [options.encoding=binary] optional to pass 'binary' or base64' for archived Epubs
|
|
47
|
+
* @param {string} [options.replacements=none] use base64, blobUrl, or none for replacing assets in archived Epubs
|
|
48
|
+
* @param {method} [options.canonical] optional function to determine canonical urls for a path
|
|
49
|
+
* @param {string} [options.openAs] optional string to determine the input type
|
|
50
|
+
* @param {string} [options.store=false] cache the contents in local storage, value should be the name of the reader
|
|
51
|
+
* @returns {Book}
|
|
52
|
+
* @example new Book("/path/to/book.epub", {})
|
|
53
|
+
* @example new Book({ replacements: "blobUrl" })
|
|
54
|
+
*/
|
|
55
|
+
declare class Book implements IEventEmitter {
|
|
56
|
+
settings: BookOptions & Record<string, any>;
|
|
57
|
+
opening: defer;
|
|
58
|
+
opened: Promise<Book> | undefined;
|
|
59
|
+
isOpen: boolean;
|
|
60
|
+
loading: BookLoadingState | undefined;
|
|
61
|
+
loaded: BookLoadedState | undefined;
|
|
62
|
+
ready: Promise<any[]> | undefined;
|
|
63
|
+
isRendered: boolean;
|
|
64
|
+
request: RequestFunction;
|
|
65
|
+
spine: Spine | undefined;
|
|
66
|
+
locations: Locations | undefined;
|
|
67
|
+
navigation: Navigation | undefined;
|
|
68
|
+
pageList: PageList | undefined;
|
|
69
|
+
url: Url | undefined;
|
|
70
|
+
path: Path | undefined;
|
|
71
|
+
archived: boolean;
|
|
72
|
+
archive: Archive | undefined;
|
|
73
|
+
storage: Store | undefined;
|
|
74
|
+
resources: Resources | undefined;
|
|
75
|
+
rendition: Rendition | undefined;
|
|
76
|
+
container: Container | undefined;
|
|
77
|
+
packaging: Packaging | undefined;
|
|
78
|
+
displayOptions: DisplayOptions | undefined;
|
|
79
|
+
package: Packaging | undefined;
|
|
80
|
+
cover: string;
|
|
81
|
+
on: IEventEmitter["on"];
|
|
82
|
+
off: IEventEmitter["off"];
|
|
83
|
+
emit: IEventEmitter["emit"];
|
|
84
|
+
constructor(url?: string | ArrayBuffer | Blob | BookOptions, options?: BookOptions);
|
|
85
|
+
/**
|
|
86
|
+
* Open a epub or url
|
|
87
|
+
* @param {string | ArrayBuffer} input Url, Path or ArrayBuffer
|
|
88
|
+
* @param {string} [what="binary", "base64", "epub", "opf", "json", "directory"] force opening as a certain type
|
|
89
|
+
* @returns {Promise} of when the book has been loaded
|
|
90
|
+
* @example book.open("/path/to/book.epub")
|
|
91
|
+
*/
|
|
92
|
+
open(input: string | ArrayBuffer | Blob, what?: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Open an archived epub
|
|
95
|
+
* @private
|
|
96
|
+
* @param {binary} data
|
|
97
|
+
* @param {string} [encoding]
|
|
98
|
+
* @return {Promise}
|
|
99
|
+
*/
|
|
100
|
+
openEpub(data: string | ArrayBuffer | Blob, encoding?: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Open the epub container
|
|
103
|
+
* @private
|
|
104
|
+
* @param {string} url
|
|
105
|
+
* @return {string} packagePath
|
|
106
|
+
*/
|
|
107
|
+
openContainer(url: string): Promise<string>;
|
|
108
|
+
/**
|
|
109
|
+
* Open the Open Packaging Format Xml
|
|
110
|
+
* @private
|
|
111
|
+
* @param {string} url
|
|
112
|
+
* @return {Promise}
|
|
113
|
+
*/
|
|
114
|
+
openPackaging(url: string): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Open the manifest JSON
|
|
117
|
+
* @private
|
|
118
|
+
* @param {string} url
|
|
119
|
+
* @return {Promise}
|
|
120
|
+
*/
|
|
121
|
+
openManifest(url: string): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Load a resource from the Book
|
|
124
|
+
* @param {string} path path to the resource to load
|
|
125
|
+
* @return {Promise} returns a promise with the requested resource
|
|
126
|
+
*/
|
|
127
|
+
load(path: string, _type?: string): Promise<any>;
|
|
128
|
+
/**
|
|
129
|
+
* Resolve a path to it's absolute position in the Book
|
|
130
|
+
* @param {string} path
|
|
131
|
+
* @param {boolean} [absolute] force resolving the full URL
|
|
132
|
+
* @return {string} the resolved path string
|
|
133
|
+
*/
|
|
134
|
+
resolve(path: string, absolute?: boolean): string;
|
|
135
|
+
/**
|
|
136
|
+
* Get a canonical link to a path
|
|
137
|
+
* @param {string} path
|
|
138
|
+
* @return {string} the canonical path string
|
|
139
|
+
*/
|
|
140
|
+
canonical(path: string): string;
|
|
141
|
+
/**
|
|
142
|
+
* Determine the type of they input passed to open
|
|
143
|
+
* @private
|
|
144
|
+
* @param {string} input
|
|
145
|
+
* @return {string} binary | directory | epub | opf
|
|
146
|
+
*/
|
|
147
|
+
determineType(input: string | ArrayBuffer | Blob): string;
|
|
148
|
+
/**
|
|
149
|
+
* unpack the contents of the Books packaging
|
|
150
|
+
* @private
|
|
151
|
+
* @param {Packaging} packaging object
|
|
152
|
+
*/
|
|
153
|
+
unpack(packaging: Packaging): void;
|
|
154
|
+
/**
|
|
155
|
+
* Load Navigation and PageList from package
|
|
156
|
+
* @private
|
|
157
|
+
* @param {Packaging} packaging
|
|
158
|
+
*/
|
|
159
|
+
loadNavigation(packaging: Packaging): Promise<Navigation>;
|
|
160
|
+
/**
|
|
161
|
+
* Gets a Section of the Book from the Spine
|
|
162
|
+
* Alias for `book.spine.get`
|
|
163
|
+
* @param {string} target
|
|
164
|
+
* @return {Section}
|
|
165
|
+
*/
|
|
166
|
+
section(target: string | number): Section | null;
|
|
167
|
+
/**
|
|
168
|
+
* Sugar to render a book to an element
|
|
169
|
+
* @param {element | string} element element or string to add a rendition to
|
|
170
|
+
* @param {object} [options]
|
|
171
|
+
* @return {Rendition}
|
|
172
|
+
*/
|
|
173
|
+
renderTo(element: HTMLElement | string, options?: RenditionOptions): Rendition;
|
|
174
|
+
/**
|
|
175
|
+
* Set if request should use withCredentials
|
|
176
|
+
* @param {boolean} credentials
|
|
177
|
+
*/
|
|
178
|
+
setRequestCredentials(credentials: boolean): void;
|
|
179
|
+
/**
|
|
180
|
+
* Set headers request should use
|
|
181
|
+
* @param {object} headers
|
|
182
|
+
*/
|
|
183
|
+
setRequestHeaders(headers: Record<string, string>): void;
|
|
184
|
+
/**
|
|
185
|
+
* Unarchive a zipped epub
|
|
186
|
+
* @private
|
|
187
|
+
* @param {binary} input epub data
|
|
188
|
+
* @param {string} [encoding]
|
|
189
|
+
* @return {Archive}
|
|
190
|
+
*/
|
|
191
|
+
unarchive(input: string | ArrayBuffer | Blob, encoding?: string): Promise<any>;
|
|
192
|
+
/**
|
|
193
|
+
* Store the epubs contents
|
|
194
|
+
* @private
|
|
195
|
+
* @param {binary} input epub data
|
|
196
|
+
* @param {string} [encoding]
|
|
197
|
+
* @return {Store}
|
|
198
|
+
*/
|
|
199
|
+
store(name: string | boolean): Store;
|
|
200
|
+
/**
|
|
201
|
+
* Get the cover url
|
|
202
|
+
* @return {Promise<?string>} coverUrl
|
|
203
|
+
*/
|
|
204
|
+
coverUrl(): Promise<string | null>;
|
|
205
|
+
/**
|
|
206
|
+
* Load replacement urls
|
|
207
|
+
* @private
|
|
208
|
+
* @return {Promise} completed loading urls
|
|
209
|
+
*/
|
|
210
|
+
replacements(): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* Find a DOM Range for a given CFI Range
|
|
213
|
+
* @param {EpubCFI} cfiRange a epub cfi range
|
|
214
|
+
* @return {Promise}
|
|
215
|
+
*/
|
|
216
|
+
getRange(cfiRange: string): Promise<Range>;
|
|
217
|
+
/**
|
|
218
|
+
* Generates the Book Key using the identifier in the manifest or other string provided
|
|
219
|
+
* @param {string} [identifier] to use instead of metadata identifier
|
|
220
|
+
* @return {string} key
|
|
221
|
+
*/
|
|
222
|
+
key(identifier?: string): string;
|
|
223
|
+
/**
|
|
224
|
+
* Destroy the Book and all associated objects
|
|
225
|
+
*/
|
|
226
|
+
destroy(): void;
|
|
227
|
+
}
|
|
228
|
+
export default Book;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles Parsing and Accessing an Epub Container
|
|
3
|
+
* @class
|
|
4
|
+
* @param {document} [containerDocument] xml document
|
|
5
|
+
*/
|
|
6
|
+
declare class Container {
|
|
7
|
+
packagePath: string;
|
|
8
|
+
directory: string;
|
|
9
|
+
encoding: string;
|
|
10
|
+
constructor(containerDocument?: Document);
|
|
11
|
+
/**
|
|
12
|
+
* Parse the Container XML
|
|
13
|
+
* @param {document} containerDocument
|
|
14
|
+
*/
|
|
15
|
+
parse(containerDocument: Document): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
export default Container;
|