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,126 @@
1
+ import Combine
2
+ import Foundation
3
+ import R2Shared
4
+ import R2Streamer
5
+ import UIKit
6
+
7
+ final class ReaderService: Loggable {
8
+ var app: AppModule?
9
+ var streamer = Streamer()
10
+ var publicationServer: PublicationServer?
11
+ private var subscriptions = Set<AnyCancellable>()
12
+
13
+ init() {
14
+ do {
15
+ self.app = try AppModule()
16
+ self.publicationServer = PublicationServer()
17
+ } catch {
18
+ print("TODO: An error occurred instantiating the ReaderService")
19
+ print(error)
20
+ }
21
+ }
22
+
23
+ func buildViewController(
24
+ url: String,
25
+ bookId: String,
26
+ locator: Locator?,
27
+ sender: UIViewController?,
28
+ completion: @escaping (ReaderViewController) -> Void
29
+ ) {
30
+ guard let reader = self.app?.reader else { return }
31
+ self.url(path: url)
32
+ .flatMap { self.openPublication(at: $0, allowUserInteraction: true, sender: sender ) }
33
+ .flatMap { (pub, _) in self.checkIsReadable(publication: pub) }
34
+ .sink(
35
+ receiveCompletion: { error in
36
+ print(">>>>>>>>>>> TODO: handle me", error)
37
+ },
38
+ receiveValue: { pub in
39
+ self.preparePresentation(of: pub)
40
+ let vc = reader.getViewController(
41
+ for: pub,
42
+ bookId: bookId,
43
+ locator: locator
44
+ )
45
+
46
+ if (vc != nil) {
47
+ completion(vc!)
48
+ }
49
+ }
50
+ )
51
+ .store(in: &subscriptions)
52
+ }
53
+
54
+ func url(path: String) -> AnyPublisher<URL, ReaderError> {
55
+ // Absolute URL.
56
+ if let url = URL(string: path), url.scheme != nil {
57
+ return .just(url)
58
+ }
59
+
60
+ // Absolute file path.
61
+ if path.hasPrefix("/") {
62
+ return .just(URL(fileURLWithPath: path))
63
+ }
64
+
65
+ return .fail(ReaderError.fileNotFound(fatalError("Unable to locate file: " + path)))
66
+ }
67
+
68
+ private func openPublication(
69
+ at url: URL,
70
+ allowUserInteraction: Bool,
71
+ sender: UIViewController?
72
+ ) -> AnyPublisher<(Publication, MediaType), ReaderError> {
73
+ let openFuture = Future<(Publication, MediaType), ReaderError>(
74
+ on: .global(),
75
+ { promise in
76
+ let asset = FileAsset(url: url)
77
+ guard let mediaType = asset.mediaType() else {
78
+ promise(.failure(.openFailed(Publication.OpeningError.unsupportedFormat)))
79
+ return
80
+ }
81
+
82
+ self.streamer.open(
83
+ asset: asset,
84
+ allowUserInteraction: allowUserInteraction,
85
+ sender: sender
86
+ ) { result in
87
+ switch result {
88
+ case .success(let publication):
89
+ promise(.success((publication, mediaType)))
90
+ case .failure(let error):
91
+ promise(.failure(.openFailed(error)))
92
+ case .cancelled:
93
+ promise(.failure(.cancelled))
94
+ }
95
+ }
96
+ }
97
+ )
98
+
99
+ return openFuture.eraseToAnyPublisher()
100
+ }
101
+
102
+ private func checkIsReadable(publication: Publication) -> AnyPublisher<Publication, ReaderError> {
103
+ guard !publication.isRestricted else {
104
+ if let error = publication.protectionError {
105
+ return .fail(.openFailed(error))
106
+ } else {
107
+ return .fail(.cancelled)
108
+ }
109
+ }
110
+ return .just(publication)
111
+ }
112
+
113
+ private func preparePresentation(of publication: Publication) {
114
+ if (self.publicationServer == nil) {
115
+ log(.error, "Whoops")
116
+ return
117
+ }
118
+
119
+ publicationServer?.removeAll()
120
+ do {
121
+ try publicationServer?.add(publication)
122
+ } catch {
123
+ log(.error, error)
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,2 @@
1
+ #import <React/RCTViewManager.h>
2
+ #import <React/RCTEventEmitter.h>
@@ -0,0 +1,293 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+
11
+ 5E555C0D2413F4C50049A1A2 /* Readium.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Readium.m */; };
12
+ F4FF95D7245B92E800C19C63 /* Readium.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* Readium.swift */; };
13
+
14
+ /* End PBXBuildFile section */
15
+
16
+ /* Begin PBXCopyFilesBuildPhase section */
17
+ 58B511D91A9E6C8500147676 /* CopyFiles */ = {
18
+ isa = PBXCopyFilesBuildPhase;
19
+ buildActionMask = 2147483647;
20
+ dstPath = "include/$(PRODUCT_NAME)";
21
+ dstSubfolderSpec = 16;
22
+ files = (
23
+ );
24
+ runOnlyForDeploymentPostprocessing = 0;
25
+ };
26
+ /* End PBXCopyFilesBuildPhase section */
27
+
28
+ /* Begin PBXFileReference section */
29
+ 134814201AA4EA6300B7C361 /* libReadium.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReadium.a; sourceTree = BUILT_PRODUCTS_DIR; };
30
+
31
+ B3E7B5891CC2AC0600A0062D /* Readium.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Readium.m; sourceTree = "<group>"; };
32
+ F4FF95D5245B92E700C19C63 /* Readium-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Readium-Bridging-Header.h"; sourceTree = "<group>"; };
33
+ F4FF95D6245B92E800C19C63 /* Readium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Readium.swift; sourceTree = "<group>"; };
34
+
35
+ /* End PBXFileReference section */
36
+
37
+ /* Begin PBXFrameworksBuildPhase section */
38
+ 58B511D81A9E6C8500147676 /* Frameworks */ = {
39
+ isa = PBXFrameworksBuildPhase;
40
+ buildActionMask = 2147483647;
41
+ files = (
42
+ );
43
+ runOnlyForDeploymentPostprocessing = 0;
44
+ };
45
+ /* End PBXFrameworksBuildPhase section */
46
+
47
+ /* Begin PBXGroup section */
48
+ 134814211AA4EA7D00B7C361 /* Products */ = {
49
+ isa = PBXGroup;
50
+ children = (
51
+ 134814201AA4EA6300B7C361 /* libReadium.a */,
52
+ );
53
+ name = Products;
54
+ sourceTree = "<group>";
55
+ };
56
+ 58B511D21A9E6C8500147676 = {
57
+ isa = PBXGroup;
58
+ children = (
59
+
60
+ F4FF95D6245B92E800C19C63 /* Readium.swift */,
61
+ B3E7B5891CC2AC0600A0062D /* Readium.m */,
62
+ F4FF95D5245B92E700C19C63 /* Readium-Bridging-Header.h */,
63
+
64
+ 134814211AA4EA7D00B7C361 /* Products */,
65
+ );
66
+ sourceTree = "<group>";
67
+ };
68
+ /* End PBXGroup section */
69
+
70
+ /* Begin PBXNativeTarget section */
71
+ 58B511DA1A9E6C8500147676 /* Readium */ = {
72
+ isa = PBXNativeTarget;
73
+ buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Readium" */;
74
+ buildPhases = (
75
+ 58B511D71A9E6C8500147676 /* Sources */,
76
+ 58B511D81A9E6C8500147676 /* Frameworks */,
77
+ 58B511D91A9E6C8500147676 /* CopyFiles */,
78
+ );
79
+ buildRules = (
80
+ );
81
+ dependencies = (
82
+ );
83
+ name = Readium;
84
+ productName = RCTDataManager;
85
+ productReference = 134814201AA4EA6300B7C361 /* libReadium.a */;
86
+ productType = "com.apple.product-type.library.static";
87
+ };
88
+ /* End PBXNativeTarget section */
89
+
90
+ /* Begin PBXProject section */
91
+ 58B511D31A9E6C8500147676 /* Project object */ = {
92
+ isa = PBXProject;
93
+ attributes = {
94
+ LastUpgradeCheck = 0920;
95
+ ORGANIZATIONNAME = Facebook;
96
+ TargetAttributes = {
97
+ 58B511DA1A9E6C8500147676 = {
98
+ CreatedOnToolsVersion = 6.1.1;
99
+ };
100
+ };
101
+ };
102
+ buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Readium" */;
103
+ compatibilityVersion = "Xcode 3.2";
104
+ developmentRegion = English;
105
+ hasScannedForEncodings = 0;
106
+ knownRegions = (
107
+ English,
108
+ en,
109
+ );
110
+ mainGroup = 58B511D21A9E6C8500147676;
111
+ productRefGroup = 58B511D21A9E6C8500147676;
112
+ projectDirPath = "";
113
+ projectRoot = "";
114
+ targets = (
115
+ 58B511DA1A9E6C8500147676 /* Readium */,
116
+ );
117
+ };
118
+ /* End PBXProject section */
119
+
120
+ /* Begin PBXSourcesBuildPhase section */
121
+ 58B511D71A9E6C8500147676 /* Sources */ = {
122
+ isa = PBXSourcesBuildPhase;
123
+ buildActionMask = 2147483647;
124
+ files = (
125
+
126
+ F4FF95D7245B92E800C19C63 /* Readium.swift in Sources */,
127
+ B3E7B58A1CC2AC0600A0062D /* Readium.m in Sources */,
128
+
129
+ );
130
+ runOnlyForDeploymentPostprocessing = 0;
131
+ };
132
+ /* End PBXSourcesBuildPhase section */
133
+
134
+ /* Begin XCBuildConfiguration section */
135
+ 58B511ED1A9E6C8500147676 /* Debug */ = {
136
+ isa = XCBuildConfiguration;
137
+ buildSettings = {
138
+ ALWAYS_SEARCH_USER_PATHS = NO;
139
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
140
+ CLANG_CXX_LIBRARY = "libc++";
141
+ CLANG_ENABLE_MODULES = YES;
142
+ CLANG_ENABLE_OBJC_ARC = YES;
143
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
144
+ CLANG_WARN_BOOL_CONVERSION = YES;
145
+ CLANG_WARN_COMMA = YES;
146
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
147
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
148
+ CLANG_WARN_EMPTY_BODY = YES;
149
+ CLANG_WARN_ENUM_CONVERSION = YES;
150
+ CLANG_WARN_INFINITE_RECURSION = YES;
151
+ CLANG_WARN_INT_CONVERSION = YES;
152
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
153
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
154
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
155
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
156
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
157
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
158
+ CLANG_WARN_UNREACHABLE_CODE = YES;
159
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
160
+ COPY_PHASE_STRIP = NO;
161
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
162
+ ENABLE_TESTABILITY = YES;
163
+ GCC_C_LANGUAGE_STANDARD = gnu99;
164
+ GCC_DYNAMIC_NO_PIC = NO;
165
+ GCC_NO_COMMON_BLOCKS = YES;
166
+ GCC_OPTIMIZATION_LEVEL = 0;
167
+ GCC_PREPROCESSOR_DEFINITIONS = (
168
+ "DEBUG=1",
169
+ "$(inherited)",
170
+ );
171
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
172
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
173
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
174
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
175
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
176
+ GCC_WARN_UNUSED_FUNCTION = YES;
177
+ GCC_WARN_UNUSED_VARIABLE = YES;
178
+ IPHONEOS_DEPLOYMENT_TARGET = 13.6;
179
+ MTL_ENABLE_DEBUG_INFO = YES;
180
+ ONLY_ACTIVE_ARCH = YES;
181
+ SDKROOT = iphoneos;
182
+ };
183
+ name = Debug;
184
+ };
185
+ 58B511EE1A9E6C8500147676 /* Release */ = {
186
+ isa = XCBuildConfiguration;
187
+ buildSettings = {
188
+ ALWAYS_SEARCH_USER_PATHS = NO;
189
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
190
+ CLANG_CXX_LIBRARY = "libc++";
191
+ CLANG_ENABLE_MODULES = YES;
192
+ CLANG_ENABLE_OBJC_ARC = YES;
193
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
194
+ CLANG_WARN_BOOL_CONVERSION = YES;
195
+ CLANG_WARN_COMMA = YES;
196
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
197
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
198
+ CLANG_WARN_EMPTY_BODY = YES;
199
+ CLANG_WARN_ENUM_CONVERSION = YES;
200
+ CLANG_WARN_INFINITE_RECURSION = YES;
201
+ CLANG_WARN_INT_CONVERSION = YES;
202
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
203
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
204
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
205
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
206
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
207
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
208
+ CLANG_WARN_UNREACHABLE_CODE = YES;
209
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
210
+ COPY_PHASE_STRIP = YES;
211
+ ENABLE_NS_ASSERTIONS = NO;
212
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
213
+ GCC_C_LANGUAGE_STANDARD = gnu99;
214
+ GCC_NO_COMMON_BLOCKS = YES;
215
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
216
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
217
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
218
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
219
+ GCC_WARN_UNUSED_FUNCTION = YES;
220
+ GCC_WARN_UNUSED_VARIABLE = YES;
221
+ IPHONEOS_DEPLOYMENT_TARGET = 13.6;
222
+ MTL_ENABLE_DEBUG_INFO = NO;
223
+ SDKROOT = iphoneos;
224
+ VALIDATE_PRODUCT = YES;
225
+ };
226
+ name = Release;
227
+ };
228
+ 58B511F01A9E6C8500147676 /* Debug */ = {
229
+ isa = XCBuildConfiguration;
230
+ buildSettings = {
231
+ HEADER_SEARCH_PATHS = (
232
+ "$(inherited)",
233
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
234
+ "$(SRCROOT)/../../../React/**",
235
+ "$(SRCROOT)/../../react-native/React/**",
236
+ );
237
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
238
+ OTHER_LDFLAGS = "-ObjC";
239
+ PRODUCT_NAME = Readium;
240
+ SKIP_INSTALL = YES;
241
+
242
+ SWIFT_OBJC_BRIDGING_HEADER = "Readium-Bridging-Header.h";
243
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
244
+ SWIFT_VERSION = 5.0;
245
+
246
+ };
247
+ name = Debug;
248
+ };
249
+ 58B511F11A9E6C8500147676 /* Release */ = {
250
+ isa = XCBuildConfiguration;
251
+ buildSettings = {
252
+ HEADER_SEARCH_PATHS = (
253
+ "$(inherited)",
254
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
255
+ "$(SRCROOT)/../../../React/**",
256
+ "$(SRCROOT)/../../react-native/React/**",
257
+ );
258
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
259
+ OTHER_LDFLAGS = "-ObjC";
260
+ PRODUCT_NAME = Readium;
261
+ SKIP_INSTALL = YES;
262
+
263
+ SWIFT_OBJC_BRIDGING_HEADER = "Readium-Bridging-Header.h";
264
+ SWIFT_VERSION = 5.0;
265
+
266
+ };
267
+ name = Release;
268
+ };
269
+ /* End XCBuildConfiguration section */
270
+
271
+ /* Begin XCConfigurationList section */
272
+ 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Readium" */ = {
273
+ isa = XCConfigurationList;
274
+ buildConfigurations = (
275
+ 58B511ED1A9E6C8500147676 /* Debug */,
276
+ 58B511EE1A9E6C8500147676 /* Release */,
277
+ );
278
+ defaultConfigurationIsVisible = 0;
279
+ defaultConfigurationName = Release;
280
+ };
281
+ 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Readium" */ = {
282
+ isa = XCConfigurationList;
283
+ buildConfigurations = (
284
+ 58B511F01A9E6C8500147676 /* Debug */,
285
+ 58B511F11A9E6C8500147676 /* Release */,
286
+ );
287
+ defaultConfigurationIsVisible = 0;
288
+ defaultConfigurationName = Release;
289
+ };
290
+ /* End XCConfigurationList section */
291
+ };
292
+ rootObject = 58B511D31A9E6C8500147676 /* Project object */;
293
+ }
@@ -0,0 +1,156 @@
1
+ import Combine
2
+ import Foundation
3
+ import R2Shared
4
+ import R2Streamer
5
+ import UIKit
6
+ import R2Navigator
7
+
8
+
9
+ class ReadiumView : UIView, Loggable {
10
+ var readerService: ReaderService = ReaderService()
11
+ var readerViewController: ReaderViewController?
12
+ private var subscriptions = Set<AnyCancellable>()
13
+
14
+ @objc var file: NSDictionary? = nil {
15
+ didSet {
16
+ if let initialLocation = file?["initialLocation"] as? NSDictionary {
17
+ location = initialLocation
18
+ }
19
+
20
+ if let url = file?["url"] as? String {
21
+ self.loadBook(url: url)
22
+ }
23
+ }
24
+ }
25
+ @objc var location: NSDictionary? = nil {
26
+ didSet {
27
+ self.updateLocation()
28
+ }
29
+ }
30
+ @objc var settings: NSDictionary? = nil {
31
+ didSet {
32
+ self.updateUserSettings(settings)
33
+ }
34
+ }
35
+ @objc var onLocationChange: RCTDirectEventBlock?
36
+
37
+ func loadBook(url: String) {
38
+ guard let rootViewController = UIApplication.shared.delegate?.window??.rootViewController else { return }
39
+ let locator: Locator? = self.getLocator()
40
+
41
+ self.readerService.buildViewController(
42
+ url: url,
43
+ bookId: url,
44
+ locator: locator,
45
+ sender: rootViewController,
46
+ completion: { vc in
47
+ self.addViewControllerAsSubview(vc)
48
+ }
49
+ )
50
+ }
51
+
52
+ func getLocator() -> Locator? {
53
+ if (location != nil) {
54
+ return try? Locator(json: location)
55
+ } else {
56
+ return nil
57
+ }
58
+ }
59
+
60
+ func updateLocation() {
61
+ guard let navigator = readerViewController?.navigator else {
62
+ return;
63
+ }
64
+ guard let locator = self.getLocator() else {
65
+ return;
66
+ }
67
+
68
+ let cur = navigator.currentLocation
69
+ if (cur != nil && locator.hashValue == cur?.hashValue) {
70
+ return;
71
+ }
72
+
73
+ navigator.go(
74
+ to: locator,
75
+ animated: true
76
+ )
77
+ }
78
+
79
+ func updateUserSettings(_ settings: NSDictionary?) {
80
+
81
+ if (readerViewController == nil) {
82
+ // defer setting update as view isn't initialized yet
83
+ return;
84
+ }
85
+
86
+ if let navigator = readerViewController!.navigator as? EPUBNavigatorViewController {
87
+ let userProperties = navigator.userSettings.userProperties
88
+
89
+ for property in userProperties.properties {
90
+ let value = settings?[property.reference]
91
+
92
+ if (value == nil) {
93
+ continue
94
+ }
95
+
96
+ if let e = property as? Enumerable {
97
+ e.index = value as! Int
98
+ } else if let i = property as? Incrementable {
99
+ i.value = value as! Float
100
+ } else if let s = property as? Switchable {
101
+ s.on = value as! Bool
102
+ }
103
+ }
104
+
105
+ navigator.updateUserSettingStyle()
106
+ }
107
+ }
108
+
109
+ override func removeFromSuperview() {
110
+ readerViewController?.willMove(toParent: nil)
111
+ readerViewController?.view.removeFromSuperview()
112
+ readerViewController?.removeFromParent()
113
+
114
+ // cancel all current subscriptions
115
+ for subscription in subscriptions {
116
+ subscription.cancel()
117
+ }
118
+ subscriptions = Set<AnyCancellable>()
119
+
120
+ readerViewController = nil
121
+ super.removeFromSuperview()
122
+ }
123
+
124
+ private func addViewControllerAsSubview(_ vc: ReaderViewController) {
125
+ vc.publisher.sink(
126
+ receiveValue: { locator in
127
+ if (self.onLocationChange != nil) {
128
+ self.onLocationChange!(locator.json)
129
+ }
130
+ }
131
+ )
132
+ .store(in: &self.subscriptions)
133
+
134
+ readerViewController = vc
135
+
136
+ // if the controller was just instantiated then apply any existing settings
137
+ if (settings != nil) {
138
+ self.updateUserSettings(settings)
139
+ }
140
+
141
+ let rootViewController = UIApplication.shared.delegate?.window??.rootViewController
142
+ rootViewController?.addChild(readerViewController!)
143
+ readerViewController!.view.frame = self.superview!.frame
144
+ let rootView = self.readerViewController!.view!
145
+ self.addSubview(rootView)
146
+
147
+ // bind the reader's view to be constrained to its parent
148
+ rootView.translatesAutoresizingMaskIntoConstraints = false
149
+ rootView.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
150
+ rootView.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
151
+ rootView.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
152
+ rootView.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
153
+
154
+ self.readerViewController!.didMove(toParent: rootViewController)
155
+ }
156
+ }
@@ -0,0 +1,10 @@
1
+ #import "React/RCTViewManager.h"
2
+
3
+ @interface RCT_EXTERN_MODULE(ReadiumViewManager, RCTViewManager)
4
+
5
+ RCT_EXPORT_VIEW_PROPERTY(file, NSDictionary *)
6
+ RCT_EXPORT_VIEW_PROPERTY(location, NSDictionary *)
7
+ RCT_EXPORT_VIEW_PROPERTY(settings, NSDictionary *)
8
+ RCT_EXPORT_VIEW_PROPERTY(onLocationChange, RCTDirectEventBlock)
9
+
10
+ @end
@@ -0,0 +1,9 @@
1
+ import Foundation
2
+
3
+ @objc(ReadiumViewManager)
4
+ class ReadiumViewManager: RCTViewManager {
5
+ override func view() -> (ReadiumView) {
6
+ let view = ReadiumView()
7
+ return view
8
+ }
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Appearance = void 0;
7
+ // NOTE: readium uses an index so the order is very important here
8
+ let Appearance;
9
+ exports.Appearance = Appearance;
10
+
11
+ (function (Appearance) {
12
+ Appearance["DEFAULT"] = "readium-default-on";
13
+ Appearance["SEPIA"] = "readium-sepia-on";
14
+ Appearance["NIGHT"] = "readium-night-on";
15
+ })(Appearance || (exports.Appearance = Appearance = {}));
16
+ //# sourceMappingURL=Appearance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Appearance.ts"],"names":["Appearance"],"mappings":";;;;;;AAAA;IACYA,U;;;WAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,0BAAAA,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,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ColumnCount = void 0;
7
+ // NOTE: readium uses an index so the order is very important here
8
+ let ColumnCount;
9
+ exports.ColumnCount = ColumnCount;
10
+
11
+ (function (ColumnCount) {
12
+ ColumnCount["AUTO"] = "auto";
13
+ ColumnCount["ONE"] = "1";
14
+ ColumnCount["TWO"] = "2";
15
+ })(ColumnCount || (exports.ColumnCount = ColumnCount = {}));
16
+ //# sourceMappingURL=ColumnCount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ColumnCount.ts"],"names":["ColumnCount"],"mappings":";;;;;;AAAA;IACYA,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,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,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FontFamily = void 0;
7
+ // NOTE: readium uses an index so the order is very important here
8
+ let FontFamily;
9
+ exports.FontFamily = FontFamily;
10
+
11
+ (function (FontFamily) {
12
+ FontFamily["ORIGINAL"] = "Original";
13
+ FontFamily["HELVETICA_NEUE"] = "Helvetica Neue";
14
+ FontFamily["IOWAN_OLD_STYLE"] = "Iowan Old Style";
15
+ FontFamily["ATHELAS"] = "Athelas";
16
+ FontFamily["SERAVEK"] = "Seravek";
17
+ FontFamily["OPEN_DYSLEXIC"] = "OpenDyslexic";
18
+ FontFamily["ACCESSIBLE_DFA"] = "AccessibleDfA";
19
+ FontFamily["IA_WRITER_DUOSPACE"] = "IA Writer Duospace";
20
+ })(FontFamily || (exports.FontFamily = FontFamily = {}));
21
+ //# sourceMappingURL=FontFamily.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FontFamily.ts"],"names":["FontFamily"],"mappings":";;;;;;AAAA;IACYA,U;;;WAAAA,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,0BAAAA,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,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TextAlignment = void 0;
7
+ // NOTE: readium uses an index so the order is very important here
8
+ let TextAlignment;
9
+ exports.TextAlignment = TextAlignment;
10
+
11
+ (function (TextAlignment) {
12
+ TextAlignment["JUSTIFY"] = "justify";
13
+ TextAlignment["START"] = "start";
14
+ })(TextAlignment || (exports.TextAlignment = TextAlignment = {}));
15
+ //# sourceMappingURL=TextAlignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["TextAlignment.ts"],"names":["TextAlignment"],"mappings":";;;;;;AAAA;IACYA,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,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"]}