@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
@@ -1,22 +0,0 @@
1
- import { ReaderSettings, WebpubManifest } from '../types';
2
- /**
3
- * These are effects that reach in to the iframe element and modify it.
4
- * They are not part of the reducer, and should only be called from within a
5
- * useEffect hook.
6
- */
7
- /**
8
- * Scroll the HTML element to a given progression by
9
- * setting the scrollTop or the scrollLeft.
10
- */
11
- export declare function navigateToProgression(iframe: HTMLIFrameElement, progression: number, isScrolling: boolean): void;
12
- export declare function navigateToHash(fragment: string, iframe: HTMLIFrameElement, isScrolling: boolean): void;
13
- /**
14
- * Takes the HTML element and sets CSS variables on it based on the
15
- * reader's state
16
- */
17
- export declare function setCss(iframeHtml: Document, settings: ReaderSettings, iframeContainer: HTMLElement | null, manifest: WebpubManifest | undefined): void;
18
- export declare function setReflowableCss(iframeHtml: HTMLElement, settings: ReaderSettings): void;
19
- /**
20
- * Apply the transform property to the iframe document to fit the current screen viewport.
21
- */
22
- export declare function setFixedCss(iframeDocument: Document, iframeContainer: HTMLElement | null): void;
@@ -1,3 +0,0 @@
1
- import { ReaderReturn, ReaderArguments } from '../types';
2
- export declare const IFRAME_ID_SELECTOR = "html-reader-iframe";
3
- export default function useHtmlReader(args: ReaderArguments): ReaderReturn;
@@ -1,107 +0,0 @@
1
- import { Injectable } from '../Readium/Injectable';
2
- import { Locator } from '../Readium/Locator';
3
- import { WebpubManifest, ColorMode, FontFamily } from '../types';
4
- import { ReadiumLink } from '../WebpubManifestTypes/ReadiumLink';
5
- import { ActiveState } from './types';
6
- /**
7
- * Constants
8
- */
9
- export declare const FONT_SIZE_STEP = 4;
10
- export declare const defaultInjectables: Injectable[];
11
- export declare const defaultInjectablesFixed: Injectable[];
12
- /**
13
- * Creates an element for an injectable so it can be injected into the iframe.
14
- */
15
- export declare function makeInjectableElement(document: Document, injectable: Injectable): HTMLElement | undefined;
16
- /**
17
- * gets the index of the current location href
18
- */
19
- export declare function getCurrentIndex(manifest: WebpubManifest, state: ActiveState, baseUrl: string): number;
20
- /**
21
- * Find a link in the reading order from a passed in href.
22
- */
23
- export declare function getFromReadingOrder(href: string, manifest: WebpubManifest, baseUrl: string): {
24
- link: ReadiumLink;
25
- index: number;
26
- } | undefined;
27
- /**
28
- * Check if two hrefs share the same pathname. They can be absolute
29
- * or relative. This will ignore hash and query params.
30
- */
31
- export declare function isSameResource(href1: string, href2: string, baseUrl: string): boolean;
32
- /**
33
- * Converts a ReadiumLink to a Locator
34
- */
35
- export declare function linkToLocator(link: ReadiumLink, baseUrl: string, locations?: Locator['locations']): Locator;
36
- declare type CalculatedPosition = {
37
- isHorizontalPaginated: boolean;
38
- containerSize: number;
39
- containerWidth: number;
40
- containerHeight: number;
41
- pageSize: number;
42
- resourceSize: number;
43
- scrollPosition: number;
44
- totalPages: number;
45
- progression: number;
46
- currentPage: number;
47
- currentPageFloor: number;
48
- isAtEnd: boolean;
49
- isAtStart: boolean;
50
- };
51
- /**
52
- * Calculate current position information
53
- */
54
- export declare function calcPosition(iframe: HTMLIFrameElement, isScrolling: boolean): CalculatedPosition;
55
- /**
56
- * Gets scroll position of an element
57
- */
58
- export declare function getScrollPosition(element: HTMLElement | undefined | null): {
59
- x: number;
60
- y: number;
61
- };
62
- /**
63
- * Fetches a resource as text
64
- */
65
- export declare function fetchAsTxt(url: string): Promise<string>;
66
- /**
67
- * Inject some raw JS into the iframe document
68
- */
69
- export declare function injectJS(document: Document): void;
70
- export declare function getMaybeIframeHtml(iframe: HTMLIFrameElement): HTMLElement | undefined;
71
- /**
72
- * Get the HTML element of the iframe
73
- */
74
- export declare function getIframeHTML(iframe: HTMLIFrameElement): HTMLElement;
75
- /**
76
- * Sets a CSS var on the html element in the iframe. Used to set
77
- * ReadiumCSS settings like scrolling and color mode and font
78
- * size.
79
- */
80
- export declare function setCSSProperty(html: HTMLElement, name: string, val: string): void;
81
- /**
82
- * Translates the readium scroll css var into a boolean
83
- */
84
- export declare function getPagination(isPaginated: boolean): 'readium-scroll-on' | 'readium-scroll-off';
85
- /**
86
- * Translates the internal color mode value into a Readium
87
- * color mode value.
88
- */
89
- export declare function getColorModeValue(mode: ColorMode): 'readium-default-on' | 'readium-night-on' | 'readium-sepia-on';
90
- /**
91
- * Translates the readium color mode value into an internal
92
- * color mode value
93
- */
94
- export declare function getColorMode(d2Mode: string): ColorMode;
95
- /**
96
- * Gets the Readium font-override setting based on the given font family.
97
- */
98
- export declare function getFontOverride(fontFamily: FontFamily): 'readium-font-off' | 'readium-font-on';
99
- /**
100
- * Translates the internal font family to a readium css font family value.
101
- */
102
- export declare const familyToReadiumFamily: Record<FontFamily, string>;
103
- /**
104
- * Translates a readium css font family to an internal font family.
105
- */
106
- export declare const r2FamilyToFamily: Record<string, FontFamily | undefined>;
107
- export {};
@@ -1,8 +0,0 @@
1
- import { ReaderArguments } from '../types';
2
- import { HtmlAction, HtmlState, InactiveState } from './types';
3
- /**
4
- * A higher order function that makes it easy to access arguments in the reducer
5
- * without passing them in to every `dispatch` call.
6
- */
7
- export default function makeHtmlReducer(args: ReaderArguments): (state: HtmlState, action: HtmlAction) => HtmlState;
8
- export declare const inactiveState: InactiveState;
@@ -1,116 +0,0 @@
1
- import { Locator } from '../Readium/Locator';
2
- import { ColorMode, FontFamily, ReaderArguments, ReaderSettings, ReaderState } from '../types';
3
- /**
4
- * Html Reader States
5
- * - Can be broken into distinct states that we create a union from.
6
- * This helps us avoid invalid states.
7
- * - We include a `state` property so that it is easy to narrow the type
8
- * of a given HtmlState to a specific state in the union.
9
- */
10
- export declare type HtmlState = InactiveState | ActiveState;
11
- export declare type ActiveState = FetchingResourceState | ResourceFetchErrorState | RenderingIframeState | LoadingIframeState | NavigatingState | ReadyState;
12
- export declare type InactiveState = ReaderState & {
13
- state: 'INACTIVE';
14
- location: undefined;
15
- iframe: null;
16
- resource: undefined;
17
- resourceFetchError: undefined;
18
- };
19
- export declare type FetchingResourceState = ReaderState & {
20
- state: 'FETCHING_RESOURCE';
21
- location: Locator;
22
- iframe: null;
23
- resource: undefined;
24
- resourceFetchError: undefined;
25
- settings: ReaderSettings;
26
- };
27
- export declare type ResourceFetchErrorState = ReaderState & {
28
- state: 'RESOURCE_FETCH_ERROR';
29
- location: Locator;
30
- iframe: null;
31
- resource: undefined;
32
- resourceFetchError: Error;
33
- settings: ReaderSettings;
34
- };
35
- export declare type RenderingIframeState = ReaderState & {
36
- state: 'RENDERING_IFRAME';
37
- location: Locator;
38
- iframe: null;
39
- resource: string;
40
- resourceFetchError: undefined;
41
- settings: ReaderSettings;
42
- };
43
- export declare type LoadingIframeState = ReaderState & {
44
- state: 'LOADING_IFRAME';
45
- location: Locator;
46
- iframe: HTMLIFrameElement;
47
- resource: string;
48
- resourceFetchError: undefined;
49
- settings: ReaderSettings;
50
- };
51
- export declare type NavigatingState = ReaderState & {
52
- state: 'NAVIGATING';
53
- location: Locator;
54
- iframe: HTMLIFrameElement;
55
- resource: string;
56
- resourceFetchError: undefined;
57
- settings: ReaderSettings;
58
- };
59
- export declare type ReadyState = ReaderState & {
60
- state: 'READY';
61
- location: Locator;
62
- iframe: HTMLIFrameElement;
63
- resource: string;
64
- resourceFetchError: undefined;
65
- settings: ReaderSettings;
66
- };
67
- export declare type HtmlAction = {
68
- type: 'ARGS_CHANGED';
69
- args: ReaderArguments;
70
- } | {
71
- type: 'IFRAME_LOADED';
72
- } | {
73
- type: 'NAV_PREVIOUS_RESOURCE';
74
- } | {
75
- type: 'NAV_NEXT_RESOURCE';
76
- } | {
77
- type: 'GO_TO_HREF';
78
- href: string;
79
- } | {
80
- type: 'GO_TO_LOCATION';
81
- location: Locator;
82
- } | {
83
- type: 'GO_FORWARD';
84
- } | {
85
- type: 'GO_BACKWARD';
86
- } | {
87
- type: 'WINDOW_RESIZED';
88
- } | {
89
- type: 'NAV_COMPLETE';
90
- } | {
91
- type: 'SET_COLOR_MODE';
92
- mode: ColorMode;
93
- } | {
94
- type: 'SET_SCROLL';
95
- isScrolling: boolean;
96
- } | {
97
- type: 'INCREASE_FONT_SIZE';
98
- } | {
99
- type: 'DECREASE_FONT_SIZE';
100
- } | {
101
- type: 'RESET_SETTINGS';
102
- } | {
103
- type: 'SET_FONT_FAMILY';
104
- family: FontFamily;
105
- } | {
106
- type: 'USER_SCROLLED';
107
- } | {
108
- type: 'SET_IFRAME';
109
- iframe: HTMLIFrameElement | null;
110
- } | {
111
- type: 'RESOURCE_FETCH_SUCCESS';
112
- resource: string;
113
- } | {
114
- type: 'RESOURCE_FETCH_ERROR';
115
- error: Error;
116
- };
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { WebpubManifest } from '../WebpubManifestTypes/WebpubManifest';
3
- import { HtmlAction } from './types';
4
- export default function useIframeLinkClick(baseUrl: string | undefined, manifest: WebpubManifest | undefined, dispatch: React.Dispatch<HtmlAction>): void;
@@ -1,8 +0,0 @@
1
- import { Locator } from '../Readium/Locator';
2
- import { HtmlState } from './types';
3
- /**
4
- * Keep the Location state in the browser's url bar.
5
- * Dispatch location changed when the url changes.
6
- */
7
- export default function useLocationQuery(state: HtmlState): void;
8
- export declare function getLocationQuery(): Locator | undefined;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { Injectable } from '../Readium/Injectable';
3
- import { WebpubManifest } from '../types';
4
- import { HtmlState, HtmlAction } from './types';
5
- /**
6
- * Fetches a resource whenever the url changes and dispatches
7
- * actions to keep the reducer up to date. Works similar to
8
- * useSWR, but storing the resource in the reducer state, not
9
- * separately.
10
- *
11
- * Also performs some modifications on the resource to add initial
12
- * css variables and injectables.
13
- */
14
- export default function useResource(manifest: WebpubManifest | undefined, state: HtmlState, getContent: (url: string) => Promise<string>, injectables: Injectable[], dispatch: React.Dispatch<HtmlAction>): void;
@@ -1,6 +0,0 @@
1
- import { WebpubManifest } from '../types';
2
- import { HtmlState } from './types';
3
- /**
4
- * Set CSS variables when user state changes
5
- */
6
- export default function useUpdateCSS(state: HtmlState, manifest: WebpubManifest | undefined): void;
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import { HtmlAction, HtmlState } from './types';
3
- /**
4
- * Dispatch a USER_SCROLLED event after some delay
5
- */
6
- export declare function useUpdateScroll(state: HtmlState, dispatch: React.Dispatch<HtmlAction>): void;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { WebpubManifest } from '../types';
3
- import { HtmlAction, HtmlState } from './types';
4
- /**
5
- * Simply dispatches an action when the window is resized.
6
- */
7
- export default function useWindowResize(manifest: WebpubManifest | undefined, state: HtmlState, dispatch: React.Dispatch<HtmlAction>): void;
@@ -1,3 +0,0 @@
1
- import { Page } from 'react-pdf';
2
- declare const ChakraPage: import("@chakra-ui/react").ChakraComponent<typeof Page, {}>;
3
- export default ChakraPage;
@@ -1,12 +0,0 @@
1
- import { FC } from 'react';
2
- import { PageProps } from 'react-pdf';
3
- declare type ScrollPageProps = {
4
- pageNumber: number;
5
- width: number | undefined;
6
- scale: number;
7
- onLoadSuccess: (page: PageProps) => void;
8
- placeholderHeight: number;
9
- placeholderWidth: number;
10
- };
11
- declare const ScrollPage: FC<ScrollPageProps>;
12
- export default ScrollPage;
@@ -1,10 +0,0 @@
1
- import { WebpubManifest } from '../types';
2
- /**
3
- * Adds TOC data to Webpub Manifest from single-resource PDF using PDF.js
4
- * @param manifest
5
- * @param getResource - a function to get the resource. This allows the caller
6
- * to decide how to get the resource, for example through a proxy if necessary.
7
- * @param pdfWorkerSrc - the path to the pdfjs worker file. Necessary to use pdfjs.
8
- * @returns {WebpubManifest} manifest object
9
- */
10
- export default function addTocToManifest(manifest: WebpubManifest, getResource: (url: string) => Promise<Uint8Array>, pdfWorkerSrc: string): Promise<WebpubManifest>;
@@ -1,12 +0,0 @@
1
- import { ReaderArguments, ReaderReturn } from '../types';
2
- import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
3
- /**
4
- * The PDF reader
5
- *
6
- * The PDF reader loads resources in two stages: First, it fetches the PDF resource as an Uint8Array
7
- * Then, it passes this array into the <Document> object, which loads the PDF inside an iframe
8
- *
9
- * @param args T
10
- * @returns
11
- */
12
- export default function usePdfReader(args: ReaderArguments): ReaderReturn;
@@ -1,26 +0,0 @@
1
- import { WebpubManifest } from '../types';
2
- import { ReadiumLink } from '../WebpubManifestTypes/ReadiumLink';
3
- export declare const IFRAME_WRAPPER_ID = "iframe-wrapper";
4
- export declare const SCALE_STEP = 0.1;
5
- export declare const START_QUERY = "start";
6
- export declare const getResourceUrl: (index: number, readingOrder: ReadiumLink[] | undefined) => string;
7
- export declare const loadResource: (resourceUrl: string, proxyUrl?: string | undefined) => Promise<Uint8Array>;
8
- /**
9
- * Gets the index of the provided href in the readingOrder, or throws an error if one
10
- * is not found.
11
- */
12
- export declare function getIndexFromHref(href: string, manifest: WebpubManifest): number;
13
- /**
14
- * Compares two hrefs without query params or hash
15
- */
16
- export declare function doHrefsMatch(href1: string | URL, href2: string | URL): boolean;
17
- /**
18
- * Extracts a start page from a href if it exists and is in the format
19
- * `?startPage=1`. Returns undefined if none found.
20
- */
21
- export declare const getStartPageFromHref: (href: string) => number | undefined;
22
- /**
23
- * Extracts a page number from a href if it exists and is in
24
- * the format of `#page=1`
25
- */
26
- export declare const getPageNumberFromHref: (href: string) => number | undefined;
@@ -1,3 +0,0 @@
1
- import { ReaderArguments } from '../types';
2
- import { PdfState, PdfReaderAction } from './types';
3
- export declare function makePdfReducer(args: ReaderArguments): (state: PdfState, action: PdfReaderAction) => PdfState;
@@ -1,61 +0,0 @@
1
- import { ReaderArguments, ReaderSettings, ReaderState } from '../types';
2
- export declare type InternalState = {
3
- resourceIndex: number;
4
- resource: {
5
- data: Uint8Array;
6
- } | null;
7
- numPages: number | null;
8
- pageNumber: number;
9
- scale: number;
10
- pdfHeight: number;
11
- pdfWidth: number;
12
- pageHeight: number | undefined;
13
- pageWidth: number | undefined;
14
- rendered: boolean;
15
- };
16
- export declare type InactiveState = ReaderState & InternalState & {
17
- state: 'INACTIVE';
18
- settings: undefined;
19
- };
20
- export declare type ActiveState = ReaderState & InternalState & {
21
- state: 'ACTIVE';
22
- settings: ReaderSettings;
23
- };
24
- export declare type PdfState = InactiveState | ActiveState;
25
- export declare type PdfReaderAction = {
26
- type: 'ARGS_CHANGED';
27
- args: ReaderArguments;
28
- } | {
29
- type: 'GO_FORWARD';
30
- } | {
31
- type: 'GO_BACKWARD';
32
- } | {
33
- type: 'GO_TO_HREF';
34
- href: string;
35
- } | {
36
- type: 'RESOURCE_FETCH_SUCCESS';
37
- resource: {
38
- data: Uint8Array;
39
- };
40
- } | {
41
- type: 'PDF_PARSED';
42
- numPages: number;
43
- } | {
44
- type: 'SET_SCALE';
45
- scale: number;
46
- } | {
47
- type: 'SET_SCROLL';
48
- isScrolling: boolean;
49
- } | {
50
- type: 'PAGE_LOAD_SUCCESS';
51
- height: number;
52
- width: number;
53
- } | {
54
- type: 'RESIZE_PAGE';
55
- height: number | undefined;
56
- width: number | undefined;
57
- } | {
58
- type: 'BOOK_BOUNDARY_CHANGED';
59
- atStart: boolean;
60
- atEnd: boolean;
61
- };
@@ -1,7 +0,0 @@
1
- export declare type Dimensions = Pick<DOMRectReadOnly, 'x' | 'y' | 'top' | 'left' | 'right' | 'bottom' | 'height' | 'width'>;
2
- export declare type UseMeasureRef<E extends Element = Element> = (element: E) => void;
3
- export declare type UseMeasureResult<E extends Element = Element> = [
4
- UseMeasureRef<E> | null,
5
- Dimensions
6
- ];
7
- export default function useMeasure<E extends Element = Element>(): UseMeasureResult<E>;
@@ -1,11 +0,0 @@
1
- export interface Injectable {
2
- type: string;
3
- url?: string;
4
- r2after?: boolean;
5
- r2before?: boolean;
6
- r2default?: boolean;
7
- fontFamily?: string;
8
- systemFont?: boolean;
9
- appearance?: string;
10
- async?: boolean;
11
- }
@@ -1,20 +0,0 @@
1
- export interface Locator {
2
- href: string;
3
- type?: string;
4
- title?: string;
5
- locations: Locations;
6
- text?: LocatorText;
7
- }
8
- export interface LocatorText {
9
- after?: string;
10
- before?: string;
11
- highlight?: string;
12
- }
13
- export interface Locations {
14
- fragment?: string;
15
- progression?: number;
16
- position?: number;
17
- totalProgression?: number;
18
- remainingPositions?: number;
19
- totalRemainingPositions?: number;
20
- }
@@ -1,3 +0,0 @@
1
- export declare const WebpubPdfConformsTo = "http://librarysimplified.org/terms/profiles/pdf";
2
- export declare const EpubConformsTo = "https://readium.org/webpub-manifest/profiles/epub";
3
- export declare type ConformsTo = typeof WebpubPdfConformsTo | typeof EpubConformsTo;
@@ -1,17 +0,0 @@
1
- import { ReadiumLink } from './ReadiumLink';
2
- export interface ContributorObject {
3
- name: string | {
4
- /**
5
- * This interface was referenced by `undefined`'s JSON-Schema definition
6
- * 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})+))$".
7
- */
8
- [k: string]: string;
9
- };
10
- identifier?: string;
11
- sortAs?: string;
12
- role?: string | string[];
13
- position?: number;
14
- links?: ReadiumLink[];
15
- [k: string]: unknown;
16
- }
17
- export declare type Contributor = string | (string | ContributorObject)[] | ContributorObject;
@@ -1,47 +0,0 @@
1
- export interface EPUBExtensionLinkProperties {
2
- /**
3
- * Identifies content contained in the linked resource, that cannot be strictly identified using a media type.
4
- */
5
- contains?: ('mathml' | 'onix' | 'remote-resources' | 'js' | 'svg' | 'xmp')[];
6
- /**
7
- * Hints how the layout of the resource should be presented
8
- */
9
- layout?: 'fixed' | 'reflowable';
10
- /**
11
- * Indicates that a resource is encrypted/obfuscated and provides relevant information for decryption
12
- */
13
- encrypted?: {
14
- /**
15
- * Identifies the algorithm used to encrypt the resource
16
- */
17
- algorithm: string;
18
- /**
19
- * Compression method used on the resource
20
- */
21
- compression?: string;
22
- /**
23
- * Original length of the resource in bytes before compression and/or encryption
24
- */
25
- originalLength?: number;
26
- /**
27
- * Identifies the encryption profile used to encrypt the resource
28
- */
29
- profile?: string;
30
- /**
31
- * Identifies the encryption scheme used to encrypt the resource
32
- */
33
- scheme?: string;
34
- [k: string]: unknown;
35
- };
36
- [k: string]: unknown;
37
- }
38
- export interface EPUBExtensionMetadata {
39
- presentation?: {
40
- /**
41
- * Hints how the layout of the resource should be presented
42
- */
43
- layout?: 'fixed' | 'reflowable';
44
- [k: string]: unknown;
45
- };
46
- [k: string]: unknown;
47
- }
@@ -1,3 +0,0 @@
1
- export declare type LanguageMap = string | {
2
- [k: string]: string;
3
- };
@@ -1,47 +0,0 @@
1
- import { ConformsTo } from './ConformsTo';
2
- import { Contributor } from './Contributor';
3
- import { EPUBExtensionMetadata } from './EpubExtension';
4
- import { LanguageMap } from './LanguageMap';
5
- import { Subject } from './Subject';
6
- export interface Metadata extends Contributors, EPUBExtensionMetadata {
7
- identifier?: string;
8
- '@type'?: string;
9
- conformsTo?: ConformsTo;
10
- title: LanguageMap;
11
- subtitle?: LanguageMap;
12
- modified?: string;
13
- published?: {
14
- [k: string]: unknown;
15
- } & string;
16
- /**
17
- * The language must be a valid BCP 47 tag.
18
- */
19
- language?: string | string[];
20
- sortAs?: LanguageMap;
21
- subject?: Subject;
22
- readingProgression?: 'rtl' | 'ltr' | 'ttb' | 'btt' | 'auto';
23
- description?: string;
24
- duration?: number;
25
- numberOfPages?: number;
26
- belongsTo?: {
27
- collection?: Contributor;
28
- series?: Contributor;
29
- [k: string]: unknown;
30
- };
31
- [k: string]: unknown;
32
- }
33
- export interface Contributors {
34
- author?: Contributor;
35
- translator?: Contributor;
36
- editor?: Contributor;
37
- artist?: Contributor;
38
- illustrator?: Contributor;
39
- letterer?: Contributor;
40
- penciler?: Contributor;
41
- colorist?: Contributor;
42
- inker?: Contributor;
43
- narrator?: Contributor;
44
- contributor?: Contributor;
45
- publisher?: Contributor;
46
- imprint?: Contributor;
47
- }