@internetarchive/bookreader 5.0.0-88-alpha.10 → 5.0.0-88

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 (215) hide show
  1. package/BookReader/BookReader.css +3 -3
  2. package/BookReader/BookReader.js +1 -1
  3. package/BookReader/BookReader.js.map +1 -1
  4. package/BookReader/ia-bookreader-bundle.js +87 -108
  5. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  6. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  7. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  8. package/BookReader/plugins/plugin.search.js +1 -1
  9. package/BookReader/plugins/plugin.search.js.map +1 -1
  10. package/BookReader/plugins/plugin.text_selection.js +1 -1
  11. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  12. package/BookReader/plugins/plugin.tts.js +1 -1
  13. package/BookReader/plugins/plugin.tts.js.map +1 -1
  14. package/BookReader/plugins/plugin.url.js +1 -1
  15. package/BookReader/plugins/plugin.url.js.map +1 -1
  16. package/CHANGELOG.md +4 -0
  17. package/babel.config.js +12 -30
  18. package/jsconfig.json +1 -3
  19. package/package.json +14 -16
  20. package/src/BookNavigator/search/search-results.js +1 -1
  21. package/src/BookReader/Mode1UpLit.js +56 -86
  22. package/src/BookReader/Mode2UpLit.js +2 -3
  23. package/src/BookReader/Navbar/Navbar.js +53 -11
  24. package/src/BookReader/options.js +3 -0
  25. package/src/BookReader.js +49 -1
  26. package/src/BookReaderPlugin.js +28 -0
  27. package/src/css/_BRnav.scss +0 -3
  28. package/src/css/_controls.scss +4 -0
  29. package/src/plugins/plugin.archive_analytics.js +84 -78
  30. package/src/plugins/plugin.chapters.js +17 -22
  31. package/src/plugins/plugin.text_selection.js +1 -1
  32. package/src/plugins/tts/plugin.tts.js +2 -2
  33. package/tests/jest/BookReader/Navbar/Navbar.test.js +16 -3
  34. package/tests/jest/plugins/plugin.archive_analytics.test.js +8 -11
  35. package/dist/esm/BookNavigator/assets/bookmark-colors.js +0 -4
  36. package/dist/esm/BookNavigator/assets/button-base.js +0 -4
  37. package/dist/esm/BookNavigator/assets/ia-logo.js +0 -4
  38. package/dist/esm/BookNavigator/assets/icon_checkmark.js +0 -8
  39. package/dist/esm/BookNavigator/assets/icon_close.js +0 -4
  40. package/dist/esm/BookNavigator/book-navigator.js +0 -612
  41. package/dist/esm/BookNavigator/bookmarks/bookmark-button.js +0 -35
  42. package/dist/esm/BookNavigator/bookmarks/bookmark-edit.js +0 -78
  43. package/dist/esm/BookNavigator/bookmarks/bookmarks-list.js +0 -160
  44. package/dist/esm/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -24
  45. package/dist/esm/BookNavigator/bookmarks/bookmarks-provider.js +0 -55
  46. package/dist/esm/BookNavigator/bookmarks/ia-bookmarks.js +0 -521
  47. package/dist/esm/BookNavigator/delete-modal-actions.js +0 -29
  48. package/dist/esm/BookNavigator/downloads/downloads-provider.js +0 -84
  49. package/dist/esm/BookNavigator/downloads/downloads.js +0 -69
  50. package/dist/esm/BookNavigator/search/search-provider.js +0 -238
  51. package/dist/esm/BookNavigator/search/search-results.js +0 -161
  52. package/dist/esm/BookNavigator/sharing.js +0 -26
  53. package/dist/esm/BookNavigator/viewable-files.js +0 -94
  54. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -83
  55. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments.js +0 -131
  56. package/dist/esm/BookReader/BookModel.js +0 -575
  57. package/dist/esm/BookReader/DragScrollable.js +0 -224
  58. package/dist/esm/BookReader/ImageCache.js +0 -122
  59. package/dist/esm/BookReader/Mode1Up.js +0 -114
  60. package/dist/esm/BookReader/Mode1UpLit.js +0 -579
  61. package/dist/esm/BookReader/Mode2Up.js +0 -106
  62. package/dist/esm/BookReader/Mode2UpLit.js +0 -1020
  63. package/dist/esm/BookReader/ModeCoordinateSpace.js +0 -28
  64. package/dist/esm/BookReader/ModeSmoothZoom.js +0 -318
  65. package/dist/esm/BookReader/ModeThumb.js +0 -366
  66. package/dist/esm/BookReader/Navbar/Navbar.js +0 -253
  67. package/dist/esm/BookReader/PageContainer.js +0 -165
  68. package/dist/esm/BookReader/ReduceSet.js +0 -27
  69. package/dist/esm/BookReader/Toolbar/Toolbar.js +0 -242
  70. package/dist/esm/BookReader/events.js +0 -20
  71. package/dist/esm/BookReader/options.js +0 -331
  72. package/dist/esm/BookReader/utils/HTMLDimensionsCacher.js +0 -48
  73. package/dist/esm/BookReader/utils/ScrollClassAdder.js +0 -31
  74. package/dist/esm/BookReader/utils/SelectionObserver.js +0 -42
  75. package/dist/esm/BookReader/utils/classes.js +0 -37
  76. package/dist/esm/BookReader/utils.js +0 -315
  77. package/dist/esm/BookReader.js +0 -1827
  78. package/dist/esm/assets/icons/1up.svg +0 -12
  79. package/dist/esm/assets/icons/2up.svg +0 -15
  80. package/dist/esm/assets/icons/advance.svg +0 -26
  81. package/dist/esm/assets/icons/chevron-right.svg +0 -1
  82. package/dist/esm/assets/icons/close-circle-dark.svg +0 -1
  83. package/dist/esm/assets/icons/close-circle.svg +0 -1
  84. package/dist/esm/assets/icons/fullscreen.svg +0 -17
  85. package/dist/esm/assets/icons/fullscreen_exit.svg +0 -17
  86. package/dist/esm/assets/icons/hamburger.svg +0 -15
  87. package/dist/esm/assets/icons/left-arrow.svg +0 -12
  88. package/dist/esm/assets/icons/magnify-minus.svg +0 -12
  89. package/dist/esm/assets/icons/magnify-plus.svg +0 -13
  90. package/dist/esm/assets/icons/magnify.svg +0 -15
  91. package/dist/esm/assets/icons/pause.svg +0 -23
  92. package/dist/esm/assets/icons/play.svg +0 -22
  93. package/dist/esm/assets/icons/playback-speed.svg +0 -34
  94. package/dist/esm/assets/icons/read-aloud.svg +0 -22
  95. package/dist/esm/assets/icons/review.svg +0 -22
  96. package/dist/esm/assets/icons/thumbnails.svg +0 -17
  97. package/dist/esm/assets/icons/voice.svg +0 -1
  98. package/dist/esm/assets/icons/volume-full.svg +0 -22
  99. package/dist/esm/assets/images/BRicons.png +0 -0
  100. package/dist/esm/assets/images/BRicons.svg +0 -94
  101. package/dist/esm/assets/images/BRicons_ia.png +0 -0
  102. package/dist/esm/assets/images/back_pages.png +0 -0
  103. package/dist/esm/assets/images/book_bottom_icon.png +0 -0
  104. package/dist/esm/assets/images/book_down_icon.png +0 -0
  105. package/dist/esm/assets/images/book_left_icon.png +0 -0
  106. package/dist/esm/assets/images/book_leftmost_icon.png +0 -0
  107. package/dist/esm/assets/images/book_right_icon.png +0 -0
  108. package/dist/esm/assets/images/book_rightmost_icon.png +0 -0
  109. package/dist/esm/assets/images/book_top_icon.png +0 -0
  110. package/dist/esm/assets/images/book_up_icon.png +0 -0
  111. package/dist/esm/assets/images/books_graphic.svg +0 -177
  112. package/dist/esm/assets/images/booksplit.png +0 -0
  113. package/dist/esm/assets/images/control_pause_icon.png +0 -0
  114. package/dist/esm/assets/images/control_play_icon.png +0 -0
  115. package/dist/esm/assets/images/embed_icon.png +0 -0
  116. package/dist/esm/assets/images/icon-home-ia.png +0 -0
  117. package/dist/esm/assets/images/icon_OL-logo-xs.png +0 -0
  118. package/dist/esm/assets/images/icon_alert-xs.png +0 -0
  119. package/dist/esm/assets/images/icon_book.svg +0 -12
  120. package/dist/esm/assets/images/icon_bookmark.svg +0 -12
  121. package/dist/esm/assets/images/icon_close-pop.png +0 -0
  122. package/dist/esm/assets/images/icon_download.png +0 -0
  123. package/dist/esm/assets/images/icon_gear.svg +0 -14
  124. package/dist/esm/assets/images/icon_hamburger.svg +0 -20
  125. package/dist/esm/assets/images/icon_home.png +0 -0
  126. package/dist/esm/assets/images/icon_home.svg +0 -21
  127. package/dist/esm/assets/images/icon_home_ia.png +0 -0
  128. package/dist/esm/assets/images/icon_indicator.png +0 -0
  129. package/dist/esm/assets/images/icon_info.svg +0 -11
  130. package/dist/esm/assets/images/icon_one_page.svg +0 -8
  131. package/dist/esm/assets/images/icon_pause.svg +0 -1
  132. package/dist/esm/assets/images/icon_play.svg +0 -1
  133. package/dist/esm/assets/images/icon_playback-rate.svg +0 -15
  134. package/dist/esm/assets/images/icon_return.png +0 -0
  135. package/dist/esm/assets/images/icon_search_button.svg +0 -8
  136. package/dist/esm/assets/images/icon_share.svg +0 -9
  137. package/dist/esm/assets/images/icon_skip-ahead.svg +0 -6
  138. package/dist/esm/assets/images/icon_skip-back.svg +0 -13
  139. package/dist/esm/assets/images/icon_speaker.svg +0 -18
  140. package/dist/esm/assets/images/icon_speaker_open.svg +0 -10
  141. package/dist/esm/assets/images/icon_thumbnails.svg +0 -12
  142. package/dist/esm/assets/images/icon_toc.svg +0 -5
  143. package/dist/esm/assets/images/icon_two_pages.svg +0 -9
  144. package/dist/esm/assets/images/icon_zoomer.png +0 -0
  145. package/dist/esm/assets/images/loading.gif +0 -0
  146. package/dist/esm/assets/images/logo_icon.png +0 -0
  147. package/dist/esm/assets/images/marker_chap-off.png +0 -0
  148. package/dist/esm/assets/images/marker_chap-off.svg +0 -11
  149. package/dist/esm/assets/images/marker_chap-off_ia.png +0 -0
  150. package/dist/esm/assets/images/marker_chap-on.png +0 -0
  151. package/dist/esm/assets/images/marker_chap-on.svg +0 -11
  152. package/dist/esm/assets/images/marker_srch-on.svg +0 -11
  153. package/dist/esm/assets/images/marker_srchchap-off.png +0 -0
  154. package/dist/esm/assets/images/marker_srchchap-on.png +0 -0
  155. package/dist/esm/assets/images/nav_control-dn.png +0 -0
  156. package/dist/esm/assets/images/nav_control-dn_ia.png +0 -0
  157. package/dist/esm/assets/images/nav_control-up.png +0 -0
  158. package/dist/esm/assets/images/nav_control-up_ia.png +0 -0
  159. package/dist/esm/assets/images/nav_control.png +0 -0
  160. package/dist/esm/assets/images/one_page_mode_icon.png +0 -0
  161. package/dist/esm/assets/images/paper-badge.png +0 -0
  162. package/dist/esm/assets/images/print_icon.png +0 -0
  163. package/dist/esm/assets/images/progressbar.gif +0 -0
  164. package/dist/esm/assets/images/right_edges.png +0 -0
  165. package/dist/esm/assets/images/slider.png +0 -0
  166. package/dist/esm/assets/images/slider_ia.png +0 -0
  167. package/dist/esm/assets/images/thumbnail_mode_icon.png +0 -0
  168. package/dist/esm/assets/images/transparent.png +0 -0
  169. package/dist/esm/assets/images/two_page_mode_icon.png +0 -0
  170. package/dist/esm/assets/images/unviewable_page.png +0 -0
  171. package/dist/esm/assets/images/zoom_in_icon.png +0 -0
  172. package/dist/esm/assets/images/zoom_out_icon.png +0 -0
  173. package/dist/esm/css/BookReader.scss +0 -85
  174. package/dist/esm/css/_BRBookmarks.scss +0 -29
  175. package/dist/esm/css/_BRComponent.scss +0 -13
  176. package/dist/esm/css/_BRfloat.scss +0 -197
  177. package/dist/esm/css/_BRicon.scss +0 -54
  178. package/dist/esm/css/_BRmain.scss +0 -262
  179. package/dist/esm/css/_BRnav.scss +0 -354
  180. package/dist/esm/css/_BRpages.scss +0 -213
  181. package/dist/esm/css/_BRsearch.scss +0 -268
  182. package/dist/esm/css/_BRtoolbar.scss +0 -84
  183. package/dist/esm/css/_BRvendor.scss +0 -5
  184. package/dist/esm/css/_TextSelection.scss +0 -108
  185. package/dist/esm/css/_colorbox.scss +0 -52
  186. package/dist/esm/css/_controls.scss +0 -257
  187. package/dist/esm/css/_icons.scss +0 -121
  188. package/dist/esm/ia-bookreader/ia-bookreader.js +0 -141
  189. package/dist/esm/jquery-wrapper.js +0 -3
  190. package/dist/esm/plugins/plugin.archive_analytics.js +0 -72
  191. package/dist/esm/plugins/plugin.autoplay.js +0 -119
  192. package/dist/esm/plugins/plugin.chapters.js +0 -288
  193. package/dist/esm/plugins/plugin.iframe.js +0 -44
  194. package/dist/esm/plugins/plugin.iiif.js +0 -146
  195. package/dist/esm/plugins/plugin.resume.js +0 -66
  196. package/dist/esm/plugins/plugin.text_selection.js +0 -621
  197. package/dist/esm/plugins/plugin.vendor-fullscreen.js +0 -227
  198. package/dist/esm/plugins/search/plugin.search.js +0 -499
  199. package/dist/esm/plugins/search/utils.js +0 -42
  200. package/dist/esm/plugins/search/view.js +0 -360
  201. package/dist/esm/plugins/tts/AbstractTTSEngine.js +0 -282
  202. package/dist/esm/plugins/tts/FestivalTTSEngine.js +0 -192
  203. package/dist/esm/plugins/tts/PageChunk.js +0 -105
  204. package/dist/esm/plugins/tts/PageChunkIterator.js +0 -155
  205. package/dist/esm/plugins/tts/WebTTSEngine.js +0 -364
  206. package/dist/esm/plugins/tts/plugin.tts.js +0 -315
  207. package/dist/esm/plugins/tts/tooltip_dict.js +0 -14
  208. package/dist/esm/plugins/tts/utils.js +0 -79
  209. package/dist/esm/plugins/url/UrlPlugin.js +0 -197
  210. package/dist/esm/plugins/url/plugin.url.js +0 -212
  211. package/dist/esm/util/browserSniffing.js +0 -56
  212. package/dist/esm/util/debouncer.js +0 -25
  213. package/dist/esm/util/docCookies.js +0 -75
  214. package/dist/esm/util/strings.js +0 -34
  215. package/index.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-88-alpha.10",
