@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,351 @@
|
|
|
1
|
+
import { default as EpubCFI } from './epubcfi';
|
|
2
|
+
import { ViewportSettings, LayoutProps, EpubCFIPair, IEventEmitter } from './types';
|
|
3
|
+
import { default as Section } from './section';
|
|
4
|
+
/**
|
|
5
|
+
* Handles DOM manipulation, queries and events for View contents
|
|
6
|
+
* @class
|
|
7
|
+
* @param {document} doc Document
|
|
8
|
+
* @param {element} content Parent Element (typically Body)
|
|
9
|
+
* @param {string} cfiBase Section component of CFIs
|
|
10
|
+
* @param {number} sectionIndex Index in Spine of Conntent's Section
|
|
11
|
+
*/
|
|
12
|
+
declare class Contents implements IEventEmitter {
|
|
13
|
+
on: (type: string, fn: (...args: any[]) => void) => this;
|
|
14
|
+
off: (type: string, fn?: (...args: any[]) => void) => this;
|
|
15
|
+
emit: (type: string, ...args: any[]) => void;
|
|
16
|
+
epubcfi: EpubCFI;
|
|
17
|
+
document: Document;
|
|
18
|
+
documentElement: HTMLElement;
|
|
19
|
+
content: HTMLElement;
|
|
20
|
+
window: Window;
|
|
21
|
+
_size: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
sectionIndex: number;
|
|
26
|
+
cfiBase: string;
|
|
27
|
+
called: number;
|
|
28
|
+
active: boolean;
|
|
29
|
+
observer: ResizeObserver | MutationObserver | undefined;
|
|
30
|
+
expanding: ReturnType<typeof setTimeout> | undefined;
|
|
31
|
+
onResize: ((size: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
}) => void) | undefined;
|
|
35
|
+
_expanding: boolean;
|
|
36
|
+
_resizeCheck: (() => void) | undefined;
|
|
37
|
+
_triggerEvent: ((e: Event) => void) | undefined;
|
|
38
|
+
_onSelectionChange: ((e: Event) => void) | undefined;
|
|
39
|
+
selectionEndTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
40
|
+
_layoutStyle: string;
|
|
41
|
+
constructor(doc: Document, content?: HTMLElement, cfiBase?: string, sectionIndex?: number);
|
|
42
|
+
/**
|
|
43
|
+
* Get DOM events that are listened for and passed along
|
|
44
|
+
*/
|
|
45
|
+
static get listenedEvents(): readonly ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "mousemove", "click", "touchend", "touchstart", "touchmove"];
|
|
46
|
+
/**
|
|
47
|
+
* Get or Set width
|
|
48
|
+
* @param {number} [w]
|
|
49
|
+
* @returns {number} width
|
|
50
|
+
*/
|
|
51
|
+
width(w?: number | string): number;
|
|
52
|
+
/**
|
|
53
|
+
* Get or Set height
|
|
54
|
+
* @param {number} [h]
|
|
55
|
+
* @returns {number} height
|
|
56
|
+
*/
|
|
57
|
+
height(h?: number | string): number;
|
|
58
|
+
/**
|
|
59
|
+
* Get or Set width of the contents
|
|
60
|
+
* @param {number} [w]
|
|
61
|
+
* @returns {number} width
|
|
62
|
+
*/
|
|
63
|
+
contentWidth(w?: number | string): number;
|
|
64
|
+
/**
|
|
65
|
+
* Get or Set height of the contents
|
|
66
|
+
* @param {number} [h]
|
|
67
|
+
* @returns {number} height
|
|
68
|
+
*/
|
|
69
|
+
contentHeight(h?: number | string): number;
|
|
70
|
+
/**
|
|
71
|
+
* Get the width of the text using Range
|
|
72
|
+
* @returns {number} width
|
|
73
|
+
*/
|
|
74
|
+
textWidth(): number;
|
|
75
|
+
/**
|
|
76
|
+
* Get the height of the text using Range
|
|
77
|
+
* @returns {number} height
|
|
78
|
+
*/
|
|
79
|
+
textHeight(): number;
|
|
80
|
+
/**
|
|
81
|
+
* Get documentElement scrollWidth
|
|
82
|
+
* @returns {number} width
|
|
83
|
+
*/
|
|
84
|
+
scrollWidth(): number;
|
|
85
|
+
/**
|
|
86
|
+
* Get documentElement scrollHeight
|
|
87
|
+
* @returns {number} height
|
|
88
|
+
*/
|
|
89
|
+
scrollHeight(): number;
|
|
90
|
+
/**
|
|
91
|
+
* Set overflow css style of the contents
|
|
92
|
+
* @param {string} [overflow]
|
|
93
|
+
*/
|
|
94
|
+
overflow(overflow?: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Set overflowX css style of the documentElement
|
|
97
|
+
* @param {string} [overflow]
|
|
98
|
+
*/
|
|
99
|
+
overflowX(overflow?: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* Set overflowY css style of the documentElement
|
|
102
|
+
* @param {string} [overflow]
|
|
103
|
+
*/
|
|
104
|
+
overflowY(overflow?: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Set Css styles on the contents element (typically Body)
|
|
107
|
+
* @param {string} property
|
|
108
|
+
* @param {string} value
|
|
109
|
+
* @param {boolean} [priority] set as "important"
|
|
110
|
+
*/
|
|
111
|
+
css(property: string, value?: string, priority?: boolean): string;
|
|
112
|
+
/**
|
|
113
|
+
* Get or Set the viewport element
|
|
114
|
+
* @param {object} [options]
|
|
115
|
+
* @param {string} [options.width]
|
|
116
|
+
* @param {string} [options.height]
|
|
117
|
+
* @param {string} [options.scale]
|
|
118
|
+
* @param {string} [options.minimum]
|
|
119
|
+
* @param {string} [options.maximum]
|
|
120
|
+
* @param {string} [options.scalable]
|
|
121
|
+
*/
|
|
122
|
+
viewport(options?: Partial<Record<keyof ViewportSettings, string | number>>): ViewportSettings;
|
|
123
|
+
/**
|
|
124
|
+
* Event emitter for when the contents has expanded
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
expand(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Add DOM listeners
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
listeners(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Remove DOM listeners
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
removeListeners(): void;
|
|
138
|
+
/**
|
|
139
|
+
* Check if size of contents has changed and
|
|
140
|
+
* emit 'resize' event if it has.
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
resizeCheck(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Poll for resize detection
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
resizeListeners(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Listen for visibility of tab to change
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
visibilityListeners(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Use css transitions to detect resize
|
|
156
|
+
* @private
|
|
157
|
+
*/
|
|
158
|
+
transitionListeners(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Listen for media query changes and emit 'expand' event
|
|
161
|
+
* Adapted from: https://github.com/tylergaw/media-query-events/blob/master/js/mq-events.js
|
|
162
|
+
* @private
|
|
163
|
+
*/
|
|
164
|
+
mediaQueryListeners(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Use ResizeObserver to listen for changes in the DOM and check for resize
|
|
167
|
+
* @private
|
|
168
|
+
*/
|
|
169
|
+
resizeObservers(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Use MutationObserver to listen for changes in the DOM and check for resize
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
mutationObservers(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Test if images are loaded or add listener for when they load
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
179
|
+
imageLoadListeners(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Listen for font load and check for resize when loaded
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
184
|
+
fontLoadListeners(): void;
|
|
185
|
+
/**
|
|
186
|
+
* Get the documentElement
|
|
187
|
+
* @returns {element} documentElement
|
|
188
|
+
*/
|
|
189
|
+
root(): HTMLElement | null;
|
|
190
|
+
/**
|
|
191
|
+
* Get the location offset of a EpubCFI or an #id
|
|
192
|
+
* @param {string | EpubCFI} target
|
|
193
|
+
* @param {string} [ignoreClass] for the cfi
|
|
194
|
+
* @returns { {left: Number, top: Number }
|
|
195
|
+
*/
|
|
196
|
+
locationOf(target: string, ignoreClass?: string): {
|
|
197
|
+
left: number;
|
|
198
|
+
top: number;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Append a stylesheet link to the document head
|
|
202
|
+
* @param {string} src url
|
|
203
|
+
*/
|
|
204
|
+
addStylesheet(src: string): Promise<boolean>;
|
|
205
|
+
_getStylesheetNode(key?: string): HTMLStyleElement | false;
|
|
206
|
+
/**
|
|
207
|
+
* Append stylesheet css
|
|
208
|
+
* @param {string} serializedCss
|
|
209
|
+
* @param {string} key If the key is the same, the CSS will be replaced instead of inserted
|
|
210
|
+
*/
|
|
211
|
+
addStylesheetCss(serializedCss: string, key?: string): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Append stylesheet rules to a generate stylesheet
|
|
214
|
+
* Array: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule
|
|
215
|
+
* Object: https://github.com/desirable-objects/json-to-css
|
|
216
|
+
* @param {array | object} rules
|
|
217
|
+
* @param {string} key If the key is the same, the CSS will be replaced instead of inserted
|
|
218
|
+
*/
|
|
219
|
+
addStylesheetRules(rules: any, key?: string): void;
|
|
220
|
+
/**
|
|
221
|
+
* Append a script tag to the document head
|
|
222
|
+
* @param {string} src url
|
|
223
|
+
* @returns {Promise} loaded
|
|
224
|
+
*/
|
|
225
|
+
addScript(src: string): Promise<boolean>;
|
|
226
|
+
/**
|
|
227
|
+
* Add a class to the contents container
|
|
228
|
+
* @param {string} className
|
|
229
|
+
*/
|
|
230
|
+
addClass(className: string): void;
|
|
231
|
+
/**
|
|
232
|
+
* Remove a class from the contents container
|
|
233
|
+
* @param {string} removeClass
|
|
234
|
+
*/
|
|
235
|
+
removeClass(className: string): void;
|
|
236
|
+
/**
|
|
237
|
+
* Add DOM event listeners
|
|
238
|
+
* @private
|
|
239
|
+
*/
|
|
240
|
+
addEventListeners(): void;
|
|
241
|
+
/**
|
|
242
|
+
* Remove DOM event listeners
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
removeEventListeners(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Emit passed browser events
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
250
|
+
triggerEvent(e: Event): void;
|
|
251
|
+
/**
|
|
252
|
+
* Add listener for text selection
|
|
253
|
+
* @private
|
|
254
|
+
*/
|
|
255
|
+
addSelectionListeners(): void;
|
|
256
|
+
/**
|
|
257
|
+
* Remove listener for text selection
|
|
258
|
+
* @private
|
|
259
|
+
*/
|
|
260
|
+
removeSelectionListeners(): void;
|
|
261
|
+
/**
|
|
262
|
+
* Handle getting text on selection
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
onSelectionChange(_e: Event): void;
|
|
266
|
+
/**
|
|
267
|
+
* Emit event on text selection
|
|
268
|
+
* @private
|
|
269
|
+
*/
|
|
270
|
+
triggerSelectedEvent(selection: Selection): void;
|
|
271
|
+
/**
|
|
272
|
+
* Get a Dom Range from EpubCFI
|
|
273
|
+
* @param {EpubCFI} _cfi
|
|
274
|
+
* @param {string} [ignoreClass]
|
|
275
|
+
* @returns {Range} range
|
|
276
|
+
*/
|
|
277
|
+
range(_cfi: string, ignoreClass?: string): Range;
|
|
278
|
+
/**
|
|
279
|
+
* Get an EpubCFI from a Dom Range
|
|
280
|
+
* @param {Range} range
|
|
281
|
+
* @param {string} [ignoreClass]
|
|
282
|
+
* @returns {EpubCFI} cfi
|
|
283
|
+
*/
|
|
284
|
+
cfiFromRange(range: Range, ignoreClass?: string): string;
|
|
285
|
+
/**
|
|
286
|
+
* Get an EpubCFI from a Dom node
|
|
287
|
+
* @param {node} node
|
|
288
|
+
* @param {string} [ignoreClass]
|
|
289
|
+
* @returns {EpubCFI} cfi
|
|
290
|
+
*/
|
|
291
|
+
cfiFromNode(node: Node, ignoreClass?: string): string;
|
|
292
|
+
map(layout: LayoutProps): EpubCFIPair[];
|
|
293
|
+
/**
|
|
294
|
+
* Size the contents to a given width and height
|
|
295
|
+
* @param {number} [width]
|
|
296
|
+
* @param {number} [height]
|
|
297
|
+
*/
|
|
298
|
+
size(width?: number, height?: number): void;
|
|
299
|
+
/**
|
|
300
|
+
* Apply columns to the contents for pagination
|
|
301
|
+
* @param {number} width
|
|
302
|
+
* @param {number} height
|
|
303
|
+
* @param {number} columnWidth
|
|
304
|
+
* @param {number} gap
|
|
305
|
+
*/
|
|
306
|
+
columns(width: number, height: number, columnWidth: number, gap: number, dir?: string): void;
|
|
307
|
+
/**
|
|
308
|
+
* Scale contents from center
|
|
309
|
+
* @param {number} scale
|
|
310
|
+
* @param {number} offsetX
|
|
311
|
+
* @param {number} offsetY
|
|
312
|
+
*/
|
|
313
|
+
scaler(scale: number, offsetX?: number, offsetY?: number): void;
|
|
314
|
+
/**
|
|
315
|
+
* Fit contents into a fixed width and height
|
|
316
|
+
* @param {number} width
|
|
317
|
+
* @param {number} height
|
|
318
|
+
*/
|
|
319
|
+
fit(width: number, height: number, section?: Section): void;
|
|
320
|
+
/**
|
|
321
|
+
* Set the direction of the text
|
|
322
|
+
* @param {string} [dir="ltr"] "rtl" | "ltr"
|
|
323
|
+
*/
|
|
324
|
+
direction(dir: string): void;
|
|
325
|
+
mapPage(cfiBase: string, layout: LayoutProps, start: number, end: number, dev?: boolean): EpubCFIPair | undefined;
|
|
326
|
+
/**
|
|
327
|
+
* Emit event when link in content is clicked
|
|
328
|
+
* @private
|
|
329
|
+
*/
|
|
330
|
+
linksHandler(): void;
|
|
331
|
+
/**
|
|
332
|
+
* Set the writingMode of the text
|
|
333
|
+
* @param {string} [mode="horizontal-tb"] "horizontal-tb" | "vertical-rl" | "vertical-lr"
|
|
334
|
+
*/
|
|
335
|
+
writingMode(mode?: string): string;
|
|
336
|
+
/**
|
|
337
|
+
* Set the layoutStyle of the content
|
|
338
|
+
* @param {string} [style="paginated"] "scrolling" | "paginated"
|
|
339
|
+
* @private
|
|
340
|
+
*/
|
|
341
|
+
layoutStyle(style?: string): string;
|
|
342
|
+
/**
|
|
343
|
+
* Add the epubReadingSystem object to the navigator
|
|
344
|
+
* @param {string} name
|
|
345
|
+
* @param {string} version
|
|
346
|
+
* @private
|
|
347
|
+
*/
|
|
348
|
+
epubReadingSystem(name: string, version: string): void;
|
|
349
|
+
destroy(): void;
|
|
350
|
+
}
|
|
351
|
+
export default Contents;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open DisplayOptions Format Parser
|
|
3
|
+
* @class
|
|
4
|
+
* @param {document} displayOptionsDocument XML
|
|
5
|
+
*/
|
|
6
|
+
declare class DisplayOptions {
|
|
7
|
+
interactive: string;
|
|
8
|
+
fixedLayout: string;
|
|
9
|
+
openToSpread: string;
|
|
10
|
+
orientationLock: string;
|
|
11
|
+
constructor(displayOptionsDocument?: Document);
|
|
12
|
+
/**
|
|
13
|
+
* Parse XML
|
|
14
|
+
* @param {document} displayOptionsDocument XML
|
|
15
|
+
* @return {DisplayOptions} self
|
|
16
|
+
*/
|
|
17
|
+
parse(displayOptionsDocument: Document): this;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
export default DisplayOptions;
|