@op-engineering/op-sqlite 5.0.1 → 5.0.5
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/android/CMakeLists.txt +23 -14
- package/android/build.gradle +22 -5
- package/cpp/PreparedStatementHostObject.cpp +1 -0
- package/cpp/bindings.cpp +9 -0
- package/cpp/bridge.cpp +1 -1
- package/cpp/sqlcipher/sqlite3.c +8992 -3860
- package/cpp/sqlcipher/sqlite3.h +1674 -1343
- package/cpp/utils.cpp +3 -3
- package/lib/commonjs/index.js +25 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/op-sqlite.podspec +18 -0
- package/package.json +1 -1
- package/src/index.ts +29 -0
package/android/CMakeLists.txt
CHANGED
|
@@ -39,7 +39,7 @@ add_library(
|
|
|
39
39
|
cpp-adapter.cpp
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
if (
|
|
42
|
+
if (USE_SQLCIPHER)
|
|
43
43
|
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlcipher/sqlite3.h ../cpp/sqlcipher/sqlite3.c)
|
|
44
44
|
|
|
45
45
|
add_definitions(
|
|
@@ -53,7 +53,7 @@ else()
|
|
|
53
53
|
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.h ../cpp/sqlite3.c)
|
|
54
54
|
endif()
|
|
55
55
|
|
|
56
|
-
if (
|
|
56
|
+
if (USE_CRSQLITE)
|
|
57
57
|
add_definitions(
|
|
58
58
|
-DOP_SQLITE_USE_CRSQLITE=1
|
|
59
59
|
)
|
|
@@ -70,16 +70,25 @@ find_package(ReactAndroid REQUIRED CONFIG)
|
|
|
70
70
|
find_package(fbjni REQUIRED CONFIG)
|
|
71
71
|
find_library(LOG_LIB log)
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
if (USE_SQLCIPHER)
|
|
74
|
+
target_link_libraries(
|
|
75
|
+
${PACKAGE_NAME}
|
|
76
|
+
${LOG_LIB}
|
|
77
|
+
fbjni::fbjni
|
|
78
|
+
ReactAndroid::jsi
|
|
79
|
+
ReactAndroid::turbomodulejsijni
|
|
80
|
+
ReactAndroid::react_nativemodule_core
|
|
81
|
+
android
|
|
82
|
+
openssl::crypto
|
|
83
|
+
)
|
|
84
|
+
else()
|
|
85
|
+
target_link_libraries(
|
|
86
|
+
${PACKAGE_NAME}
|
|
87
|
+
${LOG_LIB}
|
|
88
|
+
fbjni::fbjni
|
|
89
|
+
ReactAndroid::jsi
|
|
90
|
+
ReactAndroid::turbomodulejsijni
|
|
91
|
+
ReactAndroid::react_nativemodule_core
|
|
92
|
+
android
|
|
93
|
+
)
|
|
85
94
|
endif()
|
package/android/build.gradle
CHANGED
|
@@ -31,6 +31,7 @@ def useSQLCipher = false
|
|
|
31
31
|
def useCRSQLite = false
|
|
32
32
|
def performanceMode = "0"
|
|
33
33
|
def sqliteFlags = ""
|
|
34
|
+
def enableFTS5 = false
|
|
34
35
|
|
|
35
36
|
def packageJsonFile = new File("$rootDir/../package.json")
|
|
36
37
|
def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
|
|
@@ -41,6 +42,7 @@ if(opsqliteConfig) {
|
|
|
41
42
|
useCRSQLite = opsqliteConfig["crsqlite"]
|
|
42
43
|
performanceMode = opsqliteConfig["performanceMode"] ? opsqliteConfig["performanceMode"] : ""
|
|
43
44
|
sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
|
|
45
|
+
enableFTS5 = opsqliteConfig["fts5"]
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
if(useSQLCipher) {
|
|
@@ -61,6 +63,10 @@ if(performanceMode == "2") {
|
|
|
61
63
|
println "[OP-SQLITE] Thread safe performance mode enabled! 🚀"
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
if(enableFTS5) {
|
|
67
|
+
println "[OP-SQLITE] FTS5 enabled! 🔎"
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
if (isNewArchitectureEnabled()) {
|
|
65
71
|
apply plugin: "com.facebook.react"
|
|
66
72
|
}
|
|
@@ -100,26 +106,37 @@ android {
|
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
defaultConfig {
|
|
103
|
-
minSdkVersion
|
|
109
|
+
minSdkVersion 23
|
|
104
110
|
targetSdkVersion safeExtGet('targetSdkVersion', 34)
|
|
105
111
|
versionCode 1
|
|
106
112
|
versionName "1.0"
|
|
107
113
|
|
|
108
114
|
externalNativeBuild {
|
|
109
115
|
cmake {
|
|
116
|
+
if(useSQLCipher) {
|
|
117
|
+
cFlags += "-DOP_SQLITE_USE_SQLCIPHER=1"
|
|
118
|
+
cppFlags += "-DOP_SQLITE_USE_SQLCIPHER=1"
|
|
119
|
+
}
|
|
120
|
+
if(useCRSQLite) {
|
|
121
|
+
cFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
|
|
122
|
+
cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
|
|
123
|
+
}
|
|
110
124
|
if(performanceMode == '1') {
|
|
111
125
|
cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=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"]
|
|
112
126
|
}
|
|
113
127
|
if(performanceMode == '2') {
|
|
114
128
|
cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=1", "-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"]
|
|
115
129
|
}
|
|
130
|
+
if(enableFTS5) {
|
|
131
|
+
cFlags += ["-DSQLITE_ENABLE_FTS4=1", "-DSQLITE_ENABLE_FTS3_PARENTHESIS=1", "-DSQLITE_ENABLE_FTS5=1"]
|
|
132
|
+
}
|
|
116
133
|
|
|
117
134
|
cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
|
|
118
135
|
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
|
|
119
136
|
arguments "-DANDROID_STL=c++_shared",
|
|
120
|
-
"-DSQLITE_FLAGS='$sqliteFlags'"
|
|
121
|
-
"-
|
|
122
|
-
"-
|
|
137
|
+
"-DSQLITE_FLAGS='$sqliteFlags'",
|
|
138
|
+
"-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}",
|
|
139
|
+
"-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}"
|
|
123
140
|
abiFilters (*reactNativeArchitectures())
|
|
124
141
|
}
|
|
125
142
|
}
|
|
@@ -170,7 +187,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
170
187
|
dependencies {
|
|
171
188
|
implementation 'com.facebook.react:react-native'
|
|
172
189
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
173
|
-
if (
|
|
190
|
+
if (useSQLCipher) {
|
|
174
191
|
implementation('com.android.ndk.thirdparty:openssl:1.1.1q-beta-1')
|
|
175
192
|
}
|
|
176
193
|
}
|
|
@@ -42,6 +42,7 @@ jsi::Value PreparedStatementHostObject::get(jsi::Runtime &rt,
|
|
|
42
42
|
if (_statement == nullptr) {
|
|
43
43
|
throw std::runtime_error("statement has been freed");
|
|
44
44
|
}
|
|
45
|
+
|
|
45
46
|
std::vector<DumbHostObject> results;
|
|
46
47
|
std::shared_ptr<std::vector<SmartHostObject>> metadata =
|
|
47
48
|
std::make_shared<std::vector<SmartHostObject>>();
|
package/cpp/bindings.cpp
CHANGED
|
@@ -663,6 +663,14 @@ void install(jsi::Runtime &rt,
|
|
|
663
663
|
return jsi::String::createFromUtf8(rt, result);
|
|
664
664
|
});
|
|
665
665
|
|
|
666
|
+
auto is_sqlcipher = HOSTFN("isSQLCipher", 0) {
|
|
667
|
+
#ifdef OP_SQLITE_USE_SQLCIPHER
|
|
668
|
+
return true;
|
|
669
|
+
#else
|
|
670
|
+
return false;
|
|
671
|
+
#endif
|
|
672
|
+
});
|
|
673
|
+
|
|
666
674
|
jsi::Object module = jsi::Object(rt);
|
|
667
675
|
|
|
668
676
|
module.setProperty(rt, "open", std::move(open));
|
|
@@ -682,6 +690,7 @@ void install(jsi::Runtime &rt,
|
|
|
682
690
|
module.setProperty(rt, "loadExtension", std::move(load_extension));
|
|
683
691
|
module.setProperty(rt, "executeRawAsync", std::move(execute_raw_async));
|
|
684
692
|
module.setProperty(rt, "getDbPath", std::move(get_db_path));
|
|
693
|
+
module.setProperty(rt, "isSQLCipher", std::move(is_sqlcipher));
|
|
685
694
|
|
|
686
695
|
rt.global().setProperty(rt, "__OPSQLiteProxy", std::move(module));
|
|
687
696
|
}
|
package/cpp/bridge.cpp
CHANGED
|
@@ -204,7 +204,7 @@ inline void opsqlite_bind_statement(sqlite3_stmt *statement,
|
|
|
204
204
|
} else if (std::holds_alternative<ArrayBuffer>(value)) {
|
|
205
205
|
ArrayBuffer buffer = std::get<ArrayBuffer>(value);
|
|
206
206
|
sqlite3_bind_blob(statement, sqIndex, buffer.data.get(), buffer.size,
|
|
207
|
-
|
|
207
|
+
SQLITE_TRANSIENT);
|
|
208
208
|
} else {
|
|
209
209
|
sqlite3_bind_null(statement, sqIndex);
|
|
210
210
|
}
|