expo-sqlite 15.2.13 → 15.2.14
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 -0
- package/android/build.gradle +2 -2
- package/build/hooks.d.ts +9 -1
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +27 -5
- package/build/hooks.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.13/expo.modules.sqlite-15.2.13.module → 15.2.14/expo.modules.sqlite-15.2.14.module} +17 -17
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.13/expo.modules.sqlite-15.2.13.pom → 15.2.14/expo.modules.sqlite-15.2.14.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.14/expo.modules.sqlite-15.2.14.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/maven-metadata.xml.sha512 +1 -1
- package/package.json +3 -3
- package/src/hooks.tsx +51 -19
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.13/expo.modules.sqlite-15.2.13.pom.sha512 +0 -1
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.13/expo.modules.sqlite-15.2.13-sources.jar → 15.2.14/expo.modules.sqlite-15.2.14-sources.jar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.13/expo.modules.sqlite-15.2.13-sources.jar.md5 → 15.2.14/expo.modules.sqlite-15.2.14-sources.jar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.13/expo.modules.sqlite-15.2.13-sources.jar.sha1 → 15.2.14/expo.modules.sqlite-15.2.14-sources.jar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.13/expo.modules.sqlite-15.2.13-sources.jar.sha256 → 15.2.14/expo.modules.sqlite-15.2.14-sources.jar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.13/expo.modules.sqlite-15.2.13-sources.jar.sha512 → 15.2.14/expo.modules.sqlite-15.2.14-sources.jar.sha512} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 15.2.14 — 2025-07-07
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed unnecessary database reopen from `SQLiteProvider` with same options. ([#37872](https://github.com/expo/expo/pull/37872) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
13
19
|
## 15.2.13 — 2025-07-01
|
|
14
20
|
|
|
15
21
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -45,13 +45,13 @@ def reactNativeArchitectures() {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
group = 'host.exp.exponent'
|
|
48
|
-
version = '15.2.
|
|
48
|
+
version = '15.2.14'
|
|
49
49
|
|
|
50
50
|
android {
|
|
51
51
|
namespace "expo.modules.sqlite"
|
|
52
52
|
defaultConfig {
|
|
53
53
|
versionCode 18
|
|
54
|
-
versionName "15.2.
|
|
54
|
+
versionName "15.2.14"
|
|
55
55
|
buildConfigField "boolean", "USE_LIBSQL", project.ext.USE_LIBSQL.toString()
|
|
56
56
|
|
|
57
57
|
externalNativeBuild {
|
package/build/hooks.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface SQLiteProviderProps {
|
|
|
70
70
|
* Context.Provider component that provides a SQLite database to all children.
|
|
71
71
|
* All descendants of this component will be able to access the database using the [`useSQLiteContext`](#usesqlitecontext) hook.
|
|
72
72
|
*/
|
|
73
|
-
export declare
|
|
73
|
+
export declare const SQLiteProvider: React.NamedExoticComponent<SQLiteProviderProps>;
|
|
74
74
|
/**
|
|
75
75
|
* A global hook for accessing the SQLite database across components.
|
|
76
76
|
* This hook should only be used within a [`<SQLiteProvider>`](#sqliteprovider) component.
|
|
@@ -100,4 +100,12 @@ export declare function useSQLiteContext(): SQLiteDatabase;
|
|
|
100
100
|
* @hidden
|
|
101
101
|
*/
|
|
102
102
|
export declare function importDatabaseFromAssetAsync(databaseName: string, assetSource: SQLiteProviderAssetSource, directory?: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Compares two objects deeply for equality.
|
|
105
|
+
*/
|
|
106
|
+
export declare function deepEqual(a: {
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
} | undefined, b: {
|
|
109
|
+
[key: string]: any;
|
|
110
|
+
} | undefined): boolean;
|
|
103
111
|
//# sourceMappingURL=hooks.d.ts.map
|
package/build/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuE,MAAM,OAAO,CAAC;AAG5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG1E,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAE5B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,yBAAyB,CAAC;IAExC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAOD;;;GAGG;AACH,eAAO,MAAM,cAAc,iDA6B1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,IAAI,cAAc,CAMjD;AAkKD;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,yBAAyB,EACtC,SAAS,CAAC,EAAE,MAAM,iBAYnB;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,EACrC,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,GACpC,OAAO,CAcT"}
|
package/build/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Asset } from 'expo-asset';
|
|
2
|
-
import React, { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { createContext, memo, useContext, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import ExpoSQLite from './ExpoSQLite';
|
|
4
4
|
import { openDatabaseAsync } from './SQLiteDatabase';
|
|
5
5
|
import { createDatabasePath } from './pathUtils';
|
|
@@ -11,7 +11,7 @@ const SQLiteContext = createContext(null);
|
|
|
11
11
|
* Context.Provider component that provides a SQLite database to all children.
|
|
12
12
|
* All descendants of this component will be able to access the database using the [`useSQLiteContext`](#usesqlitecontext) hook.
|
|
13
13
|
*/
|
|
14
|
-
export function SQLiteProvider({ children, onError, useSuspense = false, ...props }) {
|
|
14
|
+
export const SQLiteProvider = memo(function SQLiteProvider({ children, onError, useSuspense = false, ...props }) {
|
|
15
15
|
if (onError != null && useSuspense) {
|
|
16
16
|
throw new Error('Cannot use `onError` with `useSuspense`, use error boundaries instead.');
|
|
17
17
|
}
|
|
@@ -19,9 +19,15 @@ export function SQLiteProvider({ children, onError, useSuspense = false, ...prop
|
|
|
19
19
|
return <SQLiteProviderSuspense {...props}>{children}</SQLiteProviderSuspense>;
|
|
20
20
|
}
|
|
21
21
|
return (<SQLiteProviderNonSuspense {...props} onError={onError}>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
22
|
+
{children}
|
|
23
|
+
</SQLiteProviderNonSuspense>);
|
|
24
|
+
}, (prevProps, nextProps) => prevProps.databaseName === nextProps.databaseName &&
|
|
25
|
+
deepEqual(prevProps.options, nextProps.options) &&
|
|
26
|
+
deepEqual(prevProps.assetSource, nextProps.assetSource) &&
|
|
27
|
+
prevProps.directory === nextProps.directory &&
|
|
28
|
+
prevProps.onInit === nextProps.onInit &&
|
|
29
|
+
prevProps.onError === nextProps.onError &&
|
|
30
|
+
prevProps.useSuspense === nextProps.useSuspense);
|
|
25
31
|
/**
|
|
26
32
|
* A global hook for accessing the SQLite database across components.
|
|
27
33
|
* This hook should only be used within a [`<SQLiteProvider>`](#sqliteprovider) component.
|
|
@@ -171,6 +177,22 @@ export async function importDatabaseFromAssetAsync(databaseName, assetSource, di
|
|
|
171
177
|
const path = createDatabasePath(databaseName, directory);
|
|
172
178
|
await ExpoSQLite.importAssetDatabaseAsync(path, asset.localUri, assetSource.forceOverwrite ?? false);
|
|
173
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Compares two objects deeply for equality.
|
|
182
|
+
*/
|
|
183
|
+
export function deepEqual(a, b) {
|
|
184
|
+
if (a === b) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (a == null || b == null) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (typeof a !== 'object' || typeof b !== 'object') {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return (Object.keys(a).length === Object.keys(b).length &&
|
|
194
|
+
Object.keys(a).every((key) => deepEqual(a[key], b[key])));
|
|
195
|
+
}
|
|
174
196
|
// Referenced from https://github.com/reactjs/react.dev/blob/6570e6cd79a16ac3b1a2902632eddab7e6abb9ad/src/content/reference/react/Suspense.md
|
|
175
197
|
/**
|
|
176
198
|
* A custom hook like [`React.use`](https://react.dev/reference/react/use) hook using private Suspense implementation.
|
package/build/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,MAAM,CAAC;IACjC,CAAC,EACD,CAAC,MAAM,EAAE,EAAE;QACT,eAAe,CAAC,MAAM,GAAG,UAAU,CAAC;QACpC,eAAe,CAAC,MAAM,GAAG,MAAM,CAAC;IAClC,CAAC,CACF,CAAC;IACF,MAAM,eAAe,CAAC;AACxB,CAAC;AAED,SAAS,iBAAiB,CACxB,OAAwC;IAExC,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,QAAQ,IAAI,OAAO,CAAC;AAChF,CAAC;AAED,YAAY","sourcesContent":["import { Asset } from 'expo-asset';\nimport React, { createContext, useContext, useEffect, useRef, useState } from 'react';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport type { SQLiteOpenOptions } from './NativeDatabase';\nimport { openDatabaseAsync, type SQLiteDatabase } from './SQLiteDatabase';\nimport { createDatabasePath } from './pathUtils';\n\nexport interface SQLiteProviderAssetSource {\n /**\n * The asset ID returned from the `require()` call.\n */\n assetId: number;\n\n /**\n * Force overwrite the local database file even if it already exists.\n * @default false\n */\n forceOverwrite?: boolean;\n}\n\nexport interface SQLiteProviderProps {\n /**\n * The name of the database file to open.\n */\n databaseName: string;\n\n /**\n * The directory where the database file is located.\n * @default defaultDatabaseDirectory\n */\n directory?: string;\n\n /**\n * Open options.\n */\n options?: SQLiteOpenOptions;\n\n /**\n * Import a bundled database file from the specified asset module.\n * @example\n * ```ts\n * assetSource={{ assetId: require('./assets/db.db') }}\n * ```\n */\n assetSource?: SQLiteProviderAssetSource;\n\n /**\n * The children to render.\n */\n children: React.ReactNode;\n\n /**\n * A custom initialization handler to run before rendering the children.\n * You can use this to run database migrations or other setup tasks.\n */\n onInit?: (db: SQLiteDatabase) => Promise<void>;\n\n /**\n * Handle errors from SQLiteProvider.\n * @default rethrow the error\n */\n onError?: (error: Error) => void;\n\n /**\n * Enable [`React.Suspense`](https://react.dev/reference/react/Suspense) integration.\n * @default false\n * @example\n * ```tsx\n * export default function App() {\n * return (\n * <Suspense fallback={<Text>Loading...</Text>}>\n * <SQLiteProvider databaseName=\"test.db\" useSuspense={true}>\n * <Main />\n * </SQLiteProvider>\n * </Suspense>\n * );\n * }\n * ```\n */\n useSuspense?: boolean;\n}\n\n/**\n * Create a context for the SQLite database\n */\nconst SQLiteContext = createContext<SQLiteDatabase | null>(null);\n\n/**\n * Context.Provider component that provides a SQLite database to all children.\n * All descendants of this component will be able to access the database using the [`useSQLiteContext`](#usesqlitecontext) hook.\n */\nexport function SQLiteProvider({\n children,\n onError,\n useSuspense = false,\n ...props\n}: SQLiteProviderProps) {\n if (onError != null && useSuspense) {\n throw new Error('Cannot use `onError` with `useSuspense`, use error boundaries instead.');\n }\n\n if (useSuspense) {\n return <SQLiteProviderSuspense {...props}>{children}</SQLiteProviderSuspense>;\n }\n\n return (\n <SQLiteProviderNonSuspense {...props} onError={onError}>\n {children}\n </SQLiteProviderNonSuspense>\n );\n}\n\n/**\n * A global hook for accessing the SQLite database across components.\n * This hook should only be used within a [`<SQLiteProvider>`](#sqliteprovider) component.\n *\n * @example\n * ```tsx\n * export default function App() {\n * return (\n * <SQLiteProvider databaseName=\"test.db\">\n * <Main />\n * </SQLiteProvider>\n * );\n * }\n *\n * export function Main() {\n * const db = useSQLiteContext();\n * console.log('sqlite version', db.getFirstSync('SELECT sqlite_version()'));\n * return <View />\n * }\n * ```\n */\nexport function useSQLiteContext(): SQLiteDatabase {\n const context = useContext(SQLiteContext);\n if (context == null) {\n throw new Error('useSQLiteContext must be used within a <SQLiteProvider>');\n }\n return context;\n}\n\n//#region Internals\n\ntype DatabaseInstanceType = Pick<\n SQLiteProviderProps,\n 'databaseName' | 'directory' | 'options' | 'onInit'\n> & {\n promise: Promise<SQLiteDatabase> | null;\n};\n\nlet databaseInstance: DatabaseInstanceType | null = null;\n\nfunction SQLiteProviderSuspense({\n databaseName,\n directory,\n options,\n assetSource,\n children,\n onInit,\n}: Omit<SQLiteProviderProps, 'onError' | 'useSuspense'>) {\n const databasePromise = getDatabaseAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n });\n const database = use(databasePromise);\n return <SQLiteContext.Provider value={database}>{children}</SQLiteContext.Provider>;\n}\n\nfunction SQLiteProviderNonSuspense({\n databaseName,\n directory,\n options,\n assetSource,\n children,\n onInit,\n onError,\n}: Omit<SQLiteProviderProps, 'useSuspense'>) {\n const databaseRef = useRef<SQLiteDatabase | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n async function setup() {\n try {\n const db = await openDatabaseWithInitAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n });\n databaseRef.current = db;\n setLoading(false);\n } catch (e: any) {\n setError(e);\n }\n }\n\n async function teardown(db: SQLiteDatabase | null) {\n try {\n await db?.closeAsync();\n } catch (e: any) {\n setError(e);\n }\n }\n\n setup();\n\n return () => {\n const db = databaseRef.current;\n teardown(db);\n databaseRef.current = null;\n setLoading(true);\n };\n }, [databaseName, directory, options, onInit]);\n\n if (error != null) {\n const handler =\n onError ??\n ((e) => {\n throw e;\n });\n handler(error);\n }\n if (loading || !databaseRef.current) {\n return null;\n }\n return <SQLiteContext.Provider value={databaseRef.current}>{children}</SQLiteContext.Provider>;\n}\n\nfunction getDatabaseAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n}: Pick<\n SQLiteProviderProps,\n 'databaseName' | 'directory' | 'options' | 'assetSource' | 'onInit'\n>): Promise<SQLiteDatabase> {\n if (\n databaseInstance?.promise != null &&\n databaseInstance?.databaseName === databaseName &&\n databaseInstance?.directory === directory &&\n databaseInstance?.options === options &&\n databaseInstance?.onInit === onInit\n ) {\n return databaseInstance.promise;\n }\n\n let promise: Promise<SQLiteDatabase>;\n if (databaseInstance?.promise != null) {\n promise = databaseInstance.promise\n .then((db) => {\n db.closeAsync();\n })\n .then(() => {\n return openDatabaseWithInitAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n });\n });\n } else {\n promise = openDatabaseWithInitAsync({ databaseName, directory, options, assetSource, onInit });\n }\n databaseInstance = {\n databaseName,\n directory,\n options,\n onInit,\n promise,\n };\n return promise;\n}\n\nasync function openDatabaseWithInitAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n}: Pick<\n SQLiteProviderProps,\n 'databaseName' | 'directory' | 'options' | 'assetSource' | 'onInit'\n>): Promise<SQLiteDatabase> {\n if (assetSource != null) {\n await importDatabaseFromAssetAsync(databaseName, assetSource, directory);\n }\n const database = await openDatabaseAsync(databaseName, options, directory);\n if (onInit != null) {\n await onInit(database);\n }\n return database;\n}\n\n/**\n * Imports an asset database into the SQLite database directory.\n *\n * Exposed only for testing purposes.\n * @hidden\n */\nexport async function importDatabaseFromAssetAsync(\n databaseName: string,\n assetSource: SQLiteProviderAssetSource,\n directory?: string\n) {\n const asset = await Asset.fromModule(assetSource.assetId).downloadAsync();\n if (!asset.localUri) {\n throw new Error(`Unable to get the localUri from asset ${assetSource.assetId}`);\n }\n const path = createDatabasePath(databaseName, directory);\n await ExpoSQLite.importAssetDatabaseAsync(\n path,\n asset.localUri,\n assetSource.forceOverwrite ?? false\n );\n}\n\n//#endregion\n\n//#region Private Suspense API similar to `React.use`\n\n// Referenced from https://github.com/vercel/swr/blob/1d8110900d1aee3747199bfb377b149b7ff6848e/_internal/src/types.ts#L27-L31\ntype ReactUsePromise<T, E extends Error = Error> = Promise<T> & {\n status?: 'pending' | 'fulfilled' | 'rejected';\n value?: T;\n reason?: E;\n};\n\n// Referenced from https://github.com/reactjs/react.dev/blob/6570e6cd79a16ac3b1a2902632eddab7e6abb9ad/src/content/reference/react/Suspense.md\n/**\n * A custom hook like [`React.use`](https://react.dev/reference/react/use) hook using private Suspense implementation.\n */\nfunction use<T>(promise: Promise<T> | ReactUsePromise<T>) {\n if (isReactUsePromise(promise)) {\n if (promise.status === 'fulfilled') {\n if (promise.value === undefined) {\n throw new Error('[use] Unexpected undefined value from promise');\n }\n return promise.value;\n } else if (promise.status === 'rejected') {\n throw promise.reason;\n } else if (promise.status === 'pending') {\n throw promise;\n }\n throw new Error('[use] Promise is in an invalid state');\n }\n\n const suspensePromise = promise as ReactUsePromise<T>;\n suspensePromise.status = 'pending';\n suspensePromise.then(\n (result: T) => {\n suspensePromise.status = 'fulfilled';\n suspensePromise.value = result;\n },\n (reason) => {\n suspensePromise.status = 'rejected';\n suspensePromise.reason = reason;\n }\n );\n throw suspensePromise;\n}\n\nfunction isReactUsePromise<T>(\n promise: Promise<T> | ReactUsePromise<T>\n): promise is ReactUsePromise<T> {\n return typeof promise === 'object' && promise !== null && 'status' in promise;\n}\n\n//#endregion\n"]}
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5F,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA6EjD;;GAEG;AACH,MAAM,aAAa,GAAG,aAAa,CAAwB,IAAI,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAChC,SAAS,cAAc,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,WAAW,GAAG,KAAK,EACnB,GAAG,KAAK,EACY;IACpB,IAAI,OAAO,IAAI,IAAI,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC5F,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,sBAAsB,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,sBAAsB,CAAC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M,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,eAAe,GAAG,OAA6B,CAAC;IACtD,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC;IACnC,eAAe,CAAC,IAAI,CAClB,CAAC,MAAS,EAAE,EAAE;QACZ,eAAe,CAAC,MAAM,GAAG,WAAW,CAAC;QACrC,eAAe,CAAC,KAAK,GAAG,MAAM,CAAC;IACjC,CAAC,EACD,CAAC,MAAM,EAAE,EAAE;QACT,eAAe,CAAC,MAAM,GAAG,UAAU,CAAC;QACpC,eAAe,CAAC,MAAM,GAAG,MAAM,CAAC;IAClC,CAAC,CACF,CAAC;IACF,MAAM,eAAe,CAAC;AACxB,CAAC;AAED,SAAS,iBAAiB,CACxB,OAAwC;IAExC,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,QAAQ,IAAI,OAAO,CAAC;AAChF,CAAC;AAED,YAAY","sourcesContent":["import { Asset } from 'expo-asset';\nimport React, { createContext, memo, useContext, useEffect, useRef, useState } from 'react';\n\nimport ExpoSQLite from './ExpoSQLite';\nimport type { SQLiteOpenOptions } from './NativeDatabase';\nimport { openDatabaseAsync, type SQLiteDatabase } from './SQLiteDatabase';\nimport { createDatabasePath } from './pathUtils';\n\nexport interface SQLiteProviderAssetSource {\n /**\n * The asset ID returned from the `require()` call.\n */\n assetId: number;\n\n /**\n * Force overwrite the local database file even if it already exists.\n * @default false\n */\n forceOverwrite?: boolean;\n}\n\nexport interface SQLiteProviderProps {\n /**\n * The name of the database file to open.\n */\n databaseName: string;\n\n /**\n * The directory where the database file is located.\n * @default defaultDatabaseDirectory\n */\n directory?: string;\n\n /**\n * Open options.\n */\n options?: SQLiteOpenOptions;\n\n /**\n * Import a bundled database file from the specified asset module.\n * @example\n * ```ts\n * assetSource={{ assetId: require('./assets/db.db') }}\n * ```\n */\n assetSource?: SQLiteProviderAssetSource;\n\n /**\n * The children to render.\n */\n children: React.ReactNode;\n\n /**\n * A custom initialization handler to run before rendering the children.\n * You can use this to run database migrations or other setup tasks.\n */\n onInit?: (db: SQLiteDatabase) => Promise<void>;\n\n /**\n * Handle errors from SQLiteProvider.\n * @default rethrow the error\n */\n onError?: (error: Error) => void;\n\n /**\n * Enable [`React.Suspense`](https://react.dev/reference/react/Suspense) integration.\n * @default false\n * @example\n * ```tsx\n * export default function App() {\n * return (\n * <Suspense fallback={<Text>Loading...</Text>}>\n * <SQLiteProvider databaseName=\"test.db\" useSuspense={true}>\n * <Main />\n * </SQLiteProvider>\n * </Suspense>\n * );\n * }\n * ```\n */\n useSuspense?: boolean;\n}\n\n/**\n * Create a context for the SQLite database\n */\nconst SQLiteContext = createContext<SQLiteDatabase | null>(null);\n\n/**\n * Context.Provider component that provides a SQLite database to all children.\n * All descendants of this component will be able to access the database using the [`useSQLiteContext`](#usesqlitecontext) hook.\n */\nexport const SQLiteProvider = memo(\n function SQLiteProvider({\n children,\n onError,\n useSuspense = false,\n ...props\n }: SQLiteProviderProps) {\n if (onError != null && useSuspense) {\n throw new Error('Cannot use `onError` with `useSuspense`, use error boundaries instead.');\n }\n\n if (useSuspense) {\n return <SQLiteProviderSuspense {...props}>{children}</SQLiteProviderSuspense>;\n }\n\n return (\n <SQLiteProviderNonSuspense {...props} onError={onError}>\n {children}\n </SQLiteProviderNonSuspense>\n );\n },\n (prevProps: SQLiteProviderProps, nextProps: SQLiteProviderProps) =>\n prevProps.databaseName === nextProps.databaseName &&\n deepEqual(prevProps.options, nextProps.options) &&\n deepEqual(prevProps.assetSource, nextProps.assetSource) &&\n prevProps.directory === nextProps.directory &&\n prevProps.onInit === nextProps.onInit &&\n prevProps.onError === nextProps.onError &&\n prevProps.useSuspense === nextProps.useSuspense\n);\n\n/**\n * A global hook for accessing the SQLite database across components.\n * This hook should only be used within a [`<SQLiteProvider>`](#sqliteprovider) component.\n *\n * @example\n * ```tsx\n * export default function App() {\n * return (\n * <SQLiteProvider databaseName=\"test.db\">\n * <Main />\n * </SQLiteProvider>\n * );\n * }\n *\n * export function Main() {\n * const db = useSQLiteContext();\n * console.log('sqlite version', db.getFirstSync('SELECT sqlite_version()'));\n * return <View />\n * }\n * ```\n */\nexport function useSQLiteContext(): SQLiteDatabase {\n const context = useContext(SQLiteContext);\n if (context == null) {\n throw new Error('useSQLiteContext must be used within a <SQLiteProvider>');\n }\n return context;\n}\n\n//#region Internals\n\ntype DatabaseInstanceType = Pick<\n SQLiteProviderProps,\n 'databaseName' | 'directory' | 'options' | 'onInit'\n> & {\n promise: Promise<SQLiteDatabase> | null;\n};\n\nlet databaseInstance: DatabaseInstanceType | null = null;\n\nfunction SQLiteProviderSuspense({\n databaseName,\n directory,\n options,\n assetSource,\n children,\n onInit,\n}: Omit<SQLiteProviderProps, 'onError' | 'useSuspense'>) {\n const databasePromise = getDatabaseAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n });\n const database = use(databasePromise);\n return <SQLiteContext.Provider value={database}>{children}</SQLiteContext.Provider>;\n}\n\nfunction SQLiteProviderNonSuspense({\n databaseName,\n directory,\n options,\n assetSource,\n children,\n onInit,\n onError,\n}: Omit<SQLiteProviderProps, 'useSuspense'>) {\n const databaseRef = useRef<SQLiteDatabase | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n async function setup() {\n try {\n const db = await openDatabaseWithInitAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n });\n databaseRef.current = db;\n setLoading(false);\n } catch (e: any) {\n setError(e);\n }\n }\n\n async function teardown(db: SQLiteDatabase | null) {\n try {\n await db?.closeAsync();\n } catch (e: any) {\n setError(e);\n }\n }\n\n setup();\n\n return () => {\n const db = databaseRef.current;\n teardown(db);\n databaseRef.current = null;\n setLoading(true);\n };\n }, [databaseName, directory, options, onInit]);\n\n if (error != null) {\n const handler =\n onError ??\n ((e) => {\n throw e;\n });\n handler(error);\n }\n if (loading || !databaseRef.current) {\n return null;\n }\n return <SQLiteContext.Provider value={databaseRef.current}>{children}</SQLiteContext.Provider>;\n}\n\nfunction getDatabaseAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n}: Pick<\n SQLiteProviderProps,\n 'databaseName' | 'directory' | 'options' | 'assetSource' | 'onInit'\n>): Promise<SQLiteDatabase> {\n if (\n databaseInstance?.promise != null &&\n databaseInstance?.databaseName === databaseName &&\n databaseInstance?.directory === directory &&\n databaseInstance?.options === options &&\n databaseInstance?.onInit === onInit\n ) {\n return databaseInstance.promise;\n }\n\n let promise: Promise<SQLiteDatabase>;\n if (databaseInstance?.promise != null) {\n promise = databaseInstance.promise\n .then((db) => {\n db.closeAsync();\n })\n .then(() => {\n return openDatabaseWithInitAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n });\n });\n } else {\n promise = openDatabaseWithInitAsync({ databaseName, directory, options, assetSource, onInit });\n }\n databaseInstance = {\n databaseName,\n directory,\n options,\n onInit,\n promise,\n };\n return promise;\n}\n\nasync function openDatabaseWithInitAsync({\n databaseName,\n directory,\n options,\n assetSource,\n onInit,\n}: Pick<\n SQLiteProviderProps,\n 'databaseName' | 'directory' | 'options' | 'assetSource' | 'onInit'\n>): Promise<SQLiteDatabase> {\n if (assetSource != null) {\n await importDatabaseFromAssetAsync(databaseName, assetSource, directory);\n }\n const database = await openDatabaseAsync(databaseName, options, directory);\n if (onInit != null) {\n await onInit(database);\n }\n return database;\n}\n\n/**\n * Imports an asset database into the SQLite database directory.\n *\n * Exposed only for testing purposes.\n * @hidden\n */\nexport async function importDatabaseFromAssetAsync(\n databaseName: string,\n assetSource: SQLiteProviderAssetSource,\n directory?: string\n) {\n const asset = await Asset.fromModule(assetSource.assetId).downloadAsync();\n if (!asset.localUri) {\n throw new Error(`Unable to get the localUri from asset ${assetSource.assetId}`);\n }\n const path = createDatabasePath(databaseName, directory);\n await ExpoSQLite.importAssetDatabaseAsync(\n path,\n asset.localUri,\n assetSource.forceOverwrite ?? false\n );\n}\n\n/**\n * Compares two objects deeply for equality.\n */\nexport function deepEqual(\n a: { [key: string]: any } | undefined,\n b: { [key: string]: any } | undefined\n): boolean {\n if (a === b) {\n return true;\n }\n if (a == null || b == null) {\n return false;\n }\n if (typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n return (\n Object.keys(a).length === Object.keys(b).length &&\n Object.keys(a).every((key) => deepEqual(a[key], b[key]))\n );\n}\n\n//#endregion\n\n//#region Private Suspense API similar to `React.use`\n\n// Referenced from https://github.com/vercel/swr/blob/1d8110900d1aee3747199bfb377b149b7ff6848e/_internal/src/types.ts#L27-L31\ntype ReactUsePromise<T, E extends Error = Error> = Promise<T> & {\n status?: 'pending' | 'fulfilled' | 'rejected';\n value?: T;\n reason?: E;\n};\n\n// Referenced from https://github.com/reactjs/react.dev/blob/6570e6cd79a16ac3b1a2902632eddab7e6abb9ad/src/content/reference/react/Suspense.md\n/**\n * A custom hook like [`React.use`](https://react.dev/reference/react/use) hook using private Suspense implementation.\n */\nfunction use<T>(promise: Promise<T> | ReactUsePromise<T>) {\n if (isReactUsePromise(promise)) {\n if (promise.status === 'fulfilled') {\n if (promise.value === undefined) {\n throw new Error('[use] Unexpected undefined value from promise');\n }\n return promise.value;\n } else if (promise.status === 'rejected') {\n throw promise.reason;\n } else if (promise.status === 'pending') {\n throw promise;\n }\n throw new Error('[use] Promise is in an invalid state');\n }\n\n const suspensePromise = promise as ReactUsePromise<T>;\n suspensePromise.status = 'pending';\n suspensePromise.then(\n (result: T) => {\n suspensePromise.status = 'fulfilled';\n suspensePromise.value = result;\n },\n (reason) => {\n suspensePromise.status = 'rejected';\n suspensePromise.reason = reason;\n }\n );\n throw suspensePromise;\n}\n\nfunction isReactUsePromise<T>(\n promise: Promise<T> | ReactUsePromise<T>\n): promise is ReactUsePromise<T> {\n return typeof promise === 'object' && promise !== null && 'status' in promise;\n}\n\n//#endregion\n"]}
|
package/expo-module.config.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6bf662007e54386a90f73fe6493ab2e6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3e9b7c1b032fb4daa2bc3e5c8a60b9f6b4698bac
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bd5d94d4158273ae535a7726a7f6123af2a4bf4eaeb2bf868f7ba2e0d3da44a1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e1c521feb14ecc2a94707a0a7e66173dcfb9a13c8bfbd9eed42bd42d59f140f303c9035efc26b4169b4d6d8432383fe8d9c693a1ef06ce453a8485ff4611f24f
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.sqlite",
|
|
6
|
-
"version": "15.2.
|
|
6
|
+
"version": "15.2.14",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.sqlite-15.2.
|
|
28
|
-
"url": "expo.modules.sqlite-15.2.
|
|
29
|
-
"size":
|
|
30
|
-
"sha512": "
|
|
31
|
-
"sha256": "
|
|
32
|
-
"sha1": "
|
|
33
|
-
"md5": "
|
|
27
|
+
"name": "expo.modules.sqlite-15.2.14.aar",
|
|
28
|
+
"url": "expo.modules.sqlite-15.2.14.aar",
|
|
29
|
+
"size": 3760131,
|
|
30
|
+
"sha512": "e1c521feb14ecc2a94707a0a7e66173dcfb9a13c8bfbd9eed42bd42d59f140f303c9035efc26b4169b4d6d8432383fe8d9c693a1ef06ce453a8485ff4611f24f",
|
|
31
|
+
"sha256": "bd5d94d4158273ae535a7726a7f6123af2a4bf4eaeb2bf868f7ba2e0d3da44a1",
|
|
32
|
+
"sha1": "3e9b7c1b032fb4daa2bc3e5c8a60b9f6b4698bac",
|
|
33
|
+
"md5": "6bf662007e54386a90f73fe6493ab2e6"
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
36
|
},
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
],
|
|
54
54
|
"files": [
|
|
55
55
|
{
|
|
56
|
-
"name": "expo.modules.sqlite-15.2.
|
|
57
|
-
"url": "expo.modules.sqlite-15.2.
|
|
58
|
-
"size":
|
|
59
|
-
"sha512": "
|
|
60
|
-
"sha256": "
|
|
61
|
-
"sha1": "
|
|
62
|
-
"md5": "
|
|
56
|
+
"name": "expo.modules.sqlite-15.2.14.aar",
|
|
57
|
+
"url": "expo.modules.sqlite-15.2.14.aar",
|
|
58
|
+
"size": 3760131,
|
|
59
|
+
"sha512": "e1c521feb14ecc2a94707a0a7e66173dcfb9a13c8bfbd9eed42bd42d59f140f303c9035efc26b4169b4d6d8432383fe8d9c693a1ef06ce453a8485ff4611f24f",
|
|
60
|
+
"sha256": "bd5d94d4158273ae535a7726a7f6123af2a4bf4eaeb2bf868f7ba2e0d3da44a1",
|
|
61
|
+
"sha1": "3e9b7c1b032fb4daa2bc3e5c8a60b9f6b4698bac",
|
|
62
|
+
"md5": "6bf662007e54386a90f73fe6493ab2e6"
|
|
63
63
|
}
|
|
64
64
|
]
|
|
65
65
|
},
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
{
|
|
76
|
-
"name": "expo.modules.sqlite-15.2.
|
|
77
|
-
"url": "expo.modules.sqlite-15.2.
|
|
76
|
+
"name": "expo.modules.sqlite-15.2.14-sources.jar",
|
|
77
|
+
"url": "expo.modules.sqlite-15.2.14-sources.jar",
|
|
78
78
|
"size": 11149,
|
|
79
79
|
"sha512": "406e6d6744631e4207a2517cc5263c709d809b4c9679e4c4b62629417cf63fcd86274ec8762f948617dccf4f7e051130a81c6e5312e7641ce6f3499f6ed7ac3f",
|
|
80
80
|
"sha256": "48e04077dfdf5b7480ffd795273f6b73651dec10f92884c27e4170b483252107",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
143f77fe09b898bd41a57edbefccdc75
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
da172bbcdf831fe4162b53c11806d61c17b27130
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
97e972a22d2a2cd2de86754818df8bafe347f70ea64779c62fd6cfbe2aa18a4f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
808d35b7cadf4233f4d513d6009e0e6042036667ab2493c6cfda836bcb24d4d08be603991b5088d5676cdc2a1b816bc578d77d45971b11d6be3330aff0d8934a
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>host.exp.exponent</groupId>
|
|
11
11
|
<artifactId>expo.modules.sqlite</artifactId>
|
|
12
|
-
<version>15.2.
|
|
12
|
+
<version>15.2.14</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.sqlite</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f43b16dde610ec156175cb668cd613b2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
9db6225163dd59cb122cdb8b3b052f3443be3184
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2728ffec99d5cd97d3b0810a35b5eb50ab208311e44f48b0abb29bde06d92bb9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
eda41993da91ee539667954f812e1cf442264e5171ae8c2d818c3fd637632a8beb2ce5e819e322a2b2319fa723988815fd7a0eabdcb6536d6d9076cd533888f7
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>host.exp.exponent</groupId>
|
|
4
4
|
<artifactId>expo.modules.sqlite</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>15.2.
|
|
7
|
-
<release>15.2.
|
|
6
|
+
<latest>15.2.14</latest>
|
|
7
|
+
<release>15.2.14</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>15.2.
|
|
9
|
+
<version>15.2.14</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250707142021</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
36ff5096cf416de7a88c8613366f820c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d65c02acaa5113e0fc92e3d8d3d18157fffe7450
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
fbda69b0165260d003101f34e445cba21fbe9fb8560785e4dbcb55c3cd9423bd
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4708b0055673b93faf58e7e428b549dcf9b1dd98cd9a2007e776d0a9104812c19500cfa0b9785170929ddbc9ad3921644500d7d21bc0f8fc7efd26c3d0b3c2c8
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-sqlite",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.14",
|
|
4
4
|
"description": "Provides access to a database using SQLite (https://www.sqlite.org/). The database is persisted across restarts of your app.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@testing-library/react-native": "^13.1.0",
|
|
56
56
|
"@types/better-sqlite3": "^7.6.6",
|
|
57
57
|
"better-sqlite3": "^11.6.0",
|
|
58
|
-
"expo-module-scripts": "^4.1.
|
|
58
|
+
"expo-module-scripts": "^4.1.9",
|
|
59
59
|
"react-error-boundary": "^4.0.11"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"react": "*",
|
|
64
64
|
"react-native": "*"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "03398e0a2fa4f1bceebbf3a73c7bfb956a3ed18b"
|
|
67
67
|
}
|
package/src/hooks.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Asset } from 'expo-asset';
|
|
2
|
-
import React, { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { createContext, memo, useContext, useEffect, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import ExpoSQLite from './ExpoSQLite';
|
|
5
5
|
import type { SQLiteOpenOptions } from './NativeDatabase';
|
|
@@ -90,26 +90,36 @@ const SQLiteContext = createContext<SQLiteDatabase | null>(null);
|
|
|
90
90
|
* Context.Provider component that provides a SQLite database to all children.
|
|
91
91
|
* All descendants of this component will be able to access the database using the [`useSQLiteContext`](#usesqlitecontext) hook.
|
|
92
92
|
*/
|
|
93
|
-
export
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
export const SQLiteProvider = memo(
|
|
94
|
+
function SQLiteProvider({
|
|
95
|
+
children,
|
|
96
|
+
onError,
|
|
97
|
+
useSuspense = false,
|
|
98
|
+
...props
|
|
99
|
+
}: SQLiteProviderProps) {
|
|
100
|
+
if (onError != null && useSuspense) {
|
|
101
|
+
throw new Error('Cannot use `onError` with `useSuspense`, use error boundaries instead.');
|
|
102
|
+
}
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
if (useSuspense) {
|
|
105
|
+
return <SQLiteProviderSuspense {...props}>{children}</SQLiteProviderSuspense>;
|
|
106
|
+
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
108
|
+
return (
|
|
109
|
+
<SQLiteProviderNonSuspense {...props} onError={onError}>
|
|
110
|
+
{children}
|
|
111
|
+
</SQLiteProviderNonSuspense>
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
(prevProps: SQLiteProviderProps, nextProps: SQLiteProviderProps) =>
|
|
115
|
+
prevProps.databaseName === nextProps.databaseName &&
|
|
116
|
+
deepEqual(prevProps.options, nextProps.options) &&
|
|
117
|
+
deepEqual(prevProps.assetSource, nextProps.assetSource) &&
|
|
118
|
+
prevProps.directory === nextProps.directory &&
|
|
119
|
+
prevProps.onInit === nextProps.onInit &&
|
|
120
|
+
prevProps.onError === nextProps.onError &&
|
|
121
|
+
prevProps.useSuspense === nextProps.useSuspense
|
|
122
|
+
);
|
|
113
123
|
|
|
114
124
|
/**
|
|
115
125
|
* A global hook for accessing the SQLite database across components.
|
|
@@ -323,6 +333,28 @@ export async function importDatabaseFromAssetAsync(
|
|
|
323
333
|
);
|
|
324
334
|
}
|
|
325
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Compares two objects deeply for equality.
|
|
338
|
+
*/
|
|
339
|
+
export function deepEqual(
|
|
340
|
+
a: { [key: string]: any } | undefined,
|
|
341
|
+
b: { [key: string]: any } | undefined
|
|
342
|
+
): boolean {
|
|
343
|
+
if (a === b) {
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
if (a == null || b == null) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
if (typeof a !== 'object' || typeof b !== 'object') {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
return (
|
|
353
|
+
Object.keys(a).length === Object.keys(b).length &&
|
|
354
|
+
Object.keys(a).every((key) => deepEqual(a[key], b[key]))
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
326
358
|
//#endregion
|
|
327
359
|
|
|
328
360
|
//#region Private Suspense API similar to `React.use`
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
69be6e4da7126f8891c756b0198542c1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f7b17938d3c0dc3d2c7f292b447ba69ddf92f72d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4af1b998f3bd238cd20cec405a31ccb9fc9c8def05a492bccfabe09dbfb068e1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
64394d52ae374662d6d10a8b3de45b88e2519aea44f8c2a9b37254b6f1fbe3029299038b440efbbe9a0ad158b5cb03d8d54a5224de9687be27bc16d5b199134e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
663fc2c20647061a51e3175aec23750c
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5fb8ba6b12d31833a7b655624aa78efc74d08d79
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
385625bba12f89b3961b2d2bee881ec0a730c1fe70be8cfe8e063e4b0df07a09
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
c9636b6f853077f5e228cc5005602739d285936378ac1901c0e037bbc6ef949a6e72f6b52c559808856fa74d040f68fb2b76eac9939bb2b4e3c35db5ce84cddc
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
59c2449daf0573d68b7eebacfaca69da
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b8bf7ed434e5a479eb33ea8f025e22dbd39b478f
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ae30d896dcfeeaa903b38fdeb1d9399b868a6dbdb436111c1a97e31d88e3e346
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b9133adfd63dd2be8419bdce11c729358141021ee0553bfff08eea4fc46c660ae73fd17319c3d950d2fc026d79276fb2041b56cedd8ffacd2a835443236b78bf
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|