@nypl/web-reader 0.1.4 → 0.2.0-alpha.3
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 +2 -0
- package/dist/cjs/ServiceWorker/sw.js.map +7 -0
- package/dist/cjs/index.js +683 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/ServiceWorker/sw.js +1263 -0
- package/dist/esm/ServiceWorker/sw.js.map +7 -0
- package/dist/esm/index.js +88803 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/html-styles.css +2 -0
- package/dist/html-styles.css.map +7 -0
- package/dist/pdf-styles.css +2 -0
- package/dist/pdf-styles.css.map +7 -0
- package/dist/{HtmlReader → types/HtmlReader}/HtmlReaderContent.d.ts +3 -3
- package/dist/{HtmlReader → types/HtmlReader}/index.d.ts +22 -22
- package/dist/{HtmlReader → types/HtmlReader}/injectables.d.ts +30 -30
- package/dist/{PdfReader → types/PdfReader}/index.d.ts +11 -12
- package/dist/{PdfReader → types/PdfReader}/useMeasure.d.ts +7 -4
- package/dist/{ServiceWorker → types/ServiceWorker}/client.d.ts +9 -9
- package/dist/{ServiceWorker → types/ServiceWorker}/constants.d.ts +3 -3
- package/{src/ServiceWorker/index.ts → dist/types/ServiceWorker/index.d.ts} +0 -0
- package/dist/{ServiceWorker → types/ServiceWorker}/sw.d.ts +7 -7
- package/dist/{ServiceWorker → types/ServiceWorker}/types.d.ts +3 -3
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/ConformsTo.d.ts +3 -3
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/Contributor.d.ts +17 -17
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/EpubExtension.d.ts +47 -47
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/LanguageMap.d.ts +3 -3
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/Metadata.d.ts +46 -46
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/OPDSLink.d.ts +63 -63
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/PresentationHints.d.ts +53 -53
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/ReadiumLink.d.ts +58 -58
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/Subject.d.ts +16 -16
- package/dist/{WebpubManifestTypes → types/WebpubManifestTypes}/WebpubManifest.d.ts +14 -14
- package/dist/{constants.d.ts → types/constants.d.ts} +2 -2
- package/dist/{index.d.ts → types/index.d.ts} +7 -7
- package/dist/{types.d.ts → types/types.d.ts} +66 -66
- package/dist/{ui → types/ui}/Button.d.ts +9 -7
- package/dist/{ui → types/ui}/Header.d.ts +6 -6
- package/dist/{ui → types/ui}/HtmlSettings.d.ts +9 -9
- package/dist/{ui → types/ui}/PageButton.d.ts +7 -7
- package/dist/{ui → types/ui}/PdfSettings.d.ts +9 -9
- package/dist/{ui → types/ui}/SettingsButton.d.ts +5 -5
- package/dist/{ui → types/ui}/TableOfContent.d.ts +7 -7
- package/dist/{ui → types/ui}/ToggleButton.d.ts +10 -10
- package/dist/{ui → types/ui}/ToggleGroup.d.ts +8 -8
- package/dist/{ui → types/ui}/constants.d.ts +1 -1
- package/dist/{ui → types/ui}/hooks/useColorModeValue.d.ts +7 -7
- package/dist/{ui → types/ui}/hooks/useContainerWidth.d.ts +6 -6
- package/dist/{ui → types/ui}/hooks/useEventListener.d.ts +8 -8
- package/dist/{ui → types/ui}/manager.d.ts +9 -9
- package/dist/{ui → types/ui}/nypl-base-theme/components/button.d.ts +94 -94
- package/dist/{ui → types/ui}/nypl-base-theme/components/checkbox.d.ts +41 -41
- package/dist/{ui → types/ui}/nypl-base-theme/components/form-error.d.ts +14 -14
- package/dist/{ui → types/ui}/nypl-base-theme/components/form-label.d.ts +14 -14
- package/dist/{ui → types/ui}/nypl-base-theme/components/form.d.ts +15 -15
- package/dist/{ui → types/ui}/nypl-base-theme/components/input.d.ts +107 -107
- package/dist/{ui → types/ui}/nypl-base-theme/components/text-area.d.ts +34 -34
- package/dist/{ui → types/ui}/nypl-base-theme/foundations/breakpoints.d.ts +8 -8
- package/dist/{ui → types/ui}/nypl-base-theme/foundations/colors.d.ts +3 -3
- package/dist/{ui → types/ui}/nypl-base-theme/foundations/global.d.ts +13 -13
- package/dist/{ui → types/ui}/nypl-base-theme/foundations/radii.d.ts +12 -12
- package/dist/{ui → types/ui}/nypl-base-theme/foundations/spacing.d.ts +49 -49
- package/dist/{ui → types/ui}/nypl-base-theme/foundations/typography.d.ts +10 -10
- package/dist/{ui → types/ui}/nypl-base-theme/index.d.ts +6 -6
- package/dist/{ui → types/ui}/nypl-base-theme/types.d.ts +1 -1
- package/dist/{ui → types/ui}/theme/components/button.d.ts +78 -78
- package/dist/{ui → types/ui}/theme/components/text.d.ts +20 -20
- package/dist/{ui → types/ui}/theme/foundations/colors.d.ts +3 -3
- package/dist/{ui → types/ui}/theme/index.d.ts +11 -11
- package/dist/{ui → types/ui}/theme/types.d.ts +1 -1
- package/dist/{useWebReader.d.ts → types/useWebReader.d.ts} +7 -7
- package/dist/{utils → types/utils}/decryptAxisNow.d.ts +0 -0
- package/dist/{utils → types/utils}/fetch.d.ts +4 -4
- package/dist/{utils → types/utils}/getColor.d.ts +2 -2
- package/dist/{utils → types/utils}/toggleFullScreen.d.ts +5 -5
- package/package.json +21 -33
- package/dist/ServiceWorker/index.d.ts +0 -1
- package/dist/index.js +0 -8
- package/dist/web-reader.cjs.development.js +0 -3363
- package/dist/web-reader.cjs.development.js.map +0 -1
- package/dist/web-reader.cjs.production.min.js +0 -2
- package/dist/web-reader.cjs.production.min.js.map +0 -1
- package/dist/web-reader.esm.js +0 -3356
- package/dist/web-reader.esm.js.map +0 -1
- package/src/HtmlReader/HtmlReaderContent.tsx +0 -19
- package/src/HtmlReader/index.tsx +0 -262
- package/src/HtmlReader/injectables.ts +0 -26
- package/src/PdfReader/index.tsx +0 -492
- package/src/PdfReader/useMeasure.tsx +0 -68
- package/src/ServiceWorker/client.ts +0 -106
- package/src/ServiceWorker/constants.ts +0 -4
- package/src/ServiceWorker/sw.ts +0 -84
- package/src/ServiceWorker/types.ts +0 -3
- package/src/WebpubManifestTypes/ConformsTo.ts +0 -9
- package/src/WebpubManifestTypes/Contributor.ts +0 -24
- package/src/WebpubManifestTypes/EpubExtension.ts +0 -48
- package/src/WebpubManifestTypes/LanguageMap.ts +0 -5
- package/src/WebpubManifestTypes/Metadata.ts +0 -48
- package/src/WebpubManifestTypes/OPDSLink.ts +0 -251
- package/src/WebpubManifestTypes/PresentationHints.ts +0 -54
- package/src/WebpubManifestTypes/ReadiumLink.ts +0 -61
- package/src/WebpubManifestTypes/Subject.ts +0 -20
- package/src/WebpubManifestTypes/WebpubManifest.ts +0 -15
- package/src/constants.ts +0 -3
- package/src/index.tsx +0 -25
- package/src/types.ts +0 -94
- package/src/ui/Button.tsx +0 -12
- package/src/ui/Header.tsx +0 -89
- package/src/ui/HtmlSettings.tsx +0 -97
- package/src/ui/PageButton.tsx +0 -39
- package/src/ui/PdfSettings.tsx +0 -85
- package/src/ui/SettingsButton.tsx +0 -71
- package/src/ui/TableOfContent.tsx +0 -144
- package/src/ui/ToggleButton.tsx +0 -60
- package/src/ui/ToggleGroup.tsx +0 -41
- package/src/ui/constants.ts +0 -2
- package/src/ui/hooks/useColorModeValue.tsx +0 -19
- package/src/ui/hooks/useContainerWidth.ts +0 -24
- package/src/ui/hooks/useEventListener.ts +0 -26
- package/src/ui/manager.tsx +0 -73
- package/src/ui/nypl-base-theme/components/button.ts +0 -117
- package/src/ui/nypl-base-theme/components/checkbox.ts +0 -45
- package/src/ui/nypl-base-theme/components/form-error.ts +0 -15
- package/src/ui/nypl-base-theme/components/form-label.ts +0 -15
- package/src/ui/nypl-base-theme/components/form.ts +0 -16
- package/src/ui/nypl-base-theme/components/input.ts +0 -101
- package/src/ui/nypl-base-theme/components/text-area.ts +0 -17
- package/src/ui/nypl-base-theme/foundations/breakpoints.ts +0 -10
- package/src/ui/nypl-base-theme/foundations/colors.ts +0 -136
- package/src/ui/nypl-base-theme/foundations/global.ts +0 -16
- package/src/ui/nypl-base-theme/foundations/radii.ts +0 -13
- package/src/ui/nypl-base-theme/foundations/spacing.ts +0 -58
- package/src/ui/nypl-base-theme/foundations/typography.ts +0 -43
- package/src/ui/nypl-base-theme/index.ts +0 -42
- package/src/ui/nypl-base-theme/types.ts +0 -1
- package/src/ui/theme/components/button.ts +0 -85
- package/src/ui/theme/components/text.ts +0 -24
- package/src/ui/theme/foundations/colors.ts +0 -10
- package/src/ui/theme/index.ts +0 -34
- package/src/ui/theme/types.ts +0 -1
- package/src/useWebReader.tsx +0 -105
- package/src/utils/decryptAxisNow.ts +0 -45
- package/src/utils/fetch.ts +0 -13
- package/src/utils/getColor.ts +0 -14
- package/src/utils/toggleFullScreen.ts +0 -71
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A comprehensive spacin scale based on NYPL Design System,
|
|
3
|
-
* with intermediate values interpolated. Those marked with comments
|
|
4
|
-
* are directly from the NYPL DS.
|
|
5
|
-
*
|
|
6
|
-
* 1 spacing unit is 4px or 0.25rem.
|
|
7
|
-
*
|
|
8
|
-
* Mental model: If you need a spacing of 40px, divide it by 4.
|
|
9
|
-
* That'll give you 10. Then use it in your component.
|
|
10
|
-
*/
|
|
11
|
-
const spacing = {
|
|
12
|
-
space: {
|
|
13
|
-
px: '1px',
|
|
14
|
-
0: '0',
|
|
15
|
-
0.5: '0.125rem',
|
|
16
|
-
// 4px
|
|
17
|
-
1: '0.25rem',
|
|
18
|
-
1.5: '0.375rem',
|
|
19
|
-
// 8px
|
|
20
|
-
2: '0.5rem',
|
|
21
|
-
2.5: '0.625rem',
|
|
22
|
-
3: '0.75rem',
|
|
23
|
-
3.5: '0.875rem',
|
|
24
|
-
// 16px
|
|
25
|
-
4: '1rem',
|
|
26
|
-
5: '1.25rem',
|
|
27
|
-
// 24px
|
|
28
|
-
6: '1.5rem',
|
|
29
|
-
7: '1.75rem',
|
|
30
|
-
// 32 px
|
|
31
|
-
8: '2rem',
|
|
32
|
-
9: '2.25rem',
|
|
33
|
-
10: '2.5rem',
|
|
34
|
-
// 48px
|
|
35
|
-
12: '3rem',
|
|
36
|
-
14: '3.5rem',
|
|
37
|
-
// 64px
|
|
38
|
-
16: '4rem',
|
|
39
|
-
20: '5rem',
|
|
40
|
-
// 96px
|
|
41
|
-
24: '6rem',
|
|
42
|
-
28: '7rem',
|
|
43
|
-
32: '8rem',
|
|
44
|
-
36: '9rem',
|
|
45
|
-
40: '10rem',
|
|
46
|
-
44: '11rem',
|
|
47
|
-
48: '12rem',
|
|
48
|
-
52: '13rem',
|
|
49
|
-
56: '14rem',
|
|
50
|
-
60: '15rem',
|
|
51
|
-
64: '16rem',
|
|
52
|
-
72: '18rem',
|
|
53
|
-
80: '20rem',
|
|
54
|
-
96: '24rem',
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default spacing;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Dict } from '../types';
|
|
2
|
-
|
|
3
|
-
type Typography = {
|
|
4
|
-
letterSpacings: Dict;
|
|
5
|
-
lineHeights: Dict;
|
|
6
|
-
fontWeights: Dict;
|
|
7
|
-
fonts: Dict;
|
|
8
|
-
fontSizes: Dict;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const typography: Typography = {
|
|
12
|
-
fonts: {
|
|
13
|
-
body: '-apple-system, BlinkMacSystemFont, system-ui, sans-serif',
|
|
14
|
-
heading: '-apple-system, BlinkMacSystemFont, system-ui, sans-seri',
|
|
15
|
-
mono: `Courier,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace`,
|
|
16
|
-
},
|
|
17
|
-
fontSizes: {
|
|
18
|
-
'-2': '0.75rem',
|
|
19
|
-
'-1': '0.875rem',
|
|
20
|
-
'0': '1rem',
|
|
21
|
-
'1': '1.125rem',
|
|
22
|
-
'2': '1.25rem',
|
|
23
|
-
'3': '1.75rem',
|
|
24
|
-
'4': '2.25rem',
|
|
25
|
-
'5': '3rem',
|
|
26
|
-
},
|
|
27
|
-
fontWeights: {
|
|
28
|
-
light: 300,
|
|
29
|
-
regular: 400,
|
|
30
|
-
medium: 500,
|
|
31
|
-
bold: 700,
|
|
32
|
-
},
|
|
33
|
-
lineHeights: [1, 1.1, 1.25, 1.5],
|
|
34
|
-
letterSpacings: {
|
|
35
|
-
tighter: '-0.05em',
|
|
36
|
-
tight: '-0.025em',
|
|
37
|
-
normal: '0',
|
|
38
|
-
wide: '0.025em',
|
|
39
|
-
wider: '0.05em',
|
|
40
|
-
widest: '0.1em',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
export default typography;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { extendTheme } from '@chakra-ui/react';
|
|
2
|
-
import Button from './components/button';
|
|
3
|
-
import breakpoints from './foundations/breakpoints';
|
|
4
|
-
import typography from './foundations/typography';
|
|
5
|
-
import colors from './foundations/colors';
|
|
6
|
-
import radii from './foundations/radii';
|
|
7
|
-
import spacing from './foundations/spacing';
|
|
8
|
-
import Checkbox from './components/checkbox';
|
|
9
|
-
import Input from './components/input';
|
|
10
|
-
import global from './foundations/global';
|
|
11
|
-
import FormLabel from './components/form-label';
|
|
12
|
-
import Form from './components/form';
|
|
13
|
-
import FormError from './components/form-error';
|
|
14
|
-
import Textarea from './components/text-area';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* See Chakra default theme for shape of theme object:
|
|
18
|
-
* https://github.com/chakra-ui/chakra-ui/tree/main/packages/theme
|
|
19
|
-
*/
|
|
20
|
-
const theme = extendTheme({
|
|
21
|
-
styles: { global },
|
|
22
|
-
breakpoints,
|
|
23
|
-
radii,
|
|
24
|
-
colors,
|
|
25
|
-
...typography,
|
|
26
|
-
space: spacing,
|
|
27
|
-
/**
|
|
28
|
-
* Chakra documentation on component styles:
|
|
29
|
-
* https://chakra-ui.com/docs/theming/component-style
|
|
30
|
-
*/
|
|
31
|
-
components: {
|
|
32
|
-
Button,
|
|
33
|
-
Checkbox,
|
|
34
|
-
Input,
|
|
35
|
-
FormLabel,
|
|
36
|
-
Form,
|
|
37
|
-
FormError,
|
|
38
|
-
Textarea,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export default theme;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Dict<T = any> = Record<string, T>;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { GetColor } from '../../../types';
|
|
2
|
-
|
|
3
|
-
const getButtonStyle = (getColor: GetColor) => ({
|
|
4
|
-
// style object for base or default style
|
|
5
|
-
baseStyle: {
|
|
6
|
-
borderRadius: 'none',
|
|
7
|
-
},
|
|
8
|
-
// styles for different sizes ("sm", "md", "lg")
|
|
9
|
-
sizes: {},
|
|
10
|
-
// styles for different visual variants ("outline", "solid")
|
|
11
|
-
variants: {
|
|
12
|
-
solid: variantSolid(getColor),
|
|
13
|
-
toggle: variantToggle(getColor),
|
|
14
|
-
},
|
|
15
|
-
// default values for `size`, `variant`, `colorScheme`
|
|
16
|
-
defaultProps: {
|
|
17
|
-
size: 'sm',
|
|
18
|
-
variant: 'solid',
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
/* Color Schemes:
|
|
23
|
-
** Light, Sepia, Dark
|
|
24
|
-
* States:
|
|
25
|
-
** Normal
|
|
26
|
-
** Selected
|
|
27
|
-
** Disabled
|
|
28
|
-
** Hovered
|
|
29
|
-
*/
|
|
30
|
-
const variantSolid = (getColor: GetColor) => (props: any) => {
|
|
31
|
-
const bgColor = getColor('ui.white', 'ui.black', 'ui.sepia');
|
|
32
|
-
const color = getColor('gray.800', 'ui.white', 'gray.800');
|
|
33
|
-
|
|
34
|
-
const _focus = { bgColor, color };
|
|
35
|
-
const _hover = { bgColor, color, _disabled: { bgColor } };
|
|
36
|
-
const _active = { bgColor, color };
|
|
37
|
-
const _checked = { bgColor, color };
|
|
38
|
-
const _disabled = { bgColor };
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
border: '1px solid',
|
|
42
|
-
borderColor: 'gray.100',
|
|
43
|
-
transition: 'none',
|
|
44
|
-
fontSize: 0,
|
|
45
|
-
letterSpacing: 1,
|
|
46
|
-
textTransform: 'uppercase',
|
|
47
|
-
maxWidth: '100%',
|
|
48
|
-
cursor: 'pointer',
|
|
49
|
-
bgColor,
|
|
50
|
-
color,
|
|
51
|
-
_focus,
|
|
52
|
-
_hover,
|
|
53
|
-
_active,
|
|
54
|
-
_checked,
|
|
55
|
-
_disabled,
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const variantToggle = (getColor: GetColor) => (props: any) => {
|
|
60
|
-
const bgColor = getColor('ui.white', 'gray.800', 'ui.white');
|
|
61
|
-
const color = getColor('gray.800', 'ui.white', 'gray.800');
|
|
62
|
-
return {
|
|
63
|
-
...variantSolid(getColor)(props),
|
|
64
|
-
bgColor,
|
|
65
|
-
color,
|
|
66
|
-
px: 8,
|
|
67
|
-
fontWeight: 'medium',
|
|
68
|
-
fontSize: -2,
|
|
69
|
-
_focus: {
|
|
70
|
-
bgColor,
|
|
71
|
-
},
|
|
72
|
-
_hover: {
|
|
73
|
-
bgColor,
|
|
74
|
-
},
|
|
75
|
-
_active: {
|
|
76
|
-
bgColor,
|
|
77
|
-
},
|
|
78
|
-
_checked: {
|
|
79
|
-
color: 'ui.white',
|
|
80
|
-
bgColor: 'green.700',
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export default getButtonStyle;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const TextStyle = {
|
|
2
|
-
// style object for base or default style
|
|
3
|
-
baseStyle: {},
|
|
4
|
-
// styles for different sizes ("sm", "md", "lg")
|
|
5
|
-
sizes: {},
|
|
6
|
-
// styles for different visual variants ("outline", "solid")
|
|
7
|
-
variants: {
|
|
8
|
-
headerNav: variantHeaderNav,
|
|
9
|
-
},
|
|
10
|
-
// default values for `size`, `variant`, `colorScheme`
|
|
11
|
-
defaultProps: {},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function variantHeaderNav() {
|
|
15
|
-
return {
|
|
16
|
-
pl: 2,
|
|
17
|
-
my: 0,
|
|
18
|
-
letterSpacing: 1,
|
|
19
|
-
fontSize: 0,
|
|
20
|
-
display: { sm: 'none', md: 'none', lg: 'inline-block' },
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default TextStyle;
|
package/src/ui/theme/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { extendTheme } from '@chakra-ui/react';
|
|
2
|
-
import Text from './components/text';
|
|
3
|
-
import colors from './foundations/colors';
|
|
4
|
-
import nyplTheme from '../nypl-base-theme';
|
|
5
|
-
import { ColorMode } from '../../types';
|
|
6
|
-
import { getColor } from '../../utils/getColor';
|
|
7
|
-
import getButtonStyle from './components/button';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* See Chakra default theme for shape of theme object:
|
|
11
|
-
* https://github.com/chakra-ui/chakra-ui/tree/main/packages/theme
|
|
12
|
-
*
|
|
13
|
-
* Making this a function because we need to adjust the theme based
|
|
14
|
-
* on the colorMode that's being passed in.
|
|
15
|
-
*
|
|
16
|
-
* Returns the chakra theme object with an additional property `currentColorMode`
|
|
17
|
-
*/
|
|
18
|
-
export function getTheme(colorMode: ColorMode) {
|
|
19
|
-
return extendTheme(
|
|
20
|
-
{
|
|
21
|
-
colors,
|
|
22
|
-
/**
|
|
23
|
-
* Chakra documentation on component styles:
|
|
24
|
-
* https://chakra-ui.com/docs/theming/component-style
|
|
25
|
-
*/
|
|
26
|
-
components: {
|
|
27
|
-
Button: getButtonStyle(getColor(colorMode)),
|
|
28
|
-
Text,
|
|
29
|
-
},
|
|
30
|
-
currentColorMode: colorMode,
|
|
31
|
-
},
|
|
32
|
-
nyplTheme
|
|
33
|
-
);
|
|
34
|
-
}
|
package/src/ui/theme/types.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Dict<T = any> = Record<string, T>;
|
package/src/useWebReader.tsx
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fetchJson } from './utils/fetch';
|
|
3
|
-
import HtmlReaderContent from './HtmlReader/HtmlReaderContent';
|
|
4
|
-
import usePdfReader from './PdfReader';
|
|
5
|
-
import useHtmlReader from './HtmlReader';
|
|
6
|
-
import {
|
|
7
|
-
ActiveReader,
|
|
8
|
-
UseWebReaderArguments,
|
|
9
|
-
HTMLActiveReader,
|
|
10
|
-
LoadingReader,
|
|
11
|
-
PDFActiveReader,
|
|
12
|
-
WebpubManifest,
|
|
13
|
-
} from './types';
|
|
14
|
-
import {
|
|
15
|
-
AxisNowEpubConformsTo,
|
|
16
|
-
WebpubPdfConformsTo,
|
|
17
|
-
ConformsTo,
|
|
18
|
-
} from './WebpubManifestTypes/ConformsTo';
|
|
19
|
-
|
|
20
|
-
function getReaderType(conformsTo: ConformsTo | null | undefined) {
|
|
21
|
-
switch (conformsTo) {
|
|
22
|
-
case AxisNowEpubConformsTo:
|
|
23
|
-
return 'HTML';
|
|
24
|
-
case WebpubPdfConformsTo:
|
|
25
|
-
return 'PDF';
|
|
26
|
-
case undefined:
|
|
27
|
-
// the manifest didn't indicate any conformsTo,
|
|
28
|
-
// so return our default
|
|
29
|
-
return 'HTML';
|
|
30
|
-
case null:
|
|
31
|
-
// the manifest is still loading, return undefined
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The React hook that exposes the main API into the reader. It
|
|
38
|
-
* will determine the type of the webpub, and then use the correct reader
|
|
39
|
-
* for that type.
|
|
40
|
-
*/
|
|
41
|
-
export default function useWebReader(
|
|
42
|
-
args: UseWebReaderArguments
|
|
43
|
-
): HTMLActiveReader | PDFActiveReader | LoadingReader {
|
|
44
|
-
const { webpubManifestUrl, getContent, proxyUrl } = args;
|
|
45
|
-
const [manifest, setManifest] = React.useState<WebpubManifest | null>(null);
|
|
46
|
-
const readerType = getReaderType(
|
|
47
|
-
manifest ? manifest.metadata.conformsTo : null
|
|
48
|
-
);
|
|
49
|
-
/**
|
|
50
|
-
* Our HTML reader and PDf Reader. Note that we cannot conditionally
|
|
51
|
-
* call a React hook, so we must _always_ call the hook, but allow for the
|
|
52
|
-
* case where we call the hook with `undefined`, which tells the hook that
|
|
53
|
-
* that format is inactive, and it will in turn return the InactiveState.
|
|
54
|
-
*/
|
|
55
|
-
const htmlReader = useHtmlReader(
|
|
56
|
-
readerType === 'HTML' && manifest
|
|
57
|
-
? {
|
|
58
|
-
webpubManifestUrl,
|
|
59
|
-
manifest,
|
|
60
|
-
getContent,
|
|
61
|
-
}
|
|
62
|
-
: undefined
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const pdfReader = usePdfReader(
|
|
66
|
-
readerType === 'PDF' && manifest
|
|
67
|
-
? {
|
|
68
|
-
webpubManifestUrl,
|
|
69
|
-
manifest,
|
|
70
|
-
proxyUrl,
|
|
71
|
-
}
|
|
72
|
-
: undefined
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
// fetch the manifest and set it in state
|
|
76
|
-
React.useEffect(() => {
|
|
77
|
-
fetchJson<WebpubManifest>(webpubManifestUrl).then(setManifest);
|
|
78
|
-
}, [webpubManifestUrl]);
|
|
79
|
-
|
|
80
|
-
// first if we are still fetching the manifest, return loading
|
|
81
|
-
if (manifest === null) {
|
|
82
|
-
return {
|
|
83
|
-
isLoading: true,
|
|
84
|
-
content: <HtmlReaderContent />,
|
|
85
|
-
manifest: null,
|
|
86
|
-
navigator: null,
|
|
87
|
-
state: null,
|
|
88
|
-
type: null,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Return whichever reader is not Inactive (not `null`)
|
|
94
|
-
*/
|
|
95
|
-
if (htmlReader) {
|
|
96
|
-
return htmlReader;
|
|
97
|
-
}
|
|
98
|
-
if (pdfReader) {
|
|
99
|
-
return pdfReader;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
throw new Error(
|
|
103
|
-
`No reader was initialized for the webpub with url: ${webpubManifestUrl} and type: ${readerType}.`
|
|
104
|
-
);
|
|
105
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// import Decryptor from '@nypl-simplified-packages/axisnow-access-control-web';
|
|
2
|
-
// import { GetContent } from '../types';
|
|
3
|
-
|
|
4
|
-
// /**
|
|
5
|
-
// * Utilities to decrypt AxisNow documents. Eventually this should be passed in
|
|
6
|
-
// * by the consuming application - Open eBooks in this case. For testing though,
|
|
7
|
-
// * we have them here for now.
|
|
8
|
-
// */
|
|
9
|
-
|
|
10
|
-
// // hardcoded with a specific isbn and vault id for now.
|
|
11
|
-
// export async function initDecryptor(): Promise<Decryptor> {
|
|
12
|
-
// const params = {
|
|
13
|
-
// book_vault_uuid: 'F58373FB-6574-45E6-B50E-6D73523AFD01',
|
|
14
|
-
// isbn: '9781467784870',
|
|
15
|
-
// };
|
|
16
|
-
// return await Decryptor.createDecryptor(params);
|
|
17
|
-
// }
|
|
18
|
-
|
|
19
|
-
// /*
|
|
20
|
-
// Convert a string into an ArrayBuffer
|
|
21
|
-
// from https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
|
|
22
|
-
// */
|
|
23
|
-
// function ab2str(buf: Iterable<number>) {
|
|
24
|
-
// const decoder = new TextDecoder('utf-8');
|
|
25
|
-
// return decoder.decode(new Uint8Array(buf));
|
|
26
|
-
// }
|
|
27
|
-
|
|
28
|
-
// // a function that builds a getContent function with a decryptor.
|
|
29
|
-
// export const makeGetContent = (decryptor: Decryptor): GetContent => async (
|
|
30
|
-
// href: string
|
|
31
|
-
// ): Promise<string> => {
|
|
32
|
-
// // the href is the readingOrder href, which we use to know which
|
|
33
|
-
// // resource we need to fetch and decrypt
|
|
34
|
-
// const result = await fetch(href);
|
|
35
|
-
// const blob = await result.blob();
|
|
36
|
-
// const blobUrl = URL.createObjectURL(blob);
|
|
37
|
-
// const decrypted = await decryptor.decryptUrl(blobUrl);
|
|
38
|
-
// URL.revokeObjectURL(blobUrl);
|
|
39
|
-
// const html = new DOMParser().parseFromString(
|
|
40
|
-
// ab2str(decrypted),
|
|
41
|
-
// 'application/xhtml+xml'
|
|
42
|
-
// ).documentElement;
|
|
43
|
-
// console.log(html);
|
|
44
|
-
// return ab2str(decrypted);
|
|
45
|
-
// };
|
package/src/utils/fetch.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for fetching specific types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export async function fetchJson<ExpectedResponse extends any = any>(
|
|
6
|
-
url: string
|
|
7
|
-
) {
|
|
8
|
-
const response = await fetch(url);
|
|
9
|
-
if (!response.ok) {
|
|
10
|
-
throw new Error('Response not Ok for URL: ' + url);
|
|
11
|
-
}
|
|
12
|
-
return (await response.json()) as ExpectedResponse;
|
|
13
|
-
}
|
package/src/utils/getColor.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ColorMode } from '../types';
|
|
2
|
-
|
|
3
|
-
export function getColor(colorMode: ColorMode) {
|
|
4
|
-
return (light: string, dark: string, sepia: string): string => {
|
|
5
|
-
switch (colorMode) {
|
|
6
|
-
case 'day':
|
|
7
|
-
return light;
|
|
8
|
-
case 'night':
|
|
9
|
-
return dark;
|
|
10
|
-
case 'sepia':
|
|
11
|
-
return sepia;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Methods for Firefox / Safari / Edge
|
|
2
|
-
// We have to cast these types so typescript doesn't complain
|
|
3
|
-
interface FullSpecDocument extends Document {
|
|
4
|
-
mozFullScreenElement: Element | null;
|
|
5
|
-
webkitFullscreenElement: Element | null;
|
|
6
|
-
msFullscreenElement: Element | null;
|
|
7
|
-
webkitFullscreenEnabled: boolean;
|
|
8
|
-
mozFullScreenEnabled: boolean;
|
|
9
|
-
msFullscreenEnabled: boolean;
|
|
10
|
-
mozCancelFullScreen: () => Promise<void>;
|
|
11
|
-
webkitExitFullscreen: () => Promise<void>;
|
|
12
|
-
msExitFullscreen: () => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface FullSpecElement extends HTMLElement {
|
|
16
|
-
mozRequestFullScreen: (options?: FullscreenOptions) => Promise<void>;
|
|
17
|
-
webkitRequestFullscreen: (options?: FullscreenOptions) => Promise<void>;
|
|
18
|
-
msRequestFullscreen: (options?: FullscreenOptions) => Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const doc = document as FullSpecDocument;
|
|
22
|
-
const docElm = document.documentElement as FullSpecElement;
|
|
23
|
-
|
|
24
|
-
// For Safari IOS: Only available on iPad, not on iPhone.
|
|
25
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenEnabled#browser_compatibility
|
|
26
|
-
export const fullScreenEnabled =
|
|
27
|
-
doc.fullscreenEnabled ||
|
|
28
|
-
doc.webkitFullscreenEnabled ||
|
|
29
|
-
doc.mozFullScreenEnabled ||
|
|
30
|
-
doc.msFullscreenEnabled;
|
|
31
|
-
|
|
32
|
-
const enterFullScreen = () => {
|
|
33
|
-
const fullScreenFunc =
|
|
34
|
-
docElm.requestFullscreen ||
|
|
35
|
-
docElm.mozRequestFullScreen ||
|
|
36
|
-
docElm.webkitRequestFullscreen ||
|
|
37
|
-
docElm.msRequestFullscreen;
|
|
38
|
-
|
|
39
|
-
if (typeof fullScreenFunc === 'function') {
|
|
40
|
-
fullScreenFunc.call(docElm);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const exitFullScreen = () => {
|
|
45
|
-
const exitFunc =
|
|
46
|
-
doc.exitFullscreen ||
|
|
47
|
-
doc.mozCancelFullScreen ||
|
|
48
|
-
doc.webkitExitFullscreen ||
|
|
49
|
-
doc.msExitFullscreen;
|
|
50
|
-
|
|
51
|
-
if (typeof exitFunc === 'function') {
|
|
52
|
-
exitFunc.call(doc);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Toggles fullscreen mode on the <html> element.
|
|
58
|
-
*/
|
|
59
|
-
export function toggleFullScreen() {
|
|
60
|
-
const isFullscreen =
|
|
61
|
-
doc.fullscreenElement ||
|
|
62
|
-
doc.mozFullScreenElement ||
|
|
63
|
-
doc.webkitFullscreenElement ||
|
|
64
|
-
doc.msFullscreenElement;
|
|
65
|
-
|
|
66
|
-
if (isFullscreen) {
|
|
67
|
-
exitFullScreen();
|
|
68
|
-
} else {
|
|
69
|
-
enterFullScreen();
|
|
70
|
-
}
|
|
71
|
-
}
|