Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/big-hornets-wear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-native-node-api/test-app": patch
---

Renamed ferric-example in test app to match mono-repo packages
5 changes: 5 additions & 0 deletions .changeset/upset-papayas-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-native-node-api": patch
---

Fix host library to not explicitly link with weak-node-api and instead rely on dlopen
2 changes: 1 addition & 1 deletion apps/test-app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function loadTests({
it("exports a callable sum function", () => {
const exampleAddon =
/* eslint-disable-next-line @typescript-eslint/no-require-imports -- TODO: Determine why a dynamic import doesn't work on Android */
require("ferric-example") as typeof import("ferric-example");
require("@react-native-node-api/ferric-example") as typeof import("@react-native-node-api/ferric-example");
const result = exampleAddon.sum(1, 3);
if (result !== 4) {
throw new Error(`Expected 1 + 3 to equal 4, but got ${result}`);
Expand Down
2 changes: 1 addition & 1 deletion apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@react-native-community/cli": "^18.0.0",
"@react-native-community/cli-platform-android": "^18.0.0",
"@react-native-community/cli-platform-ios": "^18.0.0",
"@react-native-node-api/ferric-example": "*",
"@react-native-node-api/node-addon-examples": "*",
"@react-native-node-api/node-tests": "*",
"@react-native/babel-preset": "0.79.0",
Expand All @@ -34,7 +35,6 @@
"@types/mocha": "^10.0.10",
"@types/react": "^19.0.0",
"concurrently": "^9.1.2",
"ferric-example": "^0.1.0",
"mocha": "^11.6.0",
"mocha-remote-cli": "^1.13.2",
"mocha-remote-react-native": "^1.13.2",
Expand Down
22 changes: 9 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions packages/host/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ set(CMAKE_CXX_STANDARD 20)
find_package(ReactAndroid REQUIRED CONFIG)
find_package(hermes-engine REQUIRED CONFIG)

add_library(weak-node-api SHARED IMPORTED)
set_target_properties(weak-node-api PROPERTIES
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../weak-node-api/weak-node-api.android.node/${ANDROID_ABI}/libweak-node-api.so"
)
add_library(weak-node-api INTERFACE)
target_include_directories(weak-node-api INTERFACE
../weak-node-api
../weak-node-api/include
Expand All @@ -31,6 +28,7 @@ target_include_directories(node-api-host PRIVATE
)

target_link_libraries(node-api-host
PRIVATE
# android
log
ReactAndroid::reactnative
Expand Down
2 changes: 2 additions & 0 deletions packages/host/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ android {
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
// Include the weak-node-api to enable a dynamic load
jniLibs.srcDirs += ["../weak-node-api/weak-node-api.android.node"]
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/host/cpp/RuntimeNodeApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ napi_status napi_create_buffer_copy(napi_env env,
return napi_invalid_arg;
}

void* buffer = nullptr;
if (const auto status = ::napi_create_buffer(env, length, &buffer, result);
void *buffer = nullptr;
if (const auto status = callstack::nodeapihost::napi_create_buffer(
env, length, &buffer, result);
status != napi_ok) {
return status;
}
Expand Down
Loading