@d-i-t-a/reader 2.1.0-alpha.2 → 2.1.0-beta.2

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 (104) hide show
  1. package/README.md +52 -3
  2. package/dist/esm/index.js +48628 -0
  3. package/dist/esm/index.js.map +7 -0
  4. package/dist/injectables/click/click.js +1774 -2
  5. package/dist/injectables/click/click.js.map +7 -1
  6. package/dist/injectables/mui/script.js +205 -0
  7. package/dist/injectables/mui/style.css +271 -0
  8. package/dist/injectables/style/linefocus.css +55 -0
  9. package/dist/injectables/style/popover.css +125 -0
  10. package/dist/injectables/style/popup.css +121 -0
  11. package/dist/injectables/style/style.css +255 -0
  12. package/dist/injectables/style/toast.css +76 -0
  13. package/dist/reader.css +178 -87
  14. package/dist/reader.js +128 -3
  15. package/dist/reader.js.map +7 -1
  16. package/dist/reader.map.css +21 -0
  17. package/dist/types/index.d.ts +7 -0
  18. package/dist/{model → types/model}/Link.d.ts +2 -1
  19. package/dist/{model → types/model}/Locator.d.ts +3 -18
  20. package/dist/types/model/Publication.d.ts +51 -0
  21. package/dist/{model → types/model}/user-settings/ReadiumCSS.d.ts +0 -0
  22. package/dist/{model → types/model}/user-settings/UserProperties.d.ts +10 -4
  23. package/dist/{model → types/model}/user-settings/UserSettings.d.ts +23 -23
  24. package/dist/{modules → types/modules}/AnnotationModule.d.ts +31 -19
  25. package/dist/types/modules/BookmarkModule.d.ts +57 -0
  26. package/dist/types/modules/ReaderModule.d.ts +2 -0
  27. package/dist/types/modules/TTS/TTSModule2.d.ts +74 -0
  28. package/dist/{modules → types/modules}/TTS/TTSSettings.d.ts +44 -20
  29. package/dist/types/modules/citation/CitationModule.d.ts +40 -0
  30. package/dist/{modules → types/modules}/highlight/HtmlElementSelector.d.ts +0 -0
  31. package/dist/types/modules/highlight/LayerSettings.d.ts +19 -0
  32. package/dist/{modules → types/modules}/highlight/TextHighlighter.d.ts +68 -61
  33. package/dist/{modules → types/modules}/highlight/common/document.d.ts +0 -0
  34. package/dist/{modules → types/modules}/highlight/common/events.d.ts +0 -0
  35. package/dist/types/modules/highlight/common/highlight.d.ts +71 -0
  36. package/dist/{modules → types/modules}/highlight/common/rect-utils.d.ts +2 -2
  37. package/dist/{modules → types/modules}/highlight/common/selection.d.ts +8 -3
  38. package/dist/{modules → types/modules}/highlight/renderer/common/cssselector.d.ts +0 -0
  39. package/dist/{modules → types/modules}/highlight/renderer/common/cssselector2.d.ts +0 -0
  40. package/dist/{modules → types/modules}/highlight/renderer/iframe/selection.d.ts +2 -2
  41. package/dist/{modules → types/modules}/highlight/renderer/iframe/state.d.ts +0 -3
  42. package/dist/types/modules/history/HistoryModule.d.ts +34 -0
  43. package/dist/types/modules/linefocus/LineFocusModule.d.ts +51 -0
  44. package/dist/{modules → types/modules}/mediaoverlays/MediaOverlayModule.d.ts +19 -14
  45. package/dist/{modules → types/modules}/mediaoverlays/MediaOverlaySettings.d.ts +21 -16
  46. package/dist/types/modules/pagebreak/PageBreakModule.d.ts +30 -0
  47. package/dist/{modules → types/modules}/positions/TimelineModule.d.ts +3 -3
  48. package/dist/{modules → types/modules}/protection/ContentProtectionModule.d.ts +14 -10
  49. package/dist/types/modules/sampleread/SampleReadEventHandler.d.ts +8 -0
  50. package/dist/types/modules/search/DefinitionsModule.d.ts +52 -0
  51. package/dist/types/modules/search/Popup.d.ts +10 -0
  52. package/dist/{modules → types/modules}/search/SearchModule.d.ts +22 -18
  53. package/dist/{modules → types/modules}/search/searchWithDomSeek.d.ts +1 -1
  54. package/dist/{navigator → types/navigator}/IFrameNavigator.d.ts +99 -74
  55. package/dist/{navigator → types/navigator}/Navigator.d.ts +0 -0
  56. package/dist/types/reader.d.ts +202 -0
  57. package/dist/types/store/Annotator.d.ts +25 -0
  58. package/dist/types/store/LocalAnnotator.d.ts +31 -0
  59. package/dist/{store → types/store}/LocalStorageStore.d.ts +3 -3
  60. package/dist/{store → types/store}/MemoryStore.d.ts +3 -3
  61. package/dist/types/store/Store.d.ts +6 -0
  62. package/dist/{utils → types/utils}/BrowserUtilities.d.ts +0 -0
  63. package/dist/types/utils/EventHandler.d.ts +23 -0
  64. package/dist/{utils → types/utils}/HTMLTemplates.d.ts +0 -0
  65. package/dist/{utils → types/utils}/HTMLUtilities.d.ts +3 -3
  66. package/dist/{utils → types/utils}/IconLib.d.ts +1 -0
  67. package/dist/{utils → types/utils}/JsonUtil.d.ts +0 -0
  68. package/dist/types/utils/KeyboardEventHandler.d.ts +10 -0
  69. package/dist/{utils → types/utils}/TouchEventHandler.d.ts +4 -1
  70. package/dist/types/utils/index.d.ts +6 -0
  71. package/dist/{views → types/views}/BookView.d.ts +10 -7
  72. package/dist/{views → types/views}/FixedBookView.d.ts +8 -4
  73. package/dist/{views → types/views}/ReflowableBookView.d.ts +7 -5
  74. package/package.json +54 -25
  75. package/NOTICE +0 -20
  76. package/dist/index.d.ts +0 -61
  77. package/dist/injectables/click/click.d.ts +0 -1
  78. package/dist/injectables/footnotes/footnotes.d.ts +0 -1
  79. package/dist/injectables/footnotes/footnotes.js +0 -2
  80. package/dist/injectables/footnotes/footnotes.js.map +0 -1
  81. package/dist/injectables/glossary/glossary.d.ts +0 -5
  82. package/dist/injectables/glossary/glossary.js +0 -3
  83. package/dist/injectables/glossary/glossary.js.LICENSE.txt +0 -6
  84. package/dist/injectables/glossary/glossary.js.map +0 -1
  85. package/dist/material.css +0 -4637
  86. package/dist/material.css.map +0 -30
  87. package/dist/model/MediaOverlayNode.d.ts +0 -3
  88. package/dist/model/Publication.d.ts +0 -26
  89. package/dist/modules/BookmarkModule.d.ts +0 -46
  90. package/dist/modules/ReaderModule.d.ts +0 -3
  91. package/dist/modules/TTS/TTSModule.d.ts +0 -58
  92. package/dist/modules/highlight/common/highlight.d.ts +0 -19
  93. package/dist/modules/highlight/common/styles.d.ts +0 -35
  94. package/dist/modules/syncnarration/SyncSettings.d.ts +0 -67
  95. package/dist/modules/syncnarration/SynchronizedNarrationModule.d.ts +0 -81
  96. package/dist/modules/syncnarration/renderer/media-overlays.d.ts +0 -0
  97. package/dist/reader.css.map +0 -21
  98. package/dist/reader.js.LICENSE.txt +0 -66
  99. package/dist/store/Annotator.d.ts +0 -25
  100. package/dist/store/LocalAnnotator.d.ts +0 -31
  101. package/dist/store/Store.d.ts +0 -6
  102. package/dist/utils/EventHandler.d.ts +0 -9
  103. package/dist/utils/KeyboardEventHandler.d.ts +0 -7
  104. package/dist/utils/decodeURI.d.ts +0 -1
