@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,3363 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var React__default = _interopDefault(React);
|
|
9
|
-
var react = require('@chakra-ui/react');
|
|
10
|
-
var designSystemReactComponents = require('@nypl/design-system-react-components');
|
|
11
|
-
var react$1 = require('@emotion/react');
|
|
12
|
-
var themeTools = require('@chakra-ui/theme-tools');
|
|
13
|
-
var reactPdf = require('react-pdf');
|
|
14
|
-
require('react-pdf/dist/esm/Page/AnnotationLayer.css');
|
|
15
|
-
var D2Reader = _interopDefault(require('@d-i-t-a/reader'));
|
|
16
|
-
|
|
17
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
18
|
-
try {
|
|
19
|
-
var info = gen[key](arg);
|
|
20
|
-
var value = info.value;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
reject(error);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (info.done) {
|
|
27
|
-
resolve(value);
|
|
28
|
-
} else {
|
|
29
|
-
Promise.resolve(value).then(_next, _throw);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function _asyncToGenerator(fn) {
|
|
34
|
-
return function () {
|
|
35
|
-
var self = this,
|
|
36
|
-
args = arguments;
|
|
37
|
-
return new Promise(function (resolve, reject) {
|
|
38
|
-
var gen = fn.apply(self, args);
|
|
39
|
-
|
|
40
|
-
function _next(value) {
|
|
41
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _throw(err) {
|
|
45
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
_next(undefined);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function _extends() {
|
|
54
|
-
_extends = Object.assign || function (target) {
|
|
55
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
56
|
-
var source = arguments[i];
|
|
57
|
-
|
|
58
|
-
for (var key in source) {
|
|
59
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
60
|
-
target[key] = source[key];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return target;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return _extends.apply(this, arguments);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
72
|
-
if (source == null) return {};
|
|
73
|
-
var target = {};
|
|
74
|
-
var sourceKeys = Object.keys(source);
|
|
75
|
-
var key, i;
|
|
76
|
-
|
|
77
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
78
|
-
key = sourceKeys[i];
|
|
79
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
80
|
-
target[key] = source[key];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return target;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getColor(colorMode) {
|
|
87
|
-
return function (light, dark, sepia) {
|
|
88
|
-
switch (colorMode) {
|
|
89
|
-
case 'day':
|
|
90
|
-
return light;
|
|
91
|
-
|
|
92
|
-
case 'night':
|
|
93
|
-
return dark;
|
|
94
|
-
|
|
95
|
-
case 'sepia':
|
|
96
|
-
return sepia;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
var useColorModeValue = function useColorModeValue(light, dark, sepia) {
|
|
102
|
-
var _useTheme = react$1.useTheme(),
|
|
103
|
-
currentColorMode = _useTheme.currentColorMode;
|
|
104
|
-
|
|
105
|
-
var color = getColor(currentColorMode)(light, dark, sepia);
|
|
106
|
-
return color;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
var doc = document;
|
|
110
|
-
var docElm = document.documentElement; // For Safari IOS: Only available on iPad, not on iPhone.
|
|
111
|
-
|
|
112
|
-
var enterFullScreen = function enterFullScreen() {
|
|
113
|
-
var fullScreenFunc = docElm.requestFullscreen || docElm.mozRequestFullScreen || docElm.webkitRequestFullscreen || docElm.msRequestFullscreen;
|
|
114
|
-
|
|
115
|
-
if (typeof fullScreenFunc === 'function') {
|
|
116
|
-
fullScreenFunc.call(docElm);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
var exitFullScreen = function exitFullScreen() {
|
|
121
|
-
var exitFunc = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
|
|
122
|
-
|
|
123
|
-
if (typeof exitFunc === 'function') {
|
|
124
|
-
exitFunc.call(doc);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Toggles fullscreen mode on the <html> element.
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
function toggleFullScreen() {
|
|
133
|
-
var isFullscreen = doc.fullscreenElement || doc.mozFullScreenElement || doc.webkitFullscreenElement || doc.msFullscreenElement;
|
|
134
|
-
|
|
135
|
-
if (isFullscreen) {
|
|
136
|
-
exitFullScreen();
|
|
137
|
-
} else {
|
|
138
|
-
enterFullScreen();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
var Button = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
143
|
-
return React__default.createElement(react.Button, Object.assign({
|
|
144
|
-
ref: ref,
|
|
145
|
-
variant: "solid"
|
|
146
|
-
}, props));
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
var TextStyle = {
|
|
150
|
-
// style object for base or default style
|
|
151
|
-
baseStyle: {},
|
|
152
|
-
// styles for different sizes ("sm", "md", "lg")
|
|
153
|
-
sizes: {},
|
|
154
|
-
// styles for different visual variants ("outline", "solid")
|
|
155
|
-
variants: {
|
|
156
|
-
headerNav: variantHeaderNav
|
|
157
|
-
},
|
|
158
|
-
// default values for `size`, `variant`, `colorScheme`
|
|
159
|
-
defaultProps: {}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
function variantHeaderNav() {
|
|
163
|
-
return {
|
|
164
|
-
pl: 2,
|
|
165
|
-
my: 0,
|
|
166
|
-
letterSpacing: 1,
|
|
167
|
-
fontSize: 0,
|
|
168
|
-
display: {
|
|
169
|
-
sm: 'none',
|
|
170
|
-
md: 'none',
|
|
171
|
-
lg: 'inline-block'
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
var colors = {
|
|
177
|
-
transparent: 'transparent',
|
|
178
|
-
ui: {
|
|
179
|
-
sepia: '#F9F4E9'
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
var sizes = {
|
|
184
|
-
lg: {
|
|
185
|
-
h: 12,
|
|
186
|
-
minW: 12,
|
|
187
|
-
fontSize: 'lg',
|
|
188
|
-
px: 6
|
|
189
|
-
},
|
|
190
|
-
md: {
|
|
191
|
-
h: '38px',
|
|
192
|
-
minW: 10,
|
|
193
|
-
fontSize: 'sm',
|
|
194
|
-
px: 2.5
|
|
195
|
-
},
|
|
196
|
-
sm: {
|
|
197
|
-
h: 8,
|
|
198
|
-
minW: 8,
|
|
199
|
-
fontSize: 'sm',
|
|
200
|
-
px: 3
|
|
201
|
-
},
|
|
202
|
-
xs: {
|
|
203
|
-
h: 6,
|
|
204
|
-
minW: 6,
|
|
205
|
-
fontSize: 'xs',
|
|
206
|
-
px: 2
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
var ButtonStyle = {
|
|
210
|
-
// style object for base or default style
|
|
211
|
-
baseStyle: {
|
|
212
|
-
borderRadius: 'sm',
|
|
213
|
-
fontWeight: 'light'
|
|
214
|
-
},
|
|
215
|
-
// styles for different sizes ("sm", "md", "lg")
|
|
216
|
-
sizes: sizes,
|
|
217
|
-
// styles for different visual variants ("outline", "solid")
|
|
218
|
-
variants: {
|
|
219
|
-
pill: {
|
|
220
|
-
border: '1px solid',
|
|
221
|
-
borderColor: 'gray.200',
|
|
222
|
-
borderRadius: '2xl',
|
|
223
|
-
height: 6,
|
|
224
|
-
px: 6,
|
|
225
|
-
fontSize: '-1',
|
|
226
|
-
my: 'auto'
|
|
227
|
-
},
|
|
228
|
-
solid: variantSolid,
|
|
229
|
-
secondary: {
|
|
230
|
-
border: '1px solid',
|
|
231
|
-
borderColor: 'ui.gray.light-cool',
|
|
232
|
-
_hover: {
|
|
233
|
-
bg: 'ui.gray.x-light-cool',
|
|
234
|
-
borderColor: 'ui.gray.medium'
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
// default values for `size`, `variant`, `colorScheme`
|
|
239
|
-
defaultProps: {
|
|
240
|
-
size: 'md',
|
|
241
|
-
variant: 'solid',
|
|
242
|
-
colorScheme: 'gray'
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
function solidColors(colorScheme) {
|
|
247
|
-
switch (colorScheme) {
|
|
248
|
-
case 'gray':
|
|
249
|
-
return {
|
|
250
|
-
bg: 'gray.100',
|
|
251
|
-
_hover: {
|
|
252
|
-
bg: 'gray.200',
|
|
253
|
-
_disabled: {
|
|
254
|
-
bg: 'gray.100'
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
_active: {
|
|
258
|
-
bg: 'gray.300'
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
case 'red':
|
|
263
|
-
return {
|
|
264
|
-
bg: 'brand.nypl-red',
|
|
265
|
-
color: 'white',
|
|
266
|
-
hoverBg: 'red.500',
|
|
267
|
-
activeBg: 'red.600'
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
default:
|
|
271
|
-
return {
|
|
272
|
-
bg: colorScheme + ".500",
|
|
273
|
-
color: 'white',
|
|
274
|
-
hoverBg: colorScheme + ".600",
|
|
275
|
-
activeBg: colorScheme + ".700"
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function variantSolid(props) {
|
|
281
|
-
var colors = solidColors(props.colorScheme);
|
|
282
|
-
return _extends({}, colors, {
|
|
283
|
-
_hover: {
|
|
284
|
-
_disabled: {
|
|
285
|
-
bg: 'ui.gray.light-cool',
|
|
286
|
-
color: 'ui.gray.dark'
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
_disabled: {
|
|
290
|
-
bg: 'ui.gray.light-cool',
|
|
291
|
-
color: 'ui.gray.dark'
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// theme.js
|
|
297
|
-
var breakpoints = /*#__PURE__*/themeTools.createBreakpoints({
|
|
298
|
-
sm: '20em',
|
|
299
|
-
md: '38em',
|
|
300
|
-
lg: '60em',
|
|
301
|
-
xl: '80em',
|
|
302
|
-
'2xl': '96em'
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
var typography = {
|
|
306
|
-
fonts: {
|
|
307
|
-
body: '-apple-system, BlinkMacSystemFont, system-ui, sans-serif',
|
|
308
|
-
heading: '-apple-system, BlinkMacSystemFont, system-ui, sans-seri',
|
|
309
|
-
mono: "Courier,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace"
|
|
310
|
-
},
|
|
311
|
-
fontSizes: {
|
|
312
|
-
'-2': '0.75rem',
|
|
313
|
-
'-1': '0.875rem',
|
|
314
|
-
'0': '1rem',
|
|
315
|
-
'1': '1.125rem',
|
|
316
|
-
'2': '1.25rem',
|
|
317
|
-
'3': '1.75rem',
|
|
318
|
-
'4': '2.25rem',
|
|
319
|
-
'5': '3rem'
|
|
320
|
-
},
|
|
321
|
-
fontWeights: {
|
|
322
|
-
light: 300,
|
|
323
|
-
regular: 400,
|
|
324
|
-
medium: 500,
|
|
325
|
-
bold: 700
|
|
326
|
-
},
|
|
327
|
-
lineHeights: [1, 1.1, 1.25, 1.5],
|
|
328
|
-
letterSpacings: {
|
|
329
|
-
tighter: '-0.05em',
|
|
330
|
-
tight: '-0.025em',
|
|
331
|
-
normal: '0',
|
|
332
|
-
wide: '0.025em',
|
|
333
|
-
wider: '0.05em',
|
|
334
|
-
widest: '0.1em'
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
var colors$1 = {
|
|
339
|
-
transparent: 'transparent',
|
|
340
|
-
// ui fills
|
|
341
|
-
ui: {
|
|
342
|
-
black: '#000',
|
|
343
|
-
white: '#fff',
|
|
344
|
-
focus: '#4181F1',
|
|
345
|
-
link: {
|
|
346
|
-
primary: '#0576D3',
|
|
347
|
-
secondary: '#004B98'
|
|
348
|
-
},
|
|
349
|
-
success: {
|
|
350
|
-
primary: '#077719',
|
|
351
|
-
secondary: '#095212'
|
|
352
|
-
},
|
|
353
|
-
warning: {
|
|
354
|
-
primary: '#F0974E',
|
|
355
|
-
secondary: '#EC7B1F'
|
|
356
|
-
},
|
|
357
|
-
status: {
|
|
358
|
-
primary: '#F9E08E',
|
|
359
|
-
secondary: '#FBE7E1'
|
|
360
|
-
},
|
|
361
|
-
error: '#97272C',
|
|
362
|
-
disabled: {
|
|
363
|
-
primary: '#E0E0E0',
|
|
364
|
-
secondary: '#FAFAFA'
|
|
365
|
-
},
|
|
366
|
-
test: '#FF6347',
|
|
367
|
-
gray: {
|
|
368
|
-
'x-dark': '#424242',
|
|
369
|
-
dark: '#616161',
|
|
370
|
-
medium: '#BDBDBD',
|
|
371
|
-
'light-cool': '#E0E0E0',
|
|
372
|
-
'light-warm': '#EFEDEB',
|
|
373
|
-
'x-light-cool': '#F5F5F5',
|
|
374
|
-
'x-light-warm': '#F8F8F7',
|
|
375
|
-
'xx-light-cool': '#FAFAFA'
|
|
376
|
-
}
|
|
377
|
-
},
|
|
378
|
-
// brand fills. Only primary and secondary filled in for now.
|
|
379
|
-
brand: {
|
|
380
|
-
primary: '#C60917',
|
|
381
|
-
secondary: '#760000',
|
|
382
|
-
'nypl-red': '#D0343A'
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* The following color scales are useful for color edge cases
|
|
387
|
-
* where a distinct named ui or brand color doesn't quite work.
|
|
388
|
-
*/
|
|
389
|
-
// based on ui/gray/medium
|
|
390
|
-
gray: {
|
|
391
|
-
'50': '#F2F2F2',
|
|
392
|
-
'100': '#DBDBDB',
|
|
393
|
-
'200': '#C4C4C4',
|
|
394
|
-
'300': '#ADADAD',
|
|
395
|
-
'400': '#969696',
|
|
396
|
-
'500': '#808080',
|
|
397
|
-
'600': '#666666',
|
|
398
|
-
'700': '#4D4D4D',
|
|
399
|
-
'800': '#333333',
|
|
400
|
-
'900': '#1A1A1A'
|
|
401
|
-
},
|
|
402
|
-
// based on NYPL red
|
|
403
|
-
red: {
|
|
404
|
-
50: '#ffe7e6',
|
|
405
|
-
100: '#f6c2bf',
|
|
406
|
-
200: '#e99796',
|
|
407
|
-
300: '#de6d6e',
|
|
408
|
-
400: '#d4454a',
|
|
409
|
-
500: '#ba2f2b',
|
|
410
|
-
600: '#922b21',
|
|
411
|
-
700: '#692216',
|
|
412
|
-
800: '#41150a',
|
|
413
|
-
900: '#1d0a01'
|
|
414
|
-
},
|
|
415
|
-
// based on ui/warning/secondary
|
|
416
|
-
orange: {
|
|
417
|
-
'50': '#FDF1E7',
|
|
418
|
-
'100': '#F9D8BD',
|
|
419
|
-
'200': '#F6BF93',
|
|
420
|
-
'300': '#F2A669',
|
|
421
|
-
'400': '#EF8D3E',
|
|
422
|
-
'500': '#EB7414',
|
|
423
|
-
'600': '#BC5D10',
|
|
424
|
-
'700': '#8D460C',
|
|
425
|
-
'800': '#5E2F08',
|
|
426
|
-
'900': '#2F1704'
|
|
427
|
-
},
|
|
428
|
-
// based on ui/status/primary
|
|
429
|
-
yellow: {
|
|
430
|
-
'50': '#FEF8E7',
|
|
431
|
-
'100': '#FBECBB',
|
|
432
|
-
'200': '#F9E090',
|
|
433
|
-
'300': '#F7D464',
|
|
434
|
-
'400': '#F4C938',
|
|
435
|
-
'500': '#F2BD0D',
|
|
436
|
-
'600': '#C2970A',
|
|
437
|
-
'700': '#917108',
|
|
438
|
-
'800': '#614B05',
|
|
439
|
-
'900': '#302603'
|
|
440
|
-
},
|
|
441
|
-
// based on ui/success/primary
|
|
442
|
-
green: {
|
|
443
|
-
'50': '#E7FEEB',
|
|
444
|
-
'100': '#BCFBC6',
|
|
445
|
-
'200': '#90F8A1',
|
|
446
|
-
'300': '#65F67C',
|
|
447
|
-
'400': '#3AF357',
|
|
448
|
-
'500': '#0EF133',
|
|
449
|
-
'600': '#0BC128',
|
|
450
|
-
'700': '#08911E',
|
|
451
|
-
'800': '#066014',
|
|
452
|
-
'900': '#03300A'
|
|
453
|
-
},
|
|
454
|
-
// based on NYPL blue
|
|
455
|
-
blue: {
|
|
456
|
-
50: '#dbefff',
|
|
457
|
-
100: '#add2ff',
|
|
458
|
-
200: '#7cb8ff',
|
|
459
|
-
300: '#4aa2ff',
|
|
460
|
-
400: '#1a8fff',
|
|
461
|
-
500: '#007ee6',
|
|
462
|
-
600: '#0056b4',
|
|
463
|
-
700: '#003582',
|
|
464
|
-
800: '#001a51',
|
|
465
|
-
900: '#000621'
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
var radii = {
|
|
470
|
-
none: '0',
|
|
471
|
-
sm: '0.125rem',
|
|
472
|
-
base: '0.25rem',
|
|
473
|
-
md: '0.375rem',
|
|
474
|
-
lg: '0.5rem',
|
|
475
|
-
xl: '0.75rem',
|
|
476
|
-
'2xl': '1rem',
|
|
477
|
-
'3xl': '1.5rem',
|
|
478
|
-
full: '9999px'
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* A comprehensive spacin scale based on NYPL Design System,
|
|
483
|
-
* with intermediate values interpolated. Those marked with comments
|
|
484
|
-
* are directly from the NYPL DS.
|
|
485
|
-
*
|
|
486
|
-
* 1 spacing unit is 4px or 0.25rem.
|
|
487
|
-
*
|
|
488
|
-
* Mental model: If you need a spacing of 40px, divide it by 4.
|
|
489
|
-
* That'll give you 10. Then use it in your component.
|
|
490
|
-
*/
|
|
491
|
-
var spacing = {
|
|
492
|
-
space: {
|
|
493
|
-
px: '1px',
|
|
494
|
-
0: '0',
|
|
495
|
-
0.5: '0.125rem',
|
|
496
|
-
// 4px
|
|
497
|
-
1: '0.25rem',
|
|
498
|
-
1.5: '0.375rem',
|
|
499
|
-
// 8px
|
|
500
|
-
2: '0.5rem',
|
|
501
|
-
2.5: '0.625rem',
|
|
502
|
-
3: '0.75rem',
|
|
503
|
-
3.5: '0.875rem',
|
|
504
|
-
// 16px
|
|
505
|
-
4: '1rem',
|
|
506
|
-
5: '1.25rem',
|
|
507
|
-
// 24px
|
|
508
|
-
6: '1.5rem',
|
|
509
|
-
7: '1.75rem',
|
|
510
|
-
// 32 px
|
|
511
|
-
8: '2rem',
|
|
512
|
-
9: '2.25rem',
|
|
513
|
-
10: '2.5rem',
|
|
514
|
-
// 48px
|
|
515
|
-
12: '3rem',
|
|
516
|
-
14: '3.5rem',
|
|
517
|
-
// 64px
|
|
518
|
-
16: '4rem',
|
|
519
|
-
20: '5rem',
|
|
520
|
-
// 96px
|
|
521
|
-
24: '6rem',
|
|
522
|
-
28: '7rem',
|
|
523
|
-
32: '8rem',
|
|
524
|
-
36: '9rem',
|
|
525
|
-
40: '10rem',
|
|
526
|
-
44: '11rem',
|
|
527
|
-
48: '12rem',
|
|
528
|
-
52: '13rem',
|
|
529
|
-
56: '14rem',
|
|
530
|
-
60: '15rem',
|
|
531
|
-
64: '16rem',
|
|
532
|
-
72: '18rem',
|
|
533
|
-
80: '20rem',
|
|
534
|
-
96: '24rem'
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
var baseStyleLabel = {
|
|
539
|
-
userSelect: 'none',
|
|
540
|
-
fontWeight: 'light',
|
|
541
|
-
_disabled: {
|
|
542
|
-
color: 'ui.gray.x-dark',
|
|
543
|
-
opacity: 1
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
var Checkbox = {
|
|
547
|
-
// style object for base or default style
|
|
548
|
-
baseStyle: {
|
|
549
|
-
control: {
|
|
550
|
-
borderColor: 'ui.gray.dark',
|
|
551
|
-
_hover: {
|
|
552
|
-
bg: 'white',
|
|
553
|
-
_disabled: {
|
|
554
|
-
bg: 'ui.gray.x-light-cool'
|
|
555
|
-
}
|
|
556
|
-
},
|
|
557
|
-
_checked: {
|
|
558
|
-
bg: 'white',
|
|
559
|
-
color: 'gray.800',
|
|
560
|
-
borderColor: 'ui.gray.dark',
|
|
561
|
-
_hover: {
|
|
562
|
-
bg: 'white',
|
|
563
|
-
borderColor: 'ui.gray.x-dark'
|
|
564
|
-
}
|
|
565
|
-
},
|
|
566
|
-
_disabled: {
|
|
567
|
-
bg: 'ui.gray.x-light-cool',
|
|
568
|
-
borderColor: 'ui.gray.medium'
|
|
569
|
-
}
|
|
570
|
-
},
|
|
571
|
-
label: baseStyleLabel
|
|
572
|
-
},
|
|
573
|
-
// styles for different sizes ("sm", "md", "lg")
|
|
574
|
-
sizes: {},
|
|
575
|
-
// styles for different visual variants ("outline", "solid")
|
|
576
|
-
variants: {},
|
|
577
|
-
// default values for `size`, `variant`, `colorScheme`
|
|
578
|
-
defaultProps: {
|
|
579
|
-
size: 'md',
|
|
580
|
-
colorScheme: 'gray'
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
var size = {
|
|
585
|
-
lg: {
|
|
586
|
-
fontSize: 'lg',
|
|
587
|
-
px: 4,
|
|
588
|
-
h: 12,
|
|
589
|
-
borderRadius: 'none'
|
|
590
|
-
},
|
|
591
|
-
md: {
|
|
592
|
-
fontSize: 'sm',
|
|
593
|
-
px: 4,
|
|
594
|
-
h: 9,
|
|
595
|
-
borderRadius: 'none'
|
|
596
|
-
},
|
|
597
|
-
sm: {
|
|
598
|
-
fontSize: 'sm',
|
|
599
|
-
px: 3,
|
|
600
|
-
h: 8,
|
|
601
|
-
borderRadius: 'none'
|
|
602
|
-
},
|
|
603
|
-
xs: {
|
|
604
|
-
fontSize: 'xs',
|
|
605
|
-
px: 2,
|
|
606
|
-
h: 6,
|
|
607
|
-
borderRadius: 'none'
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
var sizes$1 = {
|
|
611
|
-
lg: {
|
|
612
|
-
field: size.lg,
|
|
613
|
-
addon: size.lg
|
|
614
|
-
},
|
|
615
|
-
md: {
|
|
616
|
-
field: size.md,
|
|
617
|
-
addon: size.md
|
|
618
|
-
},
|
|
619
|
-
sm: {
|
|
620
|
-
field: size.sm,
|
|
621
|
-
addon: size.sm
|
|
622
|
-
},
|
|
623
|
-
xs: {
|
|
624
|
-
field: size.xs,
|
|
625
|
-
addon: size.xs
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
var Input = {
|
|
629
|
-
// style object for base or default style
|
|
630
|
-
baseStyle: {
|
|
631
|
-
field: {
|
|
632
|
-
borderRadius: 'none',
|
|
633
|
-
fontSize: 'sm',
|
|
634
|
-
_focus: {
|
|
635
|
-
borderColor: 'ui.link.primary',
|
|
636
|
-
_hover: {
|
|
637
|
-
borderColor: 'ui.link.primary'
|
|
638
|
-
}
|
|
639
|
-
},
|
|
640
|
-
_placeholder: {
|
|
641
|
-
fontStyle: 'italic',
|
|
642
|
-
color: 'ui.gray.dark'
|
|
643
|
-
},
|
|
644
|
-
_invalid: {
|
|
645
|
-
borderColor: 'ui.error',
|
|
646
|
-
_placeholder: {
|
|
647
|
-
color: 'ui.error'
|
|
648
|
-
},
|
|
649
|
-
_hover: {
|
|
650
|
-
borderColor: 'ui.error'
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
},
|
|
655
|
-
// styles for different sizes ("sm", "md", "lg")
|
|
656
|
-
sizes: sizes$1,
|
|
657
|
-
// styles for different visual variants ("outline", "solid")
|
|
658
|
-
variants: {
|
|
659
|
-
outline: {
|
|
660
|
-
field: {
|
|
661
|
-
_disabled: {
|
|
662
|
-
bg: 'ui.gray.xx-light-cool'
|
|
663
|
-
},
|
|
664
|
-
_focus: {
|
|
665
|
-
boxShadow: 'none',
|
|
666
|
-
_hover: {
|
|
667
|
-
borderColor: 'ui.link.primary'
|
|
668
|
-
}
|
|
669
|
-
},
|
|
670
|
-
_invalid: {
|
|
671
|
-
boxShadow: 'none'
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
},
|
|
676
|
-
// default values for `size`, `variant`, `colorScheme`
|
|
677
|
-
defaultProps: {
|
|
678
|
-
size: 'md'
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
var global = {
|
|
683
|
-
// styles for the `body`
|
|
684
|
-
body: {
|
|
685
|
-
bg: 'white',
|
|
686
|
-
color: 'black'
|
|
687
|
-
},
|
|
688
|
-
// styles for the `a`
|
|
689
|
-
a: {
|
|
690
|
-
color: 'ui.link.primary',
|
|
691
|
-
_hover: {
|
|
692
|
-
textDecoration: 'underline'
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
var baseStyle = {
|
|
698
|
-
fontSize: 'sm',
|
|
699
|
-
marginEnd: 0,
|
|
700
|
-
mb: 2,
|
|
701
|
-
fontWeight: 'medium',
|
|
702
|
-
transition: 'all 0.2s',
|
|
703
|
-
opacity: 1,
|
|
704
|
-
_disabled: {
|
|
705
|
-
opacity: 1
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
var FormLabel = {
|
|
709
|
-
baseStyle: baseStyle
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
var baseStyle$1 = {
|
|
713
|
-
requiredIndicator: {
|
|
714
|
-
marginStart: 1,
|
|
715
|
-
color: 'red.500'
|
|
716
|
-
},
|
|
717
|
-
helperText: {
|
|
718
|
-
mt: 2,
|
|
719
|
-
color: 'black',
|
|
720
|
-
lineHeight: 'normal',
|
|
721
|
-
fontSize: 'xs'
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
var Form = {
|
|
725
|
-
baseStyle: baseStyle$1
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
var baseStyle$2 = {
|
|
729
|
-
text: {
|
|
730
|
-
color: 'ui.error',
|
|
731
|
-
mt: 2,
|
|
732
|
-
fontSize: 'xs'
|
|
733
|
-
},
|
|
734
|
-
icon: {
|
|
735
|
-
marginEnd: '0.5em',
|
|
736
|
-
color: 'ui.error'
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
var FormError = {
|
|
740
|
-
baseStyle: baseStyle$2
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
var sizes$2 = {
|
|
744
|
-
xs: Input.sizes.xs.field,
|
|
745
|
-
sm: Input.sizes.sm.field,
|
|
746
|
-
md: Input.sizes.md.field,
|
|
747
|
-
lg: Input.sizes.lg.field
|
|
748
|
-
};
|
|
749
|
-
var Textarea = {
|
|
750
|
-
baseStyle: {
|
|
751
|
-
_disabled: {
|
|
752
|
-
bg: 'ui.gray.x-light-cool'
|
|
753
|
-
}
|
|
754
|
-
},
|
|
755
|
-
sizes: sizes$2
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
/**
|
|
759
|
-
* See Chakra default theme for shape of theme object:
|
|
760
|
-
* https://github.com/chakra-ui/chakra-ui/tree/main/packages/theme
|
|
761
|
-
*/
|
|
762
|
-
|
|
763
|
-
var theme = /*#__PURE__*/react.extendTheme( /*#__PURE__*/_extends({
|
|
764
|
-
styles: {
|
|
765
|
-
global: global
|
|
766
|
-
},
|
|
767
|
-
breakpoints: breakpoints,
|
|
768
|
-
radii: radii,
|
|
769
|
-
colors: colors$1
|
|
770
|
-
}, typography, {
|
|
771
|
-
space: spacing,
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* Chakra documentation on component styles:
|
|
775
|
-
* https://chakra-ui.com/docs/theming/component-style
|
|
776
|
-
*/
|
|
777
|
-
components: {
|
|
778
|
-
Button: ButtonStyle,
|
|
779
|
-
Checkbox: Checkbox,
|
|
780
|
-
Input: Input,
|
|
781
|
-
FormLabel: FormLabel,
|
|
782
|
-
Form: Form,
|
|
783
|
-
FormError: FormError,
|
|
784
|
-
Textarea: Textarea
|
|
785
|
-
}
|
|
786
|
-
}));
|
|
787
|
-
|
|
788
|
-
var getButtonStyle = function getButtonStyle(getColor) {
|
|
789
|
-
return {
|
|
790
|
-
// style object for base or default style
|
|
791
|
-
baseStyle: {
|
|
792
|
-
borderRadius: 'none'
|
|
793
|
-
},
|
|
794
|
-
// styles for different sizes ("sm", "md", "lg")
|
|
795
|
-
sizes: {},
|
|
796
|
-
// styles for different visual variants ("outline", "solid")
|
|
797
|
-
variants: {
|
|
798
|
-
solid: variantSolid$1(getColor),
|
|
799
|
-
toggle: variantToggle(getColor)
|
|
800
|
-
},
|
|
801
|
-
// default values for `size`, `variant`, `colorScheme`
|
|
802
|
-
defaultProps: {
|
|
803
|
-
size: 'sm',
|
|
804
|
-
variant: 'solid'
|
|
805
|
-
}
|
|
806
|
-
};
|
|
807
|
-
};
|
|
808
|
-
/* Color Schemes:
|
|
809
|
-
** Light, Sepia, Dark
|
|
810
|
-
* States:
|
|
811
|
-
** Normal
|
|
812
|
-
** Selected
|
|
813
|
-
** Disabled
|
|
814
|
-
** Hovered
|
|
815
|
-
*/
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
var variantSolid$1 = function variantSolid(getColor) {
|
|
819
|
-
return function (props) {
|
|
820
|
-
var bgColor = getColor('ui.white', 'ui.black', 'ui.sepia');
|
|
821
|
-
var color = getColor('gray.800', 'ui.white', 'gray.800');
|
|
822
|
-
var _focus = {
|
|
823
|
-
bgColor: bgColor,
|
|
824
|
-
color: color
|
|
825
|
-
};
|
|
826
|
-
var _hover = {
|
|
827
|
-
bgColor: bgColor,
|
|
828
|
-
color: color,
|
|
829
|
-
_disabled: {
|
|
830
|
-
bgColor: bgColor
|
|
831
|
-
}
|
|
832
|
-
};
|
|
833
|
-
var _active = {
|
|
834
|
-
bgColor: bgColor,
|
|
835
|
-
color: color
|
|
836
|
-
};
|
|
837
|
-
var _checked = {
|
|
838
|
-
bgColor: bgColor,
|
|
839
|
-
color: color
|
|
840
|
-
};
|
|
841
|
-
var _disabled = {
|
|
842
|
-
bgColor: bgColor
|
|
843
|
-
};
|
|
844
|
-
return {
|
|
845
|
-
border: '1px solid',
|
|
846
|
-
borderColor: 'gray.100',
|
|
847
|
-
transition: 'none',
|
|
848
|
-
fontSize: 0,
|
|
849
|
-
letterSpacing: 1,
|
|
850
|
-
textTransform: 'uppercase',
|
|
851
|
-
maxWidth: '100%',
|
|
852
|
-
cursor: 'pointer',
|
|
853
|
-
bgColor: bgColor,
|
|
854
|
-
color: color,
|
|
855
|
-
_focus: _focus,
|
|
856
|
-
_hover: _hover,
|
|
857
|
-
_active: _active,
|
|
858
|
-
_checked: _checked,
|
|
859
|
-
_disabled: _disabled
|
|
860
|
-
};
|
|
861
|
-
};
|
|
862
|
-
};
|
|
863
|
-
|
|
864
|
-
var variantToggle = function variantToggle(getColor) {
|
|
865
|
-
return function (props) {
|
|
866
|
-
var bgColor = getColor('ui.white', 'gray.800', 'ui.white');
|
|
867
|
-
var color = getColor('gray.800', 'ui.white', 'gray.800');
|
|
868
|
-
return _extends({}, variantSolid$1(getColor)(props), {
|
|
869
|
-
bgColor: bgColor,
|
|
870
|
-
color: color,
|
|
871
|
-
px: 8,
|
|
872
|
-
fontWeight: 'medium',
|
|
873
|
-
fontSize: -2,
|
|
874
|
-
_focus: {
|
|
875
|
-
bgColor: bgColor
|
|
876
|
-
},
|
|
877
|
-
_hover: {
|
|
878
|
-
bgColor: bgColor
|
|
879
|
-
},
|
|
880
|
-
_active: {
|
|
881
|
-
bgColor: bgColor
|
|
882
|
-
},
|
|
883
|
-
_checked: {
|
|
884
|
-
color: 'ui.white',
|
|
885
|
-
bgColor: 'green.700'
|
|
886
|
-
}
|
|
887
|
-
});
|
|
888
|
-
};
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* See Chakra default theme for shape of theme object:
|
|
893
|
-
* https://github.com/chakra-ui/chakra-ui/tree/main/packages/theme
|
|
894
|
-
*
|
|
895
|
-
* Making this a function because we need to adjust the theme based
|
|
896
|
-
* on the colorMode that's being passed in.
|
|
897
|
-
*
|
|
898
|
-
* Returns the chakra theme object with an additional property `currentColorMode`
|
|
899
|
-
*/
|
|
900
|
-
|
|
901
|
-
function getTheme(colorMode) {
|
|
902
|
-
return react.extendTheme({
|
|
903
|
-
colors: colors,
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* Chakra documentation on component styles:
|
|
907
|
-
* https://chakra-ui.com/docs/theming/component-style
|
|
908
|
-
*/
|
|
909
|
-
components: {
|
|
910
|
-
Button: getButtonStyle(getColor(colorMode)),
|
|
911
|
-
Text: TextStyle
|
|
912
|
-
},
|
|
913
|
-
currentColorMode: colorMode
|
|
914
|
-
}, theme);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
function ToggleButton(props) {
|
|
918
|
-
var isChecked = props.isChecked,
|
|
919
|
-
children = props.children,
|
|
920
|
-
colorMode = props.colorMode,
|
|
921
|
-
rest = _objectWithoutPropertiesLoose(props, ["isChecked", "children", "colorMode"]);
|
|
922
|
-
|
|
923
|
-
var _useRadio = react.useRadio(props),
|
|
924
|
-
getInputProps = _useRadio.getInputProps,
|
|
925
|
-
getCheckboxProps = _useRadio.getCheckboxProps;
|
|
926
|
-
|
|
927
|
-
var input = getInputProps();
|
|
928
|
-
var checkbox = getCheckboxProps();
|
|
929
|
-
var theme = react.useTheme();
|
|
930
|
-
return (// This will override the default theme if we specify the colorMode to the toggle button.
|
|
931
|
-
React__default.createElement(react.ThemeProvider, {
|
|
932
|
-
theme: getTheme(colorMode != null ? colorMode : theme.currentColorMode)
|
|
933
|
-
}, React__default.createElement(react.Box, {
|
|
934
|
-
as: "label",
|
|
935
|
-
d: "flex",
|
|
936
|
-
flexGrow: 1
|
|
937
|
-
}, React__default.createElement("input", Object.assign({}, input)), React__default.createElement(Button, Object.assign({
|
|
938
|
-
as: "div"
|
|
939
|
-
}, checkbox, {
|
|
940
|
-
variant: "toggle"
|
|
941
|
-
}, rest, {
|
|
942
|
-
flexGrow: 1
|
|
943
|
-
}), children, isChecked && React__default.createElement(react.Circle, {
|
|
944
|
-
position: "absolute",
|
|
945
|
-
verticalAlign: "middle",
|
|
946
|
-
right: 2,
|
|
947
|
-
top: "50%",
|
|
948
|
-
transform: "translateY(-50%)",
|
|
949
|
-
borderColor: "white",
|
|
950
|
-
border: "1px solid",
|
|
951
|
-
size: "15px",
|
|
952
|
-
alignItems: "baseline"
|
|
953
|
-
}, React__default.createElement(designSystemReactComponents.Icon, {
|
|
954
|
-
decorative: true,
|
|
955
|
-
name: designSystemReactComponents.IconNames.check,
|
|
956
|
-
modifiers: ['small']
|
|
957
|
-
})))))
|
|
958
|
-
);
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
var ToggleGroup = function ToggleGroup(_ref) {
|
|
962
|
-
var value = _ref.value,
|
|
963
|
-
label = _ref.label,
|
|
964
|
-
name = _ref.name,
|
|
965
|
-
children = _ref.children,
|
|
966
|
-
onChange = _ref.onChange;
|
|
967
|
-
|
|
968
|
-
var _useRadioGroup = react.useRadioGroup({
|
|
969
|
-
name: name,
|
|
970
|
-
onChange: onChange,
|
|
971
|
-
value: value
|
|
972
|
-
}),
|
|
973
|
-
getRootProps = _useRadioGroup.getRootProps,
|
|
974
|
-
getRadioProps = _useRadioGroup.getRadioProps;
|
|
975
|
-
|
|
976
|
-
var group = getRootProps();
|
|
977
|
-
return React__default.createElement(react.Flex, Object.assign({}, group, {
|
|
978
|
-
"aria-label": label,
|
|
979
|
-
flex: "1 0 auto",
|
|
980
|
-
flexWrap: "wrap",
|
|
981
|
-
my: 2
|
|
982
|
-
}), React__default.Children.map(children, function (element) {
|
|
983
|
-
try {
|
|
984
|
-
var _value = element.props.value;
|
|
985
|
-
var radio = getRadioProps({
|
|
986
|
-
value: _value
|
|
987
|
-
});
|
|
988
|
-
return React__default.cloneElement(element, radio);
|
|
989
|
-
} catch (e) {
|
|
990
|
-
throw new Error('ToggleGroup expects ToggleButton children with `value` props.');
|
|
991
|
-
}
|
|
992
|
-
}));
|
|
993
|
-
};
|
|
994
|
-
|
|
995
|
-
function PdfSettings(props) {
|
|
996
|
-
var navigator = props.navigator,
|
|
997
|
-
readerState = props.readerState,
|
|
998
|
-
paginationValue = props.paginationValue;
|
|
999
|
-
var fontFamily = readerState.fontFamily;
|
|
1000
|
-
var setFontFamily = navigator.setFontFamily,
|
|
1001
|
-
decreaseFontSize = navigator.decreaseFontSize,
|
|
1002
|
-
increaseFontSize = navigator.increaseFontSize,
|
|
1003
|
-
setScroll = navigator.setScroll;
|
|
1004
|
-
return React.createElement(React.Fragment, null, React.createElement(ToggleGroup, {
|
|
1005
|
-
value: fontFamily,
|
|
1006
|
-
label: "text font options",
|
|
1007
|
-
onChange: setFontFamily
|
|
1008
|
-
}, React.createElement(ToggleButton, {
|
|
1009
|
-
value: "publisher"
|
|
1010
|
-
}, "Publisher"), React.createElement(ToggleButton, {
|
|
1011
|
-
value: "serif"
|
|
1012
|
-
}, "Serif"), React.createElement(ToggleButton, {
|
|
1013
|
-
value: "sans-serif"
|
|
1014
|
-
}, "Sans-Serif"), React.createElement(ToggleButton, {
|
|
1015
|
-
value: "open-dyslexic"
|
|
1016
|
-
}, "Dyslexia-Friendly")), React.createElement(react.ButtonGroup, {
|
|
1017
|
-
d: "flex",
|
|
1018
|
-
spacing: 0
|
|
1019
|
-
}, React.createElement(Button, {
|
|
1020
|
-
flexGrow: 1,
|
|
1021
|
-
"aria-label": "Zoom In",
|
|
1022
|
-
onClick: decreaseFontSize,
|
|
1023
|
-
variant: "toggle"
|
|
1024
|
-
}, "Zoom", React.createElement(react.Circle, {
|
|
1025
|
-
border: "1px solid",
|
|
1026
|
-
p: 1,
|
|
1027
|
-
ml: 1,
|
|
1028
|
-
size: "17px",
|
|
1029
|
-
alignItems: "baseline"
|
|
1030
|
-
}, React.createElement(designSystemReactComponents.Icon, {
|
|
1031
|
-
decorative: true,
|
|
1032
|
-
name: designSystemReactComponents.IconNames.minus,
|
|
1033
|
-
modifiers: ['small']
|
|
1034
|
-
}), ' ')), React.createElement(Button, {
|
|
1035
|
-
flexGrow: 1,
|
|
1036
|
-
"aria-label": "Zoom Out",
|
|
1037
|
-
onClick: increaseFontSize,
|
|
1038
|
-
variant: "toggle"
|
|
1039
|
-
}, "Zoom", React.createElement(react.Circle, {
|
|
1040
|
-
border: "1px solid",
|
|
1041
|
-
p: 1,
|
|
1042
|
-
ml: 1,
|
|
1043
|
-
size: "17px",
|
|
1044
|
-
alignItems: "baseline"
|
|
1045
|
-
}, React.createElement(designSystemReactComponents.Icon, {
|
|
1046
|
-
decorative: true,
|
|
1047
|
-
name: designSystemReactComponents.IconNames.plus,
|
|
1048
|
-
modifiers: ['small']
|
|
1049
|
-
}), ' '))), React.createElement(ToggleGroup, {
|
|
1050
|
-
onChange: setScroll,
|
|
1051
|
-
value: paginationValue,
|
|
1052
|
-
label: "pagination options"
|
|
1053
|
-
}, React.createElement(ToggleButton, {
|
|
1054
|
-
value: "paginated"
|
|
1055
|
-
}, "Paginated"), React.createElement(ToggleButton, {
|
|
1056
|
-
value: "scrolling"
|
|
1057
|
-
}, "Scrolling")));
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
function HtmlSettings(props) {
|
|
1061
|
-
var navigator = props.navigator,
|
|
1062
|
-
readerState = props.readerState,
|
|
1063
|
-
paginationValue = props.paginationValue;
|
|
1064
|
-
var fontFamily = readerState.fontFamily,
|
|
1065
|
-
colorMode = readerState.colorMode;
|
|
1066
|
-
var setFontFamily = navigator.setFontFamily,
|
|
1067
|
-
decreaseFontSize = navigator.decreaseFontSize,
|
|
1068
|
-
increaseFontSize = navigator.increaseFontSize,
|
|
1069
|
-
setColorMode = navigator.setColorMode,
|
|
1070
|
-
setScroll = navigator.setScroll;
|
|
1071
|
-
return React.createElement(React.Fragment, null, React.createElement(ToggleGroup, {
|
|
1072
|
-
value: fontFamily,
|
|
1073
|
-
label: "text font options",
|
|
1074
|
-
onChange: setFontFamily
|
|
1075
|
-
}, React.createElement(ToggleButton, {
|
|
1076
|
-
value: "publisher"
|
|
1077
|
-
}, "Publisher"), React.createElement(ToggleButton, {
|
|
1078
|
-
value: "serif"
|
|
1079
|
-
}, "Serif"), React.createElement(ToggleButton, {
|
|
1080
|
-
value: "sans-serif"
|
|
1081
|
-
}, "Sans-Serif"), React.createElement(ToggleButton, {
|
|
1082
|
-
value: "open-dyslexic"
|
|
1083
|
-
}, "Dyslexia-Friendly")), React.createElement(react.ButtonGroup, {
|
|
1084
|
-
d: "flex",
|
|
1085
|
-
spacing: 0
|
|
1086
|
-
}, React.createElement(Button, {
|
|
1087
|
-
flexGrow: 1,
|
|
1088
|
-
"aria-label": "Decrease font size",
|
|
1089
|
-
onClick: decreaseFontSize,
|
|
1090
|
-
variant: "toggle"
|
|
1091
|
-
}, "A-"), React.createElement(Button, {
|
|
1092
|
-
flexGrow: 1,
|
|
1093
|
-
"aria-label": "Increase font size",
|
|
1094
|
-
onClick: increaseFontSize,
|
|
1095
|
-
variant: "toggle"
|
|
1096
|
-
}, "A+")), React.createElement(ToggleGroup, {
|
|
1097
|
-
value: colorMode,
|
|
1098
|
-
label: "reading theme options",
|
|
1099
|
-
onChange: setColorMode
|
|
1100
|
-
}, React.createElement(ToggleButton, {
|
|
1101
|
-
colorMode: "day",
|
|
1102
|
-
value: "day",
|
|
1103
|
-
_checked: {
|
|
1104
|
-
bg: 'ui.white'
|
|
1105
|
-
}
|
|
1106
|
-
}, "Day"), React.createElement(ToggleButton, {
|
|
1107
|
-
colorMode: "sepia",
|
|
1108
|
-
value: "sepia",
|
|
1109
|
-
bg: "ui.sepia" // distinct case where default needs to be sepia
|
|
1110
|
-
,
|
|
1111
|
-
_active: {
|
|
1112
|
-
bg: 'ui.sepia'
|
|
1113
|
-
},
|
|
1114
|
-
_hover: {
|
|
1115
|
-
bg: 'ui.sepia'
|
|
1116
|
-
},
|
|
1117
|
-
_checked: {
|
|
1118
|
-
bg: 'ui.sepia'
|
|
1119
|
-
}
|
|
1120
|
-
}, "Sepia"), React.createElement(ToggleButton, {
|
|
1121
|
-
colorMode: "night",
|
|
1122
|
-
value: "night",
|
|
1123
|
-
_checked: {
|
|
1124
|
-
bg: 'ui.black'
|
|
1125
|
-
}
|
|
1126
|
-
}, "Night")), React.createElement(ToggleGroup, {
|
|
1127
|
-
onChange: setScroll,
|
|
1128
|
-
value: paginationValue,
|
|
1129
|
-
label: "pagination options"
|
|
1130
|
-
}, React.createElement(ToggleButton, {
|
|
1131
|
-
value: "paginated"
|
|
1132
|
-
}, "Paginated"), React.createElement(ToggleButton, {
|
|
1133
|
-
value: "scrolling"
|
|
1134
|
-
}, "Scrolling")));
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
function SettingsCard(props) {
|
|
1138
|
-
var _React$useState = React.useState(false),
|
|
1139
|
-
isOpen = _React$useState[0],
|
|
1140
|
-
setIsOpen = _React$useState[1];
|
|
1141
|
-
|
|
1142
|
-
var open = function open() {
|
|
1143
|
-
return setIsOpen(!isOpen);
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
var close = function close() {
|
|
1147
|
-
return setIsOpen(false);
|
|
1148
|
-
};
|
|
1149
|
-
|
|
1150
|
-
var navigator = props.navigator,
|
|
1151
|
-
state = props.state,
|
|
1152
|
-
type = props.type;
|
|
1153
|
-
var paginationValue = state != null && state.isScrolling ? 'scrolling' : 'paginated';
|
|
1154
|
-
var contentBgColor = useColorModeValue('ui.white', 'ui.black', 'ui.white');
|
|
1155
|
-
return React.createElement(React.Fragment, null, React.createElement(react.Popover, {
|
|
1156
|
-
placement: "bottom",
|
|
1157
|
-
isOpen: isOpen,
|
|
1158
|
-
onClose: close,
|
|
1159
|
-
autoFocus: true
|
|
1160
|
-
}, React.createElement(react.PopoverTrigger, null, React.createElement(Button, {
|
|
1161
|
-
onClick: open,
|
|
1162
|
-
border: "none"
|
|
1163
|
-
}, React.createElement(designSystemReactComponents.Icon, {
|
|
1164
|
-
decorative: true,
|
|
1165
|
-
name: designSystemReactComponents.IconNames.plus,
|
|
1166
|
-
modifiers: ['small']
|
|
1167
|
-
}), ' ', React.createElement(react.Text, {
|
|
1168
|
-
variant: "headerNav"
|
|
1169
|
-
}, "Settings"))), React.createElement(react.PopoverContent, {
|
|
1170
|
-
borderColor: "gray.100",
|
|
1171
|
-
width: "fit-content",
|
|
1172
|
-
bgColor: contentBgColor
|
|
1173
|
-
}, React.createElement(react.PopoverBody, {
|
|
1174
|
-
p: 0,
|
|
1175
|
-
maxWidth: "95vw"
|
|
1176
|
-
}, type === 'PDF' && React.createElement(PdfSettings, {
|
|
1177
|
-
navigator: navigator,
|
|
1178
|
-
readerState: state,
|
|
1179
|
-
paginationValue: paginationValue
|
|
1180
|
-
}), type === 'HTML' && React.createElement(HtmlSettings, {
|
|
1181
|
-
navigator: navigator,
|
|
1182
|
-
readerState: state,
|
|
1183
|
-
paginationValue: paginationValue
|
|
1184
|
-
})))));
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
// we have to set a constant height to make this work with R2D2BC
|
|
1188
|
-
var HEADER_HEIGHT = 48;
|
|
1189
|
-
|
|
1190
|
-
var TocItem = function TocItem(props) {
|
|
1191
|
-
var href = props.href,
|
|
1192
|
-
title = props.title,
|
|
1193
|
-
isActive = props.isActive,
|
|
1194
|
-
rest = _objectWithoutPropertiesLoose(props, ["href", "title", "isActive"]);
|
|
1195
|
-
|
|
1196
|
-
var bgColor = useColorModeValue('ui.white', 'ui.black', 'ui.sepia');
|
|
1197
|
-
var color = useColorModeValue('ui.black', 'ui.white', 'ui.black');
|
|
1198
|
-
var borderColor = useColorModeValue('ui.gray.medium', 'gray.500', 'yellow.600');
|
|
1199
|
-
var activeColor = 'ui.black';
|
|
1200
|
-
var activeBgColor = 'ui.gray.light-cool';
|
|
1201
|
-
var _hover = {
|
|
1202
|
-
textDecoration: 'none',
|
|
1203
|
-
background: isActive ? 'ui.black' : 'ui.gray.x-dark',
|
|
1204
|
-
color: 'ui.white'
|
|
1205
|
-
};
|
|
1206
|
-
|
|
1207
|
-
var _focus = _extends({}, _hover, {
|
|
1208
|
-
boxShadow: 'none'
|
|
1209
|
-
});
|
|
1210
|
-
|
|
1211
|
-
var styles = {
|
|
1212
|
-
background: isActive ? activeBgColor : bgColor,
|
|
1213
|
-
color: isActive ? activeColor : color,
|
|
1214
|
-
borderBottom: "1px solid",
|
|
1215
|
-
borderColor: borderColor,
|
|
1216
|
-
py: 3,
|
|
1217
|
-
_hover: _hover,
|
|
1218
|
-
_focus: _focus
|
|
1219
|
-
};
|
|
1220
|
-
return React__default.createElement(react.MenuItem, Object.assign({
|
|
1221
|
-
as: react.Link,
|
|
1222
|
-
href: href
|
|
1223
|
-
}, styles, rest), title);
|
|
1224
|
-
};
|
|
1225
|
-
|
|
1226
|
-
function TableOfContent(_ref) {
|
|
1227
|
-
var navigator = _ref.navigator,
|
|
1228
|
-
manifest = _ref.manifest,
|
|
1229
|
-
readerState = _ref.readerState;
|
|
1230
|
-
|
|
1231
|
-
var _useState = React.useState(false),
|
|
1232
|
-
isOpen = _useState[0],
|
|
1233
|
-
setIsOpen = _useState[1];
|
|
1234
|
-
|
|
1235
|
-
var tocLinkHandler = function tocLinkHandler(evt) {
|
|
1236
|
-
evt.preventDefault();
|
|
1237
|
-
var href = evt.currentTarget.getAttribute('href');
|
|
1238
|
-
|
|
1239
|
-
if (!href) {
|
|
1240
|
-
console.warn('TOC Link clicked without an href');
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
navigator.goToPage(href);
|
|
1245
|
-
setIsOpen(false);
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
var tocBgColor = useColorModeValue('ui.white', 'ui.black', 'ui.sepia');
|
|
1249
|
-
|
|
1250
|
-
var getLinkHref = function getLinkHref(link) {
|
|
1251
|
-
if (link.href) return link.href;
|
|
1252
|
-
if (!link.children) throw new Error('Manifest is not well formed');
|
|
1253
|
-
return getLinkHref(link.children[0]);
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
return React__default.createElement(react.Menu, {
|
|
1257
|
-
onOpen: function onOpen() {
|
|
1258
|
-
return setIsOpen(true);
|
|
1259
|
-
},
|
|
1260
|
-
onClose: function onClose() {
|
|
1261
|
-
return setIsOpen(false);
|
|
1262
|
-
}
|
|
1263
|
-
}, React__default.createElement(react.MenuButton, {
|
|
1264
|
-
as: Button,
|
|
1265
|
-
border: "none"
|
|
1266
|
-
}, React__default.createElement(designSystemReactComponents.Icon, {
|
|
1267
|
-
decorative: true,
|
|
1268
|
-
name: designSystemReactComponents.IconNames.download,
|
|
1269
|
-
modifiers: ['small']
|
|
1270
|
-
}), React__default.createElement(react.Text, {
|
|
1271
|
-
variant: "headerNav"
|
|
1272
|
-
}, "Table of Contents")), isOpen && (manifest == null ? void 0 : manifest.toc) && React__default.createElement(react.Portal, null, React__default.createElement(react.MenuList, {
|
|
1273
|
-
width: "100vw",
|
|
1274
|
-
height: "calc(100vh - " + HEADER_HEIGHT + "px)",
|
|
1275
|
-
background: tocBgColor,
|
|
1276
|
-
borderRadius: "none",
|
|
1277
|
-
borderColor: tocBgColor,
|
|
1278
|
-
zIndex: "popover",
|
|
1279
|
-
px: 7,
|
|
1280
|
-
mt: "-2px" // Move the popover slightly higher to hide Header border
|
|
1281
|
-
,
|
|
1282
|
-
overflow: "auto"
|
|
1283
|
-
}, manifest.toc.map(function (content) {
|
|
1284
|
-
return React__default.createElement(React__default.Fragment, {
|
|
1285
|
-
key: content.title
|
|
1286
|
-
}, React__default.createElement(TocItem, {
|
|
1287
|
-
href: getLinkHref(content),
|
|
1288
|
-
title: content.title,
|
|
1289
|
-
isActive: (readerState == null ? void 0 : readerState.currentTocUrl) === content.href,
|
|
1290
|
-
onClick: tocLinkHandler
|
|
1291
|
-
}), content.children && content.children.map(function (subLink) {
|
|
1292
|
-
return React__default.createElement(TocItem, {
|
|
1293
|
-
key: subLink.title,
|
|
1294
|
-
href: getLinkHref(subLink),
|
|
1295
|
-
title: subLink.title,
|
|
1296
|
-
isActive: (readerState == null ? void 0 : readerState.currentTocUrl) === subLink.href,
|
|
1297
|
-
onClick: tocLinkHandler,
|
|
1298
|
-
pl: 10
|
|
1299
|
-
});
|
|
1300
|
-
}));
|
|
1301
|
-
}))));
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
function Header(props) {
|
|
1305
|
-
var headerLeft = props.headerLeft,
|
|
1306
|
-
state = props.state,
|
|
1307
|
-
navigator = props.navigator,
|
|
1308
|
-
manifest = props.manifest;
|
|
1309
|
-
var linkColor = useColorModeValue('gray.700', 'gray.100', 'gray.700');
|
|
1310
|
-
var mainBgColor = useColorModeValue('ui.white', 'ui.black', 'ui.sepia'); // Add custom styles to the NYPL Icon
|
|
1311
|
-
|
|
1312
|
-
var ChakraIcon = react.chakra(designSystemReactComponents.Icon, {
|
|
1313
|
-
baseStyle: {
|
|
1314
|
-
height: '100%'
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
return React__default.createElement(react.Flex, {
|
|
1318
|
-
as: "header",
|
|
1319
|
-
position: "sticky",
|
|
1320
|
-
top: 0,
|
|
1321
|
-
left: 0,
|
|
1322
|
-
right: 0,
|
|
1323
|
-
height: HEADER_HEIGHT + "px",
|
|
1324
|
-
zIndex: "sticky",
|
|
1325
|
-
alignContent: "space-between",
|
|
1326
|
-
alignItems: "center",
|
|
1327
|
-
px: 8,
|
|
1328
|
-
borderBottom: "1px solid",
|
|
1329
|
-
borderColor: "gray.100",
|
|
1330
|
-
bgColor: mainBgColor
|
|
1331
|
-
}, headerLeft ? headerLeft : React__default.createElement(react.Link, {
|
|
1332
|
-
href: "https://www.nypl.org",
|
|
1333
|
-
"aria-label": "Return to NYPL",
|
|
1334
|
-
tabIndex: 0,
|
|
1335
|
-
fontSize: 0,
|
|
1336
|
-
py: 1,
|
|
1337
|
-
textTransform: "uppercase",
|
|
1338
|
-
d: "flex",
|
|
1339
|
-
color: linkColor,
|
|
1340
|
-
height: "100%",
|
|
1341
|
-
alignItems: "center",
|
|
1342
|
-
_hover: {
|
|
1343
|
-
textDecoration: 'none'
|
|
1344
|
-
}
|
|
1345
|
-
}, React__default.createElement(ChakraIcon, {
|
|
1346
|
-
decorative: true,
|
|
1347
|
-
name: designSystemReactComponents.LogoNames.logo_nypl,
|
|
1348
|
-
modifiers: ['xlarge']
|
|
1349
|
-
}), React__default.createElement(react.Text, {
|
|
1350
|
-
variant: "headerNav"
|
|
1351
|
-
}, "Return to NYPL")), React__default.createElement(react.HStack, {
|
|
1352
|
-
ml: "auto",
|
|
1353
|
-
spacing: 1
|
|
1354
|
-
}, React__default.createElement(TableOfContent, {
|
|
1355
|
-
navigator: navigator,
|
|
1356
|
-
manifest: manifest,
|
|
1357
|
-
readerState: state
|
|
1358
|
-
}), React__default.createElement(SettingsCard, Object.assign({}, props)), React__default.createElement(Button, {
|
|
1359
|
-
border: "none",
|
|
1360
|
-
onClick: toggleFullScreen
|
|
1361
|
-
}, React__default.createElement(designSystemReactComponents.Icon, {
|
|
1362
|
-
decorative: true,
|
|
1363
|
-
name: designSystemReactComponents.IconNames.search,
|
|
1364
|
-
modifiers: ['small']
|
|
1365
|
-
}), React__default.createElement(react.Text, {
|
|
1366
|
-
variant: "headerNav"
|
|
1367
|
-
}, "Toggle Fullscreen"))));
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
function PageButton(props) {
|
|
1371
|
-
var children = props.children,
|
|
1372
|
-
onClick = props.onClick,
|
|
1373
|
-
rest = _objectWithoutPropertiesLoose(props, ["children", "onClick"]);
|
|
1374
|
-
|
|
1375
|
-
var circleColor = useColorModeValue('ui.black', 'ui.white', 'ui.black');
|
|
1376
|
-
var circleBgColor = useColorModeValue('ui.white', 'gray.700', 'ui.white');
|
|
1377
|
-
return React__default.createElement(react.Circle, Object.assign({
|
|
1378
|
-
as: "button",
|
|
1379
|
-
d: "flex",
|
|
1380
|
-
position: "fixed",
|
|
1381
|
-
zIndex: "docked",
|
|
1382
|
-
alignItems: "center",
|
|
1383
|
-
border: "1px solid",
|
|
1384
|
-
borderColor: "ui.gray.light-cool",
|
|
1385
|
-
color: circleColor,
|
|
1386
|
-
bg: circleBgColor,
|
|
1387
|
-
size: {
|
|
1388
|
-
sm: '40px',
|
|
1389
|
-
md: '50px'
|
|
1390
|
-
},
|
|
1391
|
-
mx: {
|
|
1392
|
-
sm: 2,
|
|
1393
|
-
md: 6
|
|
1394
|
-
},
|
|
1395
|
-
top: "50%",
|
|
1396
|
-
cursor: "pointer",
|
|
1397
|
-
onClick: onClick
|
|
1398
|
-
}, rest), children);
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
/**
|
|
1402
|
-
* The default Manager UI. This will be broken into individual components
|
|
1403
|
-
* that can be imported and used separately or in a customized setup.
|
|
1404
|
-
* It takes the return value of useWebReader as props
|
|
1405
|
-
*/
|
|
1406
|
-
|
|
1407
|
-
var ManagerUI = function ManagerUI(props) {
|
|
1408
|
-
var _props$state$colorMod, _props$state;
|
|
1409
|
-
|
|
1410
|
-
return React.createElement(react.ThemeProvider, {
|
|
1411
|
-
theme: getTheme((_props$state$colorMod = (_props$state = props.state) == null ? void 0 : _props$state.colorMode) != null ? _props$state$colorMod : 'day')
|
|
1412
|
-
}, React.createElement(WebReaderContent, Object.assign({}, props)));
|
|
1413
|
-
};
|
|
1414
|
-
|
|
1415
|
-
var WebReaderContent = function WebReaderContent(_ref) {
|
|
1416
|
-
var _props$navigator, _props$navigator2;
|
|
1417
|
-
|
|
1418
|
-
var children = _ref.children,
|
|
1419
|
-
props = _objectWithoutPropertiesLoose(_ref, ["children"]);
|
|
1420
|
-
|
|
1421
|
-
var bgColor = useColorModeValue('ui.white', 'ui.black', 'ui.sepia');
|
|
1422
|
-
return React.createElement(react.Flex, {
|
|
1423
|
-
flexDir: "column",
|
|
1424
|
-
minHeight: "100vh",
|
|
1425
|
-
w: "100vw"
|
|
1426
|
-
}, !props.isLoading && React.createElement(Header, Object.assign({}, props)), React.createElement(PageButton, {
|
|
1427
|
-
onClick: (_props$navigator = props.navigator) == null ? void 0 : _props$navigator.goBackward,
|
|
1428
|
-
left: 0,
|
|
1429
|
-
pr: 2,
|
|
1430
|
-
"aria-label": "Previous Page"
|
|
1431
|
-
}, React.createElement(designSystemReactComponents.Icon, {
|
|
1432
|
-
decorative: true,
|
|
1433
|
-
name: designSystemReactComponents.IconNames.arrow,
|
|
1434
|
-
modifiers: ['small'],
|
|
1435
|
-
iconRotation: designSystemReactComponents.IconRotationTypes.rotate90
|
|
1436
|
-
})), React.createElement(react.Flex, {
|
|
1437
|
-
width: "100vw",
|
|
1438
|
-
bg: bgColor,
|
|
1439
|
-
// accounting for the prev/next buttons
|
|
1440
|
-
px: {
|
|
1441
|
-
sm: 10,
|
|
1442
|
-
md: '5vw'
|
|
1443
|
-
},
|
|
1444
|
-
flexDir: "column",
|
|
1445
|
-
alignItems: "stretch",
|
|
1446
|
-
flex: "1 1 100%"
|
|
1447
|
-
}, children), React.createElement(PageButton, {
|
|
1448
|
-
onClick: (_props$navigator2 = props.navigator) == null ? void 0 : _props$navigator2.goForward,
|
|
1449
|
-
right: 0,
|
|
1450
|
-
pl: 2,
|
|
1451
|
-
"aria-label": "Next Page"
|
|
1452
|
-
}, React.createElement(designSystemReactComponents.Icon, {
|
|
1453
|
-
decorative: true,
|
|
1454
|
-
name: designSystemReactComponents.IconNames.arrow,
|
|
1455
|
-
modifiers: ['small'],
|
|
1456
|
-
iconRotation: designSystemReactComponents.IconRotationTypes.rotate270
|
|
1457
|
-
})));
|
|
1458
|
-
};
|
|
1459
|
-
|
|
1460
|
-
function createCommonjsModule(fn, module) {
|
|
1461
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
var runtime_1 = createCommonjsModule(function (module) {
|
|
1465
|
-
/**
|
|
1466
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
1467
|
-
*
|
|
1468
|
-
* This source code is licensed under the MIT license found in the
|
|
1469
|
-
* LICENSE file in the root directory of this source tree.
|
|
1470
|
-
*/
|
|
1471
|
-
|
|
1472
|
-
var runtime = (function (exports) {
|
|
1473
|
-
|
|
1474
|
-
var Op = Object.prototype;
|
|
1475
|
-
var hasOwn = Op.hasOwnProperty;
|
|
1476
|
-
var undefined$1; // More compressible than void 0.
|
|
1477
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
1478
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
1479
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
1480
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1481
|
-
|
|
1482
|
-
function define(obj, key, value) {
|
|
1483
|
-
Object.defineProperty(obj, key, {
|
|
1484
|
-
value: value,
|
|
1485
|
-
enumerable: true,
|
|
1486
|
-
configurable: true,
|
|
1487
|
-
writable: true
|
|
1488
|
-
});
|
|
1489
|
-
return obj[key];
|
|
1490
|
-
}
|
|
1491
|
-
try {
|
|
1492
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
1493
|
-
define({}, "");
|
|
1494
|
-
} catch (err) {
|
|
1495
|
-
define = function(obj, key, value) {
|
|
1496
|
-
return obj[key] = value;
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1501
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
1502
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
1503
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
1504
|
-
var context = new Context(tryLocsList || []);
|
|
1505
|
-
|
|
1506
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
1507
|
-
// .throw, and .return methods.
|
|
1508
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
1509
|
-
|
|
1510
|
-
return generator;
|
|
1511
|
-
}
|
|
1512
|
-
exports.wrap = wrap;
|
|
1513
|
-
|
|
1514
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
1515
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
1516
|
-
// have been (and was previously) designed to take a closure to be
|
|
1517
|
-
// invoked without arguments, but in all the cases we care about we
|
|
1518
|
-
// already have an existing method we want to call, so there's no need
|
|
1519
|
-
// to create a new function object. We can even get away with assuming
|
|
1520
|
-
// the method takes exactly one argument, since that happens to be true
|
|
1521
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
1522
|
-
// only additional allocation required is the completion record, which
|
|
1523
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
1524
|
-
function tryCatch(fn, obj, arg) {
|
|
1525
|
-
try {
|
|
1526
|
-
return { type: "normal", arg: fn.call(obj, arg) };
|
|
1527
|
-
} catch (err) {
|
|
1528
|
-
return { type: "throw", arg: err };
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
1533
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
1534
|
-
var GenStateExecuting = "executing";
|
|
1535
|
-
var GenStateCompleted = "completed";
|
|
1536
|
-
|
|
1537
|
-
// Returning this object from the innerFn has the same effect as
|
|
1538
|
-
// breaking out of the dispatch switch statement.
|
|
1539
|
-
var ContinueSentinel = {};
|
|
1540
|
-
|
|
1541
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
1542
|
-
// .constructor.prototype properties for functions that return Generator
|
|
1543
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
1544
|
-
// minifier not to mangle the names of these two functions.
|
|
1545
|
-
function Generator() {}
|
|
1546
|
-
function GeneratorFunction() {}
|
|
1547
|
-
function GeneratorFunctionPrototype() {}
|
|
1548
|
-
|
|
1549
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
1550
|
-
// don't natively support it.
|
|
1551
|
-
var IteratorPrototype = {};
|
|
1552
|
-
IteratorPrototype[iteratorSymbol] = function () {
|
|
1553
|
-
return this;
|
|
1554
|
-
};
|
|
1555
|
-
|
|
1556
|
-
var getProto = Object.getPrototypeOf;
|
|
1557
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1558
|
-
if (NativeIteratorPrototype &&
|
|
1559
|
-
NativeIteratorPrototype !== Op &&
|
|
1560
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
1561
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
1562
|
-
// of the polyfill.
|
|
1563
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
var Gp = GeneratorFunctionPrototype.prototype =
|
|
1567
|
-
Generator.prototype = Object.create(IteratorPrototype);
|
|
1568
|
-
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
1569
|
-
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
1570
|
-
GeneratorFunction.displayName = define(
|
|
1571
|
-
GeneratorFunctionPrototype,
|
|
1572
|
-
toStringTagSymbol,
|
|
1573
|
-
"GeneratorFunction"
|
|
1574
|
-
);
|
|
1575
|
-
|
|
1576
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
1577
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
1578
|
-
function defineIteratorMethods(prototype) {
|
|
1579
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
1580
|
-
define(prototype, method, function(arg) {
|
|
1581
|
-
return this._invoke(method, arg);
|
|
1582
|
-
});
|
|
1583
|
-
});
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
exports.isGeneratorFunction = function(genFun) {
|
|
1587
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
1588
|
-
return ctor
|
|
1589
|
-
? ctor === GeneratorFunction ||
|
|
1590
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
1591
|
-
// do is to check its .name property.
|
|
1592
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
1593
|
-
: false;
|
|
1594
|
-
};
|
|
1595
|
-
|
|
1596
|
-
exports.mark = function(genFun) {
|
|
1597
|
-
if (Object.setPrototypeOf) {
|
|
1598
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
1599
|
-
} else {
|
|
1600
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
1601
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
1602
|
-
}
|
|
1603
|
-
genFun.prototype = Object.create(Gp);
|
|
1604
|
-
return genFun;
|
|
1605
|
-
};
|
|
1606
|
-
|
|
1607
|
-
// Within the body of any async function, `await x` is transformed to
|
|
1608
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
1609
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
1610
|
-
// meant to be awaited.
|
|
1611
|
-
exports.awrap = function(arg) {
|
|
1612
|
-
return { __await: arg };
|
|
1613
|
-
};
|
|
1614
|
-
|
|
1615
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
1616
|
-
function invoke(method, arg, resolve, reject) {
|
|
1617
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
1618
|
-
if (record.type === "throw") {
|
|
1619
|
-
reject(record.arg);
|
|
1620
|
-
} else {
|
|
1621
|
-
var result = record.arg;
|
|
1622
|
-
var value = result.value;
|
|
1623
|
-
if (value &&
|
|
1624
|
-
typeof value === "object" &&
|
|
1625
|
-
hasOwn.call(value, "__await")) {
|
|
1626
|
-
return PromiseImpl.resolve(value.__await).then(function(value) {
|
|
1627
|
-
invoke("next", value, resolve, reject);
|
|
1628
|
-
}, function(err) {
|
|
1629
|
-
invoke("throw", err, resolve, reject);
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
1634
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
1635
|
-
// the .value of the Promise<{value,done}> result for the
|
|
1636
|
-
// current iteration.
|
|
1637
|
-
result.value = unwrapped;
|
|
1638
|
-
resolve(result);
|
|
1639
|
-
}, function(error) {
|
|
1640
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
1641
|
-
// into the async generator function so it can be handled there.
|
|
1642
|
-
return invoke("throw", error, resolve, reject);
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
var previousPromise;
|
|
1648
|
-
|
|
1649
|
-
function enqueue(method, arg) {
|
|
1650
|
-
function callInvokeWithMethodAndArg() {
|
|
1651
|
-
return new PromiseImpl(function(resolve, reject) {
|
|
1652
|
-
invoke(method, arg, resolve, reject);
|
|
1653
|
-
});
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
return previousPromise =
|
|
1657
|
-
// If enqueue has been called before, then we want to wait until
|
|
1658
|
-
// all previous Promises have been resolved before calling invoke,
|
|
1659
|
-
// so that results are always delivered in the correct order. If
|
|
1660
|
-
// enqueue has not been called before, then it is important to
|
|
1661
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
1662
|
-
// so that the async generator function has the opportunity to do
|
|
1663
|
-
// any necessary setup in a predictable way. This predictability
|
|
1664
|
-
// is why the Promise constructor synchronously invokes its
|
|
1665
|
-
// executor callback, and why async functions synchronously
|
|
1666
|
-
// execute code before the first await. Since we implement simple
|
|
1667
|
-
// async functions in terms of async generators, it is especially
|
|
1668
|
-
// important to get this right, even though it requires care.
|
|
1669
|
-
previousPromise ? previousPromise.then(
|
|
1670
|
-
callInvokeWithMethodAndArg,
|
|
1671
|
-
// Avoid propagating failures to Promises returned by later
|
|
1672
|
-
// invocations of the iterator.
|
|
1673
|
-
callInvokeWithMethodAndArg
|
|
1674
|
-
) : callInvokeWithMethodAndArg();
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
// Define the unified helper method that is used to implement .next,
|
|
1678
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
1679
|
-
this._invoke = enqueue;
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
1683
|
-
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
1684
|
-
return this;
|
|
1685
|
-
};
|
|
1686
|
-
exports.AsyncIterator = AsyncIterator;
|
|
1687
|
-
|
|
1688
|
-
// Note that simple async functions are implemented on top of
|
|
1689
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
1690
|
-
// the final result produced by the iterator.
|
|
1691
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1692
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
1693
|
-
|
|
1694
|
-
var iter = new AsyncIterator(
|
|
1695
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
1696
|
-
PromiseImpl
|
|
1697
|
-
);
|
|
1698
|
-
|
|
1699
|
-
return exports.isGeneratorFunction(outerFn)
|
|
1700
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
1701
|
-
: iter.next().then(function(result) {
|
|
1702
|
-
return result.done ? result.value : iter.next();
|
|
1703
|
-
});
|
|
1704
|
-
};
|
|
1705
|
-
|
|
1706
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
1707
|
-
var state = GenStateSuspendedStart;
|
|
1708
|
-
|
|
1709
|
-
return function invoke(method, arg) {
|
|
1710
|
-
if (state === GenStateExecuting) {
|
|
1711
|
-
throw new Error("Generator is already running");
|
|
1712
|
-
}
|
|
1713
|
-
|
|
1714
|
-
if (state === GenStateCompleted) {
|
|
1715
|
-
if (method === "throw") {
|
|
1716
|
-
throw arg;
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
1720
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
1721
|
-
return doneResult();
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
context.method = method;
|
|
1725
|
-
context.arg = arg;
|
|
1726
|
-
|
|
1727
|
-
while (true) {
|
|
1728
|
-
var delegate = context.delegate;
|
|
1729
|
-
if (delegate) {
|
|
1730
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1731
|
-
if (delegateResult) {
|
|
1732
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
1733
|
-
return delegateResult;
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
if (context.method === "next") {
|
|
1738
|
-
// Setting context._sent for legacy support of Babel's
|
|
1739
|
-
// function.sent implementation.
|
|
1740
|
-
context.sent = context._sent = context.arg;
|
|
1741
|
-
|
|
1742
|
-
} else if (context.method === "throw") {
|
|
1743
|
-
if (state === GenStateSuspendedStart) {
|
|
1744
|
-
state = GenStateCompleted;
|
|
1745
|
-
throw context.arg;
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
context.dispatchException(context.arg);
|
|
1749
|
-
|
|
1750
|
-
} else if (context.method === "return") {
|
|
1751
|
-
context.abrupt("return", context.arg);
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
state = GenStateExecuting;
|
|
1755
|
-
|
|
1756
|
-
var record = tryCatch(innerFn, self, context);
|
|
1757
|
-
if (record.type === "normal") {
|
|
1758
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
1759
|
-
// GenStateExecuting and loop back for another invocation.
|
|
1760
|
-
state = context.done
|
|
1761
|
-
? GenStateCompleted
|
|
1762
|
-
: GenStateSuspendedYield;
|
|
1763
|
-
|
|
1764
|
-
if (record.arg === ContinueSentinel) {
|
|
1765
|
-
continue;
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
return {
|
|
1769
|
-
value: record.arg,
|
|
1770
|
-
done: context.done
|
|
1771
|
-
};
|
|
1772
|
-
|
|
1773
|
-
} else if (record.type === "throw") {
|
|
1774
|
-
state = GenStateCompleted;
|
|
1775
|
-
// Dispatch the exception by looping back around to the
|
|
1776
|
-
// context.dispatchException(context.arg) call above.
|
|
1777
|
-
context.method = "throw";
|
|
1778
|
-
context.arg = record.arg;
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
};
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
1785
|
-
// result, either by returning a { value, done } result from the
|
|
1786
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
1787
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
1788
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
1789
|
-
var method = delegate.iterator[context.method];
|
|
1790
|
-
if (method === undefined$1) {
|
|
1791
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
1792
|
-
// method always terminates the yield* loop.
|
|
1793
|
-
context.delegate = null;
|
|
1794
|
-
|
|
1795
|
-
if (context.method === "throw") {
|
|
1796
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
1797
|
-
if (delegate.iterator["return"]) {
|
|
1798
|
-
// If the delegate iterator has a return method, give it a
|
|
1799
|
-
// chance to clean up.
|
|
1800
|
-
context.method = "return";
|
|
1801
|
-
context.arg = undefined$1;
|
|
1802
|
-
maybeInvokeDelegate(delegate, context);
|
|
1803
|
-
|
|
1804
|
-
if (context.method === "throw") {
|
|
1805
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
1806
|
-
// "return" to "throw", let that override the TypeError below.
|
|
1807
|
-
return ContinueSentinel;
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
context.method = "throw";
|
|
1812
|
-
context.arg = new TypeError(
|
|
1813
|
-
"The iterator does not provide a 'throw' method");
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
return ContinueSentinel;
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1820
|
-
|
|
1821
|
-
if (record.type === "throw") {
|
|
1822
|
-
context.method = "throw";
|
|
1823
|
-
context.arg = record.arg;
|
|
1824
|
-
context.delegate = null;
|
|
1825
|
-
return ContinueSentinel;
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
var info = record.arg;
|
|
1829
|
-
|
|
1830
|
-
if (! info) {
|
|
1831
|
-
context.method = "throw";
|
|
1832
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
1833
|
-
context.delegate = null;
|
|
1834
|
-
return ContinueSentinel;
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
if (info.done) {
|
|
1838
|
-
// Assign the result of the finished delegate to the temporary
|
|
1839
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
1840
|
-
context[delegate.resultName] = info.value;
|
|
1841
|
-
|
|
1842
|
-
// Resume execution at the desired location (see delegateYield).
|
|
1843
|
-
context.next = delegate.nextLoc;
|
|
1844
|
-
|
|
1845
|
-
// If context.method was "throw" but the delegate handled the
|
|
1846
|
-
// exception, let the outer generator proceed normally. If
|
|
1847
|
-
// context.method was "next", forget context.arg since it has been
|
|
1848
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
1849
|
-
// "return", allow the original .return call to continue in the
|
|
1850
|
-
// outer generator.
|
|
1851
|
-
if (context.method !== "return") {
|
|
1852
|
-
context.method = "next";
|
|
1853
|
-
context.arg = undefined$1;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
} else {
|
|
1857
|
-
// Re-yield the result returned by the delegate method.
|
|
1858
|
-
return info;
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
1862
|
-
// the outer generator.
|
|
1863
|
-
context.delegate = null;
|
|
1864
|
-
return ContinueSentinel;
|
|
1865
|
-
}
|
|
1866
|
-
|
|
1867
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
1868
|
-
// unified ._invoke helper method.
|
|
1869
|
-
defineIteratorMethods(Gp);
|
|
1870
|
-
|
|
1871
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
1872
|
-
|
|
1873
|
-
// A Generator should always return itself as the iterator object when the
|
|
1874
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
1875
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
1876
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
1877
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1878
|
-
Gp[iteratorSymbol] = function() {
|
|
1879
|
-
return this;
|
|
1880
|
-
};
|
|
1881
|
-
|
|
1882
|
-
Gp.toString = function() {
|
|
1883
|
-
return "[object Generator]";
|
|
1884
|
-
};
|
|
1885
|
-
|
|
1886
|
-
function pushTryEntry(locs) {
|
|
1887
|
-
var entry = { tryLoc: locs[0] };
|
|
1888
|
-
|
|
1889
|
-
if (1 in locs) {
|
|
1890
|
-
entry.catchLoc = locs[1];
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
if (2 in locs) {
|
|
1894
|
-
entry.finallyLoc = locs[2];
|
|
1895
|
-
entry.afterLoc = locs[3];
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
this.tryEntries.push(entry);
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
function resetTryEntry(entry) {
|
|
1902
|
-
var record = entry.completion || {};
|
|
1903
|
-
record.type = "normal";
|
|
1904
|
-
delete record.arg;
|
|
1905
|
-
entry.completion = record;
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
function Context(tryLocsList) {
|
|
1909
|
-
// The root entry object (effectively a try statement without a catch
|
|
1910
|
-
// or a finally block) gives us a place to store values thrown from
|
|
1911
|
-
// locations where there is no enclosing try statement.
|
|
1912
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
1913
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
1914
|
-
this.reset(true);
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
exports.keys = function(object) {
|
|
1918
|
-
var keys = [];
|
|
1919
|
-
for (var key in object) {
|
|
1920
|
-
keys.push(key);
|
|
1921
|
-
}
|
|
1922
|
-
keys.reverse();
|
|
1923
|
-
|
|
1924
|
-
// Rather than returning an object with a next method, we keep
|
|
1925
|
-
// things simple and return the next function itself.
|
|
1926
|
-
return function next() {
|
|
1927
|
-
while (keys.length) {
|
|
1928
|
-
var key = keys.pop();
|
|
1929
|
-
if (key in object) {
|
|
1930
|
-
next.value = key;
|
|
1931
|
-
next.done = false;
|
|
1932
|
-
return next;
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
// To avoid creating an additional object, we just hang the .value
|
|
1937
|
-
// and .done properties off the next function object itself. This
|
|
1938
|
-
// also ensures that the minifier will not anonymize the function.
|
|
1939
|
-
next.done = true;
|
|
1940
|
-
return next;
|
|
1941
|
-
};
|
|
1942
|
-
};
|
|
1943
|
-
|
|
1944
|
-
function values(iterable) {
|
|
1945
|
-
if (iterable) {
|
|
1946
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
1947
|
-
if (iteratorMethod) {
|
|
1948
|
-
return iteratorMethod.call(iterable);
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
if (typeof iterable.next === "function") {
|
|
1952
|
-
return iterable;
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
if (!isNaN(iterable.length)) {
|
|
1956
|
-
var i = -1, next = function next() {
|
|
1957
|
-
while (++i < iterable.length) {
|
|
1958
|
-
if (hasOwn.call(iterable, i)) {
|
|
1959
|
-
next.value = iterable[i];
|
|
1960
|
-
next.done = false;
|
|
1961
|
-
return next;
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
next.value = undefined$1;
|
|
1966
|
-
next.done = true;
|
|
1967
|
-
|
|
1968
|
-
return next;
|
|
1969
|
-
};
|
|
1970
|
-
|
|
1971
|
-
return next.next = next;
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
|
-
// Return an iterator with no values.
|
|
1976
|
-
return { next: doneResult };
|
|
1977
|
-
}
|
|
1978
|
-
exports.values = values;
|
|
1979
|
-
|
|
1980
|
-
function doneResult() {
|
|
1981
|
-
return { value: undefined$1, done: true };
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
Context.prototype = {
|
|
1985
|
-
constructor: Context,
|
|
1986
|
-
|
|
1987
|
-
reset: function(skipTempReset) {
|
|
1988
|
-
this.prev = 0;
|
|
1989
|
-
this.next = 0;
|
|
1990
|
-
// Resetting context._sent for legacy support of Babel's
|
|
1991
|
-
// function.sent implementation.
|
|
1992
|
-
this.sent = this._sent = undefined$1;
|
|
1993
|
-
this.done = false;
|
|
1994
|
-
this.delegate = null;
|
|
1995
|
-
|
|
1996
|
-
this.method = "next";
|
|
1997
|
-
this.arg = undefined$1;
|
|
1998
|
-
|
|
1999
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
2000
|
-
|
|
2001
|
-
if (!skipTempReset) {
|
|
2002
|
-
for (var name in this) {
|
|
2003
|
-
// Not sure about the optimal order of these conditions:
|
|
2004
|
-
if (name.charAt(0) === "t" &&
|
|
2005
|
-
hasOwn.call(this, name) &&
|
|
2006
|
-
!isNaN(+name.slice(1))) {
|
|
2007
|
-
this[name] = undefined$1;
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
},
|
|
2012
|
-
|
|
2013
|
-
stop: function() {
|
|
2014
|
-
this.done = true;
|
|
2015
|
-
|
|
2016
|
-
var rootEntry = this.tryEntries[0];
|
|
2017
|
-
var rootRecord = rootEntry.completion;
|
|
2018
|
-
if (rootRecord.type === "throw") {
|
|
2019
|
-
throw rootRecord.arg;
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
return this.rval;
|
|
2023
|
-
},
|
|
2024
|
-
|
|
2025
|
-
dispatchException: function(exception) {
|
|
2026
|
-
if (this.done) {
|
|
2027
|
-
throw exception;
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
var context = this;
|
|
2031
|
-
function handle(loc, caught) {
|
|
2032
|
-
record.type = "throw";
|
|
2033
|
-
record.arg = exception;
|
|
2034
|
-
context.next = loc;
|
|
2035
|
-
|
|
2036
|
-
if (caught) {
|
|
2037
|
-
// If the dispatched exception was caught by a catch block,
|
|
2038
|
-
// then let that catch block handle the exception normally.
|
|
2039
|
-
context.method = "next";
|
|
2040
|
-
context.arg = undefined$1;
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
return !! caught;
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2047
|
-
var entry = this.tryEntries[i];
|
|
2048
|
-
var record = entry.completion;
|
|
2049
|
-
|
|
2050
|
-
if (entry.tryLoc === "root") {
|
|
2051
|
-
// Exception thrown outside of any try block that could handle
|
|
2052
|
-
// it, so set the completion value of the entire function to
|
|
2053
|
-
// throw the exception.
|
|
2054
|
-
return handle("end");
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
|
-
if (entry.tryLoc <= this.prev) {
|
|
2058
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
2059
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
2060
|
-
|
|
2061
|
-
if (hasCatch && hasFinally) {
|
|
2062
|
-
if (this.prev < entry.catchLoc) {
|
|
2063
|
-
return handle(entry.catchLoc, true);
|
|
2064
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
2065
|
-
return handle(entry.finallyLoc);
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
} else if (hasCatch) {
|
|
2069
|
-
if (this.prev < entry.catchLoc) {
|
|
2070
|
-
return handle(entry.catchLoc, true);
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
} else if (hasFinally) {
|
|
2074
|
-
if (this.prev < entry.finallyLoc) {
|
|
2075
|
-
return handle(entry.finallyLoc);
|
|
2076
|
-
}
|
|
2077
|
-
|
|
2078
|
-
} else {
|
|
2079
|
-
throw new Error("try statement without catch or finally");
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
},
|
|
2084
|
-
|
|
2085
|
-
abrupt: function(type, arg) {
|
|
2086
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2087
|
-
var entry = this.tryEntries[i];
|
|
2088
|
-
if (entry.tryLoc <= this.prev &&
|
|
2089
|
-
hasOwn.call(entry, "finallyLoc") &&
|
|
2090
|
-
this.prev < entry.finallyLoc) {
|
|
2091
|
-
var finallyEntry = entry;
|
|
2092
|
-
break;
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
if (finallyEntry &&
|
|
2097
|
-
(type === "break" ||
|
|
2098
|
-
type === "continue") &&
|
|
2099
|
-
finallyEntry.tryLoc <= arg &&
|
|
2100
|
-
arg <= finallyEntry.finallyLoc) {
|
|
2101
|
-
// Ignore the finally entry if control is not jumping to a
|
|
2102
|
-
// location outside the try/catch block.
|
|
2103
|
-
finallyEntry = null;
|
|
2104
|
-
}
|
|
2105
|
-
|
|
2106
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
2107
|
-
record.type = type;
|
|
2108
|
-
record.arg = arg;
|
|
2109
|
-
|
|
2110
|
-
if (finallyEntry) {
|
|
2111
|
-
this.method = "next";
|
|
2112
|
-
this.next = finallyEntry.finallyLoc;
|
|
2113
|
-
return ContinueSentinel;
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
return this.complete(record);
|
|
2117
|
-
},
|
|
2118
|
-
|
|
2119
|
-
complete: function(record, afterLoc) {
|
|
2120
|
-
if (record.type === "throw") {
|
|
2121
|
-
throw record.arg;
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
if (record.type === "break" ||
|
|
2125
|
-
record.type === "continue") {
|
|
2126
|
-
this.next = record.arg;
|
|
2127
|
-
} else if (record.type === "return") {
|
|
2128
|
-
this.rval = this.arg = record.arg;
|
|
2129
|
-
this.method = "return";
|
|
2130
|
-
this.next = "end";
|
|
2131
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
2132
|
-
this.next = afterLoc;
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
return ContinueSentinel;
|
|
2136
|
-
},
|
|
2137
|
-
|
|
2138
|
-
finish: function(finallyLoc) {
|
|
2139
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2140
|
-
var entry = this.tryEntries[i];
|
|
2141
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
2142
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
2143
|
-
resetTryEntry(entry);
|
|
2144
|
-
return ContinueSentinel;
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
},
|
|
2148
|
-
|
|
2149
|
-
"catch": function(tryLoc) {
|
|
2150
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2151
|
-
var entry = this.tryEntries[i];
|
|
2152
|
-
if (entry.tryLoc === tryLoc) {
|
|
2153
|
-
var record = entry.completion;
|
|
2154
|
-
if (record.type === "throw") {
|
|
2155
|
-
var thrown = record.arg;
|
|
2156
|
-
resetTryEntry(entry);
|
|
2157
|
-
}
|
|
2158
|
-
return thrown;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
// The context.catch method must only be called with a location
|
|
2163
|
-
// argument that corresponds to a known catch block.
|
|
2164
|
-
throw new Error("illegal catch attempt");
|
|
2165
|
-
},
|
|
2166
|
-
|
|
2167
|
-
delegateYield: function(iterable, resultName, nextLoc) {
|
|
2168
|
-
this.delegate = {
|
|
2169
|
-
iterator: values(iterable),
|
|
2170
|
-
resultName: resultName,
|
|
2171
|
-
nextLoc: nextLoc
|
|
2172
|
-
};
|
|
2173
|
-
|
|
2174
|
-
if (this.method === "next") {
|
|
2175
|
-
// Deliberately forget the last sent value so that we don't
|
|
2176
|
-
// accidentally pass it on to the delegate.
|
|
2177
|
-
this.arg = undefined$1;
|
|
2178
|
-
}
|
|
2179
|
-
|
|
2180
|
-
return ContinueSentinel;
|
|
2181
|
-
}
|
|
2182
|
-
};
|
|
2183
|
-
|
|
2184
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
2185
|
-
// or not, return the runtime object so that we can declare the variable
|
|
2186
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
2187
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
2188
|
-
return exports;
|
|
2189
|
-
|
|
2190
|
-
}(
|
|
2191
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
2192
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
2193
|
-
// object. Either way, the resulting object will be used to initialize
|
|
2194
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
2195
|
-
module.exports
|
|
2196
|
-
));
|
|
2197
|
-
|
|
2198
|
-
try {
|
|
2199
|
-
regeneratorRuntime = runtime;
|
|
2200
|
-
} catch (accidentalStrictMode) {
|
|
2201
|
-
// This module should not be running in strict mode, so the above
|
|
2202
|
-
// assignment should always work unless something is misconfigured. Just
|
|
2203
|
-
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
2204
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
2205
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
2206
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
2207
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
2208
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
2209
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
2210
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
2211
|
-
}
|
|
2212
|
-
});
|
|
2213
|
-
|
|
2214
|
-
/**
|
|
2215
|
-
* Utilities for fetching specific types
|
|
2216
|
-
*/
|
|
2217
|
-
function fetchJson(_x) {
|
|
2218
|
-
return _fetchJson.apply(this, arguments);
|
|
2219
|
-
}
|
|
2220
|
-
|
|
2221
|
-
function _fetchJson() {
|
|
2222
|
-
_fetchJson = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(url) {
|
|
2223
|
-
var response;
|
|
2224
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2225
|
-
while (1) {
|
|
2226
|
-
switch (_context.prev = _context.next) {
|
|
2227
|
-
case 0:
|
|
2228
|
-
_context.next = 2;
|
|
2229
|
-
return fetch(url);
|
|
2230
|
-
|
|
2231
|
-
case 2:
|
|
2232
|
-
response = _context.sent;
|
|
2233
|
-
|
|
2234
|
-
if (response.ok) {
|
|
2235
|
-
_context.next = 5;
|
|
2236
|
-
break;
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
throw new Error('Response not Ok for URL: ' + url);
|
|
2240
|
-
|
|
2241
|
-
case 5:
|
|
2242
|
-
_context.next = 7;
|
|
2243
|
-
return response.json();
|
|
2244
|
-
|
|
2245
|
-
case 7:
|
|
2246
|
-
return _context.abrupt("return", _context.sent);
|
|
2247
|
-
|
|
2248
|
-
case 8:
|
|
2249
|
-
case "end":
|
|
2250
|
-
return _context.stop();
|
|
2251
|
-
}
|
|
2252
|
-
}
|
|
2253
|
-
}, _callee);
|
|
2254
|
-
}));
|
|
2255
|
-
return _fetchJson.apply(this, arguments);
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
var HtmlReaderContent = function HtmlReaderContent() {
|
|
2259
|
-
return React.createElement("div", {
|
|
2260
|
-
id: "D2Reader-Container"
|
|
2261
|
-
}, React.createElement("main", {
|
|
2262
|
-
tabIndex: -1,
|
|
2263
|
-
id: "iframe-wrapper",
|
|
2264
|
-
style: {
|
|
2265
|
-
height: "calc(100vh - " + HEADER_HEIGHT + "px)"
|
|
2266
|
-
}
|
|
2267
|
-
}, React.createElement("div", {
|
|
2268
|
-
id: "reader-loading",
|
|
2269
|
-
className: "loading"
|
|
2270
|
-
}), React.createElement("div", {
|
|
2271
|
-
id: "reader-error",
|
|
2272
|
-
className: "error"
|
|
2273
|
-
})));
|
|
2274
|
-
};
|
|
2275
|
-
|
|
2276
|
-
function useMeasure() {
|
|
2277
|
-
// this is a little trick to get a reference to an HTML element. Using useRef wouldn't
|
|
2278
|
-
// work because we actually need rerenders when it changes, to update the useLayoutEffect
|
|
2279
|
-
var _React$useState = React.useState(null),
|
|
2280
|
-
element = _React$useState[0],
|
|
2281
|
-
ref = _React$useState[1];
|
|
2282
|
-
|
|
2283
|
-
var _React$useState2 = React.useState(null),
|
|
2284
|
-
rect = _React$useState2[0],
|
|
2285
|
-
setRect = _React$useState2[1];
|
|
2286
|
-
|
|
2287
|
-
var observer = React.useMemo(function () {
|
|
2288
|
-
return new window.ResizeObserver(function (entries) {
|
|
2289
|
-
if (entries[0]) {
|
|
2290
|
-
var _entries$0$contentRec = entries[0].contentRect,
|
|
2291
|
-
x = _entries$0$contentRec.x,
|
|
2292
|
-
y = _entries$0$contentRec.y,
|
|
2293
|
-
width = _entries$0$contentRec.width,
|
|
2294
|
-
height = _entries$0$contentRec.height,
|
|
2295
|
-
top = _entries$0$contentRec.top,
|
|
2296
|
-
left = _entries$0$contentRec.left,
|
|
2297
|
-
bottom = _entries$0$contentRec.bottom,
|
|
2298
|
-
right = _entries$0$contentRec.right;
|
|
2299
|
-
setRect({
|
|
2300
|
-
x: x,
|
|
2301
|
-
y: y,
|
|
2302
|
-
width: width,
|
|
2303
|
-
height: height,
|
|
2304
|
-
top: top,
|
|
2305
|
-
left: left,
|
|
2306
|
-
bottom: bottom,
|
|
2307
|
-
right: right
|
|
2308
|
-
});
|
|
2309
|
-
}
|
|
2310
|
-
});
|
|
2311
|
-
}, []);
|
|
2312
|
-
React.useLayoutEffect(function () {
|
|
2313
|
-
if (!element) return;
|
|
2314
|
-
observer.observe(element);
|
|
2315
|
-
return function () {
|
|
2316
|
-
observer.disconnect();
|
|
2317
|
-
};
|
|
2318
|
-
}, [element, observer]);
|
|
2319
|
-
return [ref, rect];
|
|
2320
|
-
}
|
|
2321
|
-
|
|
2322
|
-
reactPdf.pdfjs.GlobalWorkerOptions.workerSrc = "pdf.worker.min.js";
|
|
2323
|
-
var IFRAME_WRAPPER_ID = 'iframe-wrapper';
|
|
2324
|
-
|
|
2325
|
-
function pdfReducer(state, action) {
|
|
2326
|
-
switch (action.type) {
|
|
2327
|
-
/**
|
|
2328
|
-
* Cleares the current resource and sets the current index, which will cause
|
|
2329
|
-
* the useEffect hook to load a new resource.
|
|
2330
|
-
*/
|
|
2331
|
-
case 'SET_CURRENT_RESOURCE':
|
|
2332
|
-
return _extends({}, state, {
|
|
2333
|
-
resource: null,
|
|
2334
|
-
resourceIndex: action.index,
|
|
2335
|
-
pageNumber: action.shouldNavigateToEnd ? -1 : 1,
|
|
2336
|
-
numPages: null
|
|
2337
|
-
});
|
|
2338
|
-
|
|
2339
|
-
case 'RESOURCE_FETCH_SUCCESS':
|
|
2340
|
-
return _extends({}, state, {
|
|
2341
|
-
resource: action.resource
|
|
2342
|
-
});
|
|
2343
|
-
// called when the resource has been parsed by react-pdf
|
|
2344
|
-
// and we know the number of pages
|
|
2345
|
-
|
|
2346
|
-
case 'PDF_PARSED':
|
|
2347
|
-
return _extends({}, state, {
|
|
2348
|
-
numPages: action.numPages,
|
|
2349
|
-
// if the state.pageNumber is -1, we know to navigate to the
|
|
2350
|
-
// end of the PDF that was just parsed
|
|
2351
|
-
pageNumber: state.pageNumber === -1 ? action.numPages : state.pageNumber
|
|
2352
|
-
});
|
|
2353
|
-
// Navigates to page in resource
|
|
2354
|
-
|
|
2355
|
-
case 'NAVIGATE_PAGE':
|
|
2356
|
-
return _extends({}, state, {
|
|
2357
|
-
pageNumber: action.pageNum
|
|
2358
|
-
});
|
|
2359
|
-
|
|
2360
|
-
case 'SET_COLOR_MODE':
|
|
2361
|
-
return _extends({}, state, {
|
|
2362
|
-
colorMode: action.mode
|
|
2363
|
-
});
|
|
2364
|
-
|
|
2365
|
-
case 'SET_SCROLL':
|
|
2366
|
-
return _extends({}, state, {
|
|
2367
|
-
isScrolling: action.isScrolling
|
|
2368
|
-
});
|
|
2369
|
-
|
|
2370
|
-
case 'SET_SCALE':
|
|
2371
|
-
return _extends({}, state, {
|
|
2372
|
-
scale: action.scale
|
|
2373
|
-
});
|
|
2374
|
-
|
|
2375
|
-
case 'PAGE_LOAD_SUCCESS':
|
|
2376
|
-
return _extends({}, state, {
|
|
2377
|
-
pdfWidth: action.width,
|
|
2378
|
-
pdfHeight: action.height,
|
|
2379
|
-
pageWidth: action.width,
|
|
2380
|
-
pageHeight: action.height
|
|
2381
|
-
});
|
|
2382
|
-
|
|
2383
|
-
case 'RESIZE_PAGE':
|
|
2384
|
-
return _extends({}, state, {
|
|
2385
|
-
pageWidth: action.width,
|
|
2386
|
-
pageHeight: action.height
|
|
2387
|
-
});
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
var getResourceUrl = function getResourceUrl(index, readingOrder) {
|
|
2392
|
-
if (!readingOrder || !readingOrder.length) {
|
|
2393
|
-
throw new Error('A manifest has been returned, but has no reading order');
|
|
2394
|
-
} // If it has no children, return the link href
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
return readingOrder[index].href;
|
|
2398
|
-
};
|
|
2399
|
-
|
|
2400
|
-
var loadResource = /*#__PURE__*/function () {
|
|
2401
|
-
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(resourceUrl, proxyUrl) {
|
|
2402
|
-
var resource, response, array;
|
|
2403
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2404
|
-
while (1) {
|
|
2405
|
-
switch (_context.prev = _context.next) {
|
|
2406
|
-
case 0:
|
|
2407
|
-
// Generate the resource URL using the proxy
|
|
2408
|
-
resource = proxyUrl + encodeURI(resourceUrl);
|
|
2409
|
-
_context.next = 3;
|
|
2410
|
-
return fetch(resource, {
|
|
2411
|
-
mode: 'cors'
|
|
2412
|
-
});
|
|
2413
|
-
|
|
2414
|
-
case 3:
|
|
2415
|
-
response = _context.sent;
|
|
2416
|
-
_context.t0 = Uint8Array;
|
|
2417
|
-
_context.next = 7;
|
|
2418
|
-
return response.arrayBuffer();
|
|
2419
|
-
|
|
2420
|
-
case 7:
|
|
2421
|
-
_context.t1 = _context.sent;
|
|
2422
|
-
array = new _context.t0(_context.t1);
|
|
2423
|
-
|
|
2424
|
-
if (response.ok) {
|
|
2425
|
-
_context.next = 11;
|
|
2426
|
-
break;
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
throw new Error('Response not Ok for URL: ' + resource);
|
|
2430
|
-
|
|
2431
|
-
case 11:
|
|
2432
|
-
return _context.abrupt("return", array);
|
|
2433
|
-
|
|
2434
|
-
case 12:
|
|
2435
|
-
case "end":
|
|
2436
|
-
return _context.stop();
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
}, _callee);
|
|
2440
|
-
}));
|
|
2441
|
-
|
|
2442
|
-
return function loadResource(_x, _x2) {
|
|
2443
|
-
return _ref.apply(this, arguments);
|
|
2444
|
-
};
|
|
2445
|
-
}();
|
|
2446
|
-
/**
|
|
2447
|
-
* The PDF reader
|
|
2448
|
-
*
|
|
2449
|
-
* The PDF reader loads resources in two stages: First, it fetches the PDF resource as an Uint8Array
|
|
2450
|
-
* Then, it passes this array into the <Document> object, which loads the PDF inside an iframe
|
|
2451
|
-
*
|
|
2452
|
-
* @param args T
|
|
2453
|
-
* @returns
|
|
2454
|
-
*/
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
function usePdfReader(args) {
|
|
2458
|
-
var _ref2 = args != null ? args : {},
|
|
2459
|
-
webpubManifestUrl = _ref2.webpubManifestUrl,
|
|
2460
|
-
manifest = _ref2.manifest,
|
|
2461
|
-
proxyUrl = _ref2.proxyUrl;
|
|
2462
|
-
|
|
2463
|
-
var _React$useReducer = React.useReducer(pdfReducer, {
|
|
2464
|
-
colorMode: 'day',
|
|
2465
|
-
isScrolling: false,
|
|
2466
|
-
fontSize: 16,
|
|
2467
|
-
fontFamily: 'sans-serif',
|
|
2468
|
-
resourceIndex: 0,
|
|
2469
|
-
resource: null,
|
|
2470
|
-
pageNumber: 1,
|
|
2471
|
-
numPages: null,
|
|
2472
|
-
currentTocUrl: null,
|
|
2473
|
-
scale: 1,
|
|
2474
|
-
pdfWidth: 0,
|
|
2475
|
-
pdfHeight: 0,
|
|
2476
|
-
pageHeight: undefined,
|
|
2477
|
-
pageWidth: undefined
|
|
2478
|
-
}),
|
|
2479
|
-
state = _React$useReducer[0],
|
|
2480
|
-
dispatch = _React$useReducer[1]; // state we can derive from the state above
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
var isFetching = !state.resource;
|
|
2484
|
-
var isParsed = typeof state.numPages === 'number';
|
|
2485
|
-
|
|
2486
|
-
var _useMeasure = useMeasure(),
|
|
2487
|
-
containerRef = _useMeasure[0],
|
|
2488
|
-
containerSize = _useMeasure[1]; // Wrap Page component so that we can pass it styles
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
var ChakraPage = react.chakra(reactPdf.Page, {
|
|
2492
|
-
shouldForwardProp: function shouldForwardProp(prop) {
|
|
2493
|
-
// Definitely forward width and height
|
|
2494
|
-
if (['width', 'height', 'scale'].includes(prop)) return true; // don't forward the rest of Chakra's props
|
|
2495
|
-
|
|
2496
|
-
var isChakraProp = !react.shouldForwardProp(prop);
|
|
2497
|
-
if (isChakraProp) return false; // else, only forward `sample` prop
|
|
2498
|
-
|
|
2499
|
-
return true;
|
|
2500
|
-
},
|
|
2501
|
-
baseStyle: {
|
|
2502
|
-
outline: '1px',
|
|
2503
|
-
outlineColor: 'ui.gray.light-cool'
|
|
2504
|
-
}
|
|
2505
|
-
});
|
|
2506
|
-
/**
|
|
2507
|
-
* Load the current resource and set it in state,
|
|
2508
|
-
* and reload whenever it changes (via navigation)
|
|
2509
|
-
*/
|
|
2510
|
-
|
|
2511
|
-
React.useEffect(function () {
|
|
2512
|
-
// bail out if there is not manifest passed in,
|
|
2513
|
-
// that indicates that this format is inactive
|
|
2514
|
-
if (!manifest) return; // throw an error on a badly formed manifest
|
|
2515
|
-
|
|
2516
|
-
if (!manifest.readingOrder || !manifest.readingOrder.length) {
|
|
2517
|
-
throw new Error('Manifest has no Reading Order');
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
var resourceUrl = getResourceUrl(state.resourceIndex, manifest.readingOrder);
|
|
2521
|
-
loadResource(resourceUrl, proxyUrl).then(function (data) {
|
|
2522
|
-
dispatch({
|
|
2523
|
-
type: 'RESOURCE_FETCH_SUCCESS',
|
|
2524
|
-
resource: {
|
|
2525
|
-
data: data
|
|
2526
|
-
}
|
|
2527
|
-
});
|
|
2528
|
-
});
|
|
2529
|
-
}, [state.resourceIndex, manifest, proxyUrl]);
|
|
2530
|
-
/**
|
|
2531
|
-
* calculate the height or width of the pdf page in paginated mode.
|
|
2532
|
-
* - if the page's aspect ratio is taller than the container's, we will constrain
|
|
2533
|
-
* the page to the height of the container.
|
|
2534
|
-
* - if the page's aspect ratio is wider than the container's, we will constrain
|
|
2535
|
-
* the page to the width of the container
|
|
2536
|
-
*/
|
|
2537
|
-
|
|
2538
|
-
var resizePage = React.useCallback(function (pdfWidth, pdfHeight, containerSize) {
|
|
2539
|
-
var wRatio = pdfWidth / containerSize.width;
|
|
2540
|
-
var hRatio = pdfHeight / containerSize.height;
|
|
2541
|
-
var fitHorizontal = wRatio > hRatio;
|
|
2542
|
-
var width = fitHorizontal ? Math.round(containerSize.width) : undefined;
|
|
2543
|
-
var height = !fitHorizontal ? Math.round(containerSize.height) : undefined;
|
|
2544
|
-
dispatch({
|
|
2545
|
-
type: 'RESIZE_PAGE',
|
|
2546
|
-
width: width,
|
|
2547
|
-
height: height
|
|
2548
|
-
});
|
|
2549
|
-
}, []); //TODO: Somehow, this window size updates when height
|
|
2550
|
-
|
|
2551
|
-
React.useEffect(function () {
|
|
2552
|
-
if (containerSize) {
|
|
2553
|
-
resizePage(state.pdfWidth, state.pdfHeight, containerSize);
|
|
2554
|
-
}
|
|
2555
|
-
}, [containerSize, state.pdfWidth, state.pdfHeight, resizePage]); // prev and next page functions
|
|
2556
|
-
|
|
2557
|
-
var goForward = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
2558
|
-
var _manifest$readingOrde;
|
|
2559
|
-
|
|
2560
|
-
var nextIndex;
|
|
2561
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2562
|
-
while (1) {
|
|
2563
|
-
switch (_context2.prev = _context2.next) {
|
|
2564
|
-
case 0:
|
|
2565
|
-
if (state.numPages) {
|
|
2566
|
-
_context2.next = 2;
|
|
2567
|
-
break;
|
|
2568
|
-
}
|
|
2569
|
-
|
|
2570
|
-
return _context2.abrupt("return");
|
|
2571
|
-
|
|
2572
|
-
case 2:
|
|
2573
|
-
if (state.pageNumber < state.numPages && !state.isScrolling) {
|
|
2574
|
-
dispatch({
|
|
2575
|
-
type: 'NAVIGATE_PAGE',
|
|
2576
|
-
pageNum: state.pageNumber + 1
|
|
2577
|
-
});
|
|
2578
|
-
} else if (manifest && manifest.readingOrder && state.resourceIndex < (manifest == null ? void 0 : (_manifest$readingOrde = manifest.readingOrder) == null ? void 0 : _manifest$readingOrde.length) - 1) {
|
|
2579
|
-
nextIndex = state.resourceIndex + 1;
|
|
2580
|
-
dispatch({
|
|
2581
|
-
type: 'SET_CURRENT_RESOURCE',
|
|
2582
|
-
index: nextIndex,
|
|
2583
|
-
shouldNavigateToEnd: false
|
|
2584
|
-
});
|
|
2585
|
-
} // Do nothing if it's at the last page of the last resource
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
case 3:
|
|
2589
|
-
case "end":
|
|
2590
|
-
return _context2.stop();
|
|
2591
|
-
}
|
|
2592
|
-
}
|
|
2593
|
-
}, _callee2);
|
|
2594
|
-
})), [manifest, state.isScrolling, state.numPages, state.pageNumber, state.resourceIndex]);
|
|
2595
|
-
var goBackward = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
2596
|
-
var nextIndex;
|
|
2597
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2598
|
-
while (1) {
|
|
2599
|
-
switch (_context3.prev = _context3.next) {
|
|
2600
|
-
case 0:
|
|
2601
|
-
if (isParsed) {
|
|
2602
|
-
_context3.next = 2;
|
|
2603
|
-
break;
|
|
2604
|
-
}
|
|
2605
|
-
|
|
2606
|
-
return _context3.abrupt("return");
|
|
2607
|
-
|
|
2608
|
-
case 2:
|
|
2609
|
-
if (state.pageNumber > 1) {
|
|
2610
|
-
dispatch({
|
|
2611
|
-
type: 'NAVIGATE_PAGE',
|
|
2612
|
-
pageNum: state.pageNumber - 1
|
|
2613
|
-
});
|
|
2614
|
-
} else if (manifest != null && manifest.readingOrder && state.resourceIndex > 0) {
|
|
2615
|
-
nextIndex = state.resourceIndex - 1;
|
|
2616
|
-
dispatch({
|
|
2617
|
-
type: 'SET_CURRENT_RESOURCE',
|
|
2618
|
-
index: nextIndex,
|
|
2619
|
-
shouldNavigateToEnd: !state.isScrolling
|
|
2620
|
-
});
|
|
2621
|
-
}
|
|
2622
|
-
|
|
2623
|
-
case 3:
|
|
2624
|
-
case "end":
|
|
2625
|
-
return _context3.stop();
|
|
2626
|
-
}
|
|
2627
|
-
}
|
|
2628
|
-
}, _callee3);
|
|
2629
|
-
})), [manifest, isParsed, state.isScrolling, state.pageNumber, state.resourceIndex]);
|
|
2630
|
-
/**
|
|
2631
|
-
* These ones don't make sense in the PDF case I dont think. I'm still
|
|
2632
|
-
* deciding how we will separate the types of Navigators and States, so
|
|
2633
|
-
* for now just pass dummies through.
|
|
2634
|
-
*/
|
|
2635
|
-
|
|
2636
|
-
var setColorMode = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2637
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2638
|
-
while (1) {
|
|
2639
|
-
switch (_context4.prev = _context4.next) {
|
|
2640
|
-
case 0:
|
|
2641
|
-
console.log('unimplemented');
|
|
2642
|
-
|
|
2643
|
-
case 1:
|
|
2644
|
-
case "end":
|
|
2645
|
-
return _context4.stop();
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
}, _callee4);
|
|
2649
|
-
})), []);
|
|
2650
|
-
var setScroll = React.useCallback( /*#__PURE__*/function () {
|
|
2651
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(val) {
|
|
2652
|
-
var isScrolling;
|
|
2653
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2654
|
-
while (1) {
|
|
2655
|
-
switch (_context5.prev = _context5.next) {
|
|
2656
|
-
case 0:
|
|
2657
|
-
isScrolling = val === 'scrolling';
|
|
2658
|
-
dispatch({
|
|
2659
|
-
type: 'SET_SCROLL',
|
|
2660
|
-
isScrolling: isScrolling
|
|
2661
|
-
});
|
|
2662
|
-
|
|
2663
|
-
case 2:
|
|
2664
|
-
case "end":
|
|
2665
|
-
return _context5.stop();
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
}, _callee5);
|
|
2669
|
-
}));
|
|
2670
|
-
|
|
2671
|
-
return function (_x3) {
|
|
2672
|
-
return _ref6.apply(this, arguments);
|
|
2673
|
-
};
|
|
2674
|
-
}(), []);
|
|
2675
|
-
/**
|
|
2676
|
-
* TODO: Change this button into a different "scale" button
|
|
2677
|
-
*/
|
|
2678
|
-
|
|
2679
|
-
var increaseFontSize = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
2680
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2681
|
-
while (1) {
|
|
2682
|
-
switch (_context6.prev = _context6.next) {
|
|
2683
|
-
case 0:
|
|
2684
|
-
dispatch({
|
|
2685
|
-
type: 'SET_SCALE',
|
|
2686
|
-
scale: state.scale + 0.1
|
|
2687
|
-
});
|
|
2688
|
-
|
|
2689
|
-
case 1:
|
|
2690
|
-
case "end":
|
|
2691
|
-
return _context6.stop();
|
|
2692
|
-
}
|
|
2693
|
-
}
|
|
2694
|
-
}, _callee6);
|
|
2695
|
-
})), [state.scale]);
|
|
2696
|
-
var decreaseFontSize = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
2697
|
-
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2698
|
-
while (1) {
|
|
2699
|
-
switch (_context7.prev = _context7.next) {
|
|
2700
|
-
case 0:
|
|
2701
|
-
dispatch({
|
|
2702
|
-
type: 'SET_SCALE',
|
|
2703
|
-
scale: state.scale - 0.1
|
|
2704
|
-
});
|
|
2705
|
-
|
|
2706
|
-
case 1:
|
|
2707
|
-
case "end":
|
|
2708
|
-
return _context7.stop();
|
|
2709
|
-
}
|
|
2710
|
-
}
|
|
2711
|
-
}, _callee7);
|
|
2712
|
-
})), [state.scale]);
|
|
2713
|
-
var setFontFamily = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
2714
|
-
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2715
|
-
while (1) {
|
|
2716
|
-
switch (_context8.prev = _context8.next) {
|
|
2717
|
-
case 0:
|
|
2718
|
-
console.log('unimplemented');
|
|
2719
|
-
|
|
2720
|
-
case 1:
|
|
2721
|
-
case "end":
|
|
2722
|
-
return _context8.stop();
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
}, _callee8);
|
|
2726
|
-
})), []);
|
|
2727
|
-
var goToPage = React.useCallback( /*#__PURE__*/function () {
|
|
2728
|
-
var _ref10 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(href) {
|
|
2729
|
-
var getIndexFromHref;
|
|
2730
|
-
return runtime_1.wrap(function _callee9$(_context9) {
|
|
2731
|
-
while (1) {
|
|
2732
|
-
switch (_context9.prev = _context9.next) {
|
|
2733
|
-
case 0:
|
|
2734
|
-
getIndexFromHref = function getIndexFromHref(href) {
|
|
2735
|
-
var _manifest$readingOrde2;
|
|
2736
|
-
|
|
2737
|
-
var index = manifest == null ? void 0 : (_manifest$readingOrde2 = manifest.readingOrder) == null ? void 0 : _manifest$readingOrde2.findIndex(function (link) {
|
|
2738
|
-
return link.href === href;
|
|
2739
|
-
});
|
|
2740
|
-
|
|
2741
|
-
if (!index) {
|
|
2742
|
-
throw new Error('Cannot find resource in readingOrder');
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
return index;
|
|
2746
|
-
};
|
|
2747
|
-
|
|
2748
|
-
dispatch({
|
|
2749
|
-
type: 'SET_CURRENT_RESOURCE',
|
|
2750
|
-
index: getIndexFromHref(href),
|
|
2751
|
-
shouldNavigateToEnd: false
|
|
2752
|
-
});
|
|
2753
|
-
|
|
2754
|
-
case 2:
|
|
2755
|
-
case "end":
|
|
2756
|
-
return _context9.stop();
|
|
2757
|
-
}
|
|
2758
|
-
}
|
|
2759
|
-
}, _callee9);
|
|
2760
|
-
}));
|
|
2761
|
-
|
|
2762
|
-
return function (_x4) {
|
|
2763
|
-
return _ref10.apply(this, arguments);
|
|
2764
|
-
};
|
|
2765
|
-
}(), [manifest == null ? void 0 : manifest.readingOrder]); // this format is inactive, return null
|
|
2766
|
-
|
|
2767
|
-
if (!webpubManifestUrl || !manifest) return null;
|
|
2768
|
-
|
|
2769
|
-
if (isFetching) {
|
|
2770
|
-
// The Reader is fetching a PDF resource
|
|
2771
|
-
return {
|
|
2772
|
-
type: 'PDF',
|
|
2773
|
-
isLoading: false,
|
|
2774
|
-
content: React.createElement(react.Flex, {
|
|
2775
|
-
as: "main",
|
|
2776
|
-
tabIndex: -1,
|
|
2777
|
-
id: "iframe-wrapper",
|
|
2778
|
-
zIndex: "base",
|
|
2779
|
-
alignItems: "center",
|
|
2780
|
-
justifyContent: "center",
|
|
2781
|
-
flex: "1 0 auto"
|
|
2782
|
-
}, "PDF is loading"),
|
|
2783
|
-
state: state,
|
|
2784
|
-
manifest: manifest,
|
|
2785
|
-
navigator: {
|
|
2786
|
-
goForward: goForward,
|
|
2787
|
-
goBackward: goBackward,
|
|
2788
|
-
increaseFontSize: increaseFontSize,
|
|
2789
|
-
decreaseFontSize: decreaseFontSize,
|
|
2790
|
-
setFontFamily: setFontFamily,
|
|
2791
|
-
setColorMode: setColorMode,
|
|
2792
|
-
setScroll: setScroll,
|
|
2793
|
-
goToPage: goToPage
|
|
2794
|
-
}
|
|
2795
|
-
};
|
|
2796
|
-
}
|
|
2797
|
-
|
|
2798
|
-
function onDocumentLoadSuccess(_ref11) {
|
|
2799
|
-
var numPages = _ref11.numPages;
|
|
2800
|
-
dispatch({
|
|
2801
|
-
type: 'PDF_PARSED',
|
|
2802
|
-
numPages: numPages
|
|
2803
|
-
});
|
|
2804
|
-
}
|
|
2805
|
-
|
|
2806
|
-
function onRenderSuccess(page) {
|
|
2807
|
-
if (!page.height || !page.width || !containerSize) throw new Error('Error rendering page from Reader');
|
|
2808
|
-
|
|
2809
|
-
if (Math.round(page.height) !== state.pdfHeight || Math.round(page.width) !== state.pdfWidth) {
|
|
2810
|
-
dispatch({
|
|
2811
|
-
type: 'PAGE_LOAD_SUCCESS',
|
|
2812
|
-
height: Math.round(page.height),
|
|
2813
|
-
width: Math.round(page.width)
|
|
2814
|
-
});
|
|
2815
|
-
resizePage(page.width, page.height, containerSize);
|
|
2816
|
-
}
|
|
2817
|
-
} // the reader is active but loading a page
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
return {
|
|
2821
|
-
type: 'PDF',
|
|
2822
|
-
isLoading: false,
|
|
2823
|
-
content: React.createElement(react.Flex, {
|
|
2824
|
-
as: "main",
|
|
2825
|
-
zIndex: "base",
|
|
2826
|
-
flex: "1 0 auto",
|
|
2827
|
-
justifyContent: "center",
|
|
2828
|
-
alignItems: "center",
|
|
2829
|
-
tabIndex: -1,
|
|
2830
|
-
id: IFRAME_WRAPPER_ID,
|
|
2831
|
-
ref: containerRef
|
|
2832
|
-
}, React.createElement(reactPdf.Document, {
|
|
2833
|
-
file: state.resource,
|
|
2834
|
-
onLoadSuccess: onDocumentLoadSuccess
|
|
2835
|
-
}, isParsed && state.numPages && React.createElement(React.Fragment, null, state.isScrolling && Array.from(new Array(state.numPages), function (_, index) {
|
|
2836
|
-
return React.createElement(ChakraPage, {
|
|
2837
|
-
key: "page_" + (index + 1),
|
|
2838
|
-
width: containerSize == null ? void 0 : containerSize.width,
|
|
2839
|
-
scale: state.scale,
|
|
2840
|
-
pageNumber: index + 1
|
|
2841
|
-
});
|
|
2842
|
-
}), !state.isScrolling && React.createElement(ChakraPage, {
|
|
2843
|
-
pageNumber: state.pageNumber,
|
|
2844
|
-
onLoadSuccess: onRenderSuccess,
|
|
2845
|
-
width: state.pageWidth,
|
|
2846
|
-
height: state.pageHeight,
|
|
2847
|
-
scale: state.scale,
|
|
2848
|
-
loading: React.createElement(React.Fragment, null)
|
|
2849
|
-
})))),
|
|
2850
|
-
state: state,
|
|
2851
|
-
manifest: manifest,
|
|
2852
|
-
navigator: {
|
|
2853
|
-
goForward: goForward,
|
|
2854
|
-
goBackward: goBackward,
|
|
2855
|
-
setColorMode: setColorMode,
|
|
2856
|
-
setScroll: setScroll,
|
|
2857
|
-
increaseFontSize: increaseFontSize,
|
|
2858
|
-
decreaseFontSize: decreaseFontSize,
|
|
2859
|
-
setFontFamily: setFontFamily,
|
|
2860
|
-
goToPage: goToPage
|
|
2861
|
-
}
|
|
2862
|
-
};
|
|
2863
|
-
}
|
|
2864
|
-
|
|
2865
|
-
var origin = window.location.origin;
|
|
2866
|
-
var injectables = [{
|
|
2867
|
-
type: 'style',
|
|
2868
|
-
url: origin + "/css/ReadiumCSS-before.css",
|
|
2869
|
-
r2before: true
|
|
2870
|
-
}, {
|
|
2871
|
-
type: 'style',
|
|
2872
|
-
url: origin + "/css/ReadiumCSS-default.css",
|
|
2873
|
-
r2default: true
|
|
2874
|
-
}, {
|
|
2875
|
-
type: 'style',
|
|
2876
|
-
url: origin + "/css/ReadiumCSS-after.css",
|
|
2877
|
-
r2after: true
|
|
2878
|
-
}, {
|
|
2879
|
-
type: 'style',
|
|
2880
|
-
url: origin + "/fonts/opendyslexic/opendyslexic.css",
|
|
2881
|
-
fontFamily: 'opendyslexic'
|
|
2882
|
-
}];
|
|
2883
|
-
|
|
2884
|
-
function htmlReducer(state, action) {
|
|
2885
|
-
switch (action.type) {
|
|
2886
|
-
case 'SET_READER':
|
|
2887
|
-
{
|
|
2888
|
-
var _r2FamilyToFamily$set;
|
|
2889
|
-
|
|
2890
|
-
// set all the initial settings taken from the reader
|
|
2891
|
-
var settings = action.reader.currentSettings;
|
|
2892
|
-
return {
|
|
2893
|
-
reader: action.reader,
|
|
2894
|
-
isScrolling: settings.verticalScroll,
|
|
2895
|
-
colorMode: getColorMode(settings.appearance),
|
|
2896
|
-
fontSize: settings.fontSize,
|
|
2897
|
-
fontFamily: (_r2FamilyToFamily$set = r2FamilyToFamily[settings.fontFamily]) != null ? _r2FamilyToFamily$set : 'publisher',
|
|
2898
|
-
currentTocUrl: action.reader.mostRecentNavigatedTocItem()
|
|
2899
|
-
};
|
|
2900
|
-
}
|
|
2901
|
-
|
|
2902
|
-
case 'SET_COLOR_MODE':
|
|
2903
|
-
return _extends({}, state, {
|
|
2904
|
-
colorMode: action.mode
|
|
2905
|
-
});
|
|
2906
|
-
|
|
2907
|
-
case 'SET_SCROLL':
|
|
2908
|
-
return _extends({}, state, {
|
|
2909
|
-
isScrolling: action.isScrolling
|
|
2910
|
-
});
|
|
2911
|
-
|
|
2912
|
-
case 'SET_FONT_SIZE':
|
|
2913
|
-
return _extends({}, state, {
|
|
2914
|
-
fontSize: action.size
|
|
2915
|
-
});
|
|
2916
|
-
|
|
2917
|
-
case 'SET_FONT_FAMILY':
|
|
2918
|
-
return _extends({}, state, {
|
|
2919
|
-
fontFamily: action.family
|
|
2920
|
-
});
|
|
2921
|
-
|
|
2922
|
-
case 'SET_CURRENT_TOC_URL':
|
|
2923
|
-
return _extends({}, state, {
|
|
2924
|
-
currentTocUrl: action.currentTocUrl
|
|
2925
|
-
});
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
|
-
var FONT_SIZE_STEP = 4;
|
|
2930
|
-
function useHtmlReader(args) {
|
|
2931
|
-
var _ref = args != null ? args : {},
|
|
2932
|
-
webpubManifestUrl = _ref.webpubManifestUrl,
|
|
2933
|
-
manifest = _ref.manifest,
|
|
2934
|
-
getContent = _ref.getContent;
|
|
2935
|
-
|
|
2936
|
-
var _React$useReducer = React__default.useReducer(htmlReducer, {
|
|
2937
|
-
colorMode: 'day',
|
|
2938
|
-
isScrolling: false,
|
|
2939
|
-
fontSize: 16,
|
|
2940
|
-
fontFamily: 'sans-serif',
|
|
2941
|
-
reader: undefined,
|
|
2942
|
-
currentTocUrl: null
|
|
2943
|
-
}),
|
|
2944
|
-
state = _React$useReducer[0],
|
|
2945
|
-
dispatch = _React$useReducer[1];
|
|
2946
|
-
|
|
2947
|
-
var reader = state.reader,
|
|
2948
|
-
fontSize = state.fontSize; // initialize the reader
|
|
2949
|
-
|
|
2950
|
-
React__default.useEffect(function () {
|
|
2951
|
-
// bail out if there is no webpubManifestUrl. It indicates this format is not being used.
|
|
2952
|
-
if (!webpubManifestUrl) return;
|
|
2953
|
-
var url = new URL(webpubManifestUrl);
|
|
2954
|
-
D2Reader.build({
|
|
2955
|
-
url: url,
|
|
2956
|
-
injectables: injectables,
|
|
2957
|
-
injectablesFixed: [],
|
|
2958
|
-
attributes: {
|
|
2959
|
-
navHeight: HEADER_HEIGHT,
|
|
2960
|
-
margin: 0
|
|
2961
|
-
},
|
|
2962
|
-
api: {
|
|
2963
|
-
getContent: getContent
|
|
2964
|
-
}
|
|
2965
|
-
}).then(function (reader) {
|
|
2966
|
-
dispatch({
|
|
2967
|
-
type: 'SET_READER',
|
|
2968
|
-
reader: reader
|
|
2969
|
-
});
|
|
2970
|
-
});
|
|
2971
|
-
}, [webpubManifestUrl, getContent]); // prev and next page functions
|
|
2972
|
-
|
|
2973
|
-
var goForward = React__default.useCallback(function () {
|
|
2974
|
-
if (!reader) return;
|
|
2975
|
-
var isLastPage = reader.atEnd();
|
|
2976
|
-
reader.nextPage();
|
|
2977
|
-
|
|
2978
|
-
if (isLastPage) {
|
|
2979
|
-
dispatch({
|
|
2980
|
-
type: 'SET_CURRENT_TOC_URL',
|
|
2981
|
-
currentTocUrl: reader.mostRecentNavigatedTocItem()
|
|
2982
|
-
});
|
|
2983
|
-
}
|
|
2984
|
-
}, [reader]);
|
|
2985
|
-
var goBackward = React__default.useCallback(function () {
|
|
2986
|
-
if (!reader) return;
|
|
2987
|
-
var isFirstPage = reader.atStart();
|
|
2988
|
-
reader.previousPage();
|
|
2989
|
-
|
|
2990
|
-
if (isFirstPage) {
|
|
2991
|
-
dispatch({
|
|
2992
|
-
type: 'SET_CURRENT_TOC_URL',
|
|
2993
|
-
currentTocUrl: reader.mostRecentNavigatedTocItem()
|
|
2994
|
-
});
|
|
2995
|
-
}
|
|
2996
|
-
}, [reader]);
|
|
2997
|
-
var setColorMode = React__default.useCallback( /*#__PURE__*/function () {
|
|
2998
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(mode) {
|
|
2999
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
3000
|
-
while (1) {
|
|
3001
|
-
switch (_context.prev = _context.next) {
|
|
3002
|
-
case 0:
|
|
3003
|
-
if (reader) {
|
|
3004
|
-
_context.next = 2;
|
|
3005
|
-
break;
|
|
3006
|
-
}
|
|
3007
|
-
|
|
3008
|
-
return _context.abrupt("return");
|
|
3009
|
-
|
|
3010
|
-
case 2:
|
|
3011
|
-
dispatch({
|
|
3012
|
-
type: 'SET_COLOR_MODE',
|
|
3013
|
-
mode: mode
|
|
3014
|
-
});
|
|
3015
|
-
_context.next = 5;
|
|
3016
|
-
return reader.applyUserSettings({
|
|
3017
|
-
appearance: mode
|
|
3018
|
-
});
|
|
3019
|
-
|
|
3020
|
-
case 5:
|
|
3021
|
-
case "end":
|
|
3022
|
-
return _context.stop();
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
}, _callee);
|
|
3026
|
-
}));
|
|
3027
|
-
|
|
3028
|
-
return function (_x) {
|
|
3029
|
-
return _ref2.apply(this, arguments);
|
|
3030
|
-
};
|
|
3031
|
-
}(), [reader]);
|
|
3032
|
-
var setScroll = React__default.useCallback( /*#__PURE__*/function () {
|
|
3033
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(val) {
|
|
3034
|
-
var isScrolling;
|
|
3035
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3036
|
-
while (1) {
|
|
3037
|
-
switch (_context2.prev = _context2.next) {
|
|
3038
|
-
case 0:
|
|
3039
|
-
isScrolling = val === 'scrolling';
|
|
3040
|
-
_context2.next = 3;
|
|
3041
|
-
return reader == null ? void 0 : reader.scroll(isScrolling);
|
|
3042
|
-
|
|
3043
|
-
case 3:
|
|
3044
|
-
dispatch({
|
|
3045
|
-
type: 'SET_SCROLL',
|
|
3046
|
-
isScrolling: isScrolling
|
|
3047
|
-
});
|
|
3048
|
-
|
|
3049
|
-
case 4:
|
|
3050
|
-
case "end":
|
|
3051
|
-
return _context2.stop();
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
}, _callee2);
|
|
3055
|
-
}));
|
|
3056
|
-
|
|
3057
|
-
return function (_x2) {
|
|
3058
|
-
return _ref3.apply(this, arguments);
|
|
3059
|
-
};
|
|
3060
|
-
}(), [reader]);
|
|
3061
|
-
var increaseFontSize = React__default.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
3062
|
-
var newSize;
|
|
3063
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
3064
|
-
while (1) {
|
|
3065
|
-
switch (_context3.prev = _context3.next) {
|
|
3066
|
-
case 0:
|
|
3067
|
-
if (reader) {
|
|
3068
|
-
_context3.next = 2;
|
|
3069
|
-
break;
|
|
3070
|
-
}
|
|
3071
|
-
|
|
3072
|
-
return _context3.abrupt("return");
|
|
3073
|
-
|
|
3074
|
-
case 2:
|
|
3075
|
-
newSize = fontSize + FONT_SIZE_STEP;
|
|
3076
|
-
_context3.next = 5;
|
|
3077
|
-
return reader.applyUserSettings({
|
|
3078
|
-
fontSize: newSize
|
|
3079
|
-
});
|
|
3080
|
-
|
|
3081
|
-
case 5:
|
|
3082
|
-
dispatch({
|
|
3083
|
-
type: 'SET_FONT_SIZE',
|
|
3084
|
-
size: newSize
|
|
3085
|
-
});
|
|
3086
|
-
|
|
3087
|
-
case 6:
|
|
3088
|
-
case "end":
|
|
3089
|
-
return _context3.stop();
|
|
3090
|
-
}
|
|
3091
|
-
}
|
|
3092
|
-
}, _callee3);
|
|
3093
|
-
})), [reader, fontSize]);
|
|
3094
|
-
var decreaseFontSize = React__default.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
3095
|
-
var newSize;
|
|
3096
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
3097
|
-
while (1) {
|
|
3098
|
-
switch (_context4.prev = _context4.next) {
|
|
3099
|
-
case 0:
|
|
3100
|
-
if (reader) {
|
|
3101
|
-
_context4.next = 2;
|
|
3102
|
-
break;
|
|
3103
|
-
}
|
|
3104
|
-
|
|
3105
|
-
return _context4.abrupt("return");
|
|
3106
|
-
|
|
3107
|
-
case 2:
|
|
3108
|
-
newSize = fontSize - FONT_SIZE_STEP;
|
|
3109
|
-
_context4.next = 5;
|
|
3110
|
-
return reader.applyUserSettings({
|
|
3111
|
-
fontSize: newSize
|
|
3112
|
-
});
|
|
3113
|
-
|
|
3114
|
-
case 5:
|
|
3115
|
-
dispatch({
|
|
3116
|
-
type: 'SET_FONT_SIZE',
|
|
3117
|
-
size: newSize
|
|
3118
|
-
});
|
|
3119
|
-
|
|
3120
|
-
case 6:
|
|
3121
|
-
case "end":
|
|
3122
|
-
return _context4.stop();
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
}, _callee4);
|
|
3126
|
-
})), [reader, fontSize]);
|
|
3127
|
-
var setFontFamily = React__default.useCallback( /*#__PURE__*/function () {
|
|
3128
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(family) {
|
|
3129
|
-
var r2Family;
|
|
3130
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
3131
|
-
while (1) {
|
|
3132
|
-
switch (_context5.prev = _context5.next) {
|
|
3133
|
-
case 0:
|
|
3134
|
-
if (reader) {
|
|
3135
|
-
_context5.next = 2;
|
|
3136
|
-
break;
|
|
3137
|
-
}
|
|
3138
|
-
|
|
3139
|
-
return _context5.abrupt("return");
|
|
3140
|
-
|
|
3141
|
-
case 2:
|
|
3142
|
-
r2Family = familyToR2Family[family]; // the applyUserSettings type is incorrect. We are supposed to pass in a string.
|
|
3143
|
-
|
|
3144
|
-
_context5.next = 5;
|
|
3145
|
-
return reader.applyUserSettings({
|
|
3146
|
-
fontFamily: r2Family
|
|
3147
|
-
});
|
|
3148
|
-
|
|
3149
|
-
case 5:
|
|
3150
|
-
dispatch({
|
|
3151
|
-
type: 'SET_FONT_FAMILY',
|
|
3152
|
-
family: family
|
|
3153
|
-
});
|
|
3154
|
-
|
|
3155
|
-
case 6:
|
|
3156
|
-
case "end":
|
|
3157
|
-
return _context5.stop();
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
}, _callee5);
|
|
3161
|
-
}));
|
|
3162
|
-
|
|
3163
|
-
return function (_x3) {
|
|
3164
|
-
return _ref6.apply(this, arguments);
|
|
3165
|
-
};
|
|
3166
|
-
}(), [reader]);
|
|
3167
|
-
var goToPage = React__default.useCallback(function (href) {
|
|
3168
|
-
if (!reader) return; // Adding try/catch here because goTo throws a TypeError
|
|
3169
|
-
// if the TOC link you clicked on was the current page..
|
|
3170
|
-
|
|
3171
|
-
try {
|
|
3172
|
-
reader.goTo({
|
|
3173
|
-
href: href
|
|
3174
|
-
}); // This needs to be fixed, locations should be optional.
|
|
3175
|
-
|
|
3176
|
-
dispatch({
|
|
3177
|
-
type: 'SET_CURRENT_TOC_URL',
|
|
3178
|
-
currentTocUrl: href
|
|
3179
|
-
});
|
|
3180
|
-
} catch (error) {
|
|
3181
|
-
console.error(error);
|
|
3182
|
-
}
|
|
3183
|
-
}, [reader]);
|
|
3184
|
-
var isLoading = !reader; // this format is inactive, return null
|
|
3185
|
-
|
|
3186
|
-
if (!webpubManifestUrl || !manifest) return null; // we are initializing the reader
|
|
3187
|
-
|
|
3188
|
-
if (isLoading) {
|
|
3189
|
-
return {
|
|
3190
|
-
type: null,
|
|
3191
|
-
isLoading: true,
|
|
3192
|
-
content: React__default.createElement(HtmlReaderContent, null),
|
|
3193
|
-
navigator: null,
|
|
3194
|
-
manifest: null,
|
|
3195
|
-
state: null
|
|
3196
|
-
};
|
|
3197
|
-
} // the reader is active
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
return {
|
|
3201
|
-
type: 'HTML',
|
|
3202
|
-
isLoading: false,
|
|
3203
|
-
content: React__default.createElement(HtmlReaderContent, null),
|
|
3204
|
-
state: state,
|
|
3205
|
-
manifest: manifest,
|
|
3206
|
-
navigator: {
|
|
3207
|
-
goForward: goForward,
|
|
3208
|
-
goBackward: goBackward,
|
|
3209
|
-
setColorMode: setColorMode,
|
|
3210
|
-
setScroll: setScroll,
|
|
3211
|
-
increaseFontSize: increaseFontSize,
|
|
3212
|
-
decreaseFontSize: decreaseFontSize,
|
|
3213
|
-
setFontFamily: setFontFamily,
|
|
3214
|
-
goToPage: goToPage
|
|
3215
|
-
}
|
|
3216
|
-
};
|
|
3217
|
-
}
|
|
3218
|
-
|
|
3219
|
-
function getColorMode(d2Mode) {
|
|
3220
|
-
switch (d2Mode) {
|
|
3221
|
-
case 'readium-default-on':
|
|
3222
|
-
return 'day';
|
|
3223
|
-
|
|
3224
|
-
case 'readium-night-on':
|
|
3225
|
-
return 'night';
|
|
3226
|
-
|
|
3227
|
-
case 'readium-sepia-on':
|
|
3228
|
-
return 'sepia';
|
|
3229
|
-
|
|
3230
|
-
default:
|
|
3231
|
-
console.error('COLOR MODE SLIPPED THROUG', d2Mode);
|
|
3232
|
-
return 'day';
|
|
3233
|
-
}
|
|
3234
|
-
}
|
|
3235
|
-
/**
|
|
3236
|
-
* We need to map from our family values to R2D2BC's family values.
|
|
3237
|
-
*/
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
var familyToR2Family = {
|
|
3241
|
-
publisher: 'Original',
|
|
3242
|
-
serif: 'serif',
|
|
3243
|
-
'sans-serif': 'sans-serif',
|
|
3244
|
-
'open-dyslexic': 'opendyslexic'
|
|
3245
|
-
};
|
|
3246
|
-
/**
|
|
3247
|
-
* And vice-versa
|
|
3248
|
-
*/
|
|
3249
|
-
|
|
3250
|
-
var r2FamilyToFamily = {
|
|
3251
|
-
Original: 'publisher',
|
|
3252
|
-
serif: 'serif',
|
|
3253
|
-
'sans-serif': 'sans-serif',
|
|
3254
|
-
opendyslexic: 'open-dyslexic'
|
|
3255
|
-
};
|
|
3256
|
-
|
|
3257
|
-
// a webpub pdf collection
|
|
3258
|
-
var WebpubPdfConformsTo = 'https://librarysimplified.org/terms/profiles/pdf'; // a webpub of axisnow content
|
|
3259
|
-
|
|
3260
|
-
var AxisNowEpubConformsTo = 'stub/webpub+axisnow';
|
|
3261
|
-
|
|
3262
|
-
function getReaderType(conformsTo) {
|
|
3263
|
-
switch (conformsTo) {
|
|
3264
|
-
case AxisNowEpubConformsTo:
|
|
3265
|
-
return 'HTML';
|
|
3266
|
-
|
|
3267
|
-
case WebpubPdfConformsTo:
|
|
3268
|
-
return 'PDF';
|
|
3269
|
-
|
|
3270
|
-
case undefined:
|
|
3271
|
-
// the manifest didn't indicate any conformsTo,
|
|
3272
|
-
// so return our default
|
|
3273
|
-
return 'HTML';
|
|
3274
|
-
|
|
3275
|
-
case null:
|
|
3276
|
-
// the manifest is still loading, return undefined
|
|
3277
|
-
return undefined;
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
/**
|
|
3281
|
-
* The React hook that exposes the main API into the reader. It
|
|
3282
|
-
* will determine the type of the webpub, and then use the correct reader
|
|
3283
|
-
* for that type.
|
|
3284
|
-
*/
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
function useWebReader(args) {
|
|
3288
|
-
var webpubManifestUrl = args.webpubManifestUrl,
|
|
3289
|
-
getContent = args.getContent,
|
|
3290
|
-
proxyUrl = args.proxyUrl;
|
|
3291
|
-
|
|
3292
|
-
var _React$useState = React__default.useState(null),
|
|
3293
|
-
manifest = _React$useState[0],
|
|
3294
|
-
setManifest = _React$useState[1];
|
|
3295
|
-
|
|
3296
|
-
var readerType = getReaderType(manifest ? manifest.metadata.conformsTo : null);
|
|
3297
|
-
/**
|
|
3298
|
-
* Our HTML reader and PDf Reader. Note that we cannot conditionally
|
|
3299
|
-
* call a React hook, so we must _always_ call the hook, but allow for the
|
|
3300
|
-
* case where we call the hook with `undefined`, which tells the hook that
|
|
3301
|
-
* that format is inactive, and it will in turn return the InactiveState.
|
|
3302
|
-
*/
|
|
3303
|
-
|
|
3304
|
-
var htmlReader = useHtmlReader(readerType === 'HTML' && manifest ? {
|
|
3305
|
-
webpubManifestUrl: webpubManifestUrl,
|
|
3306
|
-
manifest: manifest,
|
|
3307
|
-
getContent: getContent
|
|
3308
|
-
} : undefined);
|
|
3309
|
-
var pdfReader = usePdfReader(readerType === 'PDF' && manifest ? {
|
|
3310
|
-
webpubManifestUrl: webpubManifestUrl,
|
|
3311
|
-
manifest: manifest,
|
|
3312
|
-
proxyUrl: proxyUrl
|
|
3313
|
-
} : undefined); // fetch the manifest and set it in state
|
|
3314
|
-
|
|
3315
|
-
React__default.useEffect(function () {
|
|
3316
|
-
fetchJson(webpubManifestUrl).then(setManifest);
|
|
3317
|
-
}, [webpubManifestUrl]); // first if we are still fetching the manifest, return loading
|
|
3318
|
-
|
|
3319
|
-
if (manifest === null) {
|
|
3320
|
-
return {
|
|
3321
|
-
isLoading: true,
|
|
3322
|
-
content: React__default.createElement(HtmlReaderContent, null),
|
|
3323
|
-
manifest: null,
|
|
3324
|
-
navigator: null,
|
|
3325
|
-
state: null,
|
|
3326
|
-
type: null
|
|
3327
|
-
};
|
|
3328
|
-
}
|
|
3329
|
-
/**
|
|
3330
|
-
* Return whichever reader is not Inactive (not `null`)
|
|
3331
|
-
*/
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
if (htmlReader) {
|
|
3335
|
-
return htmlReader;
|
|
3336
|
-
}
|
|
3337
|
-
|
|
3338
|
-
if (pdfReader) {
|
|
3339
|
-
return pdfReader;
|
|
3340
|
-
}
|
|
3341
|
-
|
|
3342
|
-
throw new Error("No reader was initialized for the webpub with url: " + webpubManifestUrl + " and type: " + readerType + ".");
|
|
3343
|
-
}
|
|
3344
|
-
|
|
3345
|
-
/**
|
|
3346
|
-
* The main React component export.
|
|
3347
|
-
*/
|
|
3348
|
-
|
|
3349
|
-
var WebReader = function WebReader(_ref) {
|
|
3350
|
-
var webpubManifestUrl = _ref.webpubManifestUrl,
|
|
3351
|
-
proxyUrl = _ref.proxyUrl,
|
|
3352
|
-
getContent = _ref.getContent;
|
|
3353
|
-
var webReader = useWebReader({
|
|
3354
|
-
webpubManifestUrl: webpubManifestUrl,
|
|
3355
|
-
proxyUrl: proxyUrl,
|
|
3356
|
-
getContent: getContent
|
|
3357
|
-
});
|
|
3358
|
-
var content = webReader.content;
|
|
3359
|
-
return React__default.createElement(ManagerUI, Object.assign({}, webReader), content);
|
|
3360
|
-
};
|
|
3361
|
-
|
|
3362
|
-
exports.default = WebReader;
|
|
3363
|
-
//# sourceMappingURL=web-reader.cjs.development.js.map
|