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.
Files changed (225) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -0
  3. package/android/build.gradle +198 -0
  4. package/android/gradle.properties +3 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/com/reactnativereadium/ReadiumPackage.kt +17 -0
  7. package/android/src/main/java/com/reactnativereadium/ReadiumView.kt +84 -0
  8. package/android/src/main/java/com/reactnativereadium/ReadiumViewManager.kt +80 -0
  9. package/android/src/main/java/com/reactnativereadium/epub/UserSettings.kt +236 -0
  10. package/android/src/main/java/com/reactnativereadium/reader/BaseReaderFragment.kt +81 -0
  11. package/android/src/main/java/com/reactnativereadium/reader/EpubReaderFragment.kt +375 -0
  12. package/android/src/main/java/com/reactnativereadium/reader/ImageReaderFragment.kt +68 -0
  13. package/android/src/main/java/com/reactnativereadium/reader/PdfReaderFragment.kt +82 -0
  14. package/android/src/main/java/com/reactnativereadium/reader/ReaderService.kt +116 -0
  15. package/android/src/main/java/com/reactnativereadium/reader/ReaderViewModel.kt +120 -0
  16. package/android/src/main/java/com/reactnativereadium/reader/VisualReaderFragment.kt +78 -0
  17. package/android/src/main/java/com/reactnativereadium/search/SearchFragment.kt +100 -0
  18. package/android/src/main/java/com/reactnativereadium/search/SearchPagingSource.kt +44 -0
  19. package/android/src/main/java/com/reactnativereadium/search/SearchResultAdapter.kt +68 -0
  20. package/android/src/main/java/com/reactnativereadium/utils/ContentResolverUtil.kt +156 -0
  21. package/android/src/main/java/com/reactnativereadium/utils/Dimensions.kt +6 -0
  22. package/android/src/main/java/com/reactnativereadium/utils/EventChannel.kt +61 -0
  23. package/android/src/main/java/com/reactnativereadium/utils/FragmentFactory.kt +46 -0
  24. package/android/src/main/java/com/reactnativereadium/utils/R2DispatcherActivity.kt +45 -0
  25. package/android/src/main/java/com/reactnativereadium/utils/SectionDecoration.kt +98 -0
  26. package/android/src/main/java/com/reactnativereadium/utils/SingleClickListener.kt +32 -0
  27. package/android/src/main/java/com/reactnativereadium/utils/SystemUiManagement.kt +63 -0
  28. package/android/src/main/java/com/reactnativereadium/utils/extensions/Bitmap.kt +23 -0
  29. package/android/src/main/java/com/reactnativereadium/utils/extensions/Context.kt +16 -0
  30. package/android/src/main/java/com/reactnativereadium/utils/extensions/File.kt +22 -0
  31. package/android/src/main/java/com/reactnativereadium/utils/extensions/InputStream.kt +23 -0
  32. package/android/src/main/java/com/reactnativereadium/utils/extensions/Link.kt +6 -0
  33. package/android/src/main/java/com/reactnativereadium/utils/extensions/Metadata.kt +6 -0
  34. package/android/src/main/java/com/reactnativereadium/utils/extensions/URL.kt +29 -0
  35. package/android/src/main/java/com/reactnativereadium/utils/extensions/Uri.kt +17 -0
  36. package/android/src/main/res/drawable/background_action_mode.xml +6 -0
  37. package/android/src/main/res/drawable/cnl.png +0 -0
  38. package/android/src/main/res/drawable/cover.png +0 -0
  39. package/android/src/main/res/drawable/ic_add_white_24dp.xml +9 -0
  40. package/android/src/main/res/drawable/ic_baseline_arrow_forward_24.xml +5 -0
  41. package/android/src/main/res/drawable/ic_baseline_bookmark_24.xml +10 -0
  42. package/android/src/main/res/drawable/ic_baseline_delete_24.xml +10 -0
  43. package/android/src/main/res/drawable/ic_baseline_edit_24.xml +10 -0
  44. package/android/src/main/res/drawable/ic_baseline_enhanced_encryption_24.xml +10 -0
  45. package/android/src/main/res/drawable/ic_baseline_fast_forward_24.xml +10 -0
  46. package/android/src/main/res/drawable/ic_baseline_fast_rewind_24.xml +10 -0
  47. package/android/src/main/res/drawable/ic_baseline_headphones_24.xml +10 -0
  48. package/android/src/main/res/drawable/ic_baseline_pause_24.xml +10 -0
  49. package/android/src/main/res/drawable/ic_baseline_play_arrow_24.xml +10 -0
  50. package/android/src/main/res/drawable/ic_baseline_search_24.xml +10 -0
  51. package/android/src/main/res/drawable/ic_baseline_skip_next_24.xml +10 -0
  52. package/android/src/main/res/drawable/ic_baseline_skip_previous_24.xml +10 -0
  53. package/android/src/main/res/drawable/ic_dashboard_black_24dp.xml +9 -0
  54. package/android/src/main/res/drawable/ic_fastforward_30.xml +7 -0
  55. package/android/src/main/res/drawable/ic_info_black_24dp.xml +9 -0
  56. package/android/src/main/res/drawable/ic_local_library_black_24dp.xml +9 -0
  57. package/android/src/main/res/drawable/ic_notch.xml +4 -0
  58. package/android/src/main/res/drawable/ic_outline_add_24.xml +10 -0
  59. package/android/src/main/res/drawable/ic_outline_format_align_justify_24.xml +10 -0
  60. package/android/src/main/res/drawable/ic_outline_format_align_left_24.xml +11 -0
  61. package/android/src/main/res/drawable/ic_outline_format_size_24.xml +10 -0
  62. package/android/src/main/res/drawable/ic_outline_light_mode_24.xml +10 -0
  63. package/android/src/main/res/drawable/ic_outline_menu_24.xml +10 -0
  64. package/android/src/main/res/drawable/ic_outline_remove_24.xml +10 -0
  65. package/android/src/main/res/drawable/ic_outline_wb_sunny_24.xml +10 -0
  66. package/android/src/main/res/drawable/ic_rewind_30.xml +7 -0
  67. package/android/src/main/res/drawable/icon_font_decrease.png +0 -0
  68. package/android/src/main/res/drawable/icon_font_increase.png +0 -0
  69. package/android/src/main/res/drawable/icon_overflow.png +0 -0
  70. package/android/src/main/res/drawable/rbtn_selector.xml +25 -0
  71. package/android/src/main/res/drawable/rbtn_textcolor_selector.xml +16 -0
  72. package/android/src/main/res/drawable/repfr.png +0 -0
  73. package/android/src/main/res/drawable/selector_blue.xml +42 -0
  74. package/android/src/main/res/drawable/selector_green.xml +42 -0
  75. package/android/src/main/res/drawable/selector_purple.xml +42 -0
  76. package/android/src/main/res/drawable/selector_red.xml +42 -0
  77. package/android/src/main/res/drawable/selector_yellow.xml +41 -0
  78. package/android/src/main/res/layout/activity_epub.xml +23 -0
  79. package/android/src/main/res/layout/activity_main.xml +32 -0
  80. package/android/src/main/res/layout/activity_reader.xml +6 -0
  81. package/android/src/main/res/layout/add_catalog_dialog.xml +25 -0
  82. package/android/src/main/res/layout/filter_row.xml +34 -0
  83. package/android/src/main/res/layout/filter_window.xml +24 -0
  84. package/android/src/main/res/layout/fragment_about.xml +150 -0
  85. package/android/src/main/res/layout/fragment_audiobook.xml +151 -0
  86. package/android/src/main/res/layout/fragment_bookshelf.xml +35 -0
  87. package/android/src/main/res/layout/fragment_catalog.xml +56 -0
  88. package/android/src/main/res/layout/fragment_catalog_feed_list.xml +27 -0
  89. package/android/src/main/res/layout/fragment_drm_management.xml +284 -0
  90. package/android/src/main/res/layout/fragment_listview.xml +24 -0
  91. package/android/src/main/res/layout/fragment_outline.xml +31 -0
  92. package/android/src/main/res/layout/fragment_publication_detail.xml +55 -0
  93. package/android/src/main/res/layout/fragment_reader.xml +6 -0
  94. package/android/src/main/res/layout/fragment_screen_reader.xml +143 -0
  95. package/android/src/main/res/layout/fragment_search.xml +39 -0
  96. package/android/src/main/res/layout/item_group_view.xml +22 -0
  97. package/android/src/main/res/layout/item_recycle_book.xml +55 -0
  98. package/android/src/main/res/layout/item_recycle_bookmark.xml +72 -0
  99. package/android/src/main/res/layout/item_recycle_button.xml +23 -0
  100. package/android/src/main/res/layout/item_recycle_catalog.xml +56 -0
  101. package/android/src/main/res/layout/item_recycle_highlight.xml +85 -0
  102. package/android/src/main/res/layout/item_recycle_horizontal.xml +45 -0
  103. package/android/src/main/res/layout/item_recycle_navigation.xml +34 -0
  104. package/android/src/main/res/layout/item_recycle_search.xml +14 -0
  105. package/android/src/main/res/layout/item_spinner_days.xml +19 -0
  106. package/android/src/main/res/layout/my_fragment.xml +13 -0
  107. package/android/src/main/res/layout/popup_delete.xml +29 -0
  108. package/android/src/main/res/layout/popup_note.xml +105 -0
  109. package/android/src/main/res/layout/popup_passphrase.xml +126 -0
  110. package/android/src/main/res/layout/popup_window_user_settings.xml +576 -0
  111. package/android/src/main/res/layout/section_header.xml +25 -0
  112. package/android/src/main/res/layout/view_action_mode.xml +100 -0
  113. package/android/src/main/res/layout/view_action_mode_reverse.xml +99 -0
  114. package/android/src/main/res/menu/bottom_nav_menu.xml +19 -0
  115. package/android/src/main/res/menu/menu_action_mode.xml +26 -0
  116. package/android/src/main/res/menu/menu_bookmark.xml +18 -0
  117. package/android/src/main/res/menu/menu_epub.xml +41 -0
  118. package/android/src/main/res/menu/menu_filter.xml +21 -0
  119. package/android/src/main/res/menu/menu_reader.xml +33 -0
  120. package/android/src/main/res/navigation/navigation.xml +46 -0
  121. package/android/src/main/res/values/arrays.xml +18 -0
  122. package/android/src/main/res/values/colors.xml +22 -0
  123. package/android/src/main/res/values/refs.xml +5 -0
  124. package/android/src/main/res/values/strings.xml +200 -0
  125. package/android/src/main/res/values/styles.xml +46 -0
  126. package/android/src/main/res/xml/network_security_config.xml +38 -0
  127. package/ios/App/AppModule.swift +62 -0
  128. package/ios/Common/Paths.swift +52 -0
  129. package/ios/Common/Publication.swift +15 -0
  130. package/ios/Common/Toolkit/Extensions/AnyPublisher.swift +14 -0
  131. package/ios/Common/Toolkit/Extensions/Future.swift +16 -0
  132. package/ios/Common/Toolkit/Extensions/HTTPClient.swift +65 -0
  133. package/ios/Common/Toolkit/Extensions/Locator.swift +14 -0
  134. package/ios/Common/Toolkit/Extensions/String.swift +16 -0
  135. package/ios/Common/Toolkit/Extensions/UIImage.swift +12 -0
  136. package/ios/Common/Toolkit/Extensions/UIViewController.swift +19 -0
  137. package/ios/Common/Toolkit/ScreenOrientation.swift +13 -0
  138. package/ios/Data/Bookmark.swift +23 -0
  139. package/ios/Reader/Common/ReaderViewController.swift +309 -0
  140. package/ios/Reader/EPUB/AssociatedColors.swift +27 -0
  141. package/ios/Reader/EPUB/EPUBModule.swift +38 -0
  142. package/ios/Reader/EPUB/EPUBViewController.swift +79 -0
  143. package/ios/Reader/ReaderError.swift +25 -0
  144. package/ios/Reader/ReaderFormatModule.swift +27 -0
  145. package/ios/Reader/ReaderModule.swift +84 -0
  146. package/ios/Reader/ReaderService.swift +126 -0
  147. package/ios/Readium-Bridging-Header.h +2 -0
  148. package/ios/Readium.xcodeproj/project.pbxproj +293 -0
  149. package/ios/ReadiumView.swift +156 -0
  150. package/ios/ReadiumViewManager.m +10 -0
  151. package/ios/ReadiumViewManager.swift +9 -0
  152. package/lib/commonjs/enums/Appearance.js +16 -0
  153. package/lib/commonjs/enums/Appearance.js.map +1 -0
  154. package/lib/commonjs/enums/ColumnCount.js +16 -0
  155. package/lib/commonjs/enums/ColumnCount.js.map +1 -0
  156. package/lib/commonjs/enums/FontFamily.js +21 -0
  157. package/lib/commonjs/enums/FontFamily.js.map +1 -0
  158. package/lib/commonjs/enums/TextAlignment.js +15 -0
  159. package/lib/commonjs/enums/TextAlignment.js.map +1 -0
  160. package/lib/commonjs/enums/index.js +58 -0
  161. package/lib/commonjs/enums/index.js.map +1 -0
  162. package/lib/commonjs/index.js +105 -0
  163. package/lib/commonjs/index.js.map +1 -0
  164. package/lib/commonjs/interfaces/Dimensions.js +2 -0
  165. package/lib/commonjs/interfaces/Dimensions.js.map +1 -0
  166. package/lib/commonjs/interfaces/File.js +6 -0
  167. package/lib/commonjs/interfaces/File.js.map +1 -0
  168. package/lib/commonjs/interfaces/Locator.js +2 -0
  169. package/lib/commonjs/interfaces/Locator.js.map +1 -0
  170. package/lib/commonjs/interfaces/Settings.js +71 -0
  171. package/lib/commonjs/interfaces/Settings.js.map +1 -0
  172. package/lib/commonjs/interfaces/index.js +58 -0
  173. package/lib/commonjs/interfaces/index.js.map +1 -0
  174. package/lib/commonjs/utils/index.js +30 -0
  175. package/lib/commonjs/utils/index.js.map +1 -0
  176. package/lib/module/enums/Appearance.js +9 -0
  177. package/lib/module/enums/Appearance.js.map +1 -0
  178. package/lib/module/enums/ColumnCount.js +9 -0
  179. package/lib/module/enums/ColumnCount.js.map +1 -0
  180. package/lib/module/enums/FontFamily.js +14 -0
  181. package/lib/module/enums/FontFamily.js.map +1 -0
  182. package/lib/module/enums/TextAlignment.js +8 -0
  183. package/lib/module/enums/TextAlignment.js.map +1 -0
  184. package/lib/module/enums/index.js +5 -0
  185. package/lib/module/enums/index.js.map +1 -0
  186. package/lib/module/index.js +61 -0
  187. package/lib/module/index.js.map +1 -0
  188. package/lib/module/interfaces/Dimensions.js +2 -0
  189. package/lib/module/interfaces/Dimensions.js.map +1 -0
  190. package/lib/module/interfaces/File.js +2 -0
  191. package/lib/module/interfaces/File.js.map +1 -0
  192. package/lib/module/interfaces/Locator.js +2 -0
  193. package/lib/module/interfaces/Locator.js.map +1 -0
  194. package/lib/module/interfaces/Settings.js +61 -0
  195. package/lib/module/interfaces/Settings.js.map +1 -0
  196. package/lib/module/interfaces/index.js +5 -0
  197. package/lib/module/interfaces/index.js.map +1 -0
  198. package/lib/module/utils/index.js +17 -0
  199. package/lib/module/utils/index.js.map +1 -0
  200. package/lib/typescript/enums/Appearance.d.ts +11 -0
  201. package/lib/typescript/enums/ColumnCount.d.ts +5 -0
  202. package/lib/typescript/enums/FontFamily.d.ts +10 -0
  203. package/lib/typescript/enums/TextAlignment.d.ts +4 -0
  204. package/lib/typescript/enums/index.d.ts +4 -0
  205. package/lib/typescript/index.d.ts +17 -0
  206. package/lib/typescript/interfaces/Dimensions.d.ts +4 -0
  207. package/lib/typescript/interfaces/File.d.ts +11 -0
  208. package/lib/typescript/interfaces/Locator.d.ts +14 -0
  209. package/lib/typescript/interfaces/Settings.d.ts +40 -0
  210. package/lib/typescript/interfaces/index.d.ts +4 -0
  211. package/lib/typescript/utils/index.d.ts +10 -0
  212. package/package.json +160 -0
  213. package/react-native-readium.podspec +25 -0
  214. package/src/enums/Appearance.ts +14 -0
  215. package/src/enums/ColumnCount.ts +6 -0
  216. package/src/enums/FontFamily.ts +11 -0
  217. package/src/enums/TextAlignment.ts +5 -0
  218. package/src/enums/index.ts +4 -0
  219. package/src/index.tsx +78 -0
  220. package/src/interfaces/Dimensions.ts +4 -0
  221. package/src/interfaces/File.ts +14 -0
  222. package/src/interfaces/Locator.ts +14 -0
  223. package/src/interfaces/Settings.ts +85 -0
  224. package/src/interfaces/index.ts +4 -0
  225. package/src/utils/index.ts +18 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _Appearance = require("./Appearance");