@@ -1,30 +1,38 @@
1
1
  import Navigator from "./Navigator";
2
2
  import Annotator from "../store/Annotator";
3
3
  import { Publication } from "../model/Publication";
4
- import EventHandler from "../utils/EventHandler";
5
4
  import { Locator, ReadingPosition } from "../model/Locator";
6
5
  import { UserSettings, UserSettingsUIConfig } from "../model/user-settings/UserSettings";
7
- import BookmarkModule, { BookmarkModuleConfig } from "../modules/BookmarkModule";
8
- import AnnotationModule, { AnnotationModuleConfig } from "../modules/AnnotationModule";
9
- import TTSModule, { TTSModuleConfig } from "../modules/TTS/TTSModule";
10
- import SearchModule, { SearchModuleConfig } from "../modules/search/SearchModule";
11
- import ContentProtectionModule, { ContentProtectionModuleConfig } from "../modules/protection/ContentProtectionModule";
12
- import TextHighlighter, { TextHighlighterConfig } from "../modules/highlight/TextHighlighter";
13
- import TimelineModule from "../modules/positions/TimelineModule";
14
- import TouchEventHandler from "../utils/TouchEventHandler";
15
- import KeyboardEventHandler from "../utils/KeyboardEventHandler";
6
+ import { BookmarkModule, BookmarkModuleConfig } from "../modules/BookmarkModule";
7
+ import { AnnotationModule, AnnotationModuleConfig } from "../modules/AnnotationModule";
8
+ import { SearchModule, SearchModuleConfig } from "../modules/search/SearchModule";
9
+ import { ContentProtectionModule, ContentProtectionModuleConfig } from "../modules/protection/ContentProtectionModule";
10
+ import { TextHighlighter, TextHighlighterConfig } from "../modules/highlight/TextHighlighter";
11
+ import { TimelineModule } from "../modules/positions/TimelineModule";
16
12
  import BookView from "../views/BookView";
