react-native-nitro-sqlite 9.8.1 → 9.8.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.
@@ -5,6 +5,7 @@ set (CMAKE_VERBOSE_MAKEFILE ON)
5
5
  set (CMAKE_CXX_STANDARD 20)
6
6
 
7
7
  add_definitions(
8
+ ${SQLITE_DEFAULT_FLAGS}
8
9
  ${SQLITE_FLAGS}
9
10
  )
10
11
 
@@ -73,6 +73,7 @@ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { rea
73
73
  def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
74
74
  def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
75
75
 
76
+ apply from: file('sqlite-flags.gradle')
76
77
  def SQLITE_FLAGS = rootProject.properties['nitroSqliteFlags']
77
78
 
78
79
  // Opt-in: resolve the companion's cpp dir so CMake compiles its sqlite-vec into this library.
@@ -122,6 +123,7 @@ android {
122
123
  arguments "-DANDROID_STL=c++_shared",
123
124
  "-DANDROID_TOOLCHAIN=clang",
124
125
  "-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
126
+ "-DSQLITE_DEFAULT_FLAGS=${nitroSqliteDefaultFlags.join(';')}",
125
127
  "-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'",
126
128
  "-DNITRO_SQLITE_VEC=${NITRO_SQLITE_VEC_ENABLED ? 'ON' : 'OFF'}",
127
129
  "-DNITRO_SQLITE_VEC_CPP_DIR=${NITRO_SQLITE_VEC_CPP_DIR}",
@@ -0,0 +1,47 @@
1
+ import groovy.json.JsonSlurper
2
+
3
+ project.ext.resolveNitroSqliteDefaultFlags = { File appPackageFile, String customFlags ->
4
+ def appPackage = appPackageFile.exists() ? new JsonSlurper().parse(appPackageFile) : [:]
5
+ def appConfig = appPackage.get("nitroSQLite", [:])
6
+
7
+ if (!(appConfig instanceof Map)) {
8
+ throw new GradleException("nitroSQLite in package.json must be an object")
9
+ }
10
+
11
+ def readBooleanFlag = { String name ->
12
+ def value = appConfig.get(name, true)
13
+ if (!(value instanceof Boolean)) {
14
+ throw new GradleException("nitroSQLite.${name} in package.json must be true or false")
15
+ }
16
+ value
17
+ }
18
+
19
+ def threadSafe = readBooleanFlag("threadSafe")
20
+ def performanceMode = readBooleanFlag("performanceMode")
21
+ def customFlagNames = (customFlags =~ /-D([A-Za-z_][A-Za-z0-9_]*)/).collect { it[1] }.toSet()
22
+
23
+ def defaultFlags = [threadSafe ? '-DSQLITE_THREADSAFE=1' : '-DSQLITE_THREADSAFE=0']
24
+ if (performanceMode) {
25
+ defaultFlags += [
26
+ "-DSQLITE_DQS=0",
27
+ "-DSQLITE_DEFAULT_MEMSTATUS=0",
28
+ "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1",
29
+ "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1",
30
+ "-DSQLITE_MAX_EXPR_DEPTH=0",
31
+ "-DSQLITE_OMIT_DEPRECATED=1",
32
+ "-DSQLITE_OMIT_PROGRESS_CALLBACK=1",
33
+ "-DSQLITE_OMIT_SHARED_CACHE=1",
34
+ "-DSQLITE_USE_ALLOCA=1",
35
+ ]
36
+ }
37
+
38
+ // Preserve nitroSqliteFlags as an override for individual compile definitions.
39
+ defaultFlags.findAll { flag ->
40
+ def name = flag.substring(2).split("=")[0]
41
+ !customFlagNames.contains(name) && !(name == "SQLITE_THREADSAFE" && customFlagNames.contains("THREADSAFE"))
42
+ }
43
+ }
44
+
45
+ def appPackageFile = new File(rootProject.projectDir.parentFile, "package.json")
46
+ def customFlags = (rootProject.findProperty("nitroSqliteFlags") ?: "").toString()
47
+ project.ext.nitroSqliteDefaultFlags = resolveNitroSqliteDefaultFlags(appPackageFile, customFlags)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-sqlite",
3
- "version": "9.8.1",
3
+ "version": "9.8.2",
4
4
  "description": "Fast SQLite library for React Native built using Nitro Modules",
5
5
  "main": "./lib/module/index",
6
6
  "module": "./lib/module/index",