react-native-readium 1.2.0 → 2.0.0-rc.0

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 (190) hide show
  1. package/README.md +28 -23
  2. package/android/build.gradle +25 -34
  3. package/android/src/main/java/com/reactnativereadium/ReadiumView.kt +3 -0
  4. package/android/src/main/res/layout/fragment_fxllayout_double.xml +58 -0
  5. package/android/src/main/res/layout/fragment_fxllayout_single.xml +52 -0
  6. package/android/src/main/res/layout/viewpager_fragment_epub.xml +27 -0
  7. package/android/src/main/res/values/strings.xml +1 -0
  8. package/lib/src/components/BaseReadiumView.d.ts +2 -0
  9. package/lib/src/components/BaseReadiumView.js +7 -0
  10. package/lib/src/components/BaseReadiumView.web.d.ts +1 -0
  11. package/lib/src/components/BaseReadiumView.web.js +1 -0
  12. package/lib/src/components/ReadiumView.d.ts +4 -0
  13. package/lib/src/components/ReadiumView.js +43 -0
  14. package/lib/src/components/ReadiumView.web.d.ts +5 -0
  15. package/lib/src/components/ReadiumView.web.js +61 -0
  16. package/lib/src/enums/Appearance.js +13 -0
  17. package/lib/src/enums/ColumnCount.js +7 -0
  18. package/lib/src/enums/FontFamily.js +12 -0
  19. package/lib/src/enums/TextAlignment.js +6 -0
  20. package/lib/{module → src}/enums/index.js +0 -1
  21. package/lib/{module → src}/index.js +0 -1
  22. package/lib/src/interfaces/BaseReadiumViewProps.d.ts +16 -0
  23. package/lib/src/interfaces/BaseReadiumViewProps.js +1 -0
  24. package/lib/src/interfaces/Dimensions.js +1 -0
  25. package/lib/src/interfaces/File.js +1 -0
  26. package/lib/src/interfaces/Link.js +1 -0
  27. package/lib/src/interfaces/Locator.js +1 -0
  28. package/lib/src/interfaces/Settings.js +61 -0
  29. package/lib/{typescript → src}/interfaces/index.d.ts +1 -0
  30. package/lib/{module → src}/interfaces/index.js +1 -1
  31. package/lib/{module → src}/utils/COMPONENT_NAME.js +0 -1
  32. package/lib/src/utils/LINKING_ERROR.js +5 -0
  33. package/lib/src/utils/RANGES.js +8 -0
  34. package/lib/src/utils/clamp.js +7 -0
  35. package/lib/src/utils/createFragment.js +10 -0
  36. package/lib/src/utils/getWidthOrHeightValue.js +4 -0
  37. package/lib/{module → src}/utils/index.js +0 -1
  38. package/lib/src/utils/indexOfObjectValue.js +3 -0
  39. package/lib/web/hooks/useLocationObserver.d.ts +2 -0
  40. package/lib/web/hooks/useLocationObserver.js +13 -0
  41. package/lib/web/hooks/useReaderRef.d.ts +3 -0
  42. package/lib/web/hooks/useReaderRef.js +48 -0
  43. package/lib/web/hooks/useSettingsObserver.d.ts +2 -0
  44. package/lib/web/hooks/useSettingsObserver.js +13 -0
  45. package/package.json +32 -38
  46. package/src/components/BaseReadiumView.tsx +1 -14
  47. package/src/components/BaseReadiumView.web.tsx +1 -0
  48. package/src/components/ReadiumView.tsx +1 -2
  49. package/src/{web/ReadiumView.tsx → components/ReadiumView.web.tsx} +11 -16
  50. package/src/interfaces/BaseReadiumViewProps.ts +18 -0
  51. package/src/interfaces/index.ts +1 -0
  52. package/{lib/module/web/hooks/index.js → web/hooks/index.ts} +0 -1
  53. package/{src/web → web}/hooks/useLocationObserver.ts +1 -3
  54. package/{src/web → web}/hooks/useReaderRef.ts +20 -17
  55. package/{src/web → web}/hooks/useSettingsObserver.ts +2 -4
  56. package/lib/commonjs/components/BaseReadiumView.js +0 -16
  57. package/lib/commonjs/components/BaseReadiumView.js.map +0 -1
  58. package/lib/commonjs/components/ReadiumView.js +0 -94
  59. package/lib/commonjs/components/ReadiumView.js.map +0 -1
  60. package/lib/commonjs/enums/Appearance.js +0 -16
  61. package/lib/commonjs/enums/Appearance.js.map +0 -1
  62. package/lib/commonjs/enums/ColumnCount.js +0 -16
  63. package/lib/commonjs/enums/ColumnCount.js.map +0 -1
  64. package/lib/commonjs/enums/FontFamily.js +0 -21
  65. package/lib/commonjs/enums/FontFamily.js.map +0 -1
  66. package/lib/commonjs/enums/TextAlignment.js +0 -15
  67. package/lib/commonjs/enums/TextAlignment.js.map +0 -1
  68. package/lib/commonjs/enums/index.js +0 -58
  69. package/lib/commonjs/enums/index.js.map +0 -1
  70. package/lib/commonjs/index.js +0 -59
  71. package/lib/commonjs/index.js.map +0 -1
  72. package/lib/commonjs/index.web.js +0 -54
  73. package/lib/commonjs/index.web.js.map +0 -1
  74. package/lib/commonjs/interfaces/Dimensions.js +0 -2
  75. package/lib/commonjs/interfaces/Dimensions.js.map +0 -1
  76. package/lib/commonjs/interfaces/File.js +0 -6
  77. package/lib/commonjs/interfaces/File.js.map +0 -1
  78. package/lib/commonjs/interfaces/Link.js +0 -2
  79. package/lib/commonjs/interfaces/Link.js.map +0 -1
  80. package/lib/commonjs/interfaces/Locator.js +0 -2
  81. package/lib/commonjs/interfaces/Locator.js.map +0 -1
  82. package/lib/commonjs/interfaces/Settings.js +0 -71
  83. package/lib/commonjs/interfaces/Settings.js.map +0 -1
  84. package/lib/commonjs/interfaces/index.js +0 -71
  85. package/lib/commonjs/interfaces/index.js.map +0 -1
  86. package/lib/commonjs/utils/COMPONENT_NAME.js +0 -9
  87. package/lib/commonjs/utils/COMPONENT_NAME.js.map +0 -1
  88. package/lib/commonjs/utils/LINKING_ERROR.js +0 -15
  89. package/lib/commonjs/utils/LINKING_ERROR.js.map +0 -1
  90. package/lib/commonjs/utils/RANGES.js +0 -16
  91. package/lib/commonjs/utils/RANGES.js.map +0 -1
  92. package/lib/commonjs/utils/clamp.js +0 -15
  93. package/lib/commonjs/utils/clamp.js.map +0 -1
  94. package/lib/commonjs/utils/createFragment.js +0 -21
  95. package/lib/commonjs/utils/createFragment.js.map +0 -1
  96. package/lib/commonjs/utils/getWidthOrHeightValue.js +0 -15
  97. package/lib/commonjs/utils/getWidthOrHeightValue.js.map +0 -1
  98. package/lib/commonjs/utils/index.js +0 -97
  99. package/lib/commonjs/utils/index.js.map +0 -1
  100. package/lib/commonjs/utils/indexOfObjectValue.js +0 -13
  101. package/lib/commonjs/utils/indexOfObjectValue.js.map +0 -1
  102. package/lib/commonjs/web/ReadiumView.js +0 -106
  103. package/lib/commonjs/web/ReadiumView.js.map +0 -1
  104. package/lib/commonjs/web/hooks/index.js +0 -45
  105. package/lib/commonjs/web/hooks/index.js.map +0 -1
  106. package/lib/commonjs/web/hooks/useLocationObserver.js +0 -21
  107. package/lib/commonjs/web/hooks/useLocationObserver.js.map +0 -1
  108. package/lib/commonjs/web/hooks/useReaderRef.js +0 -63
  109. package/lib/commonjs/web/hooks/useReaderRef.js.map +0 -1
  110. package/lib/commonjs/web/hooks/useSettingsObserver.js +0 -21
  111. package/lib/commonjs/web/hooks/useSettingsObserver.js.map +0 -1
  112. package/lib/module/components/BaseReadiumView.js +0 -6
  113. package/lib/module/components/BaseReadiumView.js.map +0 -1
  114. package/lib/module/components/ReadiumView.js +0 -75
  115. package/lib/module/components/ReadiumView.js.map +0 -1
  116. package/lib/module/enums/Appearance.js +0 -9
  117. package/lib/module/enums/Appearance.js.map +0 -1
  118. package/lib/module/enums/ColumnCount.js +0 -9
  119. package/lib/module/enums/ColumnCount.js.map +0 -1
  120. package/lib/module/enums/FontFamily.js +0 -14
  121. package/lib/module/enums/FontFamily.js.map +0 -1
  122. package/lib/module/enums/TextAlignment.js +0 -8
  123. package/lib/module/enums/TextAlignment.js.map +0 -1
  124. package/lib/module/enums/index.js.map +0 -1
  125. package/lib/module/index.js.map +0 -1
  126. package/lib/module/index.web.js +0 -5
  127. package/lib/module/index.web.js.map +0 -1
  128. package/lib/module/interfaces/Dimensions.js +0 -2
  129. package/lib/module/interfaces/Dimensions.js.map +0 -1
  130. package/lib/module/interfaces/File.js +0 -2
  131. package/lib/module/interfaces/File.js.map +0 -1
  132. package/lib/module/interfaces/Link.js +0 -2
  133. package/lib/module/interfaces/Link.js.map +0 -1
  134. package/lib/module/interfaces/Locator.js +0 -2
  135. package/lib/module/interfaces/Locator.js.map +0 -1
  136. package/lib/module/interfaces/Settings.js +0 -61
  137. package/lib/module/interfaces/Settings.js.map +0 -1
  138. package/lib/module/interfaces/index.js.map +0 -1
  139. package/lib/module/utils/COMPONENT_NAME.js.map +0 -1
  140. package/lib/module/utils/LINKING_ERROR.js +0 -6
  141. package/lib/module/utils/LINKING_ERROR.js.map +0 -1
  142. package/lib/module/utils/RANGES.js +0 -9
  143. package/lib/module/utils/RANGES.js.map +0 -1
  144. package/lib/module/utils/clamp.js +0 -6
  145. package/lib/module/utils/clamp.js.map +0 -1
  146. package/lib/module/utils/createFragment.js +0 -10
  147. package/lib/module/utils/createFragment.js.map +0 -1
  148. package/lib/module/utils/getWidthOrHeightValue.js +0 -5
  149. package/lib/module/utils/getWidthOrHeightValue.js.map +0 -1
  150. package/lib/module/utils/index.js.map +0 -1
  151. package/lib/module/utils/indexOfObjectValue.js +0 -4
  152. package/lib/module/utils/indexOfObjectValue.js.map +0 -1
  153. package/lib/module/web/ReadiumView.js +0 -89
  154. package/lib/module/web/ReadiumView.js.map +0 -1
  155. package/lib/module/web/hooks/index.js.map +0 -1
  156. package/lib/module/web/hooks/useLocationObserver.js +0 -11
  157. package/lib/module/web/hooks/useLocationObserver.js.map +0 -1
  158. package/lib/module/web/hooks/useReaderRef.js +0 -50
  159. package/lib/module/web/hooks/useReaderRef.js.map +0 -1
  160. package/lib/module/web/hooks/useSettingsObserver.js +0 -11
  161. package/lib/module/web/hooks/useSettingsObserver.js.map +0 -1
  162. package/lib/typescript/components/BaseReadiumView.d.ts +0 -14
  163. package/lib/typescript/components/ReadiumView.d.ts +0 -4
  164. package/lib/typescript/index.web.d.ts +0 -4
  165. package/lib/typescript/web/ReadiumView.d.ts +0 -5
  166. package/lib/typescript/web/hooks/useLocationObserver.d.ts +0 -3
  167. package/lib/typescript/web/hooks/useReaderRef.d.ts +0 -4
  168. package/lib/typescript/web/hooks/useSettingsObserver.d.ts +0 -3
  169. package/src/index.web.tsx +0 -5
  170. /package/lib/{typescript → src}/enums/Appearance.d.ts +0 -0
  171. /package/lib/{typescript → src}/enums/ColumnCount.d.ts +0 -0
  172. /package/lib/{typescript → src}/enums/FontFamily.d.ts +0 -0
  173. /package/lib/{typescript → src}/enums/TextAlignment.d.ts +0 -0
  174. /package/lib/{typescript → src}/enums/index.d.ts +0 -0
  175. /package/lib/{typescript → src}/index.d.ts +0 -0
  176. /package/lib/{typescript → src}/interfaces/Dimensions.d.ts +0 -0
  177. /package/lib/{typescript → src}/interfaces/File.d.ts +0 -0
  178. /package/lib/{typescript → src}/interfaces/Link.d.ts +0 -0
  179. /package/lib/{typescript → src}/interfaces/Locator.d.ts +0 -0
  180. /package/lib/{typescript → src}/interfaces/Settings.d.ts +0 -0
  181. /package/lib/{typescript → src}/utils/COMPONENT_NAME.d.ts +0 -0
  182. /package/lib/{typescript → src}/utils/LINKING_ERROR.d.ts +0 -0
  183. /package/lib/{typescript → src}/utils/RANGES.d.ts +0 -0
  184. /package/lib/{typescript → src}/utils/clamp.d.ts +0 -0
  185. /package/lib/{typescript → src}/utils/createFragment.d.ts +0 -0
  186. /package/lib/{typescript → src}/utils/getWidthOrHeightValue.d.ts +0 -0
  187. /package/lib/{typescript → src}/utils/index.d.ts +0 -0
  188. /package/lib/{typescript → src}/utils/indexOfObjectValue.d.ts +0 -0
  189. /package/lib/{typescript/web → web}/hooks/index.d.ts +0 -0
  190. /package/{src/web/hooks/index.ts → lib/web/hooks/index.js} +0 -0
