Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ V3 ✨ #1466

Merged
merged 115 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
28a43f7
chore: Drop support for RN < 71 to simplify buildscript
mrousavy Feb 8, 2023
11d1e71
chore: Upgrade to RN 71 (#1465)
mrousavy Feb 9, 2023
a0590dc
feat: Replace Reanimated with RN Worklets (#1468)
mrousavy Feb 13, 2023
30b5615
feat: Sync Frame Processors (plus `runAsync` and `runAtTargetFps`) (#…
mrousavy Feb 15, 2023
f0ea181
fix: Fix CI for V3 (#1475)
mrousavy Feb 15, 2023
6825c1f
fix: Print correct error in build.gradle
mrousavy Feb 15, 2023
222ded4
fix: Prevent possible crash in log error handler
mrousavy Feb 15, 2023
770357f
chore: Bump to 3.0.0-rc.0
mrousavy Feb 15, 2023
2909085
chore: release 3.0.0-rc.1
mrousavy Feb 15, 2023
0635d4a
fix: Add missing `<regex>` header
mrousavy Feb 15, 2023
1f7a2e0
fix: Fix `global.FrameProcessorPlugins` TS error
mrousavy Feb 15, 2023
12f850c
feat: Draw onto `Frame` as if it was a Skia Canvas (#1479)
mrousavy Feb 21, 2023
1ddea17
chore: release 3.0.0-rc.2
mrousavy Feb 21, 2023
0c3cd66
fix: Improve C++ safety by attaching Cache Invalidator to `jsi::Runti…
mrousavy Feb 21, 2023
cf19ff2
fix: Fix Android namespace
mrousavy Feb 21, 2023
ad5d64b
fix: ignore duplicate `.so` libraries in package
mrousavy Feb 22, 2023
f227a3e
fix: Catch `device == null` error
mrousavy Feb 23, 2023
61f19df
fix: Remove RN Skia dependency on Android for now
mrousavy Feb 23, 2023
622d383
feat: Make Frame Processor Plugins object-oriented on iOS as well (#1…
mrousavy Feb 27, 2023
f791c6b
feat: Better Native Module Error Detection (#1515)
mrousavy Mar 13, 2023
0d83a13
feat: New `CameraDevice` + `CameraFormat` detection using CameraX (#1…
mrousavy Mar 13, 2023
a1af891
fix: Use `global.expo.modules` for JSI expo modules
mrousavy Mar 15, 2023
6deb686
fix: Remove temp-patch for REA plugin
mrousavy Mar 21, 2023
e1973b9
chore: Use Reanimated 3 from npm
mrousavy Mar 21, 2023
af4e366
fix: Fix `runAtTargetFps` for multiple invocations per FP
mrousavy Mar 21, 2023
533c32a
docs: fix wrong comment
mrousavy Mar 29, 2023
38749fb
fix: Fix missing Camera error
mrousavy Apr 21, 2023
bb7ab30
fix: Set min iOS version to 12.4
mrousavy Apr 24, 2023
bf52e8d
chore: Upgrade React Native for Xcode fix
mrousavy Apr 24, 2023
0327983
chore: Upgrade RN Skia
mrousavy May 2, 2023
f03dde7
fix: Fix Skia build (#1582)
mrousavy May 3, 2023
820db3c
android: add build support with RNSkia
hannojg May 4, 2023
4ad4804
chore: Upgrade Skia to new Ganesh Rendering Pipeline and RN to 0.72 (…
mrousavy Jul 3, 2023
82eaf95
chore: Extract to `convertMTLTextureToSkImage`
mrousavy Jul 3, 2023
d964f40
Merge branch 'v3' of https://github.com/mrousavy/react-native-vision-…
mrousavy Jul 3, 2023
0111f2e
fix: Simplify Podfile
mrousavy Jul 3, 2023
7ae15af
feat: Add RN 0.72 support (`namespace` in build.gradle)
mrousavy Jul 3, 2023
cde8b76
chore: Remove react-native-slider
mrousavy Jul 3, 2023
66c6481
fix: Downgrade Gradle to 7.5.1
mrousavy Jul 3, 2023
0139324
fix: Use correct Gradle version
mrousavy Jul 3, 2023
5fb594c
fix: Fix Worklets imports
mrousavy Jul 3, 2023
375e894
feat: Complete iOS Codebase rewrite (#1647)
mrousavy Jul 20, 2023
44ed42d
feat: Expose unified `VisionCameraProxy` object, make `FrameProcessor…
mrousavy Jul 21, 2023
86dd703
feat: Rewrite Android C++ part (`VisionCameraProxy` + `JFrame`) (#1661)
mrousavy Jul 21, 2023
78a64ab
chore: Bump version
mrousavy Jul 31, 2023
deeb8db
fix: Fix namespace
mrousavy Jul 31, 2023
c2096a4
fix: Fix FP Plugin init call
mrousavy Jul 31, 2023
7c721cc
fix: Remove iOS 13 guard
mrousavy Jul 31, 2023
127656b
fix: pragma once
mrousavy Jul 31, 2023
bc9c157
fix: Move implementation for FrameProcessorPlugin to `.m`
mrousavy Jul 31, 2023
0949dab
chore: release 3.0.0-rc.4
mrousavy Jul 31, 2023
1e57e5b
ci: Add CI tests to build Android without Skia or FP
mrousavy Jul 31, 2023
1197df7
fix: Fix `make_shared` not working on `FrameHostObject`
mrousavy Jul 31, 2023
d62a2cd
chore: Upgrade root dependencies (#1663)
mrousavy Jul 31, 2023
61fd4e0
Merge branch 'main' into v3
mrousavy Jul 31, 2023
37a3548
feat: Full Android rewrite (CameraX -> Camera2) (#1674)
mrousavy Aug 21, 2023
54240b0
chore: Update lockfiles
mrousavy Aug 21, 2023
390f48d
fix: Add `GrMTLHandle` import
mrousavy Aug 21, 2023
1f12192
fix: Don't error if session closes
mrousavy Aug 21, 2023
1d12cd9
Optimize imports
mrousavy Aug 21, 2023
07ba0e1
fix: Improve `build.gradle`
mrousavy Aug 21, 2023
e1b0408
fix: Clean up codebase
mrousavy Aug 21, 2023
4d77bc3
Try to select HDR profile
mrousavy Aug 21, 2023
94d9b69
fix: Remove unused constructor
mrousavy Aug 21, 2023
0a51980
fix: Use default HDR if not applicable
mrousavy Aug 21, 2023
a46839a
feat: Add `enableShutterSound` prop to `takePhoto()` 🔊 (#1702)
mrousavy Aug 21, 2023
617c560
fix: Remove unused imports
mrousavy Aug 23, 2023
862e05b
feat: Allow build without Skia or Frame Processors (#1710)
mrousavy Aug 23, 2023
521d7c8
feat: Use `ByteBuffer` for much faster `toArrayBuffer()` :zap:
mrousavy Aug 23, 2023
3a0d7b3
fix: Fix `JByteBuffer`
mrousavy Aug 23, 2023
86468e3
fix: Use direct `ByteBuffer`
mrousavy Aug 23, 2023
efe6556
feat: Implement `enableZoomGesture` on Android
mrousavy Aug 23, 2023
4b009a0
fix: Improve performance of zoom, fps, hdr and format selection
mrousavy Aug 23, 2023
c88605e
fix: Fix circular dependency in `FrameProcessorPlugins.ts`
mrousavy Aug 24, 2023
23af74a
feat: Support `focus()` on Android (#1713)
mrousavy Aug 24, 2023
57592d4
chore: release 3.0.0-rc.6
mrousavy Aug 24, 2023
4833c3e
chore: Bump version
mrousavy Aug 24, 2023
66c012f
fix: Fix `node_modules/` directory detection
mrousavy Aug 24, 2023
d275812
fix: Error on disabled Frame Processors
mrousavy Aug 24, 2023
e036b31
fix: Lock PixelBuffer for read in `toArrayBuffer()`
mrousavy Aug 24, 2023
dfee3b1
fix: Export `pixelFormat` property on iOS
mrousavy Aug 24, 2023
828e1ba
chore: Bump version to RC.7
mrousavy Aug 25, 2023
f87bc74
chore: release 3.0.0-rc.8
mrousavy Aug 25, 2023
dfb86e1
feat: Replace `*NativeMap` and `*NativeArray` with `Map<K,V>` and `Li…
mrousavy Aug 25, 2023
ea3686c
feat: Create C++/OpenGL-based Video Pipeline for more efficient Recor…
mrousavy Aug 29, 2023
3b04757
fix: Make Skia and Worklets optional in `package.json` (#1728)
rocket13011 Aug 29, 2023
6bbb44d
fix: Fix scene mode crash on some emulators
mrousavy Aug 31, 2023
a7c137d
feat: Skia for Android (#1731)
mrousavy Sep 1, 2023
2282908
chore: release 3.0.0-rc.9
mrousavy Sep 1, 2023
0a28454
chore: Remove Skia ❌🎨 (#1740)
mrousavy Sep 1, 2023
03b57a7
feat: Use clang-format to keep the C++ codebase clean (#1741)
mrousavy Sep 1, 2023
01a79d6
chore: Restructure codebase a bit (#1742)
mrousavy Sep 1, 2023
0e9f1ca
perf: Improve `pixelFormat` and add `CameraDevice.sensorOrientation` …
mrousavy Sep 1, 2023
b2ea240
Update clang-format.sh
mrousavy Sep 1, 2023
65aa9b4
docs: Add fancy new Banner :sparkles:
mrousavy Sep 1, 2023
2a5c333
docs: New README (#1744)
mrousavy Sep 1, 2023
036856a
chore: Move everything into `package/` (#1745)
mrousavy Sep 1, 2023
19eabe2
Update .gitignore
mrousavy Sep 1, 2023
7772fc3
Update .gitignore
mrousavy Sep 1, 2023
290a20f
docs: Update CONTRIBUTING
mrousavy Sep 1, 2023
c3f6589
Update issue templates
mrousavy Sep 1, 2023
0ee9cb3
chore: release 3.0.0-rc.10
mrousavy Sep 1, 2023
033ddb8
Move prettier and babel to separate files
mrousavy Sep 1, 2023
325fc4d
chore: Change line width to 140 in C++
mrousavy Sep 1, 2023
cebb7b3
Update .prettierrc.js
mrousavy Sep 1, 2023
fc0e2bf
fix: Fix `savePhotoToFile()` sometimes writing empty files (#1746)
vonovak Sep 1, 2023
a3b48f4
Add `start` script
mrousavy Sep 1, 2023
18d5400
Add Image to example
mrousavy Sep 1, 2023
bfa18ee
Merge branch 'main' into v3
mrousavy Sep 1, 2023
fa111ad
docs: Add docs for Pause/Resume recording
mrousavy Sep 1, 2023
e44d0e7
chore: Fix iOS build CI
mrousavy Sep 1, 2023
7ca226a
Add optional checkboxes
mrousavy Sep 1, 2023
385014b
Create `.bundle/config`
mrousavy Sep 1, 2023
ae439e3
Update .gitignore
mrousavy Sep 1, 2023
74b5898
fix: Use `pod install` instead of `bundle exec pod ...`
mrousavy Sep 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Setup JDK 1.8
- name: Setup JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand All @@ -55,7 +55,5 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run Gradle Build for android/
run: cd android && ./gradlew assembleDebug --build-cache && cd ..
- name: Run Gradle Build for example/android/
run: cd example/android && ./gradlew assembleDebug --build-cache && cd ../..
2 changes: 1 addition & 1 deletion .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: 2.6.8
bundler-cache: true
working-directory: example/ios

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
working-directory: ./android
steps:
- uses: actions/checkout@v2
- name: Setup JDK 1.8
- name: Setup JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
flags: --linelength=230 --exclude "android/src/main/cpp/reanimated-headers"
flags: --linelength=230
targets: --recursive cpp android/src/main/cpp
filter: "-legal/copyright\
,-readability/todo\
Expand Down
5 changes: 3 additions & 2 deletions VisionCamera.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ reactVersion = '0.0.0'
begin
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "react-native", "package.json")))["version"]
rescue
reactVersion = '0.66.0'
reactVersion = '0.71.0'
end
rnVersion = reactVersion.split('.')[1]

Expand All @@ -28,7 +28,7 @@ Pod::Spec.new do |s|

s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
}
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.xcconfig = {
Expand Down Expand Up @@ -64,4 +64,5 @@ Pod::Spec.new do |s|
s.dependency "React-callinvoker"
s.dependency "React"
s.dependency "React-Core"
s.dependency "react-native-worklets"
end
267 changes: 31 additions & 236 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
project(VisionCamera)
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.9.0)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(PACKAGE_NAME "VisionCamera")
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)

if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
include("${NODE_MODULES_DIR}/react-native/ReactAndroid/cmake-utils/folly-flags.cmake")
add_compile_options(${folly_FLAGS})
else()
set (CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID -DFOR_HERMES=${FOR_HERMES}")
endif()
# Folly
include("${NODE_MODULES_DIR}/react-native/ReactAndroid/cmake-utils/folly-flags.cmake")
add_compile_options(${folly_FLAGS})

# Third party libraries (Prefabs)
find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)
find_package(react-native-worklets REQUIRED CONFIG)
find_library(LOG_LIB log)

set (PACKAGE_NAME "VisionCamera")
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
# Consume shared libraries and headers from prefabs
find_package(fbjni REQUIRED CONFIG)
find_package(ReactAndroid REQUIRED CONFIG)
else()
set (RN_SO_DIR ${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/first-party/react/jni)
endif()
# VisionCamera shared

if(${REACT_NATIVE_VERSION} LESS 66)
set (
INCLUDE_JSI_CPP
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
)
set (
INCLUDE_JSIDYNAMIC_CPP
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/JSIDynamic.cpp"
)
endif()

# Add react-native-vision-camera sources
add_library(
${PACKAGE_NAME}
SHARED
Expand All @@ -48,213 +32,24 @@ add_library(
src/main/cpp/java-bindings/JHashMap.cpp
)

# includes
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/renderer/graphics/platform/cxx"
"${NODE_MODULES_DIR}/react-native/ReactCommon/runtimeexecutor"
"${NODE_MODULES_DIR}/react-native/ReactCommon/yoga"
# --- Reanimated ---
# New
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/AnimatedSensor"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/Tools"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/SpecTools"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/SharedItems"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/Registries"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/LayoutAnimations"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/hidden_headers"
"src/main/cpp"
)
else()
file (GLOB LIBFBJNI_INCLUDE_DIR "${BUILD_DIR}/fbjni-*-headers.jar/")

target_include_directories(
${PACKAGE_NAME}
PRIVATE
# --- fbjni ---
"${LIBFBJNI_INCLUDE_DIR}"
# --- Third Party (required by RN) ---
"${BUILD_DIR}/third-party-ndk/boost"
"${BUILD_DIR}/third-party-ndk/double-conversion"
"${BUILD_DIR}/third-party-ndk/folly"
"${BUILD_DIR}/third-party-ndk/glog"
# --- React Native ---
"${NODE_MODULES_DIR}/react-native/React"
"${NODE_MODULES_DIR}/react-native/React/Base"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/hermes-engine/android/include/"
${INCLUDE_JSI_CPP} # only on older RN versions
${INCLUDE_JSIDYNAMIC_CPP} # only on older RN versions
# --- Reanimated ---
# Old
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/headers/AnimatedSensor"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/headers/Tools"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/headers/SpecTools"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/headers/SharedItems"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/headers/Registries"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/headers/LayoutAnimations"
# New
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/AnimatedSensor"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/Tools"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/SpecTools"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/SharedItems"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/Registries"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/LayoutAnimations"
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/hidden_headers"
"src/main/cpp"
)
endif()



# find libraries

file (GLOB LIBRN_DIR "${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}")

if(${FOR_HERMES})
string(APPEND CMAKE_CXX_FLAGS " -DFOR_HERMES=1")

if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
find_package(hermes-engine REQUIRED CONFIG)
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 69)
# Bundled Hermes from module `com.facebook.react:hermes-engine` or project `:ReactAndroid:hermes-engine`
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"${JS_RUNTIME_DIR}/API"
"${JS_RUNTIME_DIR}/public"
)
else()
# From `hermes-engine` npm package
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"${JS_RUNTIME_DIR}/android/include"
)
endif()

if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
target_link_libraries(
${PACKAGE_NAME}
"hermes-engine::libhermes"
)
else()
target_link_libraries(
${PACKAGE_NAME}
"${BUILD_DIR}/third-party-ndk/hermes/jni/${ANDROID_ABI}/libhermes.so"
)
endif()
file (GLOB LIBREANIMATED_DIR "${BUILD_DIR}/react-native-reanimated-*-hermes.aar/jni/${ANDROID_ABI}")
else()
file (GLOB LIBJSC_DIR "${BUILD_DIR}/android-jsc*.aar/jni/${ANDROID_ABI}")

if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
set(JS_ENGINE_LIB ReactAndroid::jscexecutor)
else()
# Use JSC
find_library(
JS_ENGINE_LIB
jscexecutor
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
endif()
target_link_libraries(
${PACKAGE_NAME}
${JS_ENGINE_LIB}
)

# Use Reanimated JSC
file (GLOB LIBREANIMATED_DIR "${BUILD_DIR}/react-native-reanimated-*-jsc.aar/jni/${ANDROID_ABI}")
endif()

if(${REACT_NATIVE_VERSION} LESS 71)
find_library(
FBJNI_LIB
fbjni
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
endif()

if(${REACT_NATIVE_VERSION} LESS 69)
find_library(
FOLLY_LIB
folly_json
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
elseif(${REACT_NATIVE_VERSION} LESS 71)
find_library(
FOLLY_LIB
folly_runtime
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
endif()

if(${REACT_NATIVE_VERSION} LESS 71)
find_library(
REACT_NATIVE_JNI_LIB
reactnativejni
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
endif()

if(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
target_link_libraries(
${PACKAGE_NAME}
ReactAndroid::folly_runtime
ReactAndroid::glog
ReactAndroid::jsi
ReactAndroid::reactnativejni
fbjni::fbjni
)
elseif(${REACT_NATIVE_VERSION} LESS 66)
# JSI lib didn't exist on RN 0.65 and before. Simply omit it.
set (JSI_LIB "")
else()
# RN 0.66 distributes libjsi.so, can be used instead of compiling jsi.cpp manually.
find_library(
JSI_LIB
jsi
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
endif()

find_library(
REANIMATED_LIB
reanimated
PATHS ${LIBREANIMATED_DIR}
NO_CMAKE_FIND_ROOT_PATH
)

find_library(
LOG_LIB
log
# Header Search Paths (includes)
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"src/main/cpp"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule" # <-- CallInvokerHolder JNI wrapper
)

# linking
message(WARNING "VisionCamera linking: FOR_HERMES=${FOR_HERMES}")
# Link everything together
target_link_libraries(
${PACKAGE_NAME}
${LOG_LIB}
${JSI_LIB}
${REANIMATED_LIB}
${REACT_NATIVE_JNI_LIB}
${FBJNI_LIB}
${FOLLY_LIB}
android
${LOG_LIB} # <-- Logcat logger
android # <-- Android JNI core
ReactAndroid::jsi # <-- RN: JSI
ReactAndroid::reactnativejni # <-- RN: React Native JNI bindings
ReactAndroid::folly_runtime # <-- RN: For casting JSI <> Java objects
fbjni::fbjni # <-- fbjni
react-native-worklets::rnworklets # <-- RN Worklets
)
Loading