@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { default as EpubCFI } from '../../epubcfi';
|
|
2
|
+
import { default as Contents } from '../../contents';
|
|
3
|
+
import { Pane, Mark } from '../../marks-pane';
|
|
4
|
+
import { IEventEmitter, ViewSettings, ReframeBounds, RequestFunction } from '../../types';
|
|
5
|
+
import { default as Section } from '../../section';
|
|
6
|
+
import { default as Layout } from '../../layout';
|
|
7
|
+
declare class IframeView implements IEventEmitter {
|
|
8
|
+
settings: ViewSettings;
|
|
9
|
+
id: string;
|
|
10
|
+
section: Section;
|
|
11
|
+
index: number;
|
|
12
|
+
element: HTMLElement;
|
|
13
|
+
added: boolean;
|
|
14
|
+
displayed: boolean;
|
|
15
|
+
rendered: boolean;
|
|
16
|
+
fixedWidth: number;
|
|
17
|
+
fixedHeight: number;
|
|
18
|
+
epubcfi: EpubCFI;
|
|
19
|
+
layout: Layout;
|
|
20
|
+
pane: Pane | undefined;
|
|
21
|
+
highlights: Record<string, {
|
|
22
|
+
mark: Mark;
|
|
23
|
+
element: SVGElement | null;
|
|
24
|
+
listeners: (Function | undefined)[];
|
|
25
|
+
}>;
|
|
26
|
+
underlines: Record<string, {
|
|
27
|
+
mark: Mark;
|
|
28
|
+
element: SVGElement | null;
|
|
29
|
+
listeners: (Function | undefined)[];
|
|
30
|
+
}>;
|
|
31
|
+
marks: Record<string, {
|
|
32
|
+
element: HTMLAnchorElement;
|
|
33
|
+
range: Range;
|
|
34
|
+
listeners: (Function | undefined)[];
|
|
35
|
+
}>;
|
|
36
|
+
iframe: HTMLIFrameElement | undefined;
|
|
37
|
+
resizing: boolean;
|
|
38
|
+
_width: number;
|
|
39
|
+
_height: number;
|
|
40
|
+
_textWidth: number;
|
|
41
|
+
_textHeight: number;
|
|
42
|
+
_contentWidth: number;
|
|
43
|
+
_contentHeight: number;
|
|
44
|
+
_needsReframe: boolean;
|
|
45
|
+
_expanding: boolean;
|
|
46
|
+
elementBounds: {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
supportsSrcdoc: boolean;
|
|
51
|
+
sectionRender: Promise<string>;
|
|
52
|
+
lockedWidth: number;
|
|
53
|
+
lockedHeight: number;
|
|
54
|
+
prevBounds: ReframeBounds | undefined;
|
|
55
|
+
blobUrl: string;
|
|
56
|
+
document: Document;
|
|
57
|
+
window: Window;
|
|
58
|
+
contents: Contents | undefined;
|
|
59
|
+
rendering: boolean;
|
|
60
|
+
writingMode: string;
|
|
61
|
+
stopExpanding: boolean;
|
|
62
|
+
axis: string;
|
|
63
|
+
on: IEventEmitter["on"];
|
|
64
|
+
off: IEventEmitter["off"];
|
|
65
|
+
emit: IEventEmitter["emit"];
|
|
66
|
+
constructor(section: Section, options?: ViewSettings);
|
|
67
|
+
container(axis?: string): HTMLElement;
|
|
68
|
+
create(): HTMLIFrameElement;
|
|
69
|
+
render(request: RequestFunction, _show?: boolean): Promise<void>;
|
|
70
|
+
reset(): void;
|
|
71
|
+
size(_width?: number, _height?: number): void;
|
|
72
|
+
lock(what: string, width: number, height: number): void;
|
|
73
|
+
expand(_force?: boolean): void;
|
|
74
|
+
reframe(width: number, height: number): void;
|
|
75
|
+
load(contents: string): Promise<Contents>;
|
|
76
|
+
onLoad(event: Event, promise: {
|
|
77
|
+
resolve: (value?: any) => void;
|
|
78
|
+
reject: (reason?: any) => void;
|
|
79
|
+
}): void;
|
|
80
|
+
setLayout(layout: Layout): void;
|
|
81
|
+
setAxis(axis: string): void;
|
|
82
|
+
setWritingMode(mode: string): void;
|
|
83
|
+
addListeners(): void;
|
|
84
|
+
removeListeners(_layoutFunc?: Function): void;
|
|
85
|
+
display(request: RequestFunction): Promise<IframeView>;
|
|
86
|
+
show(): void;
|
|
87
|
+
hide(): void;
|
|
88
|
+
offset(): {
|
|
89
|
+
top: number;
|
|
90
|
+
left: number;
|
|
91
|
+
};
|
|
92
|
+
width(): number;
|
|
93
|
+
height(): number;
|
|
94
|
+
position(): DOMRect;
|
|
95
|
+
locationOf(target: string): {
|
|
96
|
+
left: number;
|
|
97
|
+
top: number;
|
|
98
|
+
};
|
|
99
|
+
onDisplayed(_view: IframeView): void;
|
|
100
|
+
onResize(_view: IframeView, _e?: ReframeBounds): void;
|
|
101
|
+
bounds(force?: boolean): {
|
|
102
|
+
width: number;
|
|
103
|
+
height: number;
|
|
104
|
+
};
|
|
105
|
+
highlight(cfiRange: string, data?: Record<string, string>, cb?: Function, className?: string, styles?: Record<string, string>): Mark | undefined;
|
|
106
|
+
underline(cfiRange: string, data?: Record<string, string>, cb?: Function, className?: string, styles?: Record<string, string>): Mark | undefined;
|
|
107
|
+
mark(cfiRange: string, data?: Record<string, string>, cb?: Function): any;
|
|
108
|
+
placeMark(element: HTMLElement, range: Range): void;
|
|
109
|
+
unhighlight(cfiRange: string): void;
|
|
110
|
+
ununderline(cfiRange: string): void;
|
|
111
|
+
unmark(cfiRange: string): void;
|
|
112
|
+
destroy(): void;
|
|
113
|
+
}
|
|
114
|
+
export default IframeView;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { IEventEmitter, ViewSettings } from '../../types';
|
|
2
|
+
declare class InlineView implements IEventEmitter {
|
|
3
|
+
settings: any;
|
|
4
|
+
id: string;
|
|
5
|
+
section: any;
|
|
6
|
+
index: number;
|
|
7
|
+
element: HTMLElement;
|
|
8
|
+
added: boolean;
|
|
9
|
+
displayed: boolean;
|
|
10
|
+
rendered: boolean;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
fixedWidth: number;
|
|
14
|
+
fixedHeight: number;
|
|
15
|
+
epubcfi: any;
|
|
16
|
+
layout: any;
|
|
17
|
+
frame: HTMLDivElement;
|
|
18
|
+
resizing: boolean;
|
|
19
|
+
_width: number;
|
|
20
|
+
_height: number;
|
|
21
|
+
_textWidth: number;
|
|
22
|
+
_textHeight: number;
|
|
23
|
+
_needsReframe: boolean;
|
|
24
|
+
_expanding: boolean;
|
|
25
|
+
elementBounds: any;
|
|
26
|
+
prevBounds: any;
|
|
27
|
+
lockedWidth: number;
|
|
28
|
+
lockedHeight: number;
|
|
29
|
+
document: Document;
|
|
30
|
+
window: Window;
|
|
31
|
+
contents: any;
|
|
32
|
+
rendering: boolean;
|
|
33
|
+
stopExpanding: boolean;
|
|
34
|
+
on: IEventEmitter["on"];
|
|
35
|
+
off: IEventEmitter["off"];
|
|
36
|
+
emit: IEventEmitter["emit"];
|
|
37
|
+
constructor(section: any, options?: ViewSettings);
|
|
38
|
+
container(axis?: string): HTMLElement;
|
|
39
|
+
create(): HTMLDivElement;
|
|
40
|
+
render(request: any, show?: boolean): Promise<any>;
|
|
41
|
+
size(_width?: number, _height?: number): void;
|
|
42
|
+
lock(what: string, width: number, height: number): void;
|
|
43
|
+
expand(_force?: boolean): void;
|
|
44
|
+
contentWidth(_min?: number): number;
|
|
45
|
+
contentHeight(_min?: number): number;
|
|
46
|
+
resize(width: any, height: any): void;
|
|
47
|
+
load(contents: string): Promise<any>;
|
|
48
|
+
setLayout(layout: any): void;
|
|
49
|
+
resizeListenters(): void;
|
|
50
|
+
addListeners(): void;
|
|
51
|
+
removeListeners(_layoutFunc?: any): void;
|
|
52
|
+
display(request: any): Promise<any>;
|
|
53
|
+
show(): void;
|
|
54
|
+
hide(): void;
|
|
55
|
+
position(): DOMRect;
|
|
56
|
+
locationOf(target: any): {
|
|
57
|
+
left: number;
|
|
58
|
+
top: number;
|
|
59
|
+
};
|
|
60
|
+
onDisplayed(_view: any): void;
|
|
61
|
+
onResize(_view: any, _e?: any): void;
|
|
62
|
+
bounds(): any;
|
|
63
|
+
destroy(): void;
|
|
64
|
+
}
|
|
65
|
+
export default InlineView;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { EpubCFIPair, RangePair, LayoutProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Map text locations to CFI ranges
|
|
4
|
+
* @class
|
|
5
|
+
* @param {Layout} layout Layout to apply
|
|
6
|
+
* @param {string} [direction="ltr"] Text direction
|
|
7
|
+
* @param {string} [axis="horizontal"] vertical or horizontal axis
|
|
8
|
+
* @param {boolean} [dev] toggle developer highlighting
|
|
9
|
+
*/
|
|
10
|
+
declare class Mapping {
|
|
11
|
+
layout: LayoutProps;
|
|
12
|
+
horizontal: boolean;
|
|
13
|
+
direction: string;
|
|
14
|
+
_dev: boolean;
|
|
15
|
+
constructor(layout: LayoutProps, direction?: string, axis?: string, dev?: boolean);
|
|
16
|
+
/**
|
|
17
|
+
* Find CFI pairs for entire section at once
|
|
18
|
+
*/
|
|
19
|
+
section(view: any): EpubCFIPair[];
|
|
20
|
+
/**
|
|
21
|
+
* Find CFI pairs for a page
|
|
22
|
+
* @param {Contents} contents Contents from view
|
|
23
|
+
* @param {string} cfiBase string of the base for a cfi
|
|
24
|
+
* @param {number} start position to start at
|
|
25
|
+
* @param {number} end position to end at
|
|
26
|
+
*/
|
|
27
|
+
page(contents: any, cfiBase: string, start: number, end: number): EpubCFIPair | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Walk a node, preforming a function on each node it finds
|
|
30
|
+
* @private
|
|
31
|
+
* @param {Node} root Node to walkToNode
|
|
32
|
+
* @param {function} func walk function
|
|
33
|
+
* @return {*} returns the result of the walk function
|
|
34
|
+
*/
|
|
35
|
+
walk(root: Node, func: (node: Node) => Node | undefined): Node | undefined;
|
|
36
|
+
findRanges(view: any): any[];
|
|
37
|
+
/**
|
|
38
|
+
* Find Start Range
|
|
39
|
+
* @private
|
|
40
|
+
* @param {Node} root root node
|
|
41
|
+
* @param {number} start position to start at
|
|
42
|
+
* @param {number} end position to end at
|
|
43
|
+
* @return {Range}
|
|
44
|
+
*/
|
|
45
|
+
findStart(root: Node, start: number, end: number): Range;
|
|
46
|
+
/**
|
|
47
|
+
* Find End Range
|
|
48
|
+
* @private
|
|
49
|
+
* @param {Node} root root node
|
|
50
|
+
* @param {number} start position to start at
|
|
51
|
+
* @param {number} end position to end at
|
|
52
|
+
* @return {Range}
|
|
53
|
+
*/
|
|
54
|
+
findEnd(root: Node, start: number, end: number): Range;
|
|
55
|
+
/**
|
|
56
|
+
* Find Text Start Range
|
|
57
|
+
* @private
|
|
58
|
+
* @param {Node} root root node
|
|
59
|
+
* @param {number} start position to start at
|
|
60
|
+
* @param {number} end position to end at
|
|
61
|
+
* @return {Range}
|
|
62
|
+
*/
|
|
63
|
+
findTextStartRange(node: Node, start: number, end: number): Range;
|
|
64
|
+
/**
|
|
65
|
+
* Find Text End Range
|
|
66
|
+
* @private
|
|
67
|
+
* @param {Node} root root node
|
|
68
|
+
* @param {number} start position to start at
|
|
69
|
+
* @param {number} end position to end at
|
|
70
|
+
* @return {Range}
|
|
71
|
+
*/
|
|
72
|
+
findTextEndRange(node: Node, start: number, end: number): Range;
|
|
73
|
+
/**
|
|
74
|
+
* Split up a text node into ranges for each word
|
|
75
|
+
* @private
|
|
76
|
+
* @param {Node} root root node
|
|
77
|
+
* @param {string} [_splitter] what to split on
|
|
78
|
+
* @return {Range[]}
|
|
79
|
+
*/
|
|
80
|
+
splitTextNodeIntoRanges(node: Node, _splitter?: string): Range[];
|
|
81
|
+
/**
|
|
82
|
+
* Turn a pair of ranges into a pair of CFIs
|
|
83
|
+
* @private
|
|
84
|
+
* @param {string} cfiBase base string for an EpubCFI
|
|
85
|
+
* @param {object} rangePair { start: Range, end: Range }
|
|
86
|
+
* @return {object} { start: "epubcfi(...)", end: "epubcfi(...)" }
|
|
87
|
+
*/
|
|
88
|
+
rangePairToCfiPair(cfiBase: string, rangePair: RangePair): EpubCFIPair;
|
|
89
|
+
rangeListToCfiList(cfiBase: string, columns: RangePair[]): EpubCFIPair[];
|
|
90
|
+
/**
|
|
91
|
+
* Set the axis for mapping
|
|
92
|
+
* @param {string} axis horizontal | vertical
|
|
93
|
+
* @return {boolean} is it horizontal?
|
|
94
|
+
*/
|
|
95
|
+
axis(axis?: string): boolean;
|
|
96
|
+
}
|
|
97
|
+
export default Mapping;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined from marks-pane v1.0.9 (https://github.com/fchasen/marks)
|
|
3
|
+
* SVG-based text annotation marks (highlights, underlines) for iframes.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Pane {
|
|
6
|
+
target: HTMLElement | HTMLIFrameElement;
|
|
7
|
+
element: SVGElement;
|
|
8
|
+
marks: Mark[];
|
|
9
|
+
container: HTMLElement;
|
|
10
|
+
constructor(target: HTMLElement | HTMLIFrameElement, container?: HTMLElement);
|
|
11
|
+
addMark(mark: Mark): Mark;
|
|
12
|
+
removeMark(mark: Mark): void;
|
|
13
|
+
render(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class Mark {
|
|
16
|
+
element: SVGElement | null;
|
|
17
|
+
container: HTMLElement;
|
|
18
|
+
range: Range;
|
|
19
|
+
constructor();
|
|
20
|
+
bind(element: SVGElement, container: HTMLElement): void;
|
|
21
|
+
unbind(): SVGElement | null;
|
|
22
|
+
render(): void;
|
|
23
|
+
dispatchEvent(e: Event): void;
|
|
24
|
+
getBoundingClientRect(): DOMRect;
|
|
25
|
+
getClientRects(): DOMRect[];
|
|
26
|
+
filteredRanges(): DOMRect[];
|
|
27
|
+
}
|
|
28
|
+
export declare class Highlight extends Mark {
|
|
29
|
+
range: Range;
|
|
30
|
+
className: string;
|
|
31
|
+
data: Record<string, string>;
|
|
32
|
+
attributes: Record<string, string>;
|
|
33
|
+
constructor(range: Range, className: string, data?: Record<string, string>, attributes?: Record<string, string>);
|
|
34
|
+
bind(element: SVGElement, container: HTMLElement): void;
|
|
35
|
+
render(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare class Underline extends Highlight {
|
|
38
|
+
constructor(range: Range, className: string, data?: Record<string, string>, attributes?: Record<string, string>);
|
|
39
|
+
render(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { NavItem, LandmarkItem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Navigation Parser
|
|
4
|
+
* @param {document} xml navigation html / xhtml / ncx
|
|
5
|
+
*/
|
|
6
|
+
declare class Navigation {
|
|
7
|
+
toc: NavItem[];
|
|
8
|
+
tocByHref: Record<string, number>;
|
|
9
|
+
tocById: Record<string, number>;
|
|
10
|
+
landmarks: LandmarkItem[];
|
|
11
|
+
landmarksByType: Record<string, number>;
|
|
12
|
+
length: number;
|
|
13
|
+
constructor(xml?: Document | NavItem[]);
|
|
14
|
+
/**
|
|
15
|
+
* Parse out the navigation items
|
|
16
|
+
* @param {document} xml navigation html / xhtml / ncx
|
|
17
|
+
*/
|
|
18
|
+
parse(xml: Document | NavItem[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Unpack navigation items
|
|
21
|
+
* @private
|
|
22
|
+
* @param {array} toc
|
|
23
|
+
*/
|
|
24
|
+
unpack(toc: NavItem[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get an item from the navigation
|
|
27
|
+
* @param {string} target
|
|
28
|
+
* @return {object} navItem
|
|
29
|
+
*/
|
|
30
|
+
get(target?: string): NavItem | NavItem[] | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get an item from navigation subitems recursively by index
|
|
33
|
+
* @param {string} target
|
|
34
|
+
* @param {number} index
|
|
35
|
+
* @param {array} navItems
|
|
36
|
+
* @return {object} navItem
|
|
37
|
+
*/
|
|
38
|
+
getByIndex(target: string, index: number | undefined, navItems: NavItem[]): NavItem | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Get a landmark by type
|
|
41
|
+
* List of types: https://idpf.github.io/epub-vocabs/structure/
|
|
42
|
+
* @param {string} type
|
|
43
|
+
* @return {object} landmarkItem
|
|
44
|
+
*/
|
|
45
|
+
landmark(type?: string): LandmarkItem | LandmarkItem[] | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Parse toc from a Epub > 3.0 Nav
|
|
48
|
+
* @private
|
|
49
|
+
* @param {document} navHtml
|
|
50
|
+
* @return {array} navigation list
|
|
51
|
+
*/
|
|
52
|
+
parseNav(navHtml: Document): NavItem[];
|
|
53
|
+
/**
|
|
54
|
+
* Parses lists in the toc
|
|
55
|
+
* @param {document} navListHtml
|
|
56
|
+
* @param {string} parent id
|
|
57
|
+
* @return {array} navigation list
|
|
58
|
+
*/
|
|
59
|
+
parseNavList(navListHtml: Element, parent?: string): NavItem[];
|
|
60
|
+
/**
|
|
61
|
+
* Create a navItem
|
|
62
|
+
* @private
|
|
63
|
+
* @param {element} item
|
|
64
|
+
* @return {object} navItem
|
|
65
|
+
*/
|
|
66
|
+
navItem(item: Element, parent?: string): NavItem | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Parse landmarks from a Epub > 3.0 Nav
|
|
69
|
+
* @private
|
|
70
|
+
* @param {document} navHtml
|
|
71
|
+
* @return {array} landmarks list
|
|
72
|
+
*/
|
|
73
|
+
parseLandmarks(navHtml: Document): LandmarkItem[];
|
|
74
|
+
/**
|
|
75
|
+
* Create a landmarkItem
|
|
76
|
+
* @private
|
|
77
|
+
* @param {element} item
|
|
78
|
+
* @return {object} landmarkItem
|
|
79
|
+
*/
|
|
80
|
+
landmarkItem(item: Element): LandmarkItem | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Parse from a Epub > 3.0 NC
|
|
83
|
+
* @private
|
|
84
|
+
* @param {document} navHtml
|
|
85
|
+
* @return {array} navigation list
|
|
86
|
+
*/
|
|
87
|
+
parseNcx(tocXml: Document): NavItem[];
|
|
88
|
+
/**
|
|
89
|
+
* Create a ncxItem
|
|
90
|
+
* @private
|
|
91
|
+
* @param {element} item
|
|
92
|
+
* @return {object} ncxItem
|
|
93
|
+
*/
|
|
94
|
+
ncxItem(item: Element): NavItem;
|
|
95
|
+
/**
|
|
96
|
+
* Load Spine Items
|
|
97
|
+
* @param {object} json the items to be loaded
|
|
98
|
+
* @return {Array} navItems
|
|
99
|
+
*/
|
|
100
|
+
load(json: any[]): NavItem[];
|
|
101
|
+
/**
|
|
102
|
+
* forEach pass through
|
|
103
|
+
* @param {Function} fn function to run on each item
|
|
104
|
+
* @return {method} forEach loop
|
|
105
|
+
*/
|
|
106
|
+
forEach(fn: (item: NavItem, index: number, array: NavItem[]) => void): void;
|
|
107
|
+
}
|
|
108
|
+
export default Navigation;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { PackagingMetadataObject, PackagingSpineItem, PackagingManifestObject, PackagingObject, NavItem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Open Packaging Format Parser
|
|
4
|
+
* @class
|
|
5
|
+
* @param {document} packageDocument OPF XML
|
|
6
|
+
*/
|
|
7
|
+
declare class Packaging {
|
|
8
|
+
manifest: PackagingManifestObject;
|
|
9
|
+
navPath: string;
|
|
10
|
+
ncxPath: string;
|
|
11
|
+
coverPath: string;
|
|
12
|
+
spineNodeIndex: number;
|
|
13
|
+
spine: PackagingSpineItem[];
|
|
14
|
+
metadata: PackagingMetadataObject;
|
|
15
|
+
uniqueIdentifier: string;
|
|
16
|
+
toc: NavItem[];
|
|
17
|
+
constructor(packageDocument?: Document);
|
|
18
|
+
/**
|
|
19
|
+
* Parse OPF XML
|
|
20
|
+
* @param {document} packageDocument OPF XML
|
|
21
|
+
* @return {object} parsed package parts
|
|
22
|
+
*/
|
|
23
|
+
parse(packageDocument: Document): PackagingObject;
|
|
24
|
+
/**
|
|
25
|
+
* Parse Metadata
|
|
26
|
+
* @private
|
|
27
|
+
* @param {node} xml
|
|
28
|
+
* @return {object} metadata
|
|
29
|
+
*/
|
|
30
|
+
parseMetadata(xml: Element): PackagingMetadataObject;
|
|
31
|
+
/**
|
|
32
|
+
* Parse Manifest
|
|
33
|
+
* @private
|
|
34
|
+
* @param {node} manifestXml
|
|
35
|
+
* @return {object} manifest
|
|
36
|
+
*/
|
|
37
|
+
parseManifest(manifestXml: Element): PackagingManifestObject;
|
|
38
|
+
/**
|
|
39
|
+
* Parse Spine
|
|
40
|
+
* @private
|
|
41
|
+
* @param {node} spineXml
|
|
42
|
+
* @param {Packaging.manifest} manifest
|
|
43
|
+
* @return {object} spine
|
|
44
|
+
*/
|
|
45
|
+
parseSpine(spineXml: Element, _manifest: PackagingManifestObject): PackagingSpineItem[];
|
|
46
|
+
/**
|
|
47
|
+
* Find Unique Identifier
|
|
48
|
+
* @private
|
|
49
|
+
* @param {node} packageXml
|
|
50
|
+
* @return {string} Unique Identifier text
|
|
51
|
+
*/
|
|
52
|
+
findUniqueIdentifier(packageXml: Document): string;
|
|
53
|
+
/**
|
|
54
|
+
* Find TOC NAV
|
|
55
|
+
* @private
|
|
56
|
+
* @param {element} manifestNode
|
|
57
|
+
* @return {string}
|
|
58
|
+
*/
|
|
59
|
+
findNavPath(manifestNode: Element): string;
|
|
60
|
+
/**
|
|
61
|
+
* Find TOC NCX
|
|
62
|
+
* media-type="application/x-dtbncx+xml" href="toc.ncx"
|
|
63
|
+
* @private
|
|
64
|
+
* @param {element} manifestNode
|
|
65
|
+
* @param {element} spineNode
|
|
66
|
+
* @return {string}
|
|
67
|
+
*/
|
|
68
|
+
findNcxPath(manifestNode: Element, spineNode: Element): string;
|
|
69
|
+
/**
|
|
70
|
+
* Find the Cover Path
|
|
71
|
+
* <item properties="cover-image" id="ci" href="cover.svg" media-type="image/svg+xml" />
|
|
72
|
+
* Fallback for Epub 2.0
|
|
73
|
+
* @private
|
|
74
|
+
* @param {node} packageXml
|
|
75
|
+
* @return {string} href
|
|
76
|
+
*/
|
|
77
|
+
findCoverPath(packageXml: Document): string;
|
|
78
|
+
/**
|
|
79
|
+
* Get text of a namespaced element
|
|
80
|
+
* @private
|
|
81
|
+
* @param {node} xml
|
|
82
|
+
* @param {string} tag
|
|
83
|
+
* @return {string} text
|
|
84
|
+
*/
|
|
85
|
+
getElementText(xml: Element, tag: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Get text by property
|
|
88
|
+
* @private
|
|
89
|
+
* @param {node} xml
|
|
90
|
+
* @param {string} property
|
|
91
|
+
* @return {string} text
|
|
92
|
+
*/
|
|
93
|
+
getPropertyText(xml: Element, property: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Load JSON Manifest
|
|
96
|
+
* @param {document} packageDocument OPF XML
|
|
97
|
+
* @return {object} parsed package parts
|
|
98
|
+
*/
|
|
99
|
+
load(json: Record<string, any>): PackagingObject & {
|
|
100
|
+
toc: NavItem[];
|
|
101
|
+
};
|
|
102
|
+
destroy(): void;
|
|
103
|
+
}
|
|
104
|
+
export default Packaging;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { default as EpubCFI } from './epubcfi';
|
|
2
|
+
import { PageListItem } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Page List Parser
|
|
5
|
+
* @param {document} [xml]
|
|
6
|
+
*/
|
|
7
|
+
declare class PageList {
|
|
8
|
+
pages: number[];
|
|
9
|
+
locations: string[];
|
|
10
|
+
epubcfi: EpubCFI;
|
|
11
|
+
firstPage: number;
|
|
12
|
+
lastPage: number;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
toc: Document | undefined;
|
|
15
|
+
ncx: Document | undefined;
|
|
16
|
+
pageList: PageListItem[];
|
|
17
|
+
constructor(xml?: Document);
|
|
18
|
+
/**
|
|
19
|
+
* Parse PageList Xml
|
|
20
|
+
* @param {document} xml
|
|
21
|
+
*/
|
|
22
|
+
parse(xml: Document): PageListItem[];
|
|
23
|
+
/**
|
|
24
|
+
* Parse a Nav PageList
|
|
25
|
+
* @private
|
|
26
|
+
* @param {node} navHtml
|
|
27
|
+
* @return {PageList.item[]} list
|
|
28
|
+
*/
|
|
29
|
+
parseNav(navHtml: Document): PageListItem[];
|
|
30
|
+
parseNcx(navXml: Document): PageListItem[];
|
|
31
|
+
ncxItem(item: Element): PageListItem;
|
|
32
|
+
/**
|
|
33
|
+
* Page List Item
|
|
34
|
+
* @private
|
|
35
|
+
* @param {node} item
|
|
36
|
+
* @return {object} pageListItem
|
|
37
|
+
*/
|
|
38
|
+
item(item: Element): PageListItem;
|
|
39
|
+
/**
|
|
40
|
+
* Process pageList items
|
|
41
|
+
* @private
|
|
42
|
+
* @param {array} pageList
|
|
43
|
+
*/
|
|
44
|
+
process(pageList: PageListItem[]): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get a PageList result from a EpubCFI
|
|
47
|
+
* @param {string} cfi EpubCFI String
|
|
48
|
+
* @return {number} page
|
|
49
|
+
*/
|
|
50
|
+
pageFromCfi(cfi: string): number;
|
|
51
|
+
/**
|
|
52
|
+
* Get an EpubCFI from a Page List Item
|
|
53
|
+
* @param {string | number} pg
|
|
54
|
+
* @return {string} cfi
|
|
55
|
+
*/
|
|
56
|
+
cfiFromPage(pg: string | number): string | number;
|
|
57
|
+
/**
|
|
58
|
+
* Get a Page from Book percentage
|
|
59
|
+
* @param {number} percent
|
|
60
|
+
* @return {number} page
|
|
61
|
+
*/
|
|
62
|
+
pageFromPercentage(percent: number): number;
|
|
63
|
+
/**
|
|
64
|
+
* Returns a value between 0 - 1 corresponding to the location of a page
|
|
65
|
+
* @param {number} pg the page
|
|
66
|
+
* @return {number} percentage
|
|
67
|
+
*/
|
|
68
|
+
percentageFromPage(pg: number): number;
|
|
69
|
+
/**
|
|
70
|
+
* Returns a value between 0 - 1 corresponding to the location of a cfi
|
|
71
|
+
* @param {string} cfi EpubCFI String
|
|
72
|
+
* @return {number} percentage
|
|
73
|
+
*/
|
|
74
|
+
percentageFromCfi(cfi: string): number;
|
|
75
|
+
/**
|
|
76
|
+
* Destroy
|
|
77
|
+
*/
|
|
78
|
+
destroy(): void;
|
|
79
|
+
}
|
|
80
|
+
export default PageList;
|