react-native-readium 5.0.0-rc.16 → 5.0.0-rc.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nitrogen/generated/android/NitroReadiumOnLoad.cpp +32 -22
- package/nitrogen/generated/android/NitroReadiumOnLoad.hpp +13 -4
- package/nitrogen/generated/android/c++/JHybridReadiumViewSpec.cpp +40 -46
- package/nitrogen/generated/android/c++/JHybridReadiumViewSpec.hpp +19 -22
- package/nitrogen/generated/android/c++/views/JHybridReadiumViewStateUpdater.cpp +12 -13
- package/nitrogen/generated/android/c++/views/JHybridReadiumViewStateUpdater.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativereadium/HybridReadiumViewSpec.kt +16 -18
- package/package.json +3 -2
|
@@ -27,30 +27,40 @@
|
|
|
27
27
|
namespace margelo::nitro::readium {
|
|
28
28
|
|
|
29
29
|
int initialize(JavaVM* vm) {
|
|
30
|
+
return facebook::jni::initialize(vm, []() {
|
|
31
|
+
::margelo::nitro::readium::registerAllNatives();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
struct JHybridReadiumViewSpecImpl: public jni::JavaClass<JHybridReadiumViewSpecImpl, JHybridReadiumViewSpec::JavaPart> {
|
|
36
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativereadium/HybridReadiumView;";
|
|
37
|
+
static std::shared_ptr<JHybridReadiumViewSpec> create() {
|
|
38
|
+
static auto constructorFn = javaClassStatic()->getConstructor<JHybridReadiumViewSpecImpl::javaobject()>();
|
|
39
|
+
jni::local_ref<JHybridReadiumViewSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
40
|
+
return javaPart->getJHybridReadiumViewSpec();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
void registerAllNatives() {
|
|
30
45
|
using namespace margelo::nitro;
|
|
31
46
|
using namespace margelo::nitro::readium;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
auto instance = object.create();
|
|
50
|
-
return instance->cthis()->shared();
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
});
|
|
47
|
+
|
|
48
|
+
// Register native JNI methods
|
|
49
|
+
margelo::nitro::readium::JHybridReadiumViewSpec::CxxPart::registerNatives();
|
|
50
|
+
margelo::nitro::readium::JFunc_void_Locator_cxx::registerNatives();
|
|
51
|
+
margelo::nitro::readium::JFunc_void_PublicationReadyEvent_cxx::registerNatives();
|
|
52
|
+
margelo::nitro::readium::JFunc_void_DecorationActivatedEvent_cxx::registerNatives();
|
|
53
|
+
margelo::nitro::readium::JFunc_void_SelectionEvent_cxx::registerNatives();
|
|
54
|
+
margelo::nitro::readium::JFunc_void_SelectionActionEvent_cxx::registerNatives();
|
|
55
|
+
margelo::nitro::readium::views::JHybridReadiumViewStateUpdater::registerNatives();
|
|
56
|
+
|
|
57
|
+
// Register Nitro Hybrid Objects
|
|
58
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
59
|
+
"ReadiumView",
|
|
60
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
61
|
+
return JHybridReadiumViewSpecImpl::create();
|
|
62
|
+
}
|
|
63
|
+
);
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
} // namespace margelo::nitro::readium
|
|
@@ -6,20 +6,29 @@
|
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include <jni.h>
|
|
9
|
+
#include <functional>
|
|
9
10
|
#include <NitroModules/NitroDefines.hpp>
|
|
10
11
|
|
|
11
12
|
namespace margelo::nitro::readium {
|
|
12
13
|
|
|
14
|
+
[[deprecated("Use registerNatives() instead.")]]
|
|
15
|
+
int initialize(JavaVM* vm);
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`)
|
|
18
|
+
* Register the native (C++) part of NitroReadium, and autolinks all Hybrid Objects.
|
|
19
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
|
|
20
|
+
* inside a `facebook::jni::initialize(vm, ...)` call.
|
|
16
21
|
* Example:
|
|
17
22
|
* ```cpp (cpp-adapter.cpp)
|
|
18
23
|
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
-
* return
|
|
24
|
+
* return facebook::jni::initialize(vm, []() {
|
|
25
|
+
* // register all NitroReadium HybridObjects
|
|
26
|
+
* margelo::nitro::readium::registerNatives();
|
|
27
|
+
* // any other custom registrations go here.
|
|
28
|
+
* });
|
|
20
29
|
* }
|
|
21
30
|
* ```
|
|
22
31
|
*/
|
|
23
|
-
|
|
32
|
+
void registerAllNatives();
|
|
24
33
|
|
|
25
34
|
} // namespace margelo::nitro::readium
|
|
@@ -114,60 +114,54 @@ namespace margelo::nitro::readium { struct SelectionActionEvent; }
|
|
|
114
114
|
|
|
115
115
|
namespace margelo::nitro::readium {
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
117
|
+
std::shared_ptr<JHybridReadiumViewSpec> JHybridReadiumViewSpec::JavaPart::getJHybridReadiumViewSpec() {
|
|
118
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
119
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridReadiumViewSpec>(hybridObject);
|
|
120
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
121
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridReadiumViewSpec!");
|
|
122
|
+
}
|
|
123
|
+
return castHybridObject;
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return method(_javaPart);
|
|
126
|
+
jni::local_ref<JHybridReadiumViewSpec::CxxPart::jhybriddata> JHybridReadiumViewSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
127
|
+
return makeCxxInstance(jThis);
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
std::shared_ptr<JHybridObject> JHybridReadiumViewSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
131
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridReadiumViewSpec::JavaPart>(javaPart);
|
|
132
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
133
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridReadiumViewSpec::JavaPart!");
|
|
135
134
|
}
|
|
136
|
-
return
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
void JHybridReadiumViewSpec::dispose() noexcept {
|
|
140
|
-
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
141
|
-
method(_javaPart);
|
|
135
|
+
return std::make_shared<JHybridReadiumViewSpec>(castJavaPart);
|
|
142
136
|
}
|
|
143
137
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
void JHybridReadiumViewSpec::CxxPart::registerNatives() {
|
|
139
|
+
registerHybrid({
|
|
140
|
+
makeNativeMethod("initHybrid", JHybridReadiumViewSpec::CxxPart::initHybrid),
|
|
141
|
+
});
|
|
148
142
|
}
|
|
149
143
|
|
|
150
144
|
// Properties
|
|
151
145
|
std::optional<ReadiumFile> JHybridReadiumViewSpec::getFile() {
|
|
152
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JReadiumFile>()>("getFile");
|
|
146
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JReadiumFile>()>("getFile");
|
|
153
147
|
auto __result = method(_javaPart);
|
|
154
148
|
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
|
155
149
|
}
|
|
156
150
|
void JHybridReadiumViewSpec::setFile(const std::optional<ReadiumFile>& file) {
|
|
157
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JReadiumFile> /* file */)>("setFile");
|
|
151
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JReadiumFile> /* file */)>("setFile");
|
|
158
152
|
method(_javaPart, file.has_value() ? JReadiumFile::fromCpp(file.value()) : nullptr);
|
|
159
153
|
}
|
|
160
154
|
std::optional<Preferences> JHybridReadiumViewSpec::getPreferences() {
|
|
161
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPreferences>()>("getPreferences");
|
|
155
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPreferences>()>("getPreferences");
|
|
162
156
|
auto __result = method(_javaPart);
|
|
163
157
|
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
|
164
158
|
}
|
|
165
159
|
void JHybridReadiumViewSpec::setPreferences(const std::optional<Preferences>& preferences) {
|
|
166
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JPreferences> /* preferences */)>("setPreferences");
|
|
160
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JPreferences> /* preferences */)>("setPreferences");
|
|
167
161
|
method(_javaPart, preferences.has_value() ? JPreferences::fromCpp(preferences.value()) : nullptr);
|
|
168
162
|
}
|
|
169
163
|
std::optional<std::vector<DecorationGroup>> JHybridReadiumViewSpec::getDecorations() {
|
|
170
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JDecorationGroup>>()>("getDecorations");
|
|
164
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JDecorationGroup>>()>("getDecorations");
|
|
171
165
|
auto __result = method(_javaPart);
|
|
172
166
|
return __result != nullptr ? std::make_optional([&]() {
|
|
173
167
|
size_t __size = __result->size();
|
|
@@ -181,7 +175,7 @@ namespace margelo::nitro::readium {
|
|
|
181
175
|
}()) : std::nullopt;
|
|
182
176
|
}
|
|
183
177
|
void JHybridReadiumViewSpec::setDecorations(const std::optional<std::vector<DecorationGroup>>& decorations) {
|
|
184
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JDecorationGroup>> /* decorations */)>("setDecorations");
|
|
178
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JDecorationGroup>> /* decorations */)>("setDecorations");
|
|
185
179
|
method(_javaPart, decorations.has_value() ? [&]() {
|
|
186
180
|
size_t __size = decorations.value().size();
|
|
187
181
|
jni::local_ref<jni::JArrayClass<JDecorationGroup>> __array = jni::JArrayClass<JDecorationGroup>::newArray(__size);
|
|
@@ -194,7 +188,7 @@ namespace margelo::nitro::readium {
|
|
|
194
188
|
}() : nullptr);
|
|
195
189
|
}
|
|
196
190
|
std::optional<std::vector<SelectionAction>> JHybridReadiumViewSpec::getSelectionActions() {
|
|
197
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JSelectionAction>>()>("getSelectionActions");
|
|
191
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JSelectionAction>>()>("getSelectionActions");
|
|
198
192
|
auto __result = method(_javaPart);
|
|
199
193
|
return __result != nullptr ? std::make_optional([&]() {
|
|
200
194
|
size_t __size = __result->size();
|
|
@@ -208,7 +202,7 @@ namespace margelo::nitro::readium {
|
|
|
208
202
|
}()) : std::nullopt;
|
|
209
203
|
}
|
|
210
204
|
void JHybridReadiumViewSpec::setSelectionActions(const std::optional<std::vector<SelectionAction>>& selectionActions) {
|
|
211
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JSelectionAction>> /* selectionActions */)>("setSelectionActions");
|
|
205
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JSelectionAction>> /* selectionActions */)>("setSelectionActions");
|
|
212
206
|
method(_javaPart, selectionActions.has_value() ? [&]() {
|
|
213
207
|
size_t __size = selectionActions.value().size();
|
|
214
208
|
jni::local_ref<jni::JArrayClass<JSelectionAction>> __array = jni::JArrayClass<JSelectionAction>::newArray(__size);
|
|
@@ -221,7 +215,7 @@ namespace margelo::nitro::readium {
|
|
|
221
215
|
}() : nullptr);
|
|
222
216
|
}
|
|
223
217
|
std::optional<std::function<void(const Locator& /* locator */)>> JHybridReadiumViewSpec::getOnLocationChange() {
|
|
224
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_Locator::javaobject>()>("getOnLocationChange_cxx");
|
|
218
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_Locator::javaobject>()>("getOnLocationChange_cxx");
|
|
225
219
|
auto __result = method(_javaPart);
|
|
226
220
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const Locator& /* locator */)> {
|
|
227
221
|
if (__result->isInstanceOf(JFunc_void_Locator_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -234,11 +228,11 @@ namespace margelo::nitro::readium {
|
|
|
234
228
|
}()) : std::nullopt;
|
|
235
229
|
}
|
|
236
230
|
void JHybridReadiumViewSpec::setOnLocationChange(const std::optional<std::function<void(const Locator& /* locator */)>>& onLocationChange) {
|
|
237
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_Locator::javaobject> /* onLocationChange */)>("setOnLocationChange_cxx");
|
|
231
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_Locator::javaobject> /* onLocationChange */)>("setOnLocationChange_cxx");
|
|
238
232
|
method(_javaPart, onLocationChange.has_value() ? JFunc_void_Locator_cxx::fromCpp(onLocationChange.value()) : nullptr);
|
|
239
233
|
}
|
|
240
234
|
std::optional<std::function<void(const PublicationReadyEvent& /* event */)>> JHybridReadiumViewSpec::getOnPublicationReady() {
|
|
241
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_PublicationReadyEvent::javaobject>()>("getOnPublicationReady_cxx");
|
|
235
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_PublicationReadyEvent::javaobject>()>("getOnPublicationReady_cxx");
|
|
242
236
|
auto __result = method(_javaPart);
|
|
243
237
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const PublicationReadyEvent& /* event */)> {
|
|
244
238
|
if (__result->isInstanceOf(JFunc_void_PublicationReadyEvent_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -251,11 +245,11 @@ namespace margelo::nitro::readium {
|
|
|
251
245
|
}()) : std::nullopt;
|
|
252
246
|
}
|
|
253
247
|
void JHybridReadiumViewSpec::setOnPublicationReady(const std::optional<std::function<void(const PublicationReadyEvent& /* event */)>>& onPublicationReady) {
|
|
254
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PublicationReadyEvent::javaobject> /* onPublicationReady */)>("setOnPublicationReady_cxx");
|
|
248
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PublicationReadyEvent::javaobject> /* onPublicationReady */)>("setOnPublicationReady_cxx");
|
|
255
249
|
method(_javaPart, onPublicationReady.has_value() ? JFunc_void_PublicationReadyEvent_cxx::fromCpp(onPublicationReady.value()) : nullptr);
|
|
256
250
|
}
|
|
257
251
|
std::optional<std::function<void(const DecorationActivatedEvent& /* event */)>> JHybridReadiumViewSpec::getOnDecorationActivated() {
|
|
258
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_DecorationActivatedEvent::javaobject>()>("getOnDecorationActivated_cxx");
|
|
252
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_DecorationActivatedEvent::javaobject>()>("getOnDecorationActivated_cxx");
|
|
259
253
|
auto __result = method(_javaPart);
|
|
260
254
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const DecorationActivatedEvent& /* event */)> {
|
|
261
255
|
if (__result->isInstanceOf(JFunc_void_DecorationActivatedEvent_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -268,11 +262,11 @@ namespace margelo::nitro::readium {
|
|
|
268
262
|
}()) : std::nullopt;
|
|
269
263
|
}
|
|
270
264
|
void JHybridReadiumViewSpec::setOnDecorationActivated(const std::optional<std::function<void(const DecorationActivatedEvent& /* event */)>>& onDecorationActivated) {
|
|
271
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_DecorationActivatedEvent::javaobject> /* onDecorationActivated */)>("setOnDecorationActivated_cxx");
|
|
265
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_DecorationActivatedEvent::javaobject> /* onDecorationActivated */)>("setOnDecorationActivated_cxx");
|
|
272
266
|
method(_javaPart, onDecorationActivated.has_value() ? JFunc_void_DecorationActivatedEvent_cxx::fromCpp(onDecorationActivated.value()) : nullptr);
|
|
273
267
|
}
|
|
274
268
|
std::optional<std::function<void(const SelectionEvent& /* event */)>> JHybridReadiumViewSpec::getOnSelectionChange() {
|
|
275
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_SelectionEvent::javaobject>()>("getOnSelectionChange_cxx");
|
|
269
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_SelectionEvent::javaobject>()>("getOnSelectionChange_cxx");
|
|
276
270
|
auto __result = method(_javaPart);
|
|
277
271
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const SelectionEvent& /* event */)> {
|
|
278
272
|
if (__result->isInstanceOf(JFunc_void_SelectionEvent_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -285,11 +279,11 @@ namespace margelo::nitro::readium {
|
|
|
285
279
|
}()) : std::nullopt;
|
|
286
280
|
}
|
|
287
281
|
void JHybridReadiumViewSpec::setOnSelectionChange(const std::optional<std::function<void(const SelectionEvent& /* event */)>>& onSelectionChange) {
|
|
288
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_SelectionEvent::javaobject> /* onSelectionChange */)>("setOnSelectionChange_cxx");
|
|
282
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_SelectionEvent::javaobject> /* onSelectionChange */)>("setOnSelectionChange_cxx");
|
|
289
283
|
method(_javaPart, onSelectionChange.has_value() ? JFunc_void_SelectionEvent_cxx::fromCpp(onSelectionChange.value()) : nullptr);
|
|
290
284
|
}
|
|
291
285
|
std::optional<std::function<void(const SelectionActionEvent& /* event */)>> JHybridReadiumViewSpec::getOnSelectionAction() {
|
|
292
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_SelectionActionEvent::javaobject>()>("getOnSelectionAction_cxx");
|
|
286
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_SelectionActionEvent::javaobject>()>("getOnSelectionAction_cxx");
|
|
293
287
|
auto __result = method(_javaPart);
|
|
294
288
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const SelectionActionEvent& /* event */)> {
|
|
295
289
|
if (__result->isInstanceOf(JFunc_void_SelectionActionEvent_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -302,25 +296,25 @@ namespace margelo::nitro::readium {
|
|
|
302
296
|
}()) : std::nullopt;
|
|
303
297
|
}
|
|
304
298
|
void JHybridReadiumViewSpec::setOnSelectionAction(const std::optional<std::function<void(const SelectionActionEvent& /* event */)>>& onSelectionAction) {
|
|
305
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_SelectionActionEvent::javaobject> /* onSelectionAction */)>("setOnSelectionAction_cxx");
|
|
299
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_SelectionActionEvent::javaobject> /* onSelectionAction */)>("setOnSelectionAction_cxx");
|
|
306
300
|
method(_javaPart, onSelectionAction.has_value() ? JFunc_void_SelectionActionEvent_cxx::fromCpp(onSelectionAction.value()) : nullptr);
|
|
307
301
|
}
|
|
308
302
|
|
|
309
303
|
// Methods
|
|
310
304
|
void JHybridReadiumViewSpec::goTo(const Locator& locator) {
|
|
311
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JLocator> /* locator */)>("goTo");
|
|
305
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JLocator> /* locator */)>("goTo");
|
|
312
306
|
method(_javaPart, JLocator::fromCpp(locator));
|
|
313
307
|
}
|
|
314
308
|
void JHybridReadiumViewSpec::goForward() {
|
|
315
|
-
static const auto method = javaClassStatic()->getMethod<void()>("goForward");
|
|
309
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("goForward");
|
|
316
310
|
method(_javaPart);
|
|
317
311
|
}
|
|
318
312
|
void JHybridReadiumViewSpec::goBackward() {
|
|
319
|
-
static const auto method = javaClassStatic()->getMethod<void()>("goBackward");
|
|
313
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("goBackward");
|
|
320
314
|
method(_javaPart);
|
|
321
315
|
}
|
|
322
316
|
void JHybridReadiumViewSpec::destroy() {
|
|
323
|
-
static const auto method = javaClassStatic()->getMethod<void()>("destroy");
|
|
317
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("destroy");
|
|
324
318
|
method(_javaPart);
|
|
325
319
|
}
|
|
326
320
|
|
|
@@ -18,34 +18,33 @@ namespace margelo::nitro::readium {
|
|
|
18
18
|
|
|
19
19
|
using namespace facebook;
|
|
20
20
|
|
|
21
|
-
class JHybridReadiumViewSpec: public
|
|
22
|
-
public virtual HybridReadiumViewSpec {
|
|
21
|
+
class JHybridReadiumViewSpec: public virtual HybridReadiumViewSpec, public virtual JHybridObject {
|
|
23
22
|
public:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
HybridBase
|
|
33
|
-
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativereadium/HybridReadiumViewSpec;";
|
|
25
|
+
std::shared_ptr<JHybridReadiumViewSpec> getJHybridReadiumViewSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativereadium/HybridReadiumViewSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
34
35
|
|
|
35
36
|
public:
|
|
37
|
+
explicit JHybridReadiumViewSpec(const jni::local_ref<JHybridReadiumViewSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridReadiumViewSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
36
41
|
~JHybridReadiumViewSpec() override {
|
|
37
42
|
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
43
|
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
public:
|
|
42
|
-
|
|
43
|
-
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
-
void dispose() noexcept override;
|
|
45
|
-
std::string toString() override;
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
inline const jni::global_ref<JHybridReadiumViewSpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
inline const jni::global_ref<JHybridReadiumViewSpec::JavaPart>& getJavaPart() const noexcept {
|
|
49
48
|
return _javaPart;
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -78,9 +77,7 @@ namespace margelo::nitro::readium {
|
|
|
78
77
|
void destroy() override;
|
|
79
78
|
|
|
80
79
|
private:
|
|
81
|
-
|
|
82
|
-
using HybridBase::HybridBase;
|
|
83
|
-
jni::global_ref<JHybridReadiumViewSpec::javaobject> _javaPart;
|
|
80
|
+
jni::global_ref<JHybridReadiumViewSpec::JavaPart> _javaPart;
|
|
84
81
|
};
|
|
85
82
|
|
|
86
83
|
} // namespace margelo::nitro::readium
|
|
@@ -16,9 +16,9 @@ using namespace facebook;
|
|
|
16
16
|
using ConcreteStateData = react::ConcreteState<HybridReadiumViewState>;
|
|
17
17
|
|
|
18
18
|
void JHybridReadiumViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
19
|
-
jni::alias_ref<JHybridReadiumViewSpec::
|
|
19
|
+
jni::alias_ref<JHybridReadiumViewSpec::JavaPart> javaView,
|
|
20
20
|
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
|
|
21
|
-
JHybridReadiumViewSpec
|
|
21
|
+
std::shared_ptr<JHybridReadiumViewSpec> hybridView = javaView->getJHybridReadiumViewSpec();
|
|
22
22
|
|
|
23
23
|
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
24
24
|
jobject rawStateWrapper = stateWrapperInterface.get();
|
|
@@ -38,39 +38,39 @@ void JHybridReadiumViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
38
38
|
|
|
39
39
|
// Update all props if they are dirty
|
|
40
40
|
if (props->file.isDirty) {
|
|
41
|
-
|
|
41
|
+
hybridView->setFile(props->file.value);
|
|
42
42
|
props->file.isDirty = false;
|
|
43
43
|
}
|
|
44
44
|
if (props->preferences.isDirty) {
|
|
45
|
-
|
|
45
|
+
hybridView->setPreferences(props->preferences.value);
|
|
46
46
|
props->preferences.isDirty = false;
|
|
47
47
|
}
|
|
48
48
|
if (props->decorations.isDirty) {
|
|
49
|
-
|
|
49
|
+
hybridView->setDecorations(props->decorations.value);
|
|
50
50
|
props->decorations.isDirty = false;
|
|
51
51
|
}
|
|
52
52
|
if (props->selectionActions.isDirty) {
|
|
53
|
-
|
|
53
|
+
hybridView->setSelectionActions(props->selectionActions.value);
|
|
54
54
|
props->selectionActions.isDirty = false;
|
|
55
55
|
}
|
|
56
56
|
if (props->onLocationChange.isDirty) {
|
|
57
|
-
|
|
57
|
+
hybridView->setOnLocationChange(props->onLocationChange.value);
|
|
58
58
|
props->onLocationChange.isDirty = false;
|
|
59
59
|
}
|
|
60
60
|
if (props->onPublicationReady.isDirty) {
|
|
61
|
-
|
|
61
|
+
hybridView->setOnPublicationReady(props->onPublicationReady.value);
|
|
62
62
|
props->onPublicationReady.isDirty = false;
|
|
63
63
|
}
|
|
64
64
|
if (props->onDecorationActivated.isDirty) {
|
|
65
|
-
|
|
65
|
+
hybridView->setOnDecorationActivated(props->onDecorationActivated.value);
|
|
66
66
|
props->onDecorationActivated.isDirty = false;
|
|
67
67
|
}
|
|
68
68
|
if (props->onSelectionChange.isDirty) {
|
|
69
|
-
|
|
69
|
+
hybridView->setOnSelectionChange(props->onSelectionChange.value);
|
|
70
70
|
props->onSelectionChange.isDirty = false;
|
|
71
71
|
}
|
|
72
72
|
if (props->onSelectionAction.isDirty) {
|
|
73
|
-
|
|
73
|
+
hybridView->setOnSelectionAction(props->onSelectionAction.value);
|
|
74
74
|
props->onSelectionAction.isDirty = false;
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -79,8 +79,7 @@ void JHybridReadiumViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
79
79
|
// hybridRef changed - call it with new this
|
|
80
80
|
const auto& maybeFunc = props->hybridRef.value;
|
|
81
81
|
if (maybeFunc.has_value()) {
|
|
82
|
-
|
|
83
|
-
maybeFunc.value()(shared);
|
|
82
|
+
maybeFunc.value()(hybridView);
|
|
84
83
|
}
|
|
85
84
|
props->hybridRef.isDirty = false;
|
|
86
85
|
}
|
|
@@ -30,7 +30,7 @@ public:
|
|
|
30
30
|
|
|
31
31
|
public:
|
|
32
32
|
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
|
-
jni::alias_ref<JHybridReadiumViewSpec::
|
|
33
|
+
jni::alias_ref<JHybridReadiumViewSpec::JavaPart> view,
|
|
34
34
|
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
|
|
35
35
|
|
|
36
36
|
public:
|
|
@@ -10,6 +10,7 @@ package com.margelo.nitro.reactnativereadium
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.HybridObject
|
|
13
14
|
import com.margelo.nitro.views.HybridView
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -24,23 +25,6 @@ import com.margelo.nitro.views.HybridView
|
|
|
24
25
|
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
26
|
)
|
|
26
27
|
abstract class HybridReadiumViewSpec: HybridView() {
|
|
27
|
-
@DoNotStrip
|
|
28
|
-
private var mHybridData: HybridData = initHybrid()
|
|
29
|
-
|
|
30
|
-
init {
|
|
31
|
-
super.updateNative(mHybridData)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override fun updateNative(hybridData: HybridData) {
|
|
35
|
-
mHybridData = hybridData
|
|
36
|
-
super.updateNative(hybridData)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Default implementation of `HybridObject.toString()`
|
|
40
|
-
override fun toString(): String {
|
|
41
|
-
return "[HybridObject ReadiumView]"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
28
|
// Properties
|
|
45
29
|
@get:DoNotStrip
|
|
46
30
|
@get:Keep
|
|
@@ -153,7 +137,21 @@ abstract class HybridReadiumViewSpec: HybridView() {
|
|
|
153
137
|
@Keep
|
|
154
138
|
abstract fun destroy(): Unit
|
|
155
139
|
|
|
156
|
-
|
|
140
|
+
// Default implementation of `HybridObject.toString()`
|
|
141
|
+
override fun toString(): String {
|
|
142
|
+
return "[HybridObject ReadiumView]"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// C++ backing class
|
|
146
|
+
@DoNotStrip
|
|
147
|
+
@Keep
|
|
148
|
+
protected open class CxxPart(javaPart: HybridReadiumViewSpec): HybridObject.CxxPart(javaPart) {
|
|
149
|
+
// C++ JHybridReadiumViewSpec::CxxPart::initHybrid(...)
|
|
150
|
+
external override fun initHybrid(): HybridData
|
|
151
|
+
}
|
|
152
|
+
override fun createCxxPart(): CxxPart {
|
|
153
|
+
return CxxPart(this)
|
|
154
|
+
}
|
|
157
155
|
|
|
158
156
|
companion object {
|
|
159
157
|
protected const val TAG = "HybridReadiumViewSpec"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-readium",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.17",
|
|
4
4
|
"description": "A react-native wrapper for https://readium.org/",
|
|
5
5
|
"main": "lib/src/index",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
@@ -86,12 +86,13 @@
|
|
|
86
86
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
87
87
|
"husky": "^6.0.0",
|
|
88
88
|
"jest": "^29.6.3",
|
|
89
|
+
"nitrogen": "^0.35.0",
|
|
89
90
|
"pod-install": "^0.1.0",
|
|
90
91
|
"prettier": "2.8.8",
|
|
91
92
|
"react": "19.0.0",
|
|
92
93
|
"react-native": "0.83.1",
|
|
93
94
|
"react-native-builder-bob": "^0.23.2",
|
|
94
|
-
"react-native-nitro-modules": "^0.
|
|
95
|
+
"react-native-nitro-modules": "^0.35.0",
|
|
95
96
|
"release-it": "^15.0.0",
|
|
96
97
|
"rimraf": "^5.0.7",
|
|
97
98
|
"turbo": "^1.10.7",
|