@internetarchive/bookreader 5.0.0-11 → 5.0.0-110

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 (380) hide show
  1. package/BookReader/474.js +2 -0
  2. package/BookReader/474.js.map +1 -0
  3. package/BookReader/BookReader.css +604 -1239
  4. package/BookReader/BookReader.js +1 -1
  5. package/BookReader/BookReader.js.LICENSE.txt +20 -20
  6. package/BookReader/BookReader.js.map +1 -1
  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 +1907 -0
  53. package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +19 -0
  54. package/BookReader/ia-bookreader-bundle.js.map +1 -0
  55. package/BookReader/icons/1up.svg +1 -1
  56. package/BookReader/icons/2up.svg +1 -1
  57. package/BookReader/icons/advance.svg +1 -1
  58. package/BookReader/icons/chevron-right.svg +1 -1
  59. package/BookReader/icons/close-circle-dark.svg +1 -1
  60. package/BookReader/icons/close-circle.svg +1 -1
  61. package/BookReader/icons/fullscreen.svg +1 -1
  62. package/BookReader/icons/fullscreen_exit.svg +1 -1
  63. package/BookReader/icons/hamburger.svg +1 -1
  64. package/BookReader/icons/left-arrow.svg +1 -1
  65. package/BookReader/icons/magnify-minus.svg +1 -1
  66. package/BookReader/icons/magnify-plus.svg +1 -1
  67. package/BookReader/icons/magnify.svg +1 -1
  68. package/BookReader/icons/pause.svg +1 -1
  69. package/BookReader/icons/play.svg +1 -1
  70. package/BookReader/icons/playback-speed.svg +1 -1
  71. package/BookReader/icons/read-aloud.svg +1 -1
  72. package/BookReader/icons/review.svg +1 -1
  73. package/BookReader/icons/slider-toggle.svg +1 -0
  74. package/BookReader/icons/thumbnails.svg +1 -1
  75. package/BookReader/icons/voice.svg +1 -0
  76. package/BookReader/icons/volume-full.svg +1 -1
  77. package/BookReader/images/BRicons.svg +3 -3
  78. package/BookReader/images/books_graphic.svg +1 -1
  79. package/BookReader/images/hypothesis.ico +0 -0
  80. package/BookReader/images/icon_book.svg +1 -1
  81. package/BookReader/images/icon_bookmark.svg +1 -1
  82. package/BookReader/images/icon_experiment.svg +1 -0
  83. package/BookReader/images/icon_gear.svg +1 -1
  84. package/BookReader/images/icon_hamburger.svg +1 -1
  85. package/BookReader/images/icon_home.svg +1 -1
  86. package/BookReader/images/icon_info.svg +1 -1
  87. package/BookReader/images/icon_one_page.svg +1 -1
  88. package/BookReader/images/icon_pause.svg +1 -1
  89. package/BookReader/images/icon_play.svg +1 -1
  90. package/BookReader/images/icon_playback-rate.svg +1 -1
  91. package/BookReader/images/icon_search_button.svg +1 -1
  92. package/BookReader/images/icon_share.svg +1 -1
  93. package/BookReader/images/icon_skip-ahead.svg +1 -1
  94. package/BookReader/images/icon_skip-back.svg +1 -1
  95. package/BookReader/images/icon_speaker.svg +1 -1
  96. package/BookReader/images/icon_speaker_open.svg +1 -1
  97. package/BookReader/images/icon_thumbnails.svg +1 -1
  98. package/BookReader/images/icon_toc.svg +1 -1
  99. package/BookReader/images/icon_two_pages.svg +1 -1
  100. package/BookReader/images/marker_chap-off.svg +1 -1
  101. package/BookReader/images/marker_chap-on.svg +1 -1
  102. package/BookReader/images/marker_srch-on.svg +1 -1
  103. package/BookReader/images/translate.svg +1 -0
  104. package/BookReader/images/unviewable_page.png +0 -0
  105. package/BookReader/jquery-3.js +2 -0
  106. package/BookReader/jquery-3.js.LICENSE.txt +24 -0
  107. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  108. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  109. package/BookReader/plugins/plugin.autoplay.js +1 -1
  110. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  111. package/BookReader/plugins/plugin.chapters.js +22 -1
  112. package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
  113. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  114. package/BookReader/plugins/plugin.experiments.js +3 -0
  115. package/BookReader/plugins/plugin.experiments.js.LICENSE.txt +1 -0
  116. package/BookReader/plugins/plugin.experiments.js.map +1 -0
  117. package/BookReader/plugins/plugin.iframe.js +1 -1
  118. package/BookReader/plugins/plugin.iframe.js.map +1 -1
  119. package/BookReader/plugins/plugin.iiif.js +2 -0
  120. package/BookReader/plugins/plugin.iiif.js.map +1 -0
  121. package/BookReader/plugins/plugin.resume.js +1 -1
  122. package/BookReader/plugins/plugin.resume.js.map +1 -1
  123. package/BookReader/plugins/plugin.search.js +2 -1
  124. package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
  125. package/BookReader/plugins/plugin.search.js.map +1 -1
  126. package/BookReader/plugins/plugin.text_selection.js +2 -1
  127. package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
  128. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  129. package/BookReader/plugins/plugin.translate.js +137 -0
  130. package/BookReader/plugins/plugin.translate.js.LICENSE.txt +1 -0
  131. package/BookReader/plugins/plugin.translate.js.map +1 -0
  132. package/BookReader/plugins/plugin.tts.js +1 -1
  133. package/BookReader/plugins/plugin.tts.js.LICENSE.txt +2 -0
  134. package/BookReader/plugins/plugin.tts.js.map +1 -1
  135. package/BookReader/plugins/plugin.url.js +1 -1
  136. package/BookReader/plugins/plugin.url.js.map +1 -1
  137. package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
  138. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
  139. package/BookReader/plugins/translator-worker.js +2 -0
  140. package/BookReader/plugins/translator-worker.js.map +1 -0
  141. package/BookReader/silence.mp3 +0 -0
  142. package/BookReader/translator-worker.js +475 -0
  143. package/BookReader/webcomponents-bundle.js +3 -0
  144. package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
  145. package/BookReader/webcomponents-bundle.js.map +1 -0
  146. package/README.md +14 -3
  147. package/jsconfig.json +19 -0
  148. package/package.json +92 -70
  149. package/src/BookReader/BookModel.js +92 -46
  150. package/src/BookReader/DragScrollable.js +233 -0
  151. package/src/BookReader/ImageCache.js +49 -16
  152. package/src/BookReader/Mode1Up.js +66 -365
  153. package/src/BookReader/Mode1UpLit.js +392 -0
  154. package/src/BookReader/Mode2Up.js +87 -1315
  155. package/src/BookReader/Mode2UpLit.js +788 -0
  156. package/src/BookReader/ModeAbstract.js +43 -0
  157. package/src/BookReader/ModeCoordinateSpace.js +29 -0
  158. package/src/BookReader/ModeSmoothZoom.js +312 -0
  159. package/src/BookReader/ModeThumb.js +29 -15
  160. package/src/BookReader/Navbar/Navbar.js +201 -76
  161. package/src/BookReader/PageContainer.js +120 -23
  162. package/src/BookReader/ReduceSet.js +2 -2
  163. package/src/BookReader/Toolbar/Toolbar.js +18 -40
  164. package/src/BookReader/events.js +3 -3
  165. package/src/BookReader/options.js +94 -17
  166. package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
  167. package/src/BookReader/utils/ScrollClassAdder.js +31 -0
  168. package/src/BookReader/utils/SelectionObserver.js +45 -0
  169. package/src/BookReader/utils/classes.js +1 -1
  170. package/src/BookReader/utils.js +136 -12
  171. package/src/BookReader.js +678 -1226
  172. package/src/BookReaderPlugin.js +52 -0
  173. package/src/assets/icons/magnify-minus.svg +3 -7
  174. package/src/assets/icons/magnify-plus.svg +3 -7
  175. package/src/assets/icons/slider-toggle.svg +1 -0
  176. package/src/assets/icons/voice.svg +1 -0
  177. package/src/assets/images/hypothesis.ico +0 -0
  178. package/src/assets/images/icon_experiment.svg +1 -0
  179. package/src/assets/images/translate.svg +1 -0
  180. package/src/assets/images/unviewable_page.png +0 -0
  181. package/src/assets/silence.mp3 +0 -0
  182. package/src/css/BookReader.scss +1 -5
  183. package/src/css/_BRBookmarks.scss +1 -1
  184. package/src/css/_BRComponent.scss +1 -1
  185. package/src/css/_BRicon.scss +8 -2
  186. package/src/css/_BRmain.scss +16 -3
  187. package/src/css/_BRnav.scss +74 -70
  188. package/src/css/_BRpages.scss +171 -42
  189. package/src/css/_BRsearch.scss +69 -30
  190. package/src/css/_BRtoolbar.scss +5 -5
  191. package/src/css/_TextSelection.scss +129 -24
  192. package/src/css/_colorbox.scss +2 -2
  193. package/src/css/_controls.scss +24 -7
  194. package/src/css/_icons.scss +8 -1
  195. package/src/{BookNavigator/assets → css}/button-base.js +2 -2
  196. package/src/css/icon_checkmark.js +9 -0
  197. package/src/css/sharedStyles.js +15 -0
  198. package/src/ia-bookreader/downloads/downloads-provider.js +81 -0
  199. package/src/{BookNavigator → ia-bookreader}/downloads/downloads.js +25 -5
  200. package/src/ia-bookreader/ia-bookreader.js +666 -0
  201. package/src/ia-bookreader/sharing.js +27 -0
  202. package/src/ia-bookreader/viewable-files.js +98 -0
  203. package/src/{BookNavigator → ia-bookreader}/visual-adjustments/visual-adjustments-provider.js +17 -17
  204. package/src/{BookNavigator → ia-bookreader}/visual-adjustments/visual-adjustments.js +75 -67
  205. package/src/{BookNavigator → plugins}/bookmarks/bookmark-button.js +4 -3
  206. package/src/{BookNavigator/assets → plugins/bookmarks}/bookmark-colors.js +1 -1
  207. package/src/{BookNavigator → plugins}/bookmarks/bookmark-edit.js +43 -31
  208. package/src/{BookNavigator → plugins}/bookmarks/bookmarks-list.js +48 -49
  209. package/src/{BookNavigator → plugins}/bookmarks/bookmarks-loginCTA.js +3 -3
  210. package/src/plugins/bookmarks/bookmarks-provider.js +63 -0
  211. package/src/{BookNavigator → plugins/bookmarks}/delete-modal-actions.js +1 -1
  212. package/src/{BookNavigator → plugins}/bookmarks/ia-bookmarks.js +117 -68
  213. package/src/plugins/plugin.archive_analytics.js +84 -78
  214. package/src/plugins/plugin.autoplay.js +99 -104
  215. package/src/plugins/plugin.chapters.js +314 -205
  216. package/src/plugins/plugin.experiments.js +321 -0
  217. package/src/plugins/plugin.iframe.js +1 -1
  218. package/src/plugins/plugin.iiif.js +141 -0
  219. package/src/plugins/plugin.resume.js +54 -51
  220. package/src/plugins/plugin.text_selection.js +522 -219
  221. package/src/plugins/plugin.vendor-fullscreen.js +5 -5
  222. package/src/plugins/search/plugin.search.js +374 -392
  223. package/src/{BookNavigator → plugins}/search/search-provider.js +59 -27
  224. package/src/{BookNavigator → plugins}/search/search-results.js +105 -76
  225. package/src/plugins/search/utils.js +50 -0
  226. package/src/plugins/search/view.js +50 -68
  227. package/src/plugins/translate/TranslationManager.js +164 -0
  228. package/src/plugins/translate/plugin.translate.js +512 -0
  229. package/src/plugins/tts/AbstractTTSEngine.js +78 -49
  230. package/src/plugins/tts/FestivalTTSEngine.js +20 -30
  231. package/src/plugins/tts/PageChunk.js +33 -21
  232. package/src/plugins/tts/PageChunkIterator.js +11 -17
  233. package/src/plugins/tts/WebTTSEngine.js +131 -91
  234. package/src/plugins/tts/plugin.tts.js +345 -350
  235. package/src/plugins/tts/utils.js +77 -49
  236. package/src/plugins/url/UrlPlugin.js +191 -0
  237. package/src/plugins/{plugin.url.js → url/plugin.url.js} +44 -15
  238. package/src/util/TextSelectionManager.js +282 -0
  239. package/src/util/browserSniffing.js +33 -1
  240. package/src/util/cache.js +20 -0
  241. package/src/util/docCookies.js +21 -2
  242. package/src/util/lit.js +15 -0
  243. package/src/util/strings.js +1 -0
  244. package/.babelrc +0 -12
  245. package/.dependabot/config.yml +0 -6
  246. package/.eslintrc.js +0 -50
  247. package/.gitattributes +0 -2
  248. package/.github/ISSUE_TEMPLATE/bug.md +0 -32
  249. package/.github/ISSUE_TEMPLATE/feature-request.md +0 -30
  250. package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -15
  251. package/.github/workflows/node.js.yml +0 -37
  252. package/.github/workflows/npm-publish.yml +0 -47
  253. package/.testcaferc.json +0 -5
  254. package/BookReader/bookreader-component-bundle.js +0 -1450
  255. package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
  256. package/BookReader/bookreader-component-bundle.js.map +0 -1
  257. package/BookReader/jquery-1.10.1.js +0 -2
  258. package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
  259. package/BookReader/plugins/plugin.menu_toggle.js +0 -2
  260. package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
  261. package/BookReader/plugins/plugin.mobile_nav.js +0 -2
  262. package/BookReader/plugins/plugin.mobile_nav.js.map +0 -1
  263. package/BookReaderDemo/BookReaderDemo.css +0 -41
  264. package/BookReaderDemo/BookReaderJSAdvanced.js +0 -115
  265. package/BookReaderDemo/BookReaderJSAutoplay.js +0 -56
  266. package/BookReaderDemo/BookReaderJSSimple.js +0 -55
  267. package/BookReaderDemo/IIIFBookReader.js +0 -207
  268. package/BookReaderDemo/assets/v5/Bookreader-logo-cool-grad.svg +0 -1
  269. package/BookReaderDemo/assets/v5/Bookreader-logo-flat.svg +0 -1
  270. package/BookReaderDemo/assets/v5/Bookreader-logo-hex-cool-grad.png +0 -0
  271. package/BookReaderDemo/assets/v5/Bookreader-logo-hex-flat.png +0 -0
  272. package/BookReaderDemo/assets/v5/Bookreader-logo-lines.png +0 -0
  273. package/BookReaderDemo/assets/v5/Bookreader-logo-lines.svg +0 -1
  274. package/BookReaderDemo/assets/v5/Bookreader-logo-warm.svg +0 -1
  275. package/BookReaderDemo/assets/v5/bookreader-logo-renders@1x.png +0 -0
  276. package/BookReaderDemo/assets/v5/bookreader-logo-renders@2x.png +0 -0
  277. package/BookReaderDemo/assets/v5/bookreader-v5-screenshot.png +0 -0
  278. package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
  279. package/BookReaderDemo/demo-advanced.html +0 -33
  280. package/BookReaderDemo/demo-autoplay.html +0 -38
  281. package/BookReaderDemo/demo-embed-iframe-src.html +0 -84
  282. package/BookReaderDemo/demo-embed.html +0 -26
  283. package/BookReaderDemo/demo-fullscreen-mobile.html +0 -36
  284. package/BookReaderDemo/demo-fullscreen.html +0 -33
  285. package/BookReaderDemo/demo-iiif.html +0 -34
  286. package/BookReaderDemo/demo-iiif.js +0 -26
  287. package/BookReaderDemo/demo-internetarchive.html +0 -74
  288. package/BookReaderDemo/demo-multiple.html +0 -43
  289. package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
  290. package/BookReaderDemo/demo-preview-pages.html +0 -1092
  291. package/BookReaderDemo/demo-simple.html +0 -34
  292. package/BookReaderDemo/demo-vendor-fullscreen.html +0 -36
  293. package/BookReaderDemo/immersion-1up.html +0 -64
  294. package/BookReaderDemo/immersion-mode.html +0 -35
  295. package/BookReaderDemo/toggle_controls.html +0 -53
  296. package/BookReaderDemo/view_mode.html +0 -39
  297. package/BookReaderDemo/viewmode-cycle.html +0 -41
  298. package/CHANGELOG.md +0 -495
  299. package/CONTRIBUTING.md +0 -7
  300. package/codecov.yml +0 -17
  301. package/index.html +0 -31
  302. package/karma.conf.js +0 -23
  303. package/screenshot.png +0 -0
  304. package/scripts/postversion.js +0 -10
  305. package/scripts/preversion.js +0 -14
  306. package/scripts/version.js +0 -26
  307. package/src/BookNavigator/BookModel.js +0 -14
  308. package/src/BookNavigator/BookNavigator.js +0 -446
  309. package/src/BookNavigator/assets/book-loader.js +0 -27
  310. package/src/BookNavigator/assets/icon_checkmark.js +0 -6
  311. package/src/BookNavigator/assets/icon_close.js +0 -3
  312. package/src/BookNavigator/bookmarks/bookmarks-provider.js +0 -53
  313. package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
  314. package/src/BookNavigator/downloads/downloads-provider.js +0 -66
  315. package/src/BookNavigator/search/a-search-result.js +0 -55
  316. package/src/BookReader/DebugConsole.js +0 -54
  317. package/src/BookReaderComponent/BookReaderComponent.js +0 -112
  318. package/src/ItemNavigator/ItemNavigator.js +0 -376
  319. package/src/ItemNavigator/providers/sharing.js +0 -29
  320. package/src/css/_MobileNav.scss +0 -194
  321. package/src/dragscrollable-br.js +0 -261
  322. package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
  323. package/src/plugins/plugin.mobile_nav.js +0 -287
  324. package/tests/BookReader/BookModel.test.js +0 -312
  325. package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
  326. package/tests/BookReader/DebugConsole.test.js +0 -25
  327. package/tests/BookReader/ImageCache.test.js +0 -150
  328. package/tests/BookReader/Mode1Up.test.js +0 -164
  329. package/tests/BookReader/Mode2Up.test.js +0 -247
  330. package/tests/BookReader/Navbar/Navbar.test.js +0 -169
  331. package/tests/BookReader/PageContainer.test.js +0 -115
  332. package/tests/BookReader/ReduceSet.test.js +0 -38
  333. package/tests/BookReader/Toolbar/Toolbar.test.js +0 -26
  334. package/tests/BookReader/utils/classes.test.js +0 -88
  335. package/tests/BookReader/utils.test.js +0 -109
  336. package/tests/BookReader.options.test.js +0 -39
  337. package/tests/BookReader.test.js +0 -301
  338. package/tests/e2e/README.md +0 -75
  339. package/tests/e2e/autoplay.test.js +0 -13
  340. package/tests/e2e/base.test.js +0 -35
  341. package/tests/e2e/helpers/base.js +0 -263
  342. package/tests/e2e/helpers/debug.js +0 -13
  343. package/tests/e2e/helpers/desktopSearch.js +0 -72
  344. package/tests/e2e/helpers/mobileSearch.js +0 -85
  345. package/tests/e2e/helpers/mockSearch.js +0 -93
  346. package/tests/e2e/helpers/rightToLeft.js +0 -29
  347. package/tests/e2e/ia-production/ia-prod-base.js +0 -17
  348. package/tests/e2e/models/BookReader.js +0 -11
  349. package/tests/e2e/models/Navigation.js +0 -56
  350. package/tests/e2e/rightToLeft.test.js +0 -20
  351. package/tests/e2e/viewmode.test.js +0 -37
  352. package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
  353. package/tests/karma/BookNavigator/bookmarks/bookmark-edit.test.js +0 -133
  354. package/tests/karma/BookNavigator/bookmarks/bookmarks-list.test.js +0 -222
  355. package/tests/karma/BookNavigator/search/search-provider.test.js +0 -23
  356. package/tests/karma/BookNavigator/search/search-results.test.js +0 -240
  357. package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
  358. package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
  359. package/tests/plugins/plugin.archive_analytics.test.js +0 -23
  360. package/tests/plugins/plugin.autoplay.test.js +0 -52
  361. package/tests/plugins/plugin.chapters.test.js +0 -130
  362. package/tests/plugins/plugin.iframe.test.js +0 -42
  363. package/tests/plugins/plugin.mobile_nav.test.js +0 -66
  364. package/tests/plugins/plugin.resume.test.js +0 -98
  365. package/tests/plugins/plugin.text_selection.test.js +0 -203
  366. package/tests/plugins/plugin.url.test.js +0 -129
  367. package/tests/plugins/plugin.vendor-fullscreen.test.js +0 -65
  368. package/tests/plugins/search/plugin.search.test.js +0 -173
  369. package/tests/plugins/search/plugin.search.view.test.js +0 -106
  370. package/tests/plugins/tts/AbstractTTSEngine.test.js +0 -153
  371. package/tests/plugins/tts/FestivalTTSEngine.test.js +0 -59
  372. package/tests/plugins/tts/PageChunk.test.js +0 -57
  373. package/tests/plugins/tts/PageChunkIterator.test.js +0 -179
  374. package/tests/plugins/tts/WebTTSEngine.test.js +0 -126
  375. package/tests/plugins/tts/utils.test.js +0 -133
  376. package/tests/util/browserSniffing.test.js +0 -56
  377. package/tests/util/docCookies.test.js +0 -15
  378. package/tests/util/strings.test.js +0 -63
  379. package/tests/utils.js +0 -42
  380. package/webpack.config.js +0 -86
