@op-engineering/op-sqlite 3.0.7 → 5.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 (40) hide show
  1. package/android/CMakeLists.txt +9 -4
  2. package/android/build.gradle +44 -17
  3. package/android/cpp-adapter.cpp +5 -1
  4. package/android/gradle.properties +1 -1
  5. package/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt +3 -1
  6. package/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt +23 -19
  7. package/android/src/main/java/com/op/sqlite/OPSQLitePackage.kt +10 -23
  8. package/android/src/main/jniLibs/arm64-v8a/libcrsqlite.so +0 -0
  9. package/android/src/main/jniLibs/armeabi-v7a/libcrsqlite.so +0 -0
  10. package/android/src/main/jniLibs/x86/libcrsqlite.so +0 -0
  11. package/android/src/main/jniLibs/x86_64/libcrsqlite.so +0 -0
  12. package/cpp/DumbHostObject.cpp +1 -0
  13. package/cpp/bindings.cpp +7 -3
  14. package/cpp/bindings.h +1 -1
  15. package/cpp/bridge.cpp +32 -3
  16. package/cpp/bridge.h +3 -2
  17. package/ios/OPSQLite.h +8 -8
  18. package/ios/OPSQLite.mm +89 -70
  19. package/ios/crsqlite.xcframework/Info.plist +40 -0
  20. package/ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/Info.plist +18 -0
  21. package/ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/crsqlite +0 -0
  22. package/ios/crsqlite.xcframework/ios-arm64_x86_64-simulator/crsqlite.framework/Info.plist +18 -0
  23. package/ios/crsqlite.xcframework/ios-arm64_x86_64-simulator/crsqlite.framework/crsqlite +0 -0
  24. package/lib/commonjs/NativeOPSQLite.js +1 -2
  25. package/lib/commonjs/NativeOPSQLite.js.map +1 -1
  26. package/lib/commonjs/index.js +33 -15
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/module/NativeOPSQLite.js.map +1 -1
  29. package/lib/module/index.js +31 -12
  30. package/lib/module/index.js.map +1 -1
  31. package/lib/typescript/{NativeOPSQLite.d.ts → src/NativeOPSQLite.d.ts} +1 -1
  32. package/lib/typescript/src/NativeOPSQLite.d.ts.map +1 -0
  33. package/lib/typescript/src/index.d.ts.map +1 -0
  34. package/op-sqlite.podspec +53 -11
  35. package/package.json +4 -11
  36. package/src/NativeOPSQLite.ts +1 -1
  37. package/src/index.ts +16 -20
  38. package/lib/typescript/NativeOPSQLite.d.ts.map +0 -1
  39. package/lib/typescript/index.d.ts.map +0 -1
  40. /package/lib/typescript/{index.d.ts → src/index.d.ts} +0 -0
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.9.0)
3
3
 
4
4
  set (PACKAGE_NAME "op-sqlite")
5
5
  set (CMAKE_VERBOSE_MAKEFILE ON)
6
- set (CMAKE_CXX_STANDARD 17)
6
+ set (CMAKE_CXX_STANDARD 20)
7
7
  set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
8
8
 
9
9
  include_directories(
@@ -43,7 +43,7 @@ if (OP_SQLITE_USE_SQLCIPHER)
43
43
  target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlcipher/sqlite3.h ../cpp/sqlcipher/sqlite3.c)
44
44
 
45
45
  add_definitions(
46
- -DOP_SQLITE_USE_SQLCIPHER
46
+ -DOP_SQLITE_USE_SQLCIPHER=1
47
47
  -DSQLITE_HAS_CODEC
48
48
  -DSQLITE_TEMP_STORE=2
49
49
  )
@@ -53,9 +53,15 @@ else()
53
53
  target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.h ../cpp/sqlite3.c)
54
54
  endif()
55
55
 
56
+ if (OP_SQLITE_USE_CRSQLITE)
57
+ add_definitions(
58
+ -DOP_SQLITE_USE_CRSQLITE=1
59
+ )
60
+ endif()
61
+
56
62
  set_target_properties(
57
63
  ${PACKAGE_NAME} PROPERTIES
58
- CXX_STANDARD 17
64
+ CXX_STANDARD 20
59
65
  CXX_EXTENSIONS OFF
60
66
  POSITION_INDEPENDENT_CODE ON
61
67
  )
