aksos-react-native-epub-reader 0.1.1 → 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 +158 -13
- package/lib/EpubReader.d.ts +47 -9
- package/lib/EpubReader.js +69 -16
- package/lib/EpubReaderView.d.ts +27 -2
- package/lib/EpubReaderView.js +38 -32
- 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 +1 -1
- package/lib/themes.d.ts +24 -6
- package/lib/themes.js +80 -20
- package/lib/types.d.ts +66 -1
- package/lib/ui/AppearanceSheet.d.ts +4 -2
- package/lib/ui/AppearanceSheet.js +20 -13
- package/lib/ui/ContentsSheet.d.ts +2 -0
- package/lib/ui/ContentsSheet.js +21 -13
- package/lib/ui/CustomizeSheet.d.ts +4 -2
- package/lib/ui/CustomizeSheet.js +20 -18
- package/lib/ui/HighlightMenu.d.ts +4 -2
- package/lib/ui/HighlightMenu.js +3 -3
- package/lib/ui/NoteEditor.js +6 -5
- package/lib/ui/SearchSheet.js +6 -5
- package/lib/ui/Sheet.js +5 -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 +121 -25
- package/src/EpubReaderView.tsx +61 -17
- 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 +830 -65
- package/src/index.ts +1 -1
- package/src/themes.ts +97 -21
- package/src/types.ts +71 -1
- package/src/ui/AppearanceSheet.tsx +19 -10
- package/src/ui/ContentsSheet.tsx +14 -4
- package/src/ui/CustomizeSheet.tsx +14 -10
- package/src/ui/HighlightMenu.tsx +6 -4
- package/src/ui/NoteEditor.tsx +2 -1
- package/src/ui/SearchSheet.tsx +2 -1
- package/src/ui/Sheet.tsx +4 -3
- package/src/ui/Text.tsx +27 -0
package/lib/ui/CustomizeSheet.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.CustomizeSheet = CustomizeSheet;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
|
+
const Text_1 = require("./Text");
|
|
39
40
|
const themes_1 = require("../themes");
|
|
40
41
|
const strings_1 = require("../strings");
|
|
41
42
|
const Icons_1 = require("./Icons");
|
|
@@ -47,27 +48,28 @@ function Toggle(props) {
|
|
|
47
48
|
react_1.default.createElement(react_native_1.Switch, { ...props })));
|
|
48
49
|
}
|
|
49
50
|
/** "Customize Theme" sheet: font, bold, spacing, margins, columns, justify, sound. */
|
|
50
|
-
function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange, onReset, onClose }) {
|
|
51
|
+
function CustomizeSheet({ visible, colors, page, settings: s, sample, fontList = themes_1.FONTS, onChange, onReset, onClose }) {
|
|
52
|
+
const track = colors.strong ? { true: colors.strong } : GREEN;
|
|
51
53
|
const L = (0, strings_1.useLabels)();
|
|
52
54
|
const COLUMN_LABEL = { auto: L.columnsAuto, '1': L.columnsOne, '2': L.columnsTwo };
|
|
53
55
|
const [fonts, setFonts] = (0, react_1.useState)(false);
|
|
54
56
|
const [columnsMenu, setColumnsMenu] = (0, react_1.useState)(false);
|
|
55
57
|
const off = !s.customize;
|
|
56
|
-
const font = (
|
|
58
|
+
const font = fontList.find((f) => f.id === s.fontId) || fontList[0];
|
|
57
59
|
const previewFont = s.fontId === 'system' ? undefined : themes_1.serifFont;
|
|
58
60
|
const border = { borderTopWidth: react_native_1.StyleSheet.hairlineWidth, borderColor: colors.separator };
|
|
59
61
|
const sliderRow = (label, icon, value, min, max, step, show, key) => (react_1.default.createElement(react_native_1.View, { style: [styles.sliderBlock, border, off && styles.dim], pointerEvents: off ? 'none' : 'auto' },
|
|
60
|
-
react_1.default.createElement(
|
|
62
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.caption, { color: colors.subtext }] }, label),
|
|
61
63
|
react_1.default.createElement(react_native_1.View, { style: styles.sliderRow },
|
|
62
64
|
react_1.default.createElement(Icons_1.Icon, { name: icon, color: colors.text, size: 24 }),
|
|
63
65
|
react_1.default.createElement(react_native_1.View, { style: { flex: 1, marginHorizontal: 12 } },
|
|
64
66
|
react_1.default.createElement(Slider_1.Slider, { value: value, min: min, max: max, step: step, onChange: (v) => onChange({ [key]: v }), color: colors.text, track: colors.separator, thumbColor: "#ffffff" })),
|
|
65
|
-
react_1.default.createElement(
|
|
67
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.value, { color: colors.subtext }] }, show))));
|
|
66
68
|
const row = (icon, label, right, onPress, top = true, iconActive = false) => {
|
|
67
69
|
const content = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
68
70
|
react_1.default.createElement(react_native_1.View, { style: styles.rowIcon },
|
|
69
71
|
react_1.default.createElement(Icons_1.Icon, { name: icon, color: colors.text, size: 22, active: iconActive })),
|
|
70
|
-
react_1.default.createElement(
|
|
72
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.label, { color: colors.text }] }, label),
|
|
71
73
|
right));
|
|
72
74
|
return onPress ? (react_1.default.createElement(react_native_1.Pressable, { style: [styles.line, top && border], onPress: onPress }, content)) : (react_1.default.createElement(react_native_1.View, { style: [styles.line, top && border] }, content));
|
|
73
75
|
};
|
|
@@ -78,8 +80,8 @@ function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange,
|
|
|
78
80
|
};
|
|
79
81
|
return (react_1.default.createElement(Sheet_1.Sheet, { visible: visible, colors: colors, onClose: close, closeIcon: "check", title: L.customizeTheme, height: "92%" },
|
|
80
82
|
react_1.default.createElement(react_native_1.View, { style: [styles.preview, { backgroundColor: page.bg }] },
|
|
81
|
-
react_1.default.createElement(
|
|
82
|
-
react_1.default.createElement(
|
|
83
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.aa, { color: page.fg, fontFamily: previewFont }] }, "Aa"),
|
|
84
|
+
react_1.default.createElement(Text_1.Text, { numberOfLines: 4, style: {
|
|
83
85
|
color: page.fg, fontFamily: previewFont, fontSize: Math.min(s.fontSize, 22),
|
|
84
86
|
lineHeight: Math.min(s.fontSize, 22) * (s.customize ? s.lineHeight : 1.5),
|
|
85
87
|
fontWeight: s.bold ? '700' : '400', textAlign: s.justify ? 'justify' : 'auto'
|
|
@@ -87,26 +89,26 @@ function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange,
|
|
|
87
89
|
react_1.default.createElement(react_native_1.ScrollView, { contentContainerStyle: styles.pad },
|
|
88
90
|
react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card }] },
|
|
89
91
|
row('textSize', L.font, react_1.default.createElement(react_native_1.View, { style: styles.value2 },
|
|
90
|
-
react_1.default.createElement(
|
|
92
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.subtext, fontSize: 17 } }, font.name),
|
|
91
93
|
react_1.default.createElement(Icons_1.Icon, { name: fonts ? 'chevronUp' : 'chevronRight', color: colors.subtext, size: 18 })), () => setFonts((v) => !v), false),
|
|
92
94
|
fonts &&
|
|
93
|
-
|
|
95
|
+
fontList.map((f) => (react_1.default.createElement(react_native_1.Pressable, { key: f.id, onPress: () => {
|
|
94
96
|
onChange({ fontId: f.id });
|
|
95
97
|
setFonts(false);
|
|
96
98
|
}, style: [styles.line, border] },
|
|
97
99
|
react_1.default.createElement(react_native_1.View, { style: styles.check }, s.fontId === f.id && react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.text, size: 20 })),
|
|
98
|
-
react_1.default.createElement(
|
|
99
|
-
row('bold', L.boldText, react_1.default.createElement(Toggle, { value: s.bold, onValueChange: (v) => onChange({ bold: v }), trackColor:
|
|
100
|
-
react_1.default.createElement(
|
|
100
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.label, { color: colors.text }] }, f.name)))),
|
|
101
|
+
row('bold', L.boldText, react_1.default.createElement(Toggle, { value: s.bold, onValueChange: (v) => onChange({ bold: v }), trackColor: track }))),
|
|
102
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.heading, { color: colors.text }] }, L.accessibilityLayout),
|
|
101
103
|
react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card }] },
|
|
102
|
-
row('sliders', L.customize, react_1.default.createElement(Toggle, { value: s.customize, onValueChange: (v) => onChange({ customize: v }), trackColor:
|
|
104
|
+
row('sliders', L.customize, react_1.default.createElement(Toggle, { value: s.customize, onValueChange: (v) => onChange({ customize: v }), trackColor: track }), undefined, false),
|
|
103
105
|
sliderRow(L.lineSpacing, 'lineSpacing', s.lineHeight, 1.1, 2.2, 0.05, s.lineHeight.toFixed(2), 'lineHeight'),
|
|
104
106
|
sliderRow(L.characterSpacing, 'charSpacing', s.letterSpacing, -50, 100, 5, `${s.letterSpacing}%`, 'letterSpacing'),
|
|
105
107
|
sliderRow(L.wordSpacing, 'wordSpacing', s.wordSpacing, -50, 100, 5, `${s.wordSpacing}%`, 'wordSpacing'),
|
|
106
108
|
sliderRow(L.margins, 'margins', s.margins, -50, 100, 5, `${s.margins}%`, 'margins')),
|
|
107
109
|
react_1.default.createElement(react_native_1.View, { style: [styles.group, { backgroundColor: colors.card, marginTop: 16 }] },
|
|
108
110
|
row('columns', L.columns, react_1.default.createElement(react_native_1.View, { style: styles.value2 },
|
|
109
|
-
react_1.default.createElement(
|
|
111
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.subtext, fontSize: 17 } }, COLUMN_LABEL[String(s.columns)]),
|
|
110
112
|
react_1.default.createElement(Icons_1.Icon, { name: columnsMenu ? 'chevronUp' : 'chevronDown', color: colors.subtext, size: 18 })), () => setColumnsMenu((v) => !v), false),
|
|
111
113
|
columnsMenu &&
|
|
112
114
|
['auto', 1, 2].map((c) => (react_1.default.createElement(react_native_1.Pressable, { key: String(c), style: [styles.line, border], onPress: () => {
|
|
@@ -114,11 +116,11 @@ function CustomizeSheet({ visible, colors, page, settings: s, sample, onChange,
|
|
|
114
116
|
setColumnsMenu(false);
|
|
115
117
|
} },
|
|
116
118
|
react_1.default.createElement(react_native_1.View, { style: styles.check }, s.columns === c && react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.text, size: 20 })),
|
|
117
|
-
react_1.default.createElement(
|
|
118
|
-
row('justify', L.justifyText, react_1.default.createElement(Toggle, { value: s.justify, onValueChange: (v) => onChange({ justify: v }), trackColor:
|
|
119
|
-
row(s.pageSound ? 'sound' : 'soundOff', L.pageTurnSound, react_1.default.createElement(Toggle, { value: s.pageSound, onValueChange: (v) => onChange({ pageSound: v }), trackColor:
|
|
119
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.label, { color: colors.text }] }, COLUMN_LABEL[String(c)])))),
|
|
120
|
+
row('justify', L.justifyText, react_1.default.createElement(Toggle, { value: s.justify, onValueChange: (v) => onChange({ justify: v }), trackColor: track })),
|
|
121
|
+
row(s.pageSound ? 'sound' : 'soundOff', L.pageTurnSound, react_1.default.createElement(Toggle, { value: s.pageSound, onValueChange: (v) => onChange({ pageSound: v }), trackColor: track }))),
|
|
120
122
|
react_1.default.createElement(react_native_1.Pressable, { onPress: onReset, style: [styles.reset, { backgroundColor: colors.card }], accessibilityRole: "button" },
|
|
121
|
-
react_1.default.createElement(
|
|
123
|
+
react_1.default.createElement(Text_1.Text, { style: { color: '#ff3b30', fontSize: 18, fontWeight: '600' } }, L.resetTheme)))));
|
|
122
124
|
}
|
|
123
125
|
const styles = react_native_1.StyleSheet.create({
|
|
124
126
|
preview: { paddingHorizontal: 22, paddingTop: 12, paddingBottom: 18, marginBottom: 10 },
|
|
@@ -3,6 +3,8 @@ import type { ChromeColors } from '../themes';
|
|
|
3
3
|
import type { Highlight, HighlightColor } from '../types';
|
|
4
4
|
interface Props {
|
|
5
5
|
highlight: Highlight;
|
|
6
|
+
/** colour name -> CSS colour shown as a dot (default: the built-in HIGHLIGHT_COLORS) */
|
|
7
|
+
palette?: Record<string, string>;
|
|
6
8
|
rect: {
|
|
7
9
|
x: number;
|
|
8
10
|
y: number;
|
|
@@ -14,12 +16,12 @@ interface Props {
|
|
|
14
16
|
height: number;
|
|
15
17
|
};
|
|
16
18
|
colors: ChromeColors;
|
|
17
|
-
onColor: (c: HighlightColor) => void;
|
|
19
|
+
onColor: (c: HighlightColor | (string & {})) => void;
|
|
18
20
|
onToggleUnderline: () => void;
|
|
19
21
|
onNote: () => void;
|
|
20
22
|
onDelete: () => void;
|
|
21
23
|
onDismiss: () => void;
|
|
22
24
|
}
|
|
23
25
|
/** Floating glass palette shown over a highlight, like Apple Books. */
|
|
24
|
-
export declare function HighlightMenu({ highlight, rect, screen, colors, onColor, onToggleUnderline, onNote, onDelete, onDismiss }: Props): React.JSX.Element;
|
|
26
|
+
export declare function HighlightMenu({ highlight, palette, rect, screen, colors, onColor, onToggleUnderline, onNote, onDelete, onDismiss }: Props): React.JSX.Element;
|
|
25
27
|
export {};
|
package/lib/ui/HighlightMenu.js
CHANGED
|
@@ -13,7 +13,7 @@ const Icons_1 = require("./Icons");
|
|
|
13
13
|
const MAX_W = 316;
|
|
14
14
|
const H = 50;
|
|
15
15
|
/** Floating glass palette shown over a highlight, like Apple Books. */
|
|
16
|
-
function HighlightMenu({ highlight, rect, screen, colors, onColor, onToggleUnderline, onNote, onDelete, onDismiss }) {
|
|
16
|
+
function HighlightMenu({ highlight, palette = themes_1.HIGHLIGHT_COLORS, rect, screen, colors, onColor, onToggleUnderline, onNote, onDelete, onDismiss }) {
|
|
17
17
|
const L = (0, strings_1.useLabels)();
|
|
18
18
|
const W = Math.min(MAX_W, screen.width - 16); // narrow windows (split screen, foldable cover screens)
|
|
19
19
|
const left = Math.max(8, Math.min(screen.width - W - 8, rect.x + rect.width / 2 - W / 2));
|
|
@@ -22,8 +22,8 @@ function HighlightMenu({ highlight, rect, screen, colors, onColor, onToggleUnder
|
|
|
22
22
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
23
23
|
react_1.default.createElement(react_native_1.Pressable, { style: react_native_1.StyleSheet.absoluteFill, onPress: onDismiss, accessibilityLabel: L.dismiss }),
|
|
24
24
|
react_1.default.createElement(Glass_1.Glass, { dark: colors.dark, background: colors.sheetGlass, border: colors.glassBorder, intensity: 55, style: [styles.menu, { left, top, width: W }] },
|
|
25
|
-
Object.keys(
|
|
26
|
-
react_1.default.createElement(react_native_1.View, { style: [styles.dot, { backgroundColor:
|
|
25
|
+
Object.keys(palette).map((c) => (react_1.default.createElement(react_native_1.Pressable, { key: c, onPress: () => onColor(c), hitSlop: 8, accessibilityRole: "button", accessibilityLabel: `${c} ${L.highlight}`, accessibilityState: { selected: highlight.color === c } },
|
|
26
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.dot, { backgroundColor: palette[c], borderWidth: highlight.color === c ? 2 : 0, borderColor: colors.text }] })))),
|
|
27
27
|
react_1.default.createElement(react_native_1.Pressable, { onPress: onToggleUnderline, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.underline, accessibilityState: { selected: highlight.style === 'underline' } },
|
|
28
28
|
react_1.default.createElement(Icons_1.Icon, { name: "underline", color: colors.text, size: 22, active: highlight.style === 'underline', strokeWidth: highlight.style === 'underline' ? 2.4 : 1.8 })),
|
|
29
29
|
react_1.default.createElement(react_native_1.Pressable, { onPress: onNote, hitSlop: 11, accessibilityRole: "button", accessibilityLabel: L.note },
|
package/lib/ui/NoteEditor.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.NoteEditor = NoteEditor;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
|
+
const Text_1 = require("./Text");
|
|
39
40
|
const strings_1 = require("../strings");
|
|
40
41
|
function NoteEditor({ visible, quote, initial, colors, onSave, onCancel }) {
|
|
41
42
|
const L = (0, strings_1.useLabels)();
|
|
@@ -47,12 +48,12 @@ function NoteEditor({ visible, quote, initial, colors, onSave, onCancel }) {
|
|
|
47
48
|
react_1.default.createElement(react_native_1.View, { style: [styles.card, { backgroundColor: colors.sheet }] },
|
|
48
49
|
react_1.default.createElement(react_native_1.View, { style: styles.head },
|
|
49
50
|
react_1.default.createElement(react_native_1.Pressable, { onPress: onCancel, hitSlop: 12, accessibilityRole: "button" },
|
|
50
|
-
react_1.default.createElement(
|
|
51
|
-
react_1.default.createElement(
|
|
51
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.accent, fontSize: 17 }, maxFontSizeMultiplier: 1.4 }, L.cancel)),
|
|
52
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.text, fontSize: 17, fontWeight: '600' }, maxFontSizeMultiplier: 1.4 }, L.note),
|
|
52
53
|
react_1.default.createElement(react_native_1.Pressable, { onPress: () => onSave(text.trim()), hitSlop: 12, accessibilityRole: "button" },
|
|
53
|
-
react_1.default.createElement(
|
|
54
|
-
react_1.default.createElement(
|
|
55
|
-
react_1.default.createElement(
|
|
54
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.accent, fontSize: 17, fontWeight: '600' }, maxFontSizeMultiplier: 1.4 }, L.save))),
|
|
55
|
+
react_1.default.createElement(Text_1.Text, { numberOfLines: 3, style: [styles.quote, { color: colors.subtext, borderColor: colors.accent }] }, quote),
|
|
56
|
+
react_1.default.createElement(Text_1.TextInput, { autoFocus: true, multiline: true, value: text, onChangeText: setText, placeholder: L.addANote, placeholderTextColor: colors.subtext, style: [styles.input, { color: colors.text, backgroundColor: colors.card }] })))));
|
|
56
57
|
}
|
|
57
58
|
const styles = react_native_1.StyleSheet.create({
|
|
58
59
|
wrap: { flex: 1, justifyContent: 'flex-end', backgroundColor: 'rgba(0,0,0,0.35)' },
|
package/lib/ui/SearchSheet.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.SearchSheet = SearchSheet;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
|
+
const Text_1 = require("./Text");
|
|
39
40
|
const strings_1 = require("../strings");
|
|
40
41
|
const Icons_1 = require("./Icons");
|
|
41
42
|
const Sheet_1 = require("./Sheet");
|
|
@@ -62,12 +63,12 @@ function SearchSheet({ visible, colors, results, searching, onClose, onSearch, o
|
|
|
62
63
|
return (react_1.default.createElement(Sheet_1.Sheet, { visible: visible, colors: colors, onClose: onClose, height: "85%", title: L.search },
|
|
63
64
|
react_1.default.createElement(react_native_1.View, { style: [styles.field, { backgroundColor: colors.card }] },
|
|
64
65
|
react_1.default.createElement(Icons_1.Icon, { name: "search", color: colors.subtext, size: 20 }),
|
|
65
|
-
react_1.default.createElement(
|
|
66
|
-
react_1.default.createElement(react_native_1.FlatList, { data: results, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "on-drag", contentContainerStyle: { paddingBottom: kb }, keyExtractor: (_, i) => String(i), ListHeaderComponent: q.trim().length >= 2 ? (react_1.default.createElement(
|
|
67
|
-
react_1.default.createElement(
|
|
68
|
-
react_1.default.createElement(
|
|
66
|
+
react_1.default.createElement(Text_1.TextInput, { value: q, onChangeText: setQ, placeholder: L.searchInBook, accessibilityLabel: L.searchInBook, placeholderTextColor: colors.subtext, style: [styles.input, { color: colors.text }], autoCorrect: false, returnKeyType: "search", onSubmitEditing: () => onSearch(q), clearButtonMode: "while-editing" })),
|
|
67
|
+
react_1.default.createElement(react_native_1.FlatList, { data: results, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "on-drag", contentContainerStyle: { paddingBottom: kb }, keyExtractor: (_, i) => String(i), ListHeaderComponent: q.trim().length >= 2 ? (react_1.default.createElement(Text_1.Text, { style: [styles.count, { color: colors.subtext }] }, searching ? L.searching : results.length === 0 ? L.noResults : `${L.formatNumber(results.length)}${results.length >= 500 ? '+' : ''}`)) : null, renderItem: ({ item }) => (react_1.default.createElement(react_native_1.Pressable, { onPress: () => onPick(item), style: [styles.row, { borderColor: colors.separator }], accessibilityRole: "button" },
|
|
68
|
+
react_1.default.createElement(Text_1.Text, { style: [styles.chapter, { color: colors.accent }], numberOfLines: 1 }, item.chapter),
|
|
69
|
+
react_1.default.createElement(Text_1.Text, { style: { color: colors.text, fontSize: 15, lineHeight: 21 }, numberOfLines: 3 },
|
|
69
70
|
item.before,
|
|
70
|
-
react_1.default.createElement(
|
|
71
|
+
react_1.default.createElement(Text_1.Text, { style: { fontWeight: '700', backgroundColor: 'rgba(255,214,10,0.45)' } }, item.match),
|
|
71
72
|
item.after))) })));
|
|
72
73
|
}
|
|
73
74
|
const styles = react_native_1.StyleSheet.create({
|
package/lib/ui/Sheet.js
CHANGED
|
@@ -6,14 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Sheet = Sheet;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_native_1 = require("react-native");
|
|
9
|
+
const Text_1 = require("./Text");
|
|
9
10
|
const Glass_1 = require("./Glass");
|
|
10
11
|
const strings_1 = require("../strings");
|
|
11
12
|
const Icons_1 = require("./Icons");
|
|
12
13
|
/** Rounded frosted-glass sheet: the book stays faintly visible behind it. */
|
|
13
14
|
function Sheet({ visible, title, subtitle, colors, height = '70%', closeIcon = 'x', onClose, children, overlay }) {
|
|
14
15
|
const L = (0, strings_1.useLabels)();
|
|
15
|
-
const button = closeIcon === 'check' ? (react_1.default.createElement(react_native_1.Pressable, { onPress: onClose, hitSlop: 10, style: [styles.circle, { backgroundColor: colors.dark ? '#ffffff' : '#000000' }], accessibilityRole: "button", accessibilityLabel: L.done },
|
|
16
|
-
react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.dark ? '#000000' : '#ffffff', size: 24, strokeWidth: 2.2 }))) : (react_1.default.createElement(react_native_1.Pressable, { onPress: onClose, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: L.close },
|
|
16
|
+
const button = closeIcon === 'check' ? (react_1.default.createElement(react_native_1.Pressable, { onPress: onClose, hitSlop: 10, style: [styles.circle, { backgroundColor: colors.strong || (colors.dark ? '#ffffff' : '#000000') }], accessibilityRole: "button", accessibilityLabel: L.done },
|
|
17
|
+
react_1.default.createElement(Icons_1.Icon, { name: "check", color: colors.onStrong || (colors.dark ? '#000000' : '#ffffff'), size: 24, strokeWidth: 2.2 }))) : (react_1.default.createElement(react_native_1.Pressable, { onPress: onClose, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: L.close },
|
|
17
18
|
react_1.default.createElement(Glass_1.Glass, { dark: colors.dark, background: colors.glass, border: colors.glassBorder, style: styles.circle },
|
|
18
19
|
react_1.default.createElement(Icons_1.Icon, { name: "close", color: colors.text, size: 22 }))));
|
|
19
20
|
return (react_1.default.createElement(react_native_1.Modal, { visible: visible, transparent: true, animationType: "slide", onRequestClose: onClose, statusBarTranslucent: true },
|
|
@@ -22,8 +23,8 @@ function Sheet({ visible, title, subtitle, colors, height = '70%', closeIcon = '
|
|
|
22
23
|
react_1.default.createElement(react_native_1.View, { style: styles.header },
|
|
23
24
|
closeIcon === 'x' && button,
|
|
24
25
|
react_1.default.createElement(react_native_1.View, { style: styles.titleBox, pointerEvents: "none" },
|
|
25
|
-
!!title && (react_1.default.createElement(
|
|
26
|
-
!!subtitle && react_1.default.createElement(
|
|
26
|
+
!!title && (react_1.default.createElement(Text_1.Text, { style: [styles.title, { color: colors.text }], numberOfLines: 1, maxFontSizeMultiplier: 1.3, accessibilityRole: "header" }, title)),
|
|
27
|
+
!!subtitle && react_1.default.createElement(Text_1.Text, { style: [styles.subtitle, { color: colors.text }] }, subtitle)),
|
|
27
28
|
react_1.default.createElement(react_native_1.View, { style: { flex: 1 } }),
|
|
28
29
|
closeIcon === 'check' && button),
|
|
29
30
|
children,
|
package/lib/ui/Text.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInput as RNTextInput } from 'react-native';
|
|
3
|
+
import type { TextInputProps, TextProps } from 'react-native';
|
|
4
|
+
import type { UiFonts } from '../types';
|
|
5
|
+
export declare const UiFontsContext: React.Context<UiFonts | null>;
|
|
6
|
+
/** Text of the reader's interface. Uses the host's `uiFonts` when given; a style with its own fontFamily keeps it. */
|
|
7
|
+
export declare function Text(props: TextProps): React.JSX.Element;
|
|
8
|
+
/** Text field of the reader's interface, in the host's regular `uiFonts` font when given. */
|
|
9
|
+
export declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<RNTextInput>>;
|
package/lib/ui/Text.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TextInput = exports.UiFontsContext = void 0;
|
|
37
|
+
exports.Text = Text;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const react_native_1 = require("react-native");
|
|
40
|
+
exports.UiFontsContext = (0, react_1.createContext)(null);
|
|
41
|
+
/** Text of the reader's interface. Uses the host's `uiFonts` when given; a style with its own fontFamily keeps it. */
|
|
42
|
+
function Text(props) {
|
|
43
|
+
const fonts = (0, react_1.useContext)(exports.UiFontsContext);
|
|
44
|
+
if (!fonts)
|
|
45
|
+
return react_1.default.createElement(react_native_1.Text, { ...props });
|
|
46
|
+
const flat = react_native_1.StyleSheet.flatten(props.style) || {};
|
|
47
|
+
if (flat.fontFamily)
|
|
48
|
+
return react_1.default.createElement(react_native_1.Text, { ...props });
|
|
49
|
+
const weight = flat.fontWeight === 'bold' ? 700 : Number(flat.fontWeight) || 400;
|
|
50
|
+
// a font file per weight: the weight is in the family, so the style's weight must not be applied again
|
|
51
|
+
const family = (weight >= 600 && fonts.bold) || (weight >= 500 && fonts.medium) || null;
|
|
52
|
+
const style = family ? { fontFamily: family, fontWeight: 'normal' } : { fontFamily: fonts.regular };
|
|
53
|
+
return react_1.default.createElement(react_native_1.Text, { ...props, style: [props.style, style] });
|
|
54
|
+
}
|
|
55
|
+
/** Text field of the reader's interface, in the host's regular `uiFonts` font when given. */
|
|
56
|
+
exports.TextInput = (0, react_1.forwardRef)(function TextInput(props, ref) {
|
|
57
|
+
const fonts = (0, react_1.useContext)(exports.UiFontsContext);
|
|
58
|
+
const flat = react_native_1.StyleSheet.flatten(props.style) || {};
|
|
59
|
+
if (!fonts || flat.fontFamily)
|
|
60
|
+
return react_1.default.createElement(react_native_1.TextInput, { ref: ref, ...props });
|
|
61
|
+
return react_1.default.createElement(react_native_1.TextInput, { ref: ref, ...props, style: [props.style, { fontFamily: fonts.regular }] });
|
|
62
|
+
});
|
package/package.json
CHANGED
|
@@ -1,76 +1,81 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "aksos-react-native-epub-reader",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A complete EPUB reader for React Native and Expo: page curl and slide, themes, highlights, notes, bookmarks, search, line guide, and full right-to-left support (Pashto, Dari, Persian, Arabic, Urdu).",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react-native",
|
|
7
|
-
"expo",
|
|
8
|
-
"epub",
|
|
9
|
-
"ebook",
|
|
10
|
-
"reader",
|
|
11
|
-
"book",
|
|
12
|
-
"pashto",
|
|
13
|
-
"dari",
|
|
14
|
-
"persian",
|
|
15
|
-
"arabic",
|
|
16
|
-
"rtl",
|
|
17
|
-
"highlight",
|
|
18
|
-
"page-curl"
|
|
19
|
-
],
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"main": "lib/index.js",
|
|
22
|
-
"types": "lib/index.d.ts",
|
|
23
|
-
"react-native": "src/index.ts",
|
|
24
|
-
"source": "src/index.ts",
|
|
25
|
-
"files": [
|
|
26
|
-
"src",
|
|
27
|
-
"lib",
|
|
28
|
-
"README.md",
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"build:
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"react
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"expo-
|
|
52
|
-
"optional": true
|
|
53
|
-
},
|
|
54
|
-
"expo-
|
|
55
|
-
"optional": true
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"react
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "aksos-react-native-epub-reader",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "A complete EPUB reader for React Native and Expo: page curl and slide, themes, highlights, notes, bookmarks, search, line guide, and full right-to-left support (Pashto, Dari, Persian, Arabic, Urdu).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"expo",
|
|
8
|
+
"epub",
|
|
9
|
+
"ebook",
|
|
10
|
+
"reader",
|
|
11
|
+
"book",
|
|
12
|
+
"pashto",
|
|
13
|
+
"dari",
|
|
14
|
+
"persian",
|
|
15
|
+
"arabic",
|
|
16
|
+
"rtl",
|
|
17
|
+
"highlight",
|
|
18
|
+
"page-curl"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"main": "lib/index.js",
|
|
22
|
+
"types": "lib/index.d.ts",
|
|
23
|
+
"react-native": "src/index.ts",
|
|
24
|
+
"source": "src/index.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"lib",
|
|
28
|
+
"README.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build:engine": "node scripts/build-engine.js",
|
|
34
|
+
"build:lib": "node scripts/build-lib.js",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
36
|
+
"prepublishOnly": "npm run build:engine && npm run build:lib",
|
|
37
|
+
"test:harness": "node test/serve.js",
|
|
38
|
+
"test:compat": "node scripts/build-engine.js && node test/compat/make-books.js && node test/compat/run.js",
|
|
39
|
+
"test:features": "node scripts/build-engine.js && node test/compat/make-books.js && node test/compat/features.js"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"expo-audio": "*",
|
|
43
|
+
"expo-blur": "*",
|
|
44
|
+
"expo-screen-orientation": "*",
|
|
45
|
+
"react": ">=18",
|
|
46
|
+
"react-native": ">=0.73",
|
|
47
|
+
"react-native-svg": ">=13",
|
|
48
|
+
"react-native-webview": ">=13"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"expo-audio": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"expo-blur": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"expo-screen-orientation": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/react": "^18.3.0",
|
|
63
|
+
"epubjs": "0.3.93",
|
|
64
|
+
"jszip": "3.10.1",
|
|
65
|
+
"puppeteer-core": "^23.11.1",
|
|
66
|
+
"react": "18.3.1",
|
|
67
|
+
"react-native": "0.76.5",
|
|
68
|
+
"react-native-svg": "15.9.0",
|
|
69
|
+
"react-native-webview": "13.12.5",
|
|
70
|
+
"typescript": "^5.6.0"
|
|
71
|
+
},
|
|
72
|
+
"author": "Aksos",
|
|
73
|
+
"homepage": "https://github.com/AhmadNasary/aksos-react-native-epub-reader#readme",
|
|
74
|
+
"repository": {
|
|
75
|
+
"type": "git",
|
|
76
|
+
"url": "git+https://github.com/AhmadNasary/aksos-react-native-epub-reader.git"
|
|
77
|
+
},
|
|
78
|
+
"bugs": {
|
|
79
|
+
"url": "https://github.com/AhmadNasary/aksos-react-native-epub-reader/issues"
|
|
80
|
+
}
|
|
81
|
+
}
|