@op-engineering/op-sqlite 14.1.3 → 15.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.
Files changed (47) hide show
  1. package/android/CMakeLists.txt +23 -62
  2. package/android/build.gradle +104 -164
  3. package/android/gradle.properties +5 -1
  4. package/android/jniLibs/arm64-v8a/libsql_experimental.a +0 -0
  5. package/android/jniLibs/armeabi-v7a/libsql_experimental.a +0 -0
  6. package/android/jniLibs/x86/libsql_experimental.a +0 -0
  7. package/android/jniLibs/x86_64/libsql_experimental.a +0 -0
  8. package/android/src/main/AndroidManifest.xml +2 -1
  9. package/cpp/DBHostObject.cpp +21 -2
  10. package/cpp/DBHostObject.h +2 -1
  11. package/cpp/bindings.cpp +7 -1
  12. package/cpp/libsql/bridge.cpp +3 -1
  13. package/cpp/libsql/bridge.h +2 -1
  14. package/cpp/libsql/libsql.h +1 -0
  15. package/cpp/sqlcipher/sqlite3.c +3091 -1643
  16. package/cpp/sqlcipher/sqlite3.h +188 -128
  17. package/cpp/sqlite3.c +304 -176
  18. package/cpp/sqlite3.h +89 -87
  19. package/ios/libsql.xcframework/Info.plist +5 -5
  20. package/ios/libsql.xcframework/ios-arm64/Headers/libsql.h +1 -0
  21. package/ios/libsql.xcframework/ios-arm64/libsql_experimental.a +0 -0
  22. package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h +1 -0
  23. package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a +0 -0
  24. package/lib/module/Storage.js +9 -2
  25. package/lib/module/Storage.js.map +1 -1
  26. package/lib/module/index.js +8 -3
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/package.json +1 -0
  29. package/lib/typescript/package.json +1 -0
  30. package/lib/typescript/src/Storage.d.ts +4 -0
  31. package/lib/typescript/src/Storage.d.ts.map +1 -1
  32. package/lib/typescript/src/index.d.ts +10 -2
  33. package/lib/typescript/src/index.d.ts.map +1 -1
  34. package/op-sqlite.podspec +2 -11
  35. package/package.json +48 -19
  36. package/src/Storage.ts +8 -1
  37. package/src/index.ts +14 -2
  38. package/android/.project +0 -17
  39. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  40. package/android/src/paper/java/com/op/sqlite/NativeOPSQLiteSpec.java +0 -77
  41. package/lib/commonjs/NativeOPSQLite.js +0 -9
  42. package/lib/commonjs/NativeOPSQLite.js.map +0 -1
  43. package/lib/commonjs/Storage.js +0 -60
  44. package/lib/commonjs/Storage.js.map +0 -1
  45. package/lib/commonjs/index.js +0 -387
  46. package/lib/commonjs/index.js.map +0 -1
  47. package/lib/commonjs/package.json +0 -1
@@ -72,72 +72,33 @@ if (USER_DEFINED_SOURCE_FILES)
72
72
  endif()
73
73
 
74
74
  if (USE_SQLCIPHER)
75
- if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
76
- target_link_libraries(
77
- ${PACKAGE_NAME}
78
- ${LOG_LIB}
79
- ReactAndroid::reactnative
80
- ReactAndroid::jsi
81
- fbjni::fbjni
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
- openssl::crypto
94
- )
95
- endif()
75
+ target_link_libraries(
76
+ ${PACKAGE_NAME}
77
+ ${LOG_LIB}
78
+ ReactAndroid::reactnative
79
+ ReactAndroid::jsi
80
+ fbjni::fbjni
81
+ openssl::crypto
82
+ )
96
83
  elseif (USE_LIBSQL)
