@internetarchive/bookreader 5.0.0-95 → 5.0.0-97

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 (330) hide show
  1. package/BookReader/474.js +2 -0
  2. package/BookReader/474.js.map +1 -0
  3. package/BookReader/BookReader.css +2257 -0
  4. package/BookReader/BookReader.js +3 -0
  5. package/BookReader/BookReader.js.LICENSE.txt +72 -0
  6. package/BookReader/BookReader.js.map +1 -0
  7. package/BookReader/bergamot-translator-worker.js +2966 -0
  8. package/BookReader/bergamot-translator-worker.wasm +0 -0
  9. package/BookReader/hypothesis/LICENSE +50 -0
  10. package/BookReader/hypothesis/README.md +55 -0
  11. package/BookReader/hypothesis/build/boot.js +1 -0
  12. package/BookReader/hypothesis/build/manifest.json +20 -0
  13. package/BookReader/hypothesis/build/scripts/annotator.bundle.js +184 -0
  14. package/BookReader/hypothesis/build/scripts/annotator.bundle.js.map +1 -0
  15. package/BookReader/hypothesis/build/scripts/sidebar.bundle.js +798 -0
  16. package/BookReader/hypothesis/build/scripts/sidebar.bundle.js.map +1 -0
  17. package/BookReader/hypothesis/build/scripts/ui-playground.bundle.js +711 -0
  18. package/BookReader/hypothesis/build/scripts/ui-playground.bundle.js.map +1 -0
  19. package/BookReader/hypothesis/build/styles/annotator.css +2235 -0
  20. package/BookReader/hypothesis/build/styles/annotator.css.map +1 -0
  21. package/BookReader/hypothesis/build/styles/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  22. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  23. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  24. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  25. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  26. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Bold.woff2 +0 -0
  27. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  28. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Italic.woff2 +0 -0
  29. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Regular.woff2 +0 -0
  30. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  31. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Math-Italic.woff2 +0 -0
  32. package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  33. package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  34. package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  35. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Script-Regular.woff2 +0 -0
  36. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  37. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  38. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  39. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  40. package/BookReader/hypothesis/build/styles/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  41. package/BookReader/hypothesis/build/styles/highlights.css +2 -0
  42. package/BookReader/hypothesis/build/styles/highlights.css.map +1 -0
  43. package/BookReader/hypothesis/build/styles/katex.min.css +2 -0
  44. package/BookReader/hypothesis/build/styles/katex.min.css.map +1 -0
  45. package/BookReader/hypothesis/build/styles/pdfjs-overrides.css +2 -0
  46. package/BookReader/hypothesis/build/styles/pdfjs-overrides.css.map +1 -0
  47. package/BookReader/hypothesis/build/styles/sidebar.css +2731 -0
  48. package/BookReader/hypothesis/build/styles/sidebar.css.map +1 -0
  49. package/BookReader/hypothesis/build/styles/ui-playground.css +2659 -0
  50. package/BookReader/hypothesis/build/styles/ui-playground.css.map +1 -0
  51. package/BookReader/hypothesis/package.json +126 -0
  52. package/BookReader/ia-bookreader-bundle.js +1782 -0
  53. package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -0
  54. package/BookReader/ia-bookreader-bundle.js.map +1 -0
  55. package/BookReader/icons/1up.svg +1 -0
  56. package/BookReader/icons/2up.svg +1 -0
  57. package/BookReader/icons/advance.svg +3 -0
  58. package/BookReader/icons/chevron-right.svg +1 -0
  59. package/BookReader/icons/close-circle-dark.svg +1 -0
  60. package/BookReader/icons/close-circle.svg +1 -0
  61. package/BookReader/icons/fullscreen.svg +1 -0
  62. package/BookReader/icons/fullscreen_exit.svg +1 -0
  63. package/BookReader/icons/hamburger.svg +1 -0
  64. package/BookReader/icons/left-arrow.svg +1 -0
  65. package/BookReader/icons/magnify-minus.svg +1 -0
  66. package/BookReader/icons/magnify-plus.svg +1 -0
  67. package/BookReader/icons/magnify.svg +1 -0
  68. package/BookReader/icons/pause.svg +1 -0
  69. package/BookReader/icons/play.svg +1 -0
  70. package/BookReader/icons/playback-speed.svg +1 -0
  71. package/BookReader/icons/read-aloud.svg +1 -0
  72. package/BookReader/icons/review.svg +3 -0
  73. package/BookReader/icons/thumbnails.svg +1 -0
  74. package/BookReader/icons/voice.svg +1 -0
  75. package/BookReader/icons/volume-full.svg +1 -0
  76. package/BookReader/images/BRicons.png +0 -0
  77. package/BookReader/images/BRicons.svg +5 -0
  78. package/BookReader/images/BRicons_ia.png +0 -0
  79. package/BookReader/images/back_pages.png +0 -0
  80. package/BookReader/images/book_bottom_icon.png +0 -0
  81. package/BookReader/images/book_down_icon.png +0 -0
  82. package/BookReader/images/book_left_icon.png +0 -0
  83. package/BookReader/images/book_leftmost_icon.png +0 -0
  84. package/BookReader/images/book_right_icon.png +0 -0
  85. package/BookReader/images/book_rightmost_icon.png +0 -0
  86. package/BookReader/images/book_top_icon.png +0 -0
  87. package/BookReader/images/book_up_icon.png +0 -0
  88. package/BookReader/images/books_graphic.svg +1 -0
  89. package/BookReader/images/booksplit.png +0 -0
  90. package/BookReader/images/control_pause_icon.png +0 -0
  91. package/BookReader/images/control_play_icon.png +0 -0
  92. package/BookReader/images/embed_icon.png +0 -0
  93. package/BookReader/images/hypothesis.ico +0 -0
  94. package/BookReader/images/icon-home-ia.png +0 -0
  95. package/BookReader/images/icon_OL-logo-xs.png +0 -0
  96. package/BookReader/images/icon_alert-xs.png +0 -0
  97. package/BookReader/images/icon_book.svg +1 -0
  98. package/BookReader/images/icon_bookmark.svg +1 -0
  99. package/BookReader/images/icon_close-pop.png +0 -0
  100. package/BookReader/images/icon_download.png +0 -0
  101. package/BookReader/images/icon_experiment.svg +1 -0
  102. package/BookReader/images/icon_gear.svg +1 -0
  103. package/BookReader/images/icon_hamburger.svg +1 -0
  104. package/BookReader/images/icon_home.png +0 -0
  105. package/BookReader/images/icon_home.svg +1 -0
  106. package/BookReader/images/icon_home_ia.png +0 -0
  107. package/BookReader/images/icon_indicator.png +0 -0
  108. package/BookReader/images/icon_info.svg +1 -0
  109. package/BookReader/images/icon_one_page.svg +1 -0
  110. package/BookReader/images/icon_pause.svg +1 -0
  111. package/BookReader/images/icon_play.svg +1 -0
  112. package/BookReader/images/icon_playback-rate.svg +1 -0
  113. package/BookReader/images/icon_return.png +0 -0
  114. package/BookReader/images/icon_search_button.svg +1 -0
  115. package/BookReader/images/icon_share.svg +1 -0
  116. package/BookReader/images/icon_skip-ahead.svg +1 -0
  117. package/BookReader/images/icon_skip-back.svg +2 -0
  118. package/BookReader/images/icon_speaker.svg +1 -0
  119. package/BookReader/images/icon_speaker_open.svg +1 -0
  120. package/BookReader/images/icon_thumbnails.svg +1 -0
  121. package/BookReader/images/icon_toc.svg +1 -0
  122. package/BookReader/images/icon_two_pages.svg +1 -0
  123. package/BookReader/images/icon_zoomer.png +0 -0
  124. package/BookReader/images/loading.gif +0 -0
  125. package/BookReader/images/logo_icon.png +0 -0
  126. package/BookReader/images/marker_chap-off.png +0 -0
  127. package/BookReader/images/marker_chap-off.svg +1 -0
  128. package/BookReader/images/marker_chap-off_ia.png +0 -0
  129. package/BookReader/images/marker_chap-on.png +0 -0
  130. package/BookReader/images/marker_chap-on.svg +1 -0
  131. package/BookReader/images/marker_srch-on.svg +1 -0
  132. package/BookReader/images/marker_srchchap-off.png +0 -0
  133. package/BookReader/images/marker_srchchap-on.png +0 -0
  134. package/BookReader/images/nav_control-dn.png +0 -0
  135. package/BookReader/images/nav_control-dn_ia.png +0 -0
  136. package/BookReader/images/nav_control-up.png +0 -0
  137. package/BookReader/images/nav_control-up_ia.png +0 -0
  138. package/BookReader/images/nav_control.png +0 -0
  139. package/BookReader/images/one_page_mode_icon.png +0 -0
  140. package/BookReader/images/paper-badge.png +0 -0
  141. package/BookReader/images/print_icon.png +0 -0
  142. package/BookReader/images/progressbar.gif +0 -0
  143. package/BookReader/images/right_edges.png +0 -0
  144. package/BookReader/images/slider.png +0 -0
  145. package/BookReader/images/slider_ia.png +0 -0
  146. package/BookReader/images/thumbnail_mode_icon.png +0 -0
  147. package/BookReader/images/translate.svg +1 -0
  148. package/BookReader/images/transparent.png +0 -0
  149. package/BookReader/images/two_page_mode_icon.png +0 -0
  150. package/BookReader/images/unviewable_page.png +0 -0
  151. package/BookReader/images/zoom_in_icon.png +0 -0
  152. package/BookReader/images/zoom_out_icon.png +0 -0
  153. package/BookReader/jquery-3.js +2 -0
  154. package/BookReader/jquery-3.js.LICENSE.txt +24 -0
  155. package/BookReader/plugins/plugin.archive_analytics.js +2 -0
  156. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -0
  157. package/BookReader/plugins/plugin.autoplay.js +2 -0
  158. package/BookReader/plugins/plugin.autoplay.js.map +1 -0
  159. package/BookReader/plugins/plugin.chapters.js +26 -0
  160. package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
  161. package/BookReader/plugins/plugin.chapters.js.map +1 -0
  162. package/BookReader/plugins/plugin.experiments.js +3 -0
  163. package/BookReader/plugins/plugin.experiments.js.LICENSE.txt +1 -0
  164. package/BookReader/plugins/plugin.experiments.js.map +1 -0
  165. package/BookReader/plugins/plugin.iframe.js +2 -0
  166. package/BookReader/plugins/plugin.iframe.js.map +1 -0
  167. package/BookReader/plugins/plugin.iiif.js +2 -0
  168. package/BookReader/plugins/plugin.iiif.js.map +1 -0
  169. package/BookReader/plugins/plugin.resume.js +2 -0
  170. package/BookReader/plugins/plugin.resume.js.map +1 -0
  171. package/BookReader/plugins/plugin.search.js +3 -0
  172. package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
  173. package/BookReader/plugins/plugin.search.js.map +1 -0
  174. package/BookReader/plugins/plugin.text_selection.js +3 -0
  175. package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
  176. package/BookReader/plugins/plugin.text_selection.js.map +1 -0
  177. package/BookReader/plugins/plugin.translate.js +3 -0
  178. package/BookReader/plugins/plugin.translate.js.LICENSE.txt +1 -0
  179. package/BookReader/plugins/plugin.translate.js.map +1 -0
  180. package/BookReader/plugins/plugin.tts.js +3 -0
  181. package/BookReader/plugins/plugin.tts.js.LICENSE.txt +29 -0
  182. package/BookReader/plugins/plugin.tts.js.map +1 -0
  183. package/BookReader/plugins/plugin.url.js +2 -0
  184. package/BookReader/plugins/plugin.url.js.map +1 -0
  185. package/BookReader/plugins/plugin.vendor-fullscreen.js +2 -0
  186. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -0
  187. package/BookReader/plugins/translator-worker.js +2 -0
  188. package/BookReader/plugins/translator-worker.js.map +1 -0
  189. package/BookReader/translator-worker.js +475 -0
  190. package/BookReader/webcomponents-bundle.js +3 -0
  191. package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
  192. package/BookReader/webcomponents-bundle.js.map +1 -0
  193. package/package.json +11 -3
  194. package/src/BookNavigator/book-navigator.js +1 -0
  195. package/src/BookReader/BookModel.js +564 -0
  196. package/src/BookReader/DragScrollable.js +233 -0
  197. package/src/BookReader/ImageCache.js +149 -0
  198. package/src/BookReader/Mode1Up.js +110 -0
  199. package/src/BookReader/Mode1UpLit.js +393 -0
  200. package/src/BookReader/Mode2Up.js +107 -0
  201. package/src/BookReader/Mode2UpLit.js +787 -0
  202. package/src/BookReader/ModeCoordinateSpace.js +29 -0
  203. package/src/BookReader/ModeSmoothZoom.js +312 -0
  204. package/src/BookReader/ModeThumb.js +344 -0
  205. package/src/BookReader/Navbar/Navbar.js +416 -0
  206. package/src/BookReader/PageContainer.js +172 -0
  207. package/src/BookReader/ReduceSet.js +26 -0
  208. package/src/BookReader/Toolbar/Toolbar.js +362 -0
  209. package/src/BookReader/events.js +19 -0
  210. package/src/BookReader/options.js +387 -0
  211. package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
  212. package/src/BookReader/utils/ScrollClassAdder.js +31 -0
  213. package/src/BookReader/utils/SelectionObserver.js +45 -0
  214. package/src/BookReader/utils/classes.js +36 -0
  215. package/src/BookReader/utils.js +313 -0
  216. package/src/BookReader.js +22 -139
  217. package/src/assets/images/icon_experiment.svg +1 -0
  218. package/src/assets/images/translate.svg +1 -0
  219. package/src/css/_BRnav.scss +0 -24
  220. package/src/css/_BRsearch.scss +0 -5
  221. package/src/css/_TextSelection.scss +32 -1
  222. package/src/plugins/plugin.experiments.js +34 -9
  223. package/src/plugins/plugin.text_selection.js +8 -20
  224. package/src/plugins/translate/TranslationManager.js +167 -0
  225. package/src/plugins/translate/plugin.translate.js +414 -0
  226. package/src/plugins/tts/utils.js +9 -20
  227. package/src/util/cache.js +20 -0
  228. package/.eslintrc.cjs +0 -51
  229. package/.gitattributes +0 -2
  230. package/.github/ISSUE_TEMPLATE/bug.md +0 -32
  231. package/.github/ISSUE_TEMPLATE/feature-request.md +0 -30
  232. package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -15
  233. package/.github/workflows/node.js.yml +0 -102
  234. package/.github/workflows/npm-publish.yml +0 -23
  235. package/.testcaferc.cjs +0 -10
  236. package/BookReaderDemo/BookReaderDemo.css +0 -40
  237. package/BookReaderDemo/BookReaderJSAdvanced.js +0 -112
  238. package/BookReaderDemo/BookReaderJSSimple.js +0 -56
  239. package/BookReaderDemo/IADemoBr.js +0 -149
  240. package/BookReaderDemo/assets/v5/Bookreader-logo-cool-grad.svg +0 -1
  241. package/BookReaderDemo/assets/v5/Bookreader-logo-flat.svg +0 -1
  242. package/BookReaderDemo/assets/v5/Bookreader-logo-hex-cool-grad.png +0 -0
  243. package/BookReaderDemo/assets/v5/Bookreader-logo-hex-flat.png +0 -0
  244. package/BookReaderDemo/assets/v5/Bookreader-logo-lines.png +0 -0
  245. package/BookReaderDemo/assets/v5/Bookreader-logo-lines.svg +0 -1
  246. package/BookReaderDemo/assets/v5/Bookreader-logo-warm.svg +0 -1
  247. package/BookReaderDemo/assets/v5/bookreader-logo-renders@1x.png +0 -0
  248. package/BookReaderDemo/assets/v5/bookreader-logo-renders@2x.png +0 -0
  249. package/BookReaderDemo/assets/v5/bookreader-v5-screenshot.png +0 -0
  250. package/BookReaderDemo/demo-advanced.html +0 -33
  251. package/BookReaderDemo/demo-embed-iframe-src.html +0 -85
  252. package/BookReaderDemo/demo-embed.html +0 -26
  253. package/BookReaderDemo/demo-fullscreen-mobile.html +0 -34
  254. package/BookReaderDemo/demo-fullscreen.html +0 -31
  255. package/BookReaderDemo/demo-iiif.html +0 -121
  256. package/BookReaderDemo/demo-internetarchive.html +0 -271
  257. package/BookReaderDemo/demo-multiple.html +0 -44
  258. package/BookReaderDemo/demo-preview-pages.html +0 -1093
  259. package/BookReaderDemo/demo-simple.html +0 -35
  260. package/BookReaderDemo/demo-vendor-fullscreen.html +0 -34
  261. package/BookReaderDemo/ia-multiple-volumes-manifest.js +0 -169
  262. package/BookReaderDemo/immersion-1up.html +0 -64
  263. package/BookReaderDemo/immersion-mode.html +0 -33
  264. package/BookReaderDemo/toggle_controls.html +0 -54
  265. package/BookReaderDemo/view_mode.html +0 -40
  266. package/BookReaderDemo/viewmode-cycle.html +0 -40
  267. package/CHANGELOG.md +0 -1087
  268. package/CONTRIBUTING.md +0 -7
  269. package/babel.config.cjs +0 -20
  270. package/codecov.yml +0 -23
  271. package/index.html +0 -34
  272. package/netlify.toml +0 -9
  273. package/renovate.json +0 -52
  274. package/screenshot.png +0 -0
  275. package/scripts/postversion.js +0 -11
  276. package/scripts/preversion.js +0 -15
  277. package/scripts/version.js +0 -24
  278. package/tests/e2e/README.md +0 -112
  279. package/tests/e2e/autoplay.test.js +0 -16
  280. package/tests/e2e/base.test.js +0 -27
  281. package/tests/e2e/helpers/base.js +0 -263
  282. package/tests/e2e/helpers/debug.js +0 -13
  283. package/tests/e2e/helpers/mockSearch.js +0 -90
  284. package/tests/e2e/helpers/params.js +0 -17
  285. package/tests/e2e/helpers/rightToLeft.js +0 -23
  286. package/tests/e2e/helpers/search.js +0 -73
  287. package/tests/e2e/models/BookReader.js +0 -11
  288. package/tests/e2e/models/Navigation.js +0 -39
  289. package/tests/e2e/rightToLeft.test.js +0 -19
  290. package/tests/e2e/viewmode.test.js +0 -44
  291. package/tests/jest/BookNavigator/book-navigator.test.js +0 -653
  292. package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +0 -43
  293. package/tests/jest/BookNavigator/bookmarks/bookmark-edit.test.js +0 -132
  294. package/tests/jest/BookNavigator/bookmarks/bookmarks-list.test.js +0 -221
  295. package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +0 -45
  296. package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +0 -67
  297. package/tests/jest/BookNavigator/downloads/downloads.test.js +0 -53
  298. package/tests/jest/BookNavigator/search/search-provider.test.js +0 -179
  299. package/tests/jest/BookNavigator/search/search-results.test.js +0 -289
  300. package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +0 -49
  301. package/tests/jest/BookNavigator/viewable-files/viewable-files-provider.test.js +0 -80
  302. package/tests/jest/BookNavigator/visual-adjustments.test.js +0 -200
  303. package/tests/jest/BookReader.keyboard.test.js +0 -190
  304. package/tests/jest/BookReader.options.test.js +0 -47
  305. package/tests/jest/BookReader.test.js +0 -316
  306. package/tests/jest/plugins/plugin.archive_analytics.test.js +0 -20
  307. package/tests/jest/plugins/plugin.autoplay.test.js +0 -35
  308. package/tests/jest/plugins/plugin.chapters.test.js +0 -193
  309. package/tests/jest/plugins/plugin.iframe.test.js +0 -42
  310. package/tests/jest/plugins/plugin.resume.test.js +0 -85
  311. package/tests/jest/plugins/plugin.text_selection.test.js +0 -447
  312. package/tests/jest/plugins/plugin.vendor-fullscreen.test.js +0 -65
  313. package/tests/jest/plugins/search/plugin.search.test.js +0 -120
  314. package/tests/jest/plugins/search/plugin.search.view.test.js +0 -131
  315. package/tests/jest/plugins/search/utils.js +0 -25
  316. package/tests/jest/plugins/search/utils.test.js +0 -29
  317. package/tests/jest/plugins/tts/AbstractTTSEngine.test.js +0 -173
  318. package/tests/jest/plugins/tts/FestivalTTSEngine.test.js +0 -59
  319. package/tests/jest/plugins/tts/PageChunk.test.js +0 -57
  320. package/tests/jest/plugins/tts/PageChunkIterator.test.js +0 -179
  321. package/tests/jest/plugins/tts/WebTTSEngine.test.js +0 -178
  322. package/tests/jest/plugins/tts/utils.test.js +0 -74
  323. package/tests/jest/plugins/url/UrlPlugin.test.js +0 -198
  324. package/tests/jest/plugins/url/plugin.url.test.js +0 -168
  325. package/tests/jest/setup.js +0 -3
  326. package/tests/jest/util/browserSniffing.test.js +0 -62
  327. package/tests/jest/util/docCookies.test.js +0 -24
  328. package/tests/jest/util/strings.test.js +0 -63
  329. package/tests/jest/utils.js +0 -83
  330. package/webpack.config.js +0 -97