@@ -0,0 +1,666 @@
1
+ // @ts-check
2
+ /**
3
+ * Wrapping web component for Internet Archive's BookReader. Currently operates
4
+ * more as a shell ; requires BookReader to be instantiated independently in the
5
+ * main slot.
6
+ */
7
+
8
+ import { LitElement, html, css } from 'lit';
9
+
10
+ import '@internetarchive/ia-item-navigator';
11
+ import '@internetarchive/modal-manager';
12
+ import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
13
+ import '@internetarchive/icon-ia-logo';
14
+ import SearchProvider from '../plugins/search/search-provider.js';
15
+ import DownloadProvider from './downloads/downloads-provider.js';
16
+ import VisualAdjustmentProvider from './visual-adjustments/visual-adjustments-provider.js';
17
+ import BookmarksProvider from '../plugins/bookmarks/bookmarks-provider.js';
18
+ import SharingProvider from './sharing.js';
19
+ import ViewableFilesProvider from './viewable-files.js';
20
+ import { sortBy } from '../BookReader/utils.js';
21
+ /** @typedef {import('@/src/BookReader.js').default} BookReader */
22
+ /** @typedef {import('@internetarchive/modal-manager').ModalManager} ModalManager */
23
+
24
+
25
+ export class IaBookReader extends LitElement {
26
+ static get properties() {
27
+ return {
28
+ item: { type: Object },
29
+ baseHost: { type: String },
30
+ signedIn: { type: Boolean },
31
+ fullscreen: { type: Boolean, reflect: true, attribute: true },
32
+ sharedObserver: { type: Object, attribute: false },
33
+ modal: { type: Object, attribute: false },
34
+ loaded: { type: Boolean },
35
+ menuShortcuts: { type: Array },
36
+ menuContents: { type: Array },
37
+ bookReaderLoaded: { type: Boolean },
38
+ bookreader: { type: Object },
39
+ bookIsRestricted: { type: Boolean },
40
+ downloadableTypes: { type: Array },
41
+ isAdmin: { type: Boolean },
42
+ lendingInitialized: { type: Boolean },
43
+ lendingStatus: { type: Object },
44
+ menuProviders: { type: Object },
45
+ fullscreenBranding: { type: Object },
46
+ };
47
+ }
48
+
49
+ /** @type {import('@internetarchive/ia-item-navigator').ItemNavigator} */
50
+ get itemNav() {
51
+ return this.shadowRoot.querySelector('iaux-item-navigator');
52
+ }
53
+
54
+ constructor() {
55
+ super();
56
+ /** The IA metadata item */
57
+ this.item = undefined;
58
+ /** @type {BookReader} */
59
+ this.bookreader = undefined;
60
+ this.baseHost = 'archive.org';
61
+ this.fullscreen = false;
62
+ this.signedIn = false;
63
+ /** @type {ModalManager} */
64
+ this.modal = undefined;
65
+ /** @type {SharedResizeObserver} */
66
+ this.sharedObserver = undefined;
67
+ this.loaded = false;
68
+ /** @type {Array<{ id: string, icon: string | import('lit').TemplateResult }>} */
69
+ this.menuShortcuts = [];
70
+ this.menuContents = [];
71
+ this.openMenuName = '';
72
+
73
+ this.bookReaderCannotLoad = false;
74
+ this.bookReaderLoaded = false;
75
+ this.bookIsRestricted = false;
76
+ this.downloadableTypes = [];
77
+ this.isAdmin = false;
78
+ this.lendingInitialized = false;
79
+ this.lendingStatus = {};
80
+ this.menuProviders = {
81
+ /** @type {BookmarksProvider} */
82
+ bookmarks: null,
83
+ /** @type {SearchProvider} */
84
+ search: null,
85
+ /** @type {DownloadProvider} */
86
+ downloads: null,
87
+ /** @type {VisualAdjustmentProvider} */
88
+ visualAdjustments: null,
89
+ /** @type {SharingProvider} */
90
+ share: null,
91
+ /** @type {ViewableFilesProvider} */
92
+ volumes: null,
93
+ };
94
+ this.signedIn = false;
95
+ this.fullscreenBranding = html`<ia-icon-ia-logo aria-hidden="true"></ia-icon-ia-logo>`;
96
+ // Untracked properties
97
+ this._sharedObserverHandler = { handleResize: this.handleResize.bind(this) };
98
+ this._brWidth = 0;
99
+ this._brHeight = 0;
100
+ this.shortcutOrder = [
101
+ /**
102
+ * sets exit FS button (`this.fullscreenBranding`)
103
+ * when `br.options.enableFSLogoShortcut`
104
+ */
105
+ 'fullscreen',
106
+ 'volumes',
107
+ 'chapters',
108
+ 'search',
109
+ 'translate',
110
+ 'bookmarks',
111
+ 'downloads',
112
+ 'visualAdjustments',
113
+ 'share',
114
+ 'experiments',
115
+ ];
116
+ }
117
+
118
+ disconnectedCallback() {
119
+ super.disconnectedCallback();
120
+ this.unloadSharedObserver();
121
+ }
122
+
123
+ firstUpdated() {
124
+ if (!this.modal) {
125
+ this.setModalManager();
126
+ }
127
+
128
+ if (!this.sharedObserver) {
129
+ this.sharedObserver = new SharedResizeObserver();
130
+ }
131
+
132
+ this._bindEventListeners();
133
+ this.loaded = true;
134
+ }
135
+
136
+ /**
137
+ * @param {import('lit').PropertyValues} changed
138
+ */
139
+ updated(changed) {
140
+ if (!this.bookreader || !this.item || !this.bookReaderLoaded) {
141
+ return;
142
+ }
143
+
144
+ const reload = changed.has('loaded') && this.loaded;
145
+ if (reload
146
+ || changed.has('item')
147
+ || changed.has('bookreader')
148
+ || changed.has('signedIn')
149
+ || changed.has('isAdmin')
150
+ || changed.has('modal')) {
151
+ this.initializeBookSubmenus();
152
+ }
153
+
154
+ if (changed.has('sharedObserver') && this.bookreader) {
155
+ this.loadSharedObserver();
156
+ this.initializeBookSubmenus();
157
+ }
158
+
159
+ if (changed.has('downloadableTypes')) {
160
+ this.initializeBookSubmenus();
161
+ }
162
+ }
163
+
164
+ loadSharedObserver() {
165
+ this.unloadSharedObserver();
166
+ this.sharedObserver?.addObserver({
167
+ target: this.mainBRContainer,
168
+ handler: this._sharedObserverHandler,
169
+ });
170
+ }
171
+
172
+ unloadSharedObserver() {
173
+ this.sharedObserver?.removeObserver({
174
+ target: this.mainBRContainer,
175
+ handler: this._sharedObserverHandler,
176
+ });
177
+ }
178
+
179
+ /**
180
+ * Uses resize observer to fire BookReader's `resize` functionality
181
+ * We do not want to trigger resize IF:
182
+ * - book animation is happening
183
+ * - book is in fullscreen (fullscreen is handled separately)
184
+ *
185
+ * @param { target: HTMLElement, contentRect: DOMRectReadOnly } entry
186
+ */
187
+ handleResize({ contentRect, target }) {
188
+ const startBrWidth = this._brWidth;
189
+ const startBrHeight = this._brHeight;
190
+ const { animating } = this.bookreader;
191
+
192
+ if (target === this.mainBRContainer) {
193
+ this._brWidth = contentRect.width;
194
+ this._brHeight = contentRect.height;
195
+ }
196
+
197
+ if (!startBrWidth && this._brWidth) {
198
+ // loading up, let's update side menus
199
+ this.initializeBookSubmenus();
200
+ }
201
+
202
+ const widthChange = startBrWidth !== this._brWidth;
203
+ const heightChange = startBrHeight !== this._brHeight;
204
+
205
+ if (!animating && (widthChange || heightChange)) {
206
+ this.bookreader?.resize();
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Manages Fullscreen behavior
212
+ * This makes sure that controls are _always_ in view
213
+ * We need this to accommodate LOAN BAR during fullscreen
214
+ */
215
+ manageFullScreenBehavior() {
216
+ if (!this.bookreader.options.enableFSLogoShortcut) {
217
+ return;
218
+ }
219
+
220
+ this.fullscreen = this.bookreader.isFullscreen();
221
+ this.dispatchEvent(new CustomEvent('fullscreenStateUpdated', { detail: { fullscreen: this.fullscreen }}));
222
+ if (this.fullscreen) {
223
+ this.addFullscreenShortcut();
224
+ } else {
225
+ this.deleteFullscreenShortcut();
226
+ }
227
+ }
228
+
229
+ /** Creates modal DOM & attaches to `<body>` */
230
+ setModalManager() {
231
+ /** @type {ModalManager} */
232
+ let modalManager = document.querySelector('modal-manager');
233
+ if (!modalManager) {
234
+ modalManager = /** @type {ModalManager} */(document.createElement('modal-manager'));
235
+ document.body.appendChild(modalManager);
236
+ }
237
+
238
+ this.modal = modalManager;
239
+ }
240
+
241
+ /**
242
+ * Instantiates books submenus & their update callbacks
243
+ *
244
+ * NOTE: we are doing our best to scope bookreader's instance.
245
+ * If your submenu provider uses a bookreader instance to read, manually
246
+ * manipulate BookReader, please update ia-bookreader's instance of it
247
+ * to keep it in sync.
248
+ */
249
+ initializeBookSubmenus() {
250
+ const providers = {
251
+ visualAdjustments: new VisualAdjustmentProvider({
252
+ ...this.baseProviderConfig,
253
+ /** Update menu contents */
254
+ onProviderChange: () => {
255
+ this.updateMenuContents();
256
+ },
257
+ }),
258
+ };
259
+
260
+ if (this.baseProviderConfig.item) {
261
+ // Share options currently rely on IA item metadata
262
+ providers.share = new SharingProvider(this.baseProviderConfig);
263
+ }
264
+
265
+ if (this.shouldShowDownloadsMenu()) {
266
+ providers.downloads = new DownloadProvider(this.baseProviderConfig);
267
+ }
268
+
269
+ // Note plugins will never be null-ish in runtime, but some of the unit tests
270
+ // stub BR with a nullish value there.
271
+ if (this.bookreader.options.plugins?.search?.enabled) {
272
+ providers.search = new SearchProvider({
273
+ ...this.baseProviderConfig,
274
+ /**
275
+ * Search specific menu updates
276
+ * @param {BookReader} brInstance
277
+ * @param {Partial<{ searchCanceled: boolean, openMenu: boolean }>} searchUpdates
278
+ */
279
+ onProviderChange: (brInstance = null, searchUpdates = {}) => {
280
+ if (brInstance) {
281
+ /** @type {BookReader} refresh br instance reference */
282
+ this.bookreader = brInstance;
283
+ }
284
+
285
+ this.updateMenuContents();
286
+
287
+ if (searchUpdates.openMenu === false) {
288
+ return;
289
+ }
290
+
291
+ if (this.isWideEnoughToOpenMenu && !searchUpdates?.searchCanceled) {
292
+ /* open side search menu */
293
+ setTimeout(() => {
294
+ this.updateSideMenu('search', 'open');
295
+ }, 0);
296
+ }
297
+ },
298
+ });
299
+ }
300
+
301
+ if (this.bookreader.options.enableBookmarks) {
302
+ providers.bookmarks = new BookmarksProvider({
303
+ ...this.baseProviderConfig,
304
+ onProviderChange: (bookmarks) => {
305
+ const method = Object.keys(bookmarks).length ? 'add' : 'remove';
306
+ this[`${method}MenuShortcut`]('bookmarks');
307
+ this.updateMenuContents();
308
+ },
309
+ });
310
+ }
311
+
312
+ // add shortcut for volumes if multipleBooksList exists
313
+ if (this.bookreader.options.enableMultipleBooks) {
314
+ providers.volumes = new ViewableFilesProvider({
315
+ ...this.baseProviderConfig,
316
+ onProviderChange: (brInstance = null, volumesUpdates = {}) => {
317
+ if (brInstance) {
318
+ /* refresh br instance reference */
319
+ this.bookreader = brInstance;
320
+ }
321
+ this.updateMenuContents();
322
+ if (this.isWideEnoughToOpenMenu) {
323
+ /* open side search menu */
324
+ setTimeout(() => {
325
+ this.updateSideMenu('volumes', 'open');
326
+ });
327
+ }
328
+ },
329
+ });
330
+ }
331
+
332
+ Object.assign(this.menuProviders, providers);
333
+ this.addMenuShortcut('search');
334
+ this.addMenuShortcut('volumes');
335
+ this.updateMenuContents();
336
+ }
337
+
338
+ /** gets element that houses the bookreader in light dom */
339
+ get mainBRContainer() {
340
+ return document.querySelector(this.bookreader?.el);
341
+ }
342
+
343
+ get baseProviderConfig() {
344
+ return {
345
+ baseHost: this.baseHost,
346
+ modal: this.modal,
347
+ sharedObserver: this.sharedObserver,
348
+ bookreader: this.bookreader,
349
+ item: this.item,
350
+ signedIn: this.signedIn,
351
+ isAdmin: this.isAdmin,
352
+ /** @type {function(BookReader, object): void} */
353
+ onProviderChange: () => {},
354
+ };
355
+ }
356
+
357
+ get isWideEnoughToOpenMenu() {
358
+ return this._brWidth >= 640;
359
+ }
360
+
361
+ /**
362
+ * Open side menu
363
+ * @param {string} menuId
364
+ * @param {('open'|'close'|'toggle')} action
365
+ */
366
+ updateSideMenu(menuId = '', action = 'open') {
367
+ if (!menuId) {
368
+ return;
369
+ }
370
+
371
+ this.openMenuName = menuId;
372
+
373
+ if (action === 'open') {
374
+ this.itemNav?.openShortcut(menuId);
375
+ } else if (action === 'toggle') {
376
+ this.itemNav?.toggleMenu();
377
+ }
378
+ }
379
+
380
+ /** Fullscreen Shortcut */
381
+ addFullscreenShortcut() {
382
+ this.menuShortcuts.push({
383
+ icon: this.fullscreenShortcut,
384
+ id: 'fullscreen',
385
+ });
386
+ this._sortMenuShortcuts();
387
+ }
388
+
389
+ deleteFullscreenShortcut() {
390
+ this.menuShortcuts = this.menuShortcuts
391
+ .filter(s => s.id !== 'fullscreen');
392
+ this._sortMenuShortcuts();
393
+ }
394
+
395
+ get fullscreenShortcut() {
396
+ return html`
397
+ <button
398
+ @click=${() => this.bookreader.exitFullScreen()}
399
+ title="Exit fullscreen view"
400
+ >${this.fullscreenBranding}</button>
401
+ `;
402
+ }
403
+ /** End Fullscreen Shortcut */
404
+
405
+ /**
406
+ * Sets order of menu and emits custom event when done
407
+ */
408
+ updateMenuContents() {
409
+ const availableMenus = sortBy(
410
+ Object.entries(this.menuProviders)
411
+ .filter(([id, menu]) => !!menu)
412
+ .filter(([id, menu]) => {
413
+ return id === 'downloads' ? this.shouldShowDownloadsMenu() : true;
414
+ }),
415
+ ([id, menu]) => {
416
+ const index = this.shortcutOrder.indexOf(id);
417
+ return index === -1 ? this.shortcutOrder.length : index;
418
+ },
419
+ ).map(([id, menu]) => menu);
420
+
421
+ if (this.shouldShowDownloadsMenu()) {
422
+ this.menuProviders.downloads?.update(this.downloadableTypes);
423
+ }
424
+
425
+ this.menuContents = availableMenus;
426
+ }
427
+
428
+ /**
429
+ * Confirms if we should show the downloads menu
430
+ * @returns {boolean}
431
+ */
432
+ shouldShowDownloadsMenu() {
433
+ if (!this.downloadableTypes.length) { return false; }
434
+ if (this.bookIsRestricted === false) { return true; }
435
+ if (this.isAdmin) { return true; }
436
+ const { user_loan_record = {} } = this.lendingStatus;
437
+ const hasNoLoanRecord = Array.isArray(user_loan_record); /* (bc PHP assoc. arrays) */
438
+
439
+ if (hasNoLoanRecord) { return false; }
440
+
441
+ const hasValidLoan = user_loan_record.type && (user_loan_record.type !== 'SESSION_LOAN');
442
+ return hasValidLoan;
443
+ }
444
+
445
+ /**
446
+ * Adds a provider object to the menuShortcuts array property if it isn't
447
+ * already added, then sorts menuShortcuts based on shortcutOrder.
448
+ *
449
+ * @param {string} menuId - a string matching the id property of a provider
450
+ */
451
+ addMenuShortcut(menuId) {
452
+ if (this.menuShortcuts.find((m) => m.id === menuId)) {
453
+ // menu is already there
454
+ return;
455
+ }
456
+
457
+ if (!this.menuProviders[menuId]) {
458
+ // no provider for this menu
459
+ return;
460
+ }
461
+
462
+ this.menuShortcuts.push(this.menuProviders[menuId]);
463
+ this._sortMenuShortcuts();
464
+ }
465
+
466
+ /**
467
+ * Sorts the menuShortcuts property by comparing each provider's id to
468
+ * the id in each iteration over the shortcutOrder array.
469
+ */
470
+ _sortMenuShortcuts() {
471
+ this.menuShortcuts = sortBy(
472
+ this.menuShortcuts,
473
+ (shortcut) => {
474
+ const index = this.shortcutOrder.indexOf(shortcut.id);
475
+ return index === -1 ? this.shortcutOrder.length : index;
476
+ },
477
+ );
478
+ }
479
+
480
+ /**
481
+ * Core bookreader event handler registry
482
+ *
483
+ * NOTE: we are trying to keep bookreader's instance in scope
484
+ * Please update ia-bookreader's instance reference of it to keep it current
485
+ */
486
+ _bindEventListeners() {
487
+ window.addEventListener('BookReader:PostInit', /** @param {CustomEvent} e */ (e) => {
488
+ this.bookreader = e.detail.props;
489
+ this.bookreader.shell = this;
490
+ this.bookReaderLoaded = true;
491
+ this.bookReaderCannotLoad = false;
492
+ this.loaded = true;
493
+ this.loadSharedObserver();
494
+ setTimeout(() => this.bookreader.resize(), 0);
495
+ });
496
+ window.addEventListener('BookReader:fullscreenToggled', /** @param {CustomEvent} event */ (event) => {
497
+ const brInstance = event.detail.props;
498
+ if (brInstance) {
499
+ this.bookreader = brInstance;
500
+ }
501
+ this.manageFullScreenBehavior();
502
+ }, { passive: true });
503
+ window.addEventListener('BookReader:ToggleSearchMenu', /** @param {CustomEvent} event */ (event) => {
504
+ this.updateSideMenu('search', 'toggle');
505
+ });
506
+ window.addEventListener('LendingFlow:PostInit', /** @param {CustomEvent} detail */ ({ detail }) => {
507
+ const {
508
+ downloadTypesAvailable, lendingStatus, isAdmin, previewType,
509
+ } = detail;
510
+ this.lendingInitialized = true;
511
+ this.downloadableTypes = downloadTypesAvailable;
512
+ this.lendingStatus = lendingStatus;
513
+ this.isAdmin = isAdmin;
514
+ this.bookReaderCannotLoad = previewType === 'singlePagePreview';
515
+ this.loaded = true;
516
+ });
517
+ window.addEventListener('BRJSIA:PostInit', /** @param {CustomEvent} detail */ ({ detail }) => {
518
+ const { isRestricted, downloadURLs } = detail;
519
+ this.bookReaderLoaded = true;
520
+ this.downloadableTypes = downloadURLs;
521
+ this.bookIsRestricted = isRestricted;
522
+ });
523
+ window.addEventListener('contextmenu', (e) => this._manageContextMenuVisibility(e), { capture: true });
524
+ }
525
+
526
+ /**
527
+ * @param {PointerEvent} e
528
+ **/
529
+ _manageContextMenuVisibility(e) {
530
+ const target = /** @type {HTMLElement} */(e.target);
531
+
532
+ window['archive_analytics']?.send_event(
533
+ 'BookReader',
534
+ `contextmenu-${this.bookIsRestricted ? 'restricted' : 'unrestricted'}`,
535
+ target?.classList?.value,
536
+ );
537
+ if (!this.bookIsRestricted) {
538
+ return;
539
+ }
540
+
541
+ const imagePane = target.classList.value.match(/BRscreen|BRpageimage/g);
542
+ if (!imagePane) {
543
+ return;
544
+ }
545
+
546
+ e.preventDefault();
547
+ return false;
548
+ }
549
+
550
+ get itemImage() {
551
+ const identifier = this.item?.metadata.identifier;
552
+ const url = `https://${this.baseHost}/services/img/${identifier}`;
553
+ return html`<img class="cover-img" src=${url} alt="cover image for ${identifier}">`;
554
+ }
555
+
556
+ get placeholder() {
557
+ return html`<div class="placeholder">${this.itemImage}</div>`;
558
+ }
559
+
560
+ render() {
561
+ return html`
562
+ <iaux-item-navigator
563
+ ?viewportInFullscreen=${this.fullscreen}
564
+ .basehost=${this.baseHost}
565
+ .item=${this.item}
566
+ .modal=${this.modal}
567
+ .loaded=${this.loaded}
568
+ .sharedObserver=${this.sharedObserver}
569
+ ?signedIn=${this.signedIn}
570
+ .menuShortcuts=${this.menuShortcuts}
571
+ .menuContents=${this.menuContents}
572
+ .openMenu=${this.openMenuName}
573
+ >
574
+ <div slot="header">
575
+ <slot name="header"></slot>
576
+ </div>
577
+ <div slot="main">
578
+ ${this.bookReaderCannotLoad ? this.placeholder : html`<slot name="main"></slot>`}
579
+ </div>
580
+ </iaux-item-navigator>
581
+ `;
582
+ }
583
+
584
+ static get styles() {
585
+ return css`
586
+ :host {
587
+ display: block;
588
+ --primaryBGColor: var(--black, #000);
589
+ --secondaryBGColor: #222;
590
+ --tertiaryBGColor: #333;
591
+ --primaryTextColor: var(--white, #fff);
592
+ --primaryCTAFill: #194880;
593
+ --primaryCTABorder: #c5d1df;
594
+ --secondaryCTAFill: #333;
595
+ --secondaryCTABorder: #999;
596
+ --primaryErrorCTAFill: #e51c26;
597
+ --primaryErrorCTABorder: #f8c6c8;
598
+ background-color: var(--primaryBGColor);
599
+ position: relative;
600
+ }
601
+
602
+ :host([fullscreen]),
603
+ iaux-item-navigator[viewportinfullscreen] {
604
+ position: fixed;
605
+ inset: 0;
606
+ height: 100%;
607
+ min-height: unset;
608
+ }
609
+
610
+ div[slot="header"],
611
+ div[slot="main"] {
612
+ display: flex;
613
+ width: 100%;
614
+ }
615
+
616
+ slot {
617
+ display: block;
618
+ flex: 1;
619
+ }
620
+
621
+ slot,
622
+ slot > * {
623
+ display: block;
624
+ height: inherit;
625
+ width: inherit;
626
+ }
627
+ .placeholder {
628
+ display: flex;
629
+ align-items: center;
630
+ justify-content: center;
631
+ flex-direction: column;
632
+ margin: 5%;
633
+ }
634
+ .cover-img {
635
+ max-height: 300px;
636
+ }
637
+
638
+ iaux-item-navigator {
639
+ display: block;
640
+ width: 100%;
641
+ min-height: var(--br-height, inherit);
642
+ height: var(--br-height, 100%);
643
+ color: var(--primaryTextColor);
644
+ --menuButtonLabelDisplay: block;
645
+ --menuWidth: 320px;
646
+ --menuSliderBg: var(--secondaryBGColor);
647
+ --activeButtonBg: var(--tertiaryBGColor);
648
+ --subpanelRightBorderColor: var(--secondaryCTABorder);
649
+ --animationTiming: 100ms;
650
+ --iconFillColor: var(--primaryTextColor);
651
+ --iconStrokeColor: var(--primaryTextColor);
652
+ --menuSliderHeaderIconHeight: 2rem;
653
+ --menuSliderHeaderIconWidth: 2rem;
654
+ --iconWidth: 2.4rem;
655
+ --iconHeight: 2.4rem;
656
+ --shareLinkColor: var(--primaryTextColor);
657
+ --shareIconBorder: var(--primaryTextColor);
658
+ --shareIconBg: var(--secondaryBGColor);
659
+ --activityIndicatorLoadingDotColor: var(--primaryTextColor);
660
+ --activityIndicatorLoadingRingColor: var(--primaryTextColor);
661
+ }
662
+ `;
663
+ }
664
+ }
665
+
666
+ window.customElements.define("ia-bookreader", IaBookReader);
@@ -0,0 +1,27 @@
1
+ import { html } from 'lit';
2
+ import { iauxShareIcon } from '@internetarchive/ia-item-navigator/dist/src/menus/share-panel.js';
3
+ import '@internetarchive/ia-item-navigator/dist/src/menus/share-panel.js';
4
+
5
+ export default class SharingProvider {
6
+ constructor({
7
+ item,
8
+ baseHost,
9
+ bookreader,
10
+ }) {
11
+ const { identifier, creator, title } = item?.metadata;
12
+ const creatorToUse = Array.isArray(creator) ? creator[0] : creator;
13
+ const subPrefix = bookreader.subPrefix || '';
14
+ const label = `Share this book`;
15
+ this.icon = html`${iauxShareIcon}`;
16
+ this.label = label;
17
+ this.id = 'share';
18
+ this.component = html`<iaux-in-share-panel
19
+ .identifier=${identifier}
20
+ .type=${`book`}
21
+ .creator=${creatorToUse}
22
+ .description=${title}
23
+ .baseHost=${baseHost}
24
+ .fileSubPrefix=${subPrefix}
25
+ ></iaux-in-share-panel>`;
26
+ }
27
+ }