@likecoin/epub-ts 0.4.3 → 0.4.5

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.
@@ -2,12 +2,12 @@ import { IEventEmitter } from './types';
2
2
  import { default as Rendition } from './rendition';
3
3
  interface AnnotationView {
4
4
  index: number;
5
- highlight: Function;
6
- underline: Function;
7
- mark: Function;
8
- unhighlight: Function;
9
- ununderline: Function;
10
- unmark: Function;
5
+ highlight: (cfiRange: string, data?: Record<string, string>, cb?: EventListener, className?: string, styles?: Record<string, string>) => object | undefined;
6
+ underline: (cfiRange: string, data?: Record<string, string>, cb?: EventListener, className?: string, styles?: Record<string, string>) => object | undefined;
7
+ mark: (cfiRange: string, data?: Record<string, string>, cb?: EventListener) => object | null | undefined;
8
+ unhighlight: (cfiRange: string) => void;
9
+ ununderline: (cfiRange: string) => void;
10
+ unmark: (cfiRange: string) => void;
11
11
  }
12
12
  /**
13
13
  * Handles managing adding & removing Annotations
@@ -32,7 +32,7 @@ declare class Annotations {
32
32
  * @param {object} styles CSS styles to assign to annotation
33
33
  * @returns {Annotation} annotation
34
34
  */
35
- add(type: string, cfiRange: string, data?: Record<string, any>, cb?: Function, className?: string, styles?: Record<string, string>): Annotation;
35
+ add(type: string, cfiRange: string, data?: Record<string, any>, cb?: EventListener, className?: string, styles?: Record<string, string>): Annotation;
36
36
  /**
37
37
  * Remove an annotation from store
38
38
  * @param {EpubCFI} cfiRange EpubCFI range the annotation is attached to
@@ -57,7 +57,7 @@ declare class Annotations {
57
57
  * @param {string} className CSS class to assign to annotation
58
58
  * @param {object} styles CSS styles to assign to annotation
59
59
  */
60
- highlight(cfiRange: string, data?: Record<string, any>, cb?: Function, className?: string, styles?: Record<string, string>): Annotation;
60
+ highlight(cfiRange: string, data?: Record<string, any>, cb?: EventListener, className?: string, styles?: Record<string, string>): Annotation;
61
61
  /**
62
62
  * Add a underline to the store
63
63
  * @param {EpubCFI} cfiRange EpubCFI range to attach annotation to
@@ -66,14 +66,14 @@ declare class Annotations {
66
66
  * @param {string} className CSS class to assign to annotation
67
67
  * @param {object} styles CSS styles to assign to annotation
68
68
  */
69
- underline(cfiRange: string, data?: Record<string, any>, cb?: Function, className?: string, styles?: Record<string, string>): Annotation;
69
+ underline(cfiRange: string, data?: Record<string, any>, cb?: EventListener, className?: string, styles?: Record<string, string>): Annotation;
70
70
  /**
71
71
  * Add a mark to the store
72
72
  * @param {EpubCFI} cfiRange EpubCFI range to attach annotation to
73
73
  * @param {object} data Data to assign to annotation
74
74
  * @param {function} cb Callback after annotation is clicked
75
75
  */
76
- mark(cfiRange: string, data?: Record<string, any>, cb?: Function): Annotation;
76
+ mark(cfiRange: string, data?: Record<string, any>, cb?: EventListener): Annotation;
77
77
  /**
78
78
  * iterate over annotations in the store
79
79
  */
@@ -119,8 +119,8 @@ declare class Annotation implements IEventEmitter {
119
119
  cfiRange: string;
120
120
  data: Record<string, any>;
121
121
  sectionIndex: number;
122
- mark: object | undefined;
123
- cb: Function;
122
+ mark: object | null | undefined;
123
+ cb: EventListener;
124
124
  className: string;
125
125
  styles: Record<string, string>;
126
126
  on: IEventEmitter["on"];
@@ -131,7 +131,7 @@ declare class Annotation implements IEventEmitter {
131
131
  cfiRange: string;
132
132
  data?: Record<string, any>;
133
133
  sectionIndex?: number;
134
- cb?: Function;
134
+ cb?: EventListener;
135
135
  className?: string;
136
136
  styles?: Record<string, string>;
137
137
  });
