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

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 (93) hide show
  1. package/README.md +10 -0
  2. package/dist/esm/index.js +60633 -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/style/linefocus.css +55 -0
  7. package/dist/injectables/style/popup.css +121 -0
  8. package/dist/injectables/style/style.css +250 -0
  9. package/dist/{material.css.map → material.map.css} +0 -0
  10. package/dist/reader.css +2 -5
  11. package/dist/reader.js +161 -3
  12. package/dist/reader.js.map +7 -1
  13. package/dist/reader.map.css +21 -0
  14. package/dist/types/index.d.ts +7 -0
  15. package/dist/{model → types/model}/Link.d.ts +1 -1
  16. package/dist/{model → types/model}/Locator.d.ts +3 -18
  17. package/dist/{model → types/model}/Publication.d.ts +17 -13
  18. package/dist/{model → types/model}/user-settings/ReadiumCSS.d.ts +0 -0
  19. package/dist/{model → types/model}/user-settings/UserProperties.d.ts +3 -2
  20. package/dist/{model → types/model}/user-settings/UserSettings.d.ts +6 -6
  21. package/dist/{modules → types/modules}/AnnotationModule.d.ts +30 -18
  22. package/dist/types/modules/BookmarkModule.d.ts +57 -0
  23. package/dist/types/modules/ReaderModule.d.ts +2 -0
  24. package/dist/types/modules/TTS/TTSModule.d.ts +33 -0
  25. package/dist/types/modules/TTS/TTSModule2.d.ts +73 -0
  26. package/dist/{modules → types/modules}/TTS/TTSSettings.d.ts +41 -17
  27. package/dist/{modules → types/modules}/highlight/HtmlElementSelector.d.ts +0 -0
  28. package/dist/types/modules/highlight/LayerSettings.d.ts +19 -0
  29. package/dist/{modules → types/modules}/highlight/TextHighlighter.d.ts +57 -57
  30. package/dist/{modules → types/modules}/highlight/common/document.d.ts +0 -0
  31. package/dist/{modules → types/modules}/highlight/common/events.d.ts +0 -0
  32. package/dist/types/modules/highlight/common/highlight.d.ts +71 -0
  33. package/dist/{modules → types/modules}/highlight/common/rect-utils.d.ts +1 -1
  34. package/dist/{modules → types/modules}/highlight/common/selection.d.ts +8 -3
  35. package/dist/{modules → types/modules}/highlight/renderer/common/cssselector.d.ts +0 -0
  36. package/dist/{modules → types/modules}/highlight/renderer/common/cssselector2.d.ts +0 -0
  37. package/dist/{modules → types/modules}/highlight/renderer/iframe/selection.d.ts +2 -2
  38. package/dist/{modules → types/modules}/highlight/renderer/iframe/state.d.ts +0 -3
  39. package/dist/types/modules/linefocus/LineFocusModule.d.ts +45 -0
  40. package/dist/{modules → types/modules}/mediaoverlays/MediaOverlayModule.d.ts +19 -14
  41. package/dist/{modules → types/modules}/mediaoverlays/MediaOverlaySettings.d.ts +20 -16
  42. package/dist/types/modules/pagebreak/PageBreakModule.d.ts +30 -0
  43. package/dist/{modules → types/modules}/positions/TimelineModule.d.ts +4 -4
  44. package/dist/{modules → types/modules}/protection/ContentProtectionModule.d.ts +11 -7
  45. package/dist/types/modules/sampleread/SampleReadEventHandler.d.ts +8 -0
  46. package/dist/types/modules/search/DefinitionsModule.d.ts +52 -0
  47. package/dist/types/modules/search/Popup.d.ts +8 -0
  48. package/dist/{modules → types/modules}/search/SearchModule.d.ts +17 -13
  49. package/dist/{modules → types/modules}/search/searchWithDomSeek.d.ts +1 -1
  50. package/dist/{navigator → types/navigator}/IFrameNavigator.d.ts +88 -57
  51. package/dist/{navigator → types/navigator}/Navigator.d.ts +0 -0
  52. package/dist/types/reader.d.ts +200 -0
  53. package/dist/types/store/Annotator.d.ts +25 -0
  54. package/dist/types/store/LocalAnnotator.d.ts +31 -0
  55. package/dist/{store → types/store}/LocalStorageStore.d.ts +3 -3
  56. package/dist/{store → types/store}/MemoryStore.d.ts +3 -3
  57. package/dist/types/store/Store.d.ts +6 -0
  58. package/dist/{utils → types/utils}/BrowserUtilities.d.ts +0 -7
  59. package/dist/{utils → types/utils}/EventHandler.d.ts +12 -0
  60. package/dist/{utils → types/utils}/HTMLTemplates.d.ts +0 -0
  61. package/dist/{utils → types/utils}/HTMLUtilities.d.ts +3 -3
  62. package/dist/{utils → types/utils}/IconLib.d.ts +1 -0
  63. package/dist/{utils → types/utils}/JsonUtil.d.ts +0 -0
  64. package/dist/types/utils/KeyboardEventHandler.d.ts +9 -0
  65. package/dist/{utils → types/utils}/TouchEventHandler.d.ts +1 -1
  66. package/dist/types/utils/index.d.ts +6 -0
  67. package/dist/{views → types/views}/BookView.d.ts +9 -7
  68. package/dist/{views → types/views}/FixedBookView.d.ts +7 -4
  69. package/dist/{views → types/views}/ReflowableBookView.d.ts +6 -4
  70. package/package.json +35 -19
  71. package/CHANGELOG.md +0 -6
  72. package/NOTICE +0 -20
  73. package/dist/index.d.ts +0 -140
  74. package/dist/injectables/click/click.d.ts +0 -1
  75. package/dist/injectables/footnotes/footnotes.d.ts +0 -1
  76. package/dist/injectables/footnotes/footnotes.js +0 -2
  77. package/dist/injectables/footnotes/footnotes.js.map +0 -1
  78. package/dist/injectables/glossary/glossary.d.ts +0 -5
  79. package/dist/injectables/glossary/glossary.js +0 -3
  80. package/dist/injectables/glossary/glossary.js.LICENSE.txt +0 -6
  81. package/dist/injectables/glossary/glossary.js.map +0 -1
  82. package/dist/modules/BookmarkModule.d.ts +0 -46
  83. package/dist/modules/ReaderModule.d.ts +0 -3
  84. package/dist/modules/TTS/TTSModule.d.ts +0 -58
  85. package/dist/modules/highlight/common/highlight.d.ts +0 -19
  86. package/dist/modules/highlight/common/styles.d.ts +0 -35
  87. package/dist/reader.css.map +0 -21
  88. package/dist/reader.js.LICENSE.txt +0 -68
  89. package/dist/store/Annotator.d.ts +0 -25
  90. package/dist/store/LocalAnnotator.d.ts +0 -31
  91. package/dist/store/Store.d.ts +0 -6
  92. package/dist/utils/KeyboardEventHandler.d.ts +0 -7
  93. package/dist/utils/index.d.ts +0 -1
