react-native-readium 1.0.0-alpha.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/LICENSE +21 -0
- package/README.md +135 -0
- package/android/build.gradle +198 -0
- package/android/gradle.properties +3 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativereadium/ReadiumPackage.kt +17 -0
- package/android/src/main/java/com/reactnativereadium/ReadiumView.kt +84 -0
- package/android/src/main/java/com/reactnativereadium/ReadiumViewManager.kt +80 -0
- package/android/src/main/java/com/reactnativereadium/epub/UserSettings.kt +236 -0
- package/android/src/main/java/com/reactnativereadium/reader/BaseReaderFragment.kt +81 -0
- package/android/src/main/java/com/reactnativereadium/reader/EpubReaderFragment.kt +375 -0
- package/android/src/main/java/com/reactnativereadium/reader/ImageReaderFragment.kt +68 -0
- package/android/src/main/java/com/reactnativereadium/reader/PdfReaderFragment.kt +82 -0
- package/android/src/main/java/com/reactnativereadium/reader/ReaderService.kt +116 -0
- package/android/src/main/java/com/reactnativereadium/reader/ReaderViewModel.kt +120 -0
- package/android/src/main/java/com/reactnativereadium/reader/VisualReaderFragment.kt +78 -0
- package/android/src/main/java/com/reactnativereadium/search/SearchFragment.kt +100 -0
- package/android/src/main/java/com/reactnativereadium/search/SearchPagingSource.kt +44 -0
- package/android/src/main/java/com/reactnativereadium/search/SearchResultAdapter.kt +68 -0
- package/android/src/main/java/com/reactnativereadium/utils/ContentResolverUtil.kt +156 -0
- package/android/src/main/java/com/reactnativereadium/utils/Dimensions.kt +6 -0
- package/android/src/main/java/com/reactnativereadium/utils/EventChannel.kt +61 -0
- package/android/src/main/java/com/reactnativereadium/utils/FragmentFactory.kt +46 -0
- package/android/src/main/java/com/reactnativereadium/utils/R2DispatcherActivity.kt +45 -0
- package/android/src/main/java/com/reactnativereadium/utils/SectionDecoration.kt +98 -0
- package/android/src/main/java/com/reactnativereadium/utils/SingleClickListener.kt +32 -0
- package/android/src/main/java/com/reactnativereadium/utils/SystemUiManagement.kt +63 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Bitmap.kt +23 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Context.kt +16 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/File.kt +22 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/InputStream.kt +23 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Link.kt +6 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Metadata.kt +6 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/URL.kt +29 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Uri.kt +17 -0
- package/android/src/main/res/drawable/background_action_mode.xml +6 -0
- package/android/src/main/res/drawable/cnl.png +0 -0
- package/android/src/main/res/drawable/cover.png +0 -0
- package/android/src/main/res/drawable/ic_add_white_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_baseline_arrow_forward_24.xml +5 -0
- package/android/src/main/res/drawable/ic_baseline_bookmark_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_delete_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_edit_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_enhanced_encryption_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_fast_forward_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_fast_rewind_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_headphones_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_pause_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_play_arrow_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_search_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_skip_next_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_skip_previous_24.xml +10 -0
- package/android/src/main/res/drawable/ic_dashboard_black_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_fastforward_30.xml +7 -0
- package/android/src/main/res/drawable/ic_info_black_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_local_library_black_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_notch.xml +4 -0
- package/android/src/main/res/drawable/ic_outline_add_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_format_align_justify_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_format_align_left_24.xml +11 -0
- package/android/src/main/res/drawable/ic_outline_format_size_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_light_mode_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_menu_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_remove_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_wb_sunny_24.xml +10 -0
- package/android/src/main/res/drawable/ic_rewind_30.xml +7 -0
- package/android/src/main/res/drawable/icon_font_decrease.png +0 -0
- package/android/src/main/res/drawable/icon_font_increase.png +0 -0
- package/android/src/main/res/drawable/icon_overflow.png +0 -0
- package/android/src/main/res/drawable/rbtn_selector.xml +25 -0
- package/android/src/main/res/drawable/rbtn_textcolor_selector.xml +16 -0
- package/android/src/main/res/drawable/repfr.png +0 -0
- package/android/src/main/res/drawable/selector_blue.xml +42 -0
- package/android/src/main/res/drawable/selector_green.xml +42 -0
- package/android/src/main/res/drawable/selector_purple.xml +42 -0
- package/android/src/main/res/drawable/selector_red.xml +42 -0
- package/android/src/main/res/drawable/selector_yellow.xml +41 -0
- package/android/src/main/res/layout/activity_epub.xml +23 -0
- package/android/src/main/res/layout/activity_main.xml +32 -0
- package/android/src/main/res/layout/activity_reader.xml +6 -0
- package/android/src/main/res/layout/add_catalog_dialog.xml +25 -0
- package/android/src/main/res/layout/filter_row.xml +34 -0
- package/android/src/main/res/layout/filter_window.xml +24 -0
- package/android/src/main/res/layout/fragment_about.xml +150 -0
- package/android/src/main/res/layout/fragment_audiobook.xml +151 -0
- package/android/src/main/res/layout/fragment_bookshelf.xml +35 -0
- package/android/src/main/res/layout/fragment_catalog.xml +56 -0
- package/android/src/main/res/layout/fragment_catalog_feed_list.xml +27 -0
- package/android/src/main/res/layout/fragment_drm_management.xml +284 -0
- package/android/src/main/res/layout/fragment_listview.xml +24 -0
- package/android/src/main/res/layout/fragment_outline.xml +31 -0
- package/android/src/main/res/layout/fragment_publication_detail.xml +55 -0
- package/android/src/main/res/layout/fragment_reader.xml +6 -0
- package/android/src/main/res/layout/fragment_screen_reader.xml +143 -0
- package/android/src/main/res/layout/fragment_search.xml +39 -0
- package/android/src/main/res/layout/item_group_view.xml +22 -0
- package/android/src/main/res/layout/item_recycle_book.xml +55 -0
- package/android/src/main/res/layout/item_recycle_bookmark.xml +72 -0
- package/android/src/main/res/layout/item_recycle_button.xml +23 -0
- package/android/src/main/res/layout/item_recycle_catalog.xml +56 -0
- package/android/src/main/res/layout/item_recycle_highlight.xml +85 -0
- package/android/src/main/res/layout/item_recycle_horizontal.xml +45 -0
- package/android/src/main/res/layout/item_recycle_navigation.xml +34 -0
- package/android/src/main/res/layout/item_recycle_search.xml +14 -0
- package/android/src/main/res/layout/item_spinner_days.xml +19 -0
- package/android/src/main/res/layout/my_fragment.xml +13 -0
- package/android/src/main/res/layout/popup_delete.xml +29 -0
- package/android/src/main/res/layout/popup_note.xml +105 -0
- package/android/src/main/res/layout/popup_passphrase.xml +126 -0
- package/android/src/main/res/layout/popup_window_user_settings.xml +576 -0
- package/android/src/main/res/layout/section_header.xml +25 -0
- package/android/src/main/res/layout/view_action_mode.xml +100 -0
- package/android/src/main/res/layout/view_action_mode_reverse.xml +99 -0
- package/android/src/main/res/menu/bottom_nav_menu.xml +19 -0
- package/android/src/main/res/menu/menu_action_mode.xml +26 -0
- package/android/src/main/res/menu/menu_bookmark.xml +18 -0
- package/android/src/main/res/menu/menu_epub.xml +41 -0
- package/android/src/main/res/menu/menu_filter.xml +21 -0
- package/android/src/main/res/menu/menu_reader.xml +33 -0
- package/android/src/main/res/navigation/navigation.xml +46 -0
- package/android/src/main/res/values/arrays.xml +18 -0
- package/android/src/main/res/values/colors.xml +22 -0
- package/android/src/main/res/values/refs.xml +5 -0
- package/android/src/main/res/values/strings.xml +200 -0
- package/android/src/main/res/values/styles.xml +46 -0
- package/android/src/main/res/xml/network_security_config.xml +38 -0
- package/ios/App/AppModule.swift +62 -0
- package/ios/Common/Paths.swift +52 -0
- package/ios/Common/Publication.swift +15 -0
- package/ios/Common/Toolkit/Extensions/AnyPublisher.swift +14 -0
- package/ios/Common/Toolkit/Extensions/Future.swift +16 -0
- package/ios/Common/Toolkit/Extensions/HTTPClient.swift +65 -0
- package/ios/Common/Toolkit/Extensions/Locator.swift +14 -0
- package/ios/Common/Toolkit/Extensions/String.swift +16 -0
- package/ios/Common/Toolkit/Extensions/UIImage.swift +12 -0
- package/ios/Common/Toolkit/Extensions/UIViewController.swift +19 -0
- package/ios/Common/Toolkit/ScreenOrientation.swift +13 -0
- package/ios/Data/Bookmark.swift +23 -0
- package/ios/Reader/Common/ReaderViewController.swift +309 -0
- package/ios/Reader/EPUB/AssociatedColors.swift +27 -0
- package/ios/Reader/EPUB/EPUBModule.swift +38 -0
- package/ios/Reader/EPUB/EPUBViewController.swift +79 -0
- package/ios/Reader/ReaderError.swift +25 -0
- package/ios/Reader/ReaderFormatModule.swift +27 -0
- package/ios/Reader/ReaderModule.swift +84 -0
- package/ios/Reader/ReaderService.swift +126 -0
- package/ios/Readium-Bridging-Header.h +2 -0
- package/ios/Readium.xcodeproj/project.pbxproj +293 -0
- package/ios/ReadiumView.swift +156 -0
- package/ios/ReadiumViewManager.m +10 -0
- package/ios/ReadiumViewManager.swift +9 -0
- package/lib/commonjs/enums/Appearance.js +16 -0
- package/lib/commonjs/enums/Appearance.js.map +1 -0
- package/lib/commonjs/enums/ColumnCount.js +16 -0
- package/lib/commonjs/enums/ColumnCount.js.map +1 -0
- package/lib/commonjs/enums/FontFamily.js +21 -0
- package/lib/commonjs/enums/FontFamily.js.map +1 -0
- package/lib/commonjs/enums/TextAlignment.js +15 -0
- package/lib/commonjs/enums/TextAlignment.js.map +1 -0
- package/lib/commonjs/enums/index.js +58 -0
- package/lib/commonjs/enums/index.js.map +1 -0
- package/lib/commonjs/index.js +105 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/interfaces/Dimensions.js +2 -0
- package/lib/commonjs/interfaces/Dimensions.js.map +1 -0
- package/lib/commonjs/interfaces/File.js +6 -0
- package/lib/commonjs/interfaces/File.js.map +1 -0
- package/lib/commonjs/interfaces/Locator.js +2 -0
- package/lib/commonjs/interfaces/Locator.js.map +1 -0
- package/lib/commonjs/interfaces/Settings.js +71 -0
- package/lib/commonjs/interfaces/Settings.js.map +1 -0
- package/lib/commonjs/interfaces/index.js +58 -0
- package/lib/commonjs/interfaces/index.js.map +1 -0
- package/lib/commonjs/utils/index.js +30 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/enums/Appearance.js +9 -0
- package/lib/module/enums/Appearance.js.map +1 -0
- package/lib/module/enums/ColumnCount.js +9 -0
- package/lib/module/enums/ColumnCount.js.map +1 -0
- package/lib/module/enums/FontFamily.js +14 -0
- package/lib/module/enums/FontFamily.js.map +1 -0
- package/lib/module/enums/TextAlignment.js +8 -0
- package/lib/module/enums/TextAlignment.js.map +1 -0
- package/lib/module/enums/index.js +5 -0
- package/lib/module/enums/index.js.map +1 -0
- package/lib/module/index.js +61 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/interfaces/Dimensions.js +2 -0
- package/lib/module/interfaces/Dimensions.js.map +1 -0
- package/lib/module/interfaces/File.js +2 -0
- package/lib/module/interfaces/File.js.map +1 -0
- package/lib/module/interfaces/Locator.js +2 -0
- package/lib/module/interfaces/Locator.js.map +1 -0
- package/lib/module/interfaces/Settings.js +61 -0
- package/lib/module/interfaces/Settings.js.map +1 -0
- package/lib/module/interfaces/index.js +5 -0
- package/lib/module/interfaces/index.js.map +1 -0
- package/lib/module/utils/index.js +17 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/enums/Appearance.d.ts +11 -0
- package/lib/typescript/enums/ColumnCount.d.ts +5 -0
- package/lib/typescript/enums/FontFamily.d.ts +10 -0
- package/lib/typescript/enums/TextAlignment.d.ts +4 -0
- package/lib/typescript/enums/index.d.ts +4 -0
- package/lib/typescript/index.d.ts +17 -0
- package/lib/typescript/interfaces/Dimensions.d.ts +4 -0
- package/lib/typescript/interfaces/File.d.ts +11 -0
- package/lib/typescript/interfaces/Locator.d.ts +14 -0
- package/lib/typescript/interfaces/Settings.d.ts +40 -0
- package/lib/typescript/interfaces/index.d.ts +4 -0
- package/lib/typescript/utils/index.d.ts +10 -0
- package/package.json +160 -0
- package/react-native-readium.podspec +25 -0
- package/src/enums/Appearance.ts +14 -0
- package/src/enums/ColumnCount.ts +6 -0
- package/src/enums/FontFamily.ts +11 -0
- package/src/enums/TextAlignment.ts +5 -0
- package/src/enums/index.ts +4 -0
- package/src/index.tsx +78 -0
- package/src/interfaces/Dimensions.ts +4 -0
- package/src/interfaces/File.ts +14 -0
- package/src/interfaces/Locator.ts +14 -0
- package/src/interfaces/Settings.ts +85 -0
- package/src/interfaces/index.ts +4 -0
- package/src/utils/index.ts +18 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const RANGES = {
|
|
2
|
+
fontSize: [100.0, 300.0],
|
|
3
|
+
wordSpacing: [0.0, 0.5],
|
|
4
|
+
letterSpacing: [0.0, 0.5],
|
|
5
|
+
pageMargins: [0.5, 4.0],
|
|
6
|
+
lineHeight: [1.0, 2.0],
|
|
7
|
+
paragraphMargins: [0.0, 2.0]
|
|
8
|
+
};
|
|
9
|
+
export const indexOfObjectValue = (obj, val) => {
|
|
10
|
+
return Object.values(obj).indexOf(val);
|
|
11
|
+
};
|
|
12
|
+
export const clamp = (val, lower, upper) => {
|
|
13
|
+
if (val < lower) return lower;
|
|
14
|
+
if (val > upper) return upper;
|
|
15
|
+
return val;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["RANGES","fontSize","wordSpacing","letterSpacing","pageMargins","lineHeight","paragraphMargins","indexOfObjectValue","obj","val","Object","values","indexOf","clamp","lower","upper"],"mappings":"AAAA,OAAO,MAAMA,MAAM,GAAG;AACpBC,EAAAA,QAAQ,EAAU,CAAC,KAAD,EAAQ,KAAR,CADE;AAEpBC,EAAAA,WAAW,EAAO,CAAC,GAAD,EAAM,GAAN,CAFE;AAGpBC,EAAAA,aAAa,EAAK,CAAC,GAAD,EAAM,GAAN,CAHE;AAIpBC,EAAAA,WAAW,EAAO,CAAC,GAAD,EAAM,GAAN,CAJE;AAKpBC,EAAAA,UAAU,EAAQ,CAAC,GAAD,EAAM,GAAN,CALE;AAMpBC,EAAAA,gBAAgB,EAAE,CAAC,GAAD,EAAM,GAAN;AANE,CAAf;AASP,OAAO,MAAMC,kBAAkB,GAAG,CAACC,GAAD,EAAWC,GAAX,KAAgC;AAChE,SAAOC,MAAM,CAACC,MAAP,CAAcH,GAAd,EAAmBI,OAAnB,CAA2BH,GAA3B,CAAP;AACD,CAFM;AAIP,OAAO,MAAMI,KAAK,GAAG,CAACJ,GAAD,EAAcK,KAAd,EAA6BC,KAA7B,KAAuD;AAC1E,MAAIN,GAAG,GAAGK,KAAV,EAAiB,OAAOA,KAAP;AACjB,MAAIL,GAAG,GAAGM,KAAV,EAAiB,OAAOA,KAAP;AACjB,SAAON,GAAP;AACD,CAJM","sourcesContent":["export const RANGES = {\n fontSize: [100.0, 300.0],\n wordSpacing: [0.0, 0.5],\n letterSpacing: [0.0, 0.5],\n pageMargins: [0.5, 4.0],\n lineHeight: [1.0, 2.0],\n paragraphMargins: [0.0, 2.0],\n}\n\nexport const indexOfObjectValue = (obj: any, val: any): number => {\n return Object.values(obj).indexOf(val);\n}\n\nexport const clamp = (val: number, lower: number, upper: number): number => {\n if (val < lower) return lower;\n if (val > upper) return upper;\n return val;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum FontFamily {
|
|
2
|
+
ORIGINAL = "Original",
|
|
3
|
+
HELVETICA_NEUE = "Helvetica Neue",
|
|
4
|
+
IOWAN_OLD_STYLE = "Iowan Old Style",
|
|
5
|
+
ATHELAS = "Athelas",
|
|
6
|
+
SERAVEK = "Seravek",
|
|
7
|
+
OPEN_DYSLEXIC = "OpenDyslexic",
|
|
8
|
+
ACCESSIBLE_DFA = "AccessibleDfA",
|
|
9
|
+
IA_WRITER_DUOSPACE = "IA Writer Duospace"
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import type { Locator, File } from './interfaces';
|
|
4
|
+
import { Settings } from './interfaces';
|
|
5
|
+
export * from './enums';
|
|
6
|
+
export * from './interfaces';
|
|
7
|
+
declare type ReadiumProps = {
|
|
8
|
+
file: File;
|
|
9
|
+
location?: Locator;
|
|
10
|
+
settings?: Partial<Settings>;
|
|
11
|
+
style?: ViewStyle;
|
|
12
|
+
onLocationChange?: (locator: Locator) => void;
|
|
13
|
+
ref?: any;
|
|
14
|
+
height?: number;
|
|
15
|
+
width?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const ReadiumView: React.FC<ReadiumProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An interface representing the Readium Locator object.
|
|
3
|
+
*/
|
|
4
|
+
export interface Locator {
|
|
5
|
+
href: string;
|
|
6
|
+
type: string;
|
|
7
|
+
target: number;
|
|
8
|
+
title?: string;
|
|
9
|
+
locations: {
|
|
10
|
+
position: number;
|
|
11
|
+
progression: number;
|
|
12
|
+
totalProgression: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Appearance, FontFamily, TextAlignment, ColumnCount } from '../enums';
|
|
2
|
+
/**
|
|
3
|
+
* A reader settings object with sensible defaults.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Settings {
|
|
6
|
+
appearance: Appearance;
|
|
7
|
+
fontFamily: FontFamily;
|
|
8
|
+
textAlign: TextAlignment;
|
|
9
|
+
colCount: ColumnCount;
|
|
10
|
+
scroll: boolean;
|
|
11
|
+
fontOverride: boolean;
|
|
12
|
+
verticalScroll: boolean;
|
|
13
|
+
bodyHyphens: boolean;
|
|
14
|
+
advancedSettings: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Range: 100.0 - 300.0
|
|
17
|
+
*/
|
|
18
|
+
fontSize: number;
|
|
19
|
+
/**
|
|
20
|
+
* Range: 0.0 - 0.5
|
|
21
|
+
*/
|
|
22
|
+
wordSpacing: number;
|
|
23
|
+
/**
|
|
24
|
+
* Range: 0.0 - 0.5
|
|
25
|
+
*/
|
|
26
|
+
letterSpacing: number;
|
|
27
|
+
/**
|
|
28
|
+
* Range: 0.5 - 4.0
|
|
29
|
+
*/
|
|
30
|
+
pageMargins: number;
|
|
31
|
+
/**
|
|
32
|
+
* Range: 1.0 - 2.0
|
|
33
|
+
*/
|
|
34
|
+
lineHeight: number;
|
|
35
|
+
/**
|
|
36
|
+
* Range: 0.0 - 2.0
|
|
37
|
+
*/
|
|
38
|
+
paragraphMargins?: number;
|
|
39
|
+
static map(settings: Partial<Settings>): any;
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const RANGES: {
|
|
2
|
+
fontSize: number[];
|
|
3
|
+
wordSpacing: number[];
|
|
4
|
+
letterSpacing: number[];
|
|
5
|
+
pageMargins: number[];
|
|
6
|
+
lineHeight: number[];
|
|
7
|
+
paragraphMargins: number[];
|
|
8
|
+
};
|
|
9
|
+
export declare const indexOfObjectValue: (obj: any, val: any) => number;
|
|
10
|
+
export declare const clamp: (val: number, lower: number, upper: number) => number;
|
package/package.json
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-readium",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"description": "A react-native wrapper for https://readium.org/",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"react-native-readium.podspec",
|
|
17
|
+
"!lib/typescript/example",
|
|
18
|
+
"!android/build",
|
|
19
|
+
"!ios/build",
|
|
20
|
+
"!**/__tests__",
|
|
21
|
+
"!**/__fixtures__",
|
|
22
|
+
"!**/__mocks__"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"typescript": "tsc --noEmit",
|
|
27
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
28
|
+
"prepare": "bob build",
|
|
29
|
+
"release": "release-it",
|
|
30
|
+
"example": "yarn --cwd example",
|
|
31
|
+
"pods": "cd example && pod-install --quiet",
|
|
32
|
+
"bootstrap": "yarn example && yarn && yarn pods",
|
|
33
|
+
"version": "yarn changelog && git add CHANGELOG.md",
|
|
34
|
+
"postversion": "npm run publish:git && npm run publish:npm",
|
|
35
|
+
"publish:git": "git push && git push --tags",
|
|
36
|
+
"publish:npm": "yarn publish --access public --new-version $npm_package_version",
|
|
37
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"react-native",
|
|
41
|
+
"ios",
|
|
42
|
+
"android",
|
|
43
|
+
"readium",
|
|
44
|
+
"ebook",
|
|
45
|
+
"epub",
|
|
46
|
+
"ereader",
|
|
47
|
+
"e-reader",
|
|
48
|
+
"read"
|
|
49
|
+
],
|
|
50
|
+
"repository": "http://github.com/5-stones/react-native-readium",
|
|
51
|
+
"author": "Jacob Spizziri <jspizziri@weare5stones.com> (https://github.com/jspizziri)",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "http://github.com/5-stones/react-native-readium/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "http://github.com/5-stones/react-native-readium#readme",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"registry": "https://registry.npmjs.org/"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@commitlint/config-conventional": "^11.0.0",
|
|
62
|
+
"@react-native-community/eslint-config": "^2.0.0",
|
|
63
|
+
"@release-it/conventional-changelog": "^2.0.0",
|
|
64
|
+
"@types/jest": "^26.0.0",
|
|
65
|
+
"@types/react": "^16.9.19",
|
|
66
|
+
"@types/react-native": "0.62.13",
|
|
67
|
+
"commitlint": "^11.0.0",
|
|
68
|
+
"conventional-changelog-cli": "^2.2.2",
|
|
69
|
+
"eslint": "^7.2.0",
|
|
70
|
+
"eslint-config-prettier": "^7.0.0",
|
|
71
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
72
|
+
"husky": "^6.0.0",
|
|
73
|
+
"jest": "^26.0.1",
|
|
74
|
+
"pod-install": "^0.1.0",
|
|
75
|
+
"prettier": "^2.0.5",
|
|
76
|
+
"react": "16.13.1",
|
|
77
|
+
"react-native": "0.63.4",
|
|
78
|
+
"react-native-builder-bob": "^0.18.2",
|
|
79
|
+
"release-it": "^14.2.2",
|
|
80
|
+
"typescript": "^4.1.3"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"react": "*",
|
|
84
|
+
"react-native": "*"
|
|
85
|
+
},
|
|
86
|
+
"jest": {
|
|
87
|
+
"preset": "react-native",
|
|
88
|
+
"modulePathIgnorePatterns": [
|
|
89
|
+
"<rootDir>/example/node_modules",
|
|
90
|
+
"<rootDir>/lib/"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"commitlint": {
|
|
94
|
+
"extends": [
|
|
95
|
+
"@commitlint/config-conventional"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
"release-it": {
|
|
99
|
+
"git": {
|
|
100
|
+
"commitMessage": "chore: release ${version}",
|
|
101
|
+
"tagName": "v${version}"
|
|
102
|
+
},
|
|
103
|
+
"npm": {
|
|
104
|
+
"publish": true
|
|
105
|
+
},
|
|
106
|
+
"github": {
|
|
107
|
+
"release": true
|
|
108
|
+
},
|
|
109
|
+
"plugins": {
|
|
110
|
+
"@release-it/conventional-changelog": {
|
|
111
|
+
"preset": "angular"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"eslintConfig": {
|
|
116
|
+
"root": true,
|
|
117
|
+
"extends": [
|
|
118
|
+
"@react-native-community",
|
|
119
|
+
"prettier"
|
|
120
|
+
],
|
|
121
|
+
"rules": {
|
|
122
|
+
"prettier/prettier": [
|
|
123
|
+
"error",
|
|
124
|
+
{
|
|
125
|
+
"quoteProps": "consistent",
|
|
126
|
+
"singleQuote": true,
|
|
127
|
+
"tabWidth": 2,
|
|
128
|
+
"trailingComma": "es5",
|
|
129
|
+
"useTabs": false
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"eslintIgnore": [
|
|
135
|
+
"node_modules/",
|
|
136
|
+
"lib/"
|
|
137
|
+
],
|
|
138
|
+
"prettier": {
|
|
139
|
+
"quoteProps": "consistent",
|
|
140
|
+
"singleQuote": true,
|
|
141
|
+
"tabWidth": 2,
|
|
142
|
+
"trailingComma": "es5",
|
|
143
|
+
"useTabs": false
|
|
144
|
+
},
|
|
145
|
+
"react-native-builder-bob": {
|
|
146
|
+
"source": "src",
|
|
147
|
+
"output": "lib",
|
|
148
|
+
"targets": [
|
|
149
|
+
"commonjs",
|
|
150
|
+
"module",
|
|
151
|
+
[
|
|
152
|
+
"typescript",
|
|
153
|
+
{
|
|
154
|
+
"project": "tsconfig.build.json"
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"dependencies": {}
|
|
160
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "react-native-readium"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "13.0" }
|
|
14
|
+
s.source = { :git => "http://github.com/5-stones/react-native-readium.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
|
+
|
|
18
|
+
s.dependency "React-Core"
|
|
19
|
+
|
|
20
|
+
# this is an issue as these aren't currently published on cocoapods.org
|
|
21
|
+
s.dependency "R2Shared"
|
|
22
|
+
s.dependency "R2Streamer"
|
|
23
|
+
s.dependency "R2Navigator"
|
|
24
|
+
s.dependency "ReadiumOPDS"
|
|
25
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// NOTE: readium uses an index so the order is very important here
|
|
2
|
+
export enum Appearance {
|
|
3
|
+
/**
|
|
4
|
+
* A traditional "light" mode
|
|
5
|
+
*/
|
|
6
|
+
DEFAULT = 'readium-default-on',
|
|
7
|
+
|
|
8
|
+
SEPIA = 'readium-sepia-on',
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A traditional "dark" mode
|
|
12
|
+
*/
|
|
13
|
+
NIGHT = 'readium-night-on',
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// NOTE: readium uses an index so the order is very important here
|
|
2
|
+
export enum FontFamily {
|
|
3
|
+
ORIGINAL = 'Original',
|
|
4
|
+
HELVETICA_NEUE = 'Helvetica Neue',
|
|
5
|
+
IOWAN_OLD_STYLE = 'Iowan Old Style',
|
|
6
|
+
ATHELAS = 'Athelas',
|
|
7
|
+
SERAVEK = 'Seravek',
|
|
8
|
+
OPEN_DYSLEXIC = 'OpenDyslexic',
|
|
9
|
+
ACCESSIBLE_DFA = 'AccessibleDfA',
|
|
10
|
+
IA_WRITER_DUOSPACE = 'IA Writer Duospace',
|
|
11
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
requireNativeComponent,
|
|
4
|
+
UIManager,
|
|
5
|
+
Platform,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
View,
|
|
8
|
+
PixelRatio,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
|
|
11
|
+
import type { Locator, File, Dimensions } from './interfaces';
|
|
12
|
+
import { Settings } from './interfaces';
|
|
13
|
+
|
|
14
|
+
export * from './enums';
|
|
15
|
+
export * from './interfaces';
|
|
16
|
+
|
|
17
|
+
const LINKING_ERROR =
|
|
18
|
+
`The package 'react-native-readium' doesn't seem to be linked. Make sure: \n\n` +
|
|
19
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
20
|
+
'- You rebuilt the app after installing the package\n' +
|
|
21
|
+
'- You are not using Expo managed workflow\n';
|
|
22
|
+
|
|
23
|
+
type ReadiumProps = {
|
|
24
|
+
file: File;
|
|
25
|
+
location?: Locator;
|
|
26
|
+
settings?: Partial<Settings>;
|
|
27
|
+
style?: ViewStyle;
|
|
28
|
+
onLocationChange?: (locator: Locator) => void;
|
|
29
|
+
ref?: any;
|
|
30
|
+
height?: number;
|
|
31
|
+
width?: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const ComponentName = 'ReadiumView';
|
|
35
|
+
|
|
36
|
+
const BaseReadiumView =
|
|
37
|
+
UIManager.getViewManagerConfig(ComponentName) != null
|
|
38
|
+
? requireNativeComponent<ReadiumProps>(ComponentName)
|
|
39
|
+
: () => {
|
|
40
|
+
throw new Error(LINKING_ERROR);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const ReadiumView: React.FC<ReadiumProps> = ({
|
|
44
|
+
onLocationChange: wrappedOnLocationChange,
|
|
45
|
+
settings: unmappedSettings,
|
|
46
|
+
...props
|
|
47
|
+
}) => {
|
|
48
|
+
|
|
49
|
+
const [{ height, width }, setDimensions] = useState<Dimensions>({
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
});
|
|
53
|
+
const onLocationChange = useCallback((event: any) => {
|
|
54
|
+
if (wrappedOnLocationChange) {
|
|
55
|
+
wrappedOnLocationChange(event.nativeEvent);
|
|
56
|
+
}
|
|
57
|
+
}, [wrappedOnLocationChange]);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<View
|
|
61
|
+
style={{ width: '100%', height: '100%' }}
|
|
62
|
+
onLayout={({ nativeEvent: { layout: { width, height } }}) => {
|
|
63
|
+
setDimensions({
|
|
64
|
+
width: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(width) : width,
|
|
65
|
+
height: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(height) : height,
|
|
66
|
+
})
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<BaseReadiumView
|
|
70
|
+
height={height}
|
|
71
|
+
width={width}
|
|
72
|
+
{...props}
|
|
73
|
+
onLocationChange={onLocationChange}
|
|
74
|
+
settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}
|
|
75
|
+
/>
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An interface representing the Readium Locator object.
|
|
3
|
+
*/
|
|
4
|
+
export interface Locator {
|
|
5
|
+
href: string;
|
|
6
|
+
type: string;
|
|
7
|
+
target: number;
|
|
8
|
+
title?: string;
|
|
9
|
+
locations: {
|
|
10
|
+
position: number;
|
|
11
|
+
progression: number;
|
|
12
|
+
totalProgression: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Appearance,
|
|
3
|
+
FontFamily,
|
|
4
|
+
TextAlignment,
|
|
5
|
+
ColumnCount,
|
|
6
|
+
} from '../enums';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
RANGES,
|
|
10
|
+
indexOfObjectValue,
|
|
11
|
+
clamp,
|
|
12
|
+
} from '../utils';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A reader settings object with sensible defaults.
|
|
16
|
+
*/
|
|
17
|
+
export class Settings {
|
|
18
|
+
// TODO:
|
|
19
|
+
// - ligatures
|
|
20
|
+
// - paraIndent
|
|
21
|
+
appearance: Appearance = Appearance.DEFAULT;
|
|
22
|
+
fontFamily: FontFamily = FontFamily.ORIGINAL;
|
|
23
|
+
textAlign: TextAlignment = TextAlignment.JUSTIFY;
|
|
24
|
+
colCount: ColumnCount = ColumnCount.AUTO;
|
|
25
|
+
|
|
26
|
+
scroll: boolean = false;
|
|
27
|
+
fontOverride: boolean = false;
|
|
28
|
+
verticalScroll: boolean = false;
|
|
29
|
+
bodyHyphens: boolean = false;
|
|
30
|
+
advancedSettings: boolean = true;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Range: 100.0 - 300.0
|
|
34
|
+
*/
|
|
35
|
+
fontSize: number = 100;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Range: 0.0 - 0.5
|
|
39
|
+
*/
|
|
40
|
+
wordSpacing: number = 0;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Range: 0.0 - 0.5
|
|
44
|
+
*/
|
|
45
|
+
letterSpacing: number = 0;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Range: 0.5 - 4.0
|
|
49
|
+
*/
|
|
50
|
+
pageMargins: number = 0;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Range: 1.0 - 2.0
|
|
54
|
+
*/
|
|
55
|
+
lineHeight: number = 1;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Range: 0.0 - 2.0
|
|
59
|
+
*/
|
|
60
|
+
paragraphMargins?: number = 0;
|
|
61
|
+
|
|
62
|
+
static map(settings: Partial<Settings>): any {
|
|
63
|
+
const defaultValues = new Settings();
|
|
64
|
+
const mapped: Record<string, any> = {};
|
|
65
|
+
|
|
66
|
+
Object.keys(defaultValues)
|
|
67
|
+
.forEach((key: string) => {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
mapped[key] = settings[key] !== undefined ? settings[key] : defaultValues[key];
|
|
70
|
+
})
|
|
71
|
+
;
|
|
72
|
+
|
|
73
|
+
mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);
|
|
74
|
+
mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);
|
|
75
|
+
mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);
|
|
76
|
+
mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);
|
|
77
|
+
|
|
78
|
+
Object.keys(RANGES).forEach((key: string) => {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return mapped;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const RANGES = {
|
|
2
|
+
fontSize: [100.0, 300.0],
|
|
3
|
+
wordSpacing: [0.0, 0.5],
|
|
4
|
+
letterSpacing: [0.0, 0.5],
|
|
5
|
+
pageMargins: [0.5, 4.0],
|
|
6
|
+
lineHeight: [1.0, 2.0],
|
|
7
|
+
paragraphMargins: [0.0, 2.0],
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const indexOfObjectValue = (obj: any, val: any): number => {
|
|
11
|
+
return Object.values(obj).indexOf(val);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const clamp = (val: number, lower: number, upper: number): number => {
|
|
15
|
+
if (val < lower) return lower;
|
|
16
|
+
if (val > upper) return upper;
|
|
17
|
+
return val;
|
|
18
|
+
}
|