11diff --git a/node_modules/@op-engineering/op-sqlite/android/build.gradle b/node_modules/@op-engineering/op-sqlite/android/build.gradle
2- index 70ebca0..5da8659 100644
2+ index d36fd85..7513556 100644
33--- a/node_modules/@op-engineering/op-sqlite/android/build.gradle
44+++ b/node_modules/@op-engineering/op-sqlite/android/build.gradle
55@@ -1,5 +1,4 @@
66 import java.nio.file.Paths
77- import groovy.json.JsonSlurper
88
99 buildscript {
10- repositories {
11- @@ -27,10 +26,10 @@ def isNewArchitectureEnabled( ) {
12- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
10+ ext.getExtOrDefault = {name ->
11+ @@ -27,57 +26,16 @@ def getExtOrIntegerDefault(name ) {
12+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["OPSQLite_" + name]).toInteger()
1313 }
1414
1515- def useSQLCipher = false
@@ -21,22 +21,39 @@ index 70ebca0..5da8659 100644
2121 def sqliteFlags = ""
2222 def enableFTS5 = false
2323 def useSqliteVec = false
24- @@ -38,28 +37,6 @@ def enableRtree = false
24+ def enableRtree = false
2525 def tokenizers = []
2626
27- def isInsideNodeModules = rootDir.absolutePath.contains("node_modules")
28- - def packageJson
27+ - // On the example app, the package.json is located at the root of the project
28+ - // On the user app, the package.json is located at the root of the node_modules directory
29+ - def isUserApp = rootDir.absolutePath.contains("node_modules")
30+ - def packageJsonFile
2931-
30- - if ( isInsideNodeModules ) {
31- - def packageJsonFile = new File("$rootDir/../../../package.json")
32- - packageJson = new JsonSlurper().parseText(packageJsonFile.text)
32+ - if (isUserApp) {
33+ - // Start from the root + 1 level up (to avoid detecting the op-sqlite/package.json) and traverse upwards to find the first package.json
34+ - File currentDir = new File("$rootDir/../")
35+ - packageJsonFile = null
36+ -
37+ - // Try to find package.json by traversing upwards
38+ - while (currentDir != null) {
39+ - File potential = new File(currentDir, "package.json")
40+ - if (potential.exists()) {
41+ - packageJsonFile = potential
42+ - break
43+ - }
44+ - currentDir = currentDir.parentFile
45+ - }
3346- } else {
34- - def packageJsonFile = new File("$rootDir/../package.json")
35- - packageJson = new JsonSlurper().parseText(packageJsonFile.text)
47+ - packageJsonFile = new File("$rootDir/../package.json")
3648- }
3749-
50+ -
51+ - def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
52+ -
3853- def opsqliteConfig = packageJson["op-sqlite"]
54+ -
3955- if(opsqliteConfig) {
56+ - println "[OP-SQLITE] Detected op-sqlite config from package.json at: " + packageJsonFile.absolutePath
4057- useSQLCipher = opsqliteConfig["sqlcipher"]
4158- useCRSQLite = opsqliteConfig["crsqlite"]
4259- useSqliteVec = opsqliteConfig["sqliteVec"]
@@ -47,11 +64,12 @@ index 70ebca0..5da8659 100644
4764- enableRtree = opsqliteConfig["rtree"]
4865- tokenizers = opsqliteConfig["tokenizers"] ? opsqliteConfig["tokenizers"] : []
4966- }
50-
67+ -
5168 if(useSQLCipher) {
52- println "[OP-SQLITE] using SQLCipher 🔒"
69+ println "[OP-SQLITE] using sqlcipher."
70+ } else if(useLibsql) {
5371diff --git a/node_modules/@op-engineering/op-sqlite/android/cpp-adapter.cpp b/node_modules/@op-engineering/op-sqlite/android/cpp-adapter.cpp
54- index 8feaf77..be0ade9 100644
72+ index 8feaf77..261ec22 100644
5573--- a/node_modules/@op-engineering/op-sqlite/android/cpp-adapter.cpp
5674+++ b/node_modules/@op-engineering/op-sqlite/android/cpp-adapter.cpp
5775@@ -19,8 +19,8 @@ struct OPSQLiteBridge : jni::JavaClass<OPSQLiteBridge> {
@@ -61,7 +79,7 @@ index 8feaf77..be0ade9 100644
6179- makeNativeMethod("clearStateNativeJsi",
6280- OPSQLiteBridge::clearStateNativeJsi)});
6381+ makeNativeMethod("clearStateNativeJsi", OPSQLiteBridge::clearStateNativeJsi),
64- + makeNativeMethod("deleteAllDBsJsi", OPSQLiteBridge::deleteAllDBsJsi)});
82+ + makeNativeMethod("deleteAllDBsJsi", OPSQLiteBridge::deleteAllDBsJsi)});
6583 }
6684
6785 private:
@@ -71,25 +89,24 @@ index 8feaf77..be0ade9 100644
7189 }
7290+
7391+ static bool deleteAllDBsJsi(jni::alias_ref<jni::JObject> thiz) {
74- + return opsqlite::deleteAllDbs();
92+ + return opsqlite::deleteAllDbs();
7593+ }
7694 };
7795
7896 JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *) {
7997diff --git a/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt b/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt
80- index 44f86df..0cb1287 100644
98+ index 44f86df..9d9f710 100644
8199--- a/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt
82100+++ b/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt
83- @@ -13,6 +13,8 @@ class OPSQLiteBridge {
101+ @@ -12,6 +12,7 @@ class OPSQLiteBridge {
102+ docPath: String
84103 )
85104 private external fun clearStateNativeJsi()
86-
87105+ private external fun deleteAllDBsJsi(): Boolean
88- +
106+
89107 fun install(context: ReactContext) {
90108 val jsContextPointer = context.javaScriptContextHolder!!.get()
91- val jsCallInvokerHolder =
92- @@ -31,6 +33,10 @@ class OPSQLiteBridge {
109+ @@ -31,6 +32,10 @@ class OPSQLiteBridge {
93110 clearStateNativeJsi()
94111 }
95112
@@ -101,29 +118,20 @@ index 44f86df..0cb1287 100644
101118 val instance = OPSQLiteBridge()
102119 }
103120diff --git a/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt b/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
104- index fea0aa7..e169fea 100644
121+ index 688832f..9ea814b 100644
105122--- a/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
106123+++ b/node_modules/@op-engineering/op-sqlite/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
107- @@ -6,14 +6,15 @@ import com.facebook.react.bridge.ReactApplicationContext
108- import com.facebook.react.bridge.ReactMethod
109- import com.facebook.react.bridge.ReactContextBaseJavaModule
110- import com.facebook.react.bridge.ReadableMap
111- + import com.facebook.react.module.annotations.ReactModule
112- import java.io.File
113- import java.io.FileOutputStream
114- import java.io.InputStream
115- import java.io.OutputStream
124+ @@ -13,7 +13,7 @@ import java.io.OutputStream
116125 import com.facebook.react.util.RNLog;
117126
118- - //@ReactModule(name = OPSQLiteModule.NAME)
127+ //@ReactModule(name = OPSQLiteModule.NAME)
119128- internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
120- + @ReactModule(name = OPSQLiteModule.NAME)
121129+ class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
122130 override fun getName(): String {
123131 return NAME
124132 }
125- @@ -55 ,6 +56,16 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextB
126- throw Exception("Do not call getDylibPath on Android")
133+ @@ -56 ,6 +56,17 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextB
134+ return true
127135 }
128136
129137+ @ReactMethod(isBlockingSynchronousMethod = true)
@@ -135,15 +143,16 @@ index fea0aa7..e169fea 100644
135143+ fun deleteAllDBs() {
136144+ OPSQLiteBridge.instance.deleteAllDBs();
137145+ }
146+ +
138147+
139148 @ReactMethod
140149 fun moveAssetsDatabase(args: ReadableMap, promise: Promise) {
141150 val filename = args.getString("filename")!!
142151diff --git a/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.cpp b/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.cpp
143- index 33e8e25..5843a46 100644
152+ index 85710ee..8cf10f2 100644
144153--- a/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.cpp
145154+++ b/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.cpp
146- @@ -847 ,6 +847 ,10 @@ void DBHostObject::invalidate() {
155+ @@ -889 ,6 +889 ,10 @@ void DBHostObject::invalidate() {
147156 #endif
148157 }
149158
@@ -155,10 +164,10 @@ index 33e8e25..5843a46 100644
155164
156165 } // namespace opsqlite
157166diff --git a/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.h b/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.h
158- index b665ddd..26a561d 100644
167+ index cc174b7..ff36f74 100644
159168--- a/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.h
160169+++ b/node_modules/@op-engineering/op-sqlite/cpp/DBHostObject.h
161- @@ -67 ,6 +67 ,7 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject {
170+ @@ -73 ,6 +73 ,7 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject {
162171 void on_commit();
163172 void on_rollback();
164173 void invalidate();
@@ -167,7 +176,7 @@ index b665ddd..26a561d 100644
167176
168177 private:
169178diff --git a/node_modules/@op-engineering/op-sqlite/cpp/bindings.cpp b/node_modules/@op-engineering/op-sqlite/cpp/bindings.cpp
170- index 3af52b2..90e8ded 100644
179+ index 5e1c1de..dc21c65 100644
171180--- a/node_modules/@op-engineering/op-sqlite/cpp/bindings.cpp
172181+++ b/node_modules/@op-engineering/op-sqlite/cpp/bindings.cpp
173182@@ -36,6 +36,13 @@ void invalidate() {
@@ -197,21 +206,17 @@ index 91511ab..cc73dfe 100644
197206
198207 } // namespace opsqlite
199208diff --git a/node_modules/@op-engineering/op-sqlite/op-sqlite.podspec b/node_modules/@op-engineering/op-sqlite/op-sqlite.podspec
200- index b8568b9..f547bc0 100644
209+ index 375cc3e..e6fce21 100644
201210--- a/node_modules/@op-engineering/op-sqlite/op-sqlite.podspec
202211+++ b/node_modules/@op-engineering/op-sqlite/op-sqlite.podspec
203- @@ -11,20 +11,11 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1
204- fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
205-
206- parent_folder_name = File.basename(__dir__)
207- - app_package = nil
208- - # When installed on user node_modules lives inside node_modules/@op-engineering/op-sqlite
209- - if is_user_app
210- - app_package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json")))
211- - # When running on the example app
212- - else
213- - app_package = JSON.parse(File.read(File.join(__dir__, "example", "package.json")))
214- - end
212+ @@ -1,4 +1,3 @@
213+ - require "json"
214+ require_relative "./generate_tokenizers_header_file"
215+
216+ log_message = lambda do |message|
217+ @@ -39,11 +38,10 @@ else
218+ app_package = JSON.parse(File.read(File.join(__dir__, "example", "package.json")))
219+ end
215220
216221- op_sqlite_config = app_package["op-sqlite"]
217222- use_sqlcipher = false
@@ -223,7 +228,7 @@ index b8568b9..f547bc0 100644
223228 phone_version = false
224229 sqlite_flags = ""
225230 fts5 = false
226- @@ -32,19 +23 ,6 @@ rtree = false
231+ @@ -51,37 +49 ,6 @@ rtree = false
227232 use_sqlite_vec = false
228233 tokenizers = []
229234
@@ -240,6 +245,24 @@ index b8568b9..f547bc0 100644
240245- tokenizers = op_sqlite_config["tokenizers"] || []
241246- end
242247-
243- if phone_version then
244- if use_sqlcipher then
245- raise "SQLCipher is not supported with phone version"
248+ - if phone_version then
249+ - if use_sqlcipher then
250+ - raise "SQLCipher is not supported with phone version"
251+ - end
252+ -
253+ - if use_crsqlite then
254+ - raise "CRSQLite is not supported with phone version"
255+ - end
256+ -
257+ - if rtree then
258+ - raise "RTree is not supported with phone version"
259+ - end
260+ -
261+ - if use_sqlite_vec then
262+ - raise "SQLite Vec is not supported with phone version"
263+ - end
264+ - end
265+ -
266+ Pod::Spec.new do |s|
267+ s.name = "op-sqlite"
268+ s.version = package["version"]
0 commit comments