3
+ "version": "5.0.0-88",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "module": "dist/esm/ia-bookreader/ia-bookreader.js",
12
+ "module": "src/ia-bookreader/ia-bookreader.js",
13
13
  "keywords": [
14
14
  "online",
15
15
  "bookreader",
@@ -25,8 +25,8 @@
25
25
  "homepage": "https://github.com/internetarchive/bookreader#readme",
26
26
  "private": false,
27
27
  "dependencies": {
28
- "@internetarchive/ia-activity-indicator": "^0.0.6",
29
- "@internetarchive/ia-item-navigator": "^2.1.3-alpha.1",
28
+ "@internetarchive/ia-activity-indicator": "^0.0.4",
29
+ "@internetarchive/ia-item-navigator": "^2.1.2",
30
30
  "@internetarchive/icon-bookmark": "^1.3.4",
31
31
  "@internetarchive/icon-dl": "^1.3.4",
32
32
  "@internetarchive/icon-edit-pencil": "^1.3.4",
@@ -35,20 +35,11 @@
35
35
  "@internetarchive/icon-search": "^1.3.4",
36
36
  "@internetarchive/icon-toc": "^1.3.4",
37
37
  "@internetarchive/icon-visual-adjustment": "^1.3.4",
38
- "@internetarchive/modal-manager": "^2.0.1",
38
+ "@internetarchive/modal-manager": "^0.2.12",
39
39
  "@internetarchive/shared-resize-observer": "^0.2.0",
40
- "interactjs": "^1.10.18",
41
- "iso-language-codes": "1.1.0",
42
- "jquery": "3.6.1",
43
- "jquery-colorbox": "1.6.4",
44
- "jquery-ui": "^1.12.1",
45
- "jquery-ui-touch-punch": "0.2.3",
46
- "jquery.browser": "0.1.0",
47
- "lit": "^2.8.0",
48
- "soundmanager2": "2.97.20170602"
40
+ "lit": "^2.5.0"
49
41
  },
50
42
  "devDependencies": {
51
- "@babel/cli": "^7.26.4",
52
43
  "@babel/core": "7.25.8",
53
44
  "@babel/eslint-parser": "7.25.7",
54
45
  "@babel/plugin-proposal-class-properties": "7.18.6",
@@ -67,12 +58,20 @@
67
58
  "eslint-plugin-no-jquery": "^2.7.0",
68
59
  "eslint-plugin-testcafe": "^0.2.1",
69
60
  "http-server": "14.1.1",
61
+ "interactjs": "^1.10.18",
62
+ "iso-language-codes": "1.1.0",
70
63
  "jest": "29.7.0",
71
64
  "jest-environment-jsdom": "^29.7.0",
65
+ "jquery": "3.6.1",
66
+ "jquery-colorbox": "1.6.4",
67
+ "jquery-ui": "1.12.1",
68
+ "jquery-ui-touch-punch": "0.2.3",
69
+ "jquery.browser": "0.1.0",
72
70
  "live-server": "1.2.2",
73
71
  "regenerator-runtime": "0.14.1",
74
72
  "sass": "1.79.5",
75
73
  "sinon": "19.0.2",
74
+ "soundmanager2": "2.97.20170602",
76
75
  "svgo": "3.3.2",
77
76
  "testcafe": "3.6.2",
78
77
  "testcafe-browser-provider-browserstack": "^1.13.2-alpha.1",
@@ -104,7 +103,6 @@
104
103
  "build-assets": "npx cpx \"src/assets/**/*\" BookReader && npx svgo -f BookReader/icons && npx svgo -f BookReader/images",
105
104
  "build-assets:watch": "npx cpx --watch --verbose \"src/assets/**/*\" BookReader",
106
105
  "build-js": "npx webpack",
107
- "build-esm": "env BABEL_ENV=esm npx babel src --out-dir dist/esm --copy-files --extensions \".js\"",
108
106
  "build-js:watch": "npx webpack --mode=development --watch",
109
107
  "build-css": "npx sass --no-source-map ./src/css/BookReader.scss ./BookReader/BookReader.css",
110
108
  "build-css:watch": "npx sass --watch --no-source-map ./src/css/BookReader.scss ./BookReader/BookReader.css",
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable class-methods-use-this */
2
2
  import { unsafeHTML } from 'lit/directives/unsafe-html.js';
3
3
  import { css, html, LitElement, nothing } from 'lit';
4
- import '@internetarchive/ia-activity-indicator';
4
+ import '@internetarchive/ia-activity-indicator/ia-activity-indicator';
5
5
  import checkmarkIcon from '../assets/icon_checkmark.js';
6
6
  import closeIcon from '../assets/icon_close.js';
7
7
  import buttonCSS from '../assets/button-base.js';
@@ -1,10 +1,10 @@
1
1
  // @ts-check
2
- import { property, query } from 'lit/decorators.js';
3
- import { LitElement, html } from 'lit';
2
+ import { customElement, property, query } from 'lit/decorators.js';
3
+ import {LitElement, html} from 'lit';
4
4
  import { styleMap } from 'lit/directives/style-map.js';
5
5
  import { ModeSmoothZoom } from './ModeSmoothZoom';
6
6
  import { arrChanged, genToArray, sum, throttle } from './utils';
7
- import { HTMLDimensionsCacher } from './utils/HTMLDimensionsCacher';
7
+ import { HTMLDimensionsCacher } from "./utils/HTMLDimensionsCacher";
8
8
  import { ScrollClassAdder } from './utils/ScrollClassAdder';
9
9
  import { ModeCoordinateSpace } from './ModeCoordinateSpace';
10
10
  /** @typedef {import('./BookModel').BookModel} BookModel */
@@ -17,6 +17,7 @@ import { ModeCoordinateSpace } from './ModeCoordinateSpace';
17
17
  // I _have_ to make this globally public, otherwise it won't let me call
18
18
  // it's constructor :/
19
19
  /** @implements {SmoothZoomable} */
20
+ @customElement('br-mode-1up')
20
21
  export class Mode1UpLit extends LitElement {
21
22
  /****************************************/
22
23
  /************** PROPERTIES **************/
@@ -85,15 +86,13 @@ export class Mode1UpLit extends LitElement {
85
86
  get worldStyle() {
86
87
  const wToR = this.coordSpace.worldUnitsToRenderedPixels;
87
88
  return {
88
- width: wToR(this.worldDimensions.width) + 'px',
89
- height: wToR(this.worldDimensions.height) + 'px',
89
+ width: wToR(this.worldDimensions.width) + "px",
90
+ height: wToR(this.worldDimensions.height) + "px",
90
91
  };
91
92
  }
92
93
 
93
94
  /** @type {HTMLElement} */
94
- get $container() {
95
- return this;
96
- }
95
+ get $container() { return this; }
97
96
 
98
97
  /** @type {HTMLElement} */
99
98
  @query('.br-mode-1up__visible-world')
@@ -129,12 +128,10 @@ export class Mode1UpLit extends LitElement {
129
128
  if (smooth) {
130
129
  this.style.scrollBehavior = 'smooth';
131
130
  }
132
- this.scrollTop = this.coordSpace.worldUnitsToVisiblePixels(
133
- this.pageTops[index] - this.SPACING_IN / 2,
134
- );
131
+ this.scrollTop = this.coordSpace.worldUnitsToVisiblePixels(this.pageTops[index] - this.SPACING_IN / 2);
135
132
  // TODO: Also h center?
136
133
  if (smooth) {
137
- setTimeout(() => (this.style.scrollBehavior = ''), 100);
134
+ setTimeout(() => this.style.scrollBehavior = '', 100);
138
135
  }
139
136
  }
140
137
 
@@ -197,7 +194,7 @@ export class Mode1UpLit extends LitElement {
197
194
  this.throttledUpdateRenderedPages();
198
195
  if (this.visiblePages.length) {
199
196
  // unclear why this is ever really happening
200
- this.br.displayedIndices = this.visiblePages.map((p) => p.index);
197
+ this.br.displayedIndices = this.visiblePages.map(p => p.index);
201
198
  this.br.updateFirstIndex(this.br.displayedIndices[0]);
202
199
  this.br._components.navbar.updateNavIndexThrottled();
203
200
  }
@@ -214,9 +211,7 @@ export class Mode1UpLit extends LitElement {
214
211
  }
215
212
 
216
213
  updatePages() {
217
- this.pages = genToArray(
218
- this.book.pagesIterator({ combineConsecutiveUnviewables: true }),
219
- );
214
+ this.pages = genToArray(this.book.pagesIterator({ combineConsecutiveUnviewables: true }));
220
215
  }
221
216
 
222
217
  /** @override */
@@ -247,59 +242,50 @@ export class Mode1UpLit extends LitElement {
247
242
 
248
243
  /** @override */
249
244
  render() {
250
- return html` <div
251
- class="br-mode-1up__world"
252
- style=${styleMap(this.worldStyle)}
253
- ></div>
245
+ return html`
246
+ <div class="br-mode-1up__world" style=${styleMap(this.worldStyle)}></div>
254
247
  <div class="br-mode-1up__visible-world">
255
- ${this.renderedPages.map((p) => this.renderPage(p))}
248
+ ${this.renderedPages.map(p => this.renderPage(p))}
256
249
  </div>`;
257
250
  }
258
251
 
259
252
  /** @param {PageModel} page */
260
253
  createPageContainer = (page) => {
261
- return (
262
- this.pageContainerCache[page.index] ||
263
- (this.pageContainerCache[page.index] =
254
+ return this.pageContainerCache[page.index] || (
255
+ this.pageContainerCache[page.index] = (
264
256
  // @ts-ignore I know it's protected, TS! But Mode1Up and BookReader are friends.
265
- this.br._createPageContainer(page.index))
257
+ this.br._createPageContainer(page.index)
258
+ )
266
259
  );
267
- };
260
+ }
268
261
 
269
262
  /** @param {PageModel} page */
270
263
  renderPage = (page) => {
271
264
  const wToR = this.coordSpace.worldUnitsToRenderedPixels;
272
265
  const wToV = this.coordSpace.worldUnitsToVisiblePixels;
273
- const containerWidth = this.coordSpace.visiblePixelsToWorldUnits(
274
- this.htmlDimensionsCacher.clientWidth,
275
- );
266
+ const containerWidth = this.coordSpace.visiblePixelsToWorldUnits(this.htmlDimensionsCacher.clientWidth);
276
267
 
277
268
  const width = wToR(page.widthInches);
278
269
  const height = wToR(page.heightInches);
279
- const left = Math.max(
280
- this.SPACING_IN,
281
- (containerWidth - page.widthInches) / 2,
282
- );
270
+ const left = Math.max(this.SPACING_IN, (containerWidth - page.widthInches) / 2);
283
271
  const top = this.pageTops[page.index];
284
272
 
285
273
  const transform = `translate(${wToR(left)}px, ${wToR(top)}px)`;
286
- const pageContainerEl = this.createPageContainer(page).update({
287
- dimensions: {
288
- width,
289
- height,
290
- top: 0,
291
- left: 0,
292
- },
293
- reduce: page.width / wToV(page.widthInches),
294
- }).$container[0];
274
+ const pageContainerEl = this.createPageContainer(page)
275
+ .update({
276
+ dimensions: {
277
+ width,
278
+ height,
279
+ top: 0,
280
+ left: 0,
281
+ },
282
+ reduce: page.width / wToV(page.widthInches),
283
+ }).$container[0];
295
284
 
296
285
  pageContainerEl.style.transform = transform;
297
- pageContainerEl.classList.toggle(
298
- 'BRpage-visible',
299
- this.visiblePages.includes(page),
300
- );
286
+ pageContainerEl.classList.toggle('BRpage-visible', this.visiblePages.includes(page));
301
287
  return pageContainerEl;
302
- };
288
+ }
303
289
 
304
290
  /************** VIRTUAL SCROLLING LOGIC **************/
305
291
 
@@ -320,7 +306,7 @@ export class Mode1UpLit extends LitElement {
320
306
  left: vToW(scrollLeft),
321
307
  width: vToW(clientWidth),
322
308
  };
323
- };
309
+ }
324
310
 
325
311
  /**
326
312
  * @returns {PageModel[]}
@@ -328,26 +314,20 @@ export class Mode1UpLit extends LitElement {
328
314
  computeRenderedPages() {
329
315
  // Also render 1 page before/after
330
316
  // @ts-ignore TS doesn't understand the filtering out of null values
331
- return (
332
- [
333
- this.visiblePages[0]?.prev,
334
- ...this.visiblePages,
335
- this.visiblePages[this.visiblePages.length - 1]?.next,
336
- ]
337
- .filter((p) => p)
338
- // Never render more than 10 pages! Usually means something is wrong
339
- .slice(0, 10)
340
- );
317
+ return [
318
+ this.visiblePages[0]?.prev,
319
+ ...this.visiblePages,
320
+ this.visiblePages[this.visiblePages.length - 1]?.next,
321
+ ]
322
+ .filter(p => p)
323
+ // Never render more than 10 pages! Usually means something is wrong
324
+ .slice(0, 10);
341
325
  }
342
326
 
343
- throttledUpdateRenderedPages = throttle(
344
- () => {
345
- this.renderedPages = this.computeRenderedPages();
346
- this.requestUpdate();
347
- },
348
- 100,
349
- null,
350
- );
327
+ throttledUpdateRenderedPages = throttle(() => {
328
+ this.renderedPages = this.computeRenderedPages();
329
+ this.requestUpdate();
330
+ }, 100, null)
351
331
 
352
332
  /**
353
333
  * @param {PageModel[]} pages
@@ -370,29 +350,21 @@ export class Mode1UpLit extends LitElement {
370
350
  */
371
351
  computeDefaultScale(page) {
372
352
  // Default to real size if it fits, otherwise default to full width
373
- const containerWidthIn = this.coordSpace.renderedPixelsToWorldUnits(
374
- this.clientWidth,
375
- );
376
- return (
377
- Math.min(
378
- 1,
379
- containerWidthIn / (page.widthInches + 2 * this.SPACING_IN),
380
- ) || 1
381
- );
353
+ const containerWidthIn = this.coordSpace.renderedPixelsToWorldUnits(this.clientWidth);
354
+ return Math.min(1, containerWidthIn / (page.widthInches + 2 * this.SPACING_IN)) || 1;
382
355
  }
383
356
 
384
357
  computeWorldDimensions() {
385
358
  return {
386
- width:
387
- Math.max(...this.pages.map((p) => p.widthInches)) + 2 * this.SPACING_IN,
359
+ width: Math.max(...this.pages.map(p => p.widthInches)) + 2 * this.SPACING_IN,
388
360
  height:
389
- sum(this.pages.map((p) => p.heightInches)) +
390
- (this.pages.length + 1) * this.SPACING_IN,
361
+ sum(this.pages.map(p => p.heightInches)) +
362
+ (this.pages.length + 1) * this.SPACING_IN,
391
363
  };
392
364
  }
393
365
 
394
366
  computeVisiblePages() {
395
- return this.pages.filter((page) => {
367
+ return this.pages.filter(page => {
396
368
  const PT = this.pageTops[page.index];
397
369
  const PB = PT + page.heightInches;
398
370
 
@@ -405,14 +377,12 @@ export class Mode1UpLit extends LitElement {
405
377
  /************** INPUT HANDLERS **************/
406
378
 
407
379
  attachScrollListeners = () => {
408
- this.addEventListener('scroll', this.updateVisibleRegion);
380
+ this.addEventListener("scroll", this.updateVisibleRegion);
409
381
  this.scrollClassAdder.attach();
410
- };
382
+ }
411
383
 
412
384
  detachScrollListeners = () => {
413
- this.removeEventListener('scroll', this.updateVisibleRegion);
385
+ this.removeEventListener("scroll", this.updateVisibleRegion);
414
386
  this.scrollClassAdder.detach();
415
- };
387
+ }
416
388
  }
417
-
418
- customElements.define('br-mode-1up', Mode1UpLit);
@@ -16,6 +16,7 @@ import { ModeCoordinateSpace } from './ModeCoordinateSpace';
16
16
  // I _have_ to make this globally public, otherwise it won't let me call
17
17
  // its constructor :/
18
18
  /** @implements {SmoothZoomable} */
19
+ @customElement('br-mode-2up')
19
20
  export class Mode2UpLit extends LitElement {
20
21
  /****************************************/
21
22
  /************** PROPERTIES **************/
@@ -675,6 +676,7 @@ export class Mode2UpLit extends LitElement {
675
676
  }
676
677
  }
677
678
 
679
+ @customElement('br-leaf-edges')
678
680
  export class LeafEdges extends LitElement {
679
681
  @property({ type: Number }) leftIndex = 0;
680
682
  @property({ type: Number }) rightIndex = 0;
@@ -772,6 +774,3 @@ export class LeafEdges extends LitElement {
772
774
  return Math.floor(this.leftIndex + (e.offsetX / this.offsetWidth) * (this.rightIndex - this.leftIndex + 1));
773
775
  }
774
776
  }
775
-
776
- customElements.define('br-mode-2up', Mode2UpLit);
777
- customElements.define('br-leaf-edges', LeafEdges);
@@ -138,16 +138,43 @@ export class Navbar {
138
138
  * Switch navbar controls on mobile and desktop
139
139
  */
140
140
  switchNavbarControls() {
141
- // we don't want navbar controls switching with liner-notes
142
- if (this.br.options.bookType !== 'linerNotes') {
143
- if (this.br.refs.$brContainer.prop('clientWidth') < 640) {
141
+ if (this.br.refs.$brContainer.prop('clientWidth') < 640) {
142
+ this.showMinimumNavPageNum();
143
+ // we don't want navbar controls switching with liner-notes
144
+ if (this.br.options.bookType !== 'linerNotes') {
144
145
  this.showMinimumNavbarControls();
145
- } else {
146
+ }
147
+ } else {
148
+ this.showMaximumNavPageNum();
149
+ // we don't want navbar controls switching with liner-notes
150
+ if (this.br.options.bookType !== 'linerNotes') {
146
151
  this.showMaximumNavbarControls();
147
152
  }
148
153
  }
149
154
  }
150
155
 
156
+ /**
157
+ * Switch Book Nav page number display to minimum/mobile
158
+ */
159
+ showMinimumNavPageNum() {
160
+ const minElement = document.querySelector('.BRcurrentpage.BRmin');
161
+ const maxElement = document.querySelector('.BRcurrentpage.BRmax');
162
+
163
+ if (minElement) minElement.classList.remove('hide');
164
+ if (maxElement) maxElement.classList.add('hide');
165
+ }
166
+
167
+ /**
168
+ * Switch Book Nav page number display to maximum/desktop
169
+ */
170
+ showMaximumNavPageNum() {
171
+ const minElement = document.querySelector('.BRcurrentpage.BRmin');
172
+ const maxElement = document.querySelector('.BRcurrentpage.BRmax');
173
+
174
+ if (minElement) minElement.classList.add('hide');
175
+ if (maxElement) maxElement.classList.remove('hide');
176
+ }
177
+
151
178
  /**
152
179
  * Switch Book Navbar controls to minimised
153
180
  * NOTE: only `this.minimumControls` and `this.maximumControls` switch on resize
@@ -203,7 +230,10 @@ export class Navbar {
203
230
  <div class="BRpager"></div>
204
231
  <div class="BRnavline"></div>
205
232
  </div>
206
- <p><span class='BRcurrentpage'></span></p>
233
+ <p>
234
+ <span class="BRcurrentpage BRmax"></span>
235
+ <span class="BRcurrentpage BRmin"></span>
236
+ </p>
207
237
  </li>
208
238
  ${this._renderControls()}
209
239
  </ul>
@@ -246,9 +276,10 @@ export class Navbar {
246
276
  /**
247
277
  * Returns the textual representation of the current page for the navbar
248
278
  * @param {number} index
279
+ * @param {boolean} [useMaxFormat = false]
249
280
  * @return {string}
250
281
  */
251
- getNavPageNumString(index) {
282
+ getNavPageNumString(index, useMaxFormat = false) {
252
283
  const { br } = this;
253
284
  // Accessible index starts at 0 (alas) so we add 1 to make human
254
285
  const pageNum = br.book.getPageNum(index);
@@ -268,7 +299,8 @@ export class Navbar {
268
299
  this.maxPageNum = maxPageNum;
269
300
  }
270
301
 
271
- return getNavPageNumHtml(index, numLeafs, pageNum, pageType, this.maxPageNum);
302
+ return getNavPageNumHtml(index, numLeafs, pageNum, pageType, this.maxPageNum, useMaxFormat);
303
+
272
304
  }
273
305
 
274
306
  /**
@@ -276,7 +308,8 @@ export class Navbar {
276
308
  * @param {number} index
277
309
  */
278
310
  updateNavPageNum(index) {
279
- this.$root.find('.BRcurrentpage').html(this.getNavPageNumString(index));
311
+ this.$root.find('.BRcurrentpage.BRmax').html(this.getNavPageNumString(index, true));
312
+ this.$root.find('.BRcurrentpage.BRmin').html(this.getNavPageNumString(index));
280
313
  }
281
314
 
282
315
  /**
@@ -298,14 +331,23 @@ export class Navbar {
298
331
  * @param {number|string} pageNum
299
332
  * @param {*} pageType - Deprecated
300
333
  * @param {number} maxPageNum
334
+ * @param {boolean} [useMaxFormat = false]
301
335
  * @return {string}
302
336
  */
303
- export function getNavPageNumHtml(index, numLeafs, pageNum, pageType, maxPageNum) {
337
+ export function getNavPageNumHtml(index, numLeafs, pageNum, pageType, maxPageNum, useMaxFormat = false) {
304
338
  const pageIsAsserted = pageNum[0] != 'n';
339
+ const pageIndex = index + 1;
340
+
341
+ if (!pageIsAsserted) {
342
+ pageNum = '—';
343
+ }
344
+
345
+ if (useMaxFormat === true) {
346
+ return `Page ${pageNum} (${pageIndex}/${numLeafs})`;
347
+ }
305
348
 
306
349
  if (!pageIsAsserted) {
307
- const pageIndex = index + 1;
308
- return `(${pageIndex} of ${numLeafs})`; // Page (8 of 10)
350
+ return `(${pageIndex} of ${numLeafs})`;
309
351
  }
310
352
 
311
353
  const bookLengthLabel = (maxPageNum && parseFloat(pageNum)) ? ` of ${maxPageNum}` : '';
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  /** @typedef {import('./BookModel.js').PageNumString} PageNumString */
2
3
  /** @typedef {import('./BookModel.js').LeafNum} LeafNum */
3
4
 
@@ -140,6 +141,8 @@ export const DEFAULT_OPTIONS = {
140
141
  * but going forward we'll keep them here.
141
142
  **/
142
143
  plugins: {
144
+ /** @type {import('../plugins/plugin.archive_analytics.js').ArchiveAnalyticsPlugin['options']}*/
145
+ archiveAnalytics: null,
143
146
  /** @type {import('../plugins/plugin.text_selection.js').TextSelectionPluginOptions} */
144
147
  textSelection: null,
145
148
  },
package/src/BookReader.js CHANGED
@@ -23,7 +23,6 @@ This file is part of BookReader.
23
23
  import 'jquery-ui/ui/widget.js';
24
24
  import 'jquery-ui/ui/widgets/mouse.js';
25
25
  import 'jquery-ui-touch-punch';
26
- import jQuery from 'jquery';
27
26
 
28
27
  import PACKAGE_JSON from '../package.json';
29
28
  import * as utils from './BookReader/utils.js';
@@ -63,6 +62,25 @@ BookReader.constMode1up = 1;
63
62
  BookReader.constMode2up = 2;
64
63
  /** thumbnails view */
65
64
  BookReader.constModeThumb = 3;
65
+
66
+ // Although this can actualy have any BookReaderPlugin subclass as value, we
67
+ // hardcode the known plugins here for type checking
68
+ BookReader.PLUGINS = {
69
+ /** @type {typeof import('./plugins/plugin.archive_analytics.js').ArchiveAnalyticsPlugin | null}*/
70
+ archiveAnalytics: null,
71
+ };
72
+
73
+ /**
74
+ * @param {string} pluginName
75
+ * @param {typeof import('./BookReaderPlugin.js').BookReaderPlugin} plugin
76
+ */
77
+ BookReader.registerPlugin = function(pluginName, plugin) {
78
+ if (BookReader.PLUGINS[pluginName]) {
79
+ console.warn(`Plugin ${pluginName} already registered. Overwriting.`);
80
+ }
81
+ BookReader.PLUGINS[pluginName] = plugin;
82
+ };
83
+
66
84
  /** image cache */
67
85
  BookReader.imageCache = null;
68
86
 
@@ -238,6 +256,26 @@ BookReader.prototype.setup = function(options) {
238
256
  '_modes.modeThumb': this._modes.modeThumb,
239
257
  };
240
258
 
259
+ // Construct the usual suspects first to get type hints
260
+ this._plugins = {
261
+ archiveAnalytics: BookReader.PLUGINS.archiveAnalytics ? new BookReader.PLUGINS.archiveAnalytics(this) : null,
262
+ };
263
+
264
+ // Now construct the rest of the plugins
265
+ for (const [pluginName, PluginClass] of Object.entries(BookReader.PLUGINS)) {
266
+ if (this._plugins[pluginName] || !PluginClass) continue;
267
+ this._plugins[pluginName] = new PluginClass(this);
268
+ }
269
+
270
+ // And call setup on them
271
+ for (const [pluginName, plugin] of Object.entries(this._plugins)) {
272
+ try {
273
+ plugin.setup(this.options.plugins?.[pluginName] ?? {});
274
+ } catch (e) {
275
+ console.error(`Error setting up plugin ${pluginName}`, e);
276
+ }
277
+ }
278
+
241
279
  /** Image cache for general image fetching */
242
280
  this.imageCache = new ImageCache(this.book, {
243
281
  useSrcSet: this.options.useSrcSet,
@@ -586,6 +624,16 @@ BookReader.prototype.init = function() {
586
624
  this.enterFullscreen(true);
587
625
  }
588
626
 
627
+ // Init plugins
628
+ for (const [pluginName, plugin] of Object.entries(this._plugins)) {
629
+ try {
630
+ plugin.init();
631
+ }
632
+ catch (e) {
633
+ console.error(`Error initializing plugin ${pluginName}`, e);
634
+ }
635
+ }
636
+
589
637
  this.init.initComplete = true;
590
638
  this.trigger(BookReader.eventNames.PostInit);
591
639
 
@@ -0,0 +1,28 @@
1
+ // @ts-check
2
+ /** @typedef {import("./BookReader.js").default} BookReader */
3
+
4
+ /**
5
+ * @template TOptions
6
+ */
7
+ export class BookReaderPlugin {
8
+ /**
9
+ * @param {BookReader} br
10
+ */
11
+ constructor(br) {
12
+ /** @type {BookReader} */
13
+ this.br = br;
14
+ /** @type {TOptions} */
15
+ this.options;
16
+ }
17
+
18
+ /**
19
+ * @abstract
20
+ * @param {TOptions} options
21
+ **/
22
+ setup(options) {
23
+ this.options = Object.assign({}, this.options, options);
24
+ }
25
+
26
+ /** @abstract */
27
+ init() {}
28
+ }
@@ -110,9 +110,6 @@
110
110
  display: block;
111
111
  }
112
112
  }
113
- &.hide {
114
- display: none;
115
- }
116
113
  }
117
114
  }
118
115
 
@@ -81,6 +81,10 @@
81
81
  height: 30px;
82
82
  }
83
83
 
84
+ .controls .hide {
85
+ display: none;
86
+ }
87
+
84
88
  @keyframes slideUp {
85
89
  from {
86
90
  opacity: 0;