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.
Files changed (48) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +178 -20
  3. package/lib/EpubReader.d.ts +66 -15
  4. package/lib/EpubReader.js +168 -30
  5. package/lib/EpubReaderView.d.ts +37 -5
  6. package/lib/EpubReaderView.js +194 -93
  7. package/lib/cfiOrder.d.ts +2 -0
  8. package/lib/cfiOrder.js +34 -0
  9. package/lib/engine/html.js +1 -1
  10. package/lib/index.d.ts +5 -2
  11. package/lib/index.js +5 -1
  12. package/lib/strings.d.ts +94 -0
  13. package/lib/strings.js +96 -0
  14. package/lib/themes.d.ts +28 -6
  15. package/lib/themes.js +80 -20
  16. package/lib/types.d.ts +82 -1
  17. package/lib/ui/AppearanceSheet.d.ts +4 -2
  18. package/lib/ui/AppearanceSheet.js +40 -26
  19. package/lib/ui/ContentsSheet.d.ts +2 -0
  20. package/lib/ui/ContentsSheet.js +32 -22
  21. package/lib/ui/CustomizeSheet.d.ts +4 -2
  22. package/lib/ui/CustomizeSheet.js +31 -27
  23. package/lib/ui/HighlightMenu.d.ts +4 -2
  24. package/lib/ui/HighlightMenu.js +13 -11
  25. package/lib/ui/NoteEditor.js +12 -9
  26. package/lib/ui/SearchSheet.js +19 -6
  27. package/lib/ui/Sheet.js +7 -4
  28. package/lib/ui/Text.d.ts +9 -0
  29. package/lib/ui/Text.js +62 -0
  30. package/package.json +81 -76
  31. package/src/EpubReader.tsx +239 -43
  32. package/src/EpubReaderView.tsx +287 -99
  33. package/src/cfiOrder.ts +28 -0
  34. package/src/engine/epubcfi.js +527 -0
  35. package/src/engine/html.ts +1 -1
  36. package/src/engine/reader.js +1273 -157
  37. package/src/index.ts +5 -2
  38. package/src/strings.ts +187 -0
  39. package/src/themes.ts +97 -21
  40. package/src/types.ts +88 -2
  41. package/src/ui/AppearanceSheet.tsx +47 -29
  42. package/src/ui/ContentsSheet.tsx +34 -22
  43. package/src/ui/CustomizeSheet.tsx +27 -21
  44. package/src/ui/HighlightMenu.tsx +17 -13
  45. package/src/ui/NoteEditor.tsx +12 -9
  46. package/src/ui/SearchSheet.tsx +22 -5
  47. package/src/ui/Sheet.tsx +8 -5
  48. package/src/ui/Text.tsx +27 -0
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.1.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
- "LICENSE"
30
- ],
31
- "scripts": {
32
- "build:engine": "node scripts/build-engine.js",
33
- "build:lib": "node scripts/build-lib.js",
34
- "typecheck": "tsc -p tsconfig.build.json --noEmit",
35
- "prepublishOnly": "npm run build:engine \u0026\u0026 npm run build:lib",
36
- "test:harness": "node test/serve.js"
37
- },
38
- "peerDependencies": {
39
- "expo-audio": "*",
40
- "expo-blur": "*",
41
- "expo-screen-orientation": "*",
42
- "react": "\u003e=18",
43
- "react-native": "\u003e=0.73",
44
- "react-native-svg": "\u003e=13",
45
- "react-native-webview": "\u003e=13"
46
- },
47
- "peerDependenciesMeta": {
48
- "expo-audio": {
49
- "optional": true
50
- },
51
- "expo-blur": {
52
- "optional": true
53
- },
54
- "expo-screen-orientation": {
55
- "optional": true
56
- }
57
- },
58
- "devDependencies": {
59
- "@types/react": "^18.3.0",
60
- "jszip": "3.10.1",
61
- "react": "18.3.1",
62
- "react-native": "0.76.5",
63
- "react-native-svg": "15.9.0",
64
- "react-native-webview": "13.12.5",
65
- "typescript": "^5.6.0"
66
- },
67
- "author": "Aksos",
68
- "homepage": "https://github.com/AhmadNasary/aksos-react-native-epub-reader#readme",
69
- "repository": {
70
- "type": "git",
71
- "url": "git+https://github.com/AhmadNasary/aksos-react-native-epub-reader.git"
72
- },
73
- "bugs": {
74
- "url": "https://github.com/AhmadNasary/aksos-react-native-epub-reader/issues"
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
+ }