97
84
  cmake_path(SET LIBSQL ${CMAKE_CURRENT_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libsql_experimental.a NORMALIZE)
98
85
  add_library(libsql STATIC IMPORTED)
99
86
  set_target_properties(libsql PROPERTIES IMPORTED_LOCATION ${LIBSQL})
100
87
 
101
- if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
102
- target_link_libraries(
103
- ${PACKAGE_NAME}
104
- ${LOG_LIB}
105
- ReactAndroid::reactnative
106
- ReactAndroid::jsi
107
- fbjni::fbjni
108
- libsql
109
- )
110
- else()
111
- target_link_libraries(
112
- ${PACKAGE_NAME}
113
- ${LOG_LIB}
114
- fbjni::fbjni
115
- ReactAndroid::jsi
116
- ReactAndroid::turbomodulejsijni
117
- ReactAndroid::react_nativemodule_core
118
- android
119
- libsql
120
- )
121
- endif()
88
+ target_link_libraries(
89
+ ${PACKAGE_NAME}
90
+ ${LOG_LIB}
91
+ ReactAndroid::reactnative
92
+ ReactAndroid::jsi
93
+ fbjni::fbjni
94
+ libsql
95
+ )
122
96
  else ()
123
- # if (REACTNATIVE_MERGED_SO)
124
- if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
125
- target_link_libraries(
126
- ${PACKAGE_NAME}
127
- ${LOG_LIB}
128
- ReactAndroid::reactnative
129
- ReactAndroid::jsi
130
- fbjni::fbjni
131
- )
132
- else()
133
- target_link_libraries(
134
- ${PACKAGE_NAME}
135
- ${LOG_LIB}
136
- fbjni::fbjni
137
- ReactAndroid::jsi
138
- ReactAndroid::turbomodulejsijni
139
- ReactAndroid::react_nativemodule_core
140
- android
141
- )
142
- endif()
97
+ target_link_libraries(
98
+ ${PACKAGE_NAME}
99
+ ${LOG_LIB}
100
+ ReactAndroid::reactnative
101
+ ReactAndroid::jsi
102
+ fbjni::fbjni
103
+ )
143
104
  endif()
@@ -2,29 +2,29 @@ import java.nio.file.Paths
2
2
  import groovy.json.JsonSlurper
3
3
 
4
4
  buildscript {
5
+ ext.getExtOrDefault = {name ->
6
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['OPSQLite_' + name]
7
+ }
8
+
5
9
  repositories {
6
10
  google()
7
- gradlePluginPortal()
11
+ mavenCentral()
8
12
  }
9
13
 
10
- def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["OPSQLite_kotlinVersion"]
11
-
12
14
  dependencies {
13
- classpath("com.android.tools.build:gradle:7.3.1")
15
+ classpath("com.android.tools.build:gradle:8.7.2")
14
16
  // noinspection DifferentKotlinGradleVersion
15
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
16
18
  }
17
19
  }
18
20
 
19
- def resolveBuildType() {
20
- Gradle gradle = getGradle()
21
- String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
21
+ apply plugin: "com.android.library"
22
+ apply plugin: "kotlin-android"
22
23
 
23
- return tskReqStr.contains('Release') ? 'release' : 'debug'
24
- }
24
+ apply plugin: "com.facebook.react"
25
25
 
26
- def isNewArchitectureEnabled() {
27
- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
26
+ def getExtOrIntegerDefault(name) {
27
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["OPSQLite_" + name]).toInteger()
28
28
  }
29
29
 
30
30
  def useSQLCipher = false
@@ -66,8 +66,7 @@ def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
66
66
  def opsqliteConfig = packageJson["op-sqlite"]
67
67
 
68
68
  if(opsqliteConfig) {
69
- println "[OP-SQLITE] Detected op-sqlite config from package.json at: " + packageJsonFile.absolutePath
70
-
69
+ println "[OP-SQLITE] Detected op-sqlite config from package.json at: " + packageJsonFile.absolutePath
71
70
  useSQLCipher = opsqliteConfig["sqlcipher"]
72
71
  useCRSQLite = opsqliteConfig["crsqlite"]
73
72
  useSqliteVec = opsqliteConfig["sqliteVec"]
@@ -80,12 +79,10 @@ println "[OP-SQLITE] Detected op-sqlite config from package.json at: " + package
80
79
  }
81
80
 
82
81
  if(useSQLCipher) {
83
- println "[OP-SQLITE] using SQLCipher 🔒"
82
+ println "[OP-SQLITE] using sqlcipher."
84
83
  } else if(useLibsql) {
85
- println "[OP-SQLITE] using libsql 📦"
86
- } else {
87
- println "[OP-SQLITE] using Vanilla SQLite"
88
- }
84
+ println "[OP-SQLITE] using libsql. Report any issues to Turso"
85
+ }
89
86
 
