@nypl/web-reader 2.0.0-0 → 3.0.0

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.
@@ -1,4 +1,4 @@
1
- import { ReaderSettings } from '../types';
1
+ import { ReaderSettings, WebpubManifest } from '../types';
2
2
  /**
3
3
  * These are effects that reach in to the iframe element and modify it.
4
4
  * They are not part of the reducer, and should only be called from within a
@@ -14,4 +14,9 @@ export declare function navigateToHash(fragment: string, iframe: HTMLIFrameEleme
14
14
  * Takes the HTML element and sets CSS variables on it based on the
15
15
  * reader's state
16
16
  */
17
- export declare function setCss(html: HTMLElement, settings: ReaderSettings): void;
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,12 +1,10 @@
1
1
  import { ReaderReturn, ReaderArguments } from '../types';
2
+ export declare const IFRAME_ID_SELECTOR = "html-reader-iframe";
2
3
  /**
3
4
  * @TODO :
4
5
  *
5
6
  * Future:
6
7
  * - provide default injectables (Readium CSS)
7
- * - Don't use ReadiumCSS for fixed layout
8
- * - Make fixed layout work
9
- * - Update to latest Readium CSS
10
8
  * - Find some way to organize effects and actions together so you can navigate, wait for iframe to load,
11
9
  * then run some other effect.
12
10
  * - goForward and goBackward should return a promise that resolves once isNavigated flips to true.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Injectable } from '../Readium/Injectable';
3
+ import { WebpubManifest } from '../types';
3
4
  import { HtmlState, HtmlAction } from './types';
4
5
  /**
5
6
  * Fetches a resource whenever the url changes and dispatches
@@ -10,4 +11,4 @@ import { HtmlState, HtmlAction } from './types';
10
11
  * Also performs some modifications on the resource to add initial
11
12
  * css variables and injectables.
12
13
  */
13
- export default function useResource(state: HtmlState, getContent: (url: string) => Promise<string>, injectables: Injectable[], dispatch: React.Dispatch<HtmlAction>): void;
14
+ export default function useResource(manifest: WebpubManifest | undefined, state: HtmlState, getContent: (url: string) => Promise<string>, injectables: Injectable[], dispatch: React.Dispatch<HtmlAction>): void;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { HtmlAction } from './types';
2
+ import { WebpubManifest } from '../types';
3
+ import { HtmlAction, HtmlState } from './types';
3
4
  /**
4
5
  * Simply dispatches an action when the window is resized.
5
6
  */
6
- export default function useWindowResize(dispatch: React.Dispatch<HtmlAction>): void;
7
+ export default function useWindowResize(manifest: WebpubManifest | undefined, state: HtmlState, dispatch: React.Dispatch<HtmlAction>): void;
@@ -1,3 +1,3 @@
1
1
  export declare const WebpubPdfConformsTo = "http://librarysimplified.org/terms/profiles/pdf";
2
- export declare const AxisNowEpubConformsTo = "stub/webpub+axisnow";
3
- export declare type ConformsTo = typeof WebpubPdfConformsTo | typeof AxisNowEpubConformsTo;
2
+ export declare const EpubConformsTo = "https://readium.org/webpub-manifest/profiles/epub";
3
+ export declare type ConformsTo = typeof WebpubPdfConformsTo | typeof EpubConformsTo;
@@ -1,8 +1,9 @@
1
1
  import { ConformsTo } from './ConformsTo';
2
2
  import { Contributor } from './Contributor';
3
+ import { EPUBExtensionMetadata } from './EpubExtension';
3
4
  import { LanguageMap } from './LanguageMap';
4
5
  import { Subject } from './Subject';
