@nypl/web-reader 1.1.1 → 1.2.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.
- package/dist/cjs/ServiceWorker/sw.js +1 -1
- package/dist/cjs/ServiceWorker/sw.js.map +3 -3
- package/dist/cjs/index.js +15 -15
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/ServiceWorker/sw.js.map +2 -2
- package/dist/esm/index.js +318 -186
- package/dist/esm/index.js.map +3 -3
- package/dist/types/HtmlReader/effects.d.ts +2 -2
- package/dist/types/HtmlReader/types.d.ts +13 -8
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/types.d.ts +12 -9
- package/dist/types/ui/HtmlSettings.d.ts +3 -3
- package/dist/types/ui/PdfSettings.d.ts +2 -2
- package/dist/types/utils/localstorage.d.ts +10 -0
- package/package.json +17 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReaderSettings } 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,4 @@ 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,
|
|
17
|
+
export declare function setCss(html: HTMLElement, settings: ReaderSettings): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Locator } from '../Readium/Locator';
|
|
2
|
-
import { ColorMode, FontFamily,
|
|
2
|
+
import { ColorMode, FontFamily, ReaderArguments, ReaderSettings, ReaderState } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Html Reader States
|
|
5
5
|
* - Can be broken into distinct states that we create a union from.
|
|
@@ -16,49 +16,54 @@ export declare type InactiveState = ReaderState & {
|
|
|
16
16
|
resource: undefined;
|
|
17
17
|
resourceFetchError: undefined;
|
|
18
18
|
};
|
|
19
|
-
export declare type FetchingResourceState =
|
|
19
|
+
export declare type FetchingResourceState = ReaderState & {
|
|
20
20
|
state: 'FETCHING_RESOURCE';
|
|
21
21
|
location: Locator;
|
|
22
22
|
iframe: null;
|
|
23
23
|
resource: undefined;
|
|
24
24
|
resourceFetchError: undefined;
|
|
25
|
+
settings: ReaderSettings;
|
|
25
26
|
};
|
|
26
|
-
export declare type ResourceFetchErrorState =
|
|
27
|
+
export declare type ResourceFetchErrorState = ReaderState & {
|
|
27
28
|
state: 'RESOURCE_FETCH_ERROR';
|
|
28
29
|
location: Locator;
|
|
29
30
|
iframe: null;
|
|
30
31
|
resource: undefined;
|
|
31
32
|
resourceFetchError: Error;
|
|
33
|
+
settings: ReaderSettings;
|
|
32
34
|
};
|
|
33
|
-
export declare type RenderingIframeState =
|
|
35
|
+
export declare type RenderingIframeState = ReaderState & {
|
|
34
36
|
state: 'RENDERING_IFRAME';
|
|
35
37
|
location: Locator;
|
|
36
38
|
iframe: null;
|
|
37
39
|
resource: string;
|
|
38
40
|
resourceFetchError: undefined;
|
|
41
|
+
settings: ReaderSettings;
|
|
39
42
|
};
|
|
40
|
-
export declare type LoadingIframeState =
|
|
43
|
+
export declare type LoadingIframeState = ReaderState & {
|
|
41
44
|
state: 'LOADING_IFRAME';
|
|
42
45
|
location: Locator;
|
|
43
46
|
iframe: HTMLIFrameElement;
|
|
44
47
|
resource: string;
|
|
45
48
|
resourceFetchError: undefined;
|
|
49
|
+
settings: ReaderSettings;
|
|
46
50
|
};
|
|
47
|
-
export declare type NavigatingState =
|
|
51
|
+
export declare type NavigatingState = ReaderState & {
|
|
48
52
|
state: 'NAVIGATING';
|
|
49
53
|
location: Locator;
|
|
50
54
|
iframe: HTMLIFrameElement;
|
|
51
55
|
resource: string;
|
|
52
56
|
resourceFetchError: undefined;
|
|
57
|
+
settings: ReaderSettings;
|
|
53
58
|
};
|
|
54
|
-
export declare type ReadyState =
|
|
59
|
+
export declare type ReadyState = ReaderState & {
|
|
55
60
|
state: 'READY';
|
|
56
61
|
location: Locator;
|
|
57
62
|
iframe: HTMLIFrameElement;
|
|
58
63
|
resource: string;
|
|
59
64
|
resourceFetchError: undefined;
|
|
65
|
+
settings: ReaderSettings;
|
|
60
66
|
};
|
|
61
|
-
export declare type CSSState = Pick<HtmlState, 'isScrolling' | 'colorMode' | 'fontFamily' | 'fontSize'>;
|
|
62
67
|
export declare type HtmlAction = {
|
|
63
68
|
type: 'ARGS_CHANGED';
|
|
64
69
|
args: ReaderArguments;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReaderSettings } from './types';
|
|
1
2
|
export declare const ReadiumWebpubContext = "http://readium.org/webpub/default.jsonld";
|
|
2
3
|
export declare const IS_DEV: boolean;
|
|
3
4
|
export declare const HEADER_HEIGHT = 48;
|
|
@@ -5,3 +6,4 @@ export declare const FOOTER_HEIGHT = 48;
|
|
|
5
6
|
export declare const CHROME_HEIGHT: number;
|
|
6
7
|
export declare const DEFAULT_HEIGHT: string;
|
|
7
8
|
export declare const DEFAULT_SHOULD_GROW_WHEN_SCROLLING = true;
|
|
9
|
+
export declare const DEFAULT_SETTINGS: ReaderSettings;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -24,20 +24,23 @@ export declare type HtmlNavigator = Navigator & {
|
|
|
24
24
|
setColorMode: (mode: ColorMode) => Promise<void>;
|
|
25
25
|
};
|
|
26
26
|
export declare type ReaderSettings = {
|
|
27
|
-
isScrolling?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export declare type ReaderState = {
|
|
30
27
|
colorMode: ColorMode;
|
|
31
28
|
isScrolling: boolean;
|
|
32
29
|
fontSize: number;
|
|
33
30
|
fontFamily: FontFamily;
|
|
34
|
-
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* This is the "public" state of the reader that
|
|
34
|
+
* is returned to consumers of useWebReader. Each
|
|
35
|
+
* reader (pdf/html) has its own internal state with
|
|
36
|
+
* more details necessary for rendering
|
|
37
|
+
*/
|
|
38
|
+
export declare type ReaderState = {
|
|
35
39
|
atStart: boolean;
|
|
36
40
|
atEnd: boolean;
|
|
37
41
|
location?: Locator;
|
|
42
|
+
settings: ReaderSettings | undefined;
|
|
38
43
|
};
|
|
39
|
-
export declare type PdfReaderState = ReaderState;
|
|
40
|
-
export declare type HtmlReaderState = ReaderState;
|
|
41
44
|
export declare type InactiveReader = null;
|
|
42
45
|
export declare type LoadingReader = {
|
|
43
46
|
isLoading: true;
|
|
@@ -53,12 +56,12 @@ declare type CommonReader = {
|
|
|
53
56
|
manifest: WebpubManifest;
|
|
54
57
|
};
|
|
55
58
|
export declare type PDFActiveReader = CommonReader & {
|
|
56
|
-
state:
|
|
59
|
+
state: ReaderState;
|
|
57
60
|
navigator: PdfNavigator;
|
|
58
61
|
type: 'PDF';
|
|
59
62
|
};
|
|
60
63
|
export declare type HTMLActiveReader = CommonReader & {
|
|
61
|
-
state:
|
|
64
|
+
state: ReaderState;
|
|
62
65
|
navigator: HtmlNavigator;
|
|
63
66
|
type: 'HTML';
|
|
64
67
|
};
|
|
@@ -95,7 +98,7 @@ export declare type UseWebReaderArguments = {
|
|
|
95
98
|
/**
|
|
96
99
|
* Initial user settings for the reader
|
|
97
100
|
*/
|
|
98
|
-
readerSettings?: ReaderSettings
|
|
101
|
+
readerSettings?: Partial<ReaderSettings>;
|
|
99
102
|
};
|
|
100
103
|
export declare type ActiveReaderArguments = UseWebReaderArguments & {
|
|
101
104
|
manifest: WebpubManifest;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { HtmlNavigator,
|
|
2
|
+
import { HtmlNavigator, ReaderState } from '../types';
|
|
3
3
|
export declare type HtmlSettingsProps = {
|
|
4
4
|
navigator: HtmlNavigator;
|
|
5
|
-
readerState:
|
|
5
|
+
readerState: ReaderState;
|
|
6
6
|
paginationValue: string;
|
|
7
7
|
};
|
|
8
|
-
export default function HtmlSettings(props: HtmlSettingsProps): React.ReactElement;
|
|
8
|
+
export default function HtmlSettings(props: HtmlSettingsProps): React.ReactElement | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { PdfNavigator,
|
|
2
|
+
import { PdfNavigator, ReaderState } from '../types';
|
|
3
3
|
export declare type PdfSettingsProps = {
|
|
4
4
|
navigator: PdfNavigator;
|
|
5
|
-
readerState:
|
|
5
|
+
readerState: ReaderState;
|
|
6
6
|
paginationValue: string;
|
|
7
7
|
};
|
|
8
8
|
export default function PdfSettings(props: PdfSettingsProps): React.ReactElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HtmlState } from '../HtmlReader/types';
|
|
2
|
+
import { Locator } from '../Readium/Locator';
|
|
3
|
+
import { ReaderSettings } from '../types';
|
|
4
|
+
export declare type LSLocationRecord = {
|
|
5
|
+
location: Locator;
|
|
6
|
+
createdAt: number;
|
|
7
|
+
};
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nypl/web-reader",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "https://github.com/NYPL-Simplified/web-reader",
|
|
6
6
|
"homepage": "https://github.com/NYPL-Simplified/web-reader",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@babel/core": "^7.12.10",
|
|
81
|
-
"@emotion/jest": "^11.
|
|
82
|
-
"@parcel/transformer-typescript-tsc": "^2.
|
|
81
|
+
"@emotion/jest": "^11.8.0",
|
|
82
|
+
"@parcel/transformer-typescript-tsc": "^2.4.1",
|
|
83
83
|
"@storybook/addon-actions": "^6.3.1",
|
|
84
84
|
"@storybook/addon-essentials": "^6.3.1",
|
|
85
85
|
"@storybook/addon-info": "^5.3.21",
|
|
@@ -88,21 +88,21 @@
|
|
|
88
88
|
"@storybook/addons": "^6.3.1",
|
|
89
89
|
"@storybook/react": "^6.3.1",
|
|
90
90
|
"@testing-library/cypress": "^8.0.2",
|
|
91
|
-
"@testing-library/jest-dom": "^5.
|
|
91
|
+
"@testing-library/jest-dom": "^5.16.3",
|
|
92
92
|
"@testing-library/react": "^12.0.0",
|
|
93
93
|
"@testing-library/react-hooks": "^7.0.1",
|
|
94
94
|
"@types/debounce": "^1.2.0",
|
|
95
95
|
"@types/http-proxy": "^1.17.7",
|
|
96
96
|
"@types/jest-axe": "^3.5.3",
|
|
97
97
|
"@types/node": "^14.17.10",
|
|
98
|
-
"@types/react": "^17.0.
|
|
99
|
-
"@types/react-dom": "^17.0.
|
|
98
|
+
"@types/react": "^17.0.43",
|
|
99
|
+
"@types/react-dom": "^17.0.14",
|
|
100
100
|
"@types/react-pdf": "^5.0.5",
|
|
101
101
|
"@types/react-router-dom": "^5.1.7",
|
|
102
102
|
"@types/rimraf": "^3.0.2",
|
|
103
103
|
"@typescript-eslint/eslint-plugin": "^4.29.2",
|
|
104
104
|
"@typescript-eslint/parser": "^4.29.2",
|
|
105
|
-
"babel-jest": "^27.
|
|
105
|
+
"babel-jest": "^27.5.1",
|
|
106
106
|
"babel-loader": "^8.2.2",
|
|
107
107
|
"cypress": "^9.5.1",
|
|
108
108
|
"debounce": "^1.2.1",
|
|
@@ -118,19 +118,19 @@
|
|
|
118
118
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
119
119
|
"express": "^4.17.1",
|
|
120
120
|
"husky": "^7.0.2",
|
|
121
|
-
"jest": "^27.
|
|
122
|
-
"jest-axe": "^
|
|
123
|
-
"jest-watch-typeahead": "^0.
|
|
121
|
+
"jest": "^27.5.1",
|
|
122
|
+
"jest-axe": "^6.0.0",
|
|
123
|
+
"jest-watch-typeahead": "^1.0.0",
|
|
124
124
|
"lint-staged": "^11.1.2",
|
|
125
|
-
"parcel": "^2.
|
|
125
|
+
"parcel": "^2.4.1",
|
|
126
126
|
"parcel-config-precache-manifest": "^0.0.4",
|
|
127
127
|
"parcel-plugin-static-files-copy": "^2.6.0",
|
|
128
128
|
"parcel-reporter-static-files-copy": "^1.3.0",
|
|
129
129
|
"prettier": "2.2.1",
|
|
130
130
|
"r2-shared-js": "^1.0.49",
|
|
131
|
-
"react": "
|
|
131
|
+
"react": "^17.0.2",
|
|
132
132
|
"react-app-polyfill": "^2.0.0",
|
|
133
|
-
"react-dom": "
|
|
133
|
+
"react-dom": "^17.0.2",
|
|
134
134
|
"react-is": "^17.0.1",
|
|
135
135
|
"react-router-dom": "^5.2.0",
|
|
136
136
|
"release-it": "^14.11.5",
|
|
@@ -138,15 +138,15 @@
|
|
|
138
138
|
"rimraf": "^3.0.2",
|
|
139
139
|
"size-limit": "^4.9.1",
|
|
140
140
|
"start-server-and-test": "^1.14.0",
|
|
141
|
-
"ts-jest": "^27.
|
|
141
|
+
"ts-jest": "^27.1.4",
|
|
142
142
|
"ts-node": "^10.1.0",
|
|
143
143
|
"tslib": "^2.3.1",
|
|
144
144
|
"typescript": "^4.3.5"
|
|
145
145
|
},
|
|
146
146
|
"dependencies": {
|
|
147
|
-
"@chakra-ui/react": "1.
|
|
148
|
-
"@emotion/react": "^11.
|
|
149
|
-
"@emotion/styled": "^11.
|
|
147
|
+
"@chakra-ui/react": "^1.8.7",
|
|
148
|
+
"@emotion/react": "^11.8.2",
|
|
149
|
+
"@emotion/styled": "^11.8.1",
|
|
150
150
|
"comlink": "^4.3.1",
|
|
151
151
|
"framer-motion": "^4.1.6",
|
|
152
152
|
"node-fetch": "^2.6.1",
|