@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.
Files changed (51) hide show
  1. package/README.md +64 -0
  2. package/dist/annotations.d.ts +159 -0
  3. package/dist/archive.d.ts +82 -0
  4. package/dist/book.d.ts +228 -0
  5. package/dist/container.d.ts +18 -0
  6. package/dist/contents.d.ts +351 -0
  7. package/dist/displayoptions.d.ts +20 -0
  8. package/dist/epub.cjs +10 -0
  9. package/dist/epub.cjs.map +1 -0
  10. package/dist/epub.d.ts +17 -0
  11. package/dist/epub.js +9500 -0
  12. package/dist/epub.js.map +1 -0
  13. package/dist/epub.umd.js +10 -0
  14. package/dist/epub.umd.js.map +1 -0
  15. package/dist/epubcfi.d.ts +116 -0
  16. package/dist/index.d.ts +8 -0
  17. package/dist/layout.d.ts +77 -0
  18. package/dist/locations.d.ts +117 -0
  19. package/dist/managers/continuous/index.d.ts +46 -0
  20. package/dist/managers/default/index.d.ts +117 -0
  21. package/dist/managers/helpers/snap.d.ts +63 -0
  22. package/dist/managers/helpers/stage.d.ts +41 -0
  23. package/dist/managers/helpers/views.d.ts +27 -0
  24. package/dist/managers/views/iframe.d.ts +114 -0
  25. package/dist/managers/views/inline.d.ts +65 -0
  26. package/dist/mapping.d.ts +97 -0
  27. package/dist/marks-pane/index.d.ts +40 -0
  28. package/dist/navigation.d.ts +108 -0
  29. package/dist/packaging.d.ts +104 -0
  30. package/dist/pagelist.d.ts +80 -0
  31. package/dist/rendition.d.ts +293 -0
  32. package/dist/resources.d.ts +97 -0
  33. package/dist/section.d.ts +88 -0
  34. package/dist/spine.d.ts +79 -0
  35. package/dist/store.d.ts +122 -0
  36. package/dist/themes.d.ts +103 -0
  37. package/dist/types.d.ts +269 -0
  38. package/dist/utils/constants.d.ts +59 -0
  39. package/dist/utils/core.d.ts +337 -0
  40. package/dist/utils/event-emitter.d.ts +6 -0
  41. package/dist/utils/hook.d.ts +30 -0
  42. package/dist/utils/mime.d.ts +5 -0
  43. package/dist/utils/path-utils.d.ts +14 -0
  44. package/dist/utils/path.d.ts +55 -0
  45. package/dist/utils/queue.d.ts +66 -0
  46. package/dist/utils/replacements.d.ts +11 -0
  47. package/dist/utils/request.d.ts +2 -0
  48. package/dist/utils/scrolltype.d.ts +2 -0
  49. package/dist/utils/url.d.ts +42 -0
  50. package/license +28 -0
  51. package/package.json +55 -0