@@ -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;
@@ -1,13 +1,6 @@
1
- import { ReaderConfig } from "../navigator/IFrameNavigator";
2
1
  /** Returns the current width of the document. */
3
2
  export declare function getWidth(): number;
4
3
  /** Returns the current height of the document. */
5
4
  export declare function getHeight(): number;
6
5
  /** Returns true if the browser is zoomed in with pinch-to-zoom on mobile. */
7
6
  export declare function isZoomed(): boolean;
8
- /**
9
- * If enforceSupportedBrowsers is true, will get supported browsers
10
- * from the config and throw an error if the user is not on a supported
11
- * browser.
12
- */
13
- export declare function enforceSupportedBrowsers(config: ReaderConfig): void;
@@ -1,9 +1,21 @@
1
+ import { IFrameNavigator } from "../navigator/IFrameNavigator";
2
+ import { Popup } from "../modules/search/Popup";
1
3
  export declare function addEventListenerOptional(element: any, eventType: string, eventListener: any): void;
2
4
  export declare function removeEventListenerOptional(element: any, eventType: string, eventListener: any): void;
3
5
  export default class EventHandler {
6
+ navigator: IFrameNavigator;
7
+ popup: Popup;
8
+ constructor(navigator: IFrameNavigator);
4
9
  onInternalLink: (event: UIEvent) => void;
5
10
  onClickThrough: (event: UIEvent) => void;
6
11
  setupEvents(element: HTMLElement | Document | null): void;
7
12
  private checkForLink;
13
+ /**
14
+ *
15
+ * This function checks the user clicked link inside the iframe
16
+ * against the readingOrder list, it is an internal link if found.
17
+ *
18
+ */
19
+ private isEpubInternal;
8
20
  private handleLinks;
9
21
  }
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): HTMLElement | 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): HTMLElement;
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 */
@@ -1,6 +1,7 @@
1
1
  export declare const WIDTH_ATTR: number;
2
2
  export declare const HEIGHT_ATTR: number;
3
3
  export declare const VIEWBOX_ATTR: string;
