diff --git a/apps/paper-example/ios/Podfile.lock b/apps/paper-example/ios/Podfile.lock index 679118c2adb..4c2e3c9f777 100644 --- a/apps/paper-example/ios/Podfile.lock +++ b/apps/paper-example/ios/Podfile.lock @@ -1614,11 +1614,11 @@ SPEC CHECKSUMS: RNCPicker: 3e2c37a8328f368ce14da050cdc8231deb5fc9f9 RNFlashList: e9b57a5553639f9b528cc50ab53f25831722ed62 RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7 - RNReanimated: 771c92dd6787dd6f18889dea61ff423694bff638 + RNReanimated: 82f65dd7f62b2ff629221e1887cd85b082dbe5a0 RNScreens: 52f2565581af64b1b410d49784cf8342ed94ca28 RNSVG: 43b64ed39c14ce830d840903774154ca0c1f27ec SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d - Yoga: 56f906bf6c11c931588191dde1229fd3e4e3d557 + Yoga: ff1d575b119f510a5de23c22a794872562078ccf PODFILE CHECKSUM: 746b518f69244f6a3f6b04dabf476339073cb5fe diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp index 2db7f14f19d..92191e1a897 100644 --- a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp +++ b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp @@ -24,7 +24,6 @@ #include "CollectionUtils.h" #include "EventHandlerRegistry.h" #include "FeaturesConfig.h" -#include "ReanimatedHiddenHeaders.h" #include "Shareables.h" #include "UIRuntimeDecorator.h" #include "WorkletEventHandler.h" diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/Tools/PlatformLogger.h b/packages/react-native-reanimated/Common/cpp/reanimated/Tools/PlatformLogger.h new file mode 100644 index 00000000000..37db18e3326 --- /dev/null +++ b/packages/react-native-reanimated/Common/cpp/reanimated/Tools/PlatformLogger.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace reanimated { + +class PlatformLogger { + public: + static void log(const char *str); + static void log(const std::string &str); + static void log(const double d); + static void log(const int i); + static void log(const bool b); +}; + +} // namespace reanimated diff --git a/packages/react-native-reanimated/Common/cpp/worklets/Tools/ReanimatedHiddenHeaders.h b/packages/react-native-reanimated/Common/cpp/worklets/Tools/ReanimatedHiddenHeaders.h deleted file mode 100644 index 4a68c5f915f..00000000000 --- a/packages/react-native-reanimated/Common/cpp/worklets/Tools/ReanimatedHiddenHeaders.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#ifdef ANDROID -#include "Logger.h" -#include "LoggerInterface.h" -#include "SpeedChecker.h" -#else -#include "Common/cpp/Worklets/hidden_headers/Logger.h" -#include "Common/cpp/Worklets/hidden_headers/LoggerInterface.h" -#include "Common/cpp/Worklets/hidden_headers/SpeedChecker.h" -#endif diff --git a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp index 2f0e06cfa5b..249d4bdd388 100644 --- a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +++ b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp @@ -1,17 +1,12 @@ #include "WorkletRuntimeDecorator.h" #include "JSISerializer.h" +#include "PlatformLogger.h" #include "ReanimatedJSIUtils.h" #include "Shareables.h" #include "WorkletRuntime.h" #include -#ifdef ANDROID -#include "Logger.h" -#else -#include "Common/cpp/Worklets/hidden_headers/Logger.h" -#endif - namespace reanimated { static inline double performanceNow() { @@ -73,7 +68,7 @@ void WorkletRuntimeDecorator::decorate( jsi_utils::installJsiFunction( rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) { - Logger::log(stringifyJSIValue(rt, value)); + PlatformLogger::log(stringifyJSIValue(rt, value)); }); jsi_utils::installJsiFunction( diff --git a/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/Logger.h b/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/Logger.h deleted file mode 100644 index dfbdf0a2ffa..00000000000 --- a/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/Logger.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include - -#include "./LoggerInterface.h" - -namespace reanimated { - -class Logger { - public: - template - static void log(T value) { - if (instance == nullptr) { - throw std::runtime_error("[Reanimated] No logger specified."); - } - instance->log(value); - } - - private: - static std::unique_ptr instance; -}; - -} // namespace reanimated diff --git a/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/LoggerInterface.h b/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/LoggerInterface.h deleted file mode 100644 index 9e249fdb661..00000000000 --- a/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/LoggerInterface.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -namespace reanimated { - -class LoggerInterface { - public: - virtual void log(const char *str) = 0; - virtual void log(const std::string &str) = 0; - virtual void log(double d) = 0; - virtual void log(int i) = 0; - virtual void log(bool b) = 0; - virtual ~LoggerInterface() = default; -}; - -} // namespace reanimated diff --git a/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/SpeedChecker.h b/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/SpeedChecker.h deleted file mode 100644 index 9b0683080d0..00000000000 --- a/packages/react-native-reanimated/Common/cpp/worklets/hidden_headers/SpeedChecker.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#define CHECK_SPEED 1 - -#include -#include -#include -#include -#include "./Logger.h" - -namespace reanimated { - -class SpeedChecker { - public: - static void checkSpeed(std::string tag, std::function fun) { -#if CHECK_SPEED - auto start = std::chrono::system_clock::now(); -#endif - fun(); -#if CHECK_SPEED - auto end = std::chrono::system_clock::now(); - std::chrono::duration elapsed_seconds = end - start; - tag += " " + std::to_string(elapsed_seconds.count()) + "s"; - Logger::log(tag.c_str()); -#endif - } -}; - -} // namespace reanimated diff --git a/packages/react-native-reanimated/RNReanimated.podspec b/packages/react-native-reanimated/RNReanimated.podspec index af21d37f715..e6711f43329 100644 --- a/packages/react-native-reanimated/RNReanimated.podspec +++ b/packages/react-native-reanimated/RNReanimated.podspec @@ -88,9 +88,6 @@ Pod::Spec.new do |s| ss.source_files = [ "Common/cpp/worklets/**/*.{cpp,h}", ] - ss.preserve_paths = [ - "Common/cpp/worklets/hidden_headers/**" - ] end gcc_debug_definitions = "$(inherited)" diff --git a/packages/react-native-reanimated/android/src/main/cpp/AndroidLogger.cpp b/packages/react-native-reanimated/android/src/main/cpp/AndroidLogger.cpp deleted file mode 100644 index 9ea3f238540..00000000000 --- a/packages/react-native-reanimated/android/src/main/cpp/AndroidLogger.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -#include "AndroidLogger.h" -#include "Logger.h" - -#define APPNAME "NATIVE_REANIMATED" - -namespace reanimated { - -std::unique_ptr Logger::instance = - std::make_unique(); - -void AndroidLogger::log(const char *str) { - __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "%s", str); -} - -void AndroidLogger::log(const std::string &str) { - log(str.c_str()); -} - -void AndroidLogger::log(double d) { - __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "%f", d); -} - -void AndroidLogger::log(int i) { - __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "%d", i); -} - -void AndroidLogger::log(bool b) { - log(b ? "true" : "false"); -} - -} // namespace reanimated diff --git a/packages/react-native-reanimated/android/src/main/cpp/AndroidLogger.h b/packages/react-native-reanimated/android/src/main/cpp/AndroidLogger.h deleted file mode 100644 index 5e15ca75bdf..00000000000 --- a/packages/react-native-reanimated/android/src/main/cpp/AndroidLogger.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include - -#include "LoggerInterface.h" - -namespace reanimated { - -class AndroidLogger : public LoggerInterface { - public: - void log(const char *str) override; - void log(const std::string &str) override; - void log(double d) override; - void log(int i) override; - void log(bool b) override; -}; - -} // namespace reanimated diff --git a/packages/react-native-reanimated/android/src/main/cpp/LayoutAnimations.cpp b/packages/react-native-reanimated/android/src/main/cpp/LayoutAnimations.cpp index 920fb2bd8b3..0fb85d42c78 100644 --- a/packages/react-native-reanimated/android/src/main/cpp/LayoutAnimations.cpp +++ b/packages/react-native-reanimated/android/src/main/cpp/LayoutAnimations.cpp @@ -1,7 +1,6 @@ #include "LayoutAnimations.h" #include #include "FeaturesConfig.h" -#include "Logger.h" namespace reanimated { diff --git a/packages/react-native-reanimated/android/src/main/cpp/OnLoad.cpp b/packages/react-native-reanimated/android/src/main/cpp/OnLoad.cpp index 0e2a2425bad..84e129b1e30 100644 --- a/packages/react-native-reanimated/android/src/main/cpp/OnLoad.cpp +++ b/packages/react-native-reanimated/android/src/main/cpp/OnLoad.cpp @@ -2,7 +2,6 @@ #include "AndroidUIScheduler.h" #include "LayoutAnimations.h" -#include "Logger.h" #include "NativeProxy.h" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { diff --git a/packages/react-native-reanimated/android/src/main/cpp/PlatformLogger.cpp b/packages/react-native-reanimated/android/src/main/cpp/PlatformLogger.cpp new file mode 100644 index 00000000000..64255c89bc8 --- /dev/null +++ b/packages/react-native-reanimated/android/src/main/cpp/PlatformLogger.cpp @@ -0,0 +1,29 @@ +#include + +#include "PlatformLogger.h" + +constexpr const auto tag = "Reanimated"; + +namespace reanimated { + +void PlatformLogger::log(const char *str) { + __android_log_print(ANDROID_LOG_VERBOSE, tag, "%s", str); +} + +void PlatformLogger::log(const std::string &str) { + log(str.c_str()); +} + +void PlatformLogger::log(const double d) { + __android_log_print(ANDROID_LOG_VERBOSE, tag, "%f", d); +} + +void PlatformLogger::log(const int i) { + __android_log_print(ANDROID_LOG_VERBOSE, tag, "%d", i); +} + +void PlatformLogger::log(const bool b) { + log(b ? "true" : "false"); +} + +} // namespace reanimated diff --git a/packages/react-native-reanimated/android/src/main/worklets/CMakeLists.txt b/packages/react-native-reanimated/android/src/main/worklets/CMakeLists.txt index 8a0fab2f648..a962a50a021 100644 --- a/packages/react-native-reanimated/android/src/main/worklets/CMakeLists.txt +++ b/packages/react-native-reanimated/android/src/main/worklets/CMakeLists.txt @@ -14,14 +14,13 @@ add_library( worklets SHARED ${WORKLETS_COMMON_SOURCES} - "${ANDROID_SRC_DIR}/main/cpp/AndroidLogger.cpp" + "${ANDROID_SRC_DIR}/main/cpp/PlatformLogger.cpp" ) # includes target_include_directories( worklets PUBLIC - "${WORKLETS_COMMON_DIR}/hidden_headers" "${WORKLETS_COMMON_DIR}/Registries" "${WORKLETS_COMMON_DIR}/SharedItems" "${WORKLETS_COMMON_DIR}/Tools" diff --git a/packages/react-native-reanimated/apple/native/PlatformLogger.mm b/packages/react-native-reanimated/apple/native/PlatformLogger.mm new file mode 100644 index 00000000000..750bdcc2066 --- /dev/null +++ b/packages/react-native-reanimated/apple/native/PlatformLogger.mm @@ -0,0 +1,31 @@ +#import +#import + +namespace reanimated { + +void PlatformLogger::log(const char *str) +{ + NSLog(@"%@", [NSString stringWithCString:str encoding:[NSString defaultCStringEncoding]]); +} + +void PlatformLogger::log(const std::string &str) +{ + log(str.c_str()); +} + +void PlatformLogger::log(const double d) +{ + NSLog(@"%lf", d); +} + +void PlatformLogger::log(const int i) +{ + NSLog(@"%i", i); +} + +void PlatformLogger::log(const bool b) +{ + log(b ? "true" : "false"); +} + +} // namespace reanimated diff --git a/packages/react-native-reanimated/apple/native/REAIOSLogger.h b/packages/react-native-reanimated/apple/native/REAIOSLogger.h deleted file mode 100644 index 816107e16b3..00000000000 --- a/packages/react-native-reanimated/apple/native/REAIOSLogger.h +++ /dev/null @@ -1,15 +0,0 @@ -#import -#include - -namespace reanimated { - -class REAIOSLogger : public LoggerInterface { - public: - void log(const char *str) override; - void log(const std::string &str) override; - void log(double d) override; - void log(int i) override; - void log(bool b) override; -}; - -} // namespace reanimated diff --git a/packages/react-native-reanimated/apple/native/REAIOSLogger.mm b/packages/react-native-reanimated/apple/native/REAIOSLogger.mm deleted file mode 100644 index 805af427375..00000000000 --- a/packages/react-native-reanimated/apple/native/REAIOSLogger.mm +++ /dev/null @@ -1,33 +0,0 @@ -#import -#import - -namespace reanimated { - -std::unique_ptr Logger::instance = std::make_unique(); - -void REAIOSLogger::log(const char *str) -{ - NSLog(@"%@", [NSString stringWithCString:str encoding:[NSString defaultCStringEncoding]]); -} - -void REAIOSLogger::log(const std::string &str) -{ - log(str.c_str()); -} - -void REAIOSLogger::log(double d) -{ - NSLog(@"%lf", d); -} - -void REAIOSLogger::log(int i) -{ - NSLog(@"%i", i); -} - -void REAIOSLogger::log(bool b) -{ - log(b ? "true" : "false"); -} - -} // namespace reanimated