react-native-nobodywho 0.0.1 → 0.1.1
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/Nobodywho.podspec +82 -0
- package/android/CMakeLists.txt +85 -0
- package/android/build.gradle +234 -0
- package/android/cpp-adapter.cpp +43 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/AndroidManifestNew.xml +3 -0
- package/android/src/main/java/com/nobodywho/NobodywhoModule.kt +43 -0
- package/android/src/main/java/com/nobodywho/NobodywhoPackage.kt +34 -0
- package/cpp/nobodywho-react-native.cpp +16 -0
- package/cpp/nobodywho-react-native.h +15 -0
- package/cpp/react-native-nobodywho.cpp +16 -0
- package/cpp/react-native-nobodywho.h +15 -0
- package/generated/cpp/nobodywho.cpp +6392 -0
- package/generated/cpp/nobodywho.hpp +614 -0
- package/generated/ts/nobodywho-ffi.ts +315 -0
- package/generated/ts/nobodywho.ts +3048 -0
- package/ios/Nobodywho.h +16 -0
- package/ios/Nobodywho.mm +66 -0
- package/package.json +12 -3
- package/src/NativeNobodywho.ts +10 -0
- package/src/chat.ts +155 -0
- package/src/index.tsx +41 -0
- package/src/prompt.ts +72 -0
- package/src/sampler_presets.ts +64 -0
- package/src/streaming.ts +46 -0
- package/src/tool.ts +80 -0
- package/ubrn.config.yaml +12 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# NobodyWho React Native - iOS podspec
|
|
2
|
+
# Downloads the prebuilt xcframework from GitHub Releases at pod install time.
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
6
|
+
version = package["version"]
|
|
7
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
8
|
+
|
|
9
|
+
framework_name = "NobodywhoFramework.xcframework"
|
|
10
|
+
framework_dir = File.join(__dir__, framework_name)
|
|
11
|
+
|
|
12
|
+
# Download the xcframework from GitHub Releases if not already present
|
|
13
|
+
unless File.exist?(framework_dir)
|
|
14
|
+
zip_name = "#{framework_name}.zip"
|
|
15
|
+
zip_path = File.join(__dir__, zip_name)
|
|
16
|
+
url = "https://github.com/nobodywho-ooo/nobodywho/releases/download/nobodywho-react-native-#{version}/#{zip_name}"
|
|
17
|
+
|
|
18
|
+
puts "[NobodyWho] Downloading xcframework from #{url}"
|
|
19
|
+
|
|
20
|
+
# Download using curl (available on all macOS systems)
|
|
21
|
+
system("curl", "-L", "-f", "-o", zip_path, url) or
|
|
22
|
+
raise "Failed to download NobodyWho xcframework.\n" \
|
|
23
|
+
"URL: #{url}\n" \
|
|
24
|
+
"Check that the release exists: https://github.com/nobodywho-ooo/nobodywho/releases/tag/nobodywho-react-native-#{version}\n" \
|
|
25
|
+
"For local development, manually place the xcframework at: #{framework_dir}"
|
|
26
|
+
|
|
27
|
+
puts "[NobodyWho] Extracting xcframework..."
|
|
28
|
+
system("unzip", "-o", "-q", zip_path, "-d", __dir__) or
|
|
29
|
+
raise "Failed to extract #{zip_name}"
|
|
30
|
+
|
|
31
|
+
File.delete(zip_path) if File.exist?(zip_path)
|
|
32
|
+
|
|
33
|
+
unless File.exist?(framework_dir)
|
|
34
|
+
raise "xcframework not found after extraction: #{framework_dir}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
puts "[NobodyWho] xcframework ready at #{framework_dir}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Pod::Spec.new do |s|
|
|
41
|
+
s.name = "Nobodywho"
|
|
42
|
+
s.version = package["version"]
|
|
43
|
+
s.summary = package["description"]
|
|
44
|
+
s.homepage = package["homepage"]
|
|
45
|
+
s.license = package["license"]
|
|
46
|
+
s.authors = package["author"]
|
|
47
|
+
|
|
48
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
49
|
+
s.source = { :git => "https://github.com/nobodywho-ooo/nobodywho", :tag => "#{s.version}" }
|
|
50
|
+
|
|
51
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}", "ios/generated/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}", "generated/cpp/**/*.{hpp,cpp,c,h}"
|
|
52
|
+
s.vendored_frameworks = framework_name
|
|
53
|
+
s.libraries = 'c++'
|
|
54
|
+
s.frameworks = 'Accelerate'
|
|
55
|
+
s.dependency "uniffi-bindgen-react-native", "0.30.0-1"
|
|
56
|
+
|
|
57
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
58
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
59
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
60
|
+
install_modules_dependencies(s)
|
|
61
|
+
else
|
|
62
|
+
s.dependency "React-Core"
|
|
63
|
+
|
|
64
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
65
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
66
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
67
|
+
s.dependency "React-Codegen"
|
|
68
|
+
s.dependency "RCT-Folly"
|
|
69
|
+
s.dependency "RCTRequired"
|
|
70
|
+
s.dependency "RCTTypeSafety"
|
|
71
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Only arm64 simulator is supported (no x86_64 simulator build)
|
|
76
|
+
s.pod_target_xcconfig = {
|
|
77
|
+
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386 x86_64'
|
|
78
|
+
}
|
|
79
|
+
s.user_target_xcconfig = {
|
|
80
|
+
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386 x86_64'
|
|
81
|
+
}
|
|
82
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Generated by uniffi-bindgen-react-native
|
|
2
|
+
cmake_minimum_required(VERSION 3.9.0)
|
|
3
|
+
project(Nobodywho)
|
|
4
|
+
|
|
5
|
+
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set (CMAKE_CXX_STANDARD 17)
|
|
7
|
+
|
|
8
|
+
# Resolve the path to the uniffi-bindgen-react-native package
|
|
9
|
+
execute_process(
|
|
10
|
+
COMMAND node -p "require.resolve('uniffi-bindgen-react-native/package.json')"
|
|
11
|
+
OUTPUT_VARIABLE UNIFFI_BINDGEN_PATH
|
|
12
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
13
|
+
)
|
|
14
|
+
# Get the directory; get_filename_component and cmake_path will normalize
|
|
15
|
+
# paths with Windows path separators.
|
|
16
|
+
get_filename_component(UNIFFI_BINDGEN_PATH "${UNIFFI_BINDGEN_PATH}" DIRECTORY)
|
|
17
|
+
|
|
18
|
+
# Specifies a path to native header files.
|
|
19
|
+
include_directories(
|
|
20
|
+
../cpp
|
|
21
|
+
../generated/cpp
|
|
22
|
+
|
|
23
|
+
${UNIFFI_BINDGEN_PATH}/cpp/includes
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
add_library(react-native-nobodywho SHARED
|
|
27
|
+
../cpp/react-native-nobodywho.cpp
|
|
28
|
+
../generated/cpp/nobodywho.cpp
|
|
29
|
+
cpp-adapter.cpp
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Set C++ compiler flags
|
|
33
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
|
34
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
|
35
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
|
|
36
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
|
37
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
|
38
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
39
|
+
|
|
40
|
+
# Set linker flags for 16KB page size alignment (required for Android 15+)
|
|
41
|
+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
|
|
42
|
+
|
|
43
|
+
# NOBODYWHO_NATIVE_LIBS_DIR is passed from build.gradle via cmake arguments.
|
|
44
|
+
# Fall back to src/main/jniLibs for local development where libs are placed manually.
|
|
45
|
+
if(NOT NOBODYWHO_NATIVE_LIBS_DIR)
|
|
46
|
+
set(NOBODYWHO_NATIVE_LIBS_DIR "${CMAKE_SOURCE_DIR}/src/main/jniLibs")
|
|
47
|
+
endif()
|
|
48
|
+
|
|
49
|
+
cmake_path(
|
|
50
|
+
SET MY_RUST_LIB
|
|
51
|
+
${NOBODYWHO_NATIVE_LIBS_DIR}/${ANDROID_ABI}/libnobodywho_uniffi.a
|
|
52
|
+
NORMALIZE
|
|
53
|
+
)
|
|
54
|
+
add_library(my_rust_lib STATIC IMPORTED)
|
|
55
|
+
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
|
|
56
|
+
|
|
57
|
+
# Add ReactAndroid libraries, being careful to account for different versions.
|
|
58
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
59
|
+
find_library(LOGCAT log)
|
|
60
|
+
|
|
61
|
+
# REACTNATIVE_MERGED_SO seems to be only be set in a build.gradle.kt file,
|
|
62
|
+
# which we don't use. Thus falling back to version number sniffing.
|
|
63
|
+
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
64
|
+
set(REACTNATIVE_MERGED_SO true)
|
|
65
|
+
endif()
|
|
66
|
+
|
|
67
|
+
# https://github.com/react-native-community/discussions-and-proposals/discussions/816
|
|
68
|
+
# This if-then-else can be removed once this library does not support version below 0.76
|
|
69
|
+
if (REACTNATIVE_MERGED_SO)
|
|
70
|
+
target_link_libraries(react-native-nobodywho ReactAndroid::reactnative)
|
|
71
|
+
else()
|
|
72
|
+
target_link_libraries(react-native-nobodywho
|
|
73
|
+
ReactAndroid::turbomodulejsijni
|
|
74
|
+
ReactAndroid::react_nativemodule_core
|
|
75
|
+
)
|
|
76
|
+
endif()
|
|
77
|
+
|
|
78
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
79
|
+
target_link_libraries(
|
|
80
|
+
react-native-nobodywho
|
|
81
|
+
fbjni::fbjni
|
|
82
|
+
ReactAndroid::jsi
|
|
83
|
+
${LOGCAT}
|
|
84
|
+
my_rust_lib
|
|
85
|
+
)
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
|
|
3
|
+
buildscript {
|
|
4
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
5
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["DummyLibForAndroid_kotlinVersion"]
|
|
6
|
+
|
|
7
|
+
repositories {
|
|
8
|
+
google()
|
|
9
|
+
mavenCentral()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
dependencies {
|
|
13
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
14
|
+
// noinspection DifferentKotlinGradleVersion
|
|
15
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def reactNativeArchitectures() {
|
|
20
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
21
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def isNewArchitectureEnabled() {
|
|
25
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
apply plugin: "com.android.library"
|
|
29
|
+
apply plugin: "kotlin-android"
|
|
30
|
+
|
|
31
|
+
if (isNewArchitectureEnabled()) {
|
|
32
|
+
apply plugin: "com.facebook.react"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def getExtOrDefault(name) {
|
|
36
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Nobodywho_" + name]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def getExtOrIntegerDefault(name) {
|
|
40
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Nobodywho_" + name]).toInteger()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def supportsNamespace() {
|
|
44
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
45
|
+
def major = parsed[0].toInteger()
|
|
46
|
+
def minor = parsed[1].toInteger()
|
|
47
|
+
|
|
48
|
+
// Namespace support was added in 7.3.0
|
|
49
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ABI to Rust target triple mapping
|
|
53
|
+
def abiToTriple = [
|
|
54
|
+
"arm64-v8a": "aarch64-linux-android",
|
|
55
|
+
"x86_64": "x86_64-linux-android",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
// Read version from package.json
|
|
59
|
+
def packageJsonFile = file("${projectDir}/../package.json")
|
|
60
|
+
def packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text)
|
|
61
|
+
def nobodywhoVersion = packageJson.version
|
|
62
|
+
|
|
63
|
+
// Directory for downloaded native libraries (outside source tree to avoid Gradle conflicts)
|
|
64
|
+
def nativeLibsDir = new File(buildDir, "nobodywho-native")
|
|
65
|
+
|
|
66
|
+
// Download native static libraries from GitHub Releases if not already present.
|
|
67
|
+
// These are .a files used by CMake at link time — not .so files for jniLibs.
|
|
68
|
+
task resolveNativeLibraries {
|
|
69
|
+
description = "Downloads NobodyWho native static libraries from GitHub Releases"
|
|
70
|
+
|
|
71
|
+
outputs.dir(nativeLibsDir)
|
|
72
|
+
|
|
73
|
+
doLast {
|
|
74
|
+
abiToTriple.each { abi, triple ->
|
|
75
|
+
def abiDir = new File(nativeLibsDir, abi)
|
|
76
|
+
def libFile = new File(abiDir, "libnobodywho_uniffi.a")
|
|
77
|
+
|
|
78
|
+
if (libFile.exists()) {
|
|
79
|
+
logger.lifecycle("[NobodyWho] ${abi}: Using existing library at ${libFile.path}")
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
abiDir.mkdirs()
|
|
84
|
+
|
|
85
|
+
def fileName = "libnobodywho-uniffi-${triple}-release.a"
|
|
86
|
+
def downloadUrl = "https://github.com/nobodywho-ooo/nobodywho/releases/download/nobodywho-react-native-${nobodywhoVersion}/${fileName}"
|
|
87
|
+
|
|
88
|
+
logger.lifecycle("[NobodyWho] ${abi}: Downloading from ${downloadUrl}")
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
// Follow redirects manually to handle cross-protocol redirects
|
|
92
|
+
// (GitHub redirects from github.com to objects.githubusercontent.com)
|
|
93
|
+
def url = downloadUrl
|
|
94
|
+
def maxRedirects = 5
|
|
95
|
+
for (int i = 0; i < maxRedirects; i++) {
|
|
96
|
+
def connection = (java.net.HttpURLConnection) new URL(url).openConnection()
|
|
97
|
+
connection.setInstanceFollowRedirects(false)
|
|
98
|
+
connection.connect()
|
|
99
|
+
|
|
100
|
+
def code = connection.responseCode
|
|
101
|
+
if (code == 200) {
|
|
102
|
+
libFile.withOutputStream { out ->
|
|
103
|
+
out << connection.inputStream
|
|
104
|
+
}
|
|
105
|
+
logger.lifecycle("[NobodyWho] ${abi}: Downloaded to ${libFile.path} (${libFile.length()} bytes)")
|
|
106
|
+
return
|
|
107
|
+
} else if (code == 301 || code == 302 || code == 307 || code == 308) {
|
|
108
|
+
url = connection.getHeaderField("Location")
|
|
109
|
+
connection.disconnect()
|
|
110
|
+
} else {
|
|
111
|
+
throw new GradleException(
|
|
112
|
+
"Failed to download NobodyWho library for ${abi}: HTTP ${code}\n" +
|
|
113
|
+
"URL: ${downloadUrl}\n" +
|
|
114
|
+
"Check that the release exists: https://github.com/nobodywho-ooo/nobodywho/releases/tag/nobodywho-react-native-${nobodywhoVersion}"
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
throw new GradleException("Too many redirects downloading NobodyWho library for ${abi}")
|
|
119
|
+
} catch (GradleException e) {
|
|
120
|
+
throw e
|
|
121
|
+
} catch (Exception e) {
|
|
122
|
+
throw new GradleException(
|
|
123
|
+
"Failed to download NobodyWho library for ${abi}: ${e.message}\n" +
|
|
124
|
+
"For local development, build the uniffi crate and place the .a file at: ${libFile.path}",
|
|
125
|
+
e
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
android {
|
|
133
|
+
if (supportsNamespace()) {
|
|
134
|
+
namespace "com.nobodywho"
|
|
135
|
+
|
|
136
|
+
sourceSets {
|
|
137
|
+
main {
|
|
138
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
ndkVersion getExtOrDefault("ndkVersion")
|
|
144
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
145
|
+
|
|
146
|
+
defaultConfig {
|
|
147
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
148
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
149
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
150
|
+
consumerProguardFiles 'proguard-rules.pro'
|
|
151
|
+
|
|
152
|
+
buildFeatures {
|
|
153
|
+
prefab true
|
|
154
|
+
}
|
|
155
|
+
externalNativeBuild {
|
|
156
|
+
cmake {
|
|
157
|
+
arguments '-DANDROID_STL=c++_shared',
|
|
158
|
+
"-DNOBODYWHO_NATIVE_LIBS_DIR=${nativeLibsDir.absolutePath}"
|
|
159
|
+
abiFilters (*reactNativeArchitectures())
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
ndk {
|
|
163
|
+
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
externalNativeBuild {
|
|
168
|
+
cmake {
|
|
169
|
+
path "CMakeLists.txt"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
buildFeatures {
|
|
174
|
+
buildConfig true
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
buildTypes {
|
|
178
|
+
release {
|
|
179
|
+
minifyEnabled false
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
lintOptions {
|
|
184
|
+
disable "GradleCompatible"
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
compileOptions {
|
|
188
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
189
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
sourceSets {
|
|
193
|
+
main {
|
|
194
|
+
if (isNewArchitectureEnabled()) {
|
|
195
|
+
java.srcDirs += [
|
|
196
|
+
"generated/java",
|
|
197
|
+
"generated/jni"
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Ensure native libraries are downloaded before CMake runs
|
|
205
|
+
afterEvaluate {
|
|
206
|
+
tasks.matching {
|
|
207
|
+
it.name.contains("configureCMake") || it.name.contains("externalNativeBuild")
|
|
208
|
+
}.configureEach {
|
|
209
|
+
dependsOn(resolveNativeLibraries)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
repositories {
|
|
214
|
+
mavenCentral()
|
|
215
|
+
google()
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
219
|
+
|
|
220
|
+
dependencies {
|
|
221
|
+
// For < 0.71, this will be from the local maven repo
|
|
222
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
223
|
+
//noinspection GradleDynamicVersion
|
|
224
|
+
implementation "com.facebook.react:react-native:+"
|
|
225
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (isNewArchitectureEnabled()) {
|
|
229
|
+
react {
|
|
230
|
+
jsRootDir = file("../src/")
|
|
231
|
+
libraryName = "Nobodywho"
|
|
232
|
+
codegenJavaPackageName = "com.nobodywho"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#include <jni.h>
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <ReactCommon/CallInvokerHolder.h>
|
|
5
|
+
#include "react-native-nobodywho.h"
|
|
6
|
+
|
|
7
|
+
namespace jsi = facebook::jsi;
|
|
8
|
+
namespace react = facebook::react;
|
|
9
|
+
|
|
10
|
+
// Automated testing checks Java_com_nobodywho_NobodywhoModule and nobodywho
|
|
11
|
+
// by comparing the whole line here.
|
|
12
|
+
/*
|
|
13
|
+
Java_com_nobodywho_NobodywhoModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
|
|
14
|
+
return nobodywho::multiply(a, b);
|
|
15
|
+
}
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Installer coming from NobodywhoModule
|
|
19
|
+
extern "C"
|
|
20
|
+
JNIEXPORT jboolean JNICALL
|
|
21
|
+
Java_com_nobodywho_NobodywhoModule_nativeInstallRustCrate(
|
|
22
|
+
JNIEnv *env,
|
|
23
|
+
jclass type,
|
|
24
|
+
jlong rtPtr,
|
|
25
|
+
jobject callInvokerHolderJavaObj
|
|
26
|
+
) {
|
|
27
|
+
using JCallInvokerHolder = facebook::react::CallInvokerHolder;
|
|
28
|
+
|
|
29
|
+
auto holderLocal = facebook::jni::make_local(callInvokerHolderJavaObj);
|
|
30
|
+
auto holderRef = facebook::jni::static_ref_cast<JCallInvokerHolder::javaobject>(holderLocal);
|
|
31
|
+
auto* holderCxx = holderRef->cthis();
|
|
32
|
+
auto jsCallInvoker = holderCxx->getCallInvoker();
|
|
33
|
+
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
|
34
|
+
|
|
35
|
+
return nobodywho::installRustCrate(*runtime, jsCallInvoker);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
extern "C"
|
|
39
|
+
JNIEXPORT jboolean JNICALL
|
|
40
|
+
Java_com_nobodywho_NobodywhoModule_nativeCleanupRustCrate(JNIEnv *env, jclass type, jlong rtPtr) {
|
|
41
|
+
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
|
42
|
+
return nobodywho::cleanupRustCrate(*runtime);
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package com.nobodywho
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
|
7
|
+
|
|
8
|
+
@ReactModule(name = NobodywhoModule.NAME)
|
|
9
|
+
class NobodywhoModule(reactContext: ReactApplicationContext) :
|
|
10
|
+
NativeNobodywhoSpec(reactContext) {
|
|
11
|
+
|
|
12
|
+
override fun getName(): String {
|
|
13
|
+
return NAME
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Two native methods implemented in cpp-adapter.cpp, and ultimately
|
|
17
|
+
// react-native-nobodywho.cpp
|
|
18
|
+
|
|
19
|
+
external fun nativeInstallRustCrate(runtimePointer: Long, callInvoker: CallInvokerHolder): Boolean
|
|
20
|
+
external fun nativeCleanupRustCrate(runtimePointer: Long): Boolean
|
|
21
|
+
|
|
22
|
+
override fun installRustCrate(): Boolean {
|
|
23
|
+
val context = this.reactApplicationContext
|
|
24
|
+
return nativeInstallRustCrate(
|
|
25
|
+
context.javaScriptContextHolder!!.get(),
|
|
26
|
+
context.jsCallInvokerHolder!!
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun cleanupRustCrate(): Boolean {
|
|
31
|
+
return nativeCleanupRustCrate(
|
|
32
|
+
this.reactApplicationContext.javaScriptContextHolder!!.get()
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
companion object {
|
|
37
|
+
const val NAME = "Nobodywho"
|
|
38
|
+
|
|
39
|
+
init {
|
|
40
|
+
System.loadLibrary("react-native-nobodywho")
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package com.nobodywho
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.TurboReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
import java.util.HashMap
|
|
10
|
+
|
|
11
|
+
class NobodywhoPackage : TurboReactPackage() {
|
|
12
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
13
|
+
return if (name == NobodywhoModule.NAME) {
|
|
14
|
+
NobodywhoModule(reactContext)
|
|
15
|
+
} else {
|
|
16
|
+
null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
21
|
+
return ReactModuleInfoProvider {
|
|
22
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
23
|
+
moduleInfos[NobodywhoModule.NAME] = ReactModuleInfo(
|
|
24
|
+
NobodywhoModule.NAME,
|
|
25
|
+
NobodywhoModule.NAME,
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
false, // isCxxModule
|
|
29
|
+
true // isTurboModule
|
|
30
|
+
)
|
|
31
|
+
moduleInfos
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#include "nobodywho-react-native.h"
|
|
3
|
+
#include "../generated/cpp/nobodywho.hpp"
|
|
4
|
+
|
|
5
|
+
namespace nobodywhoreactnative {
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker) {
|
|
9
|
+
NativeNobodywho::registerModule(runtime, callInvoker);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifndef NOBODYWHOREACTNATIVE_H
|
|
2
|
+
#define NOBODYWHOREACTNATIVE_H
|
|
3
|
+
// Generated by uniffi-bindgen-react-native
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
#include <ReactCommon/CallInvoker.h>
|
|
7
|
+
|
|
8
|
+
namespace nobodywhoreactnative {
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker);
|
|
12
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#endif /* NOBODYWHOREACTNATIVE_H */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#include "react-native-nobodywho.h"
|
|
3
|
+
#include "../generated/cpp/nobodywho.hpp"
|
|
4
|
+
|
|
5
|
+
namespace nobodywho {
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker) {
|
|
9
|
+
NativeNobodywho::registerModule(runtime, callInvoker);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifndef NOBODYWHO_H
|
|
2
|
+
#define NOBODYWHO_H
|
|
3
|
+
// Generated by uniffi-bindgen-react-native
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
#include <ReactCommon/CallInvoker.h>
|
|
7
|
+
|
|
8
|
+
namespace nobodywho {
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker);
|
|
12
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#endif /* NOBODYWHO_H */
|