4
+ export declare const iconTemplateColored: (id: string, title: string, path: string, classAttr: string | undefined, size: number, fill: string) => string;
4
5
  export declare const icons: {
5
6
  error: string;
6
7
  home: string;
File without changes
@@ -0,0 +1,9 @@
1
+ import { IFrameNavigator } from "../navigator/IFrameNavigator";
2
+ export default class KeyboardEventHandler {
3
+ delegate: IFrameNavigator;
4
+ onBackwardSwipe: (event: UIEvent) => void;
5
+ onForwardSwipe: (event: UIEvent) => void;
6
+ setupEvents: (element: HTMLElement | Document | null) => void;
7
+ focusin: (element: HTMLElement | Document) => void;
8
+ keydown: (element: HTMLElement | Document) => void;
9
+ }
@@ -4,5 +4,5 @@ export default class TouchEventHandler {
4
4
  private static readonly SLOW_SWIPE_MS;
5
5
  onBackwardSwipe: (event: UIEvent) => void;
6
6
  onForwardSwipe: (event: UIEvent) => void;
7
- setupEvents: (element: HTMLElement | Document) => void;
7
+ setupEvents: (element: HTMLElement | Document | null) => void;
8
8
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * Timer function that you can 'await' on
4
+ */
5
+ export declare function delay(t: number, v?: any): Promise<any>;
6
+ export declare const IS_DEV: boolean;
@@ -1,4 +1,4 @@
1
- import IFrameNavigator, { IFrameAttributes } from "../navigator/IFrameNavigator";
1
+ import { IFrameNavigator, IFrameAttributes } from "../navigator/IFrameNavigator";
2
2
  interface BookView {
3
3
  layout: string;
4
4
  name: string;
@@ -7,24 +7,26 @@ interface BookView {
7
7
  sideMargin: number;
8
8
  height: number;
9
9
  delegate: IFrameNavigator;
10
- attributes: IFrameAttributes;
10
+ attributes?: IFrameAttributes;
11
11
  setMode?(scroll: boolean): any;
12
- isScrollMode?(): any;
13
- isPaginated?(): any;
12
+ isScrollMode(): any;
13
+ isPaginated(): any;
14
14
  goToElement?(element: HTMLElement | null, relative?: boolean): void;
15
+ setSize(): void;
15
16
  setIframeHeight?(iframe: any): any;
17
+ setSize(): void;
16
18
  getScreenHeight(): number;
17
19
  /** Load this view in its book element, at the specified position. */
18
20
  start(): void;
19
21
  /** Remove this view from its book element. */
20
22
  stop(): void;
21
23
  getCurrentPosition(): number;
22
- goToPosition(position: number): void;
24
+ goToProgression(position: number): void;
23
25
  goToFragment(fragment: string): void;
24
26
  goToCssSelector(cssSelector: string): void;
25
27
  snap(element: HTMLElement | null, relative?: boolean): void;
26
- atStart?(): boolean;
27
- atEnd?(): boolean;
28
+ atStart(): boolean;
29
+ atEnd(): boolean;
28
30
  goToPreviousPage?(): void;
29
31
  goToNextPage?(): void;
30
32
  getCurrentPage(): number;
@@ -1,9 +1,7 @@
1
- import Store from "../store/Store";
2
- import IFrameNavigator, { IFrameAttributes } from "../navigator/IFrameNavigator";
1
+ import { IFrameNavigator, IFrameAttributes } from "../navigator/IFrameNavigator";
3
2
  import BookView from "./BookView";
4
3
  export default class FixedBookView implements BookView {
5
4
  layout: string;
6
- constructor(_store: Store);
7
5
  delegate: IFrameNavigator;
8
6
  name: string;
9
7
  label: string;
@@ -16,10 +14,15 @@ export default class FixedBookView implements BookView {
16
14
  stop(): void;
17
15
  getCurrentPosition(): number;
18
16
  getScreenHeight(): number;
19
- goToPosition(_position: number): void;
17
+ goToProgression(_position: number): void;
20
18
  goToCssSelector(_cssSelector: string, _relative?: boolean): void;
21
19
  goToFragment(_fragment: string, _relative?: boolean): void;
22
20
  snap(_element: HTMLElement, _relative?: boolean): void;
23
21
  getCurrentPage(): number;
24
22
  getPageCount(): number;
23
+ setSize(): void;
24
+ isPaginated(): boolean;
25
+ isScrollMode(): boolean;
26
+ atEnd(): boolean;
27
+ atStart(): boolean;
25
28
  }
@@ -1,7 +1,7 @@
1
1
  import { UserProperty } from "../model/user-settings/UserProperties";
2
2
  import Store from "../store/Store";
3
3
  import BookView from "./BookView";
4
- import IFrameNavigator, { IFrameAttributes } from "../navigator/IFrameNavigator";
4
+ import { IFrameAttributes, IFrameNavigator } from "../navigator/IFrameNavigator";
5
5
  export default class ReflowableBookView implements BookView {
6
6
  layout: string;
7
7
  private readonly USERSETTINGS;
@@ -19,7 +19,7 @@ export default class ReflowableBookView implements BookView {
19
19
  start(): void;
20
20
  stop(): void;
21
21
  getCurrentPosition(): number;
22
- goToPosition(position: number): void;
22
+ goToProgression(position: number): void;
23
23
  goToCssSelector(cssSelector: string, relative?: boolean): void;
24
24
  goToFragment(fragment: string, relative?: boolean): void;
25
25
  snap(element: HTMLElement | null, _relative?: boolean): void;
@@ -32,12 +32,12 @@ export default class ReflowableBookView implements BookView {
32
32
  getPageCount(): number;
33
33
  isPaginated(): boolean;
34
34
  isScrollMode(): boolean;
35
- getProperty(name: string): Promise<UserProperty>;
35
+ getProperty(name: string): Promise<UserProperty | null>;
36
36
  getScreenHeight(): number;
37
37
  setIframeHeight(iframe: any): void;
38
38
  protected hasFixedScrollWidth: boolean;
39
39
  protected checkForFixedScrollWidth(): void;
40
- private setSize;
40
+ setSize(): void;
41
41
  /** Returns the total width of the columns that are currently
42
42
  positioned to the left of the iframe viewport. */
43
43
  private getLeftColumnsWidth;
@@ -49,4 +49,6 @@ export default class ReflowableBookView implements BookView {
49
49
  /** Shifts the columns so that the specified width is positioned
50
50
  to the left of the iframe viewport. */
51
51
  private setLeftColumnsWidth;
52
+ get scrollingElement(): Element;
53
+ get scrollWidth(): number;
52
54
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@d-i-t-a/reader",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-beta.10",
4
4
  "description": "A viewer application for EPUB files.",
5
5
  "repository": "https://github.com/d-i-t-a/R2D2BC",
6
6
  "license": "Apache-2.0",
7
- "main": "dist/reader.js",
8
- "typings": "dist/index.d.ts",
7
+ "main": "dist/esm/index.js",
8
+ "typings": "dist/types/index.d.ts",
9
9
  "engines": {
10
10
  "node": ">8.0.0"
11
11
  },
@@ -14,27 +14,28 @@
14
14
  },
15
15
  "scripts": {
16
16
  "prepare": "npm run build",
17
- "build": "webpack --mode=production && npm run sass && cpx \"dist/*.{css,js,map,woff,woff2}\" viewer/ && cpx \"injectables/**/*.{css,js}\" viewer/injectables/ && cpx \"dist/injectables/**/*.{css,js,map}\" viewer/injectables/",
18
- "dev": "webpack --mode=development && npm run sass && cpx \"dist/*.{css,js,map,woff,woff2}\" viewer/ && cpx \"injectables/**/*.{css,js}\" viewer/injectables/ && cpx \"dist/injectables/**/*.{css,js,map}\" viewer/injectables/",
17
+ "clean": "rimraf node_modules dist parcel-dist .parcel-cache",
18
+ "dev": "ts-node -T build.ts -w",
19
+ "build": "ts-node -T build.ts",
19
20
  "sass": "node-sass --source-map true src/styles/sass/ -o dist/",
20
- "examples": "rimraf examples/streamed/readers/viewer && cpx \"viewer/*.{html,css,js,map,woff,woff2}\" examples/streamed/readers/viewer && cpx \"viewer/readium-css/*.{css,js}\" examples/streamed/readers/viewer/readium-css && cpx \"viewer/fonts/*/*.{css,woff,woff2}\" examples/streamed/readers/viewer/fonts && cpx \"viewer/injectables/**/*.{css,js,map}\" examples/streamed/readers/viewer/injectables && cpx \"injectables/**/*.{css,js,map}\" examples/streamed/readers/viewer/injectables",
21
- "streamed": "node \"./examples/streamed/server/server-cli.inlinesourcemap.js\" ./examples/streamed/epubs/",
22
- "clean": "rimraf node_modules lib dist examples/streamed/readers/viewer",
23
- "start": "http-server viewer",
24
- "lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
21
+ "examples": "npx ts-node examples/server.ts",
22
+ "lint": "eslint '*/**/*.{js,ts,tsx}' --fix",
25
23
  "example:react": "parcel examples/react/index.html --dist-dir parcel-dist"
26
24
  },
27
25
  "dependencies": {
28
- "browser-detect-devtools": "^1.0.4",
29
26
  "browserslist-useragent": "^3.0.3",
30
27
  "cssesc": "^3.0.0",
31
- "debounce": "^1.2.1",
32
28
  "detect-browser": "^5.2.0",
29
+ "devtools-detector": "^2.0.6",
33
30
  "jscrypto": "0.0.1",
31
+ "lodash.clonedeep": "^4.5.0",
34
32
  "mark.js": "^8.11.1",
35
33
  "promise-polyfill": "^8.2.0",
36
34
  "r2-shared-js": "^1.0.51",
35
+ "recursive-readdir": "^2.2.2",
37
36
  "sanitize-html": "^2.3.3",
37
+ "sentence-splitter": "^3.2.1",
38
+ "util": "^0.12.4",
38
39
  "whatwg-fetch": "^3.6.2"
39
40
  },
40
41
  "browserslist": {
@@ -53,26 +54,38 @@
53
54
  "@parcel/transformer-sass": "^2.0.0-beta.2",
54
55
  "@parcel/transformer-typescript-tsc": "^2.0.0-beta.1",
55
56
  "@types/chai": "^4.2.15",
57
+ "@types/copy": "^0.3.1",
56
58
  "@types/cssesc": "^3.0.0",
57
59
  "@types/debounce": "^3.0.0",
60
+ "@types/express": "^4.17.12",
58
61
  "@types/jquery": "^3.5.5",
59
62
  "@types/mark.js": "^8.11.5",
60
63
  "@types/materialize-css": "^1.0.8",
61
64
  "@types/mocha": "^8.2.2",
65
+ "@types/node-sass": "^4.11.1",
62
66
  "@types/pako": "^1.0.1",
63
67
  "@types/parse5": "^6.0.0",
64
68
  "@types/promise-polyfill": "^6.0.3",
65
69
  "@types/react": "^17.0.11",
66
70
  "@types/react-dom": "^17.0.7",
71
+ "@types/rimraf": "^3.0.0",
67
72
  "@types/sanitize-html": "^1.27.1",
68
73
  "@types/uuid": "^8.3.0",
69
74
  "@typescript-eslint/eslint-plugin": "^4.21.0",
70
75
  "@typescript-eslint/parser": "^4.21.0",
76
+ "ansi-regex": ">=5.0.1",
71
77
  "babel-eslint": "^10.1.0",
72
78
  "braces": ">=3.0.2",
73
79
  "browserslist-useragent-regexp": "^3.0.0",
74
80
  "chai": "^4.3.4",
81
+ "chalk": "^4.1.1",
82
+ "chokidar": "^3.5.2",
83
+ "copy": "^0.3.2",
75
84
  "cpx": "^1.2.1",
85
+ "debounce": "^1.2.1",
86
+ "dita-streamer-js": "^1.1.1",
87
+ "ecstatic": ">=4.1.3",
88
+ "esbuild": "^0.12.11",
76
89
  "eslint": "^7.23.0",
77
90
  "eslint-config-prettier": "^8.1.0",
78
91
  "eslint-config-react-app": "^6.0.0",
@@ -83,15 +96,16 @@
83
96
  "eslint-plugin-react": "^7.23.2",
84
97
  "eslint-plugin-react-hooks": "^4.2.0",
85
98
  "express": "^4.17.1",
86
- "http-server": "^0.12.3",
99
+ "glob-parent": ">=5.1.2",
100
+ "json-schema": ">=0.4.0",
87
101
  "materialize-css": "^1.0.0",
88
102
  "minimist": ">=1.2.5",
89
103
  "mocha": "^8.3.2",
90
- "node-sass": "^6.0.0",
104
+ "node-sass": "^6.0.1",
91
105
  "npm-force-resolutions": "0.0.10",
92
106
  "parcel": "^2.0.0-beta.2",
93
107
  "prettier": "^2.2.1",
94
- "process": "0.11.10",
108
+ "process": "^0.11.10",
95
109
  "rangy": "^1.3.0",
96
110
  "react": "^17.0.2",
97
111
  "react-app-polyfill": "^2.0.0",
@@ -100,13 +114,15 @@
100
114
  "rimraf": "^3.0.2",
101
115
  "sinon": "^10.0.0",
102
116
  "ta-json-x": "^2.5.3",
117
+ "tar": ">=6.1.9",
103
118
  "ts-loader": "^8.0.18",
104
- "typescript": "^4.2.3",
105
- "webpack": "^5.27.2",
106
- "webpack-cli": "^4.5.0"
119
+ "ts-node": "^10.4.0",
120
+ "typedoc": "^0.22.5",
121
+ "typedoc-plugin-rename-defaults": "^0.4.0",
122
+ "typescript": "^4.2.3"
107
123
  },
108
124
  "files": [
109
- "dist/*"
125
+ "dist"
110
126
  ],
111
127
  "resolutions": {
112
128
  "braces": "3.0.2"
package/CHANGELOG.md DELETED
@@ -1,6 +0,0 @@
1
- # CHANGELOG
2
-
3
- ## 2.0.0
4
-
5
- - `currentSettings` is now a property, so you don't call it as a function.
6
- - The default export is now a class which you instantiate with `.build`, and then call all API methods on the returned instance
package/NOTICE DELETED
@@ -1,20 +0,0 @@
1
- R2D2BC
2
- Copyright 2018-2020 DITA (AM Consulting LLC)
3
-
4
- This project bundles the following dependencies under the MIT license.
5
- See bundled license files for details.
6
-
7
- - Materialize | Copyright (c) 2014-2018 Materialize
8
- -> in "styles/sass/materialize"
9
-
10
- This project bundles the following dependencies under the SIL Open Font License.
11
- See bundled license files for details.
12
-
13
- - OpenDyxslexic Font | Copyright (c) 12/2012 - 2019
14
- -> in "viewer/fonts/opendyslexic"
15
-
16
- This project bundles the following dependencies under the BSD license.
17
- See bundled license files for details.
18
-
19
- - Readium-CSS | Copyright (c) 2017, Readium
20
- -> in "viewer/readium-css"
package/dist/index.d.ts DELETED
@@ -1,140 +0,0 @@
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 AnnotationModule from "./modules/AnnotationModule";
5
- import BookmarkModule from "./modules/BookmarkModule";
6
- import TextHighlighter from "./modules/highlight/TextHighlighter";
7
- import MediaOverlayModule from "./modules/mediaoverlays/MediaOverlayModule";
8
- import { IMediaOverlayUserSettings, MediaOverlaySettings } from "./modules/mediaoverlays/MediaOverlaySettings";
9
- import TimelineModule from "./modules/positions/TimelineModule";
10
- import ContentProtectionModule from "./modules/protection/ContentProtectionModule";
11
- import SearchModule from "./modules/search/SearchModule";
12
- import TTSModule from "./modules/TTS/TTSModule";
13
- import { ITTSUserSettings, TTSIncrementable, TTSSettings } from "./modules/TTS/TTSSettings";
14
- import IFrameNavigator, { IFrameAttributes, ReaderConfig } from "./navigator/IFrameNavigator";
15
- /**
16
- * A class that, once instantiated using the public `.build` method,
17
- * is the primary interface into the D2 Reader.
18
- *
19
- * @TODO :
20
- * - DEV logger
21
- * - Default config
22
- * - Different types for initial config and final config
23
- * - Testing
24
- */
25
- export default class D2Reader {
26
- readonly settings: UserSettings;
27
- readonly navigator: IFrameNavigator;
28
- readonly highlighter: TextHighlighter;
29
- readonly bookmarkModule?: BookmarkModule;
30
- readonly annotationModule?: AnnotationModule;
31
- readonly ttsSettings?: TTSSettings;
32
- readonly ttsModule?: TTSModule;
33
- readonly searchModule?: SearchModule;
34
- readonly contentProtectionModule?: ContentProtectionModule;
35
- readonly timelineModule?: TimelineModule;
36
- readonly mediaOverlaySettings?: MediaOverlaySettings;
37
- readonly mediaOverlayModule?: MediaOverlayModule;
38
- private constructor();
39
- /**
40
- * The async builder.
41
- */
42
- static build(initialConfig: ReaderConfig): Promise<D2Reader>;
43
- /**
44
- * Read Aloud
45
- */
46
- hasMediaOverlays: () => boolean;
47
- startReadAloud: () => void;
48
- stopReadAloud: () => void;
49
- pauseReadAloud: () => void;
50
- resumeReadAloud: () => void;
51
- /**
52
- * Bookmarks and annotations
53
- */
54
- saveBookmark: () => Promise<any>;
55
- deleteBookmark: (bookmark: Bookmark) => Promise<any>;
56
- deleteAnnotation: (highlight: Annotation) => Promise<any>;
57
- addAnnotation: (highlight: Annotation) => Promise<any>;
58
- tableOfContents: () => Promise<any>;
59
- readingOrder: () => Promise<any>;
60
- bookmarks: () => Promise<any>;
61
- annotations: () => Promise<any>;
62
- /**
63
- * Search
64
- */
65
- search: (term: string, current: boolean) => Promise<any>;
66
- goToSearchIndex: (href: string, index: number, current: boolean) => Promise<void>;
67
- goToSearchID: (href: string, index: number, current: boolean) => Promise<void>;
68
- clearSearch: () => Promise<void>;
69
- /**
70
- * Resources
71
- */
72
- currentResource: () => number;
73
- mostRecentNavigatedTocItem: () => string;
74
- totalResources: () => number;
75
- /**
76
- * Settings
77
- */
78
- get publicationLanguage(): string[];
79
- resetUserSettings: () => Promise<void>;
80
- applyUserSettings: (userSettings: Partial<UserSettings>) => Promise<void>;
81
- get currentSettings(): {
82
- appearance: string;
83
- fontFamily: string;
84
- textAlignment: string;
85
- columnCount: string;
86
- verticalScroll: boolean;
87
- fontSize: number;
88
- wordSpacing: number;
89
- letterSpacing: number;
90
- pageMargins: number;
91
- lineHeight: number;
92
- };
93
- scroll: (value: boolean) => Promise<void>;
94
- private isTTSIncrementable;
95
- /**
96
- * Used to increase anything that can be increased,
97
- * such as pitch, rate, volume, fontSize
98
- */
99
- increase: (incremental: UserSettingsIncrementable | TTSIncrementable) => Promise<void>;
100
- /**
101
- * Used to decrease anything that can be decreased,
102
- * such as pitch, rate, volume, fontSize
103
- */
104
- decrease: (incremental: UserSettingsIncrementable | TTSIncrementable) => Promise<void>;
105
- /**
106
- * TTS Settings
107
- */
108
- resetTTSSettings: () => Promise<void>;
109
- applyTTSSettings: (ttsSettings: ITTSUserSettings) => Promise<void>;
110
- applyTTSSetting: (key: string, value: any) => Promise<void>;
111
- applyPreferredVoice: (value: string) => Promise<void>;
112
- resetMediaOverlaySettings: () => Promise<void>;
113
- applyMediaOverlaySettings: (settings: IMediaOverlayUserSettings) => Promise<void>;
114
- /**
115
- * Navigation
116
- * @TODO : These should return promises that complete when they are done.
117
- */
118
- get currentLocator(): Locator;
119
- get positions(): any;
120
- goTo: (locator: Locator) => void;
121
- goToPosition: (value: number) => void;
122
- nextResource: () => void;
123
- previousResource: () => void;
124
- nextPage: () => void;
125
- previousPage: () => void;
126
- atStart: () => boolean;
127
- atEnd: () => boolean;
128
- snapToElement: (value: HTMLElement) => void;
129
- /**
130
- * You have attributes in the reader when you initialize it. You can set margin, navigationHeight etc...
131
- * This is in case you change the attributes after initializing the reader.
132
- */
133
- applyAttributes: (value: IFrameAttributes) => void;
134
- /**
135
- * Destructor:
136
- * Only used in react applications because when they re-visit the page
137
- * it tried to create a new reader, which interfered with the first one.
138
- */
139
- stop: () => void;
140
- }
@@ -1 +0,0 @@
1
- export declare const IS_DEV: boolean;
@@ -1 +0,0 @@
1
- export declare const IS_DEV: boolean;
@@ -1,2 +0,0 @@
1
- var Footnotes;(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{IS_DEV:()=>o});var n=function(e,t,n,o){return new(n||(n=Promise))((function(r,a){function i(e){try{c(o.next(e))}catch(e){a(e)}}function l(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}c((o=o.apply(e,t||[])).next())}))};const o=!1;document.addEventListener("click",(e=>n(void 0,void 0,void 0,(function*(){o&&console.log("Footnote Click Handler");var t=e.target;if("a"===t.tagName.toLowerCase()){var r=document.createElement("div");r.innerHTML=t.outerHTML;var a=r.querySelector("a");if(a&&"noteref"===a.getAttribute("epub:type")){var i=a.getAttribute("href");if(i.indexOf("#")>0){var l=i.substring(i.indexOf("#")+1),c=function(e){var t=document.location.href;return new URL(e,t).href}(i);c=c.substring(0,c.indexOf("#")),e.preventDefault(),e.stopPropagation(),yield fetch(c).then((e=>e.text())).then((e=>n(void 0,void 0,void 0,(function*(){var n=(new DOMParser).parseFromString(e,"text/html").querySelector("aside#"+l);if(n){var o=document.createElement("div");o.className="modal",o.innerHTML='<div class="modal-content"><span class="close">x</span>'+n.innerHTML+"</div>",o.style.display="block",document.body.appendChild(o);var r=o.getElementsByClassName("modal-content")[0],i=t.offsetTop;t.offsetTop>100&&(i=t.offsetTop-20),r.style.top=i+"px",o.getElementsByClassName("close")[0].onclick=function(){o.style.display="none",o.parentElement.removeChild(o)},window.onclick=function(e){e.target===o&&(o.style.display="none",o.parentElement.removeChild(o))}}else a.click()}))))}}}}))),!0),Footnotes=t})();
2
- //# sourceMappingURL=footnotes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["webpack://Footnotes/webpack/bootstrap","webpack://Footnotes/webpack/runtime/define property getters","webpack://Footnotes/webpack/runtime/hasOwnProperty shorthand","webpack://Footnotes/webpack/runtime/make namespace object","webpack://Footnotes/./injectables/footnotes/footnotes.ts"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","IS_DEV","document","addEventListener","event","console","log","htmlElement","target","tagName","toLowerCase","element","createElement","innerHTML","outerHTML","link","querySelector","getAttribute","href","indexOf","id","substring","absolute","currentUrl","location","URL","getAbsoluteHref","preventDefault","stopPropagation","fetch","then","r","text","data","aside","DOMParser","parseFromString","modal","className","style","display","body","appendChild","modalContent","getElementsByClassName","offset","offsetTop","top","onclick","parentElement","removeChild","window","click"],"mappings":"iCACA,IAAIA,EAAsB,CCA1B,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3E,EAAwB,CAACM,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClF,EAAyBT,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,4UCchD,MAAMC,GAC+B,EAE5CC,SAASC,iBACP,SACOC,GAAU,OAAD,6BACVH,GAAQI,QAAQC,IAAI,0BACxB,IAAIC,EAAcH,EAAMI,OACxB,GAA0C,MAAtCD,EAAYE,QAAQC,cAAuB,CAC7C,IAAIC,EAAUT,SAASU,cAAc,OACrCD,EAAQE,UAAYN,EAAYO,UAEhC,IAAIC,EAAOJ,EAAQK,cAAc,KACjC,GAAID,GACiD,YAAnCA,EAAKE,aAAa,aACnB,CACb,IAAIC,EAAOH,EAAKE,aAAa,QAC7B,GAAIC,EAAKC,QAAQ,KAAO,EAAG,CACzB,IAAIC,EAAKF,EAAKG,UAAUH,EAAKC,QAAQ,KAAO,GACxCG,EAsDZ,SAAyBJ,GACvB,IAAIK,EAAarB,SAASsB,SAASN,KACnC,OAAO,IAAIO,IAAIP,EAAMK,GAAYL,KAxDZQ,CAAgBR,GAC/BI,EAAWA,EAASD,UAAU,EAAGC,EAASH,QAAQ,MAElDf,EAAMuB,iBACNvB,EAAMwB,wBAEAC,MAAMP,GACTQ,MAAMC,GAAMA,EAAEC,SACdF,MAAYG,GAAS,OAAD,6BACnB,IAEIC,GAFS,IAAIC,WACAC,gBAAgBH,EAAM,aACvBjB,cAAc,SAAWI,GACzC,GAAIc,EAAO,CACT,IAAIG,EAAQnC,SAASU,cAAc,OACnCyB,EAAMC,UAAY,QAClBD,EAAMxB,UACJ,0DACAqB,EAAMrB,UACN,SACFwB,EAAME,MAAMC,QAAU,QAEtBtC,SAASuC,KAAKC,YAAYL,GAE1B,IAAIM,EAAeN,EAAMO,uBACvB,iBACA,GACEC,EAAStC,EAAYuC,UACrBvC,EAAYuC,UAAY,MAC1BD,EAAStC,EAAYuC,UAAY,IAEnCH,EAAaJ,MAAMQ,IAAMF,EAAS,KAEvBR,EAAMO,uBACf,SACA,GACGI,QAAU,WACbX,EAAME,MAAMC,QAAU,OACtBH,EAAMY,cAAcC,YAAYb,IAGlCc,OAAOH,QAAU,SAAU5C,GACrBA,EAAMI,SAAW6B,IACnBA,EAAME,MAAMC,QAAU,OACtBH,EAAMY,cAAcC,YAAYb,UAIpCtB,EAAKqC,qBAYrB,G","file":"footnotes.js","sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\n * Copyright 2018-2020 DITA (AM Consulting LLC)\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * Developed on behalf of: DITA\n * Licensed to: Bokbasen AS and CAST under one or more contributor license agreements.\n */\n\nexport const IS_DEV =\n process.env.NODE_ENV === \"development\" || process.env.NODE_ENV === \"dev\";\n\ndocument.addEventListener(\n \"click\",\n async (event) => {\n if (IS_DEV) console.log(\"Footnote Click Handler\");\n var htmlElement = event.target as HTMLElement;\n if (htmlElement.tagName.toLowerCase() === \"a\") {\n var element = document.createElement(\"div\");\n element.innerHTML = htmlElement.outerHTML;\n\n var link = element.querySelector(\"a\");\n if (link) {\n var attribute = link.getAttribute(\"epub:type\") === \"noteref\";\n if (attribute) {\n var href = link.getAttribute(\"href\");\n if (href.indexOf(\"#\") > 0) {\n var id = href.substring(href.indexOf(\"#\") + 1);\n var absolute = getAbsoluteHref(href);\n absolute = absolute.substring(0, absolute.indexOf(\"#\"));\n\n event.preventDefault();\n event.stopPropagation();\n\n await fetch(absolute)\n .then((r) => r.text())\n .then(async (data) => {\n var parser = new DOMParser();\n var doc = parser.parseFromString(data, \"text/html\");\n var aside = doc.querySelector(\"aside#\" + id);\n if (aside) {\n var modal = document.createElement(\"div\");\n modal.className = \"modal\";\n modal.innerHTML =\n '<div class=\"modal-content\"><span class=\"close\">x</span>' +\n aside.innerHTML +\n \"</div>\";\n modal.style.display = \"block\";\n\n document.body.appendChild(modal);\n\n var modalContent = modal.getElementsByClassName(\n \"modal-content\"\n )[0] as HTMLDivElement;\n var offset = htmlElement.offsetTop;\n if (htmlElement.offsetTop > 100) {\n offset = htmlElement.offsetTop - 20;\n }\n modalContent.style.top = offset + \"px\";\n\n var span = modal.getElementsByClassName(\n \"close\"\n )[0] as HTMLSpanElement;\n span.onclick = function () {\n modal.style.display = \"none\";\n modal.parentElement.removeChild(modal);\n };\n\n window.onclick = function (event) {\n if (event.target === modal) {\n modal.style.display = \"none\";\n modal.parentElement.removeChild(modal);\n }\n };\n } else {\n link.click();\n }\n });\n }\n }\n }\n }\n function getAbsoluteHref(href: string): string | null {\n var currentUrl = document.location.href;\n return new URL(href, currentUrl).href;\n }\n },\n true\n);\n"],"sourceRoot":""}
@@ -1,5 +0,0 @@
1
- export declare const IS_DEV: boolean;
2
- export interface GlossaryItem {
3
- word: string;
4
- definition: string;
5
- }