expo-sqlite 16.0.9 → 16.1.0-canary-20251118-8f7ee64

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 (84) hide show
  1. package/CHANGELOG.md +5 -5
  2. package/android/build.gradle +2 -2
  3. package/build/SQLiteDatabase.d.ts +35 -0
  4. package/build/SQLiteDatabase.d.ts.map +1 -1
  5. package/build/SQLiteDatabase.js +52 -2
  6. package/build/SQLiteDatabase.js.map +1 -1
  7. package/build/SQLiteDevToolsClient.d.ts +9 -0
  8. package/build/SQLiteDevToolsClient.d.ts.map +1 -0
  9. package/build/SQLiteDevToolsClient.js +206 -0
  10. package/build/SQLiteDevToolsClient.js.map +1 -0
  11. package/build/SQLiteTaggedQuery.d.ts +116 -0
  12. package/build/SQLiteTaggedQuery.d.ts.map +1 -0
  13. package/build/SQLiteTaggedQuery.js +160 -0
  14. package/build/SQLiteTaggedQuery.js.map +1 -0
  15. package/build/index.d.ts +1 -0
  16. package/build/index.d.ts.map +1 -1
  17. package/build/index.js +1 -0
  18. package/build/index.js.map +1 -1
  19. package/build/paramUtils.d.ts.map +1 -1
  20. package/build/paramUtils.js +3 -0
  21. package/build/paramUtils.js.map +1 -1
  22. package/build/pathUtils.d.ts +1 -0
  23. package/build/pathUtils.d.ts.map +1 -1
  24. package/build/pathUtils.js +3 -0
  25. package/build/pathUtils.js.map +1 -1
  26. package/build/queryUtils.d.ts +25 -0
  27. package/build/queryUtils.d.ts.map +1 -0
  28. package/build/queryUtils.js +44 -0
  29. package/build/queryUtils.js.map +1 -0
  30. package/dev-plugin-dist/+not-found.html +317 -0
  31. package/dev-plugin-dist/_expo/.routes.json +3 -0
  32. package/dev-plugin-dist/_expo/static/css/global-907315ee35d4ca59dd590c0671386803.css +2 -0
  33. package/dev-plugin-dist/_expo/static/js/web/entry-7d3bdcbe3d24f34acef3975b0a1c90b8.js +14071 -0
  34. package/dev-plugin-dist/_expo/static/js/web/worker-c5107d559366387fe3e229cdc1f04e35.js +22 -0
  35. package/dev-plugin-dist/_sitemap.html +317 -0
  36. package/dev-plugin-dist/index.html +317 -0
  37. package/expo-module.config.json +5 -2
  38. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar +0 -0
  39. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.md5 +1 -0
  40. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.sha1 +1 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.sha256 +1 -0
  42. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.aar.sha512 +1 -0
  43. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.0.9/expo.modules.sqlite-16.0.9.module → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module} +18 -18
  44. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.md5 +1 -0
  45. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.sha1 +1 -0
  46. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.sha256 +1 -0
  47. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.module.sha512 +1 -0
  48. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.0.9/expo.modules.sqlite-16.0.9.pom → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom} +1 -1
  49. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.md5 +1 -0
  50. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.sha1 +1 -0
  51. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.sha256 +1 -0
  52. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64.pom.sha512 +1 -0
  53. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml +4 -4
  54. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.md5 +1 -1
  55. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha1 +1 -1
  56. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha256 +1 -1
  57. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha512 +1 -1
  58. package/package.json +5 -5
  59. package/src/SQLiteDatabase.ts +57 -2
  60. package/src/SQLiteDevToolsClient.ts +279 -0
  61. package/src/SQLiteTaggedQuery.ts +179 -0
  62. package/src/index.ts +1 -0
  63. package/src/paramUtils.ts +2 -0
  64. package/src/pathUtils.ts +4 -0
  65. package/src/queryUtils.ts +55 -0
  66. package/web/wa-sqlite/sqlite-api.js +11 -4
  67. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.aar +0 -0
  68. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.aar.md5 +0 -1
  69. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.aar.sha1 +0 -1
  70. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.aar.sha256 +0 -1
  71. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.aar.sha512 +0 -1
  72. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.module.md5 +0 -1
  73. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.module.sha1 +0 -1
  74. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.module.sha256 +0 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.module.sha512 +0 -1
  76. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.pom.md5 +0 -1
  77. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.pom.sha1 +0 -1
  78. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.pom.sha256 +0 -1
  79. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/16.0.9/expo.modules.sqlite-16.0.9.pom.sha512 +0 -1
  80. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.0.9/expo.modules.sqlite-16.0.9-sources.jar → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar} +0 -0
  81. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.0.9/expo.modules.sqlite-16.0.9-sources.jar.md5 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.md5} +0 -0
  82. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.0.9/expo.modules.sqlite-16.0.9-sources.jar.sha1 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.sha1} +0 -0
  83. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.0.9/expo.modules.sqlite-16.0.9-sources.jar.sha256 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.sha256} +0 -0
  84. /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{16.0.9/expo.modules.sqlite-16.0.9-sources.jar.sha512 → 16.1.0-canary-20251118-8f7ee64/expo.modules.sqlite-16.1.0-canary-20251118-8f7ee64-sources.jar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -6,17 +6,17 @@
6
6
 
7
7
  ### 🎉 New features
8
8
 
9
- ### 🐛 Bug fixes
10
-
11
- ### 💡 Others
12
-
13
- ## 16.0.9 — 2025-11-03
9
+ - Added SQLite inspector devtools plugin. ([#40872](https://github.com/expo/expo/pull/40872), [#40900](https://github.com/expo/expo/pull/40900) by [@kudo](https://github.com/kudo))
10
+ - Added tagged template literals support. ([#40972](https://github.com/expo/expo/pull/40972) by [@kudo](https://github.com/kudo))
14
11
 
15
12
  ### 🐛 Bug fixes
16
13
 
17
14
  - Throwing error when `ExpoSQLite.defaultDatabaseDirectory` returns undefined. ([#40680](https://github.com/expo/expo/pull/40680) by [@kudo](https://github.com/kudo))
18
15
  - Fixed node runtime bundling error on web. ([#40739](https://github.com/expo/expo/pull/40739) by [@kudo](https://github.com/kudo))
19
16
  - Fixed Android 16kb page size issue when enabling `useSQLCipher`. ([#40781](https://github.com/expo/expo/pull/40781) by [@ronickg](https://github.com/ronickg))
17
+ - Fixed `serializeAsync` / `serializeSync` errors from memory database on web. ([#40899](https://github.com/expo/expo/pull/40899) by [@kudo](https://github.com/kudo))
18
+
19
+ ### 💡 Others
20
20
 
21
21
  ## 16.0.8 — 2025-09-10
22
22
 
@@ -46,13 +46,13 @@ def reactNativeArchitectures() {
46
46
  }
47
47
 
48
48
  group = 'host.exp.exponent'
49
- version = '16.0.9'
49
+ version = '16.1.0-canary-20251118-8f7ee64'
50
50
 
51
51
  android {
52
52
  namespace "expo.modules.sqlite"
53
53
  defaultConfig {
54
54
  versionCode 18
55
- versionName "16.0.9"
55
+ versionName "16.1.0-canary-20251118-8f7ee64"
56
56
  buildConfigField "boolean", "USE_LIBSQL", project.ext.USE_LIBSQL.toString()
57
57
  buildConfigField "boolean", "WITH_SQLITE_VEC", project.ext.WITH_SQLITE_VEC.toString()
58
58
 
@@ -2,6 +2,7 @@ import { type EventSubscription } from 'expo-modules-core';
2
2
  import { NativeDatabase, SQLiteOpenOptions } from './NativeDatabase';
3
3
  import { SQLiteSession } from './SQLiteSession';
4
4
  import { SQLiteBindParams, SQLiteRunResult, SQLiteStatement, SQLiteVariadicBindParams } from './SQLiteStatement';
5
+ import { SQLiteTaggedQuery } from './SQLiteTaggedQuery';
5
6
  export { SQLiteOpenOptions };
6
7
  /**
7
8
  * A SQLite database.
@@ -188,6 +189,40 @@ export declare class SQLiteDatabase {
188
189
  * @param task An async function to execute within a transaction.
189
190
  */
190
191
  withTransactionSync(task: () => void): void;
192
+ /**
193
+ * Execute SQL queries using tagged template literals (Bun-style API).
194
+ * Queries are automatically protected against SQL injection using prepared statements.
195
+ *
196
+ * The query result is directly awaitable and returns an array of objects by default.
197
+ * Use `.values()`, `.first()`, or `.each()` for different result formats.
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * // Direct await - returns array of objects
202
+ * const users = await sql<User>`SELECT * FROM users WHERE age > ${21}`;
203
+ *
204
+ * // Get first row only
205
+ * const user = await sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();
206
+ *
207
+ * // Get values as arrays
208
+ * const rows = await sql`SELECT name, age FROM users`.values();
209
+ * // Returns: [["Alice", 30], ["Bob", 25]]
210
+ *
211
+ * // INSERT/UPDATE/DELETE - returns SQLiteRunResult
212
+ * const result = await sql`INSERT INTO users (name, age) VALUES (${name}, ${age})` as SQLiteRunResult;
213
+ * console.log('Inserted row:', result.lastInsertRowId);
214
+ *
215
+ * // Iteration
216
+ * for await (const user of db<User>`SELECT * FROM users`.each()) {
217
+ * console.log(user.name);
218
+ * }
219
+ *
220
+ * // Synchronous API
221
+ * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();
222
+ * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();
223
+ * ```
224
+ */
225
+ sql: <T = unknown>(strings: TemplateStringsArray, ...values: unknown[]) => SQLiteTaggedQuery<T>;
191
226
  /**
192
227
  * A convenience wrapper around [`SQLiteDatabase.prepareAsync()`](#prepareasyncsource), [`SQLiteStatement.executeAsync()`](#executeasyncparams), and [`SQLiteStatement.finalizeAsync()`](#finalizeasync).
193
228
  * @param source A string containing the SQL query.
@@ -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;g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ACD,cAAc,EAAE,cAAc,CAAC;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,cAAc,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,IAAI,CAOP;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;CAS1E"}
@@ -1,8 +1,10 @@
1
1
  import { Platform } from 'react-native';
2
2
  import ExpoSQLite from './ExpoSQLite';
3
3
  import { flattenOpenOptions } from './NativeDatabase';
4
+ import { registerDatabaseForDevToolsAsync, unregisterDatabaseForDevToolsAsync, } from './SQLiteDevToolsClient';
4
5
  import { SQLiteSession } from './SQLiteSession';
5
6
  import { SQLiteStatement, } from './SQLiteStatement';
7
+ import { SQLiteTaggedQuery } from './SQLiteTaggedQuery';
6
8
  import { createDatabasePath } from './pathUtils';
7
9
  /**
8
10
  * A SQLite database.
@@ -26,6 +28,9 @@ export class SQLiteDatabase {
26
28
  * Close the database.
27
29
  */
28
30
  closeAsync() {
31
+ if (this.options.useNewConnection !== true) {
32
+ unregisterDatabaseForDevToolsAsync(this);
33
+ }
29
34
  return this.nativeDatabase.closeAsync();
30
35
  }
31
36
  /**
@@ -179,6 +184,9 @@ export class SQLiteDatabase {
179
184
  * Close the database.
180
185
  */
181
186
  closeSync() {
187
+ if (this.options.useNewConnection !== true) {
188
+ unregisterDatabaseForDevToolsAsync(this);
189
+ }
182
190
  return this.nativeDatabase.closeSync();
183
191
  }
184
192
  /**
@@ -270,6 +278,40 @@ export class SQLiteDatabase {
270
278
  throw e;
271
279
  }
272
280
  }
281
+ /**
282
+ * Execute SQL queries using tagged template literals (Bun-style API).
283
+ * Queries are automatically protected against SQL injection using prepared statements.
284
+ *
285
+ * The query result is directly awaitable and returns an array of objects by default.
286
+ * Use `.values()`, `.first()`, or `.each()` for different result formats.
287
+ *
288
+ * @example
289
+ * ```ts
290
+ * // Direct await - returns array of objects
291
+ * const users = await sql<User>`SELECT * FROM users WHERE age > ${21}`;
292
+ *
293
+ * // Get first row only
294
+ * const user = await sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();
295
+ *
296
+ * // Get values as arrays
297
+ * const rows = await sql`SELECT name, age FROM users`.values();
298
+ * // Returns: [["Alice", 30], ["Bob", 25]]
299
+ *
300
+ * // INSERT/UPDATE/DELETE - returns SQLiteRunResult
301
+ * const result = await sql`INSERT INTO users (name, age) VALUES (${name}, ${age})` as SQLiteRunResult;
302
+ * console.log('Inserted row:', result.lastInsertRowId);
303
+ *
304
+ * // Iteration
305
+ * for await (const user of db<User>`SELECT * FROM users`.each()) {
306
+ * console.log(user.name);
307
+ * }
308
+ *
309
+ * // Synchronous API
310
+ * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();
311
+ * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();
312
+ * ```
313
+ */
314
+ sql = (strings, ...values) => new SQLiteTaggedQuery(this, strings, values);
273
315
  async runAsync(source, ...params) {
274
316
  const statement = await this.prepareAsync(source);
275
317
  let result;
@@ -396,7 +438,11 @@ export async function openDatabaseAsync(databaseName, options, directory) {
396
438
  await ExpoSQLite.ensureDatabasePathExistsAsync(databasePath);
397
439
  const nativeDatabase = new ExpoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
398
440
  await nativeDatabase.initAsync();
399
- return new SQLiteDatabase(databasePath, openOptions, nativeDatabase);
441
+ const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);
442
+ if (options?.useNewConnection !== true) {
443
+ registerDatabaseForDevToolsAsync(database);
444
+ }
445
+ return database;
400
446
  }
401
447
  /**
402
448
  * Open a database.
@@ -413,7 +459,11 @@ export function openDatabaseSync(databaseName, options, directory) {
413
459
  ExpoSQLite.ensureDatabasePathExistsSync(databasePath);
414
460
  const nativeDatabase = new ExpoSQLite.NativeDatabase(databasePath, flattenOpenOptions(openOptions));
415
461
  nativeDatabase.initSync();
416
- return new SQLiteDatabase(databasePath, openOptions, nativeDatabase);
462
+ const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);
463
+ if (options?.useNewConnection !== true) {
464
+ registerDatabaseForDevToolsAsync(database);
465
+ }
466
+ return database;
417
467
  }
418
468
  /**
419
469
  * Given a `Uint8Array` data and [deserialize to memory database](https://sqlite.org/c3ref/deserialize.html).
@@ -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;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;;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 * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * await db.loadExtensionAsync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * await db.loadExtensionAsync('/path/to/extension');\n * ```\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 * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * db.loadExtensionSync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * db.loadExtensionSync('/path/to/extension');\n * ```\n\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"]}
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,EACL,gCAAgC,EAChC,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAKL,eAAe,GAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,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,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;YAC3C,kCAAkC,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,MAAc;QAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;I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AAC;AAED;;;;;;;;;;;;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 {\n registerDatabaseForDevToolsAsync,\n unregisterDatabaseForDevToolsAsync,\n} from './SQLiteDevToolsClient';\nimport { SQLiteSession } from './SQLiteSession';\nimport {\n SQLiteBindParams,\n SQLiteExecuteAsyncResult,\n SQLiteExecuteSyncResult,\n SQLiteRunResult,\n SQLiteStatement,\n SQLiteVariadicBindParams,\n} from './SQLiteStatement';\nimport { SQLiteTaggedQuery } from './SQLiteTaggedQuery';\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 if (this.options.useNewConnection !== true) {\n unregisterDatabaseForDevToolsAsync(this);\n }\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 * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * await db.loadExtensionAsync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * await db.loadExtensionAsync('/path/to/extension');\n * ```\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 if (this.options.useNewConnection !== true) {\n unregisterDatabaseForDevToolsAsync(this);\n }\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 * @example\n * ```ts\n * // Load `sqlite-vec` from `bundledExtensions`. You need to enable `withSQLiteVecExtension` to include `sqlite-vec`.\n * const extension = SQLite.bundledExtensions['sqlite-vec'];\n * db.loadExtensionSync(extension.libPath, extension.entryPoint);\n *\n * // You can also load a custom extension.\n * db.loadExtensionSync('/path/to/extension');\n * ```\n\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 /**\n * Execute SQL queries using tagged template literals (Bun-style API).\n * Queries are automatically protected against SQL injection using prepared statements.\n *\n * The query result is directly awaitable and returns an array of objects by default.\n * Use `.values()`, `.first()`, or `.each()` for different result formats.\n *\n * @example\n * ```ts\n * // Direct await - returns array of objects\n * const users = await sql<User>`SELECT * FROM users WHERE age > ${21}`;\n *\n * // Get first row only\n * const user = await sql<User>`SELECT * FROM users WHERE id = ${userId}`.first();\n *\n * // Get values as arrays\n * const rows = await sql`SELECT name, age FROM users`.values();\n * // Returns: [[\"Alice\", 30], [\"Bob\", 25]]\n *\n * // INSERT/UPDATE/DELETE - returns SQLiteRunResult\n * const result = await sql`INSERT INTO users (name, age) VALUES (${name}, ${age})` as SQLiteRunResult;\n * console.log('Inserted row:', result.lastInsertRowId);\n *\n * // Iteration\n * for await (const user of db<User>`SELECT * FROM users`.each()) {\n * console.log(user.name);\n * }\n *\n * // Synchronous API\n * const users = sql<User>`SELECT * FROM users WHERE age > ${21}`.allSync();\n * const user = sql<User>`SELECT * FROM users WHERE id = ${userId}`.firstSync();\n * ```\n */\n public sql = <T = unknown>(strings: TemplateStringsArray, ...values: unknown[]) =>\n new SQLiteTaggedQuery<T>(this, strings, values);\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 const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n if (options?.useNewConnection !== true) {\n registerDatabaseForDevToolsAsync(database);\n }\n return database;\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 const database = new SQLiteDatabase(databasePath, openOptions, nativeDatabase);\n if (options?.useNewConnection !== true) {\n registerDatabaseForDevToolsAsync(database);\n }\n return database;\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"]}
@@ -0,0 +1,9 @@
1
+ import type { SQLiteDatabase } from './SQLiteDatabase';
2
+ export declare function registerDatabaseForDevToolsAsync(database: SQLiteDatabase): Promise<void>;
3
+ export declare function unregisterDatabaseForDevToolsAsync(database: SQLiteDatabase): Promise<void>;
4
+ /**
5
+ * Close the devtools client.
6
+ * Exposed for testing purposes.
7
+ */
8
+ export declare function closeDevToolsClientAsync(): Promise<void>;
9
+ //# sourceMappingURL=SQLiteDevToolsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SQLiteDevToolsClient.d.ts","sourceRoot":"","sources":["../src/SQLiteDevToolsClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwCvD,wBAAsB,gCAAgC,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9F;AAED,wBAAsB,kCAAkC,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAKhG;AAsBD;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAI9D"}
@@ -0,0 +1,206 @@
1
+ import AwaitLock from 'await-lock';
2
+ import { basename } from './pathUtils';
3
+ const DEVTOOLS_PLUGIN_NAME = 'expo-sqlite';
4
+ const LIST_TABLES_QUERY = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name";
5
+ let client = null;
6
+ const lock = new AwaitLock();
7
+ const registeredDatabases = new Map();
8
+ export async function registerDatabaseForDevToolsAsync(database) {
9
+ if (!__DEV__) {
10
+ return;
11
+ }
12
+ await maybeInitClientAsync();
13
+ registeredDatabases.set(database.databasePath, new WeakRef(database));
14
+ }
15
+ export async function unregisterDatabaseForDevToolsAsync(database) {
16
+ if (!__DEV__) {
17
+ return;
18
+ }
19
+ registeredDatabases.delete(database.databasePath);
20
+ }
21
+ async function maybeInitClientAsync() {
22
+ if (!__DEV__ || client != null) {
23
+ return;
24
+ }
25
+ await lock.acquireAsync();
26
+ try {
27
+ const { getDevToolsPluginClientAsync } = require('expo/devtools');
28
+ client = await getDevToolsPluginClientAsync(DEVTOOLS_PLUGIN_NAME, {
29
+ websocketBinaryType: 'arraybuffer',
30
+ });
31
+ setupDevToolsListeners();
32
+ }
33
+ catch (error) {
34
+ console.warn('Failed to initialize devtools client', error);
35
+ }
36
+ finally {
37
+ lock.release();
38
+ }
39
+ }
40
+ /**
41
+ * Close the devtools client.
42
+ * Exposed for testing purposes.
43
+ */
44
+ export async function closeDevToolsClientAsync() {
45
+ await client?.closeAsync();
46
+ client = null;
47
+ registeredDatabases.clear();
48
+ }
49
+ function setupDevToolsListeners() {
50
+ client?.addMessageListener('listDatabases', async (params) => {
51
+ try {
52
+ const databases = Array.from(registeredDatabases.keys()).map((databasePath) => ({
53
+ name: basename(databasePath),
54
+ path: databasePath,
55
+ }));
56
+ client?.sendMessage('response', {
57
+ requestId: params.requestId,
58
+ method: 'listDatabases',
59
+ databases,
60
+ });
61
+ }
62
+ catch (error) {
63
+ client?.sendMessage('response', {
64
+ requestId: params.requestId,
65
+ method: 'error',
66
+ error: typeof error === 'object' && error !== null && 'message' in error
67
+ ? error.message
68
+ : String(error),
69
+ originalMethod: 'listDatabases',
70
+ });
71
+ }
72
+ });
73
+ // getDatabase uses method:requestId channel to support binary data
74
+ client?.addMessageListener('getDatabase', async (params) => {
75
+ const eventName = `getDatabase:${params.requestId}`;
76
+ try {
77
+ const databasePath = Array.from(registeredDatabases.keys()).find((path) => basename(path) === params.database);
78
+ const database = databasePath ? registeredDatabases.get(databasePath)?.deref() : undefined;
79
+ if (!database || !databasePath) {
80
+ throw new Error('Database not found');
81
+ }
82
+ const serialized = await database.serializeAsync();
83
+ client?.sendMessage(eventName, serialized);
84
+ }
85
+ catch (error) {
86
+ client?.sendMessage(eventName, {
87
+ method: 'error',
88
+ error: typeof error === 'object' && error !== null && 'message' in error
89
+ ? error.message
90
+ : String(error),
91
+ originalMethod: 'getDatabase',
92
+ });
93
+ }
94
+ });
95
+ client?.addMessageListener('executeQuery', async (params) => {
96
+ try {
97
+ const database = registeredDatabases.get(params.databasePath)?.deref();
98
+ if (!database) {
99
+ client?.sendMessage('response', {
100
+ requestId: params.requestId,
101
+ method: 'error',
102
+ error: 'Database not found',
103
+ originalMethod: 'executeQuery',
104
+ });
105
+ return;
106
+ }
107
+ const trimmedQuery = params.query.trim().toUpperCase();
108
+ const isReadQuery = trimmedQuery.startsWith('SELECT') || trimmedQuery.startsWith('PRAGMA');
109
+ let result;
110
+ if (isReadQuery) {
111
+ const rows = await database.getAllAsync(params.query, params.params || []);
112
+ const columns = rows.length > 0 && rows[0] && typeof rows[0] === 'object' ? Object.keys(rows[0]) : [];
113
+ result = { rows, columns };
114
+ }
115
+ else {
116
+ const runResult = await database.runAsync(params.query, params.params || []);
117
+ result = {
118
+ rows: [],
119
+ columns: [],
120
+ changes: runResult.changes,
121
+ lastInsertRowId: runResult.lastInsertRowId,
122
+ };
123
+ }
124
+ client?.sendMessage('response', {
125
+ requestId: params.requestId,
126
+ method: 'executeQuery',
127
+ result,
128
+ });
129
+ }
130
+ catch (error) {
131
+ client?.sendMessage('response', {
132
+ requestId: params.requestId,
133
+ method: 'error',
134
+ error: typeof error === 'object' && error !== null && 'message' in error
135
+ ? error.message
136
+ : String(error),
137
+ originalMethod: 'executeQuery',
138
+ });
139
+ }
140
+ });
141
+ client?.addMessageListener('listTables', async (params) => {
142
+ try {
143
+ const database = registeredDatabases.get(params.databasePath)?.deref();
144
+ if (!database) {
145
+ client?.sendMessage('response', {
146
+ requestId: params.requestId,
147
+ method: 'error',
148
+ error: 'Database not found',
149
+ originalMethod: 'listTables',
150
+ });
151
+ return;
152
+ }
153
+ const tables = (await database.getAllAsync(LIST_TABLES_QUERY));
154
+ client?.sendMessage('response', {
155
+ requestId: params.requestId,
156
+ method: 'listTables',
157
+ tables: tables.map((t) => t.name),
158
+ });
159
+ }
160
+ catch (error) {
161
+ client?.sendMessage('response', {
162
+ requestId: params.requestId,
163
+ method: 'error',
164
+ error: typeof error === 'object' && error !== null && 'message' in error
165
+ ? error.message
166
+ : String(error),
167
+ originalMethod: 'listTables',
168
+ });
169
+ }
170
+ });
171
+ client?.addMessageListener('getTableSchema', async (params) => {
172
+ try {
173
+ const database = registeredDatabases.get(params.databasePath)?.deref();
174
+ if (!database) {
175
+ client?.sendMessage('response', {
176
+ requestId: params.requestId,
177
+ method: 'error',
178
+ error: 'Database not found',
179
+ originalMethod: 'getTableSchema',
180
+ });
181
+ return;
182
+ }
183
+ const tables = (await database.getAllAsync("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [params.tableName]));
184
+ if (tables.length === 0) {
185
+ throw new Error(`Table '${params.tableName}' not found`);
186
+ }
187
+ const schema = (await database.getAllAsync(`PRAGMA table_info(${params.tableName})`));
188
+ client?.sendMessage('response', {
189
+ requestId: params.requestId,
190
+ method: 'getTableSchema',
191
+ schema,
192
+ });
193
+ }
194
+ catch (error) {
195
+ client?.sendMessage('response', {
196
+ requestId: params.requestId,
197
+ method: 'error',
198
+ error: typeof error === 'object' && error !== null && 'message' in error
199
+ ? error.message
200
+ : String(error),
201
+ originalMethod: 'getTableSchema',
202
+ });
203
+ }
204
+ });
205
+ }
206
+ //# sourceMappingURL=SQLiteDevToolsClient.js.map