Skip to content

Commit

Permalink
Merge branch 'main' into @tomekzaw/set-native-props
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw authored Aug 3, 2023
2 parents bee8119 + 013c510 commit c3ead49
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 233 deletions.
3 changes: 2 additions & 1 deletion Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jsi::Value AnimatedSensorModule::registerSensor(
const jsi::Value &sensorDataHandler) {
SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());

auto shareableHandler = extractShareableOrThrow(rt, sensorDataHandler);
auto shareableHandler = extractShareableOrThrow<ShareableWorklet>(
rt, sensorDataHandler, "sensor event handler must be a worklet");

int sensorId = platformRegisterSensorFunction_(
sensorType,
Expand Down
18 changes: 10 additions & 8 deletions Common/cpp/NativeModules/NativeReanimatedModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,8 @@ NativeReanimatedModule::~NativeReanimatedModule() {
void NativeReanimatedModule::scheduleOnUI(
jsi::Runtime &rt,
const jsi::Value &worklet) {
auto shareableWorklet = extractShareableOrThrow(rt, worklet);
assert(
shareableWorklet->valueType() == Shareable::WorkletType &&
"only worklets can be scheduled to run on UI");
auto shareableWorklet = extractShareableOrThrow<ShareableWorklet>(
rt, worklet, "only worklets can be scheduled to run on UI");
runtimeManager_->uiScheduler_->scheduleOnUI([=] {
jsi::Runtime &rt = *runtimeHelper->uiRuntime();
auto workletValue = shareableWorklet->getJSValue(rt);
Expand All @@ -217,7 +215,8 @@ void NativeReanimatedModule::scheduleOnJS(
"Incompatible object passed to scheduleOnJS. It is only allowed to schedule worklets or functions defined on the React Native JS runtime this way.");
auto shareableArgs = argsValue.isUndefined()
? nullptr
: extractShareableOrThrow(rt, argsValue);
: extractShareableOrThrow<ShareableArray>(
rt, argsValue, "args must be an array");
auto jsRuntime = this->runtimeHelper->rnRuntime();
runtimeManager_->jsScheduler_->scheduleOnJS([=] {
jsi::Runtime &rt = *jsRuntime;
Expand Down Expand Up @@ -333,7 +332,8 @@ jsi::Value NativeReanimatedModule::registerEventHandler(

uint64_t newRegistrationId = EVENT_HANDLER_ID++;
auto eventName = eventHash.asString(rt).utf8(rt);
auto handlerShareable = extractShareableOrThrow(rt, worklet);
auto handlerShareable = extractShareableOrThrow<ShareableWorklet>(
rt, worklet, "event handler must be a worklet");

runtimeManager_->uiScheduler_->scheduleOnUI([=] {
jsi::Runtime &rt = *runtimeHelper->uiRuntime();
Expand Down Expand Up @@ -420,7 +420,8 @@ jsi::Value NativeReanimatedModule::configureLayoutAnimation(
viewTag.asNumber(),
static_cast<LayoutAnimationType>(type.asNumber()),
sharedTransitionTag.asString(rt).utf8(rt),
extractShareableOrThrow(rt, config));
extractShareableOrThrow<ShareableObject>(
rt, config, "layout animation config must be an object"));
return jsi::Value::undefined();
}

Expand Down Expand Up @@ -735,7 +736,8 @@ jsi::Value NativeReanimatedModule::subscribeForKeyboardEvents(
jsi::Runtime &rt,
const jsi::Value &handlerWorklet,
const jsi::Value &isStatusBarTranslucent) {
auto shareableHandler = extractShareableOrThrow(rt, handlerWorklet);
auto shareableHandler = extractShareableOrThrow<ShareableWorklet>(
rt, handlerWorklet, "keyboard event handler must be a worklet");
return subscribeForKeyboardEventsFunction(
[=](int keyboardState, int height) {
jsi::Runtime &rt = *runtimeHelper->uiRuntime();
Expand Down
2 changes: 1 addition & 1 deletion Common/cpp/SharedItems/Shareables.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ std::shared_ptr<T> extractShareableOrThrow(
auto res = std::dynamic_pointer_cast<T>(
extractShareableOrThrow(rt, shareableRef, errorMessage));
if (!res) {
throw new std::runtime_error(
throw std::runtime_error(
errorMessage != nullptr
? errorMessage
: "provided shareable object is of an incompatible type");
Expand Down
12 changes: 1 addition & 11 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
else()
# Consume shared libraries from found .so files
if(${IS_NEW_ARCHITECTURE_ENABLED})
if(${CLIENT_SIDE_BUILD})
set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../../../android/app/build/react-ndk/exported")
set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers")
else()
# Reanimated Playground app
set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../${PLAYGROUND_APP_NAME}/android/app/build/react-ndk/exported")
set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers")
endif()
message(FATAL_ERROR "not supported")
else()
set (RN_SO_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/react/jni")
set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers")
Expand Down Expand Up @@ -339,8 +332,5 @@ endif()

# Resolves "CMake Warning: Manually-specified variables were not used by the project"
# when any of the following variables is not used in some build configuration.
set (ignoreMe "${CLIENT_SIDE_BUILD}")
set (ignoreMe "${JS_RUNTIME_DIR}")
set (ignoreMe "${PLAYGROUND_APP_NAME}")
set (ignoreMe "${REANIMATED_PACKAGE_BUILD}")
set (ignoreMe "${BOOST_VERSION}")
Loading

0 comments on commit c3ead49

Please sign in to comment.