90
87
  if(useCRSQLite) {
91
88
  println "[OP-SQLITE] using CR-SQLite 🤖"
@@ -112,132 +109,98 @@ if (!tokenizers.isEmpty()) {
112
109
  println "[OP-SQLITE] Tokenizers enabled! 🧾 Tokenizers: " + tokenizers
113
110
  }
114
111
 
115
- if (isNewArchitectureEnabled()) {
116
- apply plugin: "com.facebook.react"
117
- }
118
-
119
- apply plugin: 'com.android.library'
120
- apply plugin: "kotlin-android"
112
+ android {
113
+ namespace "com.op.sqlite"
121
114
 
122
- def safeExtGet(prop, fallback) {
123
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
124
- }
115
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
125
116
 
126
- def getExtOrDefault(name) {
127
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["OPSQLite" + name]
128
- }
117
+ defaultConfig {
118
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
119
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
129
120
 
130
- def reactNativeArchitectures() {
131
- def value = project.getProperties().get("reactNativeArchitectures")
132
- return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
133
- }
121
+ externalNativeBuild {
122
+ cmake {
123
+ if(useSQLCipher) {
124
+ cFlags += "-DOP_SQLITE_USE_SQLCIPHER=1"
125
+ cppFlags += "-DOP_SQLITE_USE_SQLCIPHER=1"
126
+ }
127
+ if(useLibsql) {
128
+ cFlags += "-DOP_SQLITE_USE_LIBSQL=1"
129
+ cppFlags += "-DOP_SQLITE_USE_LIBSQL=1"
130
+ }
131
+ if(useCRSQLite) {
132
+ cFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
133
+ cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
134
+ }
135
+ if(performanceMode) {
136
+ 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"]
137
+ }
138
+ if(enableFTS5) {
139
+ cFlags += ["-DSQLITE_ENABLE_FTS5=1"]
140
+ }
141
+ if(enableRtree) {
142
+ cFlags += ["-DSQLITE_ENABLE_RTREE=1"]
143
+ }
144
+ if(useSqliteVec) {
145
+ cFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
146
+ cppFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
147
+ }
134
148
 
135
- android {
149
+ // This are zeroes because they will be passed as C flags, so they become falsy
150
+ def sourceFiles = 0
151
+ // def tokenizerInitStrings = 0
152
+ def tokenizersHeaderPath = 0
153
+ if (!tokenizers.isEmpty()) {
154
+ def sourceDir = isUserApp ? file("$rootDir/../../../c_sources") : file("$rootDir/../c_sources")
155
+ def destDir = file("$buildscript.sourceFile.parentFile/c_sources")
156
+ copy {
157
+ from sourceDir
158
+ into destDir
159
+ include "**/*.cpp", "**/*.h"
160
+ }
161
+ sourceFiles = fileTree(dir: destDir, include: ["**/*.cpp", "**/*.h"]).files.join(";")
162
+ tokenizersHeaderPath = "../c_sources/tokenizers.h"
163
+ }
136
164
 
137
- compileSdkVersion safeExtGet("compileSdkVersion", 35)
138
- namespace "com.op.sqlite"
139
- // Used to override the NDK path/version on internal CI or by allowing
140
- // users to customize the NDK path/version from their root project (e.g. for M1 support)
141
- if (rootProject.hasProperty("ndkPath")) {
142
- ndkPath rootProject.ext.ndkPath
143
- }
144
- if (rootProject.hasProperty("ndkVersion")) {
145
- ndkVersion rootProject.ext.ndkVersion
165
+ cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
166
+ arguments "-DANDROID_STL=c++_shared",
167
+ "-DSQLITE_FLAGS='$sqliteFlags'",
168
+ "-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}",
169
+ "-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}",
170
+ "-DUSE_LIBSQL=${useLibsql ? 1 : 0}",
171
+ "-DUSE_SQLITE_VEC=${useSqliteVec ? 1 : 0}",
172
+ "-DUSER_DEFINED_SOURCE_FILES=${sourceFiles}",
173
+ "-DUSER_DEFINED_TOKENIZERS_HEADER_PATH='${tokenizersHeaderPath}'",
174
+ "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
175
+ }
176
+ }
146
177
  }
147
178
 
148
179
  buildFeatures {
180
+ buildConfig true
149
181
  prefab true
150
182
  prefabPublishing true
151
183
  }
152
184
 
185
+ buildTypes {
186
+ release {
187
+ minifyEnabled false
188
+ }
189
+ }
190
+
153
191
  prefab {
154
192
  "op-sqlite" {
155
193
  headers "${project.buildDir}/headers/op-sqlite/"
156
194
  }
157
195
  }
158
196
 
159
- defaultConfig {
160
- minSdkVersion safeExtGet("minSdkVersion", 24)
161
- targetSdkVersion safeExtGet('targetSdkVersion', 35)
162
- versionCode 1
163
- versionName "1.0"
164
-
165
- externalNativeBuild {
166
- cmake {
167
- if(useSQLCipher) {
168
- cFlags += "-DOP_SQLITE_USE_SQLCIPHER=1"
169
- cppFlags += "-DOP_SQLITE_USE_SQLCIPHER=1"
170
- }
171
- if(useLibsql) {
172
- cFlags += "-DOP_SQLITE_USE_LIBSQL=1"
173
- cppFlags += "-DOP_SQLITE_USE_LIBSQL=1"
174
- }
175
- if(useCRSQLite) {
176
- cFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
177
- cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
178
- }
179
- if(performanceMode) {
180
- 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"]
181
- }
182
- if(enableFTS5) {
183
- cFlags += ["-DSQLITE_ENABLE_FTS5=1"]
184
- }
185
- if(enableRtree) {
186
- cFlags += ["-DSQLITE_ENABLE_RTREE=1"]
187
- }
188
- if(useSqliteVec) {
189
- cFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
190
- cppFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
191
- }
192
-
193
- // This are zeroes because they will be passed as C flags, so they become falsy
194
- def sourceFiles = 0
195
- // def tokenizerInitStrings = 0
196
- def tokenizersHeaderPath = 0
197
- if (!tokenizers.isEmpty()) {
198
- def sourceDir = isUserApp ? file("$rootDir/../../../c_sources") : file("$rootDir/../c_sources")
199
- def destDir = file("$buildscript.sourceFile.parentFile/c_sources")
200
- copy {
201
- from sourceDir
202
- into destDir
203
- include "**/*.cpp", "**/*.h"
204
- }
205
- sourceFiles = fileTree(dir: destDir, include: ["**/*.cpp", "**/*.h"]).files.join(";")
206
- tokenizersHeaderPath = "../c_sources/tokenizers.h"
207
- }
208
-
209
- cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
210
- abiFilters(*reactNativeArchitectures())
211
- arguments "-DANDROID_STL=c++_shared",
212
- "-DSQLITE_FLAGS='$sqliteFlags'",
213
- "-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}",
214
- "-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}",
215
- "-DUSE_LIBSQL=${useLibsql ? 1 : 0}",
216
- "-DUSE_SQLITE_VEC=${useSqliteVec ? 1 : 0}",
217
- "-DUSER_DEFINED_SOURCE_FILES=${sourceFiles}",
218
- "-DUSER_DEFINED_TOKENIZERS_HEADER_PATH='${tokenizersHeaderPath}'",
219
- "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
220
- }
221
- }
222
-
223
- packagingOptions {
224
- doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
225
- excludes = [
226
- "META-INF",
227
- "META-INF/**",
228
- "**/libjsi.so",
229
- "**/libreact_nativemodule_core.so",
230
- "**/libturbomodulejsijni.so",
231
- "**/libc++_shared.so",
232
- "**/libfbjni.so",
233
- "**/libreactnative.so",
234
- ]
235
- }
197
+ lintOptions {
198
+ disable "GradleCompatible"
236
199
  }
237
200
 
238
201
  compileOptions {
239
- sourceCompatibility JavaVersion.VERSION_17
240
- targetCompatibility JavaVersion.VERSION_17
202
+ sourceCompatibility JavaVersion.VERSION_1_8
203
+ targetCompatibility JavaVersion.VERSION_1_8
241
204
  }
242
205
 
243
206
  externalNativeBuild {
@@ -246,21 +209,20 @@ android {
246
209
  }
247
210
  }
248
211
 
249
- sourceSets.main {
250
- java {
251
- // TODO removed the codegen config to allow the package to be built under bridgeless
252
- // Once there is a stable API for C++ Turbo Modules, maybe this can be enabled again
253
- // if (!isNewArchitectureEnabled()) {
254
- srcDirs += 'src/paper/java'
255
- // }
256
- }
257
- jniLibs {
258
- srcDirs = []
259
- if (useCRSQLite) {
260
- srcDirs += 'src/main/libcrsqlite'
261
- }
262
- if (useSqliteVec) {
263
- srcDirs += 'src/main/libsqlitevec'
212
+ sourceSets {
213
+ main {
214
+ java.srcDirs += [
215
+ "generated/java",
216
+ "generated/jni"
217
+ ]
218
+ jniLibs {
219
+ srcDirs = []
220
+ if (useCRSQLite) {
221
+ srcDirs += 'src/main/libcrsqlite'
222
+ }
223
+ if (useSqliteVec) {
224
+ srcDirs += 'src/main/libsqlitevec'
225
+ }
264
226
  }
265
227
  }
266
228
  }
@@ -272,11 +234,12 @@ repositories {
272
234
  }
273
235
 
274
236
  def kotlin_version = getExtOrDefault("kotlinVersion")
237
+
275
238
  dependencies {
276
- implementation 'com.facebook.react:react-native'
239
+ implementation "com.facebook.react:react-android"
277
240
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
278
241
  if (useSQLCipher) {
279
- implementation('io.github.ronickg:openssl:3.3.2')
242
+ implementation('io.github.ronickg:openssl:3.3.2-1')
280
243
  }
281
244
  }
282
245
 
@@ -288,26 +251,3 @@ tasks.register('prepareHeaders', Copy) {
288
251
  }
289
252
 
290
253
  preBuild.dependsOn(prepareHeaders)
291
-
292
- // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
293
- tasks.configureEach { task ->
294
- if (task.name.contains("configureCMakeDebug")) {
295
- rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach {
296
- task.dependsOn(it)
297
- }
298
- }
299
- // We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo
300
- if (task.name.contains("configureCMakeRel")) {
301
- rootProject.getTasksByName("packageReactNdkReleaseLibs", true).forEach {
302
- task.dependsOn(it)
303
- }
304
- }
305
- }
306
-
307
- if (isNewArchitectureEnabled()) {
308
- react {
309
- jsRootDir = file("../src/")
310
- libraryName = "opsqlite"
311
- codegenJavaPackageName = "com.op.sqlite.example"
312
- }
313
- }
@@ -1 +1,5 @@
1
- OPSQLite_kotlinVersion=2.0.21
1
+ OPSQLite_kotlinVersion=2.0.21
2
+ OPSQLite_minSdkVersion=24
3
+ OPSQLite_targetSdkVersion=34
4
+ OPSQLite_compileSdkVersion=35
5
+ OPSQLite_ndkVersion=27.1.12297006
@@ -1 +1,2 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -157,13 +157,15 @@ DBHostObject::DBHostObject(jsi::Runtime &rt,
157
157
  std::string &db_name, std::string &path,
158
158
  std::string &url, std::string &auth_token,
159
159
  int sync_interval, bool offline,
160
- std::string &encryption_key)
160
+ std::string &encryption_key,
161
+ std::string &remote_encryption_key)
161
162
  : db_name(db_name), invoker(std::move(invoker)), rt(rt) {
162
163
 
163
164
  _thread_pool = std::make_shared<ThreadPool>();
164
165
 
165
166
  db = opsqlite_libsql_open_sync(db_name, path, url, auth_token,
166
- sync_interval, offline, encryption_key);
167
+ sync_interval, offline, encryption_key,
168
+ remote_encryption_key);
167
169
 
168
170
  create_jsi_functions();
169
171
  }
@@ -359,6 +361,23 @@ void DBHostObject::create_jsi_functions() {
359
361
 
360
362
  return create_js_rows(rt, status);
361
363
  });
364
+
365
+ function_map["executeRawSync"] = HOSTFN("executeRawSync") {
366
+ const std::string query = args[0].asString(rt).utf8(rt);
367
+ std::vector<JSVariant> params = count == 2 && args[1].isObject()
368
+ ? to_variant_vec(rt, args[1])
369
+ : std::vector<JSVariant>();
370
+
371
+ std::vector<std::vector<JSVariant>> results;
372
+
373
+ #ifdef OP_SQLITE_USE_LIBSQL
374
+ auto status = opsqlite_libsql_execute_raw(db, query, &params, &results);
375
+ #else
376
+ auto status = opsqlite_execute_raw(db, query, &params, &results);
377
+ #endif
378
+
379
+ return create_raw_result(rt, status, &results);
380
+ });
362
381
 
363
382
  function_map["execute"] = HOSTFN("execute") {
364
383
  const std::string query = args[0].asString(rt).utf8(rt);
@@ -59,7 +59,8 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject {
59
59
  DBHostObject(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
60
60
  std::string &db_name, std::string &path, std::string &url,
61
61
  std::string &auth_token, int sync_interval, bool offline,
62
- std::string &encryption_key);
62
+ std::string &encryption_key,
63
+ std::string &remote_encryption_key);
63
64
  #endif
64
65
 
65
66
  std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
package/cpp/bindings.cpp CHANGED
@@ -150,6 +150,12 @@ void install(jsi::Runtime &rt,
150
150
  options.getProperty(rt, "encryptionKey").asString(rt).utf8(rt);
151
151
  }
152
152
 
153
+ std::string remote_encryption_key;
154
+ if (options.hasProperty(rt, "remoteEncryptionKey")) {
155
+ encryption_key =
156
+ options.getProperty(rt, "remoteEncryptionKey").asString(rt).utf8(rt);
157
+ }
158
+
153
159
  std::string location;
154
160
  if (options.hasProperty(rt, "location")) {
155
161
  location =
@@ -166,7 +172,7 @@ void install(jsi::Runtime &rt,
166
172
  }
167
173
 
168
174
  std::shared_ptr<DBHostObject> db = std::make_shared<DBHostObject>(
169
- rt, invoker, name, path, url, auth_token, sync_interval, offline, encryption_key);
175
+ rt, invoker, name, path, url, auth_token, sync_interval, offline, encryption_key, remote_encryption_key);
170
176
  return jsi::Object::createFromHostObject(rt, db);
171
177
  });
172
178
  #endif
@@ -40,7 +40,8 @@ DB opsqlite_libsql_open_sync(std::string const &name,
40
40
  std::string const &base_path,
41
41
  std::string const &url,
42
42
  std::string const &auth_token, int sync_interval,
43
- bool offline, std::string const &encryption_key) {
43
+ bool offline, std::string const &encryption_key,
44
+ std::string const &remote_encryption_key) {
44
45
  std::string path = opsqlite_get_db_path(name, base_path);
45
46
 
46
47
  int status;
@@ -53,6 +54,7 @@ DB opsqlite_libsql_open_sync(std::string const &name,
53
54
  .auth_token = auth_token.c_str(),
54
55
  .read_your_writes = '1',
55
56
  .encryption_key = encryption_key.c_str(),
57
+ .remote_encryption_key = remote_encryption_key.c_str(),
56
58
  .sync_interval = sync_interval,
57
59
  .with_webpki = '1',
58
60
  .offline = offline};
@@ -41,7 +41,8 @@ DB opsqlite_libsql_open_remote(std::string const &url,
41
41
  DB opsqlite_libsql_open_sync(std::string const &name, std::string const &path,
42
42
  std::string const &url,
43
43
  std::string const &auth_token, int sync_interval,
44
- bool offline, std::string const &encryption_key);
44
+ bool offline, std::string const &encryption_key,
45
+ std::string const &remote_encryption_key);
45
46
 
46
47
  void opsqlite_libsql_close(DB &db);
47
48
 
@@ -41,6 +41,7 @@ typedef struct {
41
41
  int sync_interval;
42
42
  char with_webpki;
43
43
  char offline;
44
+ const char *remote_encryption_key;
44
45
  } libsql_config;
45
46
 
46
47
  typedef const libsql_connection *libsql_connection_t;