8
+
9
+ Object.keys(_Appearance).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _Appearance[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Appearance[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _ColumnCount = require("./ColumnCount");
21
+
22
+ Object.keys(_ColumnCount).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _ColumnCount[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _ColumnCount[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _FontFamily = require("./FontFamily");
34
+
35
+ Object.keys(_FontFamily).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _FontFamily[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _FontFamily[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _TextAlignment = require("./TextAlignment");
47
+
48
+ Object.keys(_TextAlignment).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _TextAlignment[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _TextAlignment[key];
55
+ }
56
+ });
57
+ });
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './Appearance';\nexport * from './ColumnCount';\nexport * from './FontFamily';\nexport * from './TextAlignment';\n"]}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ ReadiumView: true
8
+ };
9
+ exports.ReadiumView = void 0;
10
+
11
+ var _react = _interopRequireWildcard(require("react"));
12
+
13
+ var _reactNative = require("react-native");
14
+
15
+ var _interfaces = require("./interfaces");
16
+
17
+ Object.keys(_interfaces).forEach(function (key) {
18
+ if (key === "default" || key === "__esModule") return;
19
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
+ if (key in exports && exports[key] === _interfaces[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _interfaces[key];
25
+ }
26
+ });
27
+ });
28
+
29
+ var _enums = require("./enums");
30
+
31
+ Object.keys(_enums).forEach(function (key) {
32
+ if (key === "default" || key === "__esModule") return;
33
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
34
+ if (key in exports && exports[key] === _enums[key]) return;
35
+ Object.defineProperty(exports, key, {
36
+ enumerable: true,
37
+ get: function () {
38
+ return _enums[key];
39
+ }
40
+ });
41
+ });
42
+
43
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
44
+
45
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
46
+
47
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
48
+
49
+ const LINKING_ERROR = `The package 'react-native-readium' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
50
+ ios: "- You have run 'pod install'\n",
51
+ default: ''
52
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
53
+ const ComponentName = 'ReadiumView';
54
+ const BaseReadiumView = _reactNative.UIManager.getViewManagerConfig(ComponentName) != null ? (0, _reactNative.requireNativeComponent)(ComponentName) : () => {
55
+ throw new Error(LINKING_ERROR);
56
+ };
57
+
58
+ const ReadiumView = _ref => {
59
+ let {
60
+ onLocationChange: wrappedOnLocationChange,
61
+ settings: unmappedSettings,
62
+ ...props
63
+ } = _ref;
64
+ const [{
65
+ height,
66
+ width
67
+ }, setDimensions] = (0, _react.useState)({
68
+ width: 0,
69
+ height: 0
70
+ });
71
+ const onLocationChange = (0, _react.useCallback)(event => {
72
+ if (wrappedOnLocationChange) {
73
+ wrappedOnLocationChange(event.nativeEvent);
74
+ }
75
+ }, [wrappedOnLocationChange]);
76
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
77
+ style: {
78
+ width: '100%',
79
+ height: '100%'
80
+ },
81
+ onLayout: _ref2 => {
82
+ let {
83
+ nativeEvent: {
84
+ layout: {
85
+ width,
86
+ height
87
+ }
88
+ }
89
+ } = _ref2;
90
+ setDimensions({
91
+ width: _reactNative.Platform.OS === 'android' ? _reactNative.PixelRatio.getPixelSizeForLayoutSize(width) : width,
92
+ height: _reactNative.Platform.OS === 'android' ? _reactNative.PixelRatio.getPixelSizeForLayoutSize(height) : height
93
+ });
94
+ }
95
+ }, /*#__PURE__*/_react.default.createElement(BaseReadiumView, _extends({
96
+ height: height,
97
+ width: width
98
+ }, props, {
99
+ onLocationChange: onLocationChange,
100
+ settings: unmappedSettings ? _interfaces.Settings.map(unmappedSettings) : undefined
101
+ })));
102
+ };
103
+
104
+ exports.ReadiumView = ReadiumView;
105
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.tsx"],"names":["LINKING_ERROR","Platform","select","ios","default","ComponentName","BaseReadiumView","UIManager","getViewManagerConfig","Error","ReadiumView","onLocationChange","wrappedOnLocationChange","settings","unmappedSettings","props","height","width","setDimensions","event","nativeEvent","layout","OS","PixelRatio","getPixelSizeForLayoutSize","Settings","map","undefined"],"mappings":";;;;;;;;;;AAAA;;AACA;;AAUA;;AAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AADA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;AAGA,MAAMA,aAAa,GAChB,+EAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAiBA,MAAMC,aAAa,GAAG,aAAtB;AAEA,MAAMC,eAAe,GACnBC,uBAAUC,oBAAV,CAA+BH,aAA/B,KAAiD,IAAjD,GACI,yCAAqCA,aAArC,CADJ,GAEI,MAAM;AACJ,QAAM,IAAII,KAAJ,CAAUT,aAAV,CAAN;AACD,CALP;;AAOO,MAAMU,WAAmC,G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AASC,GAAT,CAAaZ,gBAAb,CAAH,GAAoCa;AALhE,KATF,CADF;AAmBD,CAnCM","sourcesContent":["import React, { useCallback, useState } from 'react';\nimport {\n requireNativeComponent,\n UIManager,\n Platform,\n ViewStyle,\n View,\n PixelRatio,\n} from 'react-native';\n\nimport type { Locator, File, Dimensions } from './interfaces';\nimport { Settings } from './interfaces';\n\nexport * from './enums';\nexport * from './interfaces';\n\nconst LINKING_ERROR =\n `The package 'react-native-readium' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype ReadiumProps = {\n file: File;\n location?: Locator;\n settings?: Partial<Settings>;\n style?: ViewStyle;\n onLocationChange?: (locator: Locator) => void;\n ref?: any;\n height?: number;\n width?: number;\n};\n\nconst ComponentName = 'ReadiumView';\n\nconst BaseReadiumView =\n UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<ReadiumProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n\nexport const ReadiumView: React.FC<ReadiumProps> = ({\n onLocationChange: wrappedOnLocationChange,\n settings: unmappedSettings,\n ...props\n}) => {\n\n const [{ height, width }, setDimensions] = useState<Dimensions>({\n width: 0,\n height: 0,\n });\n const onLocationChange = useCallback((event: any) => {\n if (wrappedOnLocationChange) {\n wrappedOnLocationChange(event.nativeEvent);\n }\n }, [wrappedOnLocationChange]);\n\n return (\n <View\n style={{ width: '100%', height: '100%' }}\n onLayout={({ nativeEvent: { layout: { width, height } }}) => {\n setDimensions({\n width: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(width) : width,\n height: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(height) : height,\n })\n }}\n >\n <BaseReadiumView\n height={height}\n width={width}\n {...props}\n onLocationChange={onLocationChange}\n settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}\n />\n </View>\n );\n};\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=Dimensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=File.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=Locator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Settings = void 0;
7
+
8
+ var _enums = require("../enums");
9
+
10
+ var _utils = require("../utils");
11
+
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
14
+ /**
15
+ * A reader settings object with sensible defaults.
16
+ */
17
+ class Settings {
18
+ constructor() {
19
+ _defineProperty(this, "appearance", _enums.Appearance.DEFAULT);
20
+
21
+ _defineProperty(this, "fontFamily", _enums.FontFamily.ORIGINAL);
22
+
23
+ _defineProperty(this, "textAlign", _enums.TextAlignment.JUSTIFY);
24
+
25
+ _defineProperty(this, "colCount", _enums.ColumnCount.AUTO);
26
+
27
+ _defineProperty(this, "scroll", false);
28
+
29
+ _defineProperty(this, "fontOverride", false);
30
+
31
+ _defineProperty(this, "verticalScroll", false);
32
+
33
+ _defineProperty(this, "bodyHyphens", false);
34
+
35
+ _defineProperty(this, "advancedSettings", true);
36
+
37
+ _defineProperty(this, "fontSize", 100);
38
+
39
+ _defineProperty(this, "wordSpacing", 0);
40
+
41
+ _defineProperty(this, "letterSpacing", 0);
42
+
43
+ _defineProperty(this, "pageMargins", 0);
44
+
45
+ _defineProperty(this, "lineHeight", 1);
46
+
47
+ _defineProperty(this, "paragraphMargins", 0);
48
+ }
49
+
50
+ static map(settings) {
51
+ const defaultValues = new Settings();
52
+ const mapped = {};
53
+ Object.keys(defaultValues).forEach(key => {
54
+ // @ts-ignore
55
+ mapped[key] = settings[key] !== undefined ? settings[key] : defaultValues[key];
56
+ });
57
+ mapped.appearance = (0, _utils.indexOfObjectValue)(_enums.Appearance, mapped.appearance);
58
+ mapped.fontFamily = (0, _utils.indexOfObjectValue)(_enums.FontFamily, mapped.fontFamily);
59
+ mapped.textAlign = (0, _utils.indexOfObjectValue)(_enums.TextAlignment, mapped.textAlign);
60
+ mapped.colCount = (0, _utils.indexOfObjectValue)(_enums.ColumnCount, mapped.colCount);
61
+ Object.keys(_utils.RANGES).forEach(key => {
62
+ // @ts-ignore
63
+ mapped[key] = (0, _utils.clamp)(mapped[key], _utils.RANGES[key][0], _utils.RANGES[key][1]);
64
+ });
65
+ return mapped;
66
+ }
67
+
68
+ }
69
+
70
+ exports.Settings = Settings;
71
+ //# sourceMappingURL=Settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Settings.ts"],"names":["Settings","Appearance","DEFAULT","FontFamily","ORIGINAL","TextAlignment","JUSTIFY","ColumnCount","AUTO","map","settings","defaultValues","mapped","Object","keys","forEach","key","undefined","appearance","fontFamily","textAlign","colCount","RANGES"],"mappings":";;;;;;;AAAA;;AAOA;;;;AAMA;AACA;AACA;AACO,MAAMA,QAAN,CAAe;AAAA;AAAA,wCAIKC,kBAAWC,OAJhB;;AAAA,wCAKKC,kBAAWC,QALhB;;AAAA,uCAMOC,qBAAcC,OANrB;;AAAA,sCAOIC,mBAAYC,IAPhB;;AAAA,oCASF,KATE;;AAAA,0CAUI,KAVJ;;AAAA,4CAWM,KAXN;;AAAA,yCAYG,KAZH;;AAAA,8CAaQ,IAbR;;AAAA,sCAkBD,GAlBC;;AAAA,yCAuBE,CAvBF;;AAAA,2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clamp,\n} from '../utils';\n\n/**\n * A reader settings object with sensible defaults.\n */\nexport class Settings {\n // TODO:\n // - ligatures\n // - paraIndent\n appearance: Appearance = Appearance.DEFAULT;\n fontFamily: FontFamily = FontFamily.ORIGINAL;\n textAlign: TextAlignment = TextAlignment.JUSTIFY;\n colCount: ColumnCount = ColumnCount.AUTO;\n\n scroll: boolean = false;\n fontOverride: boolean = false;\n verticalScroll: boolean = false;\n bodyHyphens: boolean = false;\n advancedSettings: boolean = true;\n\n /**\n * Range: 100.0 - 300.0\n */\n fontSize: number = 100;\n\n /**\n * Range: 0.0 - 0.5\n */\n wordSpacing: number = 0;\n\n /**\n * Range: 0.0 - 0.5\n */\n letterSpacing: number = 0;\n\n /**\n * Range: 0.5 - 4.0\n */\n pageMargins: number = 0;\n\n /**\n * Range: 1.0 - 2.0\n */\n lineHeight: number = 1;\n\n /**\n * Range: 0.0 - 2.0\n */\n paragraphMargins?: number = 0;\n\n static map(settings: Partial<Settings>): any {\n const defaultValues = new Settings();\n const mapped: Record<string, any> = {};\n\n Object.keys(defaultValues)\n .forEach((key: string) => {\n // @ts-ignore\n mapped[key] = settings[key] !== undefined ? settings[key] : defaultValues[key];\n })\n ;\n\n mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);\n mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);\n mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);\n mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);\n\n Object.keys(RANGES).forEach((key: string) => {\n // @ts-ignore\n mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);\n });\n\n return mapped;\n }\n}\n"]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _Dimensions = require("./Dimensions");
8
+
9
+ Object.keys(_Dimensions).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _Dimensions[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Dimensions[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _File = require("./File");
21
+
22
+ Object.keys(_File).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _File[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _File[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _Locator = require("./Locator");
34
+
35
+ Object.keys(_Locator).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _Locator[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _Locator[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _Settings = require("./Settings");
47
+
48
+ Object.keys(_Settings).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _Settings[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _Settings[key];
55
+ }
56
+ });
57
+ });
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './Dimensions';\nexport * from './File';\nexport * from './Locator';\nexport * from './Settings';\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.indexOfObjectValue = exports.clamp = exports.RANGES = void 0;
7
+ const RANGES = {
8
+ fontSize: [100.0, 300.0],
9
+ wordSpacing: [0.0, 0.5],
10
+ letterSpacing: [0.0, 0.5],
11
+ pageMargins: [0.5, 4.0],
12
+ lineHeight: [1.0, 2.0],
13
+ paragraphMargins: [0.0, 2.0]
14
+ };
15
+ exports.RANGES = RANGES;
16
+
17
+ const indexOfObjectValue = (obj, val) => {
18
+ return Object.values(obj).indexOf(val);
19
+ };
20
+
21
+ exports.indexOfObjectValue = indexOfObjectValue;
22
+
23
+ const clamp = (val, lower, upper) => {
24
+ if (val < lower) return lower;
25
+ if (val > upper) return upper;
26
+ return val;
27
+ };
28
+
29
+ exports.clamp = clamp;
30
+ //# 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":";;;;;;AAAO,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;;;AASA,MAAMC,kBAAkB,GAAG,CAACC,GAAD,EAAWC,GAAX,KAAgC;AAChE,SAAOC,MAAM,CAACC,MAAP,CAAcH,GAAd,EAAmBI,OAAnB,CAA2BH,GAA3B,CAAP;AACD,CAFM;;;;AAIA,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,9 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export let Appearance;
3
+
4
+ (function (Appearance) {
5
+ Appearance["DEFAULT"] = "readium-default-on";
6
+ Appearance["SEPIA"] = "readium-sepia-on";
7
+ Appearance["NIGHT"] = "readium-night-on";
8
+ })(Appearance || (Appearance = {}));
9
+ //# sourceMappingURL=Appearance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Appearance.ts"],"names":["Appearance"],"mappings":"AAAA;AACA,WAAYA,UAAZ;;WAAYA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,KAAAA,U","sourcesContent":["// NOTE: readium uses an index so the order is very important here\nexport enum Appearance {\n /**\n * A traditional \"light\" mode\n */\n DEFAULT = 'readium-default-on',\n\n SEPIA = 'readium-sepia-on',\n\n /**\n * A traditional \"dark\" mode\n */\n NIGHT = 'readium-night-on',\n}\n"]}
@@ -0,0 +1,9 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export let ColumnCount;
3
+
4
+ (function (ColumnCount) {
5
+ ColumnCount["AUTO"] = "auto";
6
+ ColumnCount["ONE"] = "1";
7
+ ColumnCount["TWO"] = "2";
8
+ })(ColumnCount || (ColumnCount = {}));
9
+ //# sourceMappingURL=ColumnCount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ColumnCount.ts"],"names":["ColumnCount"],"mappings":"AAAA;AACA,WAAYA,WAAZ;;WAAYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,W","sourcesContent":["// NOTE: readium uses an index so the order is very important here\nexport enum ColumnCount {\n AUTO = 'auto',\n ONE = '1',\n TWO = '2',\n}\n"]}
@@ -0,0 +1,14 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export let FontFamily;
3
+
4
+ (function (FontFamily) {
5
+ FontFamily["ORIGINAL"] = "Original";
6
+ FontFamily["HELVETICA_NEUE"] = "Helvetica Neue";
7
+ FontFamily["IOWAN_OLD_STYLE"] = "Iowan Old Style";
8
+ FontFamily["ATHELAS"] = "Athelas";
9
+ FontFamily["SERAVEK"] = "Seravek";
10
+ FontFamily["OPEN_DYSLEXIC"] = "OpenDyslexic";
11
+ FontFamily["ACCESSIBLE_DFA"] = "AccessibleDfA";
12
+ FontFamily["IA_WRITER_DUOSPACE"] = "IA Writer Duospace";
13
+ })(FontFamily || (FontFamily = {}));
14
+ //# sourceMappingURL=FontFamily.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FontFamily.ts"],"names":["FontFamily"],"mappings":"AAAA;AACA,WAAYA,UAAZ;;WAAYA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,KAAAA,U","sourcesContent":["// NOTE: readium uses an index so the order is very important here\nexport enum FontFamily {\n ORIGINAL = 'Original',\n HELVETICA_NEUE = 'Helvetica Neue',\n IOWAN_OLD_STYLE = 'Iowan Old Style',\n ATHELAS = 'Athelas',\n SERAVEK = 'Seravek',\n OPEN_DYSLEXIC = 'OpenDyslexic',\n ACCESSIBLE_DFA = 'AccessibleDfA',\n IA_WRITER_DUOSPACE = 'IA Writer Duospace',\n}\n"]}
@@ -0,0 +1,8 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export let TextAlignment;
3
+
4
+ (function (TextAlignment) {
5
+ TextAlignment["JUSTIFY"] = "justify";
6
+ TextAlignment["START"] = "start";
7
+ })(TextAlignment || (TextAlignment = {}));
8
+ //# sourceMappingURL=TextAlignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["TextAlignment.ts"],"names":["TextAlignment"],"mappings":"AAAA;AACA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["// NOTE: readium uses an index so the order is very important here\nexport enum TextAlignment {\n JUSTIFY = 'justify',\n START = 'start',\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './Appearance';
2
+ export * from './ColumnCount';
3
+ export * from './FontFamily';
4
+ export * from './TextAlignment';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,eAAd;AACA,cAAc,cAAd;AACA,cAAc,iBAAd","sourcesContent":["export * from './Appearance';\nexport * from './ColumnCount';\nexport * from './FontFamily';\nexport * from './TextAlignment';\n"]}
@@ -0,0 +1,61 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React, { useCallback, useState } from 'react';
4
+ import { requireNativeComponent, UIManager, Platform, View, PixelRatio } from 'react-native';
5
+ import { Settings } from './interfaces';
6
+ export * from './enums';
7
+ export * from './interfaces';
8
+ const LINKING_ERROR = `The package 'react-native-readium' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
9
+ ios: "- You have run 'pod install'\n",
10
+ default: ''
11
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
12
+ const ComponentName = 'ReadiumView';
13
+ const BaseReadiumView = UIManager.getViewManagerConfig(ComponentName) != null ? requireNativeComponent(ComponentName) : () => {
14
+ throw new Error(LINKING_ERROR);
15
+ };
16
+ export const ReadiumView = _ref => {
17
+ let {
18
+ onLocationChange: wrappedOnLocationChange,
19
+ settings: unmappedSettings,
20
+ ...props
21
+ } = _ref;
22
+ const [{
23
+ height,
24
+ width
25
+ }, setDimensions] = useState({
26
+ width: 0,
27
+ height: 0
28
+ });
29
+ const onLocationChange = useCallback(event => {
30
+ if (wrappedOnLocationChange) {
31
+ wrappedOnLocationChange(event.nativeEvent);
32
+ }
33
+ }, [wrappedOnLocationChange]);
34
+ return /*#__PURE__*/React.createElement(View, {
35
+ style: {
36
+ width: '100%',
37
+ height: '100%'
38
+ },
39
+ onLayout: _ref2 => {
40
+ let {
41
+ nativeEvent: {
42
+ layout: {
43
+ width,
44
+ height
45
+ }
46
+ }
47
+ } = _ref2;
48
+ setDimensions({
49
+ width: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(width) : width,
50
+ height: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(height) : height
51
+ });
52
+ }
53
+ }, /*#__PURE__*/React.createElement(BaseReadiumView, _extends({
54
+ height: height,
55
+ width: width
56
+ }, props, {
57
+ onLocationChange: onLocationChange,
58
+ settings: unmappedSettings ? Settings.map(unmappedSettings) : undefined
59
+ })));
60
+ };
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.tsx"],"names":["React","useCallback","useState","requireNativeComponent","UIManager","Platform","View","PixelRatio","Settings","LINKING_ERROR","select","ios","default","ComponentName","BaseReadiumView","getViewManagerConfig","Error","ReadiumView","onLocationChange","wrappedOnLocationChange","settings","unmappedSettings","props","height","width","setDimensions","event","nativeEvent","layout","OS","getPixelSizeForLayoutSize","map","undef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D,MAAAA,MAAM,EAAE;AAAzB,KADT;AAEE,IAAA,QAAQ,EAAE,SAAmD;AAAA,UAAlD;AAAEI,QAAAA,WAAW,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAEJ,YAAAA,KAAF;AAASD,YAAAA;AAAT;AAAV;AAAf,OAAkD;AAC3DE,MAAAA,aAAa,CAAC;AACZD,QAAAA,KAAK,EAAEnB,QAAQ,CAACwB,EAAT,KAAgB,SAAhB,GAA4BtB,UAAU,CAACuB,yBAAX,CAAqCN,KAArC,CAA5B,GAA0EA,KADrE;AAEZD,QAAAA,MAAM,EAAElB,QAAQ,CAACwB,EAAT,KAAgB,SAAhB,GAA4BtB,UAAU,CAACuB,yBAAX,CAAqCP,MAArC,CAA5B,GAA2EA;AAFvE,OAAD,CAAb;AAID;AAPH,kBASE,oBAAC,eAAD;AACE,IAAA,MAAM,EAAEA,MADV;AAEE,IAAA,KAAK,EAAEC;AAFT,KAGMF,KAHN;AAIE,IAAA,gBAAgB,EAAEJ,gBAJpB;AAKE,IAAA,QAAQ,EAAEG,gBAAgB,GAAGb,QAAQ,CAACuB,GAAT,CAAaV,gBAAb,CAAH,GAAoCW;AALhE,KATF,CADF;AAmBD,CAnCM","sourcesContent":["import React, { useCallback, useState } from 'react';\nimport {\n requireNativeComponent,\n UIManager,\n Platform,\n ViewStyle,\n View,\n PixelRatio,\n} from 'react-native';\n\nimport type { Locator, File, Dimensions } from './interfaces';\nimport { Settings } from './interfaces';\n\nexport * from './enums';\nexport * from './interfaces';\n\nconst LINKING_ERROR =\n `The package 'react-native-readium' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype ReadiumProps = {\n file: File;\n location?: Locator;\n settings?: Partial<Settings>;\n style?: ViewStyle;\n onLocationChange?: (locator: Locator) => void;\n ref?: any;\n height?: number;\n width?: number;\n};\n\nconst ComponentName = 'ReadiumView';\n\nconst BaseReadiumView =\n UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<ReadiumProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n\nexport const ReadiumView: React.FC<ReadiumProps> = ({\n onLocationChange: wrappedOnLocationChange,\n settings: unmappedSettings,\n ...props\n}) => {\n\n const [{ height, width }, setDimensions] = useState<Dimensions>({\n width: 0,\n height: 0,\n });\n const onLocationChange = useCallback((event: any) => {\n if (wrappedOnLocationChange) {\n wrappedOnLocationChange(event.nativeEvent);\n }\n }, [wrappedOnLocationChange]);\n\n return (\n <View\n style={{ width: '100%', height: '100%' }}\n onLayout={({ nativeEvent: { layout: { width, height } }}) => {\n setDimensions({\n width: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(width) : width,\n height: Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(height) : height,\n })\n }}\n >\n <BaseReadiumView\n height={height}\n width={width}\n {...props}\n onLocationChange={onLocationChange}\n settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}\n />\n </View>\n );\n};\n"]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Dimensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=File.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Locator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,61 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { Appearance, FontFamily, TextAlignment, ColumnCount } from '../enums';
4
+ import { RANGES, indexOfObjectValue, clamp } from '../utils';
5
+ /**
6
+ * A reader settings object with sensible defaults.
7
+ */
8
+
9
+ export class Settings {
10
+ constructor() {
11
+ _defineProperty(this, "appearance", Appearance.DEFAULT);
12
+
13
+ _defineProperty(this, "fontFamily", FontFamily.ORIGINAL);
14
+
15
+ _defineProperty(this, "textAlign", TextAlignment.JUSTIFY);
16
+
17
+ _defineProperty(this, "colCount", ColumnCount.AUTO);
18
+
19
+ _defineProperty(this, "scroll", false);
20
+
21
+ _defineProperty(this, "fontOverride", false);
22
+
23
+ _defineProperty(this, "verticalScroll", false);
24
+
25
+ _defineProperty(this, "bodyHyphens", false);
26
+
27
+ _defineProperty(this, "advancedSettings", true);
28
+
29
+ _defineProperty(this, "fontSize", 100);
30
+
31
+ _defineProperty(this, "wordSpacing", 0);
32
+
33
+ _defineProperty(this, "letterSpacing", 0);
34
+
35
+ _defineProperty(this, "pageMargins", 0);
36
+
37
+ _defineProperty(this, "lineHeight", 1);
38
+
39
+ _defineProperty(this, "paragraphMargins", 0);
40
+ }
41
+
42
+ static map(settings) {
43
+ const defaultValues = new Settings();
44
+ const mapped = {};
45
+ Object.keys(defaultValues).forEach(key => {
46
+ // @ts-ignore
47
+ mapped[key] = settings[key] !== undefined ? settings[key] : defaultValues[key];
48
+ });
49
+ mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);
50
+ mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);
51
+ mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);
52
+ mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);
53
+ Object.keys(RANGES).forEach(key => {
54
+ // @ts-ignore
55
+ mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);
56
+ });
57
+ return mapped;
58
+ }
59
+
60
+ }
61
+ //# sourceMappingURL=Settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Settings.ts"],"names":["Appearance","FontFamily","TextAlignment","ColumnCount","RANGES","indexOfObjectValue","clamp","Settings","DEFAULT","ORIGINAL","JUSTIFY","AUTO","map","settings","defaultValues","mapped","Object","keys","forEach","key","undefined","appearance","fontFamily","textAlign","colCount"],"mappings":";;AAAA,SACEA,UADF,EAEEC,UAFF,EAGEC,aAHF,EAIEC,WAJF,QAKO,UALP;AAOA,SACEC,MADF,EAEEC,kBAFF,EAGEC,KAHF,QAIO,UAJP;AAMA;AACA;AACA;;AACA,OAAO,MAAMC,QAAN,CAAe;AAAA;AAAA,wCAIKP,UAAU,CAACQ,OAJhB;;AAAA,wCAKKP,UAAU,CAACQ,QALhB;;AAAA,uCAMOP,aAAa,CAACQ,OANrB;;AAAA,sCAOIP,WAAW,CAACQ,IAPhB;;AAAA,oCASF,KATE;;AAAA,0CAUI,KAVJ;;AAAA,4CAWM,KAXN;;AAAA,yCAYG,KAZH;;AAAA,8CAaQ,IAbR;;AAAA,sCAkBD,GAlBC;;AAAA,yCAuBE,CAvBF;;AAAA,2CA4BI,CA5BJ;;AAAA,yCAiCE,CAjCF;;AAAA,wCAsCC,CAtCD;;AAAA,8CA2CQ,CA3CR;AAAA;;AA6CV,SAAHC,GAAG,CAACC,QAAD,EAAmC;AAC3C,UAAMC,aAAa,GAAG,IAAIP,QAAJ,EAAtB;AACA,UAAMQ,MAA2B,GAAG,EAApC;AAEAC,IAAAA,MAAM,CAACC,IAAP,CAAYH,aAAZ,EACGI,OADH,CACYC,GAAD,IAAiB;AACxB;AACAJ,MAAAA,MAAM,CAACI,GAAD,CAAN,GAAcN,QAAQ,CAACM,GAAD,CAAR,KAAkBC,SAAlB,GAA8BP,QAAQ,CAACM,GAAD,CAAtC,GAA8CL,aAAa,CAACK,GAAD,CAAzE;AACD,KAJH;AAOAJ,IAAAA,MAAM,CAACM,UAAP,GAAoBhB,kBAAkB,CAACL,UAAD,EAAae,MAAM,CAACM,UAApB,CAAtC;AACAN,IAAAA,MAAM,CAACO,UAAP,GAAoBjB,kBAAkB,CAACJ,UAAD,EAAac,MAAM,CAACO,UAApB,CAAtC;AACAP,IAAAA,MAAM,CAACQ,SAAP,GAAmBlB,kBAAkB,CAACH,aAAD,EAAgBa,MAAM,CAACQ,SAAvB,CAArC;AACAR,IAAAA,MAAM,CAACS,QAAP,GAAkBnB,kBAAkB,CAACF,WAAD,EAAcY,MAAM,CAACS,QAArB,CAApC;AAEAR,IAAAA,MAAM,CAACC,IAAP,CAAYb,MAAZ,EAAoBc,OAApB,CAA6BC,GAAD,IAAiB;AAC3C;AACAJ,MAAAA,MAAM,CAACI,GAAD,CAAN,GAAcb,KAAK,CAACS,MAAM,CAACI,GAAD,CAAP,EAAcf,MAAM,CAACe,GAAD,CAAN,CAAY,CAAZ,CAAd,EAA8Bf,MAAM,CAACe,GAAD,CAAN,CAAY,CAAZ,CAA9B,CAAnB;AACD,KAHD;AAKA,WAAOJ,MAAP;AACD;;AAnEmB","sourcesContent":["import {\n Appearance,\n FontFamily,\n TextAlignment,\n ColumnCount,\n} from '../enums';\n\nimport {\n RANGES,\n indexOfObjectValue,\n clamp,\n} from '../utils';\n\n/**\n * A reader settings object with sensible defaults.\n */\nexport class Settings {\n // TODO:\n // - ligatures\n // - paraIndent\n appearance: Appearance = Appearance.DEFAULT;\n fontFamily: FontFamily = FontFamily.ORIGINAL;\n textAlign: TextAlignment = TextAlignment.JUSTIFY;\n colCount: ColumnCount = ColumnCount.AUTO;\n\n scroll: boolean = false;\n fontOverride: boolean = false;\n verticalScroll: boolean = false;\n bodyHyphens: boolean = false;\n advancedSettings: boolean = true;\n\n /**\n * Range: 100.0 - 300.0\n */\n fontSize: number = 100;\n\n /**\n * Range: 0.0 - 0.5\n */\n wordSpacing: number = 0;\n\n /**\n * Range: 0.0 - 0.5\n */\n letterSpacing: number = 0;\n\n /**\n * Range: 0.5 - 4.0\n */\n pageMargins: number = 0;\n\n /**\n * Range: 1.0 - 2.0\n */\n lineHeight: number = 1;\n\n /**\n * Range: 0.0 - 2.0\n */\n paragraphMargins?: number = 0;\n\n static map(settings: Partial<Settings>): any {\n const defaultValues = new Settings();\n const mapped: Record<string, any> = {};\n\n Object.keys(defaultValues)\n .forEach((key: string) => {\n // @ts-ignore\n mapped[key] = settings[key] !== undefined ? settings[key] : defaultValues[key];\n })\n ;\n\n mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);\n mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);\n mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);\n mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);\n\n Object.keys(RANGES).forEach((key: string) => {\n // @ts-ignore\n mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);\n });\n\n return mapped;\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './Dimensions';
2
+ export * from './File';
3
+ export * from './Locator';
4
+ export * from './Settings';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,QAAd;AACA,cAAc,WAAd;AACA,cAAc,YAAd","sourcesContent":["export * from './Dimensions';\nexport * from './File';\nexport * from './Locator';\nexport * from './Settings';\n"]}