expo-sqlite 13.2.1 → 13.2.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.
package/CHANGELOG.md CHANGED
@@ -10,7 +10,13 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 13.2.1 — 2024-01-10
13
+ ## 13.2.2 — 2024-01-25
14
+
15
+ ### 💡 Others
16
+
17
+ - Remove `onDatabaseChange` event from legacy API as it is not supported natively. ([#26655](https://github.com/expo/expo/pull/26655) by [@alanjhughes](https://github.com/alanjhughes))
18
+
19
+ ## 13.2.1 - 2024-01-10
14
20
 
15
21
  ### 🐛 Bug fixes
16
22
 
@@ -6,7 +6,7 @@ apply plugin: 'maven-publish'
6
6
  apply plugin: 'de.undercouch.download'
7
7
 
8
8
  group = 'host.exp.exponent'
9
- version = '13.2.1'
9
+ version = '13.2.2'
10
10
 
11
11
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
12
12
  if (expoModulesCorePlugin.exists()) {
@@ -116,7 +116,7 @@ android {
116
116
  namespace "expo.modules.sqlite"
117
117
  defaultConfig {
118
118
  versionCode 18
119
- versionName "13.2.1"
119
+ versionName "13.2.2"
120
120
 
121
121
  externalNativeBuild {
122
122
  cmake {
package/build/SQLite.d.ts CHANGED
@@ -36,14 +36,6 @@ export declare class SQLiteDatabase {
36
36
  * > The database has to be closed prior to deletion.
37
37
  */
38
38
  deleteAsync(): Promise<void>;
39
- /**
40
- * Used to listen to changes in the database.
41
- * @param callback A function that receives the `tableName` and `rowId` of the modified data.
42
- */
43
- onDatabaseChange(cb: (result: {
44
- tableName: string;
45
- rowId: number;
46
- }) => void): import("expo-modules-core").Subscription;
47
39
  /**
48
40
  * Creates a new transaction with Promise support.
49
41
  * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.
@@ -1 +1 @@
1
- {"version":3,"file":"SQLite.d.ts","sourceRoot":"","sources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AAQ;gBADR,EAAE,EAAE,cAAc,EAClB,QAAQ,EAAE,OAAO;IAG9B,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;CAW1F"}
package/build/SQLite.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import './polyfillNextTick';
2
2
  import customOpenDatabase from '@expo/websql/custom';
3
- import { requireNativeModule, EventEmitter } from 'expo-modules-core';
3
+ import { requireNativeModule } from 'expo-modules-core';
4
4
  import { Platform } from 'react-native';
5
5
  const ExpoSQLite = requireNativeModule('ExpoSQLite');
6
- const emitter = new EventEmitter(ExpoSQLite);
7
6
  function zipObject(keys, values) {
8
7
  const result = {};
9
8
  for (let i = 0; i < keys.length; i++) {
@@ -85,13 +84,6 @@ export class SQLiteDatabase {
85
84
  }
86
85
  return ExpoSQLite.deleteAsync(this._name);
87
86
  }
88
- /**
89
- * Used to listen to changes in the database.
90
- * @param callback A function that receives the `tableName` and `rowId` of the modified data.
91
- */
92
- onDatabaseChange(cb) {
93
- return emitter.addListener('onDatabaseChange', cb);
94
- }
95
87
  /**
96
88
  * Creates a new transaction with Promise support.
97
89
  * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.
@@ -171,7 +163,6 @@ export function openDatabase(name, version = '1.0', description = name, size = 1
171
163
  db.execAsync = db._db.execAsync.bind(db._db);
172
164
  db.closeAsync = db._db.closeAsync.bind(db._db);
173
165
  db.closeSync = db._db.closeSync.bind(db._db);
174
- db.onDatabaseChange = db._db.onDatabaseChange.bind(db._db);
175
166
  db.deleteAsync = db._db.deleteAsync.bind(db._db);
176
167
  db.transactionAsync = db._db.transactionAsync.bind(db._db);
177
168
  return db;
@@ -1 +1 @@
1
- {"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,kBAAkB,MAAM,qBAAqB,CAA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AAgB;QAClB,aAAQ,GAAR,QAAQ,CAAS;IACjC,CAAC;IAEJ,KAAK,CAAC,eAAe,CAAC,YAAoB,EAAE,IAAwB;QAClE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CACxC,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,EACzC,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,MAAM,MAAM,CAAC,KAAK,CAAC;SACpB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,MAAkC;IAC1D,OAAO,OAAO,IAAI,MAAM,CAAC;AAC3B,CAAC","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { requireNativeModule, EventEmitter } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport type {\n Query,\n ResultSet,\n ResultSetError,\n SQLiteCallback,\n SQLStatementArg,\n SQLTransactionAsyncCallback,\n SQLTransactionAsync,\n SQLTransactionCallback,\n SQLTransactionErrorCallback,\n} from './SQLite.types';\n\nconst ExpoSQLite = requireNativeModule('ExpoSQLite');\nconst emitter = new EventEmitter(ExpoSQLite);\n\nfunction zipObject(keys: string[], values: any[]) {\n const result = {};\n for (let i = 0; i < keys.length; i++) {\n result[keys[i]] = values[i];\n }\n return result;\n}\n\n/** The database returned by `openDatabase()` */\nexport class SQLiteDatabase {\n _name: string;\n _closed: boolean = false;\n\n constructor(name: string) {\n this._name = name;\n }\n\n /**\n * Executes the SQL statement and returns a callback resolving with the result.\n */\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n ExpoSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n // TODO: make the native API consistently reject with an error, not a string or other type\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n /**\n * Due to limitations on `Android` this function is provided to allow raw SQL queries to be\n * executed on the database. This will be less efficient than using the `exec` function, please use\n * only when necessary.\n */\n execRawQuery(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (Platform.OS === 'ios') {\n return this.exec(queries, readOnly, callback);\n }\n\n ExpoSQLite.execRawQuery(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n /**\n * Executes the SQL statement and returns a Promise resolving with the result.\n */\n async execAsync(queries: Query[], readOnly: boolean): Promise<(ResultSetError | ResultSet)[]> {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n const nativeResultSets = await ExpoSQLite.exec(\n this._name,\n queries.map(_serializeQuery),\n readOnly\n );\n return nativeResultSets.map(_deserializeResultSet);\n }\n\n /**\n * @deprecated Use `closeAsync()` instead.\n */\n close = this.closeAsync;\n\n /**\n * Close the database.\n */\n closeAsync(): Promise<void> {\n this._closed = true;\n return ExpoSQLite.close(this._name);\n }\n\n /**\n * Synchronously closes the database.\n */\n closeSync(): void {\n this._closed = true;\n return ExpoSQLite.closeSync(this._name);\n }\n\n /**\n * Delete the database file.\n * > The database has to be closed prior to deletion.\n */\n deleteAsync(): Promise<void> {\n if (!this._closed) {\n throw new Error(\n `Unable to delete '${this._name}' database that is currently open. Close it prior to deletion.`\n );\n }\n\n return ExpoSQLite.deleteAsync(this._name);\n }\n\n /**\n * Used to listen to changes in the database.\n * @param callback A function that receives the `tableName` and `rowId` of the modified data.\n */\n onDatabaseChange(cb: (result: { tableName: string; rowId: number }) => void) {\n return emitter.addListener('onDatabaseChange', cb);\n }\n\n /**\n * Creates a new transaction with Promise support.\n * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.\n * @param readOnly true if all the SQL statements in the callback are read only.\n */\n async transactionAsync(\n asyncCallback: SQLTransactionAsyncCallback,\n readOnly: boolean = false\n ): Promise<void> {\n await this.execAsync([{ sql: 'BEGIN;', args: [] }], false);\n try {\n const transaction = new ExpoSQLTransactionAsync(this, readOnly);\n await asyncCallback(transaction);\n await this.execAsync([{ sql: 'END;', args: [] }], false);\n } catch (e: unknown) {\n await this.execAsync([{ sql: 'ROLLBACK;', args: [] }], false);\n throw e;\n }\n }\n\n // @ts-expect-error: properties that are added from websql\n version: string;\n\n /**\n * Execute a database transaction.\n * @param callback A function representing the transaction to perform. Takes a Transaction\n * (see below) as its only parameter, on which it can add SQL statements to execute.\n * @param errorCallback Called if an error occurred processing this transaction. Takes a single\n * parameter describing the error.\n * @param successCallback Called when the transaction has completed executing on the database.\n */\n // @ts-expect-error: properties that are added from websql\n transaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n\n // @ts-expect-error: properties that are added from websql\n readTransaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n}\n\nfunction _serializeQuery(query: Query): Query | [string, any[]] {\n return Platform.OS === 'android'\n ? {\n sql: query.sql,\n args: query.args.map(_escapeBlob),\n }\n : [query.sql, query.args];\n}\n\nfunction _deserializeResultSet(nativeResult): ResultSet | ResultSetError {\n const [errorMessage, insertId, rowsAffected, columns, rows] = nativeResult;\n // TODO: send more structured error information from the native module so we can better construct\n // a SQLException object\n if (errorMessage !== null) {\n return { error: new Error(errorMessage) } as ResultSetError;\n }\n\n return {\n insertId,\n rowsAffected,\n rows: rows.map((row) => zipObject(columns, row)),\n };\n}\n\nfunction _escapeBlob<T>(data: T): T {\n if (typeof data === 'string') {\n /* eslint-disable no-control-regex */\n return data\n .replace(/\\u0002/g, '\\u0002\\u0002')\n .replace(/\\u0001/g, '\\u0001\\u0002')\n .replace(/\\u0000/g, '\\u0001\\u0001') as any;\n /* eslint-enable no-control-regex */\n } else {\n return data;\n }\n}\n\nconst _openExpoSQLiteDatabase = customOpenDatabase(SQLiteDatabase);\n\n// @needsAudit @docsMissing\n/**\n * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,\n * the database will be created under the app's [documents directory](./filesystem), i.e.\n * `${FileSystem.documentDirectory}/SQLite/${name}`.\n * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function\n * for compatibility with the WebSQL specification.\n * @param name Name of the database file to open.\n * @param version\n * @param description\n * @param size\n * @param callback\n * @return\n */\nexport function openDatabase(\n name: string,\n version: string = '1.0',\n description: string = name,\n size: number = 1,\n callback?: (db: SQLiteDatabase) => void\n): SQLiteDatabase {\n if (name === undefined) {\n throw new TypeError(`The database name must not be undefined`);\n }\n const db = _openExpoSQLiteDatabase(name, version, description, size, callback);\n db.exec = db._db.exec.bind(db._db);\n db.execRawQuery = db._db.execRawQuery.bind(db._db);\n db.execAsync = db._db.execAsync.bind(db._db);\n db.closeAsync = db._db.closeAsync.bind(db._db);\n db.closeSync = db._db.closeSync.bind(db._db);\n db.onDatabaseChange = db._db.onDatabaseChange.bind(db._db);\n db.deleteAsync = db._db.deleteAsync.bind(db._db);\n db.transactionAsync = db._db.transactionAsync.bind(db._db);\n return db;\n}\n\n/**\n * Internal data structure for the async transaction API.\n * @internal\n */\nexport class ExpoSQLTransactionAsync implements SQLTransactionAsync {\n constructor(\n private readonly db: SQLiteDatabase,\n private readonly readOnly: boolean\n ) {}\n\n async executeSqlAsync(sqlStatement: string, args?: SQLStatementArg[]): Promise<ResultSet> {\n const resultSets = await this.db.execAsync(\n [{ sql: sqlStatement, args: args ?? [] }],\n this.readOnly\n );\n const result = resultSets[0];\n if (isResultSetError(result)) {\n throw result.error;\n }\n return result;\n }\n}\n\nfunction isResultSetError(result: ResultSet | ResultSetError): result is ResultSetError {\n return 'error' in result;\n}\n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CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,EACzC,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,MAAM,MAAM,CAAC,KAAK,CAAC;SACpB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,MAAkC;IAC1D,OAAO,OAAO,IAAI,MAAM,CAAC;AAC3B,CAAC","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { requireNativeModule } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport type {\n Query,\n ResultSet,\n ResultSetError,\n SQLiteCallback,\n SQLStatementArg,\n SQLTransactionAsyncCallback,\n SQLTransactionAsync,\n SQLTransactionCallback,\n SQLTransactionErrorCallback,\n} from './SQLite.types';\n\nconst ExpoSQLite = requireNativeModule('ExpoSQLite');\n\nfunction zipObject(keys: string[], values: any[]) {\n const result = {};\n for (let i = 0; i < keys.length; i++) {\n result[keys[i]] = values[i];\n }\n return result;\n}\n\n/** The database returned by `openDatabase()` */\nexport class SQLiteDatabase {\n _name: string;\n _closed: boolean = false;\n\n constructor(name: string) {\n this._name = name;\n }\n\n /**\n * Executes the SQL statement and returns a callback resolving with the result.\n */\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n ExpoSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n // TODO: make the native API consistently reject with an error, not a string or other type\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n /**\n * Due to limitations on `Android` this function is provided to allow raw SQL queries to be\n * executed on the database. This will be less efficient than using the `exec` function, please use\n * only when necessary.\n */\n execRawQuery(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (Platform.OS === 'ios') {\n return this.exec(queries, readOnly, callback);\n }\n\n ExpoSQLite.execRawQuery(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n /**\n * Executes the SQL statement and returns a Promise resolving with the result.\n */\n async execAsync(queries: Query[], readOnly: boolean): Promise<(ResultSetError | ResultSet)[]> {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n const nativeResultSets = await ExpoSQLite.exec(\n this._name,\n queries.map(_serializeQuery),\n readOnly\n );\n return nativeResultSets.map(_deserializeResultSet);\n }\n\n /**\n * @deprecated Use `closeAsync()` instead.\n */\n close = this.closeAsync;\n\n /**\n * Close the database.\n */\n closeAsync(): Promise<void> {\n this._closed = true;\n return ExpoSQLite.close(this._name);\n }\n\n /**\n * Synchronously closes the database.\n */\n closeSync(): void {\n this._closed = true;\n return ExpoSQLite.closeSync(this._name);\n }\n\n /**\n * Delete the database file.\n * > The database has to be closed prior to deletion.\n */\n deleteAsync(): Promise<void> {\n if (!this._closed) {\n throw new Error(\n `Unable to delete '${this._name}' database that is currently open. Close it prior to deletion.`\n );\n }\n\n return ExpoSQLite.deleteAsync(this._name);\n }\n\n /**\n * Creates a new transaction with Promise support.\n * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.\n * @param readOnly true if all the SQL statements in the callback are read only.\n */\n async transactionAsync(\n asyncCallback: SQLTransactionAsyncCallback,\n readOnly: boolean = false\n ): Promise<void> {\n await this.execAsync([{ sql: 'BEGIN;', args: [] }], false);\n try {\n const transaction = new ExpoSQLTransactionAsync(this, readOnly);\n await asyncCallback(transaction);\n await this.execAsync([{ sql: 'END;', args: [] }], false);\n } catch (e: unknown) {\n await this.execAsync([{ sql: 'ROLLBACK;', args: [] }], false);\n throw e;\n }\n }\n\n // @ts-expect-error: properties that are added from websql\n version: string;\n\n /**\n * Execute a database transaction.\n * @param callback A function representing the transaction to perform. Takes a Transaction\n * (see below) as its only parameter, on which it can add SQL statements to execute.\n * @param errorCallback Called if an error occurred processing this transaction. Takes a single\n * parameter describing the error.\n * @param successCallback Called when the transaction has completed executing on the database.\n */\n // @ts-expect-error: properties that are added from websql\n transaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n\n // @ts-expect-error: properties that are added from websql\n readTransaction(\n callback: SQLTransactionCallback,\n errorCallback?: SQLTransactionErrorCallback,\n successCallback?: () => void\n ): void;\n}\n\nfunction _serializeQuery(query: Query): Query | [string, any[]] {\n return Platform.OS === 'android'\n ? {\n sql: query.sql,\n args: query.args.map(_escapeBlob),\n }\n : [query.sql, query.args];\n}\n\nfunction _deserializeResultSet(nativeResult): ResultSet | ResultSetError {\n const [errorMessage, insertId, rowsAffected, columns, rows] = nativeResult;\n // TODO: send more structured error information from the native module so we can better construct\n // a SQLException object\n if (errorMessage !== null) {\n return { error: new Error(errorMessage) } as ResultSetError;\n }\n\n return {\n insertId,\n rowsAffected,\n rows: rows.map((row) => zipObject(columns, row)),\n };\n}\n\nfunction _escapeBlob<T>(data: T): T {\n if (typeof data === 'string') {\n /* eslint-disable no-control-regex */\n return data\n .replace(/\\u0002/g, '\\u0002\\u0002')\n .replace(/\\u0001/g, '\\u0001\\u0002')\n .replace(/\\u0000/g, '\\u0001\\u0001') as any;\n /* eslint-enable no-control-regex */\n } else {\n return data;\n }\n}\n\nconst _openExpoSQLiteDatabase = customOpenDatabase(SQLiteDatabase);\n\n// @needsAudit @docsMissing\n/**\n * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,\n * the database will be created under the app's [documents directory](./filesystem), i.e.\n * `${FileSystem.documentDirectory}/SQLite/${name}`.\n * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function\n * for compatibility with the WebSQL specification.\n * @param name Name of the database file to open.\n * @param version\n * @param description\n * @param size\n * @param callback\n * @return\n */\nexport function openDatabase(\n name: string,\n version: string = '1.0',\n description: string = name,\n size: number = 1,\n callback?: (db: SQLiteDatabase) => void\n): SQLiteDatabase {\n if (name === undefined) {\n throw new TypeError(`The database name must not be undefined`);\n }\n const db = _openExpoSQLiteDatabase(name, version, description, size, callback);\n db.exec = db._db.exec.bind(db._db);\n db.execRawQuery = db._db.execRawQuery.bind(db._db);\n db.execAsync = db._db.execAsync.bind(db._db);\n db.closeAsync = db._db.closeAsync.bind(db._db);\n db.closeSync = db._db.closeSync.bind(db._db);\n db.deleteAsync = db._db.deleteAsync.bind(db._db);\n db.transactionAsync = db._db.transactionAsync.bind(db._db);\n return db;\n}\n\n/**\n * Internal data structure for the async transaction API.\n * @internal\n */\nexport class ExpoSQLTransactionAsync implements SQLTransactionAsync {\n constructor(\n private readonly db: SQLiteDatabase,\n private readonly readOnly: boolean\n ) {}\n\n async executeSqlAsync(sqlStatement: string, args?: SQLStatementArg[]): Promise<ResultSet> {\n const resultSets = await this.db.execAsync(\n [{ sql: sqlStatement, args: args ?? [] }],\n this.readOnly\n );\n const result = resultSets[0];\n if (isResultSetError(result)) {\n throw result.error;\n }\n return result;\n }\n}\n\nfunction isResultSetError(result: ResultSet | ResultSetError): result is ResultSetError {\n return 'error' in result;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-sqlite",
3
- "version": "13.2.1",
3
+ "version": "13.2.2",
4
4
  "description": "Provides access to a database that can be queried through a WebSQL-like API (https://www.w3.org/TR/webdatabase/). The database is persisted across restarts of your app.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "peerDependencies": {
48
48
  "expo": "*"
49
49
  },
50
- "gitHead": "ca014bf2516c7644ef303f4c21fdd68de4d99f76"
50
+ "gitHead": "ba36acbbe93bac3114612bd578619de9663c2a16"
51
51
  }
package/src/SQLite.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import './polyfillNextTick';
2
2
 
3
3
  import customOpenDatabase from '@expo/websql/custom';
4
- import { requireNativeModule, EventEmitter } from 'expo-modules-core';
4
+ import { requireNativeModule } from 'expo-modules-core';
5
5
  import { Platform } from 'react-native';
6
6
 
7
7
  import type {
@@ -17,7 +17,6 @@ import type {
17
17
  } from './SQLite.types';
18
18
 
19
19
  const ExpoSQLite = requireNativeModule('ExpoSQLite');
20
- const emitter = new EventEmitter(ExpoSQLite);
21
20
 
22
21
  function zipObject(keys: string[], values: any[]) {
23
22
  const result = {};
@@ -126,14 +125,6 @@ export class SQLiteDatabase {
126
125
  return ExpoSQLite.deleteAsync(this._name);
127
126
  }
128
127
 
129
- /**
130
- * Used to listen to changes in the database.
131
- * @param callback A function that receives the `tableName` and `rowId` of the modified data.
132
- */
133
- onDatabaseChange(cb: (result: { tableName: string; rowId: number }) => void) {
134
- return emitter.addListener('onDatabaseChange', cb);
135
- }
136
-
137
128
  /**
138
129
  * Creates a new transaction with Promise support.
139
130
  * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.
@@ -249,7 +240,6 @@ export function openDatabase(
249
240
  db.execAsync = db._db.execAsync.bind(db._db);
250
241
  db.closeAsync = db._db.closeAsync.bind(db._db);
251
242
  db.closeSync = db._db.closeSync.bind(db._db);
252
- db.onDatabaseChange = db._db.onDatabaseChange.bind(db._db);
253
243
  db.deleteAsync = db._db.deleteAsync.bind(db._db);
254
244
  db.transactionAsync = db._db.transactionAsync.bind(db._db);
255
245
  return db;