5
- export interface Metadata extends Contributors {
6
+ export interface Metadata extends Contributors, EPUBExtensionMetadata {
6
7
  identifier?: string;
7
8
  '@type'?: string;
8
9
  conformsTo?: ConformsTo;
@@ -7,3 +7,5 @@ export declare const CHROME_HEIGHT: number;
7
7
  export declare const DEFAULT_HEIGHT: string;
8
8
  export declare const DEFAULT_SHOULD_GROW_WHEN_SCROLLING = true;
9
9
  export declare const DEFAULT_SETTINGS: ReaderSettings;
10
+ export declare const LOCAL_STORAGE_SETTINGS_KEY = "web-reader-settings";
11
+ export declare const LOCAL_STORAGE_LOCATIONS_KEY = "web-reader-locations";
@@ -14,3 +14,4 @@ export { default as usePdfReader } from './PdfReader';
14
14
  export { getTheme } from './ui/theme';
15
15
  export { default as useColorModeValue } from './ui/hooks/useColorModeValue';
16
16
  export * from './constants';
17
+ export { clearWebReaderLocalStorage } from './utils/localstorage';
@@ -76,7 +76,7 @@ export declare type UseWebReaderArguments = {
76
76
  proxyUrl?: string;
77
77
  getContent?: GetContent;
78
78
  pdfWorkerSrc?: string;
79
- injectables?: Injectable[];
79
+ injectablesReflowable?: Injectable[];
80
80
  injectablesFixed?: Injectable[];
81
81
  /**
82
82
  * CSS string to set the height of the reader in paginated mode, and also
@@ -99,6 +99,20 @@ export declare type UseWebReaderArguments = {
99
99
  * Initial user settings for the reader
100
100
  */
101
101
  readerSettings?: Partial<ReaderSettings>;
102
+ /**
103
+ * If enabled, reading location will be persisted to local storage and recalled from
104
+ * there upon initial load.
105
+ *
106
+ * Default: `true`
107
+ */
108
+ persistLastLocation?: boolean;
109
+ /**
110
+ * If enabled, reader settings will be persisted to local storage and recalled
111
+ * from there upon initial load.
112
+ *
113
+ * Default: `true`
114
+ */
115
+ persistSettings?: boolean;
102
116
  };
103
117
  export declare type ActiveReaderArguments = UseWebReaderArguments & {
104
118
  manifest: WebpubManifest;
@@ -1,10 +1,21 @@
1
1
  import { HtmlState } from '../HtmlReader/types';
2
2
  import { Locator } from '../Readium/Locator';
3
- import { ReaderSettings } from '../types';
4
- export declare type LSLocationRecord = {
3
+ import { ReaderArguments, ReaderSettings } from '../types';
4
+ /**
5
+ * Use getLocalStorageLocation to get the location when
6
+ * initializing the reducer. useUpdateLocalStorage will set
7
+ * values in local storage as they change.
8
+ *
9
+ * TODO:
10
+ * - PDF Sync
11
+ * - how to handle non backwards compatible updates
12
+ */
13
+ export declare type LSLocation = {
5
14
  location: Locator;
6
15
  createdAt: number;
7
16
  };
8
- export declare function getLocalStorageLocation(identifier: string): LSLocationRecord | undefined;
9
- export declare function getLocalStorageSettings(): ReaderSettings | undefined;
10
- export default function useUpdateLocalStorage(identifier: string | null, state: HtmlState): void;
17
+ export declare type LSLocationsRecord = Record<string, LSLocation>;
18
+ export declare function getLocalStorageLocation(identifier: string, args: ReaderArguments): LSLocation | undefined;
19
+ export declare function getLocalStorageSettings(args: ReaderArguments): ReaderSettings | undefined;
20
+ export default function useUpdateLocalStorage(identifier: string | null, state: HtmlState, args: ReaderArguments): void;
21
+ export declare function clearWebReaderLocalStorage(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nypl/web-reader",
3
- "version": "2.0.0-0",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "repository": "https://github.com/NYPL-Simplified/web-reader",
6
6
  "homepage": "https://github.com/NYPL-Simplified/web-reader",