@@ -144,12 +144,12 @@ declare class Annotation implements IEventEmitter {
144
144
  * Add to a view
145
145
  * @param {View} view
146
146
  */
147
- attach(view: AnnotationView): object | undefined;
147
+ attach(view: AnnotationView): object | null | undefined;
148
148
  /**
149
149
  * Remove from a view
150
150
  * @param {View} view
151
151
  */
152
- detach(view: AnnotationView): object | undefined;
152
+ detach(view: AnnotationView): void;
153
153
  /**
154
154
  * [Not Implemented] Get text of an annotation
155
155
  * @TODO: needs implementation in contents
package/dist/archive.d.ts CHANGED
@@ -33,7 +33,7 @@ declare class Archive {
33
33
  * @param {string} [type] specify the type of the returned result
34
34
  * @return {Promise<Blob | string | JSON | Document | XMLDocument>}
35
35
  */
36
- request(url: string, type?: string): Promise<any>;
36
+ request(url: string, type?: string): Promise<unknown>;
37
37
  /**
38
38
  * Handle the response from request
39
39
  * @private
@@ -41,7 +41,7 @@ declare class Archive {
41
41
  * @param {string} [type]
42
42
  * @return {any} the parsed result
43
43
  */
44
- handleResponse(response: any, type?: string): any;
44
+ handleResponse(response: string | Blob, type?: string): Document | object | Blob | string;
45
45
  /**
46
46
  * Get a Blob from Archive by Url
47
47
  * @param {string} url
package/dist/book.d.ts CHANGED
@@ -16,14 +16,14 @@ import { default as JSZip } from 'jszip';
16
16
  import { IEventEmitter, BookOptions, RenditionOptions, RequestFunction, PackagingManifestObject, PackagingMetadataObject } from './types';
17
17
  import { default as Section } from './section';
18
18
  interface BookLoadingState {
19
- manifest: defer;
20
- spine: defer;
21
- metadata: defer;
22
- cover: defer;
23
- navigation: defer;
24
- pageList: defer;
25
- resources: defer;
26
- displayOptions: defer;
19
+ manifest: defer<PackagingManifestObject>;
20
+ spine: defer<Spine>;
21
+ metadata: defer<PackagingMetadataObject>;
22
+ cover: defer<string>;
23
+ navigation: defer<Navigation>;
24
+ pageList: defer<PageList>;
25
+ resources: defer<Resources>;
26
+ displayOptions: defer<DisplayOptions>;
27
27
  }
28
28
  interface BookLoadedState {
29
29
  manifest: Promise<PackagingManifestObject>;
@@ -54,17 +54,17 @@ interface BookLoadedState {
54
54
  * @example new Book({ replacements: "blobUrl" })
55
55
  */
56
56
  declare class Book implements IEventEmitter {
57
- settings: BookOptions & Record<string, any>;
58
- opening: defer;
59
- opened: Promise<Book> | undefined;
57
+ settings: BookOptions;
58
+ opening: defer<Book>;
59
+ opened: Promise<Book>;
60
60
  isOpen: boolean;
61
- loading: BookLoadingState | undefined;
62
- loaded: BookLoadedState | undefined;
63
- ready: Promise<[PackagingManifestObject, Spine, PackagingMetadataObject, string, Navigation, Resources, DisplayOptions]> | undefined;
61
+ loading: BookLoadingState;
62
+ loaded: BookLoadedState;
63
+ ready: Promise<[PackagingManifestObject, Spine, PackagingMetadataObject, string, Navigation, Resources, DisplayOptions]>;
64
64
  isRendered: boolean;
65
65
  request: RequestFunction;
66
- spine: Spine | undefined;
67
- locations: Locations | undefined;
66
+ spine: Spine;
67
+ locations: Locations;
68
68
  navigation: Navigation | undefined;
69
69
  pageList: PageList | undefined;
70
70
  url: Url | undefined;
@@ -125,7 +125,7 @@ declare class Book implements IEventEmitter {
125
125
  * @param {string} path path to the resource to load
126
126
  * @return {Promise} returns a promise with the requested resource
127
127
  */
128
- load(path: string, _type?: string): Promise<any>;
128
+ load(path: string, _type?: string): Promise<unknown>;
129
129
  /**
130
130
  * Resolve a path to it's absolute position in the Book
131
131
  * @param {string} path
@@ -145,7 +145,7 @@ declare class Book implements IEventEmitter {
145
145
  * @param {string} input
146
146
  * @return {string} binary | directory | epub | opf
147
147
  */
148
- determineType(input: string | ArrayBuffer | Blob): string;
148
+ determineType(input: string | ArrayBuffer | Blob): string | undefined;
149
149
  /**
150
150
  * unpack the contents of the Books packaging
151
151
  * @private
@@ -13,7 +13,7 @@ import { default as Section } from './section';
13
13
  declare class Contents implements IEventEmitter {
14
14
  on: (type: string, fn: (...args: any[]) => void) => this;
15
15
  off: (type: string, fn?: (...args: any[]) => void) => this;
16
- emit: (type: string, ...args: any[]) => void;
16
+ emit: (type: string, ...args: unknown[]) => void;
17
17
  __listeners: IEventEmitter["__listeners"];
18
18
  epubcfi: EpubCFI;
19
19
  document: Document;