@@ -0,0 +1,103 @@
1
+ import { default as Rendition } from './rendition';
2
+ import { default as Contents } from './contents';
3
+ import { ThemeEntry } from './types';
4
+ /**
5
+ * Themes to apply to displayed content
6
+ * @class
7
+ * @param {Rendition} rendition
8
+ */
9
+ declare class Themes {
10
+ rendition: Rendition;
11
+ _themes: Record<string, ThemeEntry>;
12
+ _overrides: Record<string, {
13
+ value: string;
14
+ priority: boolean;
15
+ }>;
16
+ _current: string;
17
+ _injected: string[];
18
+ constructor(rendition: Rendition);
19
+ /**
20
+ * Add themes to be used by a rendition
21
+ * @param {object | Array<object> | string}
22
+ * @example themes.register("light", "http://example.com/light.css")
23
+ * @example themes.register("light", { "body": { "color": "purple"}})
24
+ * @example themes.register({ "light" : {...}, "dark" : {...}})
25
+ */
26
+ register(..._args: any[]): void;
27
+ /**
28
+ * Add a default theme to be used by a rendition
29
+ * @param {object | string} theme
30
+ * @example themes.register("http://example.com/default.css")
31
+ * @example themes.register({ "body": { "color": "purple"}})
32
+ */
33
+ default(theme: string | Record<string, Record<string, string>>): void;
34
+ /**
35
+ * Register themes object
36
+ * @param {object} themes
37
+ */
38
+ registerThemes(themes: Record<string, string | Record<string, Record<string, string>>>): void;
39
+ /**
40
+ * Register a theme by passing its css as string
41
+ * @param {string} name
42
+ * @param {string} css
43
+ */
44
+ registerCss(name: string, css: string): void;
45
+ /**
46
+ * Register a url
47
+ * @param {string} name
48
+ * @param {string} input
49
+ */
50
+ registerUrl(name: string, input: string): void;
51
+ /**
52
+ * Register rule
53
+ * @param {string} name
54
+ * @param {object} rules
55
+ */
56
+ registerRules(name: string, rules: Record<string, Record<string, string>>): void;
57
+ /**
58
+ * Select a theme
59
+ * @param {string} name
60
+ */
61
+ select(name: string): void;
62
+ /**
63
+ * Update a theme
64
+ * @param {string} name
65
+ */
66
+ update(name: string): void;
67
+ /**
68
+ * Inject all themes into contents
69
+ * @param {Contents} contents
70
+ */
71
+ inject(contents: Contents): void;
72
+ /**
73
+ * Add Theme to contents
74
+ * @param {string} name
75
+ * @param {Contents} contents
76
+ */
77
+ add(name: string, contents: Contents): void;
78
+ /**
79
+ * Add override
80
+ * @param {string} name
81
+ * @param {string} value
82
+ * @param {boolean} priority
83
+ */
84
+ override(name: string, value: string, priority?: boolean): void;
85
+ removeOverride(name: string): void;
86
+ /**
87
+ * Add all overrides
88
+ * @param {Content} content
89
+ */
90
+ overrides(contents: Contents): void;
91
+ /**
92
+ * Adjust the font size of a rendition
93
+ * @param {number} size
94
+ */
95
+ fontSize(size: string): void;
96
+ /**
97
+ * Adjust the font-family of a rendition
98
+ * @param {string} f
99
+ */
100
+ font(f: string): void;
101
+ destroy(): void;
102
+ }
103
+ export default Themes;
@@ -0,0 +1,269 @@
1
+ /**
2
+ * Shared type definitions for epub.ts
3
+ * Adapted from legacy types/ directory (epubjs v0.3.93)
4
+ */
5
+ export interface Deferred<T = any> {
6
+ id: string;
7
+ resolve: (value?: T | PromiseLike<T>) => void;
8
+ reject: (reason?: any) => void;
9
+ promise: Promise<T>;
10
+ }
11
+ export interface IEventEmitter {
12
+ on(type: string, fn: (...args: any[]) => void): any;
13
+ off(type: string, fn?: (...args: any[]) => void): any;
14
+ emit(type: string, ...args: any[]): void;
15
+ __listeners?: Record<string, Array<(...args: any[]) => void>>;
16
+ }
17
+ export interface PackagingMetadataObject {
18
+ title: string;
19
+ creator: string;
20
+ description: string;
21
+ pubdate: string;
22
+ publisher: string;
23
+ identifier: string;
24
+ language: string;
25
+ rights: string;
26
+ modified_date: string;
27
+ layout: string;
28
+ orientation: string;
29
+ flow: string;
30
+ viewport: string;
31
+ media_active_class: string;
32
+ spread: string;
33
+ direction: string;
34
+ }
35
+ export interface PackagingSpineItem {
36
+ id?: string;
37
+ idref: string;
38
+ linear: string;
39
+ properties: string[];
40
+ index: number;
41
+ }
42
+ export interface PackagingManifestItem {
43
+ href: string;
44
+ type: string;
45
+ overlay: string;
46
+ properties: string[];
47
+ }
48
+ export interface PackagingManifestObject {
49
+ [key: string]: PackagingManifestItem;
50
+ }
51
+ export interface PackagingObject {
52
+ metadata: PackagingMetadataObject;
53
+ spine: PackagingSpineItem[];
54
+ manifest: PackagingManifestObject;
55
+ navPath: string;
56
+ ncxPath: string;
57
+ coverPath: string;
58
+ spineNodeIndex: number;
59
+ }
60
+ export interface NavItem {
61
+ id: string;
62
+ href: string;
63
+ label: string;
64
+ subitems?: NavItem[];
65
+ parent?: string;
66
+ }
67
+ export interface LandmarkItem {
68
+ href?: string;
69
+ label?: string;
70
+ type?: string;
71
+ }
72
+ export interface SpineItem {
73
+ index: number;
74
+ cfiBase: string;
75
+ idref: string;
76
+ href: string;
77
+ url: string;
78
+ canonical: string;
79
+ properties: string[];
80
+ linear: string;
81
+ id?: string;
82
+ next: () => SpineItem | undefined;
83
+ prev: () => SpineItem | undefined;
84
+ }
85
+ export interface PageListItem {
86
+ href: string;
87
+ page: number;
88
+ cfi?: string;
89
+ packageUrl?: string;
90
+ }
91
+ export interface BookOptions {
92
+ requestMethod?: (url: string, type: string, withCredentials?: boolean, headers?: object) => Promise<any>;
93
+ requestCredentials?: boolean;
94
+ requestHeaders?: Record<string, string>;
95
+ encoding?: string;
96
+ replacements?: string;
97
+ canonical?: (path: string) => string;
98
+ openAs?: string;
99
+ store?: string | boolean;
100
+ }
101
+ export interface RenditionOptions {
102
+ width?: number | string;
103
+ height?: number | string;
104
+ ignoreClass?: string;
105
+ manager?: string | Function | object;
106
+ view?: string | Function | object;
107
+ flow?: string;
108
+ layout?: string;
109
+ spread?: string | boolean;
110
+ minSpreadWidth?: number;
111
+ stylesheet?: string;
112
+ resizeOnOrientationChange?: boolean;
113
+ script?: string;
114
+ infinite?: boolean;
115
+ overflow?: string;
116
+ snap?: boolean | object;
117
+ defaultDirection?: string;
118
+ allowScriptedContent?: boolean;
119
+ allowPopups?: boolean;
120
+ }
121
+ export interface DisplayedLocation {
122
+ index: number;
123
+ href: string;
124
+ cfi: string;
125
+ location?: number;
126
+ percentage?: number;
127
+ page?: number;
128
+ displayed: {
129
+ page: number;
130
+ total: number;
131
+ };
132
+ }
133
+ export interface Location {
134
+ start: DisplayedLocation;
135
+ end: DisplayedLocation;
136
+ atStart?: boolean;
137
+ atEnd?: boolean;
138
+ }
139
+ export interface LayoutSettings {
140
+ layout?: string;
141
+ spread?: string;
142
+ minSpreadWidth?: number;
143
+ evenSpreads?: boolean;
144
+ flow?: string;
145
+ direction?: string;
146
+ }
147
+ export interface LayoutProps {
148
+ name: string;
149
+ spread: boolean;
150
+ flow: string;
151
+ width: number;
152
+ height: number;
153
+ spreadWidth: number;
154
+ pageWidth?: number;
155
+ delta: number;
156
+ columnWidth: number;
157
+ gap: number;
158
+ divisor: number;
159
+ }
160
+ export interface ViewportSettings {
161
+ width: string;
162
+ height: string;
163
+ scale: string;
164
+ scalable: string;
165
+ minimum: string;
166
+ maximum: string;
167
+ }
168
+ export interface EpubCFIPair {
169
+ start: string;
170
+ end: string;
171
+ }
172
+ export interface RangePair {
173
+ start: Range;
174
+ end: Range;
175
+ }
176
+ export interface EpubCFIStep {
177
+ id: string | null;
178
+ tagName: string;
179
+ type: string;
180
+ index: number;
181
+ }
182
+ export interface EpubCFIComponent {
183
+ steps: EpubCFIStep[];
184
+ terminal: {
185
+ offset: number | null;
186
+ assertion: string | null;
187
+ };
188
+ }
189
+ export type RequestFunction = (url: string, type?: string, withCredentials?: boolean, headers?: Record<string, string>) => Promise<any>;
190
+ export interface SizeObject {
191
+ width: number;
192
+ height: number;
193
+ }
194
+ export interface ReframeBounds extends SizeObject {
195
+ widthDelta: number;
196
+ heightDelta: number;
197
+ }
198
+ export interface ThemeEntry {
199
+ rules?: Record<string, Record<string, string>>;
200
+ url?: string;
201
+ serialized?: string;
202
+ injected?: boolean;
203
+ }
204
+ export interface ViewSettings {
205
+ ignoreClass?: string;
206
+ axis?: string;
207
+ direction?: string;
208
+ flow?: string;
209
+ layout?: LayoutProps;
210
+ method?: string;
211
+ width?: number;
212
+ height?: number;
213
+ forceEvenPages?: boolean;
214
+ forceRight?: boolean;
215
+ allowScriptedContent?: boolean;
216
+ allowPopups?: boolean;
217
+ globalLayoutProperties?: GlobalLayout;
218
+ }
219
+ export interface ViewLocation {
220
+ index: number;
221
+ href: string;
222
+ pages: number[];
223
+ totalPages: number;
224
+ mapping: EpubCFIPair;
225
+ }
226
+ export interface ManagerOptions extends ViewSettings {
227
+ infinite?: boolean;
228
+ overflow?: string;
229
+ hidden?: boolean;
230
+ fullsize?: boolean;
231
+ snap?: boolean | object;
232
+ view?: string | Function | object;
233
+ request?: RequestFunction;
234
+ [key: string]: any;
235
+ }
236
+ export interface HooksObject {
237
+ [key: string]: any;
238
+ }
239
+ export interface StageOptions {
240
+ width?: number | string;
241
+ height?: number | string;
242
+ overflow?: string | boolean;
243
+ hidden?: boolean;
244
+ axis?: string;
245
+ fullsize?: boolean;
246
+ direction?: string;
247
+ dir?: string;
248
+ writingMode?: string;
249
+ }
250
+ export interface GlobalLayout {
251
+ layout: string;
252
+ spread: string;
253
+ orientation: string;
254
+ flow: string;
255
+ viewport: string;
256
+ minSpreadWidth: number;
257
+ direction: string;
258
+ }
259
+ export interface SearchResult {
260
+ cfi: string;
261
+ excerpt: string;
262
+ }
263
+ export interface ParsedPath {
264
+ root: string;
265
+ dir: string;
266
+ base: string;
267
+ ext: string;
268
+ name: string;
269
+ }
@@ -0,0 +1,59 @@
1
+ export declare const EPUBJS_VERSION = "0.3";
2
+ export declare const DOM_EVENTS: readonly ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "mousemove", "click", "touchend", "touchstart", "touchmove"];
3
+ export declare const EVENTS: {
4
+ readonly BOOK: {
5
+ readonly OPEN_FAILED: "openFailed";
6
+ };
7
+ readonly CONTENTS: {
8
+ readonly EXPAND: "expand";
9
+ readonly RESIZE: "resize";
10
+ readonly SELECTED: "selected";
11
+ readonly SELECTED_RANGE: "selectedRange";
12
+ readonly LINK_CLICKED: "linkClicked";
13
+ };
14
+ readonly LOCATIONS: {
15
+ readonly CHANGED: "changed";
16
+ };
17
+ readonly MANAGERS: {
18
+ readonly RESIZE: "resize";
19
+ readonly RESIZED: "resized";
20
+ readonly ORIENTATION_CHANGE: "orientationchange";
21
+ readonly ADDED: "added";
22
+ readonly SCROLL: "scroll";
23
+ readonly SCROLLED: "scrolled";
24
+ readonly REMOVED: "removed";
25
+ };
26
+ readonly VIEWS: {
27
+ readonly AXIS: "axis";
28
+ readonly WRITING_MODE: "writingMode";
29
+ readonly LOAD_ERROR: "loaderror";
30
+ readonly RENDERED: "rendered";
31
+ readonly RESIZED: "resized";
32
+ readonly DISPLAYED: "displayed";
33
+ readonly SHOWN: "shown";
34
+ readonly HIDDEN: "hidden";
35
+ readonly MARK_CLICKED: "markClicked";
36
+ };
37
+ readonly RENDITION: {
38
+ readonly STARTED: "started";
39
+ readonly ATTACHED: "attached";
40
+ readonly DISPLAYED: "displayed";
41
+ readonly DISPLAY_ERROR: "displayerror";
42
+ readonly RENDERED: "rendered";
43
+ readonly REMOVED: "removed";
44
+ readonly RESIZED: "resized";
45
+ readonly ORIENTATION_CHANGE: "orientationchange";
46
+ readonly LOCATION_CHANGED: "locationChanged";
47
+ readonly RELOCATED: "relocated";
48
+ readonly MARK_CLICKED: "markClicked";
49
+ readonly SELECTED: "selected";
50
+ readonly LAYOUT: "layout";
51
+ };
52
+ readonly LAYOUT: {
53
+ readonly UPDATED: "updated";
54
+ };
55
+ readonly ANNOTATION: {
56
+ readonly ATTACH: "attach";
57
+ readonly DETACH: "detach";
58
+ };
59
+ };