@hot-updater/react-native 0.19.8 → 0.20.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.
- package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeHotUpdaterSpec.java +94 -0
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
- package/android/app/build/generated/source/codegen/jni/HotUpdater-generated.cpp +68 -0
- package/android/app/build/generated/source/codegen/jni/HotUpdater.h +31 -0
- package/android/app/build/generated/source/codegen/jni/HotUpdaterSpec-generated.cpp +68 -0
- package/android/app/build/generated/source/codegen/jni/HotUpdaterSpec.h +31 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/HotUpdater/HotUpdaterJSI-generated.cpp +69 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/HotUpdater/HotUpdaterJSI.h +168 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI-generated.cpp +69 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI.h +172 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +16 -3
- package/android/src/main/java/com/hotupdater/ReactIntegrationManagerBase.kt +3 -0
- package/android/src/newarch/ReactIntegrationManager.kt +20 -9
- package/android/src/oldarch/ReactIntegrationManager.kt +26 -7
- package/ios/HotUpdater/Package.resolved +15 -0
- package/package.json +6 -5
- package/plugin/build/withHotUpdater.js +41 -15
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.facebook.fbreact.specs;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.common.build.ReactBuildConfig;
|
|
22
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
23
|
+
import java.util.Arrays;
|
|
24
|
+
import java.util.HashSet;
|
|
25
|
+
import java.util.Map;
|
|
26
|
+
import java.util.Set;
|
|
27
|
+
import javax.annotation.Nonnull;
|
|
28
|
+
import javax.annotation.Nullable;
|
|
29
|
+
|
|
30
|
+
public abstract class NativeHotUpdaterSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
31
|
+
public static final String NAME = "HotUpdater";
|
|
32
|
+
|
|
33
|
+
public NativeHotUpdaterSpec(ReactApplicationContext reactContext) {
|
|
34
|
+
super(reactContext);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Override
|
|
38
|
+
public @Nonnull String getName() {
|
|
39
|
+
return NAME;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
@DoNotStrip
|
|
44
|
+
public abstract void reload();
|
|
45
|
+
|
|
46
|
+
@ReactMethod
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
public abstract void updateBundle(ReadableMap params, Promise promise);
|
|
49
|
+
|
|
50
|
+
@ReactMethod
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
public abstract void getAppVersion(Promise promise);
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
@DoNotStrip
|
|
56
|
+
public abstract void setChannel(String channel, Promise promise);
|
|
57
|
+
|
|
58
|
+
@ReactMethod
|
|
59
|
+
@DoNotStrip
|
|
60
|
+
public abstract void addListener(String eventName);
|
|
61
|
+
|
|
62
|
+
@ReactMethod
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
public abstract void removeListeners(double count);
|
|
65
|
+
|
|
66
|
+
protected abstract Map<String, Object> getTypedExportedConstants();
|
|
67
|
+
|
|
68
|
+
@Override
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
public final @Nullable Map<String, Object> getConstants() {
|
|
71
|
+
Map<String, Object> constants = getTypedExportedConstants();
|
|
72
|
+
if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
|
|
73
|
+
Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
|
|
74
|
+
"MIN_BUNDLE_ID"
|
|
75
|
+
));
|
|
76
|
+
Set<String> optionalFlowConstants = new HashSet<>(Arrays.asList(
|
|
77
|
+
"APP_VERSION",
|
|
78
|
+
"CHANNEL"
|
|
79
|
+
));
|
|
80
|
+
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
|
|
81
|
+
undeclaredConstants.removeAll(obligatoryFlowConstants);
|
|
82
|
+
undeclaredConstants.removeAll(optionalFlowConstants);
|
|
83
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
84
|
+
throw new IllegalStateException(String.format("Native Module Flow doesn't declare constants: %s", undeclaredConstants));
|
|
85
|
+
}
|
|
86
|
+
undeclaredConstants = obligatoryFlowConstants;
|
|
87
|
+
undeclaredConstants.removeAll(constants.keySet());
|
|
88
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
89
|
+
throw new IllegalStateException(String.format("Native Module doesn't fill in constants: %s", undeclaredConstants));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return constants;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/HotUpdaterSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_HotUpdaterSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_HotUpdaterSpec PUBLIC . react/renderer/components/HotUpdaterSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_HotUpdaterSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_options(
|
|
29
|
+
react_codegen_HotUpdaterSpec
|
|
30
|
+
PRIVATE
|
|
31
|
+
-DLOG_TAG=\"ReactNative\"
|
|
32
|
+
-fexceptions
|
|
33
|
+
-frtti
|
|
34
|
+
-std=c++20
|
|
35
|
+
-Wall
|
|
36
|
+
)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "HotUpdater.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_reload(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "reload", "()V", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_updateBundle(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "updateBundle", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_getAppVersion(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
26
|
+
static jmethodID cachedMethodId = nullptr;
|
|
27
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getAppVersion", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_setChannel(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
31
|
+
static jmethodID cachedMethodId = nullptr;
|
|
32
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "setChannel", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
36
|
+
static jmethodID cachedMethodId = nullptr;
|
|
37
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "addListener", "(Ljava/lang/String;)V", args, count, cachedMethodId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_removeListeners(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
41
|
+
static jmethodID cachedMethodId = nullptr;
|
|
42
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "removeListeners", "(D)V", args, count, cachedMethodId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
46
|
+
static jmethodID cachedMethodId = nullptr;
|
|
47
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, ObjectKind, "getConstants", "()Ljava/util/Map;", args, count, cachedMethodId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
NativeHotUpdaterSpecJSI::NativeHotUpdaterSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
51
|
+
: JavaTurboModule(params) {
|
|
52
|
+
methodMap_["reload"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterSpecJSI_reload};
|
|
53
|
+
methodMap_["updateBundle"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_updateBundle};
|
|
54
|
+
methodMap_["getAppVersion"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterSpecJSI_getAppVersion};
|
|
55
|
+
methodMap_["setChannel"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_setChannel};
|
|
56
|
+
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_addListener};
|
|
57
|
+
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_removeListeners};
|
|
58
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterSpecJSI_getConstants};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
std::shared_ptr<TurboModule> HotUpdater_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
62
|
+
if (moduleName == "HotUpdater") {
|
|
63
|
+
return std::make_shared<NativeHotUpdaterSpecJSI>(params);
|
|
64
|
+
}
|
|
65
|
+
return nullptr;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeHotUpdater'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeHotUpdaterSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeHotUpdaterSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> HotUpdater_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "HotUpdaterSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_reload(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "reload", "()V", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_updateBundle(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "updateBundle", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_getAppVersion(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
26
|
+
static jmethodID cachedMethodId = nullptr;
|
|
27
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getAppVersion", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_setChannel(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
31
|
+
static jmethodID cachedMethodId = nullptr;
|
|
32
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "setChannel", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
36
|
+
static jmethodID cachedMethodId = nullptr;
|
|
37
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "addListener", "(Ljava/lang/String;)V", args, count, cachedMethodId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_removeListeners(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
41
|
+
static jmethodID cachedMethodId = nullptr;
|
|
42
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "removeListeners", "(D)V", args, count, cachedMethodId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static facebook::jsi::Value __hostFunction_NativeHotUpdaterSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
46
|
+
static jmethodID cachedMethodId = nullptr;
|
|
47
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, ObjectKind, "getConstants", "()Ljava/util/Map;", args, count, cachedMethodId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
NativeHotUpdaterSpecJSI::NativeHotUpdaterSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
51
|
+
: JavaTurboModule(params) {
|
|
52
|
+
methodMap_["reload"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterSpecJSI_reload};
|
|
53
|
+
methodMap_["updateBundle"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_updateBundle};
|
|
54
|
+
methodMap_["getAppVersion"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterSpecJSI_getAppVersion};
|
|
55
|
+
methodMap_["setChannel"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_setChannel};
|
|
56
|
+
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_addListener};
|
|
57
|
+
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterSpecJSI_removeListeners};
|
|
58
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterSpecJSI_getConstants};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
std::shared_ptr<TurboModule> HotUpdaterSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
62
|
+
if (moduleName == "HotUpdater") {
|
|
63
|
+
return std::make_shared<NativeHotUpdaterSpecJSI>(params);
|
|
64
|
+
}
|
|
65
|
+
return nullptr;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeHotUpdater'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeHotUpdaterSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeHotUpdaterSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> HotUpdaterSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "HotUpdaterJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_reload(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->reload(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
return jsi::Value::undefined();
|
|
19
|
+
}
|
|
20
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_updateBundle(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
21
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->updateBundle(
|
|
22
|
+
rt,
|
|
23
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_getAppVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
27
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->getAppVersion(
|
|
28
|
+
rt
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_setChannel(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
32
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->setChannel(
|
|
33
|
+
rt,
|
|
34
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_addListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
38
|
+
static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->addListener(
|
|
39
|
+
rt,
|
|
40
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
41
|
+
);
|
|
42
|
+
return jsi::Value::undefined();
|
|
43
|
+
}
|
|
44
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_removeListeners(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
45
|
+
static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->removeListeners(
|
|
46
|
+
rt,
|
|
47
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
48
|
+
);
|
|
49
|
+
return jsi::Value::undefined();
|
|
50
|
+
}
|
|
51
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
52
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->getConstants(
|
|
53
|
+
rt
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
NativeHotUpdaterCxxSpecJSI::NativeHotUpdaterCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
58
|
+
: TurboModule("HotUpdater", jsInvoker) {
|
|
59
|
+
methodMap_["reload"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterCxxSpecJSI_reload};
|
|
60
|
+
methodMap_["updateBundle"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_updateBundle};
|
|
61
|
+
methodMap_["getAppVersion"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterCxxSpecJSI_getAppVersion};
|
|
62
|
+
methodMap_["setChannel"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_setChannel};
|
|
63
|
+
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_addListener};
|
|
64
|
+
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_removeListeners};
|
|
65
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterCxxSpecJSI_getConstants};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#pragma mark - NativeHotUpdaterUpdateBundleParams
|
|
20
|
+
|
|
21
|
+
template <typename P0, typename P1>
|
|
22
|
+
struct NativeHotUpdaterUpdateBundleParams {
|
|
23
|
+
P0 bundleId;
|
|
24
|
+
P1 zipUrl;
|
|
25
|
+
bool operator==(const NativeHotUpdaterUpdateBundleParams &other) const {
|
|
26
|
+
return bundleId == other.bundleId && zipUrl == other.zipUrl;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
template <typename T>
|
|
31
|
+
struct NativeHotUpdaterUpdateBundleParamsBridging {
|
|
32
|
+
static T types;
|
|
33
|
+
|
|
34
|
+
static T fromJs(
|
|
35
|
+
jsi::Runtime &rt,
|
|
36
|
+
const jsi::Object &value,
|
|
37
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
38
|
+
T result{
|
|
39
|
+
bridging::fromJs<decltype(types.bundleId)>(rt, value.getProperty(rt, "bundleId"), jsInvoker),
|
|
40
|
+
bridging::fromJs<decltype(types.zipUrl)>(rt, value.getProperty(rt, "zipUrl"), jsInvoker)};
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#ifdef DEBUG
|
|
45
|
+
static jsi::String bundleIdToJs(jsi::Runtime &rt, decltype(types.bundleId) value) {
|
|
46
|
+
return bridging::toJs(rt, value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static std::optional<jsi::String> zipUrlToJs(jsi::Runtime &rt, decltype(types.zipUrl) value) {
|
|
50
|
+
return bridging::toJs(rt, value);
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
static jsi::Object toJs(
|
|
55
|
+
jsi::Runtime &rt,
|
|
56
|
+
const T &value,
|
|
57
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
58
|
+
auto result = facebook::jsi::Object(rt);
|
|
59
|
+
result.setProperty(rt, "bundleId", bridging::toJs(rt, value.bundleId, jsInvoker));
|
|
60
|
+
result.setProperty(rt, "zipUrl", bridging::toJs(rt, value.zipUrl, jsInvoker));
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
class JSI_EXPORT NativeHotUpdaterCxxSpecJSI : public TurboModule {
|
|
66
|
+
protected:
|
|
67
|
+
NativeHotUpdaterCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
virtual void reload(jsi::Runtime &rt) = 0;
|
|
71
|
+
virtual jsi::Value updateBundle(jsi::Runtime &rt, jsi::Object params) = 0;
|
|
72
|
+
virtual jsi::Value getAppVersion(jsi::Runtime &rt) = 0;
|
|
73
|
+
virtual jsi::Value setChannel(jsi::Runtime &rt, jsi::String channel) = 0;
|
|
74
|
+
virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0;
|
|
75
|
+
virtual void removeListeners(jsi::Runtime &rt, double count) = 0;
|
|
76
|
+
virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;
|
|
77
|
+
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
template <typename T>
|
|
81
|
+
class JSI_EXPORT NativeHotUpdaterCxxSpec : public TurboModule {
|
|
82
|
+
public:
|
|
83
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
84
|
+
return delegate_.get(rt, propName);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static constexpr std::string_view kModuleName = "HotUpdater";
|
|
88
|
+
|
|
89
|
+
protected:
|
|
90
|
+
NativeHotUpdaterCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
91
|
+
: TurboModule(std::string{NativeHotUpdaterCxxSpec::kModuleName}, jsInvoker),
|
|
92
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
private:
|
|
96
|
+
class Delegate : public NativeHotUpdaterCxxSpecJSI {
|
|
97
|
+
public:
|
|
98
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
99
|
+
NativeHotUpdaterCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
void reload(jsi::Runtime &rt) override {
|
|
104
|
+
static_assert(
|
|
105
|
+
bridging::getParameterCount(&T::reload) == 1,
|
|
106
|
+
"Expected reload(...) to have 1 parameters");
|
|
107
|
+
|
|
108
|
+
return bridging::callFromJs<void>(
|
|
109
|
+
rt, &T::reload, jsInvoker_, instance_);
|
|
110
|
+
}
|
|
111
|
+
jsi::Value updateBundle(jsi::Runtime &rt, jsi::Object params) override {
|
|
112
|
+
static_assert(
|
|
113
|
+
bridging::getParameterCount(&T::updateBundle) == 2,
|
|
114
|
+
"Expected updateBundle(...) to have 2 parameters");
|
|
115
|
+
|
|
116
|
+
return bridging::callFromJs<jsi::Value>(
|
|
117
|
+
rt, &T::updateBundle, jsInvoker_, instance_, std::move(params));
|
|
118
|
+
}
|
|
119
|
+
jsi::Value getAppVersion(jsi::Runtime &rt) override {
|
|
120
|
+
static_assert(
|
|
121
|
+
bridging::getParameterCount(&T::getAppVersion) == 1,
|
|
122
|
+
"Expected getAppVersion(...) to have 1 parameters");
|
|
123
|
+
|
|
124
|
+
return bridging::callFromJs<jsi::Value>(
|
|
125
|
+
rt, &T::getAppVersion, jsInvoker_, instance_);
|
|
126
|
+
}
|
|
127
|
+
jsi::Value setChannel(jsi::Runtime &rt, jsi::String channel) override {
|
|
128
|
+
static_assert(
|
|
129
|
+
bridging::getParameterCount(&T::setChannel) == 2,
|
|
130
|
+
"Expected setChannel(...) to have 2 parameters");
|
|
131
|
+
|
|
132
|
+
return bridging::callFromJs<jsi::Value>(
|
|
133
|
+
rt, &T::setChannel, jsInvoker_, instance_, std::move(channel));
|
|
134
|
+
}
|
|
135
|
+
void addListener(jsi::Runtime &rt, jsi::String eventName) override {
|
|
136
|
+
static_assert(
|
|
137
|
+
bridging::getParameterCount(&T::addListener) == 2,
|
|
138
|
+
"Expected addListener(...) to have 2 parameters");
|
|
139
|
+
|
|
140
|
+
return bridging::callFromJs<void>(
|
|
141
|
+
rt, &T::addListener, jsInvoker_, instance_, std::move(eventName));
|
|
142
|
+
}
|
|
143
|
+
void removeListeners(jsi::Runtime &rt, double count) override {
|
|
144
|
+
static_assert(
|
|
145
|
+
bridging::getParameterCount(&T::removeListeners) == 2,
|
|
146
|
+
"Expected removeListeners(...) to have 2 parameters");
|
|
147
|
+
|
|
148
|
+
return bridging::callFromJs<void>(
|
|
149
|
+
rt, &T::removeListeners, jsInvoker_, instance_, std::move(count));
|
|
150
|
+
}
|
|
151
|
+
jsi::Object getConstants(jsi::Runtime &rt) override {
|
|
152
|
+
static_assert(
|
|
153
|
+
bridging::getParameterCount(&T::getConstants) == 1,
|
|
154
|
+
"Expected getConstants(...) to have 1 parameters");
|
|
155
|
+
|
|
156
|
+
return bridging::callFromJs<jsi::Object>(
|
|
157
|
+
rt, &T::getConstants, jsInvoker_, instance_);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private:
|
|
161
|
+
friend class NativeHotUpdaterCxxSpec;
|
|
162
|
+
T *instance_;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
Delegate delegate_;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "HotUpdaterSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_reload(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->reload(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
return jsi::Value::undefined();
|
|
19
|
+
}
|
|
20
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_updateBundle(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
21
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->updateBundle(
|
|
22
|
+
rt,
|
|
23
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_getAppVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
27
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->getAppVersion(
|
|
28
|
+
rt
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_setChannel(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
32
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->setChannel(
|
|
33
|
+
rt,
|
|
34
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_addListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
38
|
+
static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->addListener(
|
|
39
|
+
rt,
|
|
40
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
41
|
+
);
|
|
42
|
+
return jsi::Value::undefined();
|
|
43
|
+
}
|
|
44
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_removeListeners(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
45
|
+
static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->removeListeners(
|
|
46
|
+
rt,
|
|
47
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
48
|
+
);
|
|
49
|
+
return jsi::Value::undefined();
|
|
50
|
+
}
|
|
51
|
+
static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
52
|
+
return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->getConstants(
|
|
53
|
+
rt
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
NativeHotUpdaterCxxSpecJSI::NativeHotUpdaterCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
58
|
+
: TurboModule("HotUpdater", jsInvoker) {
|
|
59
|
+
methodMap_["reload"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterCxxSpecJSI_reload};
|
|
60
|
+
methodMap_["updateBundle"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_updateBundle};
|
|
61
|
+
methodMap_["getAppVersion"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterCxxSpecJSI_getAppVersion};
|
|
62
|
+
methodMap_["setChannel"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_setChannel};
|
|
63
|
+
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_addListener};
|
|
64
|
+
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeHotUpdaterCxxSpecJSI_removeListeners};
|
|
65
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeHotUpdaterCxxSpecJSI_getConstants};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#pragma mark - NativeHotUpdaterUpdateBundleParams
|
|
20
|
+
|
|
21
|
+
template <typename P0, typename P1>
|
|
22
|
+
struct NativeHotUpdaterUpdateBundleParams {
|
|
23
|
+
P0 bundleId;
|
|
24
|
+
P1 zipUrl;
|
|
25
|
+
bool operator==(const NativeHotUpdaterUpdateBundleParams &other) const {
|
|
26
|
+
return bundleId == other.bundleId && zipUrl == other.zipUrl;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
template <typename T>
|
|
31
|
+
struct NativeHotUpdaterUpdateBundleParamsBridging {
|
|
32
|
+
static T types;
|
|
33
|
+
|
|
34
|
+
static T fromJs(
|
|
35
|
+
jsi::Runtime &rt,
|
|
36
|
+
const jsi::Object &value,
|
|
37
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
38
|
+
T result{
|
|
39
|
+
bridging::fromJs<decltype(types.bundleId)>(rt, value.getProperty(rt, "bundleId"), jsInvoker),
|
|
40
|
+
bridging::fromJs<decltype(types.zipUrl)>(rt, value.getProperty(rt, "zipUrl"), jsInvoker)};
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#ifdef DEBUG
|
|
45
|
+
static jsi::String bundleIdToJs(jsi::Runtime &rt, decltype(types.bundleId) value) {
|
|
46
|
+
return bridging::toJs(rt, value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static std::optional<jsi::String> zipUrlToJs(jsi::Runtime &rt, decltype(types.zipUrl) value) {
|
|
50
|
+
return bridging::toJs(rt, value);
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
static jsi::Object toJs(
|
|
55
|
+
jsi::Runtime &rt,
|
|
56
|
+
const T &value,
|
|
57
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
58
|
+
auto result = facebook::jsi::Object(rt);
|
|
59
|
+
result.setProperty(rt, "bundleId", bridging::toJs(rt, value.bundleId, jsInvoker));
|
|
60
|
+
result.setProperty(rt, "zipUrl", bridging::toJs(rt, value.zipUrl, jsInvoker));
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
class JSI_EXPORT NativeHotUpdaterCxxSpecJSI : public TurboModule {
|
|
66
|
+
protected:
|
|
67
|
+
NativeHotUpdaterCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
virtual void reload(jsi::Runtime &rt) = 0;
|
|
71
|
+
virtual jsi::Value updateBundle(jsi::Runtime &rt, jsi::Object params) = 0;
|
|
72
|
+
virtual jsi::Value getAppVersion(jsi::Runtime &rt) = 0;
|
|
73
|
+
virtual jsi::Value setChannel(jsi::Runtime &rt, jsi::String channel) = 0;
|
|
74
|
+
virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0;
|
|
75
|
+
virtual void removeListeners(jsi::Runtime &rt, double count) = 0;
|
|
76
|
+
virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;
|
|
77
|
+
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
template <typename T>
|
|
81
|
+
class JSI_EXPORT NativeHotUpdaterCxxSpec : public TurboModule {
|
|
82
|
+
public:
|
|
83
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
84
|
+
return delegate_.create(rt, propName);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
88
|
+
return delegate_.getPropertyNames(runtime);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static constexpr std::string_view kModuleName = "HotUpdater";
|
|
92
|
+
|
|
93
|
+
protected:
|
|
94
|
+
NativeHotUpdaterCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
95
|
+
: TurboModule(std::string{NativeHotUpdaterCxxSpec::kModuleName}, jsInvoker),
|
|
96
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
private:
|
|
100
|
+
class Delegate : public NativeHotUpdaterCxxSpecJSI {
|
|
101
|
+
public:
|
|
102
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
103
|
+
NativeHotUpdaterCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void reload(jsi::Runtime &rt) override {
|
|
108
|
+
static_assert(
|
|
109
|
+
bridging::getParameterCount(&T::reload) == 1,
|
|
110
|
+
"Expected reload(...) to have 1 parameters");
|
|
111
|
+
|
|
112
|
+
return bridging::callFromJs<void>(
|
|
113
|
+
rt, &T::reload, jsInvoker_, instance_);
|
|
114
|
+
}
|
|
115
|
+
jsi::Value updateBundle(jsi::Runtime &rt, jsi::Object params) override {
|
|
116
|
+
static_assert(
|
|
117
|
+
bridging::getParameterCount(&T::updateBundle) == 2,
|
|
118
|
+
"Expected updateBundle(...) to have 2 parameters");
|
|
119
|
+
|
|
120
|
+
return bridging::callFromJs<jsi::Value>(
|
|
121
|
+
rt, &T::updateBundle, jsInvoker_, instance_, std::move(params));
|
|
122
|
+
}
|
|
123
|
+
jsi::Value getAppVersion(jsi::Runtime &rt) override {
|
|
124
|
+
static_assert(
|
|
125
|
+
bridging::getParameterCount(&T::getAppVersion) == 1,
|
|
126
|
+
"Expected getAppVersion(...) to have 1 parameters");
|
|
127
|
+
|
|
128
|
+
return bridging::callFromJs<jsi::Value>(
|
|
129
|
+
rt, &T::getAppVersion, jsInvoker_, instance_);
|
|
130
|
+
}
|
|
131
|
+
jsi::Value setChannel(jsi::Runtime &rt, jsi::String channel) override {
|
|
132
|
+
static_assert(
|
|
133
|
+
bridging::getParameterCount(&T::setChannel) == 2,
|
|
134
|
+
"Expected setChannel(...) to have 2 parameters");
|
|
135
|
+
|
|
136
|
+
return bridging::callFromJs<jsi::Value>(
|
|
137
|
+
rt, &T::setChannel, jsInvoker_, instance_, std::move(channel));
|
|
138
|
+
}
|
|
139
|
+
void addListener(jsi::Runtime &rt, jsi::String eventName) override {
|
|
140
|
+
static_assert(
|
|
141
|
+
bridging::getParameterCount(&T::addListener) == 2,
|
|
142
|
+
"Expected addListener(...) to have 2 parameters");
|
|
143
|
+
|
|
144
|
+
return bridging::callFromJs<void>(
|
|
145
|
+
rt, &T::addListener, jsInvoker_, instance_, std::move(eventName));
|
|
146
|
+
}
|
|
147
|
+
void removeListeners(jsi::Runtime &rt, double count) override {
|
|
148
|
+
static_assert(
|
|
149
|
+
bridging::getParameterCount(&T::removeListeners) == 2,
|
|
150
|
+
"Expected removeListeners(...) to have 2 parameters");
|
|
151
|
+
|
|
152
|
+
return bridging::callFromJs<void>(
|
|
153
|
+
rt, &T::removeListeners, jsInvoker_, instance_, std::move(count));
|
|
154
|
+
}
|
|
155
|
+
jsi::Object getConstants(jsi::Runtime &rt) override {
|
|
156
|
+
static_assert(
|
|
157
|
+
bridging::getParameterCount(&T::getConstants) == 1,
|
|
158
|
+
"Expected getConstants(...) to have 1 parameters");
|
|
159
|
+
|
|
160
|
+
return bridging::callFromJs<jsi::Object>(
|
|
161
|
+
rt, &T::getConstants, jsInvoker_, instance_);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private:
|
|
165
|
+
friend class NativeHotUpdaterCxxSpec;
|
|
166
|
+
T *instance_;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
Delegate delegate_;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
} // namespace facebook::react
|
|
@@ -167,17 +167,30 @@ class HotUpdaterImpl(
|
|
|
167
167
|
* @param activity Current activity (optional)
|
|
168
168
|
*/
|
|
169
169
|
fun reload(activity: Activity? = null) {
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
if (activity == null) {
|
|
171
|
+
Log.e("HotUpdaterImpl", "Activity is null, cannot reload")
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
val application = activity.application
|
|
176
|
+
if (application == null) {
|
|
177
|
+
Log.e("HotUpdaterImpl", "Application is null, cannot reload")
|
|
178
|
+
return
|
|
179
|
+
}
|
|
172
180
|
|
|
173
181
|
try {
|
|
182
|
+
val reactIntegrationManager = ReactIntegrationManager(context)
|
|
174
183
|
val reactApplication = reactIntegrationManager.getReactApplication(application)
|
|
175
184
|
val bundleURL = getJSBundleFile()
|
|
176
185
|
|
|
177
186
|
reactIntegrationManager.setJSBundle(reactApplication, bundleURL)
|
|
178
187
|
|
|
179
188
|
Handler(Looper.getMainLooper()).post {
|
|
180
|
-
|
|
189
|
+
try {
|
|
190
|
+
reactIntegrationManager.reload(reactApplication)
|
|
191
|
+
} catch (e: Exception) {
|
|
192
|
+
Log.e("HotUpdaterImpl", "Failed to reload on main thread", e)
|
|
193
|
+
}
|
|
181
194
|
}
|
|
182
195
|
} catch (e: Exception) {
|
|
183
196
|
Log.e("HotUpdaterImpl", "Failed to reload application", e)
|
|
@@ -25,6 +25,9 @@ open class ReactIntegrationManagerBase(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
public fun getReactApplication(application: Application?): ReactApplication {
|
|
28
|
+
if (application == null) {
|
|
29
|
+
throw IllegalArgumentException("Application is null")
|
|
30
|
+
}
|
|
28
31
|
if (application is ReactApplication) {
|
|
29
32
|
return application
|
|
30
33
|
} else {
|
|
@@ -53,26 +53,37 @@ class ReactIntegrationManager(
|
|
|
53
53
|
try {
|
|
54
54
|
val reactHost = application.reactHost
|
|
55
55
|
if (reactHost != null) {
|
|
56
|
-
val
|
|
57
|
-
if (
|
|
58
|
-
|
|
56
|
+
val currentReactContext = reactHost.currentReactContext
|
|
57
|
+
if (currentReactContext != null) {
|
|
58
|
+
val activity = currentReactContext.currentActivity
|
|
59
|
+
if (reactHost.lifecycleState != LifecycleState.RESUMED && activity != null) {
|
|
60
|
+
reactHost.onHostResume(activity)
|
|
61
|
+
}
|
|
62
|
+
reactHost.reload("Requested by HotUpdater")
|
|
63
|
+
} else {
|
|
64
|
+
Log.d("HotUpdater", "ReactContext is null, cannot reload safely")
|
|
59
65
|
}
|
|
60
|
-
reactHost.reload("Requested by HotUpdater")
|
|
61
66
|
} else {
|
|
62
67
|
val reactNativeHost = application.reactNativeHost
|
|
63
68
|
try {
|
|
64
69
|
reactNativeHost.reactInstanceManager.recreateReactContextInBackground()
|
|
65
70
|
} catch (e: Exception) {
|
|
66
|
-
|
|
71
|
+
Log.d("HotUpdater", "Failed to recreate context in background: ${e.message}")
|
|
72
|
+
|
|
73
|
+
val currentReactContext = reactNativeHost.reactInstanceManager.currentReactContext
|
|
74
|
+
val currentActivity = currentReactContext?.currentActivity
|
|
67
75
|
if (currentActivity == null) {
|
|
76
|
+
Log.d("HotUpdater", "No current activity available for fallback reload")
|
|
68
77
|
return
|
|
69
78
|
}
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
currentActivity.
|
|
80
|
+
try {
|
|
81
|
+
currentActivity.runOnUiThread {
|
|
82
|
+
currentActivity.recreate()
|
|
83
|
+
}
|
|
84
|
+
} catch (e: Exception) {
|
|
85
|
+
Log.d("HotUpdater", "Failed to recreate activity: ${e.message}")
|
|
73
86
|
}
|
|
74
|
-
} catch (e: Exception) {
|
|
75
|
-
Log.d("HotUpdater", "Failed to reload: ${e.message}")
|
|
76
87
|
}
|
|
77
88
|
}
|
|
78
89
|
} catch (e: Exception) {
|
|
@@ -34,17 +34,36 @@ class ReactIntegrationManager(
|
|
|
34
34
|
* Reload the React Native application.
|
|
35
35
|
*/
|
|
36
36
|
public fun reload(application: ReactApplication) {
|
|
37
|
-
val reactNativeHost = application.reactNativeHost
|
|
38
37
|
try {
|
|
39
|
-
reactNativeHost.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if
|
|
38
|
+
val reactNativeHost = application.reactNativeHost
|
|
39
|
+
val reactInstanceManager = reactNativeHost.reactInstanceManager
|
|
40
|
+
|
|
41
|
+
// Check if React instance is available before attempting reload
|
|
42
|
+
val currentReactContext = reactInstanceManager.currentReactContext
|
|
43
|
+
if (currentReactContext == null) {
|
|
44
|
+
Log.d("HotUpdater", "ReactContext is null, cannot reload safely")
|
|
43
45
|
return
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
try {
|
|
49
|
+
reactInstanceManager.recreateReactContextInBackground()
|
|
50
|
+
} catch (e: Exception) {
|
|
51
|
+
Log.d("HotUpdater", "Failed to recreate context in background: ${e.message}")
|
|
52
|
+
|
|
53
|
+
// Fallback to activity recreation if available
|
|
54
|
+
val currentActivity = currentReactContext.currentActivity
|
|
55
|
+
if (currentActivity == null) {
|
|
56
|
+
Log.d("HotUpdater", "No current activity available for fallback reload")
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
currentActivity.runOnUiThread {
|
|
62
|
+
currentActivity.recreate()
|
|
63
|
+
}
|
|
64
|
+
} catch (e: Exception) {
|
|
65
|
+
Log.d("HotUpdater", "Failed to recreate activity: ${e.message}")
|
|
66
|
+
}
|
|
48
67
|
}
|
|
49
68
|
} catch (e: Exception) {
|
|
50
69
|
Log.d("HotUpdater", "Failed to reload: ${e.message}")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"originHash" : "11a19903c341bf413adfdb15a6fb5dff9a819b0557a6cfe9e5fe00f32a0ff74e",
|
|
3
|
+
"pins" : [
|
|
4
|
+
{
|
|
5
|
+
"identity" : "ziparchive",
|
|
6
|
+
"kind" : "remoteSourceControl",
|
|
7
|
+
"location" : "https://github.com/ZipArchive/ZipArchive.git",
|
|
8
|
+
"state" : {
|
|
9
|
+
"revision" : "df35718ea19a94e015b91dc4881dee028ce4cdba",
|
|
10
|
+
"version" : "2.6.0"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"version" : 3
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-rc.0",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"expo": ">=50.0.0",
|
|
108
108
|
"react": "*",
|
|
109
109
|
"react-native": "*",
|
|
110
|
-
"hot-updater": "
|
|
110
|
+
"hot-updater": "0.20.0-rc.0"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@react-native-community/cli": "18.0.0",
|
|
@@ -119,12 +119,13 @@
|
|
|
119
119
|
"react-native": "0.79.1",
|
|
120
120
|
"react-native-builder-bob": "^0.40.10",
|
|
121
121
|
"typescript": "^5.8.3",
|
|
122
|
-
"hot-updater": "0.
|
|
122
|
+
"hot-updater": "0.20.0-rc.0"
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
125
125
|
"use-sync-external-store": "1.5.0",
|
|
126
|
-
"@hot-updater/core": "0.
|
|
127
|
-
"@hot-updater/
|
|
126
|
+
"@hot-updater/core": "0.20.0-rc.0",
|
|
127
|
+
"@hot-updater/plugin-core": "0.20.0-rc.0",
|
|
128
|
+
"@hot-updater/js": "0.20.0-rc.0"
|
|
128
129
|
},
|
|
129
130
|
"scripts": {
|
|
130
131
|
"build": "bob build && tsc -p plugin/tsconfig.json",
|
|
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var plugin_core_1 = require("@hot-updater/plugin-core");
|
|
42
43
|
var config_plugins_1 = require("expo/config-plugins");
|
|
43
44
|
var hot_updater_1 = require("hot-updater");
|
|
44
45
|
var package_json_1 = __importDefault(require("../../package.json"));
|
|
@@ -207,26 +208,46 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
|
|
|
207
208
|
var modifiedConfig = config;
|
|
208
209
|
// === iOS: Add channel and fingerprint to Info.plist ===
|
|
209
210
|
modifiedConfig = (0, config_plugins_1.withInfoPlist)(modifiedConfig, function (cfg) { return __awaiter(void 0, void 0, void 0, function () {
|
|
210
|
-
var ios;
|
|
211
|
+
var fingerprintHash, config, ios;
|
|
211
212
|
return __generator(this, function (_a) {
|
|
212
213
|
switch (_a.label) {
|
|
213
|
-
case 0:
|
|
214
|
+
case 0:
|
|
215
|
+
fingerprintHash = null;
|
|
216
|
+
return [4 /*yield*/, (0, plugin_core_1.loadConfig)(null)];
|
|
214
217
|
case 1:
|
|
218
|
+
config = _a.sent();
|
|
219
|
+
if (!(config.updateStrategy !== "appVersion")) return [3 /*break*/, 3];
|
|
220
|
+
return [4 /*yield*/, getFingerprint()];
|
|
221
|
+
case 2:
|
|
215
222
|
ios = (_a.sent()).ios;
|
|
223
|
+
fingerprintHash = ios.hash;
|
|
224
|
+
_a.label = 3;
|
|
225
|
+
case 3:
|
|
216
226
|
cfg.modResults.HOT_UPDATER_CHANNEL = channel;
|
|
217
|
-
|
|
227
|
+
if (fingerprintHash) {
|
|
228
|
+
cfg.modResults.HOT_UPDATER_FINGERPRINT_HASH = fingerprintHash;
|
|
229
|
+
}
|
|
218
230
|
return [2 /*return*/, cfg];
|
|
219
231
|
}
|
|
220
232
|
});
|
|
221
233
|
}); });
|
|
222
234
|
// === Android: Add channel and fingerprint to strings.xml ===
|
|
223
235
|
modifiedConfig = (0, config_plugins_1.withStringsXml)(modifiedConfig, function (cfg) { return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
-
var android;
|
|
236
|
+
var fingerprintHash, config, android;
|
|
225
237
|
return __generator(this, function (_a) {
|
|
226
238
|
switch (_a.label) {
|
|
227
|
-
case 0:
|
|
239
|
+
case 0:
|
|
240
|
+
fingerprintHash = null;
|
|
241
|
+
return [4 /*yield*/, (0, plugin_core_1.loadConfig)(null)];
|
|
228
242
|
case 1:
|
|
243
|
+
config = _a.sent();
|
|
244
|
+
if (!(config.updateStrategy !== "appVersion")) return [3 /*break*/, 3];
|
|
245
|
+
return [4 /*yield*/, getFingerprint()];
|
|
246
|
+
case 2:
|
|
229
247
|
android = (_a.sent()).android;
|
|
248
|
+
fingerprintHash = android.hash;
|
|
249
|
+
_a.label = 3;
|
|
250
|
+
case 3:
|
|
230
251
|
// Ensure resources object exists
|
|
231
252
|
if (!cfg.modResults.resources) {
|
|
232
253
|
cfg.modResults.resources = {};
|
|
@@ -244,16 +265,21 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
|
|
|
244
265
|
},
|
|
245
266
|
_: channel,
|
|
246
267
|
});
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
268
|
+
if (fingerprintHash) {
|
|
269
|
+
// Remove existing hot_updater_fingerprint_hash entry if it exists
|
|
270
|
+
cfg.modResults.resources.string =
|
|
271
|
+
cfg.modResults.resources.string.filter(function (item) {
|
|
272
|
+
return !(item.$ && item.$.name === "hot_updater_fingerprint_hash");
|
|
273
|
+
});
|
|
274
|
+
// Add the new hot_updater_fingerprint_hash entry
|
|
275
|
+
cfg.modResults.resources.string.push({
|
|
276
|
+
$: {
|
|
277
|
+
name: "hot_updater_fingerprint_hash",
|
|
278
|
+
moduleConfig: "true",
|
|
279
|
+
},
|
|
280
|
+
_: fingerprintHash,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
257
283
|
return [2 /*return*/, cfg];
|
|
258
284
|
}
|
|
259
285
|
});
|