expo-sqlite 13.3.0 → 13.4.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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,13 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 13.4.0 — 2024-03-20
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Enabled [FTS](https://www.sqlite.org/fts3.html) and [FTS5](https://www.sqlite.org/fts5.html) for SQLite. ([#27738](https://github.com/expo/expo/pull/27738) by [@kudo](https://github.com/kudo))
18
+ - Fixed `NullPointerException` on Android when opening the same database multiple times. ([#27748](https://github.com/expo/expo/pull/27748) by [@kudo](https://github.com/kudo))
19
+
13
20
  ## 13.3.0 — 2024-03-05
14
21
 
15
22
  ### 🎉 New features
@@ -10,11 +10,10 @@ set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
10
10
  set(SRC_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
11
11
  file(GLOB SOURCES "${SRC_DIR}/*.cpp")
12
12
 
13
- if (NOT "${SQLITE_CUSTOM_BUILDFLAGS}" STREQUAL "")
14
- add_compile_options(
15
- "${SQLITE_CUSTOM_BUILDFLAGS}"
16
- )
17
- endif()
13
+ separate_arguments(SQLITE_BUILDFLAGS)
14
+ add_compile_options(
15
+ ${SQLITE_BUILDFLAGS}
16
+ )
18
17
 
19
18
  add_library(
20
19
  ${PACKAGE_NAME}
@@ -6,7 +6,7 @@ apply plugin: 'maven-publish'
6
6
  apply plugin: 'de.undercouch.download'
7
7
 
8
8
  group = 'host.exp.exponent'
9
- version = '13.3.0'
9
+ version = '13.4.0'
10
10
 
11
11
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
12
12
  if (expoModulesCorePlugin.exists()) {
@@ -32,6 +32,20 @@ def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
32
32
  def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads")
33
33
  def SQLITE3_SRC_DIR = new File("$buildDir/sqlite3_src")
34
34
 
35
+ def getSQLiteBuildFlags() {
36
+ def buildFlags = ''
37
+ if (findProperty('expo.sqlite.enableFTS') !== 'false') {
38
+ buildFlags <<= '-DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1'
39
+ } else {
40
+ }
41
+ def customBuildFlags = findProperty('expo.sqlite.customBuildFlags') ?: ''
42
+ if (customBuildFlags != '') {
43
+ buildFlags <<= " ${customBuildFlags}"
44
+ }
45
+ logger.info("SQLite build flags: ${buildFlags}")
46
+ return buildFlags
47
+ }
48
+
35
49
  def reactNativeArchitectures() {
36
50
  def value = project.getProperties().get("reactNativeArchitectures")
37
51
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
@@ -116,14 +130,14 @@ android {
116
130
  namespace "expo.modules.sqlite"
117
131
  defaultConfig {
118
132
  versionCode 18
119
- versionName "13.3.0"
133
+ versionName "13.4.0"
120
134
 
121
135
  externalNativeBuild {
122
136
  cmake {
123
137
  abiFilters (*reactNativeArchitectures())
124
138
  arguments "-DANDROID_STL=c++_shared",
125
139
  "-DSQLITE3_SRC_DIR=${toPlatformIndependentPath(SQLITE3_SRC_DIR)}",
126
- "-DSQLITE_CUSTOM_BUILDFLAGS=${findProperty('expo.sqlite.customBuildFlags') ?: ''}"
140
+ "-DSQLITE_BUILDFLAGS=${getSQLiteBuildFlags()}"
127
141
  }
128
142
  }
129
143
  }
@@ -3,9 +3,15 @@
3
3
  package expo.modules.sqlite
4
4
 
5
5
  import expo.modules.kotlin.sharedobjects.SharedRef
6
+ import java.util.concurrent.atomic.AtomicInteger
6
7
 
7
8
  internal class NativeDatabase(val databaseName: String, val openOptions: OpenDatabaseOptions) : SharedRef<NativeDatabaseBinding>(NativeDatabaseBinding()) {
8
9
  var isClosed = false
10
+ private val refCount = AtomicInteger(1)
11
+
12
+ internal fun addRef() {
13
+ refCount.incrementAndGet()
14
+ }
9
15
 
10
16
  override fun equals(other: Any?): Boolean {
11
17
  return other is NativeDatabase && this.ref == other.ref
@@ -13,6 +19,9 @@ internal class NativeDatabase(val databaseName: String, val openOptions: OpenDat
13
19
 
14
20
  override fun deallocate() {
15
21
  super.deallocate()
16
- this.ref.close()
22
+ val shouldClose = refCount.decrementAndGet() <= 0
23
+ if (shouldClose) {
24
+ this.ref.close()
25
+ }
17
26
  }
18
27
  }
@@ -60,6 +60,7 @@ class SQLiteModuleNext : Module() {
60
60
 
61
61
  // Try to find opened database for fast refresh
62
62
  findCachedDatabase { it.databaseName == databaseName && it.openOptions == options && !options.useNewConnection }?.let {
63
+ it.addRef()
63
64
  return@Constructor it
64
65
  }
65
66
 
@@ -1,6 +1,9 @@
1
1
  require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+ podfile_properties = JSON.parse(File.read("#{Pod::Config.instance.installation_root}/Podfile.properties.json")) rescue {}
5
+
6
+ sqliteVersion = '3.42.0'
4
7
 
5
8
  Pod::Spec.new do |s|
6
9
  s.name = 'ExpoSQLite'
@@ -14,8 +17,12 @@ Pod::Spec.new do |s|
14
17
  s.source = { git: 'https://github.com/expo/expo.git' }
15
18
  s.static_framework = true
16
19
  s.dependency 'ExpoModulesCore'
17
- # The builtin sqlite does not support extensions so we update it
18
- s.dependency 'sqlite3', '~> 3.42.0'
20
+
21
+ s.dependency 'sqlite3', "~> #{sqliteVersion}"
22
+ unless podfile_properties['expo.sqlite.enableFTS'] === 'false'
23
+ s.dependency 'sqlite3/fts', "~> #{sqliteVersion}"
24
+ s.dependency 'sqlite3/fts5', "~> #{sqliteVersion}"
25
+ end
19
26
 
20
27
  # Swift/Objective-C compatibility
21
28
  s.pod_target_xcconfig = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-sqlite",
3
- "version": "13.3.0",
3
+ "version": "13.4.0",
4
4
  "description": "Provides access to a database that can be queried through a WebSQL-like API (https://www.w3.org/TR/webdatabase/). The database is persisted across restarts of your app.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -57,5 +57,5 @@
57
57
  "peerDependencies": {
58
58
  "expo": "*"
59
59
  },
60
- "gitHead": "008e3d4a9d9f68d681d1a07a2ad2cffe3c122c3a"
60
+ "gitHead": "74264a222fcc02d5885b451597113df852d272fb"
61
61
  }