@@ -0,0 +1,387 @@
1
+ // @ts-check
2
+ /** @typedef {import('./BookModel.js').PageNumString} PageNumString */
3
+ /** @typedef {import('./BookModel.js').LeafNum} LeafNum */
4
+
5
+ export const DEFAULT_OPTIONS = {
6
+ /**
7
+ * @type {string} A string, such as "mode/1up". See
8
+ * http://openlibrary.org/dev/docs/bookurls for valid syntax
9
+ */
10
+ defaults: null,
11
+
12
+ /** Padding in 1up */
13
+ padding: 10,
14
+
15
+ /** @type {'full' | 'embed' | 'responsive'} UI mode */
16
+ ui: 'full',
17
+
18
+ /** Controls whether nav/toolbar will autohide */
19
+ uiAutoHide: false,
20
+
21
+ /** thumbnail mode */
22
+ /** number of rows to pre-cache out a view */
23
+ thumbRowBuffer: 1,
24
+ thumbColumns: 6,
25
+ /** number of thumbnails to load at once */
26
+ thumbMaxLoading: 4,
27
+ /** spacing between thumbnails */
28
+ thumbPadding: 10,
29
+ /** min zoom in columns */
30
+ thumbMinZoomColumns: 2,
31
+ /** max zoom out columns */
32
+ thumbMaxZoomColumns: 8,
33
+
34
+ /** @type {number | 'fast' | 'slow'} speed for flip animation */
35
+ flipSpeed: 400,
36
+
37
+ showToolbar: true,
38
+ showNavbar: true,
39
+ navBarTitle: '',
40
+
41
+ showLogo: true,
42
+ /** Where the logo links to */
43
+ logoURL: 'https://archive.org',
44
+
45
+ /**
46
+ * Base URL for UI images - should be overridden (before init) by
47
+ * custom implementations.
48
+ * $$$ This is the same directory as the images referenced by relative
49
+ * path in the CSS. Would be better to automagically find that path.
50
+ */
51
+ imagesBaseURL: '/BookReader/images/',
52
+
53
+ /** @type {'pow2' | 'integer'} What reduces are valid for getURI. */
54
+ reduceSet: 'pow2',
55
+
56
+ /**
57
+ * Zoom levels
58
+ * @type {ReductionFactor[]}
59
+ * $$$ provide finer grained zooming, {reduce: 8, autofit: null}, {reduce: 16, autofit: null}
60
+ * The autofit code ensures that fit to width and fit to height will be available
61
+ */
62
+ reductionFactors: [
63
+ {reduce: 0.25, autofit: null},
64
+ {reduce: 0.5, autofit: null},
65
+ {reduce: 1, autofit: null},
66
+ {reduce: 2, autofit: null},
67
+ {reduce: 3, autofit: null},
68
+ {reduce: 4, autofit: null},
69
+ {reduce: 6, autofit: null},
70
+ ],
71
+
72
+ /** Object to hold parameters related to 1up mode */
73
+ onePage: {
74
+ /** @type {AutoFitValues} */
75
+ autofit: 'auto',
76
+ },
77
+
78
+ /** Object to hold parameters related to 2up mode */
79
+ twoPage: {
80
+ /** Width of cover */
81
+ coverInternalPadding: 0,
82
+ /** Padding outside of cover */
83
+ coverExternalPadding: 0,
84
+ /** Width of book spine $$$ consider sizing based on book length */
85
+ bookSpineDivWidth: 64,
86
+ /** @type {AutoFitValues} */
87
+ autofit: 'auto',
88
+ },
89
+
90
+ onePageMinBreakpoint: 800,
91
+
92
+ bookTitle: '',
93
+ /** @type {string} */
94
+ bookUrl: null,
95
+ /** @type {string} */
96
+ bookUrlText: null,
97
+ /** @type {string} */
98
+ bookUrlTitle: null,
99
+ enableBookTitleLink: true,
100
+ /**
101
+ * @type {string} A globally unique URI for the book. This is used to
102
+ * save data like annotations the user makes to the book.
103
+ */
104
+ bookUri: null,
105
+ /**
106
+ * @type {string} language in ISO 639-1 (PRIVATE: Will also
107
+ * handle language name in English, native name, 639-2/T, or 639-2/B . (archive.org books
108
+ * appear to use 639-2/B ? But I don't think that's a guarantee). See
109
+ * https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ) */
110
+ bookLanguage: null,
111
+
112
+ /**
113
+ * @type {Array<{label: string, value: *, extraValueClass: string?}>}
114
+ * Fields used to populate the info window
115
+ * @example [
116
+ * {label: 'Title', value: 'Open Library BookReader Presentation'},
117
+ * {label: 'Author', value: 'Internet Archive'},
118
+ * {label: 'Demo Info', value: 'This demo shows how one could use BookReader with their own content.'},
119
+ * ]
120
+ **/
121
+ metadata: [],
122
+ /** @type {string} */
123
+ thumbnail: null,
124
+ /** @type {string} */
125
+ bookUrlMoreInfo: null,
126
+
127
+ /** Experimental Controls (eg b/w) */
128
+ enableExperimentalControls: false,
129
+
130
+ /** CSS selectors */
131
+ /** Where BookReader mounts to */
132
+ el: '#BookReader',
133
+
134
+ /** @type {'lr' | 'rl'} Page progression */
135
+ pageProgression: 'lr',
136
+
137
+ /** The PPI the book is scanned at **/
138
+ ppi: 500,
139
+
140
+ /** Should image downloads be blocked */
141
+ protected: false,
142
+
143
+ /**
144
+ * Settings for individual plugins. Note they have to be imported first.
145
+ * WIP: Most plugins just put their options anywhere in this global options file,
146
+ * but going forward we'll keep them here.
147
+ **/
148
+ plugins: {
149
+ /** @type {Partial<import('../plugins/plugin.archive_analytics.js').ArchiveAnalyticsPlugin['options'>]}*/
150
+ archiveAnalytics: null,
151
+ /** @type {Partial<import('../plugins/plugin.autoplay.js').AutoplayPlugin['options'>]}*/
152
+ autoplay: null,
153
+ /** @type {Partial<import('../plugins/plugin.chapters.js').ChaptersPlugin['options']>} */
154
+ chapters: null,
155
+ /** @type {Partial<import('../plugins/plugin.iiif.js').IiifPlugin['options']>} */
156
+ iiif: null,
157
+ /** @type {Partial<import('../plugins/plugin.resume.js').ResumePlugin['options']>} */
158
+ resume: null,
159
+ /** @type {Partial<import('../plugins/search/plugin.search.js').SearchPlugin['options']>} */
160
+ search: null,
161
+ /** @type {Partial<import('../plugins/plugin.text_selection.js').TextSelectionPlugin['options']>} */
162
+ textSelection: null,
163
+ /** @type {Partial<import('../plugins/tts/plugin.tts.js').TtsPlugin['options']>} */
164
+ tts: null,
165
+ },
166
+
167
+ /**
168
+ * Any variables you want to define. If an option has a StringWithVars type, or
169
+ * has something like `{{server}}/foo.com` in its value, these variables replace
170
+ * the `{{foo}}`.
171
+ * @type { {[var_name: string]: any } }
172
+ */
173
+ vars: {},
174
+
175
+ /**
176
+ * @type {Array<[PageData, PageData]|[PageData]>}
177
+ * Data is a simple way to populate the bookreader
178
+ *
179
+ * Example:
180
+ * ```
181
+ * [
182
+ * // Each child is a spread
183
+ * [
184
+ * {
185
+ * width: 123,
186
+ * height: 123,
187
+ * // Optional: If not provided, include a getPageURI
188
+ * uri: 'https://archive.org/image.jpg',
189
+ * // Optional: Shown instead of leaf number if present.
190
+ * pageNum: '1'
191
+ * },
192
+ * {width: 123, height: 123, uri: 'https://archive.org/image2.jpg', pageNum: '2'},
193
+ * ]
194
+ * ],
195
+ * ```
196
+ *
197
+ * Note if URI is omitted, a custom getPageURI can be provided. This allows the page
198
+ * URI to the result of a function, which allows for things such as dynamic
199
+ * page scaling.
200
+ */
201
+ data: [],
202
+
203
+ /** @type {import('../plugins/plugin.chapters.js').TocEntry[]} */
204
+ table_of_contents: null,
205
+
206
+ /**
207
+ * Advanced methods for page rendering.
208
+ * All option functions have their `this` object set to the BookReader instance.
209
+ **/
210
+
211
+ /** @type {() => number} */
212
+ getNumLeafs: null,
213
+ /** @type {(index: number) => number} */
214
+ getPageWidth: null,
215
+ /** @type {(index: number) => number} */
216
+ getPageHeight: null,
217
+ /** @type {(index: number, reduce: number, rotate: number) => string} */
218
+ getPageURI: null,
219
+
220
+ /**
221
+ * @type {(img: HTMLImageElement, uri: string) => Promise<void>}
222
+ * Render the page URI into the image element. Perform any necessary preloading,
223
+ * authentication, etc.
224
+ */
225
+ renderPageURI(img, uri) {
226
+ img.src = uri;
227
+ },
228
+
229
+ /**
230
+ * @type {(index: number) => 'L' | 'R'}
231
+ * Return which side, left or right, that a given page should be displayed on
232
+ */
233
+ getPageSide: null,
234
+
235
+ /**
236
+ * @type {(pindex: number) => [number, number]}
237
+ * This function returns the left and right indices for the user-visible
238
+ * spread that contains the given index. The return values may be
239
+ * null if there is no facing page or the index is invalid.
240
+ */
241
+ getSpreadIndices: null,
242
+
243
+ /** @type {(index: number) => string} */
244
+ getPageNum: null,
245
+ /** @type {(index: number) => *} */
246
+ getPageProp: null,
247
+ /** @type {(index: number) => number} */
248
+ leafNumToIndex: null,
249
+
250
+ /**
251
+ * @type {(frameWidth: number|string, frameHeight: number|string, viewParams) => *}
252
+ * Optional: if present, and embed code will be shown in the share dialog
253
+ */
254
+ getEmbedCode: null,
255
+
256
+ controls: {
257
+ bookLeft: {
258
+ visible: true,
259
+ label: 'Flip left',
260
+ className: 'book_left',
261
+ iconClassName: 'left-arrow',
262
+ },
263
+ bookRight: {
264
+ visible: true,
265
+ label: 'Flip right',
266
+ className: 'book_right',
267
+ iconClassName: 'left-arrow hflip',
268
+ },
269
+ onePage: {
270
+ visible: true,
271
+ label: 'One-page view',
272
+ className: 'onepg',
273
+ iconClassName: 'onepg',
274
+ },
275
+ twoPage: {
276
+ visible: true,
277
+ label: 'Two-page view',
278
+ className: 'twopg',
279
+ iconClassName: 'twopg',
280
+ },
281
+ thumbnail: {
282
+ visible: true,
283
+ label: 'Thumbnail view',
284
+ className: 'thumb',
285
+ iconClassName: 'thumb',
286
+ },
287
+ viewmode: {
288
+ visible: true,
289
+ className: 'viewmode',
290
+ excludedModes: [],
291
+ },
292
+ zoomOut: {
293
+ visible: true,
294
+ label: 'Zoom out',
295
+ className: 'zoom_out',
296
+ iconClassName: 'magnify',
297
+ },
298
+ zoomIn: {
299
+ visible: true,
300
+ label: 'Zoom in',
301
+ className: 'zoom_in',
302
+ iconClassName: 'magnify plus',
303
+ },
304
+ fullScreen: {
305
+ visible: true,
306
+ label: 'Toggle fullscreen',
307
+ className: 'full',
308
+ iconClassName: 'fullscreen',
309
+ },
310
+ },
311
+
312
+ /**
313
+ * @type {Boolean}
314
+ * Optional: if true, starts in fullscreen mode
315
+ */
316
+ startFullscreen: false,
317
+
318
+ /**
319
+ * @type {Boolean}
320
+ * will show logo at fullscreen mode
321
+ */
322
+ enableFSLogoShortcut: false,
323
+
324
+ /**
325
+ * @type {Boolean}
326
+ * On init, by default, we want to handle resizing bookreader
327
+ * when browser window changes size (inc. `orientationchange` event)
328
+ * toggle off if you want to handle this outside of bookreader
329
+ */
330
+ autoResize: true,
331
+
332
+ /**
333
+ * @type {Boolean}
334
+ * On init, by default, we want to use srcSet for images
335
+ */
336
+ useSrcSet: false,
337
+
338
+ /**
339
+ * @type {string}
340
+ * Path to the image to display when a page is unviewable (i.e. when
341
+ * displaying a preview of a book).
342
+ *
343
+ * Relative to the imagesBaseURL if a relative path is specified.
344
+ */
345
+ unviewablePageURI: './unviewable_page.png',
346
+ };
347
+
348
+ /**
349
+ * @typedef {'width' | 'height' | 'auto' | 'none'} AutoFitValues
350
+ * - width: fill the width of the container
351
+ * - height: fill the height of the container
352
+ * - auto: fill the width or height of the container, whichever is smaller
353
+ * - none: do not autofit
354
+ **/
355
+
356
+ /**
357
+ * @typedef {object} ReductionFactor
358
+ * @property {number} reduce
359
+ * @property {AutoFitValues} [autofit] If set, the corresponding reduction factors
360
+ * are what will be used when the user tries to autofit by width/height.
361
+ */
362
+
363
+ /**
364
+ * @typedef {Object} PageData
365
+ * @property {number} width
366
+ * @property {number} height
367
+ * @property {string} [uri] If not provided, include a getPageURI
368
+ * @property {PageNumString} [pageNum] Shown instead of leaf number if present
369
+ * @property {LeafNum} [leafNum] Sometimes specified in Internet Archive books
370
+ * @property {number} [ppi] The resolution of the page if different from {@see BookReaderOptions.ppi}
371
+ * @property {'L' | 'R'} [pageSide] PRIVATE; computed automatically
372
+ * @property {boolean} [viewable=true] Set false if page is not viewable. Displays a dummy preview image.
373
+ * @property {number} [unviewablesStart] PRIVATE; index where the chunk of unviewable pages started
374
+ *
375
+ * Note if URI is omitted, a custom getPageURI can be provided. This allows the page
376
+ * URI to the result of a function, which allows for things such as dynamic
377
+ * page scaling.
378
+ */
379
+
380
+ /** @typedef {typeof DEFAULT_OPTIONS} BookReaderOptions */
381
+
382
+ /**
383
+ * Thrown when an error occurs while parsing options.
384
+ * Potentially recoverable and non-halting.
385
+ */
386
+ export class OptionsParseError extends Error {
387
+ }
@@ -0,0 +1,44 @@
1
+ // @ts-check
2
+ import { debounce } from '../utils.js';
3
+
4
+ /**
5
+ * Computing these things repeatedly is expensive (the browser needs to
6
+ * do a lot of computations/redrawing to make sure these are correct),
7
+ * so we store them here, and only recompute them when necessary:
8
+ * - window resize could have cause the container to change size
9
+ * - zoom could have cause scrollbars to appear/disappear, changing
10
+ * the client size.
11
+ */
12
+ export class HTMLDimensionsCacher {
13
+ clientWidth = 100;
14
+ clientHeight = 100;
15
+
16
+ boundingClientRect = { top: 0, left: 0 };
17
+
18
+ /**
19
+ * @param {HTMLElement} element
20
+ */
21
+ constructor(element) {
22
+ /** @type {HTMLElement} */
23
+ this.element = element;
24
+ }
25
+
26
+ updateClientSizes = () => {
27
+ const bc = this.element.getBoundingClientRect();
28
+ this.clientWidth = this.element.clientWidth;
29
+ this.clientHeight = this.element.clientHeight;
30
+ this.boundingClientRect.top = bc.top;
31
+ this.boundingClientRect.left = bc.left;
32
+ }
33
+ debouncedUpdateClientSizes = debounce(this.updateClientSizes, 150, false);
34
+
35
+ /** @param {EventTarget} win */
36
+ attachResizeListener(win = window) {
37
+ win.addEventListener('resize', this.debouncedUpdateClientSizes);
38
+ }
39
+
40
+ /** @param {EventTarget} win */
41
+ detachResizeListener(win = window) {
42
+ win.removeEventListener('resize', this.debouncedUpdateClientSizes);
43
+ }
44
+ }
@@ -0,0 +1,31 @@
1
+ /** Adds a class while the given element is experiencing scrolling */
2
+ export class ScrollClassAdder {
3
+ /**
4
+ * @param {HTMLElement} element
5
+ * @param {string} className
6
+ */
7
+ constructor(element, className) {
8
+ /** @type {HTMLElement} */
9
+ this.element = element;
10
+ /** @type {string} */
11
+ this.className = className;
12
+ this.timeout = null;
13
+ }
14
+
15
+ attach() {
16
+ this.element.addEventListener('scroll', this.onScroll);
17
+ }
18
+
19
+ detach() {
20
+ this.element.removeEventListener('scroll', this.onScroll);
21
+ }
22
+
23
+ onScroll = () => {
24
+ this.element.classList.add(this.className);
25
+ clearTimeout(this.timeout);
26
+ // TODO: Also remove class on mousemove, touch, click, etc.
27
+ this.timeout = setTimeout(() => {
28
+ this.element.classList.remove(this.className);
29
+ }, 600);
30
+ }
31
+ }
@@ -0,0 +1,45 @@
1
+ // @ts-check
2
+ export class SelectionObserver {
3
+ selecting = false;
4
+ startedInSelector = false;
5
+ /** @type {HTMLElement} */
6
+ target = null;
7
+
8
+ /**
9
+ * @param {string} selector
10
+ * @param {function('started' | 'cleared', HTMLElement): any} handler
11
+ */
12
+ constructor(selector, handler) {
13
+ this.selector = selector;
14
+ this.handler = handler;
15
+ }
16
+
17
+ attach() {
18
+ // We can't just use selectstart, because safari on iOS just
19
+ // randomly decides when to fire it 😤
20
+ // document.addEventListener("selectstart", this._onSelectStart);
21
+ // This has to be on document :/
22
+ document.addEventListener("selectionchange", this._onSelectionChange);
23
+ }
24
+
25
+ detach() {
26
+ document.removeEventListener("selectionchange", this._onSelectionChange);
27
+ }
28
+
29
+ _onSelectionChange = () => {
30
+ const sel = window.getSelection();
31
+
32
+ if (!this.selecting && sel.toString()) {
33
+ const target = $(sel.anchorNode).closest(this.selector)[0];
34
+ if (!target) return;
35
+ this.target = target;
36
+ this.selecting = true;
37
+ this.handler('started', this.target);
38
+ }
39
+
40
+ if (this.selecting && (sel.isCollapsed || !sel.toString() || !$(sel.anchorNode).closest(this.selector)[0])) {
41
+ this.selecting = false;
42
+ this.handler('cleared', this.target);
43
+ }
44
+ };
45
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Exposes a function from one class (FromClass) to another (ToClass), in such a way
3
+ * that if the ToClass's method is overridden, the FromClass's method is also overridden.
4
+ * WARNING: This modifies FromClass' prototype! So FromClasses cannot be shared between
5
+ * different ToClasses.
6
+ * @param {new () => TFrom} FromClass the class to get the method from
7
+ * @param {keyof TFrom} fromMethod the method's name in FromClass
8
+ * @param {function(TFrom): TTo} fromTransform how to get the TTo `this` to use when setting the method on TFrom
9
+ * @param {new () => TTo} ToClass the class to add the method to
10
+ * @param {string} toMethod the name of the method to add to TTo (likely will be equal to fromMethod)
11
+ * @param {function(TTo): TFrom} toTransform how to get the TFrom this to use when calling the new method
12
+ * @template TFrom type of FromClass for type-checking/autocomplete
13
+ * @template TTo type of ToClass for type-checking/autocomplete
14
+ */
15
+ export function exposeOverrideable(FromClass, fromMethod, fromTransform, ToClass, toMethod, toTransform) {
16
+ // Wrapper function needed to "capture" the current version of fromMethod
17
+ let wrapper = (fn => {
18
+ return function () {
19
+ return fn.apply(toTransform(this), arguments);
20
+ };
21
+ })(FromClass.prototype[fromMethod]);
22
+
23
+ Object.defineProperty(ToClass.prototype, toMethod, {
24
+ get() { return wrapper; },
25
+ set(overrideFn) {
26
+ // overrideFn expects `this` to be ToClass, so ensure as such
27
+ // But we can also call this method from FromClass; need to ensure
28
+ // it's always called with a ToClass
29
+ FromClass.prototype[fromMethod] = function () {
30
+ const newThis = this instanceof FromClass ? fromTransform(this) : this;
31
+ return overrideFn.apply(newThis, arguments);
32
+ };
33
+ wrapper = overrideFn;
34
+ },
35
+ });
36
+ }