expo-sqlite 10.0.3 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -4
- package/README.md +1 -1
- package/android/build.gradle +2 -2
- package/build/SQLite.js +7 -1
- package/build/SQLite.js.map +1 -1
- package/package.json +7 -7
- package/src/SQLite.ts +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 10.0
|
|
13
|
+
## 10.1.0 — 2021-12-03
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
### 🎉 New features
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
- Removed lodash. ([#12523](https://github.com/expo/expo/pull/12523) by [@EvanBacon](https://github.com/EvanBacon))
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
### 💡 Others
|
|
20
|
+
|
|
21
|
+
- Update `lodash` dependency. ([#15069](https://github.com/expo/expo/pull/15069) by [@Simek](https://github.com/Simek))
|
|
20
22
|
|
|
21
23
|
## 10.0.1 — 2021-10-01
|
|
22
24
|
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-
|
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
|
16
|
-
For bare React Native projects, you must ensure that you have [installed and configured the `
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
17
|
|
|
18
18
|
### Add the package to your npm dependencies
|
|
19
19
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '10.0
|
|
6
|
+
version = '10.1.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
// Simple helper that allows the root project to override versions declared by this library.
|
|
@@ -57,7 +57,7 @@ android {
|
|
|
57
57
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
58
58
|
targetSdkVersion safeExtGet("targetSdkVersion", 30)
|
|
59
59
|
versionCode 18
|
|
60
|
-
versionName "10.0
|
|
60
|
+
versionName "10.1.0"
|
|
61
61
|
}
|
|
62
62
|
lintOptions {
|
|
63
63
|
abortOnError false
|
package/build/SQLite.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import './polyfillNextTick';
|
|
2
2
|
import customOpenDatabase from '@expo/websql/custom';
|
|
3
3
|
import { NativeModulesProxy } from 'expo-modules-core';
|
|
4
|
-
import zipObject from 'lodash/zipObject';
|
|
5
4
|
import { Platform } from 'react-native';
|
|
6
5
|
const { ExponentSQLite } = NativeModulesProxy;
|
|
6
|
+
function zipObject(keys, values) {
|
|
7
|
+
const result = {};
|
|
8
|
+
for (let i = 0; i < keys.length; i++) {
|
|
9
|
+
result[keys[i]] = values[i];
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
7
13
|
class SQLiteDatabase {
|
|
8
14
|
_name;
|
|
9
15
|
_closed = false;
|
package/build/SQLite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"SQLite.js","sourceRoot":"","sources":["../src/SQLite.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,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EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC,CAAC;IACF,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,2BAA2B;AAC3B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,UAAkB,KAAK,EACvB,cAAsB,IAAI,EAC1B,OAAe,CAAC,EAChB,QAAuC;IAEvC,IAAI,IAAI,KAAK,SAAS,EAAE;QACtB,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;KAChE;IACD,MAAM,EAAE,GAAG,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/E,MAAM,UAAU,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import './polyfillNextTick';\n\nimport customOpenDatabase from '@expo/websql/custom';\nimport { NativeModulesProxy } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport { Query, ResultSet, ResultSetError, SQLiteCallback, WebSQLDatabase } from './SQLite.types';\n\nconst { ExponentSQLite } = NativeModulesProxy;\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\nclass SQLiteDatabase {\n _name: string;\n _closed: boolean = false;\n\n constructor(name: string) {\n this._name = name;\n }\n\n exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void {\n if (this._closed) {\n throw new Error(`The SQLite database is closed`);\n }\n\n ExponentSQLite.exec(this._name, queries.map(_serializeQuery), readOnly).then(\n (nativeResultSets) => {\n callback(null, nativeResultSets.map(_deserializeResultSet));\n },\n (error) => {\n // TODO: make the native API consistently reject with an error, not a string or other type\n callback(error instanceof Error ? error : new Error(error));\n }\n );\n }\n\n close() {\n this._closed = true;\n ExponentSQLite.close(this._name);\n }\n}\n\nfunction _serializeQuery(query: Query): [string, unknown[]] {\n return [query.sql, Platform.OS === 'android' ? query.args.map(_escapeBlob) : query.args];\n}\n\nfunction _deserializeResultSet(nativeResult): ResultSet | ResultSetError {\n const [errorMessage, insertId, rowsAffected, columns, rows] = nativeResult;\n // TODO: send more structured error information from the native module so we can better construct\n // a SQLException object\n if (errorMessage !== null) {\n return { error: new Error(errorMessage) } as ResultSetError;\n }\n\n return {\n insertId,\n rowsAffected,\n rows: rows.map((row) => zipObject(columns, row)),\n };\n}\n\nfunction _escapeBlob<T>(data: T): T {\n if (typeof data === 'string') {\n /* eslint-disable no-control-regex */\n return data\n .replace(/\\u0002/g, '\\u0002\\u0002')\n .replace(/\\u0001/g, '\\u0001\\u0002')\n .replace(/\\u0000/g, '\\u0001\\u0001') as any;\n /* eslint-enable no-control-regex */\n } else {\n return data;\n }\n}\n\nconst _openExpoSQLiteDatabase = customOpenDatabase(SQLiteDatabase);\n\nfunction addExecMethod(db: any): WebSQLDatabase {\n db.exec = (queries: Query[], readOnly: boolean, callback: SQLiteCallback): void => {\n db._db.exec(queries, readOnly, callback);\n };\n return db;\n}\n\n// @needsAudit @docsMissing\n/**\n * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,\n * the database will be created under the app's [documents directory](../filesystem), i.e.\n * `${FileSystem.documentDirectory}/SQLite/${name}`.\n * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function\n * for compatibility with the WebSQL specification.\n * @param name Name of the database file to open.\n * @param version\n * @param description\n * @param size\n * @param callback\n * @return\n */\nexport function openDatabase(\n name: string,\n version: string = '1.0',\n description: string = name,\n size: number = 1,\n callback?: (db: WebSQLDatabase) => void\n): WebSQLDatabase {\n if (name === undefined) {\n throw new TypeError(`The database name must not be undefined`);\n }\n const db = _openExpoSQLiteDatabase(name, version, description, size, callback);\n const dbWithExec = addExecMethod(db);\n return dbWithExec;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-sqlite",
|
|
3
|
-
"version": "10.0
|
|
3
|
+
"version": "10.1.0",
|
|
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",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/sqlite/",
|
|
35
35
|
"jest": {
|
|
36
|
-
"preset": "expo-module-scripts
|
|
36
|
+
"preset": "expo-module-scripts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@expo/websql": "^1.0.1"
|
|
40
|
-
"expo-modules-core": "~0.4.4",
|
|
41
|
-
"lodash": "^4.17.15"
|
|
39
|
+
"@expo/websql": "^1.0.1"
|
|
42
40
|
},
|
|
43
41
|
"devDependencies": {
|
|
44
|
-
"@types/lodash.zipobject": "^4.1.4",
|
|
45
42
|
"expo-module-scripts": "^2.0.0"
|
|
46
43
|
},
|
|
47
|
-
"
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"expo": "*"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "2e5c6983b86d5ecfca028ba64002897d8adc2cc4"
|
|
48
48
|
}
|
package/src/SQLite.ts
CHANGED
|
@@ -2,13 +2,20 @@ import './polyfillNextTick';
|
|
|
2
2
|
|
|
3
3
|
import customOpenDatabase from '@expo/websql/custom';
|
|
4
4
|
import { NativeModulesProxy } from 'expo-modules-core';
|
|
5
|
-
import zipObject from 'lodash/zipObject';
|
|
6
5
|
import { Platform } from 'react-native';
|
|
7
6
|
|
|
8
|
-
import { Query,
|
|
7
|
+
import { Query, ResultSet, ResultSetError, SQLiteCallback, WebSQLDatabase } from './SQLite.types';
|
|
9
8
|
|
|
10
9
|
const { ExponentSQLite } = NativeModulesProxy;
|
|
11
10
|
|
|
11
|
+
function zipObject(keys: string[], values: any[]) {
|
|
12
|
+
const result = {};
|
|
13
|
+
for (let i = 0; i < keys.length; i++) {
|
|
14
|
+
result[keys[i]] = values[i];
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
class SQLiteDatabase {
|
|
13
20
|
_name: string;
|
|
14
21
|
_closed: boolean = false;
|