@nypl/web-reader 4.3.0 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +0 -15
  2. package/dist/{esm/index.css → index.css} +3 -1
  3. package/dist/index.css.map +1 -0
  4. package/dist/index.d.ts +532 -0
  5. package/dist/index.js +9381 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +9378 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/injectable-html-styles/ReadiumCSS-after.css +488 -2
  10. package/dist/injectable-html-styles/ReadiumCSS-after.css.map +1 -7
  11. package/dist/injectable-html-styles/ReadiumCSS-after.d.ts +2 -0
  12. package/dist/injectable-html-styles/ReadiumCSS-before.css +648 -2
  13. package/dist/injectable-html-styles/ReadiumCSS-before.css.map +1 -7
  14. package/dist/injectable-html-styles/ReadiumCSS-before.d.ts +2 -0
  15. package/dist/injectable-html-styles/ReadiumCSS-default.css +141 -2
  16. package/dist/injectable-html-styles/ReadiumCSS-default.css.map +1 -7
  17. package/dist/injectable-html-styles/ReadiumCSS-default.d.ts +2 -0
  18. package/package.json +9 -24
  19. package/dist/cjs/index.css +0 -2
  20. package/dist/cjs/index.css.map +0 -7
  21. package/dist/cjs/index.js +0 -340
  22. package/dist/cjs/index.js.map +0 -7
  23. package/dist/esm/index.css.map +0 -7
  24. package/dist/esm/index.js +0 -42173
  25. package/dist/esm/index.js.map +0 -7
  26. package/dist/types/HtmlReader/effects.d.ts +0 -22
  27. package/dist/types/HtmlReader/index.d.ts +0 -3
  28. package/dist/types/HtmlReader/lib.d.ts +0 -107
  29. package/dist/types/HtmlReader/reducer.d.ts +0 -8
  30. package/dist/types/HtmlReader/types.d.ts +0 -116
  31. package/dist/types/HtmlReader/useIframeLinkClick.d.ts +0 -4
  32. package/dist/types/HtmlReader/useLocationQuery.d.ts +0 -8
  33. package/dist/types/HtmlReader/useResource.d.ts +0 -14
  34. package/dist/types/HtmlReader/useUpdateCSS.d.ts +0 -6
  35. package/dist/types/HtmlReader/useUpdateScroll.d.ts +0 -6
  36. package/dist/types/HtmlReader/useWindowResize.d.ts +0 -7
  37. package/dist/types/PdfReader/ChakraPage.d.ts +0 -3
  38. package/dist/types/PdfReader/ScrollPage.d.ts +0 -12
  39. package/dist/types/PdfReader/addTocToManifest.d.ts +0 -10
  40. package/dist/types/PdfReader/index.d.ts +0 -12
  41. package/dist/types/PdfReader/lib.d.ts +0 -26
  42. package/dist/types/PdfReader/reducer.d.ts +0 -3
  43. package/dist/types/PdfReader/types.d.ts +0 -61
  44. package/dist/types/PdfReader/useMeasure.d.ts +0 -7
  45. package/dist/types/Readium/Injectable.d.ts +0 -11
  46. package/dist/types/Readium/Locator.d.ts +0 -20
  47. package/dist/types/WebpubManifestTypes/ConformsTo.d.ts +0 -3
  48. package/dist/types/WebpubManifestTypes/Contributor.d.ts +0 -17
  49. package/dist/types/WebpubManifestTypes/EpubExtension.d.ts +0 -47
  50. package/dist/types/WebpubManifestTypes/LanguageMap.d.ts +0 -3
  51. package/dist/types/WebpubManifestTypes/Metadata.d.ts +0 -47
  52. package/dist/types/WebpubManifestTypes/OPDSLink.d.ts +0 -63
  53. package/dist/types/WebpubManifestTypes/PresentationHints.d.ts +0 -53
  54. package/dist/types/WebpubManifestTypes/ReadiumLink.d.ts +0 -58
  55. package/dist/types/WebpubManifestTypes/Subject.d.ts +0 -16
  56. package/dist/types/WebpubManifestTypes/WebpubManifest.d.ts +0 -14
  57. package/dist/types/constants.d.ts +0 -37
  58. package/dist/types/index.d.ts +0 -17
  59. package/dist/types/types.d.ts +0 -123
  60. package/dist/types/ui/Button.d.ts +0 -9
  61. package/dist/types/ui/ErrorBoundary.d.ts +0 -16
  62. package/dist/types/ui/Footer.d.ts +0 -9
  63. package/dist/types/ui/Header.d.ts +0 -9
  64. package/dist/types/ui/HtmlSettings.d.ts +0 -9
  65. package/dist/types/ui/LoadingSkeleton.d.ts +0 -9
  66. package/dist/types/ui/PageButton.d.ts +0 -7
  67. package/dist/types/ui/PdfSettings.d.ts +0 -8
  68. package/dist/types/ui/SettingsButton.d.ts +0 -5
  69. package/dist/types/ui/TableOfContent.d.ts +0 -7
  70. package/dist/types/ui/ToggleButton.d.ts +0 -14
  71. package/dist/types/ui/ToggleGroup.d.ts +0 -8
  72. package/dist/types/ui/hooks/useColorModeValue.d.ts +0 -7
  73. package/dist/types/ui/hooks/useContainerWidth.d.ts +0 -6
  74. package/dist/types/ui/hooks/useEventListener.d.ts +0 -8
  75. package/dist/types/ui/hooks/useFullScreen.d.ts +0 -7
  76. package/dist/types/ui/icons/Continuous.d.ts +0 -4
  77. package/dist/types/ui/icons/Day.d.ts +0 -4
  78. package/dist/types/ui/icons/EnlargeFont.d.ts +0 -4
  79. package/dist/types/ui/icons/Night.d.ts +0 -4
  80. package/dist/types/ui/icons/Paginated.d.ts +0 -4
  81. package/dist/types/ui/icons/Previous.d.ts +0 -4
  82. package/dist/types/ui/icons/ReaderSettings.d.ts +0 -4
  83. package/dist/types/ui/icons/ReduceFont.d.ts +0 -4
  84. package/dist/types/ui/icons/Reset.d.ts +0 -4
  85. package/dist/types/ui/icons/Sepia.d.ts +0 -4
  86. package/dist/types/ui/icons/TableOfContents.d.ts +0 -4
  87. package/dist/types/ui/icons/ToggleFullScreen.d.ts +0 -4
  88. package/dist/types/ui/icons/ToggleFullScreenExit.d.ts +0 -4
  89. package/dist/types/ui/icons/index.d.ts +0 -14
  90. package/dist/types/ui/manager.d.ts +0 -9
  91. package/dist/types/ui/menu/index.d.ts +0 -10
  92. package/dist/types/ui/menu/menu.d.ts +0 -76
  93. package/dist/types/ui/menu/use-menu.d.ts +0 -2510
  94. package/dist/types/ui/nypl-base-theme/components/button.d.ts +0 -94
  95. package/dist/types/ui/nypl-base-theme/components/checkbox.d.ts +0 -41
  96. package/dist/types/ui/nypl-base-theme/components/form-error.d.ts +0 -14
  97. package/dist/types/ui/nypl-base-theme/components/form-label.d.ts +0 -14
  98. package/dist/types/ui/nypl-base-theme/components/form.d.ts +0 -15
  99. package/dist/types/ui/nypl-base-theme/components/input.d.ts +0 -107
  100. package/dist/types/ui/nypl-base-theme/components/text-area.d.ts +0 -34
  101. package/dist/types/ui/nypl-base-theme/foundations/breakpoints.d.ts +0 -8
  102. package/dist/types/ui/nypl-base-theme/foundations/colors.d.ts +0 -3
  103. package/dist/types/ui/nypl-base-theme/foundations/global.d.ts +0 -13
  104. package/dist/types/ui/nypl-base-theme/foundations/radii.d.ts +0 -12
  105. package/dist/types/ui/nypl-base-theme/foundations/spacing.d.ts +0 -49
  106. package/dist/types/ui/nypl-base-theme/foundations/typography.d.ts +0 -10
  107. package/dist/types/ui/nypl-base-theme/index.d.ts +0 -7
  108. package/dist/types/ui/nypl-base-theme/types.d.ts +0 -1
  109. package/dist/types/ui/theme/components/alert.d.ts +0 -24
  110. package/dist/types/ui/theme/components/button.d.ts +0 -93
  111. package/dist/types/ui/theme/components/text.d.ts +0 -20
  112. package/dist/types/ui/theme/foundations/colors.d.ts +0 -3
  113. package/dist/types/ui/theme/foundations/fonts.d.ts +0 -3
  114. package/dist/types/ui/theme/foundations/typography.d.ts +0 -6
  115. package/dist/types/ui/theme/index.d.ts +0 -12
  116. package/dist/types/ui/theme/types.d.ts +0 -1
  117. package/dist/types/useWebReader.d.ts +0 -7
  118. package/dist/types/utils/fetch.d.ts +0 -4
  119. package/dist/types/utils/getColor.d.ts +0 -2
  120. package/dist/types/utils/localstorage.d.ts +0 -17
