expo-sqlite 9.1.0 → 10.0.1
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 +32 -0
- package/android/build.gradle +24 -14
- package/android/src/main/java/expo/modules/sqlite/SQLiteHelpers.kt +96 -0
- package/android/src/main/java/expo/modules/sqlite/SQLiteModule.kt +164 -0
- package/android/src/main/java/expo/modules/sqlite/SQLitePackage.kt +11 -0
- package/build/SQLite.d.ts +13 -0
- package/build/SQLite.js +20 -5
- package/build/SQLite.js.map +1 -1
- package/build/SQLite.types.d.ts +74 -28
- package/build/SQLite.types.js.map +1 -1
- package/build/SQLite.web.js +1 -1
- package/build/SQLite.web.js.map +1 -1
- package/ios/EXSQLite/EXSQLite.h +3 -3
- package/ios/EXSQLite/EXSQLite.m +12 -12
- package/ios/EXSQLite.podspec +3 -3
- package/package.json +4 -3
- package/src/SQLite.ts +18 -4
- package/src/SQLite.types.ts +91 -29
- package/src/SQLite.web.ts +1 -1
- package/android/src/main/java/expo/modules/sqlite/SQLiteModule.java +0 -358
- package/android/src/main/java/expo/modules/sqlite/SQLitePackage.java +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,38 @@
|
|
|
8
8
|
|
|
9
9
|
### 🐛 Bug fixes
|
|
10
10
|
|
|
11
|
+
### 💡 Others
|
|
12
|
+
|
|
13
|
+
## 10.0.1 — 2021-10-01
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 10.0.0 — 2021-09-28
|
|
18
|
+
|
|
19
|
+
### 🛠 Breaking changes
|
|
20
|
+
|
|
21
|
+
- Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
|
|
22
|
+
|
|
23
|
+
### 🐛 Bug fixes
|
|
24
|
+
|
|
25
|
+
- Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
|
|
26
|
+
|
|
27
|
+
### 💡 Others
|
|
28
|
+
|
|
29
|
+
- Converted Android code to Kotlin ([#13724](https://github.com/expo/expo/pull/13724) by [@ixf](https://github.com/ixf))
|
|
30
|
+
- Added missing `_array` typing to `SQLResultSetRowList`/`ResultSet` return object. ([#13826](https://github.com/expo/expo/pull/13826) by [@bbarthec](https://github.com/bbarthec))
|
|
31
|
+
|
|
32
|
+
## 9.2.0 — 2021-06-16
|
|
33
|
+
|
|
34
|
+
### 🐛 Bug fixes
|
|
35
|
+
|
|
36
|
+
- Enable kotlin in all modules. ([#12716](https://github.com/expo/expo/pull/12716) by [@wschurman](https://github.com/wschurman))
|
|
37
|
+
|
|
38
|
+
### 💡 Others
|
|
39
|
+
|
|
40
|
+
- Migrated from `unimodules-file-system-interface` to `expo-modules-core`.
|
|
41
|
+
- Build Android code using Java 8 to fix Android instrumented test build error. ([#12939](https://github.com/expo/expo/pull/12939) by [@kudo](https://github.com/kudo))
|
|
42
|
+
|
|
11
43
|
## 9.1.0 — 2021-03-10
|
|
12
44
|
|
|
13
45
|
### 🎉 New features
|
package/android/build.gradle
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
2
3
|
apply plugin: 'maven'
|
|
3
4
|
|
|
4
5
|
group = 'host.exp.exponent'
|
|
5
|
-
version = '
|
|
6
|
+
version = '10.0.1'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
buildscript {
|
|
9
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
10
|
+
ext.safeExtGet = { prop, fallback ->
|
|
11
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
repositories {
|
|
15
|
+
mavenCentral()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
dependencies {
|
|
19
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}")
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
// Upload android library to maven with javadoc and android sources
|
|
@@ -37,25 +48,24 @@ uploadArchives {
|
|
|
37
48
|
android {
|
|
38
49
|
compileSdkVersion safeExtGet("compileSdkVersion", 30)
|
|
39
50
|
|
|
51
|
+
compileOptions {
|
|
52
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
53
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
}
|
|
55
|
+
|
|
40
56
|
defaultConfig {
|
|
41
57
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
42
58
|
targetSdkVersion safeExtGet("targetSdkVersion", 30)
|
|
43
59
|
versionCode 18
|
|
44
|
-
versionName "
|
|
60
|
+
versionName "10.0.1"
|
|
45
61
|
}
|
|
46
62
|
lintOptions {
|
|
47
63
|
abortOnError false
|
|
48
64
|
}
|
|
49
65
|
}
|
|
50
66
|
|
|
51
|
-
if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
|
|
52
|
-
apply from: project(":unimodules-core").file("../unimodules-core.gradle")
|
|
53
|
-
} else {
|
|
54
|
-
throw new GradleException(
|
|
55
|
-
"'unimodules-core.gradle' was not found in the usual React Native dependency location. " +
|
|
56
|
-
"This package can only be used in such projects. Are you sure you've installed the dependencies properly?")
|
|
57
|
-
}
|
|
58
|
-
|
|
59
67
|
dependencies {
|
|
60
|
-
|
|
68
|
+
implementation project(':expo-modules-core')
|
|
69
|
+
|
|
70
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
|
|
61
71
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
package expo.modules.sqlite
|
|
2
|
+
|
|
3
|
+
import java.io.File
|
|
4
|
+
import java.io.IOException
|
|
5
|
+
import java.util.ArrayList
|
|
6
|
+
|
|
7
|
+
@Throws(IOException::class)
|
|
8
|
+
internal fun ensureDirExists(dir: File): File {
|
|
9
|
+
if (!dir.isDirectory) {
|
|
10
|
+
if (dir.isFile) {
|
|
11
|
+
throw IOException("Path '$dir' points to a file, but must point to a directory.")
|
|
12
|
+
}
|
|
13
|
+
if (!dir.mkdirs()) {
|
|
14
|
+
var additionalErrorMessage = ""
|
|
15
|
+
if (dir.exists()) {
|
|
16
|
+
additionalErrorMessage = "Path already points to a non-normal file."
|
|
17
|
+
}
|
|
18
|
+
if (dir.parentFile == null) {
|
|
19
|
+
additionalErrorMessage = "Parent directory is null."
|
|
20
|
+
}
|
|
21
|
+
throw IOException("Couldn't create directory '$dir'. $additionalErrorMessage")
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return dir
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
internal fun pluginResultsToPrimitiveData(results: List<SQLiteModule.SQLitePluginResult>): List<Any> {
|
|
28
|
+
return results.map { convertPluginResultToArray(it) }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private fun convertPluginResultToArray(result: SQLiteModule.SQLitePluginResult): List<Any?> {
|
|
32
|
+
val rowsContent = result.rows.map { row ->
|
|
33
|
+
row.map { value ->
|
|
34
|
+
when (value) {
|
|
35
|
+
null -> null
|
|
36
|
+
is String -> value
|
|
37
|
+
is Boolean -> value
|
|
38
|
+
else -> (value as Number).toDouble()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return arrayListOf(
|
|
44
|
+
result.error?.message,
|
|
45
|
+
result.insertId.toInt(),
|
|
46
|
+
result.rowsAffected,
|
|
47
|
+
result.columns,
|
|
48
|
+
rowsContent
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private fun isPragma(str: String): Boolean {
|
|
53
|
+
return startsWithCaseInsensitive(str, "pragma")
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private fun isPragmaReadOnly(str: String): Boolean {
|
|
57
|
+
return isPragma(str) && !str.contains('=')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
internal fun isSelect(str: String): Boolean {
|
|
61
|
+
return startsWithCaseInsensitive(str, "select") || isPragmaReadOnly(str)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
internal fun isInsert(str: String): Boolean {
|
|
65
|
+
return startsWithCaseInsensitive(str, "insert")
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
internal fun isUpdate(str: String): Boolean {
|
|
69
|
+
return startsWithCaseInsensitive(str, "update")
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
internal fun isDelete(str: String): Boolean {
|
|
73
|
+
return startsWithCaseInsensitive(str, "delete")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private fun startsWithCaseInsensitive(str: String, substr: String): Boolean {
|
|
77
|
+
return str.trimStart().startsWith(substr, true)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
internal fun convertParamsToStringArray(paramArrayArg: ArrayList<Any?>): Array<String?> {
|
|
81
|
+
return paramArrayArg.map { param ->
|
|
82
|
+
when (param) {
|
|
83
|
+
is String -> unescapeBlob(param)
|
|
84
|
+
is Boolean -> if (param) "1" else "0"
|
|
85
|
+
is Double -> param.toString()
|
|
86
|
+
null -> null
|
|
87
|
+
else -> throw ClassCastException("Could not find proper SQLite data type for argument: $")
|
|
88
|
+
}
|
|
89
|
+
}.toTypedArray()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private fun unescapeBlob(str: String): String {
|
|
93
|
+
return str.replace("\u0001\u0001", "\u0000")
|
|
94
|
+
.replace("\u0001\u0002", "\u0001")
|
|
95
|
+
.replace("\u0002\u0002", "\u0002")
|
|
96
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
|
+
package expo.modules.sqlite
|
|
3
|
+
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.database.Cursor
|
|
6
|
+
import android.database.sqlite.SQLiteDatabase
|
|
7
|
+
import expo.modules.core.ExportedModule
|
|
8
|
+
import expo.modules.core.Promise
|
|
9
|
+
import expo.modules.core.interfaces.ExpoMethod
|
|
10
|
+
import java.io.File
|
|
11
|
+
import java.io.IOException
|
|
12
|
+
import java.util.*
|
|
13
|
+
|
|
14
|
+
private val TAG = SQLiteModule::class.java.simpleName
|
|
15
|
+
private val EMPTY_ROWS = arrayOf<Array<Any?>>()
|
|
16
|
+
private val EMPTY_COLUMNS = arrayOf<String?>()
|
|
17
|
+
private val EMPTY_RESULT = SQLiteModule.SQLitePluginResult(EMPTY_ROWS, EMPTY_COLUMNS, 0, 0, null)
|
|
18
|
+
private val DATABASES: MutableMap<String, SQLiteDatabase?> = HashMap()
|
|
19
|
+
|
|
20
|
+
class SQLiteModule(private val mContext: Context) : ExportedModule(mContext) {
|
|
21
|
+
override fun getName(): String {
|
|
22
|
+
return "ExponentSQLite"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@ExpoMethod
|
|
26
|
+
fun exec(dbName: String, queries: ArrayList<ArrayList<Any>>, readOnly: Boolean, promise: Promise) {
|
|
27
|
+
try {
|
|
28
|
+
val db = getDatabase(dbName)
|
|
29
|
+
val results = queries.map { sqlQuery ->
|
|
30
|
+
val sql = sqlQuery[0] as String
|
|
31
|
+
val bindArgs = convertParamsToStringArray(sqlQuery[1] as ArrayList<Any?>)
|
|
32
|
+
try {
|
|
33
|
+
if (isSelect(sql)) {
|
|
34
|
+
doSelectInBackgroundAndPossiblyThrow(sql, bindArgs, db)
|
|
35
|
+
} else { // update/insert/delete
|
|
36
|
+
if (readOnly) {
|
|
37
|
+
SQLitePluginResult(EMPTY_ROWS, EMPTY_COLUMNS, 0, 0, ReadOnlyException())
|
|
38
|
+
} else {
|
|
39
|
+
doUpdateInBackgroundAndPossiblyThrow(sql, bindArgs, db)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch (e: Throwable) {
|
|
43
|
+
SQLitePluginResult(EMPTY_ROWS, EMPTY_COLUMNS, 0, 0, e)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
val data = pluginResultsToPrimitiveData(results)
|
|
47
|
+
promise.resolve(data)
|
|
48
|
+
} catch (e: Exception) {
|
|
49
|
+
promise.reject("SQLiteError", e)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@ExpoMethod
|
|
54
|
+
fun close(dbName: String, promise: Promise) {
|
|
55
|
+
DATABASES
|
|
56
|
+
.remove(dbName)
|
|
57
|
+
?.close()
|
|
58
|
+
promise.resolve(null)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// do a update/delete/insert operation
|
|
62
|
+
private fun doUpdateInBackgroundAndPossiblyThrow(
|
|
63
|
+
sql: String,
|
|
64
|
+
bindArgs: Array<String?>?,
|
|
65
|
+
db: SQLiteDatabase
|
|
66
|
+
): SQLitePluginResult {
|
|
67
|
+
return db.compileStatement(sql).use { statement ->
|
|
68
|
+
if (bindArgs != null) {
|
|
69
|
+
for (i in bindArgs.size downTo 1) {
|
|
70
|
+
if (bindArgs[i - 1] == null) {
|
|
71
|
+
statement.bindNull(i)
|
|
72
|
+
} else {
|
|
73
|
+
statement.bindString(i, bindArgs[i - 1])
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (isInsert(sql)) {
|
|
78
|
+
val insertId = statement.executeInsert()
|
|
79
|
+
val rowsAffected = if (insertId >= 0) 1 else 0
|
|
80
|
+
SQLitePluginResult(EMPTY_ROWS, EMPTY_COLUMNS, rowsAffected, insertId, null)
|
|
81
|
+
} else if (isDelete(sql) || isUpdate(sql)) {
|
|
82
|
+
val rowsAffected = statement.executeUpdateDelete()
|
|
83
|
+
SQLitePluginResult(EMPTY_ROWS, EMPTY_COLUMNS, rowsAffected, 0, null)
|
|
84
|
+
} else {
|
|
85
|
+
// in this case, we don't need rowsAffected or insertId, so we can have a slight
|
|
86
|
+
// perf boost by just executing the query
|
|
87
|
+
statement.execute()
|
|
88
|
+
EMPTY_RESULT
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// do a select operation
|
|
94
|
+
private fun doSelectInBackgroundAndPossiblyThrow(
|
|
95
|
+
sql: String,
|
|
96
|
+
bindArgs: Array<String?>,
|
|
97
|
+
db: SQLiteDatabase
|
|
98
|
+
): SQLitePluginResult {
|
|
99
|
+
return db.rawQuery(sql, bindArgs).use { cursor ->
|
|
100
|
+
val numRows = cursor.count
|
|
101
|
+
if (numRows == 0) {
|
|
102
|
+
return EMPTY_RESULT
|
|
103
|
+
}
|
|
104
|
+
val numColumns = cursor.columnCount
|
|
105
|
+
val columnNames = cursor.columnNames
|
|
106
|
+
val rows: Array<Array<Any?>> = Array(numRows) { arrayOfNulls(numColumns) }
|
|
107
|
+
var i = 0
|
|
108
|
+
while (cursor.moveToNext()) {
|
|
109
|
+
val row = rows[i]
|
|
110
|
+
for (j in 0 until numColumns) {
|
|
111
|
+
row[j] = getValueFromCursor(cursor, j, cursor.getType(j))
|
|
112
|
+
}
|
|
113
|
+
rows[i] = row
|
|
114
|
+
i++
|
|
115
|
+
}
|
|
116
|
+
SQLitePluginResult(rows, columnNames, 0, 0, null)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private fun getValueFromCursor(cursor: Cursor, index: Int, columnType: Int): Any? {
|
|
121
|
+
return when (columnType) {
|
|
122
|
+
Cursor.FIELD_TYPE_FLOAT -> cursor.getDouble(index)
|
|
123
|
+
Cursor.FIELD_TYPE_INTEGER -> cursor.getLong(index)
|
|
124
|
+
Cursor.FIELD_TYPE_BLOB ->
|
|
125
|
+
// convert byte[] to binary string; it's good enough, because
|
|
126
|
+
// WebSQL doesn't support blobs anyway
|
|
127
|
+
String(cursor.getBlob(index))
|
|
128
|
+
Cursor.FIELD_TYPE_STRING -> cursor.getString(index)
|
|
129
|
+
else -> null
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Throws(IOException::class)
|
|
134
|
+
private fun pathForDatabaseName(name: String): String {
|
|
135
|
+
val directory = File("${mContext.filesDir}${File.separator}SQLite")
|
|
136
|
+
ensureDirExists(directory)
|
|
137
|
+
return "$directory${File.separator}$name"
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Throws(IOException::class)
|
|
141
|
+
private fun getDatabase(name: String): SQLiteDatabase {
|
|
142
|
+
var database: SQLiteDatabase? = null
|
|
143
|
+
val path = pathForDatabaseName(name)
|
|
144
|
+
if (File(path).exists()) {
|
|
145
|
+
database = DATABASES[name]
|
|
146
|
+
}
|
|
147
|
+
if (database == null) {
|
|
148
|
+
DATABASES.remove(name)
|
|
149
|
+
database = SQLiteDatabase.openOrCreateDatabase(path, null)
|
|
150
|
+
DATABASES[name] = database
|
|
151
|
+
}
|
|
152
|
+
return database!!
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
internal class SQLitePluginResult(
|
|
156
|
+
val rows: Array<Array<Any?>>,
|
|
157
|
+
val columns: Array<String?>,
|
|
158
|
+
val rowsAffected: Int,
|
|
159
|
+
val insertId: Long,
|
|
160
|
+
val error: Throwable?
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
private class ReadOnlyException : Exception("could not prepare statement (23 not authorized)")
|
|
164
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package expo.modules.sqlite
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import expo.modules.core.BasePackage
|
|
5
|
+
import expo.modules.core.ExportedModule
|
|
6
|
+
|
|
7
|
+
class SQLitePackage : BasePackage() {
|
|
8
|
+
override fun createExportedModules(context: Context): List<ExportedModule> {
|
|
9
|
+
return listOf(SQLiteModule(context))
|
|
10
|
+
}
|
|
11
|
+
}
|
package/build/SQLite.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import './polyfillNextTick';
|
|
2
2
|
import { WebSQLDatabase } from './SQLite.types';
|
|
3
|
+
/**
|
|
4
|
+
* Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,
|
|
5
|
+
* the database will be created under the app's [documents directory](../filesystem), i.e.
|
|
6
|
+
* `${FileSystem.documentDirectory}/SQLite/${name}`.
|
|
7
|
+
* > The `version`, `description` and `size` arguments are ignored, but are accepted by the function
|
|
8
|
+
* for compatibility with the WebSQL specification.
|
|
9
|
+
* @param name Name of the database file to open.
|
|
10
|
+
* @param version
|
|
11
|
+
* @param description
|
|
12
|
+
* @param size
|
|
13
|
+
* @param callback
|
|
14
|
+
* @return
|
|
15
|
+
*/
|
|
3
16
|
export declare function openDatabase(name: string, version?: string, description?: string, size?: number, callback?: (db: WebSQLDatabase) => void): WebSQLDatabase;
|
package/build/SQLite.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import './polyfillNextTick';
|
|
2
2
|
import customOpenDatabase from '@expo/websql/custom';
|
|
3
|
-
import { NativeModulesProxy } from '
|
|
3
|
+
import { NativeModulesProxy } from 'expo-modules-core';
|
|
4
4
|
import zipObject from 'lodash/zipObject';
|
|
5
5
|
import { Platform } from 'react-native';
|
|
6
6
|
const { ExponentSQLite } = NativeModulesProxy;
|
|
7
7
|
class SQLiteDatabase {
|
|
8
|
+
_name;
|
|
9
|
+
_closed = false;
|
|
8
10
|
constructor(name) {
|
|
9
|
-
this._closed = false;
|
|
10
11
|
this._name = name;
|
|
11
12
|
}
|
|
12
13
|
exec(queries, readOnly, callback) {
|
|
13
14
|
if (this._closed) {
|
|
14
15
|
throw new Error(`The SQLite database is closed`);
|
|
15
16
|
}
|
|
16
|
-
ExponentSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then(nativeResultSets => {
|
|
17
|
+
ExponentSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then((nativeResultSets) => {
|
|
17
18
|
callback(null, nativeResultSets.map(_deserializeResultSet));
|
|
18
|
-
}, error => {
|
|
19
|
+
}, (error) => {
|
|
19
20
|
// TODO: make the native API consistently reject with an error, not a string or other type
|
|
20
21
|
callback(error instanceof Error ? error : new Error(error));
|
|
21
22
|
});
|
|
@@ -38,7 +39,7 @@ function _deserializeResultSet(nativeResult) {
|
|
|
38
39
|
return {
|
|
39
40
|
insertId,
|
|
40
41
|
rowsAffected,
|
|
41
|
-
rows: rows.map(row => zipObject(columns, row)),
|
|
42
|
+
rows: rows.map((row) => zipObject(columns, row)),
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
function _escapeBlob(data) {
|
|
@@ -61,6 +62,20 @@ function addExecMethod(db) {
|
|
|
61
62
|
};
|
|
62
63
|
return db;
|
|
63
64
|
}
|
|
65
|
+
// @needsAudit @docsMissing
|
|
66
|
+
/**
|
|
67
|
+
* Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,
|
|
68
|
+
* the database will be created under the app's [documents directory](../filesystem), i.e.
|
|
69
|
+
* `${FileSystem.documentDirectory}/SQLite/${name}`.
|
|
70
|
+
* > The `version`, `description` and `size` arguments are ignored, but are accepted by the function
|
|
71
|
+
* for compatibility with the WebSQL specification.
|
|
72
|
+
* @param name Name of the database file to open.
|
|
73
|
+
* @param version
|
|
74
|
+
* @param description
|
|
75
|
+
* @param size
|
|
76
|
+
* @param callback
|
|
77
|
+
* @return
|
|
78
|
+
*/
|
|
64
79
|
export function openDatabase(name, version = '1.0', description = name, size = 1, callback) {
|
|
65
80
|
if (name === undefined) {
|
|
66
81
|
throw new TypeError(`The database name must not be undefined`);
|
package/build/SQLite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"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","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { NativeModulesProxy } from 'expo-modules-core';\nimport zipObject from 'lodash/zipObject';\nimport { Platform } from 'react-native';\n\nimport { Query, SQLiteCallback, ResultSet, ResultSetError, WebSQLDatabase } from './SQLite.types';\n\nconst { ExponentSQLite } = NativeModulesProxy;\n\nclass SQLiteDatabase {\n _name: string;\n _closed: boolean = false;\n\n constructor(name: string) {\n this._name = name;\n }\n\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n ExponentSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n // TODO: make the native API consistently reject with an error, not a string or other type\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n close() {\n this._closed = true;\n ExponentSQLite.close(this._name);\n }\n}\n\nfunction _serializeQuery(query: Query): [string, unknown[]] {\n return [query.sql, Platform.OS === 'android' ? query.args.map(_escapeBlob) : query.args];\n}\n\nfunction _deserializeResultSet(nativeResult): ResultSet | ResultSetError {\n const [errorMessage, insertId, rowsAffected, columns, rows] = nativeResult;\n // TODO: send more structured error information from the native module so we can better construct\n // a SQLException object\n if (errorMessage !== null) {\n return { error: new Error(errorMessage) } as ResultSetError;\n }\n\n return {\n insertId,\n rowsAffected,\n rows: rows.map((row) => zipObject(columns, row)),\n };\n}\n\nfunction _escapeBlob<T>(data: T): T {\n if (typeof data === 'string') {\n /* eslint-disable no-control-regex */\n return data\n .replace(/\\u0002/g, '\\u0002\\u0002')\n .replace(/\\u0001/g, '\\u0001\\u0002')\n .replace(/\\u0000/g, '\\u0001\\u0001') as any;\n /* eslint-enable no-control-regex */\n } else {\n return data;\n }\n}\n\nconst _openExpoSQLiteDatabase = customOpenDatabase(SQLiteDatabase);\n\nfunction addExecMethod(db: any): WebSQLDatabase {\n db.exec = (queries: Query[], readOnly: boolean, callback: SQLiteCallback): void => {\n db._db.exec(queries, readOnly, callback);\n };\n return db;\n}\n\n// @needsAudit @docsMissing\n/**\n * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,\n * the database will be created under the app's [documents directory](../filesystem), i.e.\n * `${FileSystem.documentDirectory}/SQLite/${name}`.\n * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function\n * for compatibility with the WebSQL specification.\n * @param name Name of the database file to open.\n * @param version\n * @param description\n * @param size\n * @param callback\n * @return\n */\nexport function openDatabase(\n name: string,\n version: string = '1.0',\n description: string = name,\n size: number = 1,\n callback?: (db: WebSQLDatabase) => void\n): WebSQLDatabase {\n if (name === undefined) {\n throw new TypeError(`The database name must not be undefined`);\n }\n const db = _openExpoSQLiteDatabase(name, version, description, size, callback);\n const dbWithExec = addExecMethod(db);\n return dbWithExec;\n}\n"]}
|
package/build/SQLite.types.d.ts
CHANGED
|
@@ -1,40 +1,76 @@
|
|
|
1
1
|
export interface Window {
|
|
2
2
|
openDatabase?: (name: string, version: string, displayName: string, estimatedSize: number, creationCallback?: DatabaseCallback) => Database;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare type DatabaseCallback = (database: Database) => void;
|
|
5
|
+
/**
|
|
6
|
+
* `Database` objects are returned by calls to `SQLite.openDatabase()`. Such an object represents a
|
|
7
|
+
* connection to a database on your device.
|
|
8
|
+
*/
|
|
7
9
|
export interface Database {
|
|
8
10
|
version: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(error: SQLError): void;
|
|
11
|
+
/**
|
|
12
|
+
* Execute a database transaction.
|
|
13
|
+
* @param callback A function representing the transaction to perform. Takes a Transaction
|
|
14
|
+
* (see below) as its only parameter, on which it can add SQL statements to execute.
|
|
15
|
+
* @param errorCallback Called if an error occurred processing this transaction. Takes a single
|
|
16
|
+
* parameter describing the error.
|
|
17
|
+
* @param successCallback Called when the transaction has completed executing on the database.
|
|
18
|
+
*/
|
|
19
|
+
transaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
|
|
20
|
+
readTransaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
|
|
20
21
|
}
|
|
22
|
+
export declare type SQLTransactionCallback = (transaction: SQLTransaction) => void;
|
|
23
|
+
export declare type SQLTransactionErrorCallback = (error: SQLError) => void;
|
|
24
|
+
/**
|
|
25
|
+
* A `SQLTransaction` object is passed in as a parameter to the `callback` parameter for the
|
|
26
|
+
* `db.transaction()` method on a `Database` (see above). It allows enqueuing SQL statements to
|
|
27
|
+
* perform in a database transaction.
|
|
28
|
+
*/
|
|
21
29
|
export interface SQLTransaction {
|
|
22
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Enqueue a SQL statement to execute in the transaction. Authors are strongly recommended to make
|
|
32
|
+
* use of the `?` placeholder feature of the method to avoid against SQL injection attacks, and to
|
|
33
|
+
* never construct SQL statements on the fly.
|
|
34
|
+
* @param sqlStatement A string containing a database query to execute expressed as SQL. The string
|
|
35
|
+
* may contain `?` placeholders, with values to be substituted listed in the `arguments` parameter.
|
|
36
|
+
* @param args An array of values (numbers or strings) to substitute for `?` placeholders in the
|
|
37
|
+
* SQL statement.
|
|
38
|
+
* @param callback Called when the query is successfully completed during the transaction. Takes
|
|
39
|
+
* two parameters: the transaction itself, and a `ResultSet` object (see below) with the results
|
|
40
|
+
* of the query.
|
|
41
|
+
* @param errorCallback Called if an error occurred executing this particular query in the
|
|
42
|
+
* transaction. Takes two parameters: the transaction itself, and the error object.
|
|
43
|
+
*/
|
|
44
|
+
executeSql(sqlStatement: string, args?: (number | string)[], callback?: SQLStatementCallback, errorCallback?: SQLStatementErrorCallback): void;
|
|
23
45
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
export declare type SQLStatementCallback = (transaction: SQLTransaction, resultSet: SQLResultSet) => void;
|
|
47
|
+
export declare type SQLStatementErrorCallback = (transaction: SQLTransaction, error: SQLError) => boolean;
|
|
48
|
+
export declare type SQLResultSet = {
|
|
49
|
+
/**
|
|
50
|
+
* The row ID of the row that the SQL statement inserted into the database, if a row was inserted.
|
|
51
|
+
*/
|
|
52
|
+
insertId?: number;
|
|
53
|
+
/**
|
|
54
|
+
* The number of rows that were changed by the SQL statement.
|
|
55
|
+
*/
|
|
32
56
|
rowsAffected: number;
|
|
33
57
|
rows: SQLResultSetRowList;
|
|
34
|
-
}
|
|
58
|
+
};
|
|
35
59
|
export interface SQLResultSetRowList {
|
|
60
|
+
/**
|
|
61
|
+
* The number of rows returned by the query.
|
|
62
|
+
*/
|
|
36
63
|
length: number;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the row with the given `index`. If there is no such row, returns `null`.
|
|
66
|
+
* @param index Index of row to get.
|
|
67
|
+
*/
|
|
37
68
|
item(index: number): any;
|
|
69
|
+
/**
|
|
70
|
+
* The actual array of rows returned by the query. Can be used directly instead of
|
|
71
|
+
* getting rows through rows.item().
|
|
72
|
+
*/
|
|
73
|
+
_array: any[];
|
|
38
74
|
}
|
|
39
75
|
export declare class SQLError {
|
|
40
76
|
static UNKNOWN_ERR: number;
|
|
@@ -55,14 +91,24 @@ export declare type Query = {
|
|
|
55
91
|
sql: string;
|
|
56
92
|
args: unknown[];
|
|
57
93
|
};
|
|
58
|
-
export
|
|
94
|
+
export declare type ResultSetError = {
|
|
59
95
|
error: Error;
|
|
60
|
-
}
|
|
61
|
-
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* `ResultSet` objects are returned through second parameter of the `success` callback for the
|
|
99
|
+
* `tx.executeSql()` method on a `SQLTransaction` (see above).
|
|
100
|
+
*/
|
|
101
|
+
export declare type ResultSet = {
|
|
102
|
+
/**
|
|
103
|
+
* The row ID of the row that the SQL statement inserted into the database, if a row was inserted.
|
|
104
|
+
*/
|
|
62
105
|
insertId?: number;
|
|
106
|
+
/**
|
|
107
|
+
* The number of rows that were changed by the SQL statement.
|
|
108
|
+
*/
|
|
63
109
|
rowsAffected: number;
|
|
64
110
|
rows: {
|
|
65
111
|
[column: string]: any;
|
|
66
112
|
}[];
|
|
67
|
-
}
|
|
113
|
+
};
|
|
68
114
|
export declare type SQLiteCallback = (error?: Error | null, resultSet?: (ResultSetError | ResultSet)[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLite.types.js","sourceRoot":"","sources":["../src/SQLite.types.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,8CAA8C;AAC9C,gDAAgD;AAChD,2DAA2D;AAC3D,EAAE;AACF,0EAA0E","sourcesContent":["// Definitions copied from `@types/websql` as we want\n// to expose a custom version of the API that:\n// - uses primitive `string` instead of `String`\n// - excludes some methods that are not exposed by our API.\n//\n// Original definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>\n\nexport interface Window {\n openDatabase?: (\n name: string,\n version: string,\n displayName: string,\n estimatedSize: number,\n creationCallback?: DatabaseCallback\n ) => Database;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"SQLite.types.js","sourceRoot":"","sources":["../src/SQLite.types.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,8CAA8C;AAC9C,gDAAgD;AAChD,2DAA2D;AAC3D,EAAE;AACF,0EAA0E","sourcesContent":["// Definitions copied from `@types/websql` as we want\n// to expose a custom version of the API that:\n// - uses primitive `string` instead of `String`\n// - excludes some methods that are not exposed by our API.\n//\n// Original definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>\n\n// @docsMissing\nexport interface Window {\n openDatabase?: (\n name: string,\n version: string,\n displayName: string,\n estimatedSize: number,\n creationCallback?: DatabaseCallback\n ) => Database;\n}\n\n// @docsMissing\nexport type DatabaseCallback = (database: Database) => void;\n\n// @needsAudit @docsMissing\n/**\n * `Database` objects are returned by calls to `SQLite.openDatabase()`. Such an object represents a\n * connection to a database on your device.\n */\nexport interface Database {\n version: string;\n\n /**\n * Execute a database transaction.\n * @param callback A function representing the transaction to perform. Takes a Transaction\n * (see below) as its only parameter, on which it can add SQL statements to execute.\n * @param errorCallback Called if an error occurred processing this transaction. Takes a single\n * parameter describing the error.\n * @param successCallback Called when the transaction has completed executing on the database.\n */\n transaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n\n readTransaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n}\n\n// @docsMissing\nexport type SQLTransactionCallback = (transaction: SQLTransaction) => void;\n\n// @docsMissing\nexport type SQLTransactionErrorCallback = (error: SQLError) => void;\n\n// @needsAudit\n/**\n * A `SQLTransaction` object is passed in as a parameter to the `callback` parameter for the\n * `db.transaction()` method on a `Database` (see above). It allows enqueuing SQL statements to\n * perform in a database transaction.\n */\nexport interface SQLTransaction {\n /**\n * Enqueue a SQL statement to execute in the transaction. Authors are strongly recommended to make\n * use of the `?` placeholder feature of the method to avoid against SQL injection attacks, and to\n * never construct SQL statements on the fly.\n * @param sqlStatement A string containing a database query to execute expressed as SQL. The string\n * may contain `?` placeholders, with values to be substituted listed in the `arguments` parameter.\n * @param args An array of values (numbers or strings) to substitute for `?` placeholders in the\n * SQL statement.\n * @param callback Called when the query is successfully completed during the transaction. Takes\n * two parameters: the transaction itself, and a `ResultSet` object (see below) with the results\n * of the query.\n * @param errorCallback Called if an error occurred executing this particular query in the\n * transaction. Takes two parameters: the transaction itself, and the error object.\n */\n executeSql(\n sqlStatement: string,\n args?: (number | string)[],\n callback?: SQLStatementCallback,\n errorCallback?: SQLStatementErrorCallback\n ): void;\n}\n\n// @docsMissing\nexport type SQLStatementCallback = (transaction: SQLTransaction, resultSet: SQLResultSet) => void;\n\n// @docsMissing\nexport type SQLStatementErrorCallback = (transaction: SQLTransaction, error: SQLError) => boolean;\n\n// @needsAudit\nexport type SQLResultSet = {\n /**\n * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.\n */\n insertId?: number;\n /**\n * The number of rows that were changed by the SQL statement.\n */\n rowsAffected: number;\n rows: SQLResultSetRowList;\n};\n\n// @needsAudit\nexport interface SQLResultSetRowList {\n /**\n * The number of rows returned by the query.\n */\n length: number;\n /**\n * Returns the row with the given `index`. If there is no such row, returns `null`.\n * @param index Index of row to get.\n */\n item(index: number): any;\n /**\n * The actual array of rows returned by the query. Can be used directly instead of\n * getting rows through rows.item().\n */\n _array: any[];\n}\n\n// @docsMissing\nexport declare class SQLError {\n static UNKNOWN_ERR: number;\n static DATABASE_ERR: number;\n static VERSION_ERR: number;\n static TOO_LARGE_ERR: number;\n static QUOTA_ERR: number;\n static SYNTAX_ERR: number;\n static CONSTRAINT_ERR: number;\n static TIMEOUT_ERR: number;\n\n code: number;\n message: string;\n}\n\n// @docsMissing\nexport interface WebSQLDatabase extends Database {\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void;\n}\n\n// @docsMissing\nexport type Query = { sql: string; args: unknown[] };\n\n// @docsMissing\nexport type ResultSetError = {\n error: Error;\n};\n\n// @needsAudit\n/**\n * `ResultSet` objects are returned through second parameter of the `success` callback for the\n * `tx.executeSql()` method on a `SQLTransaction` (see above).\n */\nexport type ResultSet = {\n /**\n * The row ID of the row that the SQL statement inserted into the database, if a row was inserted.\n */\n insertId?: number;\n /**\n * The number of rows that were changed by the SQL statement.\n */\n rowsAffected: number;\n rows: { [column: string]: any }[];\n};\n\n// @docsMissing\nexport type SQLiteCallback = (\n error?: Error | null,\n resultSet?: (ResultSetError | ResultSet)[]\n) => void;\n"]}
|
package/build/SQLite.web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnavailabilityError } from '
|
|
1
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
export function openDatabase(name, version = '1.0', description = name, size = 1, callback) {
|
|
3
3
|
const typedWindow = window;
|
|
4
4
|
if ('openDatabase' in typedWindow && typedWindow.openDatabase) {
|
package/build/SQLite.web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLite.web.js","sourceRoot":"","sources":["../src/SQLite.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SQLite.web.js","sourceRoot":"","sources":["../src/SQLite.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,UAAkB,KAAK,EACvB,cAAsB,IAAI,EAC1B,OAAe,CAAC,EAChB,QAA2B;IAE3B,MAAM,WAAW,GAAW,MAAgB,CAAC;IAC7C,IAAI,cAAc,IAAI,WAAW,IAAI,WAAW,CAAC,YAAY,EAAE;QAC7D,OAAO,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;KAC7E;IACD,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { Window, DatabaseCallback } from './SQLite.types';\n\nexport function openDatabase(\n name: string,\n version: string = '1.0',\n description: string = name,\n size: number = 1,\n callback?: DatabaseCallback\n) {\n const typedWindow: Window = window as Window;\n if ('openDatabase' in typedWindow && typedWindow.openDatabase) {\n return typedWindow.openDatabase(name, version, description, size, callback);\n }\n throw new UnavailabilityError('window', 'openDatabase');\n}\n"]}
|
package/ios/EXSQLite/EXSQLite.h
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
|
-
#import <
|
|
4
|
-
#import <
|
|
3
|
+
#import <ExpoModulesCore/EXExportedModule.h>
|
|
4
|
+
#import <ExpoModulesCore/EXModuleRegistryConsumer.h>
|
|
5
5
|
|
|
6
|
-
@interface EXSQLite :
|
|
6
|
+
@interface EXSQLite : EXExportedModule <EXModuleRegistryConsumer>
|
|
7
7
|
|
|
8
8
|
@end
|