expo-sqlite 15.2.15-canary-20250729-d8899ae → 16.0.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 +11 -2
- package/android/build.gradle +11 -2
- package/android/shouldUsePublication.groovy +1 -0
- package/android/src/main/cpp/NativeDatabaseBinding.cpp +5 -5
- package/android/src/main/cpp/NativeDatabaseBinding.h +1 -1
- package/android/src/main/java/expo/modules/sqlite/NativeDatabaseBinding.kt +1 -1
- package/android/src/main/java/expo/modules/sqlite/SQLiteModule.kt +30 -1
- package/android/vec/arm64-v8a/vec.so +0 -0
- package/android/vec/armeabi-v7a/vec.so +0 -0
- package/android/vec/x86/vec.so +0 -0
- package/android/vec/x86_64/vec.so +0 -0
- package/build/NativeDatabase.d.ts +2 -0
- package/build/NativeDatabase.d.ts.map +1 -1
- package/build/NativeDatabase.js.map +1 -1
- package/build/SQLiteDatabase.d.ts +30 -0
- package/build/SQLiteDatabase.d.ts.map +1 -1
- package/build/SQLiteDatabase.js +31 -0
- package/build/SQLiteDatabase.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/ExpoSQLite.podspec +11 -3
- package/ios/SQLiteModule.swift +35 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.module +87 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.pom → 16.0.0/expo.modules.sqlite-16.0.0.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.0/expo.modules.sqlite-16.0.0.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha512 +1 -1
- package/package.json +5 -4
- package/plugin/build/withSQLite.d.ts +4 -0
- package/plugin/build/withSQLite.js +4 -0
- package/plugin/src/withSQLite.ts +18 -0
- package/src/NativeDatabase.ts +2 -0
- package/src/SQLiteDatabase.ts +37 -0
- package/web/SQLiteModule.ts +7 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.module +0 -87
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.15-canary-20250729-d8899ae/expo.modules.sqlite-15.2.15-canary-20250729-d8899ae.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,10 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
### 🐛 Bug fixes
|
|
10
10
|
|
|
11
|
-
- [Android] Fix nullability of binding params. ([#37200](https://github.com/expo/expo/pull/37200) by [@lukmccall](https://github.com/lukmccall))
|
|
12
|
-
|
|
13
11
|
### 💡 Others
|
|
14
12
|
|
|
13
|
+
## 16.0.0 — 2025-08-13
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- [iOS] Support Apple TV. ([#38475](https://github.com/expo/expo/pull/38475) by [@douglowder](https://github.com/douglowder))
|
|
18
|
+
- Added `loadExtensionAsync` / `loadExtensionSync` APIs and pre-bundled [sqlite-vec](https://github.com/asg017/sqlite-vec) extension. ([#38693](https://github.com/expo/expo/pull/38693) by [@kudo](https://github.com/kudo))
|
|
19
|
+
|
|
20
|
+
### 🐛 Bug fixes
|
|
21
|
+
|
|
22
|
+
- [Android] Fix nullability of binding params. ([#37200](https://github.com/expo/expo/pull/37200) by [@lukmccall](https://github.com/lukmccall))
|
|
23
|
+
|
|
15
24
|
### 📚 3rd party library updates
|
|
16
25
|
|
|
17
26
|
- Updated SQLite to 3.50.3. ([#38200](https://github.com/expo/expo/pull/38200) by [@kudo](https://github.com/kudo))
|
package/android/build.gradle
CHANGED
|
@@ -16,6 +16,7 @@ String toPlatformIndependentPath(File path) {
|
|
|
16
16
|
ext {
|
|
17
17
|
USE_SQLCIPHER = findProperty('expo.sqlite.useSQLCipher') == 'true'
|
|
18
18
|
USE_LIBSQL = findProperty('expo.sqlite.useLibSQL') == 'true'
|
|
19
|
+
WITH_SQLITE_VEC = findProperty('expo.sqlite.withSQLiteVecExtension') == 'true'
|
|
19
20
|
}
|
|
20
21
|
def SQLITE3_SRC_DIR = new File("${projectDir}/../vendor/sqlite3")
|
|
21
22
|
if (ext.USE_SQLCIPHER) {
|
|
@@ -45,14 +46,15 @@ def reactNativeArchitectures() {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
group = 'host.exp.exponent'
|
|
48
|
-
version = '
|
|
49
|
+
version = '16.0.0'
|
|
49
50
|
|
|
50
51
|
android {
|
|
51
52
|
namespace "expo.modules.sqlite"
|
|
52
53
|
defaultConfig {
|
|
53
54
|
versionCode 18
|
|
54
|
-
versionName "
|
|
55
|
+
versionName "16.0.0"
|
|
55
56
|
buildConfigField "boolean", "USE_LIBSQL", project.ext.USE_LIBSQL.toString()
|
|
57
|
+
buildConfigField "boolean", "WITH_SQLITE_VEC", project.ext.WITH_SQLITE_VEC.toString()
|
|
56
58
|
|
|
57
59
|
externalNativeBuild {
|
|
58
60
|
cmake {
|
|
@@ -81,6 +83,13 @@ android {
|
|
|
81
83
|
"**/libfbjni.so",
|
|
82
84
|
]
|
|
83
85
|
}
|
|
86
|
+
sourceSets {
|
|
87
|
+
main {
|
|
88
|
+
if (project.ext.WITH_SQLITE_VEC) {
|
|
89
|
+
jniLibs.srcDirs += ['vec']
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
dependencies {
|
|
@@ -58,8 +58,8 @@ void NativeDatabaseBinding::sqlite3_finalize_all_statement() {
|
|
|
58
58
|
int ret = ::exsqlite3_finalize(stmt);
|
|
59
59
|
if (ret != SQLITE_OK) {
|
|
60
60
|
std::string error = convertSqlLiteErrorToSTLString();
|
|
61
|
-
__android_log_print(ANDROID_LOG_WARN, TAG,
|
|
62
|
-
error.c_str());
|
|
61
|
+
__android_log_print(ANDROID_LOG_WARN, TAG,
|
|
62
|
+
"exsqlite3_finalize failed: %s", error.c_str());
|
|
63
63
|
}
|
|
64
64
|
stmt = nextStmt;
|
|
65
65
|
}
|
|
@@ -100,10 +100,10 @@ int64_t NativeDatabaseBinding::sqlite3_last_insert_rowid() {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
int NativeDatabaseBinding::sqlite3_load_extension(
|
|
103
|
-
const std::string &libPath, const std::string &
|
|
103
|
+
const std::string &libPath, const std::string &entryPoint) {
|
|
104
104
|
char *error;
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
auto *entryProc = !entryPoint.empty() ? entryPoint.c_str() : nullptr;
|
|
106
|
+
int ret = ::exsqlite3_load_extension(db, libPath.c_str(), entryProc, &error);
|
|
107
107
|
if (ret != SQLITE_OK && error) {
|
|
108
108
|
std::string errorString(error);
|
|
109
109
|
::exsqlite3_free(error);
|
|
@@ -29,7 +29,7 @@ public:
|
|
|
29
29
|
int sqlite3_get_autocommit();
|
|
30
30
|
int64_t sqlite3_last_insert_rowid();
|
|
31
31
|
int sqlite3_load_extension(const std::string &libPath,
|
|
32
|
-
const std::string &
|
|
32
|
+
const std::string &entryPoint);
|
|
33
33
|
int sqlite3_open(const std::string &dbPath);
|
|
34
34
|
int sqlite3_prepare_v2(
|
|
35
35
|
const std::string &source,
|
|
@@ -51,7 +51,7 @@ internal class NativeDatabaseBinding : Closeable {
|
|
|
51
51
|
external fun sqlite3_exec(source: String): Int
|
|
52
52
|
external fun sqlite3_get_autocommit(): Int
|
|
53
53
|
external fun sqlite3_last_insert_rowid(): Long
|
|
54
|
-
external fun sqlite3_load_extension(libPath: String,
|
|
54
|
+
external fun sqlite3_load_extension(libPath: String, entryPoint: String): Int
|
|
55
55
|
external fun sqlite3_open(dbPath: String): Int
|
|
56
56
|
external fun sqlite3_prepare_v2(source: String, statement: NativeStatementBinding): Int
|
|
57
57
|
external fun sqlite3_serialize(databaseName: String): ByteArray
|
|
@@ -31,8 +31,20 @@ class SQLiteModule : Module() {
|
|
|
31
31
|
|
|
32
32
|
Constants {
|
|
33
33
|
val defaultDatabaseDirectory = context.filesDir.canonicalPath + File.separator + "SQLite"
|
|
34
|
+
val bundledExtensions: Map<String, Map<String, String?>> = buildMap {
|
|
35
|
+
if (BuildConfig.WITH_SQLITE_VEC) {
|
|
36
|
+
put(
|
|
37
|
+
"sqlite-vec",
|
|
38
|
+
mapOf(
|
|
39
|
+
"libPath" to "vec",
|
|
40
|
+
"entryPoint" to "sqlite3_vec_init"
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
34
45
|
return@Constants mapOf(
|
|
35
|
-
"defaultDatabaseDirectory" to defaultDatabaseDirectory
|
|
46
|
+
"defaultDatabaseDirectory" to defaultDatabaseDirectory,
|
|
47
|
+
"bundledExtensions" to bundledExtensions
|
|
36
48
|
)
|
|
37
49
|
}
|
|
38
50
|
|
|
@@ -181,6 +193,13 @@ class SQLiteModule : Module() {
|
|
|
181
193
|
sessionCreate(database, session, dbName)
|
|
182
194
|
}
|
|
183
195
|
|
|
196
|
+
AsyncFunction("loadExtensionAsync") { database: NativeDatabase, libPath: String, entryPoint: String? ->
|
|
197
|
+
loadExtension(database, libPath, entryPoint)
|
|
198
|
+
}.runOnQueue(moduleCoroutineScope)
|
|
199
|
+
Function("loadExtensionSync") { database: NativeDatabase, libPath: String, entryPoint: String? ->
|
|
200
|
+
loadExtension(database, libPath, entryPoint)
|
|
201
|
+
}
|
|
202
|
+
|
|
184
203
|
AsyncFunction("syncLibSQL") { database: NativeDatabase ->
|
|
185
204
|
maybeThrowForClosedDatabase(database)
|
|
186
205
|
if (database.ref.libsql_sync() != NativeDatabaseBinding.SQLITE_OK) {
|
|
@@ -482,6 +501,16 @@ class SQLiteModule : Module() {
|
|
|
482
501
|
}
|
|
483
502
|
}
|
|
484
503
|
|
|
504
|
+
@Throws(AccessClosedResourceException::class, SQLiteErrorException::class)
|
|
505
|
+
private fun loadExtension(database: NativeDatabase, libPath: String, entryPoint: String?) {
|
|
506
|
+
maybeThrowForClosedDatabase(database)
|
|
507
|
+
database.ref.sqlite3_enable_load_extension(1)
|
|
508
|
+
val ret = database.ref.sqlite3_load_extension(libPath, entryPoint ?: "")
|
|
509
|
+
if (ret != NativeDatabaseBinding.SQLITE_OK) {
|
|
510
|
+
throw SQLiteErrorException(database.ref.convertSqlLiteErrorToString())
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
485
514
|
@Throws(AccessClosedResourceException::class, SQLiteErrorException::class)
|
|
486
515
|
private fun closeDatabase(database: NativeDatabase) {
|
|
487
516
|
maybeFinalizeAllStatements(database)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -12,6 +12,7 @@ export declare class NativeDatabase {
|
|
|
12
12
|
serializeAsync(databaseName: string): Promise<Uint8Array>;
|
|
13
13
|
prepareAsync(nativeStatement: NativeStatement, source: string): Promise<NativeStatement>;
|
|
14
14
|
createSessionAsync(nativeSession: NativeSession, dbName: string): Promise<NativeSession>;
|
|
15
|
+
loadExtensionAsync(libPath: string, entryPoint?: string): Promise<void>;
|
|
15
16
|
initSync(): void;
|
|
16
17
|
isInTransactionSync(): boolean;
|
|
17
18
|
closeSync(): void;
|
|
@@ -19,6 +20,7 @@ export declare class NativeDatabase {
|
|
|
19
20
|
serializeSync(databaseName: string): Uint8Array;
|
|
20
21
|
prepareSync(nativeStatement: NativeStatement, source: string): NativeStatement;
|
|
21
22
|
createSessionSync(nativeSession: NativeSession, dbName: string): NativeSession;
|
|
23
|
+
loadExtensionSync(libPath: string, entryPoint?: string): void;
|
|
22
24
|
syncLibSQL(): Promise<void>;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeDatabase.d.ts","sourceRoot":"","sources":["../src/NativeDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;gBACrB,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,cAAc,CAAC,EAAE,UA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
|
|
|
1
|
-
{"version":3,"file":"NativeDatabase.js","sourceRoot":"","sources":["../src/NativeDatabase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NativeDatabase.js","sourceRoot":"","sources":["../src/NativeDatabase.ts"],"names":[],"mappings":"AAqFA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA0B;IAC3D,MAAM,EAAE,aAAa,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,MAAM,GAAyB;QACnC,GAAG,WAAW;KACf,CAAC;IACF,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;YACpB,SAAS,EAAE,aAAa,CAAC,GAAG;YAC5B,eAAe,EAAE,aAAa,CAAC,SAAS;YACxC,gBAAgB,EAAE,aAAa,CAAC,UAAU;SAC3C,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { NativeSession } from './NativeSession';\nimport { NativeStatement } from './NativeStatement';\n\n/**\n * A class that represents an instance of the SQLite database.\n */\nexport declare class NativeDatabase {\n constructor(databasePath: string, options?: SQLiteOpenOptions, serializedData?: Uint8Array);\n\n //#region Asynchronous API\n\n public initAsync(): Promise<void>;\n public isInTransactionAsync(): Promise<boolean>;\n public closeAsync(): Promise<void>;\n public execAsync(source: string): Promise<void>;\n public serializeAsync(databaseName: string): Promise<Uint8Array>;\n public prepareAsync(nativeStatement: NativeStatement, source: string): Promise<NativeStatement>;\n public createSessionAsync(nativeSession: NativeSession, dbName: string): Promise<NativeSession>;\n public loadExtensionAsync(libPath: string, entryPoint?: string): Promise<void>;\n\n //#endregion\n\n //#region Synchronous API\n\n public initSync(): void;\n public isInTransactionSync(): boolean;\n public closeSync(): void;\n public execSync(source: string): void;\n public serializeSync(databaseName: string): Uint8Array;\n public prepareSync(nativeStatement: NativeStatement, source: string): NativeStatement;\n public createSessionSync(nativeSession: NativeSession, dbName: string): NativeSession;\n public loadExtensionSync(libPath: string, entryPoint?: string): void;\n\n //#endregion\n\n public syncLibSQL(): Promise<void>;\n}\n\n/**\n * Options for opening a database.\n */\nexport interface SQLiteOpenOptions {\n /**\n * Whether to call the [`sqlite3_update_hook()`](https://www.sqlite.org/c3ref/update_hook.html) function and enable the `onDatabaseChange` events. You can later subscribe to the change events by [`addDatabaseChangeListener`](#sqliteadddatabasechangelistenerlistener).\n * @default false\n */\n enableChangeListener?: boolean;\n\n /**\n * Whether to create new connection even if connection with the same database name exists in cache.\n * @default false\n */\n useNewConnection?: boolean;\n\n /**\n * Finalized unclosed statements automatically when the database is closed.\n * @default true\n * @hidden\n */\n finalizeUnusedStatementsBeforeClosing?: boolean;\n\n /**\n * Options for libSQL integration.\n */\n libSQLOptions?: {\n /** The URL of the libSQL server. */\n url: string;\n\n /** The auth token for the libSQL server. */\n authToken: string;\n\n /**\n * Whether to use remote-only without syncing to local database.\n * @default false\n */\n remoteOnly?: boolean;\n };\n}\n\ntype FlattenedOpenOptions = Omit<SQLiteOpenOptions, 'libSQLOptions'> & {\n libSQLUrl?: string;\n libSQLAuthToken?: string;\n libSQLRemoteOnly?: boolean;\n};\n\n/**\n * Flattens the SQLiteOpenOptions that are passed to the native module.\n */\nexport function flattenOpenOptions(options: SQLiteOpenOptions): FlattenedOpenOptions {\n const { libSQLOptions, ...restOptions } = options;\n const result: FlattenedOpenOptions = {\n ...restOptions,\n };\n if (libSQLOptions) {\n Object.assign(result, {\n libSQLUrl: libSQLOptions.url,\n libSQLAuthToken: libSQLOptions.authToken,\n libSQLRemoteOnly: libSQLOptions.remoteOnly,\n });\n }\n return result;\n}\n"]}
|
|
@@ -44,6 +44,17 @@ export declare class SQLiteDatabase {
|
|
|
44
44
|
* @param dbName The name of the database to create a session for. The default value is `main`.
|
|
45
45
|
*/
|
|
46
46
|
createSessionAsync(dbName?: string): Promise<SQLiteSession>;
|
|
47
|
+
/**
|
|
48
|
+
* Load a SQLite extension.
|
|
49
|
+
* @param libPath The path to the extension library file.
|
|
50
|
+
* @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).
|
|
51
|
+
*
|
|
52
|
+
* @platform android
|
|
53
|
+
* @platform ios
|
|
54
|
+
* @platform macos
|
|
55
|
+
* @platform tvos
|
|
56
|
+
*/
|
|
57
|
+
loadExtensionAsync(libPath: string, entryPoint?: string): Promise<void>;
|
|
47
58
|
/**
|
|
48
59
|
* Execute a transaction and automatically commit/rollback based on the `task` result.
|
|
49
60
|
*
|
|
@@ -84,6 +95,7 @@ export declare class SQLiteDatabase {
|
|
|
84
95
|
* @platform android
|
|
85
96
|
* @platform ios
|
|
86
97
|
* @platform macos
|
|
98
|
+
* @platform tvos
|
|
87
99
|
*
|
|
88
100
|
* @example
|
|
89
101
|
* ```ts
|
|
@@ -136,6 +148,17 @@ export declare class SQLiteDatabase {
|
|
|
136
148
|
* @param dbName The name of the database to create a session for. The default value is `main`.
|
|
137
149
|
*/
|
|
138
150
|
createSessionSync(dbName?: string): SQLiteSession;
|
|
151
|
+
/**
|
|
152
|
+
* Load a SQLite extension.
|
|
153
|
+
* @param libPath The path to the extension library file.
|
|
154
|
+
* @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).
|
|
155
|
+
*
|
|
156
|
+
* @platform android
|
|
157
|
+
* @platform ios
|
|
158
|
+
* @platform macos
|
|
159
|
+
* @platform tvos
|
|
160
|
+
*/
|
|
161
|
+
loadExtensionSync(libPath: string, entryPoint?: string): void;
|
|
139
162
|
/**
|
|
140
163
|
* Execute a transaction and automatically commit/rollback based on the `task` result.
|
|
141
164
|
*
|
|
@@ -251,6 +274,13 @@ export declare class SQLiteDatabase {
|
|
|
251
274
|
* The default directory for SQLite databases.
|
|
252
275
|
*/
|
|
253
276
|
export declare const defaultDatabaseDirectory: any;
|
|
277
|
+
/**
|
|
278
|
+
* The pre-bundled SQLite extensions.
|
|
279
|
+
*/
|
|
280
|
+
export declare const bundledExtensions: Record<string, {
|
|
281
|
+
libPath: string;
|
|
282
|
+
entryPoint: string;
|
|
283
|
+
} | undefined>;
|
|
254
284
|
/**
|
|
255
285
|
* Open a database.
|
|
256
286
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteDatabase.d.ts","sourceRoot":"","sources":["../src/SQLiteDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EAAsB,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,gBAAgB,EAGhB,eAAe,EACf,eAAe,EACf,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;GAEG;AACH,qBAAa,cAAc;aAEP,YAAY,EAAE,MAAM;aACpB,OAAO,EAAE,iBAAiB;aAC1B,cAAc,EAAE,cAAc;gBAF9B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EAAE,cAAc;IAGhD;;OAEG;IACI,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/C;;OAEG;IACI,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;;;;OAKG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;;;OAIG;IACI,cAAc,CAAC,YAAY,GAAE,MAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAIzE;;;;OAIG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAMnE;;;;OAIG;IACU,kBAAkB,CAAC,MAAM,GAAE,MAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAMhF;;;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6 +65,19 @@ export class SQLiteDatabase {
|
|
|
65
65
|
await this.nativeDatabase.createSessionAsync(nativeSession, dbName);
|
|
66
66
|
return new SQLiteSession(this.nativeDatabase, nativeSession);
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Load a SQLite extension.
|
|
70
|
+
* @param libPath The path to the extension library file.
|
|
71
|
+
* @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).
|
|
72
|
+
*
|
|
73
|
+
* @platform android
|
|
74
|
+
* @platform ios
|
|
75
|
+
* @platform macos
|
|
76
|
+
* @platform tvos
|
|
77
|
+
*/
|
|
78
|
+
loadExtensionAsync(libPath, entryPoint) {
|
|
79
|
+
return this.nativeDatabase.loadExtensionAsync(libPath, entryPoint);
|
|
80
|
+
}
|
|
68
81
|
/**
|
|
69
82
|
* Execute a transaction and automatically commit/rollback based on the `task` result.
|
|
70
83
|
*
|
|
@@ -115,6 +128,7 @@ export class SQLiteDatabase {
|
|
|
115
128
|
* @platform android
|
|
116
129
|
* @platform ios
|
|
117
130
|
* @platform macos
|
|
131
|
+
* @platform tvos
|
|
118
132
|
*
|
|
119
133
|
* @example
|
|
120
134
|
* ```ts
|
|
@@ -204,6 +218,19 @@ export class SQLiteDatabase {
|
|
|
204
218
|
this.nativeDatabase.createSessionSync(nativeSession, dbName);
|
|
205
219
|
return new SQLiteSession(this.nativeDatabase, nativeSession);
|
|
206
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Load a SQLite extension.
|
|
223
|
+
* @param libPath The path to the extension library file.
|
|
224
|
+
* @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).
|
|
225
|
+
*
|
|
226
|
+
* @platform android
|
|
227
|
+
* @platform ios
|
|
228
|
+
* @platform macos
|
|
229
|
+
* @platform tvos
|
|
230
|
+
*/
|
|
231
|
+
loadExtensionSync(libPath, entryPoint) {
|
|
232
|
+
this.nativeDatabase.loadExtensionSync(libPath, entryPoint);
|
|
233
|
+
}
|
|
207
234
|
/**
|
|
208
235
|
* Execute a transaction and automatically commit/rollback based on the `task` result.
|
|
209
236
|
*
|
|
@@ -331,6 +358,10 @@ export class SQLiteDatabase {
|
|
|
331
358
|
* The default directory for SQLite databases.
|
|
332
359
|
*/
|
|
333
360
|
export const defaultDatabaseDirectory = ExpoSQLite.defaultDatabaseDirectory;
|
|
361
|
+
/**
|
|
362
|
+
* The pre-bundled SQLite extensions.
|
|
363
|
+
*/
|
|
364
|
+
export const bundledExtensions = ExpoSQLite.bundledExtensions;
|
|
334
365
|
/**
|
|
335
366
|
* Open a database.
|
|
336
367
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteDatabase.js","sourceRoot":"","sources":["../src/SQLiteDatabase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAqC,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAKL,eAAe,GAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD;;GAEG;AACH,MAAM,OAAO,cAAc;IAEP;IACA;IACA;IAHlB,YACkB,YAAoB,EACpB,OAA0B,EAC1B,cAA8B;QAF9B,iBAAY,GAAZ,YAAY,CAAQ;QACpB,YAAO,GAAP,OAAO,CAAmB;QAC1B,mBAAc,GAAd,cAAc,CAAgB;IAC7C,CAAC;IAEJ;;OAEG;IACI,oBAAoB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAA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E,CAAC;CACF","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport { flattenOpenOptions, NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';\nimport { SQLiteSession } from './SQLiteSession';\nimport {\n SQLiteBindParams,\n SQLiteExecuteAsyncResult,\n SQLiteExecuteSyncResult,\n SQLiteRunResult,\n SQLiteStatement,\n SQLiteVariadicBindParams,\n} from './SQLiteStatement';\nimport { createDatabasePath } from './pathUtils';\n\nexport { SQLiteOpenOptions };\n\n/**\n * A SQLite database.\n */\nexport class SQLiteDatabase {\n constructor(\n public readonly databasePath: string,\n public readonly options: SQLiteOpenOptions,\n public readonly nativeDatabase: NativeDatabase\n ) {}\n\n /**\n * Asynchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionAsync(): Promise<boolean> {\n return this.nativeDatabase.isInTransactionAsync();\n }\n\n /**\n * Close the database.\n */\n public closeAsync(): Promise<void> {\n return this.nativeDatabase.closeAsync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n * > Note: The queries are not escaped for you! Be careful when constructing your queries.\n *\n * @param source A string containing all the SQL queries.\n */\n public execAsync(source: string): Promise<void> {\n return this.nativeDatabase.execAsync(source);\n }\n\n /**\n * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeAsync(databaseName: string = 'main'): Promise<Uint8Array> {\n return this.nativeDatabase.serializeAsync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\n *\n * @param source A string containing the SQL query.\n */\n public async prepareAsync(source: string): Promise<SQLiteStatement> {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n await this.nativeDatabase.prepareAsync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public async createSessionAsync(dbName: string = 'main'): Promise<SQLiteSession> {\n const nativeSession = new ExpoSQLite.NativeSession();\n await this.nativeDatabase.createSessionAsync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** This transaction is not exclusive and can be interrupted by other async queries.\n *\n * @example\n * ```ts\n * db.withTransactionAsync(async () => {\n * await db.execAsync('UPDATE test SET name = \"aaa\"');\n *\n * //\n * // We cannot control the order of async/await order, so order of execution is not guaranteed.\n * // The following UPDATE query out of transaction may be executed here and break the expectation.\n * //\n *\n * const result = await db.getFirstAsync<{ name: string }>('SELECT name FROM Users');\n * expect(result?.name).toBe('aaa');\n * });\n * db.execAsync('UPDATE test SET name = \"bbb\"');\n * ```\n * If you worry about the order of execution, use `withExclusiveTransactionAsync` instead.\n *\n * @param task An async function to execute within a transaction.\n */\n public async withTransactionAsync(task: () => Promise<void>): Promise<void> {\n try {\n await this.execAsync('BEGIN');\n await task();\n await this.execAsync('COMMIT');\n } catch (e) {\n await this.execAsync('ROLLBACK');\n throw e;\n }\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * The transaction may be exclusive.\n * As long as the transaction is converted into a write transaction,\n * the other async write queries will abort with `database is locked` error.\n *\n * > **Note:** This function is not supported on web.\n *\n * @param task An async function to execute within a transaction. Any queries inside the transaction must be executed on the `txn` object.\n * The `txn` object has the same interfaces as the [`SQLiteDatabase`](#sqlitedatabase) object. You can use `txn` like a [`SQLiteDatabase`](#sqlitedatabase) object.\n *\n * @platform android\n * @platform ios\n * @platform macos\n *\n * @example\n * ```ts\n * db.withExclusiveTransactionAsync(async (txn) => {\n * await txn.execAsync('UPDATE test SET name = \"aaa\"');\n * });\n * ```\n */\n public async withExclusiveTransactionAsync(\n task: (txn: Transaction) => Promise<void>\n ): Promise<void> {\n if (Platform.OS === 'web') {\n throw new Error('withExclusiveTransactionAsync is not supported on web');\n }\n const transaction = await Transaction.createAsync(this);\n let error;\n try {\n await transaction.execAsync('BEGIN');\n await task(transaction);\n await transaction.execAsync('COMMIT');\n } catch (e) {\n await transaction.execAsync('ROLLBACK');\n error = e;\n } finally {\n await transaction.closeAsync();\n }\n if (error) {\n throw error;\n }\n }\n\n /**\n * Synchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionSync(): boolean {\n return this.nativeDatabase.isInTransactionSync();\n }\n\n /**\n * Close the database.\n */\n public closeSync(): void {\n return this.nativeDatabase.closeSync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n *\n * > **Note:** The queries are not escaped for you! Be careful when constructing your queries.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param source A string containing all the SQL queries.\n */\n public execSync(source: string): void {\n return this.nativeDatabase.execSync(source);\n }\n\n /**\n * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeSync(databaseName: string = 'main'): Uint8Array {\n return this.nativeDatabase.serializeSync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param source A string containing the SQL query.\n */\n public prepareSync(source: string): SQLiteStatement {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n this.nativeDatabase.prepareSync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public createSessionSync(dbName: string = 'main'): SQLiteSession {\n const nativeSession = new ExpoSQLite.NativeSession();\n this.nativeDatabase.createSessionSync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param task An async function to execute within a transaction.\n */\n public withTransactionSync(task: () => void): void {\n try {\n this.execSync('BEGIN');\n task();\n this.execSync('COMMIT');\n } catch (e) {\n this.execSync('ROLLBACK');\n throw e;\n }\n }\n\n //#region Statement API shorthands\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runAsync(source: string, params: SQLiteBindParams): Promise<SQLiteRunResult>;\n\n /**\n * @hidden\n */\n public runAsync(source: string, ...params: SQLiteVariadicBindParams): Promise<SQLiteRunResult>;\n public async runAsync(source: string, ...params: any[]): Promise<SQLiteRunResult> {\n const statement = await this.prepareAsync(source);\n let result: SQLiteExecuteAsyncResult<unknown>;\n try {\n result = await statement.executeAsync(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getFirstAsync()`](#getfirstasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstAsync<T>(source: string, params: SQLiteBindParams): Promise<T | null>;\n /**\n * @hidden\n */\n public getFirstAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T | null>;\n public async getFirstAsync<T>(source: string, ...params: any[]): Promise<T | null> {\n const statement = await this.prepareAsync(source);\n let firstRow: T | null;\n try {\n const result = await statement.executeAsync<T>(...params);\n firstRow = await result.getFirstAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult`](#sqliteexecuteasyncresult) `AsyncIterator`, and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns Rather than returning Promise, this function returns an [`AsyncIterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator). You can use `for await...of` to iterate over the rows from the SQLite query result.\n */\n public getEachAsync<T>(source: string, params: SQLiteBindParams): AsyncIterableIterator<T>;\n /**\n * @hidden\n */\n public getEachAsync<T>(\n source: string,\n ...params: SQLiteVariadicBindParams\n ): AsyncIterableIterator<T>;\n public async *getEachAsync<T>(source: string, ...params: any[]): AsyncIterableIterator<T> {\n const statement = await this.prepareAsync(source);\n try {\n const result = await statement.executeAsync<T>(...params);\n for await (const row of result) {\n yield row;\n }\n } finally {\n await statement.finalizeAsync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getAllAsync()`](#getallasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @example\n * ```ts\n * // For unnamed parameters, you pass values in an array.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', [1, 'Hello']);\n *\n * // For unnamed parameters, you pass values in variadic arguments.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', 1, 'Hello');\n *\n * // For named parameters, you should pass values in object.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = $intValue AND name = $name', { $intValue: 1, $name: 'Hello' });\n * ```\n */\n public getAllAsync<T>(source: string, params: SQLiteBindParams): Promise<T[]>;\n /**\n * @hidden\n */\n public getAllAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T[]>;\n public async getAllAsync<T>(source: string, ...params: any[]): Promise<T[]> {\n const statement = await this.prepareAsync(source);\n let allRows;\n try {\n const result = await statement.executeAsync<T>(...params);\n allRows = await result.getAllAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return allRows;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runSync(source: string, params: SQLiteBindParams): SQLiteRunResult;\n /**\n * @hidden\n */\n public runSync(source: string, ...params: SQLiteVariadicBindParams): SQLiteRunResult;\n public runSync(source: string, ...params: any[]): SQLiteRunResult {\n const statement = this.prepareSync(source);\n let result: SQLiteExecuteSyncResult<unknown>;\n try {\n result = statement.executeSync(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getFirstSync()`](#getfirstsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstSync<T>(source: string, params: SQLiteBindParams): T | null;\n /**\n * @hidden\n */\n public getFirstSync<T>(source: string, ...params: SQLiteVariadicBindParams): T | null;\n public getFirstSync<T>(source: string, ...params: any[]): T | null {\n const statement = this.prepareSync(source);\n let firstRow: T | null;\n try {\n const result = statement.executeSync<T>(...params);\n firstRow = result.getFirstSync();\n } finally {\n statement.finalizeSync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult`](#sqliteexecutesyncresult) `Iterator`, and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns This function returns an [`IterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator). You can use `for...of` to iterate over the rows from the SQLite query result.\n */\n public getEachSync<T>(source: string, params: SQLiteBindParams): IterableIterator<T>;\n /**\n * @hidden\n */\n public getEachSync<T>(source: string, ...params: SQLiteVariadicBindParams): IterableIterator<T>;\n public *getEachSync<T>(source: string, ...params: any[]): IterableIterator<T> {\n const statement = this.prepareSync(source);\n try {\n const result = statement.executeSync<T>(...params);\n for (const row of result) {\n yield row;\n }\n } finally {\n statement.finalizeSync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getAllSync()`](#getallsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getAllSync<T>(source: string, params: SQLiteBindParams): T[];\n /**\n * @hidden\n */\n public getAllSync<T>(source: string, ...params: SQLiteVariadicBindParams): T[];\n public getAllSync<T>(source: string, ...params: any[]): T[] {\n const statement = this.prepareSync(source);\n let allRows;\n try {\n const result = statement.executeSync<T>(...params);\n allRows = result.getAllSync();\n } finally {\n statement.finalizeSync();\n }\n return allRows;\n }\n\n /**\n * Synchronize the local database with the remote libSQL server.\n * This method is only available from libSQL integration.\n */\n public syncLibSQL(): Promise<void> {\n if (typeof this.nativeDatabase.syncLibSQL !== 'function') {\n throw new Error('syncLibSQL is not supported in the current environment');\n }\n return this.nativeDatabase.syncLibSQL();\n }\n\n //#endregion\n}\n\n/**\n * The default directory for SQLite databases.\n */\nexport const defaultDatabaseDirectory = ExpoSQLite.defaultDatabaseDirectory;\n\n/**\n * Open a database.\n *\n * @param databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport async function openDatabaseAsync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n await ExpoSQLite.ensureDatabasePathExistsAsync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n await nativeDatabase.initAsync();\n return new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n}\n\n/**\n * Open a database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport function openDatabaseSync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n ExpoSQLite.ensureDatabasePathExistsSync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n nativeDatabase.initSync();\n return new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeAsync()`](#serializeasyncdatabasename).\n * @param options Open options.\n */\nexport async function deserializeDatabaseAsync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n await nativeDatabase.initAsync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeSync()`](#serializesyncdatabasename)\n * @param options Open options.\n */\nexport function deserializeDatabaseSync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n nativeDatabase.initSync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Delete a database file.\n *\n * @param databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport async function deleteDatabaseAsync(databaseName: string, directory?: string): Promise<void> {\n const databasePath = createDatabasePath(databaseName, directory);\n return await ExpoSQLite.deleteDatabaseAsync(databasePath);\n}\n\n/**\n * Delete a database file.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport function deleteDatabaseSync(databaseName: string, directory?: string): void {\n const databasePath = createDatabasePath(databaseName, directory);\n return ExpoSQLite.deleteDatabaseSync(databasePath);\n}\n\n/**\n * Backup a database to another database.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseAsync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): Promise<void> {\n return ExpoSQLite.backupDatabaseAsync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\n}\n\n/**\n * Backup a database to another database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseSync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): void {\n return ExpoSQLite.backupDatabaseSync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\n}\n\n/**\n * The event payload for the listener of [`addDatabaseChangeListener`](#sqliteadddatabasechangelistenerlistener)\n */\nexport type DatabaseChangeEvent = {\n /** The database name. The value would be `main` by default and other database names if you use `ATTACH DATABASE` statement. */\n databaseName: string;\n\n /** The absolute file path to the database. */\n databaseFilePath: string;\n\n /** The table name. */\n tableName: string;\n\n /** The changed row ID. */\n rowId: number;\n};\n\n/**\n * Add a listener for database changes.\n * > Note: to enable this feature, you must set [`enableChangeListener` to `true`](#sqliteopenoptions) when opening the database.\n *\n * @param listener A function that receives the `databaseName`, `databaseFilePath`, `tableName` and `rowId` of the modified data.\n * @returns A `Subscription` object that you can call `remove()` on when you would like to unsubscribe the listener.\n */\nexport function addDatabaseChangeListener(\n listener: (event: DatabaseChangeEvent) => void\n): EventSubscription {\n return ExpoSQLite.addListener('onDatabaseChange', listener);\n}\n\n/**\n * A new connection specific used for [`withExclusiveTransactionAsync`](#withexclusivetransactionasynctask).\n * @hidden not going to pull all the database methods to the document.\n */\nclass Transaction extends SQLiteDatabase {\n public static async createAsync(db: SQLiteDatabase): Promise<Transaction> {\n const options = { ...db.options, useNewConnection: true };\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n db.databasePath,\n flattenOpenOptions(options)\n );\n await nativeDatabase.initAsync();\n return new Transaction(db.databasePath, options, nativeDatabase);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SQLiteDatabase.js","sourceRoot":"","sources":["../src/SQLiteDatabase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAqC,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAKL,eAAe,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;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GAMjB;IACC,OAAO,UAAU,CAAC,kBAAkB,CAClC,YAAY,CAAC,cAAc,EAC3B,gBAAgB,IAAI,MAAM,EAC1B,cAAc,CAAC,cAAc,EAC7B,kBAAkB,IAAI,MAAM,CAC7B,CAAC;AACJ,CAAC;AAmBD;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAA8C;IAE9C,OAAO,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,WAAY,SAAQ,cAAc;IAC/B,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAkB;QAChD,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;QAC1D,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,cAAc,CAClD,EAAE,CAAC,YAAY,EACf,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;QACF,MAAM,cAAc,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport { flattenOpenOptions, NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';\nimport { SQLiteSession } from './SQLiteSession';\nimport {\n SQLiteBindParams,\n SQLiteExecuteAsyncResult,\n SQLiteExecuteSyncResult,\n SQLiteRunResult,\n SQLiteStatement,\n SQLiteVariadicBindParams,\n} from './SQLiteStatement';\nimport { createDatabasePath } from './pathUtils';\n\nexport { SQLiteOpenOptions };\n\n/**\n * A SQLite database.\n */\nexport class SQLiteDatabase {\n constructor(\n public readonly databasePath: string,\n public readonly options: SQLiteOpenOptions,\n public readonly nativeDatabase: NativeDatabase\n ) {}\n\n /**\n * Asynchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionAsync(): Promise<boolean> {\n return this.nativeDatabase.isInTransactionAsync();\n }\n\n /**\n * Close the database.\n */\n public closeAsync(): Promise<void> {\n return this.nativeDatabase.closeAsync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n * > Note: The queries are not escaped for you! Be careful when constructing your queries.\n *\n * @param source A string containing all the SQL queries.\n */\n public execAsync(source: string): Promise<void> {\n return this.nativeDatabase.execAsync(source);\n }\n\n /**\n * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeAsync(databaseName: string = 'main'): Promise<Uint8Array> {\n return this.nativeDatabase.serializeAsync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\n *\n * @param source A string containing the SQL query.\n */\n public async prepareAsync(source: string): Promise<SQLiteStatement> {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n await this.nativeDatabase.prepareAsync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public async createSessionAsync(dbName: string = 'main'): Promise<SQLiteSession> {\n const nativeSession = new ExpoSQLite.NativeSession();\n await this.nativeDatabase.createSessionAsync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Load a SQLite extension.\n * @param libPath The path to the extension library file.\n * @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n */\n public loadExtensionAsync(libPath: string, entryPoint?: string): Promise<void> {\n return this.nativeDatabase.loadExtensionAsync(libPath, entryPoint);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** This transaction is not exclusive and can be interrupted by other async queries.\n *\n * @example\n * ```ts\n * db.withTransactionAsync(async () => {\n * await db.execAsync('UPDATE test SET name = \"aaa\"');\n *\n * //\n * // We cannot control the order of async/await order, so order of execution is not guaranteed.\n * // The following UPDATE query out of transaction may be executed here and break the expectation.\n * //\n *\n * const result = await db.getFirstAsync<{ name: string }>('SELECT name FROM Users');\n * expect(result?.name).toBe('aaa');\n * });\n * db.execAsync('UPDATE test SET name = \"bbb\"');\n * ```\n * If you worry about the order of execution, use `withExclusiveTransactionAsync` instead.\n *\n * @param task An async function to execute within a transaction.\n */\n public async withTransactionAsync(task: () => Promise<void>): Promise<void> {\n try {\n await this.execAsync('BEGIN');\n await task();\n await this.execAsync('COMMIT');\n } catch (e) {\n await this.execAsync('ROLLBACK');\n throw e;\n }\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * The transaction may be exclusive.\n * As long as the transaction is converted into a write transaction,\n * the other async write queries will abort with `database is locked` error.\n *\n * > **Note:** This function is not supported on web.\n *\n * @param task An async function to execute within a transaction. Any queries inside the transaction must be executed on the `txn` object.\n * The `txn` object has the same interfaces as the [`SQLiteDatabase`](#sqlitedatabase) object. You can use `txn` like a [`SQLiteDatabase`](#sqlitedatabase) object.\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n *\n * @example\n * ```ts\n * db.withExclusiveTransactionAsync(async (txn) => {\n * await txn.execAsync('UPDATE test SET name = \"aaa\"');\n * });\n * ```\n */\n public async withExclusiveTransactionAsync(\n task: (txn: Transaction) => Promise<void>\n ): Promise<void> {\n if (Platform.OS === 'web') {\n throw new Error('withExclusiveTransactionAsync is not supported on web');\n }\n const transaction = await Transaction.createAsync(this);\n let error;\n try {\n await transaction.execAsync('BEGIN');\n await task(transaction);\n await transaction.execAsync('COMMIT');\n } catch (e) {\n await transaction.execAsync('ROLLBACK');\n error = e;\n } finally {\n await transaction.closeAsync();\n }\n if (error) {\n throw error;\n }\n }\n\n /**\n * Synchronous call to return whether the database is currently in a transaction.\n */\n public isInTransactionSync(): boolean {\n return this.nativeDatabase.isInTransactionSync();\n }\n\n /**\n * Close the database.\n */\n public closeSync(): void {\n return this.nativeDatabase.closeSync();\n }\n\n /**\n * Execute all SQL queries in the supplied string.\n *\n * > **Note:** The queries are not escaped for you! Be careful when constructing your queries.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param source A string containing all the SQL queries.\n */\n public execSync(source: string): void {\n return this.nativeDatabase.execSync(source);\n }\n\n /**\n * [Serialize the database](https://sqlite.org/c3ref/serialize.html) as `Uint8Array`.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the current attached databases. The default value is `main` which is the default database name.\n */\n public serializeSync(databaseName: string = 'main'): Uint8Array {\n return this.nativeDatabase.serializeSync(databaseName);\n }\n\n /**\n * Create a [prepared SQLite statement](https://www.sqlite.org/c3ref/prepare.html).\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param source A string containing the SQL query.\n */\n public prepareSync(source: string): SQLiteStatement {\n const nativeStatement = new ExpoSQLite.NativeStatement();\n this.nativeDatabase.prepareSync(nativeStatement, source);\n return new SQLiteStatement(this.nativeDatabase, nativeStatement);\n }\n\n /**\n * Create a new session for the database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see [`sqlite3session_create`](https://www.sqlite.org/session/sqlite3session_create.html)\n * @param dbName The name of the database to create a session for. The default value is `main`.\n */\n public createSessionSync(dbName: string = 'main'): SQLiteSession {\n const nativeSession = new ExpoSQLite.NativeSession();\n this.nativeDatabase.createSessionSync(nativeSession, dbName);\n return new SQLiteSession(this.nativeDatabase, nativeSession);\n }\n\n /**\n * Load a SQLite extension.\n * @param libPath The path to the extension library file.\n * @param entryPoint The entry point of the extension. If not provided, the default entry point is inferred by [`sqlite3_load_extension`](https://www.sqlite.org/c3ref/load_extension.html).\n *\n * @platform android\n * @platform ios\n * @platform macos\n * @platform tvos\n */\n public loadExtensionSync(libPath: string, entryPoint?: string): void {\n this.nativeDatabase.loadExtensionSync(libPath, entryPoint);\n }\n\n /**\n * Execute a transaction and automatically commit/rollback based on the `task` result.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param task An async function to execute within a transaction.\n */\n public withTransactionSync(task: () => void): void {\n try {\n this.execSync('BEGIN');\n task();\n this.execSync('COMMIT');\n } catch (e) {\n this.execSync('ROLLBACK');\n throw e;\n }\n }\n\n //#region Statement API shorthands\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runAsync(source: string, params: SQLiteBindParams): Promise<SQLiteRunResult>;\n\n /**\n * @hidden\n */\n public runAsync(source: string, ...params: SQLiteVariadicBindParams): Promise<SQLiteRunResult>;\n public async runAsync(source: string, ...params: any[]): Promise<SQLiteRunResult> {\n const statement = await this.prepareAsync(source);\n let result: SQLiteExecuteAsyncResult<unknown>;\n try {\n result = await statement.executeAsync(...params);\n } finally {\n await statement.finalizeAsync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getFirstAsync()`](#getfirstasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstAsync<T>(source: string, params: SQLiteBindParams): Promise<T | null>;\n /**\n * @hidden\n */\n public getFirstAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T | null>;\n public async getFirstAsync<T>(source: string, ...params: any[]): Promise<T | null> {\n const statement = await this.prepareAsync(source);\n let firstRow: T | null;\n try {\n const result = await statement.executeAsync<T>(...params);\n firstRow = await result.getFirstAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult`](#sqliteexecuteasyncresult) `AsyncIterator`, and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns Rather than returning Promise, this function returns an [`AsyncIterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator). You can use `for await...of` to iterate over the rows from the SQLite query result.\n */\n public getEachAsync<T>(source: string, params: SQLiteBindParams): AsyncIterableIterator<T>;\n /**\n * @hidden\n */\n public getEachAsync<T>(\n source: string,\n ...params: SQLiteVariadicBindParams\n ): AsyncIterableIterator<T>;\n public async *getEachAsync<T>(source: string, ...params: any[]): AsyncIterableIterator<T> {\n const statement = await this.prepareAsync(source);\n try {\n const result = await statement.executeAsync<T>(...params);\n for await (const row of result) {\n yield row;\n }\n } finally {\n await statement.finalizeAsync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), [`SQLiteExecuteAsyncResult.getAllAsync()`](#getallasync), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @example\n * ```ts\n * // For unnamed parameters, you pass values in an array.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', [1, 'Hello']);\n *\n * // For unnamed parameters, you pass values in variadic arguments.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = ? AND name = ?', 1, 'Hello');\n *\n * // For named parameters, you should pass values in object.\n * db.getAllAsync('SELECT * FROM test WHERE intValue = $intValue AND name = $name', { $intValue: 1, $name: 'Hello' });\n * ```\n */\n public getAllAsync<T>(source: string, params: SQLiteBindParams): Promise<T[]>;\n /**\n * @hidden\n */\n public getAllAsync<T>(source: string, ...params: SQLiteVariadicBindParams): Promise<T[]>;\n public async getAllAsync<T>(source: string, ...params: any[]): Promise<T[]> {\n const statement = await this.prepareAsync(source);\n let allRows;\n try {\n const result = await statement.executeAsync<T>(...params);\n allRows = await result.getAllAsync();\n } finally {\n await statement.finalizeAsync();\n }\n return allRows;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public runSync(source: string, params: SQLiteBindParams): SQLiteRunResult;\n /**\n * @hidden\n */\n public runSync(source: string, ...params: SQLiteVariadicBindParams): SQLiteRunResult;\n public runSync(source: string, ...params: any[]): SQLiteRunResult {\n const statement = this.prepareSync(source);\n let result: SQLiteExecuteSyncResult<unknown>;\n try {\n result = statement.executeSync(...params);\n } finally {\n statement.finalizeSync();\n }\n return result;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getFirstSync()`](#getfirstsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getFirstSync<T>(source: string, params: SQLiteBindParams): T | null;\n /**\n * @hidden\n */\n public getFirstSync<T>(source: string, ...params: SQLiteVariadicBindParams): T | null;\n public getFirstSync<T>(source: string, ...params: any[]): T | null {\n const statement = this.prepareSync(source);\n let firstRow: T | null;\n try {\n const result = statement.executeSync<T>(...params);\n firstRow = result.getFirstSync();\n } finally {\n statement.finalizeSync();\n }\n return firstRow;\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult`](#sqliteexecutesyncresult) `Iterator`, and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n * @returns This function returns an [`IterableIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator). You can use `for...of` to iterate over the rows from the SQLite query result.\n */\n public getEachSync<T>(source: string, params: SQLiteBindParams): IterableIterator<T>;\n /**\n * @hidden\n */\n public getEachSync<T>(source: string, ...params: SQLiteVariadicBindParams): IterableIterator<T>;\n public *getEachSync<T>(source: string, ...params: any[]): IterableIterator<T> {\n const statement = this.prepareSync(source);\n try {\n const result = statement.executeSync<T>(...params);\n for (const row of result) {\n yield row;\n }\n } finally {\n statement.finalizeSync();\n }\n }\n\n /**\n * A convenience wrapper around [`SQLiteDatabase.prepareSync()`](#preparesyncsource), [`SQLiteStatement.executeSync()`](#executesyncparams), [`SQLiteExecuteSyncResult.getAllSync()`](#getallsync), and [`SQLiteStatement.finalizeSync()`](#finalizesync).\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n * @param source A string containing the SQL query.\n * @param params The parameters to bind to the prepared statement. You can pass values in array, object, or variadic arguments. See [`SQLiteBindValue`](#sqlitebindvalue) for more information about binding values.\n */\n public getAllSync<T>(source: string, params: SQLiteBindParams): T[];\n /**\n * @hidden\n */\n public getAllSync<T>(source: string, ...params: SQLiteVariadicBindParams): T[];\n public getAllSync<T>(source: string, ...params: any[]): T[] {\n const statement = this.prepareSync(source);\n let allRows;\n try {\n const result = statement.executeSync<T>(...params);\n allRows = result.getAllSync();\n } finally {\n statement.finalizeSync();\n }\n return allRows;\n }\n\n /**\n * Synchronize the local database with the remote libSQL server.\n * This method is only available from libSQL integration.\n */\n public syncLibSQL(): Promise<void> {\n if (typeof this.nativeDatabase.syncLibSQL !== 'function') {\n throw new Error('syncLibSQL is not supported in the current environment');\n }\n return this.nativeDatabase.syncLibSQL();\n }\n\n //#endregion\n}\n\n/**\n * The default directory for SQLite databases.\n */\nexport const defaultDatabaseDirectory = ExpoSQLite.defaultDatabaseDirectory;\n\n/**\n * The pre-bundled SQLite extensions.\n */\nexport const bundledExtensions: Record<\n string,\n { libPath: string; entryPoint: string } | undefined\n> = ExpoSQLite.bundledExtensions;\n\n/**\n * Open a database.\n *\n * @param databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport async function openDatabaseAsync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n await ExpoSQLite.ensureDatabasePathExistsAsync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n await nativeDatabase.initAsync();\n return new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n}\n\n/**\n * Open a database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the database file to open.\n * @param options Open options.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`. This parameter is not supported on web.\n */\nexport function openDatabaseSync(\n databaseName: string,\n options?: SQLiteOpenOptions,\n directory?: string\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const databasePath = createDatabasePath(databaseName, directory);\n ExpoSQLite.ensureDatabasePathExistsSync(databasePath);\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n databasePath,\n flattenOpenOptions(openOptions)\n );\n nativeDatabase.initSync();\n return new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeAsync()`](#serializeasyncdatabasename).\n * @param options Open options.\n */\nexport async function deserializeDatabaseAsync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): Promise<SQLiteDatabase> {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n await nativeDatabase.initAsync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param serializedData The binary array to deserialize from [`SQLiteDatabase.serializeSync()`](#serializesyncdatabasename)\n * @param options Open options.\n */\nexport function deserializeDatabaseSync(\n serializedData: Uint8Array,\n options?: SQLiteOpenOptions\n): SQLiteDatabase {\n const openOptions = options ?? {};\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n ':memory:',\n flattenOpenOptions(openOptions),\n serializedData\n );\n nativeDatabase.initSync();\n return new SQLiteDatabase(':memory:', openOptions, nativeDatabase);\n}\n\n/**\n * Delete a database file.\n *\n * @param databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport async function deleteDatabaseAsync(databaseName: string, directory?: string): Promise<void> {\n const databasePath = createDatabasePath(databaseName, directory);\n return await ExpoSQLite.deleteDatabaseAsync(databasePath);\n}\n\n/**\n * Delete a database file.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @param databaseName The name of the database file to delete.\n * @param directory The directory where the database file is located. The default value is `defaultDatabaseDirectory`.\n */\nexport function deleteDatabaseSync(databaseName: string, directory?: string): void {\n const databasePath = createDatabasePath(databaseName, directory);\n return ExpoSQLite.deleteDatabaseSync(databasePath);\n}\n\n/**\n * Backup a database to another database.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseAsync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): Promise<void> {\n return ExpoSQLite.backupDatabaseAsync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\n}\n\n/**\n * Backup a database to another database.\n *\n * > **Note:** Running heavy tasks with this function can block the JavaScript thread and affect performance.\n *\n * @see https://www.sqlite.org/c3ref/backup_finish.html\n *\n * @param options - The backup options\n * @param options.sourceDatabase - The source database to backup from\n * @param options.sourceDatabaseName - The name of the source database. The default value is `main`\n * @param options.destDatabase - The destination database to backup to\n * @param options.destDatabaseName - The name of the destination database. The default value is `m\n */\nexport function backupDatabaseSync({\n sourceDatabase,\n sourceDatabaseName,\n destDatabase,\n destDatabaseName,\n}: {\n sourceDatabase: SQLiteDatabase;\n sourceDatabaseName?: string;\n destDatabase: SQLiteDatabase;\n destDatabaseName?: string;\n}): void {\n return ExpoSQLite.backupDatabaseSync(\n destDatabase.nativeDatabase,\n destDatabaseName ?? 'main',\n sourceDatabase.nativeDatabase,\n sourceDatabaseName ?? 'main'\n );\n}\n\n/**\n * The event payload for the listener of [`addDatabaseChangeListener`](#sqliteadddatabasechangelistenerlistener)\n */\nexport type DatabaseChangeEvent = {\n /** The database name. The value would be `main` by default and other database names if you use `ATTACH DATABASE` statement. */\n databaseName: string;\n\n /** The absolute file path to the database. */\n databaseFilePath: string;\n\n /** The table name. */\n tableName: string;\n\n /** The changed row ID. */\n rowId: number;\n};\n\n/**\n * Add a listener for database changes.\n * > Note: to enable this feature, you must set [`enableChangeListener` to `true`](#sqliteopenoptions) when opening the database.\n *\n * @param listener A function that receives the `databaseName`, `databaseFilePath`, `tableName` and `rowId` of the modified data.\n * @returns A `Subscription` object that you can call `remove()` on when you would like to unsubscribe the listener.\n */\nexport function addDatabaseChangeListener(\n listener: (event: DatabaseChangeEvent) => void\n): EventSubscription {\n return ExpoSQLite.addListener('onDatabaseChange', listener);\n}\n\n/**\n * A new connection specific used for [`withExclusiveTransactionAsync`](#withexclusivetransactionasynctask).\n * @hidden not going to pull all the database methods to the document.\n */\nclass Transaction extends SQLiteDatabase {\n public static async createAsync(db: SQLiteDatabase): Promise<Transaction> {\n const options = { ...db.options, useNewConnection: true };\n const nativeDatabase = new ExpoSQLite.NativeDatabase(\n db.databasePath,\n flattenOpenOptions(options)\n );\n await nativeDatabase.initAsync();\n return new Transaction(db.databasePath, options, nativeDatabase);\n }\n}\n"]}
|
package/expo-module.config.json
CHANGED
package/ios/ExpoSQLite.podspec
CHANGED
|
@@ -14,6 +14,7 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.homepage = package['homepage']
|
|
15
15
|
s.platforms = {
|
|
16
16
|
:ios => '15.1',
|
|
17
|
+
:tvos => '15.1',
|
|
17
18
|
:osx => '11.0'
|
|
18
19
|
}
|
|
19
20
|
s.source = { git: 'https://github.com/expo/expo.git' }
|
|
@@ -36,11 +37,11 @@ Pod::Spec.new do |s|
|
|
|
36
37
|
|
|
37
38
|
sqlite_cflags = '-DHAVE_USLEEP=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_ENABLE_BYTECODE_VTAB=1 -DSQLITE_TEMP_STORE=2'
|
|
38
39
|
sqlite_cflags << ' -DSQLITE_ENABLE_SESSION=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1'
|
|
39
|
-
unless podfile_properties['expo.sqlite.enableFTS']
|
|
40
|
+
unless podfile_properties['expo.sqlite.enableFTS'] == 'false'
|
|
40
41
|
sqlite_cflags << ' -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1'
|
|
41
42
|
end
|
|
42
43
|
|
|
43
|
-
if podfile_properties['expo.sqlite.useSQLCipher']
|
|
44
|
+
if podfile_properties['expo.sqlite.useSQLCipher'] == 'true'
|
|
44
45
|
s.vendor_sqlite_src!(true)
|
|
45
46
|
# SQLCipher will have build error in sqlite3.c on debug build without the `-DNDEBUG`
|
|
46
47
|
sqlite_cflags << ' -DSQLITE_HAS_CODEC=1 -DSQLCIPHER_CRYPTO_CC -DSQLITE_EXTRA_INIT=sqlcipher_extra_init -DSQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown -DNDEBUG'
|
|
@@ -56,6 +57,10 @@ Pod::Spec.new do |s|
|
|
|
56
57
|
# Consistent SQLite build flags for Swift module exposing from the umbrella header
|
|
57
58
|
swift_flags = sqlite_cflags.split(' ').map { |flag| "-Xcc #{flag}" }.join(' ')
|
|
58
59
|
|
|
60
|
+
if podfile_properties['expo.sqlite.withSQLiteVecExtension'] == 'true'
|
|
61
|
+
swift_flags += ' -DWITH_SQLITE_VEC'
|
|
62
|
+
end
|
|
63
|
+
|
|
59
64
|
# Swift/Objective-C compatibility
|
|
60
65
|
s.pod_target_xcconfig = {
|
|
61
66
|
'DEFINES_MODULE' => 'YES',
|
|
@@ -66,7 +71,7 @@ Pod::Spec.new do |s|
|
|
|
66
71
|
s.source_files = "**/*.{c,h,m,swift}"
|
|
67
72
|
|
|
68
73
|
vendored_frameworks = []
|
|
69
|
-
if podfile_properties['expo.sqlite.useLibSQL']
|
|
74
|
+
if podfile_properties['expo.sqlite.useLibSQL'] == 'true'
|
|
70
75
|
vendored_frameworks << 'libsql.xcframework'
|
|
71
76
|
s.private_header_files = [
|
|
72
77
|
'libsql.xcframework/**/*.h',
|
|
@@ -76,6 +81,9 @@ Pod::Spec.new do |s|
|
|
|
76
81
|
else
|
|
77
82
|
s.exclude_files = ['libsql/**/*', 'libsql.xcframework/**/*', 'SQLiteModuleLibSQL.swift']
|
|
78
83
|
end
|
|
84
|
+
if podfile_properties['expo.sqlite.withSQLiteVecExtension'] == 'true'
|
|
85
|
+
vendored_frameworks << 'vec.xcframework'
|
|
86
|
+
end
|
|
79
87
|
|
|
80
88
|
s.ios.vendored_frameworks = vendored_frameworks
|
|
81
89
|
end
|