package/README.md CHANGED
@@ -51,7 +51,6 @@ const ReaderPage = ({ manifestUrl }) => {
51
51
  ```
52
52
 
53
53
  - [More React examples](/example/index.tsx) - Includes examples that render EPUB2 & EPUB3 based webpubs, remote hosted webpubs, and PDFs
54
- - [Encrypted example](/example/axisnow-encrypted.tsx) - How to pass an content decryptor to the web-reader to render encrypted content
55
54
  - [usePDFReader hook example](/example/use-pdf-reader.tsx) - Useful for instances when you know you're only going to be using the web-reader to open PDFs
56
55
  - [useHTMLReader hook example](/example/use-html-reader.tsx) - Useful for cases when you know you're only going to be using the web-reader to read EPUBs
57
56
  - [Real-world example: Open eBooks Web](https://github.com/NYPL/ereading-clients/blob/staging/apps/oew/src/components/theme-ui/WebReader.tsx) - NYPL application for children to read books on the web. This demonstrates how encrypted AxisNow content is passed to the web-reader.
@@ -255,16 +254,6 @@ The web reader does support DRM via two possible routes:
255
254
  1. The default Readium suggested method is to have a server-side "streamer" between the content server and the application. This server would fetch the encrypted DRM content, decrypt it, and then serve the decrypted assets individually to the client alongside a webpub manifest pointing to these decrypted assets. One example of such a streamer is [readium/r2-streamer-js](https://github.com/readium/r2-streamer-js).
256
255
  1. If decryption cannot be performed in a streamer, the web-reader can support client-side decryption of licensed content. This is done by passing a `getContent` function to either the `<WebReader>` component or the `useWebReader` hook. It has the type signature `(resourceUrl: string) => Promise<string>`, and can thus be used to fetch and decrypt (or otherwise manipulate) content before it is passed to the iframe for rendering.
257
256
 
258
- The `AxisNow Encrypted EPUB` example shows how this is done using the private NYPL AxisNow decryptor. The AxisNow scheme is a specific DRM technique not publicly available and the repo and code for the decryptor cannot be shared. Thus this example will not work for the public, but you can read the example code to see how we use the private `Decryptor` package to:
259
-
260
- - Create a Web Worker using [Comlink](https://github.com/GoogleChromeLabs/comlink) that will perform the fetching and decryption. This should help keep the main thread free while those heavy tasks are performed.
261
- - Fetch content from the network
262
- - Decrypt the HTML content
263
- - Search for embedded CSS and image assets
264
- - Fetch those assets and decrypt them
265
- - Re-embed the decrypted CSS and image assets as Object URLs into the decrypted HTML document
266
- - Return the HTML string with fully decrypted reources for the web-reader to render in the iframe
267
-
268
257
  ## Getting Started
269
258
 
270
259
  These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [Publishing to NPM](#publishing-to-npm) for notes on how to publish a new version to NPM.
@@ -273,8 +262,6 @@ These instructions will get you a copy of the project up and running on your loc
273
262
 
274
263
  1. Before getting started, be sure to run `npm install`.
275
264
 
276
- If you are internal to NYPL you can be added to the private `@nypl-simplified-packages/axisnow-access-control-web` package, which is required in order to open the AxisNow Encrypted EPUB example. If you decide to install this package, you'll also need to generate a Personal Access Token in GitHub with `read` permissions and run `GH_PACKAGE_AUTH_TOKEN=<your-token-here> npm install`.
277
-
278
265
  2. In order to open any of the PDF examples in the Example App, you'll need to allow urls in a `WebpubManifest` to be proxied. This is done by passing a `proxyUrl` to the `<WebReader>` component. In order to do that, you must have a proxy running somewhere.
279
266
 
280
267
  We have set up a small express-based CORS proxy that can be run for local development.
@@ -283,8 +270,6 @@ We have set up a small express-based CORS proxy that can be run for local develo
283
270
  - Pass the proxy url to the example app by setting the following env var in a `.env` file at the root of the project: `CORS_PROXY_URL="http://localhost:3001/?requestUrl="`.
284
271
  - In a separate terminal session, start the example app: `npm run example`.
285
272
 
286
- 3. In order to open the AxisNow Encrypted EPUB example (`/html/axisnow-encrypted`), you will need to have `process.env.VAULT_UUID` and `process.env.ISBN` set in your `.env` file. Read [example/README.txt](/example/README.txt) for more info.
287
-
288
273
  ### Running the Example App
289
274
 
290
275
  To run the example app for local development:
@@ -158,4 +158,6 @@
158
158
  .annotationLayer .fileAttachmentAnnotation {
159
159
  cursor: pointer;
160
160
  }
161
- /*# sourceMappingURL=index.css.map */
161
+
162
+ /* src/PdfReader/pdf.css */
163
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/react-pdf/dist/esm/Page/AnnotationLayer.css"],"sourcesContent":["/* Copyright 2014 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.annotationLayer section {\n position: absolute;\n}\n\n.annotationLayer .linkAnnotation > a,\n.annotationLayer .buttonWidgetAnnotation.pushButton > a {\n position: absolute;\n font-size: 1em;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n}\n\n.annotationLayer .linkAnnotation > a:hover,\n.annotationLayer .buttonWidgetAnnotation.pushButton > a:hover {\n opacity: 0.2;\n background: #ff0;\n box-shadow: 0px 2px 10px #ff0;\n}\n\n.annotationLayer .textAnnotation img {\n position: absolute;\n cursor: pointer;\n}\n\n.annotationLayer .textWidgetAnnotation input,\n.annotationLayer .textWidgetAnnotation textarea,\n.annotationLayer .choiceWidgetAnnotation select,\n.annotationLayer .buttonWidgetAnnotation.checkBox input,\n.annotationLayer .buttonWidgetAnnotation.radioButton input {\n background-color: rgba(0, 54, 255, 0.13);\n border: 1px solid transparent;\n box-sizing: border-box;\n font-size: 9px;\n height: 100%;\n margin: 0;\n padding: 0 3px;\n vertical-align: top;\n width: 100%;\n}\n\n.annotationLayer .choiceWidgetAnnotation select option {\n padding: 0;\n}\n\n.annotationLayer .buttonWidgetAnnotation.radioButton input {\n border-radius: 50%;\n}\n\n.annotationLayer .textWidgetAnnotation textarea {\n font: message-box;\n font-size: 9px;\n resize: none;\n}\n\n.annotationLayer .textWidgetAnnotation input[disabled],\n.annotationLayer .textWidgetAnnotation textarea[disabled],\n.annotationLayer .choiceWidgetAnnotation select[disabled],\n.annotationLayer .buttonWidgetAnnotation.checkBox input[disabled],\n.annotationLayer .buttonWidgetAnnotation.radioButton input[disabled] {\n background: none;\n border: 1px solid transparent;\n cursor: not-allowed;\n}\n\n.annotationLayer .textWidgetAnnotation input:hover,\n.annotationLayer .textWidgetAnnotation textarea:hover,\n.annotationLayer .choiceWidgetAnnotation select:hover,\n.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,\n.annotationLayer .buttonWidgetAnnotation.radioButton input:hover {\n border: 1px solid #000;\n}\n\n.annotationLayer .textWidgetAnnotation input:focus,\n.annotationLayer .textWidgetAnnotation textarea:focus,\n.annotationLayer .choiceWidgetAnnotation select:focus {\n background: none;\n border: 1px solid transparent;\n}\n\n.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,\n.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,\n.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before {\n background-color: #000;\n content: '';\n display: block;\n position: absolute;\n}\n\n.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,\n.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after {\n height: 80%;\n left: 45%;\n width: 1px;\n}\n\n.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before {\n transform: rotate(45deg);\n}\n\n.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after {\n transform: rotate(-45deg);\n}\n\n.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before {\n border-radius: 50%;\n height: 50%;\n left: 30%;\n top: 20%;\n width: 50%;\n}\n\n.annotationLayer .textWidgetAnnotation input.comb {\n font-family: monospace;\n padding-left: 2px;\n padding-right: 0;\n}\n\n.annotationLayer .textWidgetAnnotation input.comb:focus {\n /*\n * Letter spacing is placed on the right side of each character. Hence, the\n * letter spacing of the last character may be placed outside the visible\n * area, causing horizontal scrolling. We avoid this by extending the width\n * when the element has focus and revert this when it loses focus.\n */\n width: 115%;\n}\n\n.annotationLayer .buttonWidgetAnnotation.checkBox input,\n.annotationLayer .buttonWidgetAnnotation.radioButton input {\n appearance: none;\n padding: 0;\n}\n\n.annotationLayer .popupWrapper {\n position: absolute;\n width: 20em;\n}\n\n.annotationLayer .popup {\n position: absolute;\n z-index: 200;\n max-width: 20em;\n background-color: #FFFF99;\n box-shadow: 0px 2px 5px #888;\n border-radius: 2px;\n padding: 6px;\n margin-left: 5px;\n cursor: pointer;\n font: message-box;\n font-size: 9px;\n word-wrap: break-word;\n}\n\n.annotationLayer .popup > * {\n font-size: 9px;\n}\n\n.annotationLayer .popup h1 {\n display: inline-block;\n}\n\n.annotationLayer .popup span {\n display: inline-block;\n margin-left: 5px;\n}\n\n.annotationLayer .popup p {\n border-top: 1px solid #333;\n margin-top: 2px;\n padding-top: 2px;\n}\n\n.annotationLayer .highlightAnnotation,\n.annotationLayer .underlineAnnotation,\n.annotationLayer .squigglyAnnotation,\n.annotationLayer .strikeoutAnnotation,\n.annotationLayer .freeTextAnnotation,\n.annotationLayer .lineAnnotation svg line,\n.annotationLayer .squareAnnotation svg rect,\n.annotationLayer .circleAnnotation svg ellipse,\n.annotationLayer .polylineAnnotation svg polyline,\n.annotationLayer .polygonAnnotation svg polygon,\n.annotationLayer .caretAnnotation,\n.annotationLayer .inkAnnotation svg polyline,\n.annotationLayer .stampAnnotation,\n.annotationLayer .fileAttachmentAnnotation {\n cursor: pointer;\n}\n"],"mappings":";AAeA;AACE;AAAA;AAGF;AAAA;AAEE;AACA;AACA;AACA;AACA;AACA;AAAA;AAGF;AAAA;AAEE;AACA;AACA;AAAA;AAGF;AACE;AACA;AAAA;AAGF;AAAA;AAAA;AAAA;AAAA;AAKE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AACA;AACA;AAAA;AAGF;AAAA;AAAA;AAAA;AAAA;AAKE;AACA;AACA;AAAA;AAGF;AAAA;AAAA;AAAA;AAAA;AAKE;AAAA;AAGF;AAAA;AAAA;AAGE;AACA;AAAA;AAGF;AAAA;AAAA;AAGE;AACA;AACA;AACA;AAAA;AAGF;AAAA;AAEE;AACA;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AACA;AACA;AACA;AACA;AAAA;AAGF;AACE;AACA;AACA;AAAA;AAGF;AAOE;AAAA;AAGF;AAAA;AAEE;AACA;AAAA;AAGF;AACE;AACA;AAAA;AAGF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AACA;AAAA;AAGF;AACE;AACA;AACA;AAAA;AAGF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcE;AAAA;","names":[]}
@@ -0,0 +1,532 @@
1
+ import { FC } from 'react';
2
+
3
+ interface Injectable {
4
+ type: string;
5
+ url?: string;
6
+ r2after?: boolean;
7
+ r2before?: boolean;
8
+ r2default?: boolean;
9
+ fontFamily?: string;
10
+ systemFont?: boolean;
11
+ appearance?: string;
12
+ async?: boolean;
13
+ }
14
+
15
+ interface Locator {
16
+ href: string;
17
+ type?: string;
18
+ title?: string;
19
+ locations: Locations;
20
+ text?: LocatorText;
21
+ }
22
+ interface LocatorText {
23
+ after?: string;
24
+ before?: string;
25
+ highlight?: string;
26
+ }
27
+ interface Locations {
28
+ fragment?: string;
29
+ progression?: number;
30
+ position?: number;
31
+ totalProgression?: number;
32
+ remainingPositions?: number;
33
+ totalRemainingPositions?: number;
34
+ }
35
+
36
+ declare const ReadiumWebpubContext = "http://readium.org/webpub/default.jsonld";
37
+ declare const IS_DEV: boolean;
38
+ declare const HEADER_HEIGHT = 48;
39
+ declare const FOOTER_HEIGHT = 48;
40
+ declare const CHROME_HEIGHT: number;
41
+ declare const DEFAULT_HEIGHT: string;
42
+ declare const DEFAULT_SHOULD_GROW_WHEN_SCROLLING = true;
43
+ declare const DEFAULT_SETTINGS: ReaderSettings;
44
+ declare const FONT_DETAILS: {
45
+ publisher: {
46
+ heading: string;
47
+ body: string;
48
+ token: string;
49
+ fontWeight: string;
50
+ };
51
+ serif: {
52
+ heading: string;
53
+ body: string;
54
+ token: string;
55
+ fontWeight: string;
56
+ };
57
+ 'sans-serif': {
58
+ heading: string;
59
+ body: string;
60
+ token: string;
61
+ fontWeight: string;
62
+ };
63
+ 'open-dyslexic': {
64
+ heading: string;
65
+ body: string;
66
+ token: string;
67
+ fontWeight: string;
68
+ };
69
+ };
70
+ declare const LOCAL_STORAGE_SETTINGS_KEY = "web-reader-settings";
71
+ declare const LOCAL_STORAGE_LOCATIONS_KEY = "web-reader-locations";
72
+
73
+ declare const WebpubPdfConformsTo = "http://librarysimplified.org/terms/profiles/pdf";
74
+ declare const EpubConformsTo = "https://readium.org/webpub-manifest/profiles/epub";
75
+ declare type ConformsTo = typeof WebpubPdfConformsTo | typeof EpubConformsTo;
76
+
77
+ interface EPUBExtensionLinkProperties {
78
+ /**
79
+ * Identifies content contained in the linked resource, that cannot be strictly identified using a media type.
80
+ */
81
+ contains?: ('mathml' | 'onix' | 'remote-resources' | 'js' | 'svg' | 'xmp')[];
82
+ /**
83
+ * Hints how the layout of the resource should be presented
84
+ */
85
+ layout?: 'fixed' | 'reflowable';
86
+ /**
87
+ * Indicates that a resource is encrypted/obfuscated and provides relevant information for decryption
88
+ */
89
+ encrypted?: {
90
+ /**
91
+ * Identifies the algorithm used to encrypt the resource
92
+ */
93
+ algorithm: string;
94
+ /**
95
+ * Compression method used on the resource
96
+ */
97
+ compression?: string;
98
+ /**
99
+ * Original length of the resource in bytes before compression and/or encryption
100
+ */
101
+ originalLength?: number;
102
+ /**
103
+ * Identifies the encryption profile used to encrypt the resource
104
+ */
105
+ profile?: string;
106
+ /**
107
+ * Identifies the encryption scheme used to encrypt the resource
108
+ */
109
+ scheme?: string;
110
+ [k: string]: unknown;
111
+ };
112
+ [k: string]: unknown;
113
+ }
114
+ interface EPUBExtensionMetadata {
115
+ presentation?: {
116
+ /**
117
+ * Hints how the layout of the resource should be presented
118
+ */
119
+ layout?: 'fixed' | 'reflowable';
120
+ [k: string]: unknown;
121
+ };
122
+ [k: string]: unknown;
123
+ }
124
+
125
+ interface OPDSLinkProperties {
126
+ /**
127
+ * Provide a hint about the expected number of items returned
128
+ */
129
+ numberOfItems?: number;
130
+ /**
131
+ * The price of a publication is tied to its acquisition link
132
+ */
133
+ price?: {
134
+ value: number;
135
+ currency: 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UZS' | 'VEF' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XBA' | 'XBB' | 'XBC' | 'XBD' | 'XCD' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'XSU' | 'XTS' | 'XUA' | 'XXX' | 'YER' | 'ZAR' | 'ZMW' | 'ZWL';
136
+ [k: string]: unknown;
137
+ };
138
+ /**
139
+ * Indirect acquisition provides a hint for the expected media type that will be acquired after additional steps
140
+ */
141
+ indirectAcquisition?: OPDSAcquisitionObject[];
142
+ /**
143
+ * Library-specific feature for unavailable books that support a hold list
144
+ */
145
+ holds?: {
146
+ total?: number;
147
+ position?: number;
148
+ [k: string]: unknown;
149
+ };
150
+ /**
151
+ * Library-specific feature that contains information about the copies that a library has acquired
152
+ */
153
+ copies?: {
154
+ total?: number;
155
+ available?: number;
156
+ [k: string]: unknown;
157
+ };
158
+ /**
159
+ * Indicates the availability of a given resource
160
+ */
161
+ availability?: {
162
+ state: 'available' | 'unavailable' | 'reserved' | 'ready';
163
+ /**
164
+ * Timestamp for the previous state change
165
+ */
166
+ since?: ({
167
+ [k: string]: unknown;
168
+ } | {
169
+ [k: string]: unknown;
170
+ }) & string;
171
+ /**
172
+ * Timestamp for the next state change
173
+ */
174
+ until?: ({
175
+ [k: string]: unknown;
176
+ } | {
177
+ [k: string]: unknown;
178
+ }) & string;
179
+ [k: string]: unknown;
180
+ };
181
+ [k: string]: unknown;
182
+ }
183
+ interface OPDSAcquisitionObject {
184
+ type: string;
185
+ child?: OPDSAcquisitionObject[];
186
+ [k: string]: unknown;
187
+ }
188
+
189
+ interface PresentationHintsLinkProperties {
190
+ /**
191
+ * Specifies whether or not the parts of a linked resource that flow out of the viewport are clipped.
192
+ */
193
+ clipped?: boolean;
194
+ /**
195
+ * Specifies constraints for the presentation of a linked resource within the viewport.
196
+ */
197
+ fit?: 'contain' | 'cover' | 'width' | 'height';
198
+ /**
199
+ * Suggested orientation for the device when displaying the linked resource.
200
+ */
201
+ orientation?: 'auto' | 'landscape' | 'portrait';
202
+ /**
203
+ * Indicates how the linked resource should be displayed in a reading environment that displays synthetic spreads.
204
+ */
205
+ page?: 'left' | 'right' | 'center';
206
+ /**
207
+ * Indicates the condition to be met for the linked resource to be rendered within a synthetic spread.
208
+ */
209
+ spread?: 'auto' | 'both' | 'none' | 'landscape';
210
+ [k: string]: unknown;
211
+ }
212
+
213
+ interface ReadiumLink {
214
+ /**
215
+ * URI or URI template of the linked resource
216
+ */
217
+ href: string;
218
+ /**
219
+ * MIME type of the linked resource
220
+ */
221
+ type?: string;
222
+ /**
223
+ * Indicates that a URI template is used in href
224
+ */
225
+ templated?: boolean;
226
+ /**
227
+ * Title of the linked resource
228
+ */
229
+ title?: string;
230
+ /**
231
+ * Relation between the linked resource and its containing collection
232
+ */
233
+ rel?: string | string[];
234
+ /**
235
+ * Properties associated to the linked resource
236
+ */
237
+ properties?: OPDSLinkProperties & EPUBExtensionLinkProperties & PresentationHintsLinkProperties;
238
+ /**
239
+ * Height of the linked resource in pixels
240
+ */
241
+ height?: number;
242
+ /**
243
+ * Width of the linked resource in pixels
244
+ */
245
+ width?: number;
246
+ /**
247
+ * Bitrate of the linked resource in kbps
248
+ */
249
+ bitrate?: number;
250
+ /**
251
+ * Length of the linked resource in seconds
252
+ */
253
+ duration?: number;
254
+ /**
255
+ * Expected language of the linked resource
256
+ */
257
+ language?: string | string[];
258
+ /**
259
+ * Alternate resources for the linked resource
260
+ */
261
+ alternate?: ReadiumLink[];
262
+ /**
263
+ * Resources that are children of the linked resource, in the context of a given collection role
264
+ */
265
+ children?: ReadiumLink[];
266
+ [k: string]: unknown;
267
+ }
268
+
269
+ interface ContributorObject {
270
+ name: string | {
271
+ /**
272
+ * This interface was referenced by `undefined`'s JSON-Schema definition
273
+ * via the `patternProperty` "^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUse>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUse2>x(-[A-Za-z0-9]{1,8})+))$".
274
+ */
275
+ [k: string]: string;
276
+ };
277
+ identifier?: string;
278
+ sortAs?: string;
279
+ role?: string | string[];
280
+ position?: number;
281
+ links?: ReadiumLink[];
282
+ [k: string]: unknown;
283
+ }
284
+ declare type Contributor = string | (string | ContributorObject)[] | ContributorObject;
285
+
286
+ declare type LanguageMap = string | {
287
+ [k: string]: string;
288
+ };
289
+
290
+ interface SubjectObject {
291
+ name: string | {
292
+ /**
293
+ * This interface was referenced by `undefined`'s JSON-Schema definition
294
+ * via the `patternProperty` "^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUse>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUse2>x(-[A-Za-z0-9]{1,8})+))$".
295
+ */
296
+ [k: string]: string;
297
+ };
298
+ sortAs?: string;
299
+ code?: string;
300
+ scheme?: string;
301
+ links?: ReadiumLink[];
302
+ [k: string]: unknown;
303
+ }
304
+ declare type Subject = string | (string | SubjectObject)[] | SubjectObject;
305
+
306
+ interface Metadata extends Contributors, EPUBExtensionMetadata {
307
+ identifier?: string;
308
+ '@type'?: string;
309
+ conformsTo?: ConformsTo;
310
+ title: LanguageMap;
311
+ subtitle?: LanguageMap;
312
+ modified?: string;
313
+ published?: {
314
+ [k: string]: unknown;
315
+ } & string;
316
+ /**
317
+ * The language must be a valid BCP 47 tag.
318
+ */
319
+ language?: string | string[];
320
+ sortAs?: LanguageMap;
321
+ subject?: Subject;
322
+ readingProgression?: 'rtl' | 'ltr' | 'ttb' | 'btt' | 'auto';
323
+ description?: string;
324
+ duration?: number;
325
+ numberOfPages?: number;
326
+ belongsTo?: {
327
+ collection?: Contributor;
328
+ series?: Contributor;
329
+ [k: string]: unknown;
330
+ };
331
+ [k: string]: unknown;
332
+ }
333
+ interface Contributors {
334
+ author?: Contributor;
335
+ translator?: Contributor;
336
+ editor?: Contributor;
337
+ artist?: Contributor;
338
+ illustrator?: Contributor;
339
+ letterer?: Contributor;
340
+ penciler?: Contributor;
341
+ colorist?: Contributor;
342
+ inker?: Contributor;
343
+ narrator?: Contributor;
344
+ contributor?: Contributor;
345
+ publisher?: Contributor;
346
+ imprint?: Contributor;
347
+ }
348
+
349
+ /**
350
+ * Type definitions for a manifest
351
+ */
352
+
353
+ interface WebpubManifest {
354
+ '@context'?: typeof ReadiumWebpubContext;
355
+ metadata: Metadata;
356
+ links: ReadiumLink[];
357
+ readingOrder: ReadiumLink[];
358
+ resources?: ReadiumLink[];
359
+ toc?: ReadiumLink[];
360
+ }
361
+
362
+ declare type ColorMode = 'night' | 'sepia' | 'day';
363
+ declare type FontFamily = 'publisher' | 'serif' | 'sans-serif' | 'open-dyslexic';
364
+ declare type Navigator = {
365
+ goForward: () => void;
366
+ goBackward: () => void;
367
+ setScroll: (val: 'scrolling' | 'paginated') => Promise<void>;
368
+ goToPage: (href: string) => void;
369
+ };
370
+ declare type PdfNavigator = Navigator & {
371
+ zoomIn: () => Promise<void>;
372
+ zoomOut: () => Promise<void>;
373
+ };
374
+ declare type HtmlNavigator = Navigator & {
375
+ increaseFontSize: () => Promise<void>;
376
+ decreaseFontSize: () => Promise<void>;
377
+ resetSettings: () => Promise<void>;
378
+ setFontFamily: (family: FontFamily) => Promise<void>;
379
+ setColorMode: (mode: ColorMode) => Promise<void>;
380
+ };
381
+ declare type ReaderSettings = {
382
+ colorMode: ColorMode;
383
+ isScrolling: boolean;
384
+ fontSize: number;
385
+ fontFamily: FontFamily;
386
+ };
387
+ /**
388
+ * This is the "public" state of the reader that
389
+ * is returned to consumers of useWebReader. Each
390
+ * reader (pdf/html) has its own internal state with
391
+ * more details necessary for rendering
392
+ */
393
+ declare type ReaderState = {
394
+ atStart: boolean;
395
+ atEnd: boolean;
396
+ location?: Locator;
397
+ settings: ReaderSettings | undefined;
398
+ };
399
+ declare type InactiveReader = null;
400
+ declare type LoadingReader = {
401
+ isLoading: true;
402
+ content: JSX.Element;
403
+ navigator: null;
404
+ state: null;
405
+ manifest: null;
406
+ type: null;
407
+ };
408
+ declare type CommonReader = {
409
+ isLoading: false;
410
+ content: JSX.Element;
411
+ manifest: WebpubManifest;
412
+ };
413
+ declare type PDFActiveReader = CommonReader & {
414
+ state: ReaderState;
415
+ navigator: PdfNavigator;
416
+ type: 'PDF';
417
+ };
418
+ declare type HTMLActiveReader = CommonReader & {
419
+ state: ReaderState;
420
+ navigator: HtmlNavigator;
421
+ type: 'HTML';
422
+ };
423
+ declare type ActiveReader = PDFActiveReader | HTMLActiveReader;
424
+ declare type ReaderReturn = InactiveReader | LoadingReader | ActiveReader;
425
+ declare type GetContent = (href: string) => Promise<string>;
426
+ declare type ReaderManagerArguments = {
427
+ headerLeft?: JSX.Element;
428
+ };
429
+ declare type UseWebReaderArguments = {
430
+ webpubManifestUrl: string;
431
+ proxyUrl?: string;
432
+ getContent?: GetContent;
433
+ pdfWorkerSrc?: string;
434
+ injectablesReflowable?: Injectable[];
435
+ injectablesFixed?: Injectable[];
436
+ /**
437
+ * CSS string to set the height of the reader in paginated mode, and also
438
+ * in scrolling mode if `growWhenScrolling` is `false`.
439
+ *
440
+ * eg: "800px" or `calc(100vh-${CHROME_HEIGHT})`
441
+ *
442
+ * Default: `calc(100vh-${CHROME_HEIGHT})`
443
+ */
444
+ height?: string;
445
+ /**
446
+ * Tells the renderer if it should grow to fit content in scrolling mode, or if should
447
+ * remain the same height and instead show an internal scroll bar. Set to `true` by
448
+ * default, as this should be used in a full-page reader, the most common use case.
449
+ *
450
+ * Default: `true`
451
+ */
452
+ growWhenScrolling?: boolean;
453
+ /**
454
+ * Initial user settings for the reader
455
+ */
456
+ readerSettings?: Partial<ReaderSettings>;
457
+ /**
458
+ * If enabled, reading location will be persisted to local storage and recalled from
459
+ * there upon initial load.
460
+ *
461
+ * Default: `true`
462
+ */
463
+ persistLastLocation?: boolean;
464
+ /**
465
+ * If enabled, reader settings will be persisted to local storage and recalled
466
+ * from there upon initial load.
467
+ *
468
+ * Default: `true`
469
+ */
470
+ persistSettings?: boolean;
471
+ };
472
+ declare type ActiveReaderArguments = UseWebReaderArguments & {
473
+ manifest: WebpubManifest;
474
+ };
475
+ declare type InactiveReaderArguments = undefined;
476
+ declare type ReaderArguments = ActiveReaderArguments | InactiveReaderArguments;
477
+
478
+ /**
479
+ * The React hook that exposes the main API into the reader. It
480
+ * will determine the type of the webpub, and then use the correct reader
481
+ * for that type.
482
+ */
483
+ declare function useWebReader(args: UseWebReaderArguments): HTMLActiveReader | PDFActiveReader | LoadingReader;
484
+
485
+ declare function useHtmlReader(args: ReaderArguments): ReaderReturn;
486
+
487
+ /**
488
+ * The PDF reader
489
+ *
490
+ * The PDF reader loads resources in two stages: First, it fetches the PDF resource as an Uint8Array
491
+ * Then, it passes this array into the <Document> object, which loads the PDF inside an iframe
492
+ *
493
+ * @param args T
494
+ * @returns
495
+ */
496
+ declare function usePdfReader(args: ReaderArguments): ReaderReturn;
497
+
498
+ declare type Dict<T = any> = Record<string, T>;
499
+
500
+ /**
501
+ * See Chakra default theme for shape of theme object:
502
+ * https://github.com/chakra-ui/chakra-ui/tree/main/packages/theme
503
+ *
504
+ * Making this a function because we need to adjust the theme based
505
+ * on the colorMode that's being passed in.
506
+ *
507
+ * Returns the chakra theme object with an additional property `currentColorMode`
508
+ */
509
+ declare function getTheme(colorMode?: ColorMode): Dict<unknown>;
510
+
511
+ declare const useColorModeValue: (light: string, dark: string, sepia: string) => string;
512
+
513
+ declare function clearWebReaderLocalStorage(): void;
514
+
515
+ /**
516
+ * Adds TOC data to Webpub Manifest from single-resource PDF using PDF.js
517
+ * @param manifest
518
+ * @param getResource - a function to get the resource. This allows the caller
519
+ * to decide how to get the resource, for example through a proxy if necessary.
520
+ * @param pdfWorkerSrc - the path to the pdfjs worker file. Necessary to use pdfjs.
521
+ * @returns {WebpubManifest} manifest object
522
+ */
523
+ declare function addTocToManifest(manifest: WebpubManifest, getResource: (url: string) => Promise<Uint8Array>, pdfWorkerSrc: string): Promise<WebpubManifest>;
524
+
525
+ /**
526
+ * The main React component export.
527
+ */
528
+ declare type WebReaderProps = UseWebReaderArguments & ReaderManagerArguments;
529
+ declare const WebReaderWithoutBoundary: FC<WebReaderProps>;
530
+ declare const WebReader: FC<WebReaderProps>;
531
+
532
+ export { CHROME_HEIGHT, DEFAULT_HEIGHT, DEFAULT_SETTINGS, DEFAULT_SHOULD_GROW_WHEN_SCROLLING, FONT_DETAILS, FOOTER_HEIGHT, HEADER_HEIGHT, IS_DEV, LOCAL_STORAGE_LOCATIONS_KEY, LOCAL_STORAGE_SETTINGS_KEY, ReadiumWebpubContext, WebReaderProps, WebReaderWithoutBoundary, addTocToManifest, clearWebReaderLocalStorage, WebReader as default, getTheme, useColorModeValue, useHtmlReader, usePdfReader, useWebReader };