react-native-nitro-sqlite 8.2.2-nitro.1 → 9.0.0
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/RNNitroSQLite.podspec +22 -5
- package/android/CMakeLists.txt +42 -5
- package/android/build.gradle +83 -23
- package/android/{src/main/cpp/cpp-adapter.cpp → cpp-adapter.cpp} +1 -1
- package/android/gradle.properties +5 -0
- package/android/src/main/java/com/margelo/rnnitrosqlite/DocPathSetter.kt +13 -0
- package/android/src/main/java/com/margelo/rnnitrosqlite/RNNitroSQLitePackage.kt +40 -0
- package/android/src/newarch/com/margelo/rnnitrosqlite/RNNitroSQLiteOnLoadModule.kt +41 -0
- package/android/src/oldarch/com/margelo/rnnitrosqlite/RNNitroSQLiteOnLoadModule.kt +43 -0
- package/cpp/operations.cpp +0 -3
- package/cpp/sqlite/sqlite3.c +41 -41
- package/cpp/sqliteExecuteBatch.cpp +0 -1
- package/lib/commonjs/index.js +6 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nitro.js.map +1 -1
- package/lib/commonjs/operations/execute.js +1 -1
- package/lib/commonjs/operations/execute.js.map +1 -1
- package/lib/commonjs/operations/session.js +3 -3
- package/lib/commonjs/operations/session.js.map +1 -1
- package/lib/commonjs/operations/transaction.js +4 -7
- package/lib/commonjs/operations/transaction.js.map +1 -1
- package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.ios.js.map +1 -1
- package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.js.map +1 -1
- package/lib/commonjs/specs/NativeQueryResult.nitro.js.map +1 -1
- package/lib/commonjs/specs/NitroSQLite.nitro.js.map +1 -1
- package/lib/commonjs/typeORM.js +1 -1
- package/lib/commonjs/typeORM.js.map +1 -1
- package/lib/commonjs/types.js +0 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.js +9 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/nitro.js +2 -0
- package/lib/module/nitro.js.map +1 -1
- package/lib/module/operations/execute.js +3 -1
- package/lib/module/operations/execute.js.map +1 -1
- package/lib/module/operations/session.js +5 -3
- package/lib/module/operations/session.js.map +1 -1
- package/lib/module/operations/transaction.js +6 -7
- package/lib/module/operations/transaction.js.map +1 -1
- package/lib/module/specs/NativeNitroSQLiteOnLoad.ios.js +2 -0
- package/lib/module/specs/NativeNitroSQLiteOnLoad.ios.js.map +1 -1
- package/lib/module/specs/NativeNitroSQLiteOnLoad.js +2 -0
- package/lib/module/specs/NativeNitroSQLiteOnLoad.js.map +1 -1
- package/lib/module/specs/NativeQueryResult.nitro.js +2 -0
- package/lib/module/specs/NativeQueryResult.nitro.js.map +1 -1
- package/lib/module/specs/NitroSQLite.nitro.js +2 -0
- package/lib/module/specs/NitroSQLite.nitro.js.map +1 -1
- package/lib/module/typeORM.js +3 -1
- package/lib/module/typeORM.js.map +1 -1
- package/lib/module/types.js +2 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/{index.d.ts → commonjs/index.d.ts} +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/{nitro.d.ts → commonjs/nitro.d.ts} +1 -0
- package/lib/typescript/commonjs/nitro.d.ts.map +1 -0
- package/lib/typescript/{operations → commonjs/operations}/execute.d.ts +1 -0
- package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -0
- package/lib/typescript/{operations → commonjs/operations}/session.d.ts +1 -0
- package/lib/typescript/commonjs/operations/session.d.ts.map +1 -0
- package/lib/typescript/{operations → commonjs/operations}/transaction.d.ts +1 -0
- package/lib/typescript/commonjs/operations/transaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/{specs → commonjs/specs}/NativeNitroSQLiteOnLoad.d.ts +1 -0
- package/lib/typescript/commonjs/specs/NativeNitroSQLiteOnLoad.d.ts.map +1 -0
- package/lib/typescript/{specs → commonjs/specs}/NativeNitroSQLiteOnLoad.ios.d.ts +1 -0
- package/lib/typescript/commonjs/specs/NativeNitroSQLiteOnLoad.ios.d.ts.map +1 -0
- package/lib/typescript/{specs → commonjs/specs}/NativeQueryResult.nitro.d.ts +1 -0
- package/lib/typescript/commonjs/specs/NativeQueryResult.nitro.d.ts.map +1 -0
- package/lib/typescript/{specs → commonjs/specs}/NitroSQLite.nitro.d.ts +1 -0
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts.map +1 -0
- package/lib/typescript/{typeORM.d.ts → commonjs/typeORM.d.ts} +1 -0
- package/lib/typescript/commonjs/typeORM.d.ts.map +1 -0
- package/lib/typescript/{types.d.ts → commonjs/types.d.ts} +1 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +31 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/nitro.d.ts +8 -0
- package/lib/typescript/module/nitro.d.ts.map +1 -0
- package/lib/typescript/module/operations/execute.d.ts +4 -0
- package/lib/typescript/module/operations/execute.d.ts.map +1 -0
- package/lib/typescript/module/operations/session.d.ts +5 -0
- package/lib/typescript/module/operations/session.d.ts.map +1 -0
- package/lib/typescript/module/operations/transaction.d.ts +6 -0
- package/lib/typescript/module/operations/transaction.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/specs/NativeNitroSQLiteOnLoad.d.ts +7 -0
- package/lib/typescript/module/specs/NativeNitroSQLiteOnLoad.d.ts.map +1 -0
- package/lib/typescript/module/specs/NativeNitroSQLiteOnLoad.ios.d.ts +4 -0
- package/lib/typescript/module/specs/NativeNitroSQLiteOnLoad.ios.d.ts.map +1 -0
- package/lib/typescript/module/specs/NativeQueryResult.nitro.d.ts +38 -0
- package/lib/typescript/module/specs/NativeQueryResult.nitro.d.ts.map +1 -0
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts +20 -0
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts.map +1 -0
- package/lib/typescript/module/typeORM.d.ts +20 -0
- package/lib/typescript/module/typeORM.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +80 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/nitrogen/generated/android/RNNitroSQLite+autolinking.cmake +13 -1
- package/nitrogen/generated/android/RNNitroSQLite+autolinking.gradle +2 -0
- package/nitrogen/generated/ios/RNNitroSQLite+autolinking.rb +1 -1
- package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.hpp +0 -6
- package/package.json +85 -42
- package/src/operations/transaction.ts +2 -3
- package/src/types.ts +0 -1
- package/android/src/main/java/com/margelo/rnnitrosqlite/RNNitroSQLiteOnLoadModule.java +0 -57
- package/android/src/main/java/com/margelo/rnnitrosqlite/RNNitroSQLitePackage.java +0 -48
- package/lib/tsconfig.tsbuildinfo +0 -1
package/RNNitroSQLite.podspec
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
4
5
|
|
|
5
6
|
# TODO: Should be customizable in package.json.
|
|
6
7
|
# Used to create comparable benchmark results
|
|
@@ -17,6 +18,9 @@ Pod::Spec.new do |s|
|
|
|
17
18
|
s.platforms = { :ios => min_ios_version_supported, :visionos => "1.0" }
|
|
18
19
|
s.source = { :git => "https://github.com/margelo/react-native-nitro-sqlite.git", :tag => "#{s.version}" }
|
|
19
20
|
|
|
21
|
+
# s.header_mappings_dir = "cpp"
|
|
22
|
+
s.source_files = "ios/**/*.{h,hpp,m,mm}", "cpp/**/*.{h,hpp,c,cpp}"
|
|
23
|
+
|
|
20
24
|
s.pod_target_xcconfig = {
|
|
21
25
|
:GCC_PREPROCESSOR_DEFINITIONS => "HAVE_FULLFSYNC=1",
|
|
22
26
|
:WARNING_CFLAGS => "-Wno-shorten-64-to-32 -Wno-comma -Wno-unreachable-code -Wno-conditional-uninitialized -Wno-deprecated-declarations",
|
|
@@ -25,18 +29,32 @@ Pod::Spec.new do |s|
|
|
|
25
29
|
'CLANG_CXX_LIBRARY' => 'libc++'
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
# s.header_mappings_dir = "cpp"
|
|
29
|
-
s.source_files = "ios/**/*.{h,hpp,m,mm}", "cpp/**/*.{h,hpp,c,cpp}"
|
|
30
|
-
|
|
31
32
|
load 'nitrogen/generated/ios/RNNitroSQLite+autolinking.rb'
|
|
32
33
|
add_nitrogen_files(s)
|
|
33
34
|
|
|
34
|
-
if
|
|
35
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
36
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
37
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
35
38
|
install_modules_dependencies(s)
|
|
36
39
|
else
|
|
37
40
|
s.dependency "React-callinvoker"
|
|
38
41
|
s.dependency "React"
|
|
39
42
|
s.dependency "React-Core"
|
|
43
|
+
|
|
44
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
45
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
46
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
47
|
+
s.pod_target_xcconfig = {
|
|
48
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
49
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
50
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
51
|
+
}
|
|
52
|
+
s.dependency "React-Codegen"
|
|
53
|
+
s.dependency "RCT-Folly"
|
|
54
|
+
s.dependency "RCTRequired"
|
|
55
|
+
s.dependency "RCTTypeSafety"
|
|
56
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
57
|
+
end
|
|
40
58
|
end
|
|
41
59
|
|
|
42
60
|
optimizedCflags = '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1'
|
|
@@ -55,5 +73,4 @@ Pod::Spec.new do |s|
|
|
|
55
73
|
s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h"
|
|
56
74
|
s.library = "sqlite3"
|
|
57
75
|
end
|
|
58
|
-
|
|
59
76
|
end
|
package/android/CMakeLists.txt
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
1
2
|
project(RNNitroSQLite)
|
|
2
|
-
cmake_minimum_required(VERSION 3.9.0)
|
|
3
3
|
|
|
4
|
-
set (PACKAGE_NAME RNNitroSQLite)
|
|
5
4
|
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
5
|
set (CMAKE_CXX_STANDARD 20)
|
|
7
6
|
|
|
@@ -12,11 +11,11 @@ add_definitions(
|
|
|
12
11
|
file(GLOB_RECURSE cpp_files RELATIVE ${CMAKE_SOURCE_DIR}
|
|
13
12
|
"../cpp/**.c"
|
|
14
13
|
"../cpp/**.cpp"
|
|
15
|
-
"
|
|
14
|
+
"cpp-adapter.cpp"
|
|
16
15
|
)
|
|
17
16
|
|
|
18
17
|
# Create library "RNNitroSQLite" and add all C++ files to it
|
|
19
|
-
add_library(${
|
|
18
|
+
add_library(${CMAKE_PROJECT_NAME} SHARED
|
|
20
19
|
${cpp_files}
|
|
21
20
|
)
|
|
22
21
|
|
|
@@ -30,10 +29,48 @@ include_directories(
|
|
|
30
29
|
src/main/cpp
|
|
31
30
|
)
|
|
32
31
|
|
|
32
|
+
set_target_properties(
|
|
33
|
+
${CMAKE_PROJECT_NAME} PROPERTIES
|
|
34
|
+
CXX_STANDARD ${CMAKE_CXX_STANDARD}
|
|
35
|
+
CXX_EXTENSIONS OFF
|
|
36
|
+
POSITION_INDEPENDENT_CODE ON
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
40
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
33
41
|
find_library(LOG_LIB log)
|
|
34
42
|
|
|
35
43
|
target_link_libraries(
|
|
36
|
-
${
|
|
44
|
+
${CMAKE_PROJECT_NAME}
|
|
37
45
|
${LOG_LIB}
|
|
38
46
|
android
|
|
47
|
+
fbjni::fbjni
|
|
48
|
+
ReactAndroid::jsi
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# https://github.com/react-native-community/discussions-and-proposals/discussions/816
|
|
52
|
+
# This if-then-else can be removed once this library does not support version below .76
|
|
53
|
+
if (REACTNATIVE_MERGED_SO OR ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
54
|
+
target_link_libraries(
|
|
55
|
+
${CMAKE_PROJECT_NAME}
|
|
56
|
+
ReactAndroid::reactnative
|
|
57
|
+
)
|
|
58
|
+
else()
|
|
59
|
+
target_link_libraries(
|
|
60
|
+
${CMAKE_PROJECT_NAME}
|
|
61
|
+
ReactAndroid::turbomodulejsijni
|
|
62
|
+
ReactAndroid::react_nativemodule_core
|
|
63
|
+
)
|
|
64
|
+
endif()
|
|
65
|
+
|
|
66
|
+
target_compile_options(
|
|
67
|
+
${CMAKE_PROJECT_NAME}
|
|
68
|
+
PRIVATE
|
|
69
|
+
-DLOG_TAG=\"ReactNative\"
|
|
70
|
+
-fexceptions
|
|
71
|
+
-frtti
|
|
72
|
+
-fstack-protector-all
|
|
73
|
+
-O2
|
|
74
|
+
-Wall
|
|
75
|
+
-DONANDROID
|
|
39
76
|
)
|
package/android/build.gradle
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNNitroSQLite_kotlinVersion"]
|
|
4
|
+
|
|
2
5
|
repositories {
|
|
3
6
|
google()
|
|
4
7
|
mavenCentral()
|
|
@@ -6,6 +9,8 @@ buildscript {
|
|
|
6
9
|
|
|
7
10
|
dependencies {
|
|
8
11
|
classpath "com.android.tools.build:gradle:7.2.2"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
9
14
|
}
|
|
10
15
|
}
|
|
11
16
|
|
|
@@ -18,26 +23,77 @@ def isNewArchitectureEnabled() {
|
|
|
18
23
|
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
24
|
}
|
|
20
25
|
|
|
26
|
+
def getExtOrDefault(name) {
|
|
27
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNNitroSQLite_" + name]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def getExtOrIntegerDefault(name) {
|
|
31
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNNitroSQLite_" + name]).toInteger()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def safeAppExtGet(prop, fallback) {
|
|
35
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
36
|
+
appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def resolveBuildType() {
|
|
40
|
+
Gradle gradle = getGradle()
|
|
41
|
+
String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
|
|
42
|
+
return tskReqStr.contains('Release') ? 'release' : 'debug'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
def supportsNamespace() {
|
|
46
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
47
|
+
def major = parsed[0].toInteger()
|
|
48
|
+
def minor = parsed[1].toInteger()
|
|
49
|
+
|
|
50
|
+
// Namespace support was added in 7.3.0
|
|
51
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
def resolveReactNativeDirectory() {
|
|
55
|
+
def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
|
|
56
|
+
if (reactNativeLocation != null) {
|
|
57
|
+
return file(reactNativeLocation)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Fallback to node resolver for custom directory structures like monorepos.
|
|
61
|
+
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
|
|
62
|
+
if (reactNativePackage.exists()) {
|
|
63
|
+
return reactNativePackage.parentFile
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
throw new GradleException("[react-native-nitro-sqlite] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules.")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
70
|
+
def reactProperties = new Properties()
|
|
71
|
+
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
72
|
+
|
|
73
|
+
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
|
|
74
|
+
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
|
|
75
|
+
|
|
21
76
|
def SQLITE_FLAGS = rootProject.properties['nitroSqliteFlags']
|
|
22
77
|
|
|
23
78
|
apply plugin: "com.android.library"
|
|
24
|
-
apply plugin:
|
|
25
|
-
apply from: '../nitrogen/generated/android/RNNitroSQLite+autolinking.gradle'
|
|
79
|
+
apply plugin: "kotlin-android"
|
|
26
80
|
|
|
27
81
|
if (isNewArchitectureEnabled()) {
|
|
28
82
|
apply plugin: "com.facebook.react"
|
|
29
83
|
}
|
|
30
84
|
|
|
31
|
-
|
|
32
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNNitroSQLite_" + name]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
def getExtOrIntegerDefault(name) {
|
|
36
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNNitroSQLite_" + name]).toInteger()
|
|
37
|
-
}
|
|
85
|
+
apply from: '../nitrogen/generated/android/RNNitroSQLite+autolinking.gradle'
|
|
38
86
|
|
|
39
87
|
android {
|
|
40
|
-
|
|
88
|
+
if (supportsNamespace()) {
|
|
89
|
+
namespace "com.margelo.rnnitrosqlite"
|
|
90
|
+
|
|
91
|
+
sourceSets {
|
|
92
|
+
main {
|
|
93
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
41
97
|
|
|
42
98
|
ndkVersion getExtOrDefault("ndkVersion")
|
|
43
99
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
@@ -45,12 +101,16 @@ android {
|
|
|
45
101
|
defaultConfig {
|
|
46
102
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
47
103
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
104
|
+
|
|
105
|
+
buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString()
|
|
48
106
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
49
107
|
|
|
50
108
|
externalNativeBuild {
|
|
51
109
|
cmake {
|
|
52
|
-
|
|
53
|
-
|
|
110
|
+
arguments "-DANDROID_STL=c++_shared",
|
|
111
|
+
"-DANDROID_TOOLCHAIN=clang",
|
|
112
|
+
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
|
|
113
|
+
"-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'"
|
|
54
114
|
abiFilters (*reactNativeArchitectures())
|
|
55
115
|
}
|
|
56
116
|
}
|
|
@@ -59,6 +119,7 @@ android {
|
|
|
59
119
|
externalNativeBuild {
|
|
60
120
|
cmake {
|
|
61
121
|
path "CMakeLists.txt"
|
|
122
|
+
version = System.getenv("CMAKE_VERSION") ?: "3.22.1"
|
|
62
123
|
}
|
|
63
124
|
}
|
|
64
125
|
|
|
@@ -86,30 +147,27 @@ android {
|
|
|
86
147
|
main {
|
|
87
148
|
if (isNewArchitectureEnabled()) {
|
|
88
149
|
java.srcDirs += [
|
|
89
|
-
|
|
90
|
-
|
|
150
|
+
"src/newarch",
|
|
151
|
+
// Codegen specs
|
|
152
|
+
"generated/java",
|
|
153
|
+
"generated/jni"
|
|
91
154
|
]
|
|
155
|
+
} else {
|
|
156
|
+
java.srcDirs += ["src/oldarch"]
|
|
92
157
|
}
|
|
93
158
|
}
|
|
94
159
|
}
|
|
95
160
|
|
|
96
161
|
packagingOptions {
|
|
162
|
+
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
|
|
97
163
|
excludes = [
|
|
98
164
|
"META-INF",
|
|
99
165
|
"META-INF/**",
|
|
166
|
+
"**/libreactnative.so",
|
|
100
167
|
"**/libc++_shared.so",
|
|
101
168
|
"**/libfbjni.so",
|
|
102
169
|
"**/libjsi.so",
|
|
103
|
-
"**/libfolly_json.so",
|
|
104
|
-
"**/libfolly_runtime.so",
|
|
105
|
-
"**/libglog.so",
|
|
106
170
|
"**/libhermes.so",
|
|
107
|
-
"**/libhermes-executor-debug.so",
|
|
108
|
-
"**/libhermes_executor.so",
|
|
109
|
-
"**/libreactnativejni.so",
|
|
110
|
-
"**/libturbomodulejsijni.so",
|
|
111
|
-
"**/libreact_nativemodule_core.so",
|
|
112
|
-
"**/libjscexecutor.so"
|
|
113
171
|
]
|
|
114
172
|
}
|
|
115
173
|
}
|
|
@@ -119,12 +177,14 @@ repositories {
|
|
|
119
177
|
google()
|
|
120
178
|
}
|
|
121
179
|
|
|
180
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
122
181
|
|
|
123
182
|
dependencies {
|
|
124
183
|
// For < 0.71, this will be from the local maven repo
|
|
125
184
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
126
185
|
//noinspection GradleDynamicVersion
|
|
127
186
|
implementation "com.facebook.react:react-native:+"
|
|
187
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
128
188
|
|
|
129
189
|
// Add a dependency on NitroModules
|
|
130
190
|
implementation project(":react-native-nitro-modules")
|
|
@@ -13,7 +13,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
|
13
13
|
|
|
14
14
|
extern "C"
|
|
15
15
|
JNIEXPORT void JNICALL
|
|
16
|
-
|
|
16
|
+
Java_com_margelo_rnnitrosqlite_DocPathSetter_setDocPathInJNI(JNIEnv *env, jclass clazz,
|
|
17
17
|
jstring doc_path) {
|
|
18
18
|
const char *nativeString = env->GetStringUTFChars(doc_path, nullptr);
|
|
19
19
|
HybridNitroSQLite::docPath = std::string(nativeString);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.margelo.rnnitrosqlite
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
|
|
5
|
+
object DocPathSetter {
|
|
6
|
+
@JvmStatic
|
|
7
|
+
fun setDocPath(context: ReactApplicationContext) {
|
|
8
|
+
val path = context.filesDir.absolutePath
|
|
9
|
+
setDocPathInJNI(path)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private external fun setDocPathInJNI(docPath: String)
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.margelo.rnnitrosqlite
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
|
|
9
|
+
class RNNitroSQLitePackage : TurboReactPackage() {
|
|
10
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
11
|
+
return if (name == RNNitroSQLiteOnLoadModule.NAME) {
|
|
12
|
+
RNNitroSQLiteOnLoadModule(reactContext)
|
|
13
|
+
} else {
|
|
14
|
+
null
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
19
|
+
return ReactModuleInfoProvider {
|
|
20
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
21
|
+
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
22
|
+
moduleInfos[RNNitroSQLiteOnLoadModule.NAME] = ReactModuleInfo(
|
|
23
|
+
RNNitroSQLiteOnLoadModule.NAME,
|
|
24
|
+
RNNitroSQLiteOnLoadModule.NAME,
|
|
25
|
+
canOverrideExistingModule=false,
|
|
26
|
+
needsEagerInit=true,
|
|
27
|
+
hasConstants=true,
|
|
28
|
+
isCxxModule=false,
|
|
29
|
+
isTurboModule=isTurboModule
|
|
30
|
+
)
|
|
31
|
+
moduleInfos
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
companion object {
|
|
36
|
+
init {
|
|
37
|
+
System.loadLibrary("RNNitroSQLite")
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package com.margelo.rnnitrosqlite
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Callback
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.margelo.rnnitrosqlite.NativeNitroSQLiteOnLoadSpec
|
|
6
|
+
|
|
7
|
+
class RNNitroSQLiteOnLoadModule(reactContext: ReactApplicationContext) :
|
|
8
|
+
NativeNitroSQLiteOnLoadSpec(reactContext) {
|
|
9
|
+
private var reactApplicationContextReadyCallback: Callback? = null
|
|
10
|
+
|
|
11
|
+
init {
|
|
12
|
+
Companion.reactContext = reactContext
|
|
13
|
+
DocPathSetter.setDocPath(reactContext)
|
|
14
|
+
|
|
15
|
+
if (reactApplicationContextReadyCallback != null) {
|
|
16
|
+
reactApplicationContextReadyCallback!!.invoke()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getName(): String {
|
|
21
|
+
return NAME
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun onReactApplicationContextReady(callback: Callback) {
|
|
25
|
+
if (reactContext != null) {
|
|
26
|
+
callback.invoke()
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
reactApplicationContextReadyCallback = callback
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
companion object {
|
|
34
|
+
const val NAME: String = "RNNitroSQLiteOnLoad"
|
|
35
|
+
|
|
36
|
+
var reactContext: ReactApplicationContext? = null
|
|
37
|
+
private set
|
|
38
|
+
var reactApplicationContextReadyCallback: Callback? = null
|
|
39
|
+
private set
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package com.margelo.rnnitrosqlite
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Callback
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
|
|
8
|
+
class RNNitroSQLiteOnLoadModule(reactContext: ReactApplicationContext) :
|
|
9
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
init {
|
|
13
|
+
Companion.reactContext = reactContext
|
|
14
|
+
DocPathSetter.setDocPath(reactContext)
|
|
15
|
+
|
|
16
|
+
if (reactApplicationContextReadyCallback != null) {
|
|
17
|
+
reactApplicationContextReadyCallback!!.invoke()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun getName(): String {
|
|
22
|
+
return NAME
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@ReactMethod
|
|
26
|
+
fun onReactApplicationContextReady(callback: Callback) {
|
|
27
|
+
if (reactContext != null) {
|
|
28
|
+
callback.invoke()
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
reactApplicationContextReadyCallback = callback
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
companion object {
|
|
36
|
+
const val NAME: String = "RNNitroSQLiteOnLoad"
|
|
37
|
+
|
|
38
|
+
var reactContext: ReactApplicationContext? = null
|
|
39
|
+
private set
|
|
40
|
+
var reactApplicationContextReadyCallback: Callback? = null
|
|
41
|
+
private set
|
|
42
|
+
}
|
|
43
|
+
}
|
package/cpp/operations.cpp
CHANGED
|
@@ -102,7 +102,6 @@ void bindStatement(sqlite3_stmt* statement, const SQLiteQueryParams& values) {
|
|
|
102
102
|
for (int valueIndex = 0; valueIndex < values.size(); valueIndex++) {
|
|
103
103
|
int sqliteIndex = valueIndex+1;
|
|
104
104
|
SQLiteValue value = values.at(valueIndex);
|
|
105
|
-
|
|
106
105
|
// if (std::holds_alternative<std::monostate>(value))
|
|
107
106
|
// {
|
|
108
107
|
// sqlite3_bind_null(statement, sqliteIndex);
|
|
@@ -148,7 +147,6 @@ SQLiteExecuteQueryResult sqliteExecute(const std::string& dbName, const std::str
|
|
|
148
147
|
std::string column_name;
|
|
149
148
|
ColumnType column_declared_type;
|
|
150
149
|
SQLiteQueryResultRow row;
|
|
151
|
-
|
|
152
150
|
auto results = std::make_unique<SQLiteQueryResults>();
|
|
153
151
|
auto metadata = new SQLiteQueryTableMetadata();
|
|
154
152
|
|
|
@@ -232,7 +230,6 @@ SQLiteExecuteQueryResult sqliteExecute(const std::string& dbName, const std::str
|
|
|
232
230
|
? std::make_optional(std::move(*metadata))
|
|
233
231
|
: std::nullopt
|
|
234
232
|
);
|
|
235
|
-
|
|
236
233
|
return {
|
|
237
234
|
.rowsAffected = rowsAffected,
|
|
238
235
|
.insertId = static_cast<double>(latestInsertRowId),
|