@@ -64,7 +70,6 @@ find_package(ReactAndroid REQUIRED CONFIG)
64
70
  find_package(fbjni REQUIRED CONFIG)
65
71
  find_library(LOG_LIB log)
66
72
 
67
-
68
73
  target_link_libraries(
69
74
  ${PACKAGE_NAME}
70
75
  ${LOG_LIB}
@@ -1,4 +1,5 @@
1
1
  import java.nio.file.Paths
2
+ import groovy.json.JsonSlurper
2
3
 
3
4
  buildscript {
4
5
  repositories {
@@ -26,7 +27,39 @@ def isNewArchitectureEnabled() {
26
27
  return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
27
28
  }
28
29
 
29
- def SQLITE_FLAGS = rootProject.properties['OPSQLiteFlags']
30
+ def useSQLCipher = false
31
+ def useCRSQLite = false
32
+ def performanceMode = "0"
33
+ def sqliteFlags = ""
34
+
35
+ def packageJsonFile = new File("$rootDir/../package.json")
36
+ def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
37
+
38
+ def opsqliteConfig = packageJson["op-sqlite"]
39
+ if(opsqliteConfig) {
40
+ useSQLCipher = opsqliteConfig["sqlcipher"]
41
+ useCRSQLite = opsqliteConfig["crsqlite"]
42
+ performanceMode = opsqliteConfig["performanceMode"] ? opsqliteConfig["performanceMode"] : ""
43
+ sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
44
+ }
45
+
46
+ if(useSQLCipher) {
47
+ println "[OP-SQLITE] using SQLCipher 🔒"
48
+ } else {
49
+ println "[OP-SQLITE] using Vanilla SQLite"
50
+ }
51
+
52
+ if(useCRSQLite) {
53
+ println "[OP-SQLITE] using CR-SQLite 🤖"
54
+ }
55
+
56
+ if(performanceMode == "1") {
57
+ println "[OP-SQLITE] Thread unsafe performance mode enabled. Use only transactions! 🚀"
58
+ }
59
+
60
+ if(performanceMode == "2") {
61
+ println "[OP-SQLITE] Thread safe performance mode enabled! 🚀"
62
+ }
30
63
 
31
64
  if (isNewArchitectureEnabled()) {
32
65
  apply plugin: "com.facebook.react"
@@ -48,8 +81,6 @@ def getExtOrDefault(name) {
48
81
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["OPSQLite" + name]
49
82
  }
50
83
 
51
- def USE_HERMES = rootProject.ext.hermesEnabled
52
-
53
84
  android {
54
85
 
55
86
  compileSdkVersion safeExtGet("compileSdkVersion", 33)
@@ -69,32 +100,26 @@ android {
69
100
  }
70
101
 
71
102
  defaultConfig {
72
- minSdkVersion 21
103
+ minSdkVersion 23
73
104
  targetSdkVersion safeExtGet('targetSdkVersion', 34)
74
105
  versionCode 1
75
106
  versionName "1.0"
76
107
 
77
108
  externalNativeBuild {
78
109
  cmake {
79
- if(System.getenv("OP_SQLITE_PERF") == '1') {
80
- println "OP-SQLITE performance mode enabled! 🚀"
110
+ if(performanceMode == '1') {
81
111
  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"]
82
112
  }
83
- if(System.getenv("OP_SQLITE_PERF") == '2') {
84
- println "OP-SQLITE (thread safe) performance mode enabled! 🚀"
113
+ if(performanceMode == '2') {
85
114
  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"]
86
115
  }
87
116
 
88
- if(System.getenv("OP_SQLITE_USE_SQLCIPHER") == '1') {
89
- println "OP-SQLITE using SQLCipher! 🔒"
90
- cFlags += "-DOP_SQLITE_USE_SQLCIPHER=1"
91
- }
92
-
93
117
  cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
94
118
  abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
95
119
  arguments "-DANDROID_STL=c++_shared",
96
- "-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'"
97
- "-DOP_SQLITE_USE_SQLCIPHER='${System.getenv("OP_SQLITE_USE_SQLCIPHER") == '1'? 1 : 0}'"
120
+ "-DSQLITE_FLAGS='$sqliteFlags'"
121
+ "-DOP_SQLITE_USE_SQLCIPHER='${useSQLCipher? 1 : 0}'"
122
+ "-DOP_SQLITE_USE_CRSQLITE='${useCRSQLite? 1 : 0}'"
98
123
  abiFilters (*reactNativeArchitectures())
99
124
  }
100
125
  }
@@ -127,9 +152,11 @@ android {
127
152
 
128
153
  sourceSets.main {
129
154
  java {
130
- if (!isNewArchitectureEnabled()) {
155
+ // TODO removed the codegen config to allow the package to be built under bridgeless
156
+ // Once there is a stable API for C++ Turbo Modules, maybe this can be enabled again
157
+ // if (!isNewArchitectureEnabled()) {
131
158
  srcDirs += 'src/paper/java'
132
- }
159
+ // }
133
160
  }
134
161
  }
135
162
  }
@@ -6,6 +6,9 @@
6
6
  #include <jsi/jsi.h>
7
7
  #include <typeinfo>
8
8
 
9
+ // This file is not using raw jni but rather fbjni, do not change how the native
10
+ // functions are registered
11
+ // https://github.com/facebookincubator/fbjni/blob/main/docs/quickref.md
9
12
  struct OPSQLiteBridge : jni::JavaClass<OPSQLiteBridge> {
10
13
  static constexpr auto kJavaDescriptor = "Lcom/op/sqlite/OPSQLiteBridge;";
11
14
 
@@ -25,7 +28,8 @@ private:
25
28
  auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
26
29
  std::string dbPathStr = dbPath->toStdString();
27
30
 
28
- opsqlite::install(*jsiRuntime, jsCallInvoker, dbPathStr.c_str());
31
+ opsqlite::install(*jsiRuntime, jsCallInvoker, dbPathStr.c_str(),
32
+ "libcrsqlite");
29
33
  }
30
34
 
31
35
  static void clearStateNativeJsi(jni::alias_ref<jni::JObject> thiz) {
@@ -1 +1 @@
1
- OPSQLite_kotlinVersion=1.8.0
1
+ OPSQLite_kotlinVersion=1.9.22
@@ -2,15 +2,17 @@ package com.op.sqlite
2
2
 
3
3
  import com.facebook.react.bridge.ReactContext
4
4
  import com.facebook.react.turbomodule.core.CallInvokerHolderImpl
5
+ import com.facebook.react.common.annotations.FrameworkAPI
5
6
 
7
+ @OptIn(FrameworkAPI::class)
6
8
  class OPSQLiteBridge {
7
9
  private external fun installNativeJsi(
8
10
  jsContextNativePointer: Long,
9
11
  jsCallInvokerHolder: CallInvokerHolderImpl,
10
12
  docPath: String
11
13
  )
12
-
13
14
  private external fun clearStateNativeJsi()
15
+
14
16
  fun install(context: ReactContext) {
15
17
  val jsContextPointer = context.javaScriptContextHolder!!.get()
16
18
  val jsCallInvokerHolder =
@@ -1,27 +1,27 @@
1
1
  package com.op.sqlite
2
2
 
3
+ import android.util.Log
3
4
  import com.facebook.react.bridge.ReactApplicationContext
4
5
  import com.facebook.react.bridge.ReactMethod
5
- import com.facebook.react.module.annotations.ReactModule;
6
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
6
7
  import java.io.File
7
8
  import java.io.FileOutputStream
8
9
  import java.io.InputStream
9
10
  import java.io.OutputStream
10
11
 
11
- @ReactModule(name = OPSQLiteModule.NAME)
12
- internal class OPSQLiteModule(context: ReactApplicationContext?) :
13
- NativeOPSQLiteSpec(context) {
12
+ //@ReactModule(name = OPSQLiteModule.NAME)
13
+ internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
14
14
  override fun getName(): String {
15
15
  return NAME
16
16
  }
17
17
 
18
- override fun getTypedExportedConstants(): MutableMap<String, Any> {
18
+ fun getTypedExportedConstants(): MutableMap<String, Any> {
19
19
  val constants: MutableMap<String, Any> = HashMap()
20
20
  val context = reactApplicationContext
21
- val dbPath = context
22
- .getDatabasePath("defaultDatabase")
23
- .absolutePath
24
- .replace("defaultDatabase", "")
21
+ val dbPath =
22
+ context.getDatabasePath("defaultDatabase")
23
+ .absolutePath
24
+ .replace("defaultDatabase", "")
25
25
  constants["ANDROID_DATABASE_PATH"] = dbPath
26
26
  val filesPath = context.filesDir.absolutePath
27
27
  constants["ANDROID_FILES_PATH"] = filesPath
@@ -32,32 +32,35 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) :
32
32
  return constants
33
33
  }
34
34
 
35
+ override fun getConstants(): MutableMap<String, Any>? {
36
+ return getTypedExportedConstants()
37
+ }
38
+
35
39
  @ReactMethod(isBlockingSynchronousMethod = true)
36
- override fun install(): Boolean {
40
+ fun install(): Boolean {
37
41
  return try {
38
42
  OPSQLiteBridge.instance.install(reactApplicationContext)
39
43
  true
40
44
  } catch (exception: Exception) {
45
+ Log.e(NAME, "Install exception: $exception")
41
46
  false
42
47
  }
43
48
  }
44
49
 
45
50
  @ReactMethod(isBlockingSynchronousMethod = true)
46
- override fun moveAssetsDatabase(name: String, extension: String): Boolean {
51
+ fun moveAssetsDatabase(name: String, extension: String): Boolean {
47
52
  val context = reactApplicationContext
48
53
  val assetsManager = context.assets
49
54
 
50
55
  try {
51
-
52
- // val assets = assetsManager.list("");
53
56
  // Open the input stream for the asset file
54
57
  val inputStream: InputStream = assetsManager.open("custom/$name.$extension")
55
58
 
56
59
  // Create the output file in the documents directory
57
- val databasesFolder = context
58
- .getDatabasePath("defaultDatabase")
59
- .absolutePath
60
- .replace("defaultDatabase", "")
60
+ val databasesFolder =
61
+ context.getDatabasePath("defaultDatabase")
62
+ .absolutePath
63
+ .replace("defaultDatabase", "")
61
64
 
62
65
  val outputFile = File(databasesFolder, "$name.$extension")
63
66
 
@@ -85,7 +88,8 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) :
85
88
  }
86
89
  }
87
90
 
88
- override fun onCatalystInstanceDestroy() {
91
+ override fun invalidate() {
92
+ super.invalidate()
89
93
  OPSQLiteBridge.instance.clearState()
90
94
  }
91
95
 
@@ -96,4 +100,4 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) :
96
100
 
97
101
  const val NAME = "OPSQLite"
98
102
  }
99
- }
103
+ }
@@ -1,31 +1,18 @@
1
1
  package com.op.sqlite
2
2
 
3
- import com.facebook.react.TurboReactPackage
3
+ import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.module.model.ReactModuleInfoProvider
7
- import com.facebook.react.module.model.ReactModuleInfo
6
+ import com.facebook.react.uimanager.ViewManager
8
7
 
9
- class OPSQLitePackage : TurboReactPackage() {
10
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
11
- if(name == OPSQLiteModule.NAME) {
12
- return OPSQLiteModule(reactContext)
13
- } else {
14
- return null
15
- }
8
+ class OPSQLitePackage : ReactPackage {
9
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
+ return listOf<NativeModule>(OPSQLiteModule(reactContext))
16
11
  }
17
12
 
18
- override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
19
- mapOf(
20
- OPSQLiteModule.NAME to ReactModuleInfo(
21
- OPSQLiteModule.NAME,
22
- OPSQLiteModule.NAME,
23
- false, // canOverrideExistingModule
24
- false, // needsEagerInit
25
- true, // hasConstants
26
- false, // isCxxModule
27
- true // isTurboModule
28
- )
29
- )
13
+ override fun createViewManagers(
14
+ reactContext: ReactApplicationContext
15
+ ): List<ViewManager<*, *>> {
16
+ return emptyList()
30
17
  }
31
- }
18
+ }
@@ -27,6 +27,7 @@ DumbHostObject::getPropertyNames(jsi::Runtime &rt) {
27
27
 
28
28
  jsi::Value DumbHostObject::get(jsi::Runtime &rt,
29
29
  const jsi::PropNameID &propNameID) {
30
+
30
31
  auto name = propNameID.utf8(rt);
31
32
  auto fields = metadata.get();
32
33
  for (int i = 0; i < fields->size(); i++) {
package/cpp/bindings.cpp CHANGED
@@ -17,6 +17,7 @@ namespace opsqlite {
17
17
  namespace jsi = facebook::jsi;
18
18
 
19
19
  std::string basePath;
20
+ std::string crsqlitePath;
20
21
  std::shared_ptr<react::CallInvoker> invoker;
21
22
  ThreadPool pool;
22
23
  std::unordered_map<std::string, std::shared_ptr<jsi::Value>> updateHooks =
@@ -44,9 +45,11 @@ void clearState() {
44
45
 
45
46
  void install(jsi::Runtime &rt,
46
47
  std::shared_ptr<react::CallInvoker> jsCallInvoker,
47
- const char *docPath) {
48
+ const char *docPath, const char *_crsqlitePath) {
49
+
48
50
  invalidated = false;
49
51
  basePath = std::string(docPath);
52
+ crsqlitePath = std::string(_crsqlitePath);
50
53
  invoker = jsCallInvoker;
51
54
 
52
55
  auto open = HOSTFN("open", 3) {
@@ -94,9 +97,10 @@ void install(jsi::Runtime &rt,
94
97
  }
95
98
 
96
99
  #ifdef OP_SQLITE_USE_SQLCIPHER
97
- BridgeResult result = opsqlite_open(dbName, path, encryptionKey);
100
+ BridgeResult result =
101
+ opsqlite_open(dbName, path, crsqlitePath, encryptionKey);
98
102
  #else
99
- BridgeResult result = opsqlite_open(dbName, path);
103
+ BridgeResult result = opsqlite_open(dbName, path, crsqlitePath);
100
104
  #endif
101
105
 
102
106
  if (result.type == SQLiteError) {
package/cpp/bindings.h CHANGED
@@ -8,7 +8,7 @@ namespace opsqlite {
8
8
 
9
9
  void install(jsi::Runtime &rt,
10
10
  std::shared_ptr<react::CallInvoker> jsCallInvoker,
11
- const char *docPath);
11
+ const char *docPath, const char *crsqlitePath);
12
12
  void clearState();
13
13
 
14
14
  } // namespace opsqlite
package/cpp/bridge.cpp CHANGED
@@ -3,6 +3,7 @@
3
3
  #include "SmartHostObject.h"
4
4
  #include "logs.h"
5
5
  #include "utils.h"
6
+ #include <iostream>
6
7
  #include <unordered_map>
7
8
  #include <variant>
8
9
 
@@ -11,6 +12,7 @@ namespace opsqlite {
11
12
  /// Maps to hold the different objects
12
13
  std::unordered_map<std::string, sqlite3 *> dbMap =
13
14
  std::unordered_map<std::string, sqlite3 *>();
15
+
14
16
  std::unordered_map<std::string, UpdateCallback> updateCallbackMap =
15
17
  std::unordered_map<std::string, UpdateCallback>();
16
18
 
@@ -26,7 +28,12 @@ inline void check_db_open(std::string const &db_name) {
26
28
  }
27
29
  }
28
30
 
29
- /// Start of api
31
+ // _____ _____
32
+ // /\ | __ \_ _|
33
+ // / \ | |__) || |
34
+ // / /\ \ | ___/ | |
35
+ // / ____ \| | _| |_
36
+ // /_/ \_\_| |_____|
30
37
 
31
38
  /// Returns the completely formed db path, but it also creates any sub-folders
32
39
  /// along the way
@@ -44,10 +51,12 @@ std::string opsqlite_get_db_path(std::string const &db_name,
44
51
  #ifdef OP_SQLITE_USE_SQLCIPHER
45
52
  BridgeResult opsqlite_open(std::string const &dbName,
46
53
  std::string const &last_path,
54
+ std::string const &crsqlitePath,
47
55
  std::string const &encryptionKey) {
48
56
  #else
49
57
  BridgeResult opsqlite_open(std::string const &dbName,
50
- std::string const &last_path) {
58
+ std::string const &last_path,
59
+ std::string const &crsqlitePath) {
51
60
  #endif
52
61
  std::string dbPath = opsqlite_get_db_path(dbName, last_path);
53
62
 
@@ -69,7 +78,22 @@ BridgeResult opsqlite_open(std::string const &dbName,
69
78
  nullptr, nullptr);
70
79
  #endif
71
80
 
72
- return BridgeResult{.type = SQLiteOk, .affectedRows = 0};
81
+ #ifdef OP_SQLITE_USE_CRSQLITE
82
+ char *errMsg;
83
+ const char *crsqliteEntryPoint = "sqlite3_crsqlite_init";
84
+
85
+ sqlite3_enable_load_extension(db, 1);
86
+
87
+ sqlite3_load_extension(db, crsqlitePath.c_str(), crsqliteEntryPoint, &errMsg);
88
+
89
+ if (errMsg != nullptr) {
90
+ return {.type = SQLiteError, .message = errMsg};
91
+ } else {
92
+ LOGI("Loaded CRSQlite successfully");
93
+ }
94
+ #endif
95
+
96
+ return {.type = SQLiteOk, .affectedRows = 0};
73
97
  }
74
98
 
75
99
  BridgeResult opsqlite_close(std::string const &dbName) {
@@ -78,6 +102,11 @@ BridgeResult opsqlite_close(std::string const &dbName) {
78
102
 
79
103
  sqlite3 *db = dbMap[dbName];
80
104
 
105
+ #ifdef OP_SQLITE_USE_CRSQLITE
106
+ opsqlite_execute(dbName, "select crsql_finalize();", nullptr, nullptr,
107
+ nullptr);
108
+ #endif
109
+
81
110
  sqlite3_close_v2(db);
82
111
 
83
112
  dbMap.erase(dbName);
package/cpp/bridge.h CHANGED
@@ -24,10 +24,11 @@ std::string opsqlite_get_db_path(std::string const &db_name,
24
24
 
25
25
  #ifdef OP_SQLITE_USE_SQLCIPHER
26
26
  BridgeResult opsqlite_open(std::string const &dbName, std::string const &dbPath,
27
+ std::string const &crsqlitePath,
27
28
  std::string const &encryptionKey);
28
29
  #else
29
- BridgeResult opsqlite_open(std::string const &dbName,
30
- std::string const &dbPath);
30
+ BridgeResult opsqlite_open(std::string const &dbName, std::string const &dbPath,
31
+ std::string const &crsqlitePath);
31
32
  #endif
32
33
 
33
34
  BridgeResult opsqlite_close(std::string const &dbName);
package/ios/OPSQLite.h CHANGED
@@ -1,15 +1,15 @@
1
- #ifdef RCT_NEW_ARCH_ENABLED
2
- #import <OPSQLiteSpec/OPSQLiteSpec.h>
3
- #else
1
+ // #ifdef RCT_NEW_ARCH_ENABLED
2
+ // #import <OPSQLiteSpec/OPSQLiteSpec.h>
3
+ // #else
4
4
  #import <React/RCTBridge.h>
5
- #endif
5
+ // #endif
6
6
 
7
7
  @interface OPSQLite : NSObject
8
- #ifdef RCT_NEW_ARCH_ENABLED
9
- <NativeOPSQLiteSpec>
10
- #else
8
+ // #ifdef RCT_NEW_ARCH_ENABLED
9
+ // <NativeOPSQLiteSpec>
10
+ // #else
11
11
  <RCTBridgeModule>
12
- #endif
12
+ // #endif
13
13
 
14
14
  @property(nonatomic, assign) BOOL setBridgeOnMainQueue;
15
15