aksos-react-native-epub-reader 0.1.0 → 0.2.1
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/CHANGELOG.md +60 -0
- package/README.md +178 -20
- package/lib/EpubReader.d.ts +66 -15
- package/lib/EpubReader.js +168 -30
- package/lib/EpubReaderView.d.ts +37 -5
- package/lib/EpubReaderView.js +194 -93
- package/lib/cfiOrder.d.ts +2 -0
- package/lib/cfiOrder.js +34 -0
- package/lib/engine/html.js +1 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.js +5 -1
- package/lib/strings.d.ts +94 -0
- package/lib/strings.js +96 -0
- package/lib/themes.d.ts +28 -6
- package/lib/themes.js +80 -20
- package/lib/types.d.ts +82 -1
- package/lib/ui/AppearanceSheet.d.ts +4 -2
- package/lib/ui/AppearanceSheet.js +40 -26
- package/lib/ui/ContentsSheet.d.ts +2 -0
- package/lib/ui/ContentsSheet.js +32 -22
- package/lib/ui/CustomizeSheet.d.ts +4 -2
- package/lib/ui/CustomizeSheet.js +31 -27
- package/lib/ui/HighlightMenu.d.ts +4 -2
- package/lib/ui/HighlightMenu.js +13 -11
- package/lib/ui/NoteEditor.js +12 -9
- package/lib/ui/SearchSheet.js +19 -6
- package/lib/ui/Sheet.js +7 -4
- package/lib/ui/Text.d.ts +9 -0
- package/lib/ui/Text.js +62 -0
- package/package.json +81 -76
- package/src/EpubReader.tsx +239 -43
- package/src/EpubReaderView.tsx +287 -99
- package/src/cfiOrder.ts +28 -0
- package/src/engine/epubcfi.js +527 -0
- package/src/engine/html.ts +1 -1
- package/src/engine/reader.js +1273 -157
- package/src/index.ts +5 -2
- package/src/strings.ts +187 -0
- package/src/themes.ts +97 -21
- package/src/types.ts +88 -2
- package/src/ui/AppearanceSheet.tsx +47 -29
- package/src/ui/ContentsSheet.tsx +34 -22
- package/src/ui/CustomizeSheet.tsx +27 -21
- package/src/ui/HighlightMenu.tsx +17 -13
- package/src/ui/NoteEditor.tsx +12 -9
- package/src/ui/SearchSheet.tsx +22 -5
- package/src/ui/Sheet.tsx +8 -5
- package/src/ui/Text.tsx +27 -0
package/lib/EpubReaderView.js
CHANGED
|
@@ -36,12 +36,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.EpubReaderView = EpubReaderView;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
|
+
const Text_1 = require("./ui/Text");
|
|
39
40
|
const EpubReader_1 = require("./EpubReader");
|
|
40
41
|
const themes_1 = require("./themes");
|
|
41
42
|
const AppearanceSheet_1 = require("./ui/AppearanceSheet");
|
|
42
43
|
const ContentsSheet_1 = require("./ui/ContentsSheet");
|
|
43
44
|
const CustomizeSheet_1 = require("./ui/CustomizeSheet");
|
|
44
45
|
const sound_1 = require("./sound");
|
|
46
|
+
const strings_1 = require("./strings");
|
|
45
47
|
const Glass_1 = require("./ui/Glass");
|
|
46
48
|
const HighlightMenu_1 = require("./ui/HighlightMenu");
|
|
47
49
|
const Icons_1 = require("./ui/Icons");
|
|
@@ -68,21 +70,46 @@ try {
|
|
|
68
70
|
catch {
|
|
69
71
|
ScreenOrientation = null;
|
|
70
72
|
}
|
|
71
|
-
const
|
|
72
|
-
{ id: 'high', label: '
|
|
73
|
-
{ id: 'medium', label: '
|
|
74
|
-
{ id: 'low', label: '
|
|
75
|
-
{ id: 'none', label: '
|
|
73
|
+
const DIM_IDS = [
|
|
74
|
+
{ id: 'high', label: 'dimHigh' },
|
|
75
|
+
{ id: 'medium', label: 'dimMedium' },
|
|
76
|
+
{ id: 'low', label: 'dimLow' },
|
|
77
|
+
{ id: 'none', label: 'dimNone' }
|
|
76
78
|
];
|
|
77
79
|
const SAMPLE = 'The reader turned the page slowly, listening to the wind move across the empty hills.';
|
|
78
80
|
const uid = () => Date.now().toString(36) + Math.random().toString(36).slice(2, 7);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
// Used when the host passes no safeInsets. A guess from the screen size; the exact values come from react-native-safe-area-context.
|
|
82
|
+
function defaultInsets(width, height) {
|
|
83
|
+
if (react_native_1.Platform.OS !== 'ios')
|
|
84
|
+
return { top: react_native_1.StatusBar.currentHeight || 24, bottom: 0 };
|
|
85
|
+
const long = Math.max(width, height);
|
|
86
|
+
const landscape = width > height;
|
|
87
|
+
const notch = long >= 812; // iPhone X and later (iPads are larger but have no notch: they are caught by the short side)
|
|
88
|
+
const phone = Math.min(width, height) < 600;
|
|
89
|
+
if (!phone)
|
|
90
|
+
return { top: 24, bottom: 20 };
|
|
91
|
+
if (!notch)
|
|
92
|
+
return { top: 20, bottom: 0 };
|
|
93
|
+
const top = long >= 852 ? 59 : 47;
|
|
94
|
+
return landscape ? { top: 0, bottom: 21, left: top, right: top } : { top, bottom: 34 };
|
|
81
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Full reader screen. A different `source` (or Try again after an error) starts a fresh screen, so highlights,
|
|
98
|
+
* bookmarks and position of one book can never leak into another.
|
|
99
|
+
*/
|
|
82
100
|
function EpubReaderView(props) {
|
|
83
|
-
const
|
|
101
|
+
const [attempt, setAttempt] = (0, react_1.useState)(0);
|
|
102
|
+
const labels = (0, react_1.useMemo)(() => (0, strings_1.mergeLabels)(props.labels), [props.labels]);
|
|
103
|
+
return (react_1.default.createElement(strings_1.LabelsProvider, { value: labels },
|
|
104
|
+
react_1.default.createElement(Text_1.UiFontsContext.Provider, { value: props.uiFonts || null },
|
|
105
|
+
react_1.default.createElement(ReaderScreen, { key: `${(0, EpubReader_1.sourceKeyOf)(props.source)}#${attempt}`, ...props, onRetry: () => setAttempt((a) => a + 1) }))));
|
|
106
|
+
}
|
|
107
|
+
function ReaderScreen(props) {
|
|
108
|
+
const L = (0, strings_1.useLabels)();
|
|
84
109
|
const screen = (0, react_native_1.useWindowDimensions)();
|
|
85
|
-
const
|
|
110
|
+
const safe = props.safeInsets || defaultInsets(screen.width, screen.height);
|
|
111
|
+
const phoneScheme = (0, react_native_1.useColorScheme)();
|
|
112
|
+
const systemDark = (props.colorScheme || phoneScheme) === 'dark';
|
|
86
113
|
const reader = (0, react_1.useRef)(null);
|
|
87
114
|
const [settings, setSettings] = (0, react_1.useState)({ ...themes_1.DEFAULT_SETTINGS, ...props.initialSettings });
|
|
88
115
|
const [highlights, setHighlights] = (0, react_1.useState)(props.initialHighlights || []);
|
|
@@ -109,12 +136,33 @@ function EpubReaderView(props) {
|
|
|
109
136
|
const [results, setResults] = (0, react_1.useState)([]);
|
|
110
137
|
const [searching, setSearching] = (0, react_1.useState)(false);
|
|
111
138
|
const [error, setError] = (0, react_1.useState)(null);
|
|
139
|
+
// the book could not be opened (or the reader engine stopped): a full screen with a way out
|
|
140
|
+
const [fatal, setFatal] = (0, react_1.useState)(null);
|
|
141
|
+
const [loaded, setLoaded] = (0, react_1.useState)(false);
|
|
142
|
+
const [reduceMotion, setReduceMotion] = (0, react_1.useState)(false);
|
|
112
143
|
const searchId = (0, react_1.useRef)(0);
|
|
144
|
+
const latestProps = (0, react_1.useRef)(props);
|
|
145
|
+
latestProps.current = props;
|
|
146
|
+
const settingsRef = (0, react_1.useRef)(settings);
|
|
147
|
+
const highlightsRef = (0, react_1.useRef)(highlights);
|
|
148
|
+
const bookmarksRef = (0, react_1.useRef)(bookmarks);
|
|
149
|
+
const lockedByUs = (0, react_1.useRef)(false);
|
|
113
150
|
const seen = (0, react_1.useRef)({});
|
|
114
151
|
const layoutKey = (0, react_1.useRef)('');
|
|
152
|
+
(0, react_1.useEffect)(() => {
|
|
153
|
+
let on = true;
|
|
154
|
+
react_native_1.AccessibilityInfo.isReduceMotionEnabled?.().then((v) => on && setReduceMotion(!!v)).catch(() => undefined);
|
|
155
|
+
const sub = react_native_1.AccessibilityInfo.addEventListener?.('reduceMotionChanged', (v) => setReduceMotion(!!v));
|
|
156
|
+
return () => {
|
|
157
|
+
on = false;
|
|
158
|
+
sub?.remove?.();
|
|
159
|
+
};
|
|
160
|
+
}, []);
|
|
161
|
+
// people who asked for less motion get the fade instead of the curl or slide
|
|
162
|
+
const readerSettings = (0, react_1.useMemo)(() => (reduceMotion && (settings.pageTurn === 'curl' || settings.pageTurn === 'slide') ? { ...settings, pageTurn: 'fade' } : settings), [settings, reduceMotion]);
|
|
115
163
|
const dark = (0, themes_1.isDark)(settings, systemDark);
|
|
116
|
-
const page = (0, themes_1.themeColors)(settings, systemDark);
|
|
117
|
-
const colors = (0, react_1.useMemo)(() => (0, themes_1.chromeColors)(page, dark), [page, dark]);
|
|
164
|
+
const page = (0, themes_1.themeColors)(settings, systemDark, props.themes);
|
|
165
|
+
const colors = (0, react_1.useMemo)(() => (0, themes_1.chromeColors)(page, dark, props.chrome), [page, dark, props.chrome]);
|
|
118
166
|
// ----- chrome visibility animation
|
|
119
167
|
const fade = (0, react_1.useRef)(new react_native_1.Animated.Value(1)).current;
|
|
120
168
|
(0, react_1.useEffect)(() => {
|
|
@@ -130,29 +178,26 @@ function EpubReaderView(props) {
|
|
|
130
178
|
setMenuOpen(false);
|
|
131
179
|
}, [chrome]);
|
|
132
180
|
// ----- persistence helpers
|
|
181
|
+
// The next list is computed from a ref and the host is told outside of any state updater, so a callback
|
|
182
|
+
// never runs during render (StrictMode runs updaters twice) and quick successive edits never lose each other.
|
|
133
183
|
const updateHighlights = (0, react_1.useCallback)((fn) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
-
[props.onHighlightsChange]);
|
|
184
|
+
const next = fn(highlightsRef.current);
|
|
185
|
+
highlightsRef.current = next;
|
|
186
|
+
setHighlights(next);
|
|
187
|
+
latestProps.current.onHighlightsChange?.(next);
|
|
188
|
+
}, []);
|
|
142
189
|
const updateBookmarks = (0, react_1.useCallback)((fn) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const changeSettings = (patch) => {
|
|
152
|
-
const next = { ...settings, ...patch };
|
|
190
|
+
const next = fn(bookmarksRef.current);
|
|
191
|
+
bookmarksRef.current = next;
|
|
192
|
+
setBookmarks(next);
|
|
193
|
+
latestProps.current.onBookmarksChange?.(next);
|
|
194
|
+
}, []);
|
|
195
|
+
const changeSettings = (0, react_1.useCallback)((patch) => {
|
|
196
|
+
const next = { ...settingsRef.current, ...patch };
|
|
197
|
+
settingsRef.current = next;
|
|
153
198
|
setSettings(next);
|
|
154
|
-
|
|
155
|
-
};
|
|
199
|
+
latestProps.current.onSettingsChange?.(next);
|
|
200
|
+
}, []);
|
|
156
201
|
// ----- book page numbers (estimated from characters per page)
|
|
157
202
|
const onRelocate = (e) => {
|
|
158
203
|
const key = [settings.fontSize, settings.fontId, settings.lineHeight, settings.letterSpacing, settings.wordSpacing, settings.margins, settings.customize, settings.columns, settings.bold, settings.pageTurn === 'scroll'].join('|');
|
|
@@ -170,6 +215,7 @@ function EpubReaderView(props) {
|
|
|
170
215
|
const next = pc > 0 && len > 0 ? len / pc : 1200;
|
|
171
216
|
setCpp((old) => (Math.abs(old - next) / next > 0.01 ? next : old));
|
|
172
217
|
setLoc(e);
|
|
218
|
+
setLoaded(true);
|
|
173
219
|
setActive(null);
|
|
174
220
|
props.onLocationChange?.(e);
|
|
175
221
|
};
|
|
@@ -186,10 +232,10 @@ function EpubReaderView(props) {
|
|
|
186
232
|
(0, react_1.useEffect)(() => {
|
|
187
233
|
if (!loc)
|
|
188
234
|
return;
|
|
189
|
-
const header = chrome ? (pagesLeft === 0 ?
|
|
190
|
-
const footer = chrome ?
|
|
235
|
+
const header = chrome ? (pagesLeft === 0 ? L.lastPageInChapter : L.pagesLeft(pagesLeft)) : loc.chapter;
|
|
236
|
+
const footer = chrome ? L.pageOfTotal(curPage, totalPages) : L.formatNumber(curPage);
|
|
191
237
|
reader.current?.setLabels(header, footer);
|
|
192
|
-
}, [chrome, loc, curPage, totalPages, pagesLeft]);
|
|
238
|
+
}, [chrome, loc, curPage, totalPages, pagesLeft, L]);
|
|
193
239
|
// ----- bookmarks
|
|
194
240
|
const bookmarkHere = (0, react_1.useMemo)(() => (loc ? bookmarks.filter((b) => b.spine === loc.spine && b.offset >= loc.offset && b.offset < Math.max(loc.end, loc.offset + 1)) : []), [bookmarks, loc]);
|
|
195
241
|
const toggleBookmark = () => {
|
|
@@ -202,7 +248,7 @@ function EpubReaderView(props) {
|
|
|
202
248
|
else {
|
|
203
249
|
updateBookmarks((prev) => [
|
|
204
250
|
...prev,
|
|
205
|
-
{ id: uid(), spine: loc.spine, offset: loc.offset, chapter: loc.chapter, excerpt: loc.excerpt, progress: loc.progress, createdAt: Date.now() }
|
|
251
|
+
{ id: uid(), spine: loc.spine, offset: loc.offset, cfi: loc.startCfi, chapter: loc.chapter, excerpt: loc.excerpt, progress: loc.progress, createdAt: Date.now() }
|
|
206
252
|
]);
|
|
207
253
|
}
|
|
208
254
|
};
|
|
@@ -215,7 +261,8 @@ function EpubReaderView(props) {
|
|
|
215
261
|
start: sel.start,
|
|
216
262
|
end: sel.end,
|
|
217
263
|
text: sel.text.replace(/\s+/g, ' ').trim(),
|
|
218
|
-
color: 'yellow',
|
|
264
|
+
color: props.highlightColors ? Object.keys(props.highlightColors)[0] || 'yellow' : 'yellow',
|
|
265
|
+
cfi: sel.cfi,
|
|
219
266
|
chapter: loc?.chapter,
|
|
220
267
|
createdAt: Date.now()
|
|
221
268
|
};
|
|
@@ -260,12 +307,13 @@ function EpubReaderView(props) {
|
|
|
260
307
|
};
|
|
261
308
|
const toggleRotationLock = async () => {
|
|
262
309
|
if (!ScreenOrientation) {
|
|
263
|
-
react_native_1.Alert.alert(
|
|
310
|
+
react_native_1.Alert.alert(L.rotationLock, L.rotationLockNeedsPackage);
|
|
264
311
|
return;
|
|
265
312
|
}
|
|
266
313
|
try {
|
|
267
314
|
if (rotLocked) {
|
|
268
315
|
await ScreenOrientation.unlockAsync();
|
|
316
|
+
lockedByUs.current = false;
|
|
269
317
|
setRotLocked(false);
|
|
270
318
|
}
|
|
271
319
|
else {
|
|
@@ -273,6 +321,7 @@ function EpubReaderView(props) {
|
|
|
273
321
|
const O = ScreenOrientation.Orientation;
|
|
274
322
|
const L = ScreenOrientation.OrientationLock;
|
|
275
323
|
await ScreenOrientation.lockAsync(o === O.LANDSCAPE_LEFT ? L.LANDSCAPE_LEFT : o === O.LANDSCAPE_RIGHT ? L.LANDSCAPE_RIGHT : L.PORTRAIT_UP);
|
|
324
|
+
lockedByUs.current = true;
|
|
276
325
|
setRotLocked(true);
|
|
277
326
|
}
|
|
278
327
|
}
|
|
@@ -281,7 +330,8 @@ function EpubReaderView(props) {
|
|
|
281
330
|
}
|
|
282
331
|
};
|
|
283
332
|
(0, react_1.useEffect)(() => () => {
|
|
284
|
-
|
|
333
|
+
// only release a lock this reader set: the host app may have its own orientation policy
|
|
334
|
+
if (ScreenOrientation && lockedByUs.current)
|
|
285
335
|
ScreenOrientation.unlockAsync().catch(() => undefined);
|
|
286
336
|
}, []);
|
|
287
337
|
const onLineGuideButton = () => {
|
|
@@ -293,14 +343,24 @@ function EpubReaderView(props) {
|
|
|
293
343
|
else
|
|
294
344
|
setLineMenu(true);
|
|
295
345
|
};
|
|
346
|
+
const openLink = (href) => {
|
|
347
|
+
if (!/^(https?|mailto):/i.test(href))
|
|
348
|
+
return;
|
|
349
|
+
react_native_1.Alert.alert(L.openLink, href, [
|
|
350
|
+
{ text: L.cancel, style: 'cancel' },
|
|
351
|
+
{ text: L.open, onPress: () => react_native_1.Linking.openURL(href).catch(() => undefined) }
|
|
352
|
+
]);
|
|
353
|
+
};
|
|
296
354
|
const share = () => {
|
|
297
355
|
const text = [loc?.excerpt, meta?.title && `— ${meta.title}`].filter(Boolean).join(' ');
|
|
298
356
|
react_native_1.Share.share({ message: text || meta?.title || '' }).catch(() => undefined);
|
|
299
357
|
};
|
|
300
358
|
const progressFill = Math.max(0, Math.min(1, loc?.progress ?? 0));
|
|
301
359
|
const tx = colors.text;
|
|
360
|
+
// text on the progress fill: the host's onStrong, else the default for that fill
|
|
361
|
+
const onFill = colors.onStrong || (colors.strong ? '#ffffff' : dark ? tx : '#ffffff');
|
|
302
362
|
return (react_1.default.createElement(react_native_1.View, { style: [styles.root, { backgroundColor: page.bg }] },
|
|
303
|
-
react_1.default.createElement(EpubReader_1.EpubReader, { ref: reader, source: props.source, settings:
|
|
363
|
+
react_1.default.createElement(EpubReader_1.EpubReader, { ref: reader, source: props.source, settings: readerSettings, systemDark: systemDark, safeInsets: safe, initialLocation: props.initialLocation, highlights: highlights, maxFileSize: props.maxFileSize, highlightColors: props.highlightColors, highlightOpacity: props.highlightOpacity, fonts: props.fonts, bookColors: props.bookColors, themes: props.themes, maxZoom: props.maxZoom, locationChars: props.locationChars, repairZeroWidth: props.repairZeroWidth, onLocations: props.onLocations, onReady: ({ metadata, rtl: isRtl }) => {
|
|
304
364
|
setMeta(metadata);
|
|
305
365
|
setRtl(isRtl);
|
|
306
366
|
props.onMetadata?.(metadata);
|
|
@@ -320,135 +380,167 @@ function EpubReaderView(props) {
|
|
|
320
380
|
setChrome(false);
|
|
321
381
|
setActive(null);
|
|
322
382
|
}
|
|
323
|
-
}, onLink: (
|
|
383
|
+
}, onLink: openLink, onLinkJump: (from) => setReturnTo({ spine: from.spine, offset: from.offset, page: pageOf(from.spine, from.offset) }), onDirectionChange: setRtl, onSearchResults: (id, found, done) => {
|
|
324
384
|
if (id !== searchId.current)
|
|
325
385
|
return;
|
|
326
386
|
setResults((prev) => prev.concat(found));
|
|
327
387
|
if (done)
|
|
328
388
|
setSearching(false);
|
|
329
|
-
}, onError: (m) => {
|
|
330
|
-
|
|
389
|
+
}, onError: (m, info) => {
|
|
390
|
+
if (info.fatal || !loaded)
|
|
391
|
+
setFatal(m);
|
|
392
|
+
else
|
|
393
|
+
setError(m);
|
|
331
394
|
props.onError?.(m);
|
|
332
395
|
} }),
|
|
396
|
+
!chrome && (react_1.default.createElement(react_native_1.View, { pointerEvents: "none", accessible: true, accessibilityRole: "button", accessibilityLabel: L.readerMenu, accessibilityActions: [
|
|
397
|
+
{ name: 'activate', label: L.readerMenu },
|
|
398
|
+
{ name: 'increment', label: 'Next page' },
|
|
399
|
+
{ name: 'decrement', label: 'Previous page' }
|
|
400
|
+
], onAccessibilityAction: (e) => {
|
|
401
|
+
const a = e.nativeEvent.actionName;
|
|
402
|
+
if (a === 'increment')
|
|
403
|
+
reader.current?.next();
|
|
404
|
+
else if (a === 'decrement')
|
|
405
|
+
reader.current?.prev();
|
|
406
|
+
else
|
|
407
|
+
setChrome(true);
|
|
408
|
+
}, style: [styles.a11yHandle, { bottom: safe.bottom, left: safe.left || 0 }] })),
|
|
333
409
|
react_1.default.createElement(react_native_1.View, { pointerEvents: "none", style: [react_native_1.StyleSheet.absoluteFill, { backgroundColor: '#000000', opacity: (1 - settings.brightness) * 0.75 }] }),
|
|
334
410
|
lineGuide && (react_1.default.createElement(LineGuide_1.LineGuide, { bg: page.bg, dark: dark, dim: dimLevel, lineHeight: settings.fontSize * (settings.customize ? settings.lineHeight : 1.5), minY: safe.top + 30, maxY: screen.height - safe.bottom - 30 })),
|
|
335
411
|
bookmarkHere.length > 0 && (react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: "none", style: [styles.ribbon, { right: 22, opacity: fadeOut }] },
|
|
336
412
|
react_1.default.createElement(react_native_1.View, { style: styles.ribbonBody }),
|
|
337
413
|
react_1.default.createElement(react_native_1.View, { style: styles.ribbonNotch }))),
|
|
338
|
-
react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome ? 'auto' : 'none', style: [styles.closeWrap, { top: safe.top + 2, opacity: fade }] },
|
|
339
|
-
react_1.default.createElement(react_native_1.Pressable, { onPress: props.onClose, hitSlop: 10, accessibilityRole: "button", accessibilityLabel:
|
|
414
|
+
react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome ? 'auto' : 'none', ...hiddenA11y(!chrome), style: [styles.closeWrap, { top: safe.top + 2, right: 16 + (safe.right || 0), opacity: fade }] },
|
|
415
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: props.onClose, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: L.closeBook },
|
|
340
416
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.circle },
|
|
341
417
|
react_1.default.createElement(Icons_1.Icon, { name: "close", color: tx, size: 22 })))),
|
|
342
|
-
returnTo && (react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome ? 'auto' : 'none', style: [styles.returnWrap, { top: safe.top + 2, opacity: fade }] },
|
|
418
|
+
returnTo && (react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome ? 'auto' : 'none', ...hiddenA11y(!chrome), style: [styles.returnWrap, { top: safe.top + 2, left: 16 + (safe.left || 0), opacity: fade }] },
|
|
343
419
|
react_1.default.createElement(react_native_1.Pressable, { onPress: () => {
|
|
344
420
|
reader.current?.goTo({ spine: returnTo.spine, offset: returnTo.offset });
|
|
345
421
|
setReturnTo(null);
|
|
346
|
-
}, hitSlop: 8, accessibilityRole: "button", accessibilityLabel:
|
|
422
|
+
}, hitSlop: 8, accessibilityRole: "button", accessibilityLabel: L.returnToPage(returnTo.page) },
|
|
347
423
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.returnPill },
|
|
348
424
|
react_1.default.createElement(Icons_1.Icon, { name: "undo", color: tx, size: 22 }),
|
|
349
|
-
react_1.default.createElement(
|
|
350
|
-
react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome && !menuOpen ? 'auto' : 'none', style: [styles.menuBtnWrap, { bottom: safe.bottom + 14, opacity: react_native_1.Animated.multiply(fade, react_native_1.Animated.subtract(1, menuFade)) }] },
|
|
351
|
-
react_1.default.createElement(react_native_1.Pressable, { onPress: () => setMenuOpen(true), accessibilityRole: "button", accessibilityLabel:
|
|
425
|
+
react_1.default.createElement(Text_1.Text, { style: { color: tx, fontSize: 20, marginStart: 8 }, maxFontSizeMultiplier: 1.3 }, L.formatNumber(returnTo.page)))))),
|
|
426
|
+
react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome && !menuOpen ? 'auto' : 'none', ...hiddenA11y(!(chrome && !menuOpen)), style: [styles.menuBtnWrap, { bottom: safe.bottom + 14, right: 16 + (safe.right || 0), opacity: react_native_1.Animated.multiply(fade, react_native_1.Animated.subtract(1, menuFade)) }] },
|
|
427
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: () => setMenuOpen(true), accessibilityRole: "button", accessibilityLabel: L.readerMenu },
|
|
352
428
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.menuBtn },
|
|
353
429
|
react_1.default.createElement(Icons_1.Icon, { name: "list", color: tx, size: 24 })))),
|
|
354
|
-
react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome && menuOpen ? 'box-none' : 'none', style: [styles.controls, { bottom: safe.bottom + 44, opacity: menuFade }] },
|
|
430
|
+
react_1.default.createElement(react_native_1.Animated.View, { pointerEvents: chrome && menuOpen ? 'box-none' : 'none', ...hiddenA11y(!(chrome && menuOpen)), style: [styles.controls, { bottom: safe.bottom + 44, right: 16 + (safe.right || 0), opacity: menuFade }] },
|
|
355
431
|
react_1.default.createElement(react_native_1.Pressable, { onPress: () => {
|
|
356
432
|
setMenuOpen(false);
|
|
357
433
|
setSheet('contents');
|
|
358
|
-
}, accessibilityRole: "button", accessibilityLabel:
|
|
434
|
+
}, accessibilityRole: "button", accessibilityLabel: L.contents, style: styles.pillWrap },
|
|
359
435
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.pill },
|
|
360
436
|
react_1.default.createElement(react_native_1.View, { style: styles.pillRow, onLayout: (e) => setPillW(e.nativeEvent.layout.width) },
|
|
361
|
-
react_1.default.createElement(
|
|
362
|
-
|
|
363
|
-
|
|
437
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.pillText, { color: tx }], maxFontSizeMultiplier: 1.3 },
|
|
438
|
+
L.contents,
|
|
439
|
+
" \u2022 ",
|
|
440
|
+
L.formatNumber(percent),
|
|
364
441
|
"%"),
|
|
365
442
|
react_1.default.createElement(Icons_1.Icon, { name: "list", color: tx, size: 24 })),
|
|
366
|
-
react_1.default.createElement(react_native_1.View, { pointerEvents: "none", style: [styles.fill, { width: progressFill * pillW, backgroundColor: dark ? 'rgba(255,255,255,0.35)' : '#1c1408', [rtl ? 'right' : 'left']: 0 }] },
|
|
443
|
+
react_1.default.createElement(react_native_1.View, { pointerEvents: "none", style: [styles.fill, { width: progressFill * pillW, backgroundColor: colors.strong || (dark ? 'rgba(255,255,255,0.35)' : '#1c1408'), [rtl ? 'right' : 'left']: 0 }] },
|
|
367
444
|
react_1.default.createElement(react_native_1.View, { style: [styles.pillRow, { position: 'absolute', top: 0, width: pillW, [rtl ? 'right' : 'left']: 0 }] },
|
|
368
|
-
react_1.default.createElement(
|
|
369
|
-
|
|
370
|
-
|
|
445
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.pillText, { color: onFill }], maxFontSizeMultiplier: 1.3 },
|
|
446
|
+
L.contents,
|
|
447
|
+
" \u2022 ",
|
|
448
|
+
L.formatNumber(percent),
|
|
371
449
|
"%"),
|
|
372
|
-
react_1.default.createElement(Icons_1.Icon, { name: "list", color:
|
|
450
|
+
react_1.default.createElement(Icons_1.Icon, { name: "list", color: onFill, size: 24 }))))),
|
|
373
451
|
react_1.default.createElement(react_native_1.Pressable, { onPress: () => {
|
|
374
452
|
setMenuOpen(false);
|
|
375
453
|
setSheet('search');
|
|
376
|
-
}, accessibilityRole: "button", accessibilityLabel:
|
|
454
|
+
}, accessibilityRole: "button", accessibilityLabel: L.searchBook, style: styles.pillWrap },
|
|
377
455
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.pill },
|
|
378
456
|
react_1.default.createElement(react_native_1.View, { style: styles.pillRow },
|
|
379
|
-
react_1.default.createElement(
|
|
457
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.pillText, { color: tx }], maxFontSizeMultiplier: 1.3 }, L.searchBook),
|
|
380
458
|
react_1.default.createElement(Icons_1.Icon, { name: "search", color: tx, size: 24 })))),
|
|
381
459
|
react_1.default.createElement(react_native_1.Pressable, { onPress: () => {
|
|
382
460
|
setMenuOpen(false);
|
|
383
461
|
setSheet('appearance');
|
|
384
|
-
}, accessibilityRole: "button", accessibilityLabel:
|
|
462
|
+
}, accessibilityRole: "button", accessibilityLabel: L.themesSettings, style: styles.pillWrap },
|
|
385
463
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.pill },
|
|
386
464
|
react_1.default.createElement(react_native_1.View, { style: styles.pillRow },
|
|
387
|
-
react_1.default.createElement(
|
|
465
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.pillText, { color: tx }], maxFontSizeMultiplier: 1.3 }, L.themesSettings),
|
|
388
466
|
react_1.default.createElement(Icons_1.Icon, { name: "textSize", color: tx, size: 26 })))),
|
|
389
467
|
react_1.default.createElement(react_native_1.View, { style: styles.roundRow },
|
|
390
|
-
react_1.default.createElement(react_native_1.Pressable, { onPress: share, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel:
|
|
468
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: share, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel: L.share },
|
|
391
469
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.round },
|
|
392
470
|
react_1.default.createElement(Icons_1.Icon, { name: "share", color: tx, size: 24 }))),
|
|
393
|
-
react_1.default.createElement(react_native_1.Pressable, { onPress: toggleRotationLock, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel:
|
|
471
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: toggleRotationLock, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel: L.rotationLock, accessibilityState: { selected: rotLocked } },
|
|
394
472
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: rotLocked ? (dark ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.18)') : colors.glass, border: colors.glassBorder, style: styles.round },
|
|
395
473
|
react_1.default.createElement(Icons_1.Icon, { name: "rotationLock", color: tx, size: 26, active: rotLocked }))),
|
|
396
|
-
react_1.default.createElement(react_native_1.Pressable, { onPress: onLineGuideButton, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel:
|
|
474
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: onLineGuideButton, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel: L.lineGuide, accessibilityState: { selected: lineGuide } },
|
|
397
475
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: lineGuide ? (dark ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.18)') : colors.glass, border: colors.glassBorder, style: styles.round },
|
|
398
476
|
react_1.default.createElement(Icons_1.Icon, { name: "lineGuide", color: tx, size: 26, active: lineGuide }))),
|
|
399
|
-
react_1.default.createElement(react_native_1.Pressable, { onPress: toggleBookmark, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel:
|
|
477
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: toggleBookmark, style: styles.roundWrap, accessibilityRole: "button", accessibilityLabel: L.bookmarkPage, accessibilityState: { selected: bookmarkHere.length > 0 } },
|
|
400
478
|
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.round },
|
|
401
479
|
react_1.default.createElement(Icons_1.Icon, { name: "bookmark", color: tx, size: 24, active: bookmarkHere.length > 0 }))))),
|
|
402
480
|
selection && !active && !noteFor && (() => {
|
|
403
|
-
const w = 214;
|
|
481
|
+
const w = Math.min(Math.max(214, screen.width * 0.5), screen.width - 16);
|
|
404
482
|
const r = selection.rect;
|
|
405
483
|
const left = Math.max(8, Math.min(screen.width - w - 8, r.x + r.width / 2 - w / 2));
|
|
406
484
|
// the system callout (Copy / Look Up) sits above the selection, so ours goes below it
|
|
407
485
|
const below = r.y + r.height + 16;
|
|
408
486
|
const top = below + 54 > screen.height - safe.bottom ? Math.max(safe.top + 8, r.y - 120) : below;
|
|
409
487
|
return (react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.sheetGlass, border: colors.glassBorder, intensity: 55, style: [styles.selBar, { left, top, width: w }] },
|
|
410
|
-
react_1.default.createElement(react_native_1.Pressable, { style: styles.selBtn, onPress: () => createHighlight(selection, false), accessibilityRole: "button", accessibilityLabel:
|
|
488
|
+
react_1.default.createElement(react_native_1.Pressable, { style: styles.selBtn, onPress: () => createHighlight(selection, false), accessibilityRole: "button", accessibilityLabel: L.highlight },
|
|
411
489
|
react_1.default.createElement(Icons_1.Icon, { name: "highlighter", color: tx, size: 22 }),
|
|
412
|
-
react_1.default.createElement(
|
|
490
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.selText, { color: tx }], numberOfLines: 1, maxFontSizeMultiplier: 1.2 }, L.highlight)),
|
|
413
491
|
react_1.default.createElement(react_native_1.View, { style: [styles.selSep, { backgroundColor: colors.separator }] }),
|
|
414
|
-
react_1.default.createElement(react_native_1.Pressable, { style: styles.selBtn, onPress: () => createHighlight(selection, true), accessibilityRole: "button", accessibilityLabel:
|
|
492
|
+
react_1.default.createElement(react_native_1.Pressable, { style: styles.selBtn, onPress: () => createHighlight(selection, true), accessibilityRole: "button", accessibilityLabel: L.addNote },
|
|
415
493
|
react_1.default.createElement(Icons_1.Icon, { name: "pencil", color: tx, size: 22 }),
|
|
416
|
-
react_1.default.createElement(
|
|
494
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.selText, { color: tx }], numberOfLines: 1, maxFontSizeMultiplier: 1.2 }, L.note))));
|
|
417
495
|
})(),
|
|
418
|
-
activeHighlight && active && (react_1.default.createElement(HighlightMenu_1.HighlightMenu, { highlight: activeHighlight, rect: active.rect, screen: screen, colors: colors, onColor: (c) => patchHighlight(activeHighlight.id, { color: c }), onToggleUnderline: () => patchHighlight(activeHighlight.id, { style: activeHighlight.style === 'underline' ? 'highlight' : 'underline' }), onNote: () => {
|
|
496
|
+
activeHighlight && active && (react_1.default.createElement(HighlightMenu_1.HighlightMenu, { highlight: activeHighlight, rect: active.rect, screen: screen, colors: colors, palette: props.highlightColors, onColor: (c) => patchHighlight(activeHighlight.id, { color: c }), onToggleUnderline: () => patchHighlight(activeHighlight.id, { style: activeHighlight.style === 'underline' ? 'highlight' : 'underline' }), onNote: () => {
|
|
419
497
|
setNoteFor(activeHighlight.id);
|
|
420
498
|
setActive(null);
|
|
421
499
|
}, onDelete: () => removeHighlight(activeHighlight.id), onDismiss: () => setActive(null) })),
|
|
422
|
-
|
|
423
|
-
react_1.default.createElement(react_native_1.
|
|
424
|
-
react_1.default.createElement(
|
|
425
|
-
|
|
500
|
+
!loaded && !fatal && (react_1.default.createElement(react_native_1.View, { style: [react_native_1.StyleSheet.absoluteFill, styles.splash, { backgroundColor: page.bg }], pointerEvents: "box-none" },
|
|
501
|
+
react_1.default.createElement(react_native_1.ActivityIndicator, { color: page.fg }),
|
|
502
|
+
react_1.default.createElement(Text_1.Text, { style: { color: page.fg, opacity: 0.6, marginTop: 12, fontSize: 15 }, maxFontSizeMultiplier: 1.3 }, L.loading),
|
|
503
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: props.onClose, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: L.closeBook, style: [styles.splashClose, { top: safe.top + 2, right: 16 + (safe.right || 0) }] },
|
|
504
|
+
react_1.default.createElement(Glass_1.Glass, { dark: dark, background: colors.glass, border: colors.glassBorder, style: styles.circle },
|
|
505
|
+
react_1.default.createElement(Icons_1.Icon, { name: "close", color: tx, size: 22 }))))),
|
|
506
|
+
!!fatal && (react_1.default.createElement(react_native_1.View, { style: [react_native_1.StyleSheet.absoluteFill, styles.splash, { backgroundColor: page.bg }], accessibilityViewIsModal: true },
|
|
507
|
+
react_1.default.createElement(Text_1.Text, { style: { color: page.fg, fontSize: 18, fontWeight: '600', textAlign: 'center' }, accessibilityRole: "header" }, L.couldNotOpen),
|
|
508
|
+
react_1.default.createElement(Text_1.Text, { style: { color: page.fg, opacity: 0.7, fontSize: 15, textAlign: 'center', marginTop: 10 }, accessibilityRole: "alert" }, fatal),
|
|
509
|
+
react_1.default.createElement(react_native_1.View, { style: styles.fatalButtons },
|
|
510
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: props.onRetry, style: [styles.fatalBtn, { backgroundColor: colors.accent }], accessibilityRole: "button" },
|
|
511
|
+
react_1.default.createElement(Text_1.Text, { style: { color: '#ffffff', fontSize: 16, fontWeight: '600' } }, L.tryAgain)),
|
|
512
|
+
!!props.onClose && (react_1.default.createElement(react_native_1.Pressable, { onPress: props.onClose, style: [styles.fatalBtn, { backgroundColor: colors.card }], accessibilityRole: "button" },
|
|
513
|
+
react_1.default.createElement(Text_1.Text, { style: { color: tx, fontSize: 16, fontWeight: '600' } }, L.close)))))),
|
|
514
|
+
error && !fatal && (react_1.default.createElement(react_native_1.View, { style: [styles.error, { backgroundColor: colors.sheet }], accessibilityRole: "alert" },
|
|
515
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.text, fontSize: 15, textAlign: 'center' } }, error),
|
|
516
|
+
react_1.default.createElement(react_native_1.Pressable, { onPress: () => setError(null), style: { marginTop: 12, padding: 8 }, accessibilityRole: "button" },
|
|
517
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.accent, fontSize: 16 } }, L.ok)))),
|
|
426
518
|
lineMenu && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
427
|
-
react_1.default.createElement(react_native_1.Pressable, { style: react_native_1.StyleSheet.absoluteFill, onPress: () => setLineMenu(false), accessibilityLabel:
|
|
519
|
+
react_1.default.createElement(react_native_1.Pressable, { style: react_native_1.StyleSheet.absoluteFill, onPress: () => setLineMenu(false), accessibilityLabel: L.dismiss }),
|
|
428
520
|
react_1.default.createElement(react_native_1.View, { style: [styles.lineMenu, { bottom: safe.bottom + 20, backgroundColor: colors.dark ? '#4a4742' : '#ffffff', borderColor: colors.glassBorder }] },
|
|
429
|
-
react_1.default.createElement(
|
|
430
|
-
|
|
521
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.lineMenuHead, { color: colors.subtext }] }, L.backgroundDimming),
|
|
522
|
+
DIM_IDS.map((d) => (react_1.default.createElement(react_native_1.Pressable, { key: d.id, style: styles.lineItem, accessibilityRole: "button", accessibilityState: { selected: dimLevel === d.id }, onPress: () => {
|
|
431
523
|
setDimLevel(d.id);
|
|
432
524
|
setLineMenu(false);
|
|
433
525
|
} },
|
|
434
526
|
react_1.default.createElement(react_native_1.View, { style: styles.lineCheck }, dimLevel === d.id && react_1.default.createElement(Icons_1.Icon, { name: "check", color: tx, size: 20 })),
|
|
435
|
-
react_1.default.createElement(
|
|
527
|
+
react_1.default.createElement(Text_1.Text, { style: { color: tx, fontSize: 19 } }, L[d.label])))),
|
|
436
528
|
react_1.default.createElement(react_native_1.View, { style: [styles.lineSep, { backgroundColor: colors.separator }] }),
|
|
437
|
-
react_1.default.createElement(react_native_1.Pressable, { style: styles.lineItem, onPress: () => {
|
|
529
|
+
react_1.default.createElement(react_native_1.Pressable, { style: styles.lineItem, accessibilityRole: "button", onPress: () => {
|
|
438
530
|
setLineGuide(false);
|
|
439
531
|
setLineMenu(false);
|
|
440
532
|
} },
|
|
441
533
|
react_1.default.createElement(react_native_1.View, { style: styles.lineCheck }),
|
|
442
|
-
react_1.default.createElement(
|
|
443
|
-
react_1.default.createElement(ContentsSheet_1.ContentsSheet, { visible: sheet === 'contents', colors: colors, title: meta?.title || props.title || '', subtitle:
|
|
534
|
+
react_1.default.createElement(Text_1.Text, { style: { color: tx, fontSize: 19 } }, L.turnOffLineGuide))))),
|
|
535
|
+
react_1.default.createElement(ContentsSheet_1.ContentsSheet, { visible: sheet === 'contents', colors: colors, title: meta?.title || props.title || '', subtitle: L.pageOfTotalLong(curPage, totalPages), toc: toc, currentSpine: loc?.spine ?? 0, pageOf: pageOf, bookmarks: bookmarks, highlights: highlights, palette: props.highlightColors, onClose: closeSheet, onGoToc: (item) => {
|
|
444
536
|
closeSheet();
|
|
445
537
|
jump({ spine: item.spine, fragment: item.fragment });
|
|
446
538
|
}, onGoBookmark: (b) => {
|
|
447
539
|
closeSheet();
|
|
448
|
-
jump({ spine: b.spine, offset: b.offset });
|
|
540
|
+
jump(b.cfi ? { cfi: b.cfi, spine: b.spine, offset: b.offset } : { spine: b.spine, offset: b.offset });
|
|
449
541
|
}, onGoHighlight: (h) => {
|
|
450
542
|
closeSheet();
|
|
451
|
-
jump({ spine: h.spine, offset: h.start });
|
|
543
|
+
jump(h.cfi ? { cfi: h.cfi, spine: h.spine, offset: h.start } : { spine: h.spine, offset: h.start });
|
|
452
544
|
}, onDeleteBookmark: (id) => updateBookmarks((prev) => prev.filter((b) => b.id !== id)), onDeleteHighlight: (id) => updateHighlights((prev) => prev.filter((h) => h.id !== id)) }),
|
|
453
545
|
react_1.default.createElement(SearchSheet_1.SearchSheet, { visible: sheet === 'search', colors: colors, results: results, searching: searching, onClose: closeSheet, onSearch: runSearch, onPick: (r) => {
|
|
454
546
|
closeSheet();
|
|
@@ -457,8 +549,8 @@ function EpubReaderView(props) {
|
|
|
457
549
|
setChrome(false);
|
|
458
550
|
reader.current?.showSearchResult(r);
|
|
459
551
|
} }),
|
|
460
|
-
react_1.default.createElement(AppearanceSheet_1.AppearanceSheet, { visible: sheet === 'appearance', colors: colors, settings: settings, systemDark: systemDark, onChange: changeSettings, onCustomize: () => switchSheet('customize'), onClose: closeSheet }),
|
|
461
|
-
react_1.default.createElement(CustomizeSheet_1.CustomizeSheet, { visible: sheet === 'customize', colors: colors, page: page, settings: settings, sample: loc?.excerpt || SAMPLE, onChange: changeSettings, onReset: () => changeSettings(RESET_THEME), onClose: () => switchSheet('appearance') }),
|
|
552
|
+
react_1.default.createElement(AppearanceSheet_1.AppearanceSheet, { visible: sheet === 'appearance', colors: colors, settings: settings, systemDark: systemDark, themes: props.themes, onChange: changeSettings, onCustomize: () => switchSheet('customize'), onClose: closeSheet }),
|
|
553
|
+
react_1.default.createElement(CustomizeSheet_1.CustomizeSheet, { visible: sheet === 'customize', colors: colors, page: page, settings: settings, sample: loc?.excerpt || SAMPLE, fontList: (0, themes_1.fontChoices)(props.fonts), onChange: changeSettings, onReset: () => changeSettings(RESET_THEME), onClose: () => switchSheet('appearance') }),
|
|
462
554
|
react_1.default.createElement(NoteEditor_1.NoteEditor, { visible: !!noteHighlight, quote: noteHighlight?.text || '', initial: noteHighlight?.note || '', colors: colors, onCancel: () => setNoteFor(null), onSave: (text) => {
|
|
463
555
|
if (noteFor)
|
|
464
556
|
patchHighlight(noteFor, { note: text || undefined });
|
|
@@ -467,9 +559,9 @@ function EpubReaderView(props) {
|
|
|
467
559
|
}
|
|
468
560
|
const styles = react_native_1.StyleSheet.create({
|
|
469
561
|
root: { flex: 1 },
|
|
470
|
-
closeWrap: { position: 'absolute'
|
|
562
|
+
closeWrap: { position: 'absolute' },
|
|
471
563
|
circle: { width: 42, height: 42, borderRadius: 21, alignItems: 'center', justifyContent: 'center' },
|
|
472
|
-
controls: { position: 'absolute',
|
|
564
|
+
controls: { position: 'absolute', width: '68%', minWidth: 260, maxWidth: 420 },
|
|
473
565
|
selBar: { position: 'absolute', height: 48, borderRadius: 24, flexDirection: 'row', alignItems: 'center' },
|
|
474
566
|
selBtn: { flex: 1, height: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 6 },
|
|
475
567
|
selText: { fontSize: 15, fontWeight: '600' },
|
|
@@ -482,9 +574,9 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
482
574
|
lineItem: { flexDirection: 'row', alignItems: 'center', paddingVertical: 12, paddingHorizontal: 18 },
|
|
483
575
|
lineCheck: { width: 34 },
|
|
484
576
|
lineSep: { height: react_native_1.StyleSheet.hairlineWidth, marginVertical: 6, marginHorizontal: 18 },
|
|
485
|
-
menuBtnWrap: { position: 'absolute'
|
|
577
|
+
menuBtnWrap: { position: 'absolute' },
|
|
486
578
|
menuBtn: { width: 54, height: 54, borderRadius: 27, alignItems: 'center', justifyContent: 'center' },
|
|
487
|
-
returnWrap: { position: 'absolute'
|
|
579
|
+
returnWrap: { position: 'absolute' },
|
|
488
580
|
returnPill: { height: 46, borderRadius: 23, flexDirection: 'row', alignItems: 'center', paddingHorizontal: 16 },
|
|
489
581
|
pillRow: { height: 50, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 22 },
|
|
490
582
|
pillWrap: { marginBottom: 8 },
|
|
@@ -500,5 +592,14 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
500
592
|
width: 0, height: 0, borderLeftWidth: 8, borderRightWidth: 8, borderBottomWidth: 7,
|
|
501
593
|
borderLeftColor: '#ff3b30', borderRightColor: '#ff3b30', borderBottomColor: 'transparent'
|
|
502
594
|
},
|
|
503
|
-
error: { position: 'absolute', left: 24, right: 24, top: '40%', padding: 20, borderRadius: 14, alignItems: 'center', elevation: 10 }
|
|
595
|
+
error: { position: 'absolute', left: 24, right: 24, top: '40%', padding: 20, borderRadius: 14, alignItems: 'center', elevation: 10 },
|
|
596
|
+
splash: { alignItems: 'center', justifyContent: 'center', paddingHorizontal: 32 },
|
|
597
|
+
splashClose: { position: 'absolute' },
|
|
598
|
+
fatalButtons: { flexDirection: 'row', gap: 12, marginTop: 24 },
|
|
599
|
+
fatalBtn: { minWidth: 110, height: 46, borderRadius: 23, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 20 },
|
|
600
|
+
a11yHandle: { position: 'absolute', width: 48, height: 48, backgroundColor: 'transparent' }
|
|
504
601
|
});
|
|
602
|
+
// controls that are faded out must not stay reachable for VoiceOver / TalkBack
|
|
603
|
+
function hiddenA11y(hidden) {
|
|
604
|
+
return { accessibilityElementsHidden: hidden, importantForAccessibility: (hidden ? 'no-hide-descendants' : 'auto') };
|
|
605
|
+
}
|
package/lib/cfiOrder.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Book order of two epub.js CFIs, without a DOM. A range CFI counts from its start.
|
|
3
|
+
// Only the step numbers and the character offset matter for order; [id] assertions are ignored.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.compareCfi = compareCfi;
|
|
6
|
+
function partsOf(cfi) {
|
|
7
|
+
const m = /^epubcfi\((.*)\)$/.exec(cfi.trim());
|
|
8
|
+
if (!m)
|
|
9
|
+
return null;
|
|
10
|
+
// drop [..] assertions first, they may contain ',' or ':'
|
|
11
|
+
const bits = m[1].replace(/\[[^\]]*\]/g, '').split(',');
|
|
12
|
+
const path = bits.length === 3 ? bits[0] + bits[1] : bits[0];
|
|
13
|
+
const steps = [];
|
|
14
|
+
const re = /\/(\d+)/g;
|
|
15
|
+
let s;
|
|
16
|
+
while ((s = re.exec(path)))
|
|
17
|
+
steps.push(+s[1]);
|
|
18
|
+
const off = /:(\d+)[^/]*$/.exec(path);
|
|
19
|
+
return steps.length ? { steps, offset: off ? +off[1] : 0 } : null;
|
|
20
|
+
}
|
|
21
|
+
/** Negative when `a` comes first, positive when `b` comes first, 0 when equal or unreadable. */
|
|
22
|
+
function compareCfi(a, b) {
|
|
23
|
+
const x = partsOf(a);
|
|
24
|
+
const y = partsOf(b);
|
|
25
|
+
if (!x || !y)
|
|
26
|
+
return 0;
|
|
27
|
+
for (let i = 0; i < Math.min(x.steps.length, y.steps.length); i++) {
|
|
28
|
+
if (x.steps[i] !== y.steps[i])
|
|
29
|
+
return x.steps[i] - y.steps[i];
|
|
30
|
+
}
|
|
31
|
+
if (x.steps.length !== y.steps.length)
|
|
32
|
+
return x.steps.length - y.steps.length;
|
|
33
|
+
return x.offset - y.offset;
|
|
34
|
+
}
|