17
- import MediaOverlayModule, { MediaOverlayModuleConfig } from "../modules/mediaoverlays/MediaOverlayModule";
13
+ import { MediaOverlayModule, MediaOverlayModuleConfig } from "../modules/mediaoverlays/MediaOverlayModule";
18
14
  import { D2Link, Link } from "../model/Link";
15
+ import { ReaderModule } from "../modules/ReaderModule";
16
+ import { TTSModuleConfig } from "../modules/TTS/TTSSettings";
17
+ import { PageBreakModuleConfig } from "../modules/pagebreak/PageBreakModule";
18
+ import { PageBreakModule } from "../modules/pagebreak/PageBreakModule";
19
+ import { DefinitionsModule, DefinitionsModuleConfig } from "../modules/search/DefinitionsModule";
20
+ import EventEmitter from "eventemitter3";
21
+ import LineFocusModule, { LineFocusModuleConfig } from "../modules/linefocus/LineFocusModule";
22
+ import { HistoryModule } from "../modules/history/HistoryModule";
23
+ import CitationModule, { CitationModuleConfig } from "../modules/citation/CitationModule";
19
24
  export declare type GetContent = (href: string) => Promise<string>;
25
+ export declare type GetContentBytesLength = (href: string) => Promise<number>;
20
26
  export interface NavigatorAPI {
21
27
  updateSettings: any;
22
28
  getContent: GetContent;
29
+ getContentBytesLength: GetContentBytesLength;
23
30
  resourceReady: any;
24
31
  resourceAtStart: any;
25
32
  resourceAtEnd: any;
26
33
  resourceFitsScreen: any;
27
34
  updateCurrentLocation: any;
35
+ onError?: (e: Error) => void;
28
36
  }
