@op-engineering/op-sqlite 14.1.0 → 14.1.2

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.
@@ -37,19 +37,37 @@ def useSqliteVec = false
37
37
  def enableRtree = false
38
38
  def tokenizers = []
39
39
 
40
- def isInsideNodeModules = rootDir.absolutePath.contains("node_modules")
41
- def packageJson
42
-
43
- if ( isInsideNodeModules ) {
44
- def packageJsonFile = new File("$rootDir/../../../package.json")
45
- packageJson = new JsonSlurper().parseText(packageJsonFile.text)
40
+ // On the example app, the package.json is located at the root of the project
41
+ // On the user app, the package.json is located at the root of the node_modules directory
42
+ def isUserApp = rootDir.absolutePath.contains("node_modules")
43
+ def packageJsonFile
44
+
45
+ if (isUserApp) {
46
+ // Start from the root + 1 level up (to avoid detecting the op-sqlite/package.json) and traverse upwards to find the first package.json
47
+ File currentDir = new File("$rootDir/../")
48
+ packageJsonFile = null
49
+
50
+ // Try to find package.json by traversing upwards
51
+ while (currentDir != null) {
52
+ File potential = new File(currentDir, "package.json")
53
+ if (potential.exists()) {
54
+ packageJsonFile = potential
55
+ break
56
+ }
57
+ currentDir = currentDir.parentFile
58
+ }
46
59
  } else {
47
- def packageJsonFile = new File("$rootDir/../package.json")
48
- packageJson = new JsonSlurper().parseText(packageJsonFile.text)
60
+ packageJsonFile = new File("$rootDir/../package.json")
49
61
  }
50
62
 
63
+
64
+ def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
65
+
51
66
  def opsqliteConfig = packageJson["op-sqlite"]
67
+
52
68
  if(opsqliteConfig) {
69
+ println "[OP-SQLITE] Detected op-sqlite config from package.json at: " + packageJsonFile.absolutePath
70
+
53
71
  useSQLCipher = opsqliteConfig["sqlcipher"]
54
72
  useCRSQLite = opsqliteConfig["crsqlite"]
55
73
  useSqliteVec = opsqliteConfig["sqliteVec"]
@@ -177,7 +195,7 @@ android {
177
195
  // def tokenizerInitStrings = 0
178
196
  def tokenizersHeaderPath = 0
179
197
  if (!tokenizers.isEmpty()) {
180
- def sourceDir = isInsideNodeModules ? file("$rootDir/../../../c_sources") : file("$rootDir/../c_sources")
198
+ def sourceDir = isUserApp ? file("$rootDir/../../../c_sources") : file("$rootDir/../c_sources")
181
199
  def destDir = file("$buildscript.sourceFile.parentFile/c_sources")
182
200
  copy {
183
201
  from sourceDir
@@ -236,6 +254,15 @@ android {
236
254
  srcDirs += 'src/paper/java'
237
255
  // }
238
256
  }
257
+ jniLibs {
258
+ srcDirs = []
259
+ if (useCRSQLite) {
260
+ srcDirs += 'src/main/libcrsqlite'
261
+ }
262
+ if (useSqliteVec) {
263
+ srcDirs += 'src/main/libsqlitevec'
264
+ }
265
+ }
239
266
  }
240
267
  }
241
268
 
@@ -253,7 +280,7 @@ dependencies {
253
280
  }
254
281
  }
255
282
 
256
- task prepareHeaders(type: Copy) {
283
+ tasks.register('prepareHeaders', Copy) {
257
284
  from('../cpp')
258
285
  include "**/*.h"
259
286
  into "${project.buildDir}/headers/op-sqlite/op-engineering_op-sqlite/"
@@ -263,7 +290,7 @@ task prepareHeaders(type: Copy) {
263
290
  preBuild.dependsOn(prepareHeaders)
264
291
 
265
292
  // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
266
- tasks.whenTaskAdded { task ->
293
+ tasks.configureEach { task ->
267
294
  if (task.name.contains("configureCMakeDebug")) {
268
295
  rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach {
269
296
  task.dependsOn(it)
@@ -8,8 +8,12 @@
8
8
  #ifdef OP_SQLITE_USE_LIBSQL
9
9
  #include "libsql/bridge.h"
10
10
  #else
11
+ #ifdef __ANDROID__
12
+ #include "sqlite3.h"
13
+ #else
11
14
  #include <sqlite3.h>
12
15
  #endif
16
+ #endif
13
17
  #include <unordered_map>
14
18
  #include <vector>
15
19
 
@@ -7,8 +7,12 @@
7
7
  #include "libsql.h"
8
8
  #include "libsql/bridge.h"
9
9
  #else
10
+ #ifdef __ANDROID__
11
+ #include "sqlite3.h"
12
+ #else
10
13
  #include <sqlite3.h>
11
14
  #endif
15
+ #endif
12
16
  #include "OPThreadPool.h"
13
17
  #include <string>
14
18
  #include <utility>
package/cpp/bridge.h CHANGED
@@ -4,7 +4,11 @@
4
4
  #include "SmartHostObject.h"
5
5
  #include "types.h"
6
6
  #include "utils.h"
7
+ #ifdef __ANDROID__
8
+ #include "sqlite3.h"
9
+ #else
7
10
  #include <sqlite3.h>
11
+ #endif
8
12
  #include <vector>
9
13
 
10
14
  namespace opsqlite {
package/cpp/utils.h CHANGED
@@ -4,7 +4,11 @@
4
4
  #include "SmartHostObject.h"
5
5
  #include "types.h"
6
6
  #include <jsi/jsi.h>
7
+ #ifdef __ANDROID__
8
+ #include "sqlite3.h"
9
+ #else
7
10
  #include <sqlite3.h>
11
+ #endif
8
12
  #include <string>
9
13
  #include <vector>
10
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op-engineering/op-sqlite",
3
- "version": "14.1.0",
3
+ "version": "14.1.2",
4
4
  "description": "Next generation SQLite for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",