package/README.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # react-native-readium
2
2
 
3
+ [![NPM version](https://img.shields.io/npm/v/react-native-readium.svg?color=success&label=npm%20package&logo=npm)](https://www.npmjs.com/package/react-native-readium)
4
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
5
+ ![PRs welcome!](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)
6
+ ![This project is released under the MIT license](https://img.shields.io/badge/license-MIT-blue.svg)
7
+
8
+ ----
9
+
10
+ ## Have A Bug/Feature You Care About?
11
+
12
+ We :heart: open source. We work on the things that are important to us when
13
+ we're able to work on them. Have an issue you care about?
14
+
15
+ - [Dive Into The Code!](CONTRIBUTING.md)
16
+ - [Sponsor Your Issue](https://issuehunt.io/r/5-stones/react-native-readium).
17
+
18
+ [![Issue Hunt](https://issuehunt.io/static/embed/issuehunt-button-v1.svg)](https://issuehunt.io/r/5-stones/react-native-readium)
19
+
20
+ ----
21
+
22
+ ## Overview
23
+
3
24
  A react-native wrapper for https://readium.org/. At a high level this package
4
25
  allows you to do things like:
5
26
 
@@ -13,7 +34,7 @@ allows you to do things like:
13
34
  - More (see the `Settings` documentation in the [API section](#api))
14
35
  - Etc. (read on for more details. :book:)
15
36
 
16
- ## Overview
37
+ ## Table of Contents
17
38
 
18
39
  - [Installation](#installation)
19
40
  - [Usage](#usage)
@@ -24,7 +45,7 @@ allows you to do things like:
24
45
  - [License](#license)
25
46
 
26
47
  | Dark Mode| Light Mode |
27
- |---|---|
48
+ |----------|------------|
28
49
  | ![Dark Mode](https://github.com/5-stones/react-native-readium/blob/main/docs/demo-dark-mode.gif) | ![Light Mode](https://github.com/5-stones/react-native-readium/blob/main/docs/demo-light-mode.gif) |
29
50
 
30
51
  ## Installation
@@ -63,10 +84,11 @@ platform :ios, '13.0'
63
84
  target 'ExampleApp' do
64
85
  config = use_native_modules!
65
86
  ...
66
- pod 'GCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/3ec154d358f26858071feaa6429e0f1c16bb11bd/GCDWebServer.podspec', modular_headers: true
67
- pod 'R2Shared', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.4.0/Support/CocoaPods/ReadiumShared.podspec'
68
- pod 'R2Streamer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.4.0/Support/CocoaPods/ReadiumStreamer.podspec'
69
- pod 'R2Navigator', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.4.0/Support/CocoaPods/ReadiumNavigator.podspec'
87
+ pod 'GCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/3.7.5/GCDWebServer.podspec', modular_headers: true
88
+ pod 'R2Navigator', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumNavigator.podspec'
89
+ pod 'R2Shared', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumShared.podspec'
90
+ pod 'R2Streamer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumStreamer.podspec'
91
+ pod 'ReadiumInternal', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.6.0/Support/CocoaPods/ReadiumInternal.podspec'
70
92
  pod 'Minizip', modular_headers: true
71
93
  ...
72
94
  end
@@ -78,23 +100,6 @@ Finally, install the pods:
78
100
 
79
101
  #### Android
80
102
 
81
- You might need to [add `jcenter` if you're getting a build failure on android](https://github.com/readium/kotlin-toolkit/issues/31):
82
-
83
- ```groovy
84
- // android/build.gradle
85
- ...
86
-
87
- allprojects {
88
- repositories {
89
- ...
90
- // required by react-native-readium https://github.com/readium/kotlin-toolkit/issues/31
91
- jcenter()
92
- }
93
- ...
94
- }
95
- ...
96
- ```
97
-
98
103
  If you're not using `compileSdkVersion` >= 31 you'll need to update that:
99
104
 
100
105
  ```groovy
@@ -1,12 +1,11 @@
1
1
  buildscript {
2
2
  // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
3
  def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Readium_kotlinVersion']
4
- ext.readium_version = '2.2.1'
4
+ ext.readium_version = '2.4.1'
5
5
 
6
6
  repositories {
7
7
  google()
8
8
  mavenCentral()
9
- jcenter()
10
9
  }
11
10
 
12
11
  dependencies {
@@ -49,21 +48,13 @@ android {
49
48
  targetCompatibility JavaVersion.VERSION_1_8
50
49
  }
51
50
 
52
- kotlinOptions {
53
- jvmTarget = "1.8"
54
- }
55
-
56
51
  buildFeatures {
57
52
  viewBinding true
58
53
  }
59
54
  }
60
55
 
61
56
  repositories {
62
-
63
- maven { url 'https://jitpack.io' }
64
-
65
57
  mavenCentral()
66
- jcenter()
67
58
  google()
68
59
 
69
60
  def found = false
@@ -140,51 +131,51 @@ dependencies {
140
131
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
141
132
 
142
133
  // readium deps
143
- implementation "com.github.readium.kotlin-toolkit:readium-shared:$readium_version"
144
- implementation "com.github.readium.kotlin-toolkit:readium-streamer:$readium_version"
145
- implementation ("com.github.readium.kotlin-toolkit:readium-navigator:$readium_version") {
134
+ implementation "org.readium.kotlin-toolkit:readium-shared:$readium_version"
135
+ implementation "org.readium.kotlin-toolkit:readium-streamer:$readium_version"
136
+ implementation ("org.readium.kotlin-toolkit:readium-navigator:$readium_version") {
146
137
  // this package doesn't provide audio playback, so remove exoplayer
147
138
  // transitive deps to avoid potential collisions with other projects.
148
139
  exclude group: "com.google.android.exoplayer"
149
140
  }
150
141
 
151
142
  // other deps
152
- implementation "androidx.core:core-ktx:1.6.0"
153
- implementation "androidx.activity:activity-ktx:1.3.1"
154
- implementation "androidx.appcompat:appcompat:1.3.1"
155
- implementation "androidx.browser:browser:1.3.0"
143
+ implementation "androidx.core:core-ktx:1.7.0"
144
+ implementation "androidx.activity:activity-ktx:1.4.0"
145
+ implementation "androidx.appcompat:appcompat:1.4.1"
146
+ implementation "androidx.browser:browser:1.4.0"
156
147
  implementation "androidx.cardview:cardview:1.0.0"
157
- implementation "androidx.constraintlayout:constraintlayout:2.1.1"
158
- implementation "androidx.fragment:fragment-ktx:1.3.6"
159
- implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
160
- implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
161
- implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
148
+ implementation "androidx.constraintlayout:constraintlayout:2.1.3"
149
+ implementation "androidx.fragment:fragment-ktx:1.4.0"
150
+ implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
151
+ implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
152
+ implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
162
153
  implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
163
154
  implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
164
- implementation "androidx.paging:paging-runtime-ktx:3.0.1"
155
+ implementation "androidx.paging:paging-runtime-ktx:3.1.0"
165
156
  implementation "androidx.recyclerview:recyclerview:1.2.1"
166
157
  implementation "androidx.viewpager2:viewpager2:1.0.0"
167
158
  implementation "androidx.webkit:webkit:1.4.0"
168
- implementation "com.google.android.material:material:1.4.0"
169
- implementation "com.jakewharton.timber:timber:4.7.1"
159
+ implementation "com.google.android.material:material:1.5.0"
160
+ implementation "com.jakewharton.timber:timber:5.0.1"
170
161
  // AM NOTE: needs to stay this version for now (June 24,2020)
171
162
  //noinspection GradleDependency
172
- implementation "com.squareup.picasso:picasso:2.5.2"
173
- implementation "joda-time:joda-time:2.10.10"
174
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
163
+ implementation "com.squareup.picasso:picasso:2.71828"
164
+ implementation "joda-time:joda-time:2.10.13"
165
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0"
175
166
  // AM NOTE: needs to stay this version for now (June 24,2020)
176
167
  //noinspection GradleDependency
177
- implementation "org.jsoup:jsoup:1.13.1"
168
+ implementation "org.jsoup:jsoup:1.14.3"
178
169
 
179
170
  // Room database
180
- final room_version = "2.4.0-beta01"
181
- implementation "androidx.room:room-runtime:$room_version"
182
- implementation "androidx.room:room-ktx:$room_version"
183
- annotationProcessor "androidx.room:room-compiler:$room_version"
171
+ final roomVersion = "2.4.1"
172
+ implementation "androidx.room:room-runtime:$roomVersion"
173
+ implementation "androidx.room:room-ktx:$roomVersion"
174
+ annotationProcessor "androidx.room:room-compiler:$roomVersion"
184
175
 
185
176
  implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
186
177
  //noinspection LifecycleAnnotationProcessorWithJava8
187
- annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
178
+ annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.4.0"
188
179
 
189
180
  testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
190
181
  testImplementation "junit:junit:4.13.2"
@@ -78,6 +78,9 @@ class ReadiumView(
78
78
  payload
79
79
  )
80
80
  }
81
+ else -> {
82
+ // do nothing
83
+ }
81
84
  }
82
85
  }
83
86
  }
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!--
2
+ FIXME: this was imported from `kotlin-toolkit/readium/navigator/src/main/res/layout@v2.2.1`.
3
+ Not sure why it's not being imported from readium-navigator, but if its not here
4
+ the android build throws an error due to UserSettings.kt#updateViewCSS
5
+
6
+ ~ Module: r2-navigator-kotlin
7
+ ~ Developers: Aferdita Muriqi
8
+ ~
9
+ ~ Copyright (c) 2018. Readium Foundation. All rights reserved.
10
+ ~ Use of this source code is governed by a BSD-style license which is detailed in the
11
+ ~ LICENSE file present in the project repository where this source code is maintained.
12
+ -->
13
+
14
+ <org.readium.r2.navigator.epub.fxl.R2FXLLayout xmlns:android="http://schemas.android.com/apk/res/android"
15
+ xmlns:tools="http://schemas.android.com/tools"
16
+ android:id="@+id/r2FXLLayout"
17
+ android:layout_width="match_parent"
18
+ android:layout_height="match_parent">
19
+
20
+ <ScrollView
21
+ android:layout_width="match_parent"
22
+ android:layout_height="match_parent"
23
+ android:fillViewport="true"
24
+ android:scrollbars="none">
25
+
26
+ <RelativeLayout
27
+ android:layout_width="match_parent"
28
+ android:layout_height="match_parent"
29
+ android:layout_gravity="center">
30
+
31
+ <LinearLayout
32
+ android:layout_width="wrap_content"
33
+ android:layout_height="wrap_content"
34
+ android:layout_centerInParent="true"
35
+ android:gravity="center_horizontal"
36
+ android:orientation="horizontal"
37
+ tools:ignore="UselessParent">
38
+
39
+ <org.readium.r2.navigator.R2BasicWebView
40
+ android:id="@+id/firstWebView"
41
+ android:layout_width="0dp"
42
+ android:layout_height="wrap_content"
43
+ android:layout_gravity="end"
44
+ android:layout_weight="1"
45
+ android:layerType="hardware" />
46
+
47
+ <org.readium.r2.navigator.R2BasicWebView
48
+ android:id="@+id/secondWebView"
49
+ android:layout_width="0dp"
50
+ android:layout_height="wrap_content"
51
+ android:layout_gravity="start"
52
+ android:layout_weight="1"
53
+ android:layerType="hardware" />
54
+
55
+ </LinearLayout>
56
+ </RelativeLayout>
57
+ </ScrollView>
58
+ </org.readium.r2.navigator.epub.fxl.R2FXLLayout>
@@ -0,0 +1,52 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!--
2
+ FIXME: this was imported from `kotlin-toolkit/readium/navigator/src/main/res/layout@v2.2.1`.
3
+ Not sure why it's not being imported from readium-navigator, but if its not here
4
+ the android build throws an error due to UserSettings.kt#updateViewCSS
5
+
6
+
7
+ ~ Module: r2-navigator-kotlin
8
+ ~ Developers: Aferdita Muriqi
9
+ ~
10
+ ~ Copyright (c) 2018. Readium Foundation. All rights reserved.
11
+ ~ Use of this source code is governed by a BSD-style license which is detailed in the
12
+ ~ LICENSE file present in the project repository where this source code is maintained.
13
+ -->
14
+
15
+ <org.readium.r2.navigator.epub.fxl.R2FXLLayout xmlns:android="http://schemas.android.com/apk/res/android"
16
+ xmlns:tools="http://schemas.android.com/tools"
17
+ android:id="@+id/r2FXLLayout"
18
+ android:layout_width="match_parent"
19
+ android:layout_height="match_parent">
20
+
21
+ <ScrollView
22
+ android:layout_width="match_parent"
23
+ android:layout_height="match_parent"
24
+ android:fillViewport="true"
25
+ android:scrollbars="none">
26
+
27
+ <RelativeLayout
28
+ android:layout_width="match_parent"
29
+ android:layout_height="wrap_content"
30
+ android:layout_gravity="center">
31
+
32
+ <LinearLayout
33
+ android:layout_width="wrap_content"
34
+ android:layout_height="wrap_content"
35
+ android:layout_centerInParent="true"
36
+ android:gravity="center_horizontal"
37
+ android:orientation="horizontal"
38
+ tools:ignore="UselessParent">
39
+
40
+ <org.readium.r2.navigator.R2BasicWebView
41
+ android:id="@+id/webViewSingle"
42
+ android:layout_width="0dp"
43
+ android:layout_height="wrap_content"
44
+ android:layout_weight="1"
45
+ android:layerType="hardware" />
46
+
47
+ </LinearLayout>
48
+
49
+ </RelativeLayout>
50
+ </ScrollView>
51
+
52
+ </org.readium.r2.navigator.epub.fxl.R2FXLLayout>
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!--
3
+ FIXME: this was imported from `kotlin-toolkit/readium/navigator/src/main/res/layout@v2.2.1`.
4
+ Not sure why it's not being imported from readium-navigator, but if its not here
5
+ the android build throws an error due to UserSettings.kt#updateViewCSS
6
+
7
+ ~ Module: r2-navigator-kotlin
8
+ ~ Developers: Aferdita Muriqi, Clément Baumann
9
+ ~
10
+ ~ Copyright (c) 2018. Readium Foundation. All rights reserved.
11
+ ~ Use of this source code is governed by a BSD-style license which is detailed in the
12
+ ~ LICENSE file present in the project repository where this source code is maintained.
13
+ -->
14
+
15
+ <androidx.coordinatorlayout.widget.CoordinatorLayout
16
+ xmlns:android="http://schemas.android.com/apk/res/android"
17
+ xmlns:app="http://schemas.android.com/apk/res-auto"
18
+ android:layout_width="match_parent"
19
+ android:layout_height="match_parent"
20
+ android:orientation="vertical">
21
+
22
+ <org.readium.r2.navigator.R2WebView
23
+ android:id="@+id/webView"
24
+ android:layout_width="match_parent"
25
+ android:layout_height="match_parent"/>
26
+
27
+ </androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -1,3 +1,4 @@
1
1
  <resources>
2
2
  <string name="no_result">No result</string>
3
+ <string name="epub_navigator_tag">epub_navigator</string>
3
4
  </resources>
@@ -0,0 +1,2 @@
1
+ import type { BaseReadiumViewProps } from '../interfaces';
2
+ export declare const BaseReadiumView: import("react-native").HostComponent<BaseReadiumViewProps> | (() => never);
@@ -0,0 +1,7 @@
1
+ import { requireNativeComponent, UIManager, } from 'react-native';
2
+ import { COMPONENT_NAME, LINKING_ERROR } from '../utils';
3
+ export const BaseReadiumView = UIManager.getViewManagerConfig(COMPONENT_NAME) != null
4
+ ? requireNativeComponent(COMPONENT_NAME)
5
+ : () => {
6
+ throw new Error(LINKING_ERROR);
7
+ };
@@ -0,0 +1 @@
1
+ export declare const BaseReadiumView: () => null;
@@ -0,0 +1 @@
1
+ export const BaseReadiumView = () => null;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { BaseReadiumViewProps } from '../interfaces';
3
+ export type ReadiumProps = BaseReadiumViewProps;
4
+ export declare const ReadiumView: React.FC<ReadiumProps>;
@@ -0,0 +1,43 @@
1
+ import React, { useCallback, useState, useRef, useEffect } from 'react';
2
+ import { View, Platform, findNodeHandle, StyleSheet } from 'react-native';
3
+ import { Settings } from '../interfaces';
4
+ import { createFragment, getWidthOrHeightValue as dimension } from '../utils';
5
+ import { BaseReadiumView } from './BaseReadiumView';
6
+ export const ReadiumView = ({ onLocationChange: wrappedOnLocationChange, onTableOfContents: wrappedOnTableOfContents, settings: unmappedSettings, ...props }) => {
7
+ const ref = useRef(null);
8
+ const [{ height, width }, setDimensions] = useState({
9
+ width: 0,
10
+ height: 0,
11
+ });
12
+ // set the view dimensions on layout
13
+ const onLayout = useCallback(({ nativeEvent: { layout: { width, height } } }) => {
14
+ setDimensions({
15
+ width: dimension(width),
16
+ height: dimension(height),
17
+ });
18
+ }, []);
19
+ // wrap the native onLocationChange and extract the raw event value
20
+ const onLocationChange = useCallback((event) => {
21
+ if (wrappedOnLocationChange) {
22
+ wrappedOnLocationChange(event.nativeEvent);
23
+ }
24
+ }, [wrappedOnLocationChange]);
25
+ const onTableOfContents = useCallback((event) => {
26
+ if (wrappedOnTableOfContents) {
27
+ const toc = event.nativeEvent.toc || null;
28
+ wrappedOnTableOfContents(toc);
29
+ }
30
+ }, [wrappedOnTableOfContents]);
31
+ useEffect(() => {
32
+ if (Platform.OS === 'android') {
33
+ const viewId = findNodeHandle(ref.current);
34
+ createFragment(viewId);
35
+ }
36
+ }, []);
37
+ return (<View style={styles.container} onLayout={onLayout}>
38
+ <BaseReadiumView height={height} width={width} {...props} onLocationChange={onLocationChange} onTableOfContents={onTableOfContents} settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined} ref={ref}/>
39
+ </View>);
40
+ };
41
+ const styles = StyleSheet.create({
42
+ container: { width: '100%', height: '100%' },
43
+ });
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const ReadiumView: React.ForwardRefExoticComponent<Omit<import("..").BaseReadiumViewProps, "ref"> & React.RefAttributes<{
3
+ nextPage: () => void;
4
+ prevPage: () => void;
5
+ }>>;
@@ -0,0 +1,61 @@
1
+ import React, { useImperativeHandle } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { useReaderRef, useSettingsObserver, useLocationObserver, } from '../../web/hooks';
4
+ export const ReadiumView = React.forwardRef(({ file, settings, location, onLocationChange, onTableOfContents, style = {}, height, width, }, ref) => {
5
+ const readerRef = useReaderRef({
6
+ file,
7
+ onLocationChange,
8
+ onTableOfContents,
9
+ });
10
+ const reader = readerRef.current;
11
+ useImperativeHandle(ref, () => ({
12
+ nextPage: () => {
13
+ readerRef.current?.nextPage();
14
+ },
15
+ prevPage: () => {
16
+ readerRef.current?.previousPage();
17
+ },
18
+ }));
19
+ useSettingsObserver(reader, settings);
20
+ useLocationObserver(reader, location);
21
+ const mainStyle = {
22
+ ...styles.maximize,
23
+ ...style,
24
+ };
25
+ if (height)
26
+ mainStyle.height = height;
27
+ if (width)
28
+ mainStyle.width = width;
29
+ return (<View style={styles.container}>
30
+ {!reader && <div style={loaderStyle}>Loading reader...</div>}
31
+ <div id="D2Reader-Container" style={styles.d2Container}>
32
+ <main style={mainStyle} tabIndex={-1} id="iframe-wrapper">
33
+ <div id="reader-loading" className="loading" style={loaderStyle}></div>
34
+ <div id="reader-error" className="error"></div>
35
+ </main>
36
+ </div>
37
+ </View>);
38
+ });
39
+ const loaderStyle = {
40
+ width: '100%',
41
+ height: '100%',
42
+ textAlign: 'center',
43
+ position: 'relative',
44
+ top: 'calc(50% - 10px)',
45
+ };
46
+ const styles = StyleSheet.create({
47
+ container: {
48
+ width: '100%',
49
+ height: '100%',
50
+ },
51
+ d2Container: {
52
+ width: '100%',
53
+ height: '100%',
54
+ display: 'flex',
55
+ },
56
+ maximize: {
57
+ width: '100%',
58
+ height: '100%',
59
+ display: 'flex',
60
+ },
61
+ });
@@ -0,0 +1,13 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export var Appearance;
3
+ (function (Appearance) {
4
+ /**
5
+ * A traditional "light" mode
6
+ */
7
+ Appearance["DEFAULT"] = "readium-default-on";
8
+ Appearance["SEPIA"] = "readium-sepia-on";
9
+ /**
10
+ * A traditional "dark" mode
11
+ */
12
+ Appearance["NIGHT"] = "readium-night-on";
13
+ })(Appearance || (Appearance = {}));
@@ -0,0 +1,7 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export var ColumnCount;
3
+ (function (ColumnCount) {
4
+ ColumnCount["AUTO"] = "auto";
5
+ ColumnCount["ONE"] = "1";
6
+ ColumnCount["TWO"] = "2";
7
+ })(ColumnCount || (ColumnCount = {}));
@@ -0,0 +1,12 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export var FontFamily;
3
+ (function (FontFamily) {
4
+ FontFamily["ORIGINAL"] = "Original";
5
+ FontFamily["HELVETICA_NEUE"] = "Helvetica Neue";
6
+ FontFamily["IOWAN_OLD_STYLE"] = "Iowan Old Style";
7
+ FontFamily["ATHELAS"] = "Athelas";
8
+ FontFamily["SERAVEK"] = "Seravek";
9
+ FontFamily["OPEN_DYSLEXIC"] = "OpenDyslexic";
10
+ FontFamily["ACCESSIBLE_DFA"] = "AccessibleDfA";
11
+ FontFamily["IA_WRITER_DUOSPACE"] = "IA Writer Duospace";
12
+ })(FontFamily || (FontFamily = {}));
@@ -0,0 +1,6 @@
1
+ // NOTE: readium uses an index so the order is very important here
2
+ export var TextAlignment;
3
+ (function (TextAlignment) {
4
+ TextAlignment["JUSTIFY"] = "justify";
5
+ TextAlignment["START"] = "start";
6
+ })(TextAlignment || (TextAlignment = {}));
@@ -2,4 +2,3 @@ export * from './Appearance';
2
2
  export * from './ColumnCount';
3
3
  export * from './FontFamily';
4
4
  export * from './TextAlignment';
5
- //# sourceMappingURL=index.js.map
@@ -2,4 +2,3 @@ export * from './enums';
2
2
  export * from './interfaces';
3
3
  export { RANGES } from './utils';
4
4
  export * from './components/ReadiumView';
5
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ import type { ViewStyle } from 'react-native';
2
+ import type { Settings } from './Settings';
3
+ import type { Link } from './Link';
4
+ import type { Locator } from './Locator';
5
+ import type { File } from './File';
6
+ export type BaseReadiumViewProps = {
7
+ file: File;
8
+ location?: Locator | Link;
9
+ settings?: Partial<Settings>;
10
+ style?: ViewStyle;
11
+ onLocationChange?: (locator: Locator) => void;
12
+ onTableOfContents?: (toc: Link[] | null) => void;
13
+ ref?: any;
14
+ height?: number;
15
+ width?: number;
16
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ import { Appearance, FontFamily, TextAlignment, ColumnCount, } from '../enums';
2
+ import { RANGES, indexOfObjectValue, clamp, } from '../utils';
3
+ /**
4
+ * A reader settings object with sensible defaults.
5
+ */
6
+ export class Settings {
7
+ // TODO:
8
+ // - ligatures
9
+ // - paraIndent
10
+ appearance = Appearance.DEFAULT;
11
+ fontFamily = FontFamily.ORIGINAL;
12
+ textAlign = TextAlignment.JUSTIFY;
13
+ colCount = ColumnCount.AUTO;
14
+ scroll = false;
15
+ fontOverride = false;
16
+ verticalScroll = false;
17
+ bodyHyphens = false;
18
+ advancedSettings = true;
19
+ /**
20
+ * Range: 100.0 - 300.0
21
+ */
22
+ fontSize = 100;
23
+ /**
24
+ * Range: 0.0 - 0.5
25
+ */
26
+ wordSpacing = 0;
27
+ /**
28
+ * Range: 0.0 - 0.5
29
+ */
30
+ letterSpacing = 0;
31
+ /**
32
+ * Range: 0.5 - 4.0
33
+ */
34
+ pageMargins = 0;
35
+ /**
36
+ * Range: 1.0 - 2.0
37
+ */
38
+ lineHeight = 1;
39
+ /**
40
+ * Range: 0.0 - 2.0
41
+ */
42
+ paragraphMargins = 0;
43
+ static map(settings) {
44
+ const defaultValues = new Settings();
45
+ const mapped = {};
46
+ Object.keys(defaultValues)
47
+ .forEach((key) => {
48
+ // @ts-ignore
49
+ mapped[key] = settings[key] !== undefined ? settings[key] : defaultValues[key];
50
+ });
51
+ mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);
52
+ mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);
53
+ mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);
54
+ mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);
55
+ Object.keys(RANGES).forEach((key) => {
56
+ // @ts-ignore
57
+ mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);
58
+ });
59
+ return mapped;
60
+ }
61
+ }
@@ -1,3 +1,4 @@
1
+ export * from './BaseReadiumViewProps';
1
2
  export * from './Dimensions';
2
3
  export * from './File';
3
4
  export * from './Link';