29
37
  export interface UpLinkConfig {
30
38
  url?: URL;
@@ -36,31 +44,36 @@ export interface IFrameAttributes {
36
44
  navHeight?: number;
37
45
  iframePaddingTop?: number;
38
46
  bottomInfoHeight?: number;
47
+ sideNavPosition?: "left" | "right";
39
48
  }
40
49
  export interface IFrameNavigatorConfig {
41
50
  mainElement: HTMLElement;
42
- headerMenu: HTMLElement;
43
- footerMenu: HTMLElement;
51
+ headerMenu?: HTMLElement | null;
52
+ footerMenu?: HTMLElement | null;
44
53
  publication: Publication;
45
54
  settings: UserSettings;
46
55
  annotator?: Annotator;
47
- eventHandler?: EventHandler;
48
- touchEventHandler?: TouchEventHandler;
49
- keyboardEventHandler?: KeyboardEventHandler;
50
56
  upLink?: UpLinkConfig;
51
57
  initialLastReadingPosition?: ReadingPosition;
52
- rights?: ReaderRights;
58
+ rights: ReaderRights;
53
59
  material?: ReaderUI;
54
- api: NavigatorAPI;
55
- tts: TTSModuleConfig;
60
+ api?: NavigatorAPI;
61
+ tts?: TTSModuleConfig;
56
62
  injectables: Array<Injectable>;
57
- attributes: IFrameAttributes;
58
- services: PublicationServices;
63
+ attributes?: IFrameAttributes;
64
+ services?: PublicationServices;
65
+ sample?: SampleRead;
59
66
  }
60
67
  export interface PublicationServices {
61
68
  positions?: URL;
62
69
  weight?: URL;
63
70
  }
71
+ export interface SampleRead {
72
+ isSampleRead?: boolean;
73
+ limit?: number;
74
+ popup?: string;
75
+ minimum?: number;
76
+ }
64
77
  export interface Injectable {
65
78
  type: string;
66
79
  url?: string;
@@ -72,20 +85,21 @@ export interface Injectable {
72
85
  appearance?: string;
73
86
  async?: boolean;
74
87
  }
75
- export interface SelectionMenuItem {
76
- id: string;
77
- callback: any;
78
- }
79
88
  export interface ReaderRights {
80
- enableBookmarks?: boolean;
81
- enableAnnotations?: boolean;
82
- enableTTS?: boolean;
83
- enableSearch?: boolean;
84
- enableContentProtection?: boolean;
85
- enableMaterial?: boolean;
86
- enableTimeline?: boolean;
87
- autoGeneratePositions?: boolean;
88
- enableMediaOverlays?: boolean;
89
+ enableBookmarks: boolean;
90
+ enableAnnotations: boolean;
91
+ enableTTS: boolean;
92
+ enableSearch: boolean;
93
+ enableDefinitions: boolean;
94
+ enableContentProtection: boolean;
95
+ enableTimeline: boolean;
96
+ autoGeneratePositions: boolean;
97
+ enableMediaOverlays: boolean;
98
+ enablePageBreaks: boolean;
99
+ enableLineFocus: boolean;
100
+ customKeyboardEvents: boolean;
101
+ enableHistory: boolean;
102
+ enableCitations: boolean;
89
103
  }
90
104
  export interface ReaderUI {
91
105
  settings: UserSettingsUIConfig;
@@ -101,38 +115,44 @@ export interface ReaderConfig {
101
115
  api?: NavigatorAPI;
102
116
  tts?: TTSModuleConfig;
103
117
  search?: SearchModuleConfig;
118
+ define?: DefinitionsModuleConfig;
104
119
  protection?: ContentProtectionModuleConfig;
105
120
  mediaOverlays?: MediaOverlayModuleConfig;
121
+ pagebreak?: PageBreakModuleConfig;
106
122
  annotations?: AnnotationModuleConfig;
107
123
  bookmarks?: BookmarkModuleConfig;
124
+ lineFocus?: LineFocusModuleConfig;
125
+ citations?: CitationModuleConfig;
108
126
  highlighter?: TextHighlighterConfig;
109
127
  injectables: Array<Injectable>;
110
128
  injectablesFixed: Array<Injectable>;
111
129
  useLocalStorage?: boolean;
112
130
  attributes?: IFrameAttributes;
113
131
  services?: PublicationServices;
132
+ sample?: SampleRead;
114
133
  }
115
134
  /** Class that shows webpub resources in an iframe, with navigation controls outside the iframe. */
116
- export default class IFrameNavigator implements Navigator {
135
+ export declare class IFrameNavigator extends EventEmitter implements Navigator {
117
136
  iframes: Array<HTMLIFrameElement>;
118
- currentTocUrl: string;
119
- headerMenu: HTMLElement;
137
+ currentTocUrl: string | undefined;
138
+ headerMenu?: HTMLElement | null;
120
139
  mainElement: HTMLElement;
121
140
  publication: Publication;
122
141
  bookmarkModule?: BookmarkModule;
123
142
  annotationModule?: AnnotationModule;
124
- ttsModule?: TTSModule;
143
+ ttsModule?: ReaderModule;
125
144
  searchModule?: SearchModule;
145
+ definitionsModule?: DefinitionsModule;
126
146
  contentProtectionModule?: ContentProtectionModule;
127
147
  highlighter?: TextHighlighter;
128
148
  timelineModule?: TimelineModule;
149
+ pageBreakModule?: PageBreakModule;
129
150
  mediaOverlayModule?: MediaOverlayModule;
151
+ lineFocusModule?: LineFocusModule;
152
+ historyModule?: HistoryModule;
153
+ citationModule?: CitationModule;
130
154
  sideNavExpanded: boolean;
131
155
  material: boolean;
132
- mTabs: Array<any>;
133
- mDropdowns: Array<any>;
134
- mCollapsibles: Array<any>;
135
- mSidenav: any;
136
156
  currentChapterLink: D2Link;
137
157
  currentSpreadLinks: {
138
158
  left?: D2Link;
@@ -143,10 +163,11 @@ export default class IFrameNavigator implements Navigator {
143
163
  private previousChapterLink;
144
164
  settings: UserSettings;
145
165
  private readonly annotator;
146
- view: BookView | null;
166
+ view: BookView;
147
167
  private readonly eventHandler;
148
168
  private readonly touchEventHandler;
149
169
  private readonly keyboardEventHandler;
170
+ private readonly sampleReadEventHandler;
150
171
  private readonly upLinkConfig;
151
172
  private upLink;
152
173
  private nextChapterBottomAnchorElement;
@@ -159,18 +180,13 @@ export default class IFrameNavigator implements Navigator {
159
180
  private landmarksView;
160
181
  private landmarksSection;
161
182
  private pageListView;
162
- private goToPageView;
163
- private goToPageNumberInput;
164
- private goToPageNumberButton;
165
- private bookmarksControl;
166
- private bookmarksView;
167
183
  private links;
168
184
  private linksTopLeft;
169
185
  private linksBottom;
170
186
  private linksMiddle;
171
187
  private tocView;
172
188
  private loadingMessage;
173
- private errorMessage;
189
+ errorMessage: HTMLDivElement;
174
190
  private tryAgainButton;
175
191
  private goBackButton;
176
192
  private infoTop;
@@ -183,48 +199,51 @@ export default class IFrameNavigator implements Navigator {
183
199
  private newElementId;
184
200
  private isBeingStyled;
185
201
  private isLoading;
186
- private readonly initialLastReadingPosition;
187
- api: NavigatorAPI;
202
+ private readonly initialLastReadingPosition?;
203
+ api?: NavigatorAPI;
188
204
  rights: ReaderRights;
189
- tts: TTSModuleConfig;
190
- injectables: Array<Injectable>;
191
- attributes: IFrameAttributes;
192
- services: PublicationServices;
193
- static create(config: IFrameNavigatorConfig): Promise<any>;
194
- protected constructor(settings: UserSettings, annotator: Annotator | null, eventHandler: EventHandler | null, touchEventHandler: TouchEventHandler | null, keyboardEventHandler: KeyboardEventHandler | null, upLinkConfig: UpLinkConfig | null, initialLastReadingPosition: ReadingPosition | null, publication: Publication, material: any, api: NavigatorAPI, rights: ReaderRights, tts: TTSModuleConfig, injectables: Array<Injectable>, attributes: IFrameAttributes, services: PublicationServices);
195
- stop(): Promise<void>;
205
+ tts?: TTSModuleConfig;
206
+ injectables?: Array<Injectable>;
207
+ attributes?: IFrameAttributes;
208
+ services?: PublicationServices;
209
+ sample?: SampleRead;
210
+ private didInitKeyboardEventHandler;
211
+ static create(config: IFrameNavigatorConfig): Promise<IFrameNavigator>;
212
+ protected constructor(settings: UserSettings, annotator: Annotator | undefined, upLinkConfig: UpLinkConfig | undefined, initialLastReadingPosition: ReadingPosition | undefined, publication: Publication, material: any, api?: NavigatorAPI, rights?: ReaderRights, tts?: TTSModuleConfig, injectables?: Array<Injectable>, attributes?: IFrameAttributes, services?: PublicationServices, sample?: SampleRead);
213
+ stop(): void;
196
214
  spreads: HTMLDivElement;
197
215
  firstSpread: HTMLDivElement;
198
- protected start(mainElement: HTMLElement, headerMenu: HTMLElement, footerMenu: HTMLElement): Promise<void>;
216
+ protected start(mainElement: HTMLElement, headerMenu?: HTMLElement | null, footerMenu?: HTMLElement | null): Promise<void>;
199
217
  timeout: any;
200
218
  onResize: () => void;
201
219
  reload: () => Promise<void>;
202
220
  private setupEvents;
203
- private setupModalFocusTrap;
204
- private goToPageNumber;
205
221
  isScrolling: boolean;
206
222
  private updateBookView;
207
223
  private loadManifest;
208
224
  private handleIFrameLoad;
225
+ private injectInjectablesIntoIframeHead;
226
+ /**
227
+ * Displays standard error UI.
228
+ */
209
229
  private abortOnError;
210
230
  private tryAgain;
211
231
  private precessContentForIframe;
212
232
  private static goBack;
213
- private static isDisplayed;
214
- private static showElement;
215
- private static hideElement;
216
- private hideModal;
217
- private toggleDisplay;
218
233
  private handleEditClick;
219
234
  get hasMediaOverlays(): boolean;
220
235
  startReadAloud(): void;
221
- stopReadAloud(ttsOnly?: boolean): void;
236
+ startReadAlong(): void;
237
+ stopReadAloud(): void;
238
+ stopReadAlong(): void;
222
239
  pauseReadAloud(): void;
240
+ pauseReadAlong(): void;
223
241
  resumeReadAloud(): void;
242
+ resumeReadAlong(): void;
224
243
  totalResources(): number;
225
244
  mostRecentNavigatedTocItem(): string;
226
- currentResource(): number;
227
- currentLink(): Array<Link>;
245
+ currentResource(): number | undefined;
246
+ currentLink(): Array<Link | undefined>;
228
247
  tableOfContents(): any;
229
248
  readingOrder(): any;
230
249
  atStart(): boolean;
@@ -237,21 +256,23 @@ export default class IFrameNavigator implements Navigator {
237
256
  currentLocator(): Locator;
238
257
  positions(): any;
239
258
  goToPosition(position: number): void;
240
- snapToElement(element: HTMLElement): void;
259
+ snapToSelector(selector: any): void;
241
260
  applyAttributes(attributes: IFrameAttributes): void;
242
261
  private handlePreviousPageClick;
243
262
  private handleNextPageClick;
244
263
  private handleClickThrough;
245
264
  private handleInternalLink;
246
265
  private handleNumberOfIframes;
247
- private handleResize;
248
- updatePositionInfo(): void;
266
+ handleResize(): Promise<void>;
267
+ updatePositionInfo(save?: boolean): void;
268
+ savePosition: (() => void) & {
269
+ clear(): void;
270
+ };
249
271
  private handlePreviousChapterClick;
250
272
  private handleNextChapterClick;
251
- private hideBookmarksOnEscape;
252
273
  private hideView;
253
274
  private setActiveTOCItem;
254
- navigate(locator: Locator): void;
275
+ navigate(locator: Locator, history?: boolean): Promise<void>;
255
276
  checkResourcePosition: (() => void) & {
256
277
  clear(): void;
257
278
  };
@@ -263,4 +284,8 @@ export default class IFrameNavigator implements Navigator {
263
284
  private static createBase;
264
285
  private static createCssLink;
265
286
  private static createJavascriptLink;
287
+ activateMarker(id: any, position: any): void;
288
+ deactivateMarker(): void;
289
+ showLayer(layer: any): void;
290
+ hideLayer(layer: any): void;
266
291
  }
@@ -0,0 +1,202 @@
1
+ import { Annotation, Bookmark, Locator } from "./model/Locator";
2
+ import { UserSettingsIncrementable } from "./model/user-settings/UserProperties";
3
+ import { UserSettings } from "./model/user-settings/UserSettings";
4
+ import { IMediaOverlayUserSettings, MediaOverlayIncrementable } from "./modules/mediaoverlays/MediaOverlaySettings";
5
+ import { ITTSUserSettings, TTSIncrementable } from "./modules/TTS/TTSSettings";
6
+ import { IFrameAttributes, ReaderConfig } from "./navigator/IFrameNavigator";
7
+ /**
8
+ * A class that, once instantiated using the public `.build` method,
9
+ * is the primary interface into the D2 Reader.
10
+ * @TODO :
11
+ * - Type all function arguments
12
+ * - DEV logger
13
+ * - Default config
14
+ * - Different types for initial config and final config
15
+ * - Testing
16
+ */
17
+ export default class D2Reader {
18
+ private readonly settings;
19
+ private readonly navigator;
20
+ private readonly highlighter;
21
+ private readonly bookmarkModule?;
22
+ private readonly annotationModule?;
23
+ private readonly ttsSettings?;
24
+ private readonly ttsModule?;
25
+ private readonly searchModule?;
26
+ private readonly definitionsModule?;
27
+ private readonly contentProtectionModule?;
28
+ private readonly timelineModule?;
29
+ private readonly mediaOverlaySettings?;
30
+ private readonly mediaOverlayModule?;
31
+ private readonly pageBreakModule?;
32
+ private readonly lineFocusModule?;
33
+ private readonly historyModule?;
34
+ private readonly citationModule?;
35
+ private constructor();
36
+ addEventListener(): void;
37
+ /**
38
+ * The async builder.
39
+ */
40
+ static load(initialConfig: ReaderConfig): Promise<D2Reader>;
41
+ /**
42
+ * Read Aloud
43
+ */
44
+ /** Start TTS Read Aloud */
45
+ startReadAloud: () => void;
46
+ /** Start TTS Read Aloud */
47
+ stopReadAloud: () => void;
48
+ /** Start TTS Read Aloud */
49
+ pauseReadAloud: () => void;
50
+ /** Start TTS Read Aloud */
51
+ resumeReadAloud: () => void;
52
+ /**
53
+ * Read Along
54
+ */
55
+ /** Start Media Overlay Read Along */
56
+ startReadAlong: () => void;
57
+ /** Stop Media Overlay Read Along */
58
+ stopReadAlong: () => void;
59
+ /** Pause Media Overlay Read Along */
60
+ pauseReadAlong: () => void;
61
+ /** Resume Media Overlay Read Along */
62
+ resumeReadAlong: () => void;
63
+ get hasMediaOverlays(): boolean;
64
+ /**
65
+ * Bookmarks and annotations
66
+ */
67
+ /** Save bookmark by progression */
68
+ saveBookmark: () => Promise<any>;
69
+ /** Save bookmark by annotation */
70
+ saveBookmarkPlus: () => Promise<any>;
71
+ /** Delete bookmark */
72
+ deleteBookmark: (bookmark: Bookmark) => Promise<any>;
73
+ /** Delete annotation */
74
+ deleteAnnotation: (highlight: Annotation) => Promise<any>;
75
+ /** Add annotation */
76
+ addAnnotation: (highlight: Annotation) => Promise<any>;
77
+ /** Hide Annotation Layer */
78
+ hideAnnotationLayer: () => void | undefined;
79
+ /** Show Annotation Layer */
80
+ showAnnotationLayer: () => void | undefined;
81
+ /** Hide Layer */
82
+ hideLayer: (layer: any) => void;
83
+ /** Show Layer */
84
+ showLayer: (layer: any) => void;
85
+ /** Activate Marker <br>
86
+ * Activated Marker will be used for active annotation creation */
87
+ activateMarker: (id: string, position: string) => void;
88
+ /** Deactivate Marker */
89
+ deactivateMarker: () => void;
90
+ /**
91
+ * Definitions
92
+ */
93
+ /** Clear current definitions */
94
+ clearDefinitions: () => Promise<void>;
95
+ /** Add newt definition */
96
+ addDefinition: (definition: any) => Promise<void>;
97
+ /** Table of Contents */
98
+ get tableOfContents(): any;
99
+ /** Reading Order or Spine */
100
+ get readingOrder(): any;
101
+ /** Current Bookmarks */
102
+ get bookmarks(): any;
103
+ /** Current Annotations */
104
+ get annotations(): any;
105
+ /**
106
+ * Search
107
+ */
108
+ /** Search by term and current resource or entire book <br>
109
+ * current = true, will search only current resource <br>
110
+ * current = false, will search entire publication */
111
+ search: (term: string, current: boolean) => Promise<any>;
112
+ goToSearchIndex: (href: string, index: number, current: boolean) => Promise<void>;
113
+ goToSearchID: (href: string, index: number, current: boolean) => Promise<void>;
114
+ clearSearch: () => Promise<void>;
115
+ /**
116
+ * Resources
117
+ */
118
+ get currentResource(): number | undefined;
119
+ get mostRecentNavigatedTocItem(): string;
120
+ get totalResources(): number;
121
+ get publicationLanguage(): string[];
122
+ /**
123
+ * Settings
124
+ */
125
+ get currentSettings(): {
126
+ appearance: string;
127
+ fontFamily: string;
128
+ textAlignment: string;
129
+ columnCount: string;
130
+ verticalScroll: boolean;
131
+ fontSize: number;
132
+ wordSpacing: number;
133
+ letterSpacing: number;
134
+ pageMargins: number;
135
+ lineHeight: number;
136
+ };
137
+ resetUserSettings: () => Promise<void>;
138
+ applyUserSettings: (userSettings: Partial<UserSettings>) => Promise<void>;
139
+ scroll: (value: boolean) => Promise<void>;
140
+ private isTTSIncrementable;
141
+ private isMOIncrementable;
142
+ /**
143
+ * Used to increase anything that can be increased,
144
+ * such as pitch, rate, volume, fontSize
145
+ */
146
+ increase: (incremental: UserSettingsIncrementable | TTSIncrementable | MediaOverlayIncrementable) => Promise<void>;
147
+ /**
148
+ * Used to decrease anything that can be decreased,
149
+ * such as pitch, rate, volume, fontSize
150
+ */
151
+ decrease: (incremental: UserSettingsIncrementable | TTSIncrementable | MediaOverlayIncrementable) => Promise<void>;
152
+ /**
153
+ * Publisher?
154
+ * Disabled
155
+ */
156
+ /**
157
+ * TTS Settings
158
+ */
159
+ resetTTSSettings: () => void;
160
+ applyTTSSettings: (ttsSettings: Partial<ITTSUserSettings>) => Promise<void>;
161
+ /**
162
+ * Disabled
163
+ */
164
+ applyPreferredVoice: (value: string) => Promise<void>;
165
+ /**
166
+ * Media Overlay Settings
167
+ */
168
+ resetMediaOverlaySettings: () => Promise<void>;
169
+ applyMediaOverlaySettings: (settings: Partial<IMediaOverlayUserSettings>) => Promise<void>;
170
+ /**
171
+ * Navigation
172
+ * @TODO : These should return promises that complete when they are done.
173
+ */
174
+ get currentLocator(): Locator;
175
+ get positions(): any;
176
+ goTo: (locator: Locator) => Promise<void>;
177
+ goToPosition: (value: number) => Promise<void>;
178
+ nextResource: () => void;
179
+ previousResource: () => void;
180
+ nextPage: () => Promise<void>;
181
+ previousPage: () => Promise<void>;
182
+ get atStart(): boolean;
183
+ get atEnd(): boolean;
184
+ snapToSelector: (selector: any) => Promise<void>;
185
+ /**
186
+ * You have attributes in the reader when you initialize it. You can set margin, navigationHeight etc...
187
+ * This is in case you change the attributes after initializing the reader.
188
+ */
189
+ applyAttributes: (value: IFrameAttributes) => void;
190
+ applyLineFocusSettings(userSettings: any): Promise<void>;
191
+ lineUp(): void;
192
+ lineDown(): void;
193
+ enableLineFocus(): Promise<void>;
194
+ lineFocus(active: boolean): Promise<void>;
195
+ disableLineFocus(): void;
196
+ /**
197
+ * Destructor:
198
+ * Only used in react applications because when they re-visit the page
199
+ * it tried to create a new reader, which interfered with the first one.
200
+ */
201
+ stop: () => void;
202
+ }
@@ -0,0 +1,25 @@
1
+ import { ReadingPosition } from "../model/Locator";
2
+ import { IHighlight } from "../modules/highlight/common/highlight";
3
+ interface Annotator {
4
+ initLastReadingPosition(position: ReadingPosition): any;
5
+ getLastReadingPosition(): any;
6
+ saveLastReadingPosition(position: any): any;
7
+ initBookmarks(list: any): any;
8
+ saveBookmark(bookmark: any): any;
9
+ deleteBookmark(bookmark: any): any;
10
+ getBookmarks(href?: string): any;
11
+ locatorExists(locator: any, type: AnnotationType): any;
12
+ initAnnotations(list: any): any;
13
+ saveAnnotation(annotation: any): any;
14
+ deleteAnnotation(id: any): any;
15
+ deleteSelectedAnnotation(annotation: any): any;
16
+ getAnnotations(): any;
17
+ getAnnotation(annotation: IHighlight): any;
18
+ getAnnotationByID(id: string): any;
19
+ getAnnotationPosition(id: any, iframeWin: any): any;
20
+ }
21
+ export declare enum AnnotationType {
22
+ Bookmark = 0,
23
+ Annotation = 1
24
+ }
25
+ export default Annotator;
@@ -0,0 +1,31 @@
1
+ import Annotator, { AnnotationType } from "./Annotator";
2
+ import Store from "./Store";
3
+ import { ReadingPosition } from "../model/Locator";
4
+ import { IHighlight } from "../modules/highlight/common/highlight";
5
+ export interface LocalAnnotatorConfig {
6
+ store: Store;
7
+ }
8
+ /** Annotator that stores annotations locally, in the browser. */
9
+ export default class LocalAnnotator implements Annotator {
10
+ private readonly store;
11
+ private static readonly LAST_READING_POSITION;
12
+ private static readonly BOOKMARKS;
13
+ private static readonly ANNOTATIONS;
14
+ constructor(config: LocalAnnotatorConfig);
15
+ getLastReadingPosition(): any;
16
+ initLastReadingPosition(position: ReadingPosition): void;
17
+ saveLastReadingPosition(position: any): void;
18
+ initBookmarks(list: any): any;
19
+ saveBookmark(bookmark: any): any;
20
+ locatorExists(locator: any, type: AnnotationType): any | null;
21
+ deleteBookmark(bookmark: any): any;
22
+ getBookmarks(href?: string): any;
23
+ initAnnotations(list: any): any;
24
+ saveAnnotation(annotation: any): any;
25
+ deleteAnnotation(id: any): any;
26
+ deleteSelectedAnnotation(annotation: any): any;
27
+ getAnnotations(): any;
28
+ getAnnotationPosition(id: any, iframeWin: any): any;
29
+ getAnnotation(highlight: IHighlight): any;
30
+ getAnnotationByID(id: string): any;
31
+ }
@@ -14,7 +14,7 @@ export default class LocalStorageStore implements Store {
14
14
  private readonly useLocalStorage;
15
15
  constructor(config: LocalStorageStoreConfig);
16
16
  private getLocalStorageKey;
17
- get(key: string): Promise<any | null>;
18
- set(key: string, value: any): Promise<void>;
19
- remove(key: string): Promise<void>;
17
+ get(key: string): any | null;
18
+ set(key: string, value: any): void;
19
+ remove(key: string): void;
20
20
  }
@@ -3,7 +3,7 @@ import Store from "./Store";
3
3
  export default class MemoryStore implements Store {
4
4
  private readonly store;
5
5
  constructor();
6
- get(key: string): Promise<string | null>;
7
- set(key: string, value: string): Promise<void>;
8
- remove(key: string): Promise<void>;
6
+ get(key: string): string | null;
7
+ set(key: string, value: string): void;
8
+ remove(key: string): void;
9
9
  }
@@ -0,0 +1,6 @@
1
+ interface Store {
2
+ get(key: string): any | null;
3
+ set(key: string, value: any): void;
4
+ remove(key: string): void;
5
+ }
6
+ export default Store;
@@ -0,0 +1,23 @@
1
+ import { IFrameNavigator } from "../navigator/IFrameNavigator";
2
+ import { Popup } from "../modules/search/Popup";
3
+ export declare function addEventListenerOptional(element: any, eventType: string, eventListener: any): void;
4
+ export declare function removeEventListenerOptional(element: any, eventType: string, eventListener: any): void;
5
+ export default class EventHandler {
6
+ navigator: IFrameNavigator;
7
+ popup: Popup;
8
+ constructor(navigator: IFrameNavigator);
9
+ onInternalLink: (event: UIEvent) => void;
10
+ onClickThrough: (event: UIEvent) => void;
11
+ setupEvents(element: HTMLElement | Document | null): void;
12
+ private checkForLink;
13
+ private linkInPublication;
14
+ /**
15
+ *
16
+ * This function checks the user clicked link inside the iframe
17
+ * against the readingOrder list, it is an internal link if found.
18
+ *
19
+ */
20
+ private isReadingOrderInternal;
21
+ private isResourceInternal;
22
+ private handleLinks;
23
+ }
File without changes
@@ -1,15 +1,15 @@
1
1
  /** Returns a single element matching the selector within the parentElement,
2
2
  or null if no element matches. */
3
- export declare function findElement(parentElement: Element | Document, selector: string): Element | null;
3
+ export declare function findElement(parentElement: Element | Document, selector: string): any | null;
4
4
  /** Returns a single element matching the selector within the parent element,
5
5
  or throws an exception if no element matches. */
6
- export declare function findRequiredElement(parentElement: Element | Document, selector: string): Element;
6
+ export declare function findRequiredElement(parentElement: Element | Document, selector: string): any;
7
7
  /** Returns a single element matching the selector within the parentElement in the iframe context,
8
8
  or null if no element matches. */
9
9
  export declare function findIframeElement(parentElement: Document | null, selector: string): Element | null;
10
10
  /** Returns a single element matching the selector within the parent element in an iframe context,
11
11
  or throws an exception if no element matches. */
12
- export declare function findRequiredIframeElement(parentElement: Document | null, selector: string): Element;
12
+ export declare function findRequiredIframeElement(parentElement: Document, selector: string): Element;
13
13
  /** Sets an attribute and its value for an HTML element */
14
14
  export declare function setAttr(element: HTMLElement, attr: string, value: string): void;
15
15
  /** Removes an attribute for an HTML element */