expo-sqlite 15.1.0 → 15.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/android/build.gradle +2 -2
  3. package/android/libsql/arm64-v8a/libsql_experimental.so +0 -0
  4. package/android/libsql/armeabi-v7a/libsql_experimental.so +0 -0
  5. package/android/libsql/libsql.h +1 -0
  6. package/android/libsql/x86/libsql_experimental.so +0 -0
  7. package/android/libsql/x86_64/libsql_experimental.so +0 -0
  8. package/android/src/main/cpp/libsql/NativeDatabaseBinding.cpp +14 -3
  9. package/android/src/main/cpp/libsql/NativeDatabaseBinding.h +2 -1
  10. package/android/src/main/java/expo/modules/sqlite/NativeDatabaseBinding.kt +2 -1
  11. package/android/src/main/java/expo/modules/sqlite/SQLiteModule.kt +8 -1
  12. package/android/src/main/java/expo/modules/sqlite/SQLiteOptions.kt +1 -4
  13. package/build/NativeDatabase.d.ts +1 -7
  14. package/build/NativeDatabase.d.ts.map +1 -1
  15. package/build/NativeDatabase.js +0 -1
  16. package/build/NativeDatabase.js.map +1 -1
  17. package/build/SQLiteDatabase.d.ts +5 -0
  18. package/build/SQLiteDatabase.d.ts.map +1 -1
  19. package/build/SQLiteDatabase.js +10 -0
  20. package/build/SQLiteDatabase.js.map +1 -1
  21. package/ios/SQLiteModuleLibSQL.swift +11 -2
  22. package/ios/SQLiteOptions.swift +1 -5
  23. package/ios/libsql.xcframework/Info.plist +4 -4
  24. package/ios/libsql.xcframework/ios-arm64/libsql.framework/Headers/libsql.h +1 -0
  25. package/ios/libsql.xcframework/ios-arm64/libsql.framework/libsql +0 -0
  26. package/ios/libsql.xcframework/ios-arm64-simulator/libsql.framework/Headers/libsql.h +1 -0
  27. package/ios/libsql.xcframework/ios-arm64-simulator/libsql.framework/libsql +0 -0
  28. package/package.json +2 -2
  29. package/src/NativeDatabase.ts +2 -9
  30. package/src/SQLiteDatabase.ts +11 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 15.1.2 — 2025-02-05
14
+
15
+ ### 💡 Others
16
+
17
+ - Added offline-writes support for libSQL. ([#34673](https://github.com/expo/expo/pull/34673) by [@kudo](https://github.com/kudo))
18
+
19
+ ## 15.1.1 — 2025-01-28
20
+
21
+ ### 🐛 Bug fixes
22
+
23
+ - Fixed resolving libsql binary issue on iOS. ([#34529](https://github.com/expo/expo/pull/34529) by [@kudo](https://github.com/kudo))
24
+
13
25
  ## 15.1.0 — 2025-01-27
14
26
 
15
27
  ### 🎉 New features
@@ -3,7 +3,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
3
3
  apply plugin: 'com.android.library'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '15.1.0'
6
+ version = '15.1.2'
7
7
 
8
8
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
9
  apply from: expoModulesCorePlugin
@@ -54,7 +54,7 @@ android {
54
54
  namespace "expo.modules.sqlite"
55
55
  defaultConfig {
56
56
  versionCode 18
57
- versionName "15.1.0"
57
+ versionName "15.1.2"
58
58
  buildConfigField "boolean", "USE_LIBSQL", project.ext.USE_LIBSQL.toString()
59
59
 
60
60
  externalNativeBuild {
@@ -40,6 +40,7 @@ typedef struct {
40
40
  const char *encryption_key;
41
41
  int sync_interval;
42
42
  char with_webpki;
43
+ char offline;
43
44
  } libsql_config;
44
45
 
45
46
  typedef const libsql_connection *libsql_connection_t;
@@ -44,6 +44,7 @@ void NativeDatabaseBinding::registerNatives() {
44
44
  makeNativeMethod("libsql_open_remote",
45
45
  NativeDatabaseBinding::libsql_open_remote),
46
46
  makeNativeMethod("libsql_open", NativeDatabaseBinding::libsql_open),
47
+ makeNativeMethod("libsql_sync", NativeDatabaseBinding::libsql_sync),
47
48
  makeNativeMethod("convertSqlLiteErrorToString",
48
49
  NativeDatabaseBinding::convertSqlLiteErrorToString),
49
50
  });
@@ -147,8 +148,7 @@ int NativeDatabaseBinding::libsql_open_remote(const std::string &url,
147
148
 
148
149
  int NativeDatabaseBinding::libsql_open(const std::string &dbPath,
149
150
  const std::string &url,
150
- const std::string &authToken,
151
- int syncInterval) {
151
+ const std::string &authToken) {
152
152
  const char *errMsg;
153
153
  libsql_config config = {
154
154
  .db_path = dbPath.c_str(),
@@ -156,8 +156,9 @@ int NativeDatabaseBinding::libsql_open(const std::string &dbPath,
156
156
  .auth_token = authToken.c_str(),
157
157
  .read_your_writes = 1,
158
158
  .encryption_key = nullptr,
159
- .sync_interval = syncInterval,
159
+ .sync_interval = 0,
160
160
  .with_webpki = 1,
161
+ .offline = 1,
161
162
  };
162
163
  int ret = ::libsql_open_sync_with_config(config, &db, &errMsg);
163
164
  if (ret != 0) {
@@ -172,6 +173,16 @@ int NativeDatabaseBinding::libsql_open(const std::string &dbPath,
172
173
  return 0;
173
174
  }
174
175
 
176
+ int NativeDatabaseBinding::libsql_sync() {
177
+ const char *errMsg;
178
+ int ret = ::libsql_sync(db, &errMsg);
179
+ if (ret != 0) {
180
+ jni::throwNewJavaException(SQLiteErrorException::create(errMsg).get());
181
+ return ret;
182
+ }
183
+ return 0;
184
+ }
185
+
175
186
  jni::local_ref<jni::JString>
176
187
  NativeDatabaseBinding::convertSqlLiteErrorToString() {
177
188
  jni::throwNewJavaException(UnsupportedOperationException::create().get());
@@ -41,7 +41,8 @@ public:
41
41
 
42
42
  int libsql_open_remote(const std::string &url, const std::string &authToken);
43
43
  int libsql_open(const std::string &dbPath, const std::string &url,
44
- const std::string &authToken, int syncInterval);
44
+ const std::string &authToken);
45
+ int libsql_sync();
45
46
 
46
47
  // helpers
47
48
  jni::local_ref<jni::JString> convertSqlLiteErrorToString();
@@ -57,7 +57,8 @@ internal class NativeDatabaseBinding : Closeable {
57
57
  private external fun sqlite3_update_hook(enabled: Boolean) // Keeps it private internally and uses `enableUpdateHook` publicly
58
58
 
59
59
  external fun libsql_open_remote(url: String, authToken: String): Int
60
- external fun libsql_open(dbPath: String, url: String, authToken: String, syncInterval: Int): Int
60
+ external fun libsql_open(dbPath: String, url: String, authToken: String): Int
61
+ external fun libsql_sync(): Int
61
62
 
62
63
  external fun convertSqlLiteErrorToString(): String
63
64
 
@@ -98,7 +98,7 @@ class SQLiteModule : Module() {
98
98
  if (options.libSQLRemoteOnly) {
99
99
  database.ref.libsql_open_remote(libSQLUrl, libSQLAuthToken)
100
100
  } else {
101
- database.ref.libsql_open(dbPath, libSQLUrl, libSQLAuthToken, options.libSQLSyncInterval)
101
+ database.ref.libsql_open(dbPath, libSQLUrl, libSQLAuthToken)
102
102
  }
103
103
  } else {
104
104
  if (database.ref.sqlite3_open(dbPath) != NativeDatabaseBinding.SQLITE_OK) {
@@ -156,6 +156,13 @@ class SQLiteModule : Module() {
156
156
  Function("prepareSync") { database: NativeDatabase, statement: NativeStatement, source: String ->
157
157
  prepareStatement(database, statement, source)
158
158
  }
159
+
160
+ AsyncFunction("syncLibSQL") { database: NativeDatabase ->
161
+ maybeThrowForClosedDatabase(database)
162
+ if (database.ref.libsql_sync() != NativeDatabaseBinding.SQLITE_OK) {
163
+ throw SQLiteErrorException(database.ref.convertSqlLiteErrorToString())
164
+ }
165
+ }
159
166
  }
160
167
 
161
168
  Class(NativeStatement::class) {
@@ -25,8 +25,5 @@ internal data class OpenDatabaseOptions(
25
25
  val libSQLAuthToken: String? = null,
26
26
 
27
27
  @Field
28
- val libSQLRemoteOnly: Boolean = false,
29
-
30
- @Field
31
- val libSQLSyncInterval: Int = 0
28
+ val libSQLRemoteOnly: Boolean = false
32
29
  ) : Record
@@ -16,6 +16,7 @@ export declare class NativeDatabase {
16
16
  execSync(source: string): void;
17
17
  serializeSync(databaseName: string): Uint8Array;
18
18
  prepareSync(nativeStatement: NativeStatement, source: string): NativeStatement;
19
+ syncLibSQL(): void;
19
20
  }
20
21
  /**
21
22
  * Options for opening a database.
@@ -56,19 +57,12 @@ export interface SQLiteOpenOptions {
56
57
  * @default false
57
58
  */
58
59
  remoteOnly?: boolean;
59
- /**
60
- * The interval to sync the local database with the remote database.
61
- * Only works when `remoteOnly` is `false`.
62
- * @default 0 and disable automatic sync.
63
- */
64
- syncInterval?: number;
65
60
  };
66
61
  }
67
62
  type FlattenedOpenOptions = Omit<SQLiteOpenOptions, 'libSQLOptions'> & {
68
63
  libSQLUrl?: string;
69
64
  libSQLAuthToken?: string;
70
65
  libSQLRemoteOnly?: boolean;
71
- libSQLSyncInterval?: number;
72
66
  };
73
67
  /**
74
68
  * Flattens the SQLiteOpenOptions that are passed to the native module.
@@ -1 +1 @@
1
- {"version":3,"file":"NativeDatabase.d.ts","sourceRoot":"","sources":["../src/NativeDatabase.ts"],"names":[],"mappings":"AAAA,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,UAAU;IAInF,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAC1B,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;IACxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAC3B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACxC,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IACzD,YAAY,CAAC,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAMxF,QAAQ,IAAI,IAAI;IAChB,mBAAmB,IAAI,OAAO;IAC9B,SAAS,IAAI,IAAI;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAC9B,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU;IAC/C,WAAW,CAAC,eAAe,EAAE,eAAe,EAAE,M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anF"}
@@ -11,7 +11,6 @@ export function flattenOpenOptions(options) {
11
11
  libSQLUrl: libSQLOptions.url,
12
12
  libSQLAuthToken: libSQLOptions.authToken,
13
13
  libSQLRemoteOnly: libSQLOptions.remoteOnly,
14
- libSQLSyncInterval: libSQLOptions.syncInterval,
15
14
  });
16
15
  }
17
16
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeDatabase.js","sourceRoot":"","sources":["../src/NativeDatabase.ts"],"names":[],"mappings":"AA6FA;;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;QACjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;YACpB,SAAS,EAAE,aAAa,CAAC,GAAG;YAC5B,eAAe,EAAE,aAAa,CAAC,SAAS;YACxC,gBAAgB,EAAE,aAAa,CAAC,UAAU;YAC1C,kBAAkB,EAAE,aAAa,CAAC,YAAY;SAC/C,CAAC,CAAC;KACJ;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { 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\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\n //#endregion\n}\n\n/**\n * Options for opening a database.\n */\nexport interface SQLiteOpenOptions {\n /**\n * Whether to enable the CR-SQLite extension.\n * @default false\n * @deprecated CR-SQLite is no longer actively maintained. Its support is deprecated in SDK 52, and the option will be removed in SDK 53.\n */\n enableCRSQLite?: boolean;\n\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 * The interval to sync the local database with the remote database.\n * Only works when `remoteOnly` is `false`.\n * @default 0 and disable automatic sync.\n */\n syncInterval?: number;\n };\n}\n\ntype FlattenedOpenOptions = Omit<SQLiteOpenOptions, 'libSQLOptions'> & {\n libSQLUrl?: string;\n libSQLAuthToken?: string;\n libSQLRemoteOnly?: boolean;\n libSQLSyncInterval?: number;\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 libSQLSyncInterval: libSQLOptions.syncInterval,\n });\n }\n return result;\n}\n"]}
1
+ {"version":3,"file":"NativeDatabase.js","sourceRoot":"","sources":["../src/NativeDatabase.ts"],"names":[],"mappings":"AAuFA;;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;QACjB,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;KACJ;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { 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\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\n //#endregion\n\n public syncLibSQL(): void;\n}\n\n/**\n * Options for opening a database.\n */\nexport interface SQLiteOpenOptions {\n /**\n * Whether to enable the CR-SQLite extension.\n * @default false\n * @deprecated CR-SQLite is no longer actively maintained. Its support is deprecated in SDK 52, and the option will be removed in SDK 53.\n */\n enableCRSQLite?: boolean;\n\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"]}
@@ -218,6 +218,11 @@ export declare class SQLiteDatabase {
218
218
  * @hidden
219
219
  */
220
220
  getAllSync<T>(source: string, ...params: SQLiteVariadicBindParams): T[];
221
+ /**
222
+ * Synchronize the local database with the remote libSQL server.
223
+ * This method is only available from libSQL integration.
224
+ */
225
+ syncLibSQL(): void;
221
226
  }
222
227
  /**
223
228
  * The default directory for SQLite databases.
@@ -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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BAAgB,uBAAuB,CACrC,cAAc,EAAE,UAAU,EAC1B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,CAUhB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGjG;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAGjF;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,+HAA+H;IAC/H,YAAY,EAAE,MAAM,CAAC;IAErB,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,CAAC;IAEzB,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAElB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAC7C,iBAAiB,CAEnB;AAED;;;GAGG;AACH,cAAM,WAAY,SAAQ,cAAc;WAClB,WAAW,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;CAU1E"}
@@ -282,6 +282,16 @@ export class SQLiteDatabase {
282
282
  }
283
283
  return allRows;
284
284
  }
285
+ /**
286
+ * Synchronize the local database with the remote libSQL server.
287
+ * This method is only available from libSQL integration.
288
+ */
289
+ syncLibSQL() {
290
+ if (typeof this.nativeDatabase.syncLibSQL !== 'function') {
291
+ throw new Error('syncLibSQL is not supported in the current environment');
292
+ }
293
+ return this.nativeDatabase.syncLibSQL();
294
+ }
285
295
  }
286
296
  /**
287
297
  * The default directory for SQLite databases.
@@ -1 +1 @@
1
- {"version":3,"file":"SQLiteDatabase.js","sourceRoot":"","sources":["../src/SQLiteDatabase.ts"],"names":[],"mappings":"AAEA,OAAO,UAA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QACtC,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;AAED,2DAA2D;AAC3D,SAAS,4BAA4B,CAAC,WAAiD;IACrF,MAAM,cAAc,GAAG,WAAW,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5D,IAAI,CAAC,cAAc,IAAI,OAAO,KAAK,IAAI,IAAI,2BAA2B,EAAE;QACtE,OAAO;KACR;IACD,OAAO,CAAC,IAAI,CACV,mIAAmI,CACpI,CAAC;IACF,2BAA2B,GAAG,IAAI,CAAC;AACrC,CAAC","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport { flattenOpenOptions, NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';\nimport {\n SQLiteBindParams,\n SQLiteExecuteAsyncResult,\n SQLiteExecuteSyncResult,\n SQLiteRunResult,\n SQLiteStatement,\n SQLiteVariadicBindParams,\n} from './SQLiteStatement';\nimport { createDatabasePath } from './pathUtils';\n\nexport { SQLiteOpenOptions };\n\nlet memoWarnCRSQLiteDeprecation = false;\n\n/**\n * A SQLite database.\n */\nexport class SQLiteDatabase {\n constructor(\n public readonly databasePath: string,\n public readonly options: SQLiteOpenOptions,\n private 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 * 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 * @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 * @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 * @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 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 * 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 //#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`.\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 maybeWarnCRSQLiteDeprecation(options);\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`.\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 maybeWarnCRSQLiteDeprecation(options);\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 maybeWarnCRSQLiteDeprecation(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 maybeWarnCRSQLiteDeprecation(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 * 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 maybeWarnCRSQLiteDeprecation(options);\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\n// TODO(kudo,20241017) - Remove `enableCRSQLite` in SDK 53.\nfunction maybeWarnCRSQLiteDeprecation(openOptions: SQLiteOpenOptions | undefined | null) {\n const enableCRSQLite = openOptions?.enableCRSQLite === true;\n if (!enableCRSQLite || __DEV__ !== true || memoWarnCRSQLiteDeprecation) {\n return;\n }\n console.warn(\n 'CR-SQLite is no longer actively maintained. The experimental `enableCRSQLite` option is deprecated and will be removed in SDK 53.'\n );\n memoWarnCRSQLiteDeprecation = true;\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,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,4BAA4B,CAAC,OAAO,CAAC,CAAC;QACtC,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;AAED,2DAA2D;AAC3D,SAAS,4BAA4B,CAAC,WAAiD;IACrF,MAAM,cAAc,GAAG,WAAW,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5D,IAAI,CAAC,cAAc,IAAI,OAAO,KAAK,IAAI,IAAI,2BAA2B,EAAE;QACtE,OAAO;KACR;IACD,OAAO,CAAC,IAAI,CACV,mIAAmI,CACpI,CAAC;IACF,2BAA2B,GAAG,IAAI,CAAC;AACrC,CAAC","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport { flattenOpenOptions, NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';\nimport {\n SQLiteBindParams,\n SQLiteExecuteAsyncResult,\n SQLiteExecuteSyncResult,\n SQLiteRunResult,\n SQLiteStatement,\n SQLiteVariadicBindParams,\n} from './SQLiteStatement';\nimport { createDatabasePath } from './pathUtils';\n\nexport { SQLiteOpenOptions };\n\nlet memoWarnCRSQLiteDeprecation = false;\n\n/**\n * A SQLite database.\n */\nexport class SQLiteDatabase {\n constructor(\n public readonly databasePath: string,\n public readonly options: SQLiteOpenOptions,\n private 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 * 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 * @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 * @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 * @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 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 * 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(): 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`.\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 maybeWarnCRSQLiteDeprecation(options);\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`.\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 maybeWarnCRSQLiteDeprecation(options);\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 maybeWarnCRSQLiteDeprecation(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 maybeWarnCRSQLiteDeprecation(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 * 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 maybeWarnCRSQLiteDeprecation(options);\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\n// TODO(kudo,20241017) - Remove `enableCRSQLite` in SDK 53.\nfunction maybeWarnCRSQLiteDeprecation(openOptions: SQLiteOpenOptions | undefined | null) {\n const enableCRSQLite = openOptions?.enableCRSQLite === true;\n if (!enableCRSQLite || __DEV__ !== true || memoWarnCRSQLiteDeprecation) {\n return;\n }\n console.warn(\n 'CR-SQLite is no longer actively maintained. The experimental `enableCRSQLite` option is deprecated and will be removed in SDK 53.'\n );\n memoWarnCRSQLiteDeprecation = true;\n}\n"]}
@@ -111,8 +111,9 @@ public final class SQLiteModule: Module {
111
111
  auth_token: libSQLAuthToken,
112
112
  read_your_writes: 1,
113
113
  encryption_key: nil,
114
- sync_interval: Int32(options.libSQLSyncInterval),
115
- with_webpki: 1)
114
+ sync_interval: 0,
115
+ with_webpki: 1,
116
+ offline: 1)
116
117
  result = libsql_open_sync_with_config(libSQLConfig, &db, &errMsg)
117
118
  }
118
119
  }
@@ -176,6 +177,14 @@ public final class SQLiteModule: Module {
176
177
  Function("prepareSync") { (database: NativeDatabase, statement: NativeStatement, source: String) in
177
178
  try prepareStatement(database: database, statement: statement, source: source)
178
179
  }
180
+
181
+ AsyncFunction("syncLibSQL") { (database: NativeDatabase) in
182
+ var errMsg: UnsafePointer<CChar>?
183
+ if libsql_sync(database.pointer, &errMsg) != 0 {
184
+ let err = convertLibSqlErrorToString(errMsg)
185
+ throw SQLiteErrorException(convertLibSqlErrorToString(errMsg))
186
+ }
187
+ }
179
188
  }
180
189
 
181
190
  // swiftlint:disable:next closure_body_length
@@ -24,9 +24,6 @@ struct OpenDatabaseOptions: Record, Equatable {
24
24
  @Field
25
25
  var libSQLRemoteOnly: Bool = false
26
26
 
27
- @Field
28
- var libSQLSyncInterval: Int = 0
29
-
30
27
  // MARK: - Equatable
31
28
 
32
29
  static func == (lhs: OpenDatabaseOptions, rhs: OpenDatabaseOptions) -> Bool {
@@ -36,7 +33,6 @@ struct OpenDatabaseOptions: Record, Equatable {
36
33
  lhs.finalizeUnusedStatementsBeforeClosing == rhs.finalizeUnusedStatementsBeforeClosing &&
37
34
  lhs.libSQLUrl == rhs.libSQLUrl &&
38
35
  lhs.libSQLAuthToken == rhs.libSQLAuthToken &&
39
- lhs.libSQLRemoteOnly == rhs.libSQLRemoteOnly &&
40
- lhs.libSQLSyncInterval == rhs.libSQLSyncInterval
36
+ lhs.libSQLRemoteOnly == rhs.libSQLRemoteOnly
41
37
  }
42
38
  }
@@ -8,7 +8,7 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>libsql.framework/libsql</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64</string>
11
+ <string>ios-arm64-simulator</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>libsql.framework</string>
14
14
  <key>SupportedArchitectures</key>
@@ -17,12 +17,14 @@
17
17
  </array>
18
18
  <key>SupportedPlatform</key>
19
19
  <string>ios</string>
20
+ <key>SupportedPlatformVariant</key>
21
+ <string>simulator</string>
20
22
  </dict>
21
23
  <dict>
22
24
  <key>BinaryPath</key>
23
25
  <string>libsql.framework/libsql</string>
24
26
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64-simulator</string>
27
+ <string>ios-arm64</string>
26
28
  <key>LibraryPath</key>
27
29
  <string>libsql.framework</string>
28
30
  <key>SupportedArchitectures</key>
@@ -31,8 +33,6 @@
31
33
  </array>
32
34
  <key>SupportedPlatform</key>
33
35
  <string>ios</string>
34
- <key>SupportedPlatformVariant</key>
35
- <string>simulator</string>
36
36
  </dict>
37
37
  </array>
38
38
  <key>CFBundlePackageType</key>
@@ -40,6 +40,7 @@ typedef struct {
40
40
  const char *encryption_key;
41
41
  int sync_interval;
42
42
  char with_webpki;
43
+ char offline;
43
44
  } libsql_config;
44
45
 
45
46
  typedef const libsql_connection *libsql_connection_t;
@@ -40,6 +40,7 @@ typedef struct {
40
40
  const char *encryption_key;
41
41
  int sync_interval;
42
42
  char with_webpki;
43
+ char offline;
43
44
  } libsql_config;
44
45
 
45
46
  typedef const libsql_connection *libsql_connection_t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-sqlite",
3
- "version": "15.1.0",
3
+ "version": "15.1.2",
4
4
  "description": "Provides access to a database using SQLite (https://www.sqlite.org/). The database is persisted across restarts of your app.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -61,5 +61,5 @@
61
61
  "react": "*",
62
62
  "react-native": "*"
63
63
  },
64
- "gitHead": "3fd37fd31fd818d833e85c4723b1578010da6967"
64
+ "gitHead": "9b69f290e1a2c1d41fd200ae988891364cd6c8a2"
65
65
  }
@@ -27,6 +27,8 @@ export declare class NativeDatabase {
27
27
  public prepareSync(nativeStatement: NativeStatement, source: string): NativeStatement;
28
28
 
29
29
  //#endregion
30
+
31
+ public syncLibSQL(): void;
30
32
  }
31
33
 
32
34
  /**
@@ -74,13 +76,6 @@ export interface SQLiteOpenOptions {
74
76
  * @default false
75
77
  */
76
78
  remoteOnly?: boolean;
77
-
78
- /**
79
- * The interval to sync the local database with the remote database.
80
- * Only works when `remoteOnly` is `false`.
81
- * @default 0 and disable automatic sync.
82
- */
83
- syncInterval?: number;
84
79
  };
85
80
  }
86
81
 
@@ -88,7 +83,6 @@ type FlattenedOpenOptions = Omit<SQLiteOpenOptions, 'libSQLOptions'> & {
88
83
  libSQLUrl?: string;
89
84
  libSQLAuthToken?: string;
90
85
  libSQLRemoteOnly?: boolean;
91
- libSQLSyncInterval?: number;
92
86
  };
93
87
 
94
88
  /**
@@ -104,7 +98,6 @@ export function flattenOpenOptions(options: SQLiteOpenOptions): FlattenedOpenOpt
104
98
  libSQLUrl: libSQLOptions.url,
105
99
  libSQLAuthToken: libSQLOptions.authToken,
106
100
  libSQLRemoteOnly: libSQLOptions.remoteOnly,
107
- libSQLSyncInterval: libSQLOptions.syncInterval,
108
101
  });
109
102
  }
110
103
  return result;
@@ -407,6 +407,17 @@ export class SQLiteDatabase {
407
407
  return allRows;
408
408
  }
409
409
 
410
+ /**
411
+ * Synchronize the local database with the remote libSQL server.
412
+ * This method is only available from libSQL integration.
413
+ */
414
+ public syncLibSQL(): void {
415
+ if (typeof this.nativeDatabase.syncLibSQL !== 'function') {
416
+ throw new Error('syncLibSQL is not supported in the current environment');
417
+ }
418
+ return this.nativeDatabase.syncLibSQL();
419
+ }
420
+
410
421
  //#endregion
411
422
  }
412
423