expo-sqlite 15.2.3 → 15.2.5
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 +8 -0
- package/android/build.gradle +2 -2
- package/build/hooks.js.map +1 -1
- package/build/paramUtils.d.ts.map +1 -1
- package/build/paramUtils.js +2 -0
- package/build/paramUtils.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3.module → 15.2.5/expo.modules.sqlite-15.2.5.module} +7 -7
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3.pom → 15.2.5/expo.modules.sqlite-15.2.5.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.5/expo.modules.sqlite-15.2.5.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 +2 -2
- package/src/paramUtils.ts +4 -2
- package/src/ts-declarations/whatwg-url-without-unicode.d.ts +4 -0
- package/web/SQLiteModule.ts +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/15.2.3/expo.modules.sqlite-15.2.3.pom.sha512 +0 -1
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3-sources.jar → 15.2.5/expo.modules.sqlite-15.2.5-sources.jar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3-sources.jar.md5 → 15.2.5/expo.modules.sqlite-15.2.5-sources.jar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3-sources.jar.sha1 → 15.2.5/expo.modules.sqlite-15.2.5-sources.jar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3-sources.jar.sha256 → 15.2.5/expo.modules.sqlite-15.2.5-sources.jar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3-sources.jar.sha512 → 15.2.5/expo.modules.sqlite-15.2.5-sources.jar.sha512} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3.aar → 15.2.5/expo.modules.sqlite-15.2.5.aar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3.aar.md5 → 15.2.5/expo.modules.sqlite-15.2.5.aar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3.aar.sha1 → 15.2.5/expo.modules.sqlite-15.2.5.aar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3.aar.sha256 → 15.2.5/expo.modules.sqlite-15.2.5.aar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{15.2.3/expo.modules.sqlite-15.2.3.aar.sha512 → 15.2.5/expo.modules.sqlite-15.2.5.aar.sha512} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 15.2.5 — 2025-04-14
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 15.2.4 — 2025-04-11
|
|
18
|
+
|
|
19
|
+
_This version does not introduce any user-facing changes._
|
|
20
|
+
|
|
13
21
|
## 15.2.3 — 2025-04-11
|
|
14
22
|
|
|
15
23
|
_This version does not introduce any user-facing changes._
|
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.5'
|
|
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.5"
|
|
55
55
|
buildConfigField "boolean", "USE_LIBSQL", project.ext.USE_LIBSQL.toString()
|
|
56
56
|
|
|
57
57
|
externalNativeBuild {
|
package/build/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,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,UAAU,cAAc,CAAC,EAC7B,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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AC;QACvB,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACzC,MAAM,OAAO,CAAC,MAAM,CAAC;QACvB,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,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, 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) {\n setError(e);\n }\n }\n\n async function teardown(db: SQLiteDatabase | null) {\n try {\n await db?.closeAsync();\n } catch (e) {\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,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA6E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K,CACpC,CAAC;AACJ,CAAC;AAaD,6IAA6I;AAC7I;;GAEG;AACH,SAAS,GAAG,CAAI,OAAwC;IACtD,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACnE,CAAC;YACD,OAAO,OAAO,CAAC,KAAK,CAAC;QACvB,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACzC,MAAM,OAAO,CAAC,MAAM,CAAC;QACvB,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,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, 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paramUtils.d.ts","sourceRoot":"","sources":["../src/paramUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAEpB,yBAAyB,EAEzB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,MAAM,EAAE,GAAG,EAAE,GACf,CAAC,yBAAyB,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAgC5D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"paramUtils.d.ts","sourceRoot":"","sources":["../src/paramUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAEpB,yBAAyB,EAEzB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,MAAM,EAAE,GAAG,EAAE,GACf,CAAC,yBAAyB,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAgC5D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,GAAG,CAAC,CAYjG;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,WAAW,EAAE,iBAAiB,EAC9B,gBAAgB,EAAE,kBAAkB,EAAE,GACrC,CAAC,EAAE,CAoBL"}
|
package/build/paramUtils.js
CHANGED
|
@@ -38,6 +38,7 @@ export function normalizeParams(...params) {
|
|
|
38
38
|
* @hidden
|
|
39
39
|
*/
|
|
40
40
|
export function composeRow(columnNames, columnValues) {
|
|
41
|
+
// TODO(cedric): make these types more generic and tighten the returned object type based on provided column names/values
|
|
41
42
|
const row = {};
|
|
42
43
|
if (columnNames.length !== columnValues.length) {
|
|
43
44
|
throw new Error(`Column names and values count mismatch. Names: ${columnNames.length}, Values: ${columnValues.length}`);
|
|
@@ -61,6 +62,7 @@ export function composeRows(columnNames, columnValuesList) {
|
|
|
61
62
|
}
|
|
62
63
|
const results = [];
|
|
63
64
|
for (const columnValues of columnValuesList) {
|
|
65
|
+
// TODO(cedric): make these types more generic and tighten the returned object type based on provided column names/values
|
|
64
66
|
const row = {};
|
|
65
67
|
for (let i = 0; i < columnNames.length; i++) {
|
|
66
68
|
row[columnNames[i]] = columnValues[i];
|
package/build/paramUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paramUtils.js","sourceRoot":"","sources":["../src/paramUtils.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAG,MAAa;IAEhB,IAAI,UAAU,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAE,MAAM,CAAC,CAAC,CAAsB,CAAC;IAC9E,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,UAAU,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,IACE,OAAO,UAAU,KAAK,QAAQ;QAC9B,UAAU,YAAY,WAAW;QACjC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,EAC9B,CAAC;QACD,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;IACD,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,UAAU,GAAG,UAAU,CAAC,MAAM,CAAkC,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACpF,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;YACnB,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACT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,EAAE,CAAC;QAClC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACtD,yFAAyF;QACzF,MAAM,IAAI,KAAK,CACb,kDAAkD,WAAW,CAAC,MAAM,aAAa,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAC9G,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,KAAK,MAAM,YAAY,IAAI,gBAAgB,EAAE,CAAC;QAC5C,yHAAyH;QACzH,MAAM,GAAG,GAAuE,EAAE,CAAC;QACnF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5C,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAQ,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n SQLiteBindBlobParams,\n SQLiteBindParams,\n SQLiteBindPrimitiveParams,\n SQLiteBindValue,\n type SQLiteColumnNames,\n type SQLiteColumnValues,\n} from './NativeStatement';\n\n/**\n * Normalize the bind params to data structure that can be passed to native module.\n * The data structure is a tuple of [primitiveParams, blobParams, shouldPassAsArray].\n * @hidden\n */\nexport function normalizeParams(\n ...params: any[]\n): [SQLiteBindPrimitiveParams, SQLiteBindBlobParams, boolean] {\n let bindParams = params.length > 1 ? params : (params[0] as SQLiteBindParams);\n if (bindParams == null) {\n bindParams = [];\n }\n if (\n typeof bindParams !== 'object' ||\n bindParams instanceof ArrayBuffer ||\n ArrayBuffer.isView(bindParams)\n ) {\n bindParams = [bindParams];\n }\n const shouldPassAsArray = Array.isArray(bindParams);\n if (Array.isArray(bindParams)) {\n bindParams = bindParams.reduce<Record<string, SQLiteBindValue>>((acc, value, index) => {\n acc[index] = value;\n return acc;\n }, {});\n }\n\n const primitiveParams: SQLiteBindPrimitiveParams = {};\n const blobParams: SQLiteBindBlobParams = {};\n for (const key in bindParams) {\n const value = bindParams[key];\n if (value instanceof Uint8Array) {\n blobParams[key] = value;\n } else {\n primitiveParams[key] = value;\n }\n }\n\n return [primitiveParams, blobParams, shouldPassAsArray];\n}\n\n/**\n * Compose `columnNames` and `columnValues` to an row object.\n * @hidden\n */\nexport function composeRow<T>(columnNames: SQLiteColumnNames, columnValues: SQLiteColumnValues): T {\n // TODO(cedric): make these types more generic and tighten the returned object type based on provided column names/values\n const row: { [key in SQLiteColumnNames[number]]: SQLiteColumnValues[number] } = {};\n if (columnNames.length !== columnValues.length) {\n throw new Error(\n `Column names and values count mismatch. Names: ${columnNames.length}, Values: ${columnValues.length}`\n );\n }\n for (let i = 0; i < columnNames.length; i++) {\n row[columnNames[i]] = columnValues[i];\n }\n return row as T;\n}\n\n/**\n * Compose `columnNames` and `columnValuesList` to an array of row objects.\n * @hidden\n */\nexport function composeRows<T>(\n columnNames: SQLiteColumnNames,\n columnValuesList: SQLiteColumnValues[]\n): T[] {\n if (columnValuesList.length === 0) {\n return [];\n }\n if (columnNames.length !== columnValuesList[0].length) {\n // We only check the first row because SQLite returns the same column count for all rows.\n throw new Error(\n `Column names and values count mismatch. Names: ${columnNames.length}, Values: ${columnValuesList[0].length}`\n );\n }\n const results: T[] = [];\n for (const columnValues of columnValuesList) {\n // TODO(cedric): make these types more generic and tighten the returned object type based on provided column names/values\n const row: { [key in SQLiteColumnNames[number]]: SQLiteColumnValues[number] } = {};\n for (let i = 0; i < columnNames.length; i++) {\n row[columnNames[i]] = columnValues[i];\n }\n results.push(row as T);\n }\n return results;\n}\n"]}
|
package/expo-module.config.json
CHANGED
|
@@ -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.5",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.sqlite-15.2.
|
|
28
|
-
"url": "expo.modules.sqlite-15.2.
|
|
27
|
+
"name": "expo.modules.sqlite-15.2.5.aar",
|
|
28
|
+
"url": "expo.modules.sqlite-15.2.5.aar",
|
|
29
29
|
"size": 3757128,
|
|
30
30
|
"sha512": "da8d096e6b7df2f95f6eceaff0bd1855fb876df9d7b740b5a5523449213115c43b2cf40bade6d90c6aafedb55133a5394e2546d3938444f74b940fbed169aa82",
|
|
31
31
|
"sha256": "3386211fe7b21f21e5ef2cebedd6c166c875b1a3f608353a49408d1af1c8b80b",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
],
|
|
54
54
|
"files": [
|
|
55
55
|
{
|
|
56
|
-
"name": "expo.modules.sqlite-15.2.
|
|
57
|
-
"url": "expo.modules.sqlite-15.2.
|
|
56
|
+
"name": "expo.modules.sqlite-15.2.5.aar",
|
|
57
|
+
"url": "expo.modules.sqlite-15.2.5.aar",
|
|
58
58
|
"size": 3757128,
|
|
59
59
|
"sha512": "da8d096e6b7df2f95f6eceaff0bd1855fb876df9d7b740b5a5523449213115c43b2cf40bade6d90c6aafedb55133a5394e2546d3938444f74b940fbed169aa82",
|
|
60
60
|
"sha256": "3386211fe7b21f21e5ef2cebedd6c166c875b1a3f608353a49408d1af1c8b80b",
|
|
@@ -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.5-sources.jar",
|
|
77
|
+
"url": "expo.modules.sqlite-15.2.5-sources.jar",
|
|
78
78
|
"size": 11071,
|
|
79
79
|
"sha512": "4917cf35bb225309902a2482186f53d3cdde720c66d66ecf0dfa7aa42684a6ac4af424f8ea0e2bc7f7095b6301c1560ccb1fe9b224d8179e86e73e2c0a4c96c1",
|
|
80
80
|
"sha256": "df4580eb041e8620081acf960e64263a63771e856a40cc5ee17fa654fe3672da",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ecd4308501f71cea62d90385d094f27c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3600b1247828db8c3f2582d0f2fb4e46a8bc2f0e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b09cdf5a3d7704e4830be6af5d02ba80808949c28126514e996bff372fc6e6c5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
25c74881730f1082ca0f2890770559e13999b9bf2d027803ccf73b0fce0a0702e383c6959810f4345709b7e893c640b2db0c30c70f5b2154632bf5440c134252
|
|
@@ -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.5</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
|
+
5975f62406d652a12e7ae08fd67fedc2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ae21add602b8309310f22484f428da8d395f57c6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
72991eda1a8fe05f1e8279ff486685be6cdc2cb18e5db725273c0edcb0f496ff
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
178b78e10a2c38160ebd43e14340674b3aab5235bdabe591f20693ed2e1681192101461a49d3bdd6190ffba389204ad2e8409ac3d0742faf161c1b4a61c9d5c5
|
|
@@ -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.5</latest>
|
|
7
|
+
<release>15.2.5</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>15.2.
|
|
9
|
+
<version>15.2.5</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250414184227</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
77305bf6271a8b0b57984d44837ebaad
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
bc2a5e07f4334ddac17a129e8921b28620086722
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
535f1881d2f57474c9fec2a8afb2b7dc02c3dd9e05f5981ed8b50aa7f3122973
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ec969513f0cc7ddf46d5fe2733cfca7ca80879dca658ac52e971cc51c2c3ffdd33ca036f6ed56b5649fe4cc0498a44e3cce7c88b7d87d4a6b31218e2b42113a7
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-sqlite",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.5",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@testing-library/react-native": "^13.1.0",
|
|
54
54
|
"@types/better-sqlite3": "^7.6.6",
|
|
55
55
|
"better-sqlite3": "^11.6.0",
|
|
56
|
-
"expo-module-scripts": "^4.1.
|
|
56
|
+
"expo-module-scripts": "^4.1.2",
|
|
57
57
|
"react-error-boundary": "^4.0.11"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"react": "*",
|
|
62
62
|
"react-native": "*"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "335e9312f5caf634097354a230f0d4bbbfb9b0ba"
|
|
65
65
|
}
|
package/src/hooks.tsx
CHANGED
|
@@ -195,7 +195,7 @@ function SQLiteProviderNonSuspense({
|
|
|
195
195
|
});
|
|
196
196
|
databaseRef.current = db;
|
|
197
197
|
setLoading(false);
|
|
198
|
-
} catch (e) {
|
|
198
|
+
} catch (e: any) {
|
|
199
199
|
setError(e);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
@@ -203,7 +203,7 @@ function SQLiteProviderNonSuspense({
|
|
|
203
203
|
async function teardown(db: SQLiteDatabase | null) {
|
|
204
204
|
try {
|
|
205
205
|
await db?.closeAsync();
|
|
206
|
-
} catch (e) {
|
|
206
|
+
} catch (e: any) {
|
|
207
207
|
setError(e);
|
|
208
208
|
}
|
|
209
209
|
}
|
package/src/paramUtils.ts
CHANGED
|
@@ -53,7 +53,8 @@ export function normalizeParams(
|
|
|
53
53
|
* @hidden
|
|
54
54
|
*/
|
|
55
55
|
export function composeRow<T>(columnNames: SQLiteColumnNames, columnValues: SQLiteColumnValues): T {
|
|
56
|
-
|
|
56
|
+
// TODO(cedric): make these types more generic and tighten the returned object type based on provided column names/values
|
|
57
|
+
const row: { [key in SQLiteColumnNames[number]]: SQLiteColumnValues[number] } = {};
|
|
57
58
|
if (columnNames.length !== columnValues.length) {
|
|
58
59
|
throw new Error(
|
|
59
60
|
`Column names and values count mismatch. Names: ${columnNames.length}, Values: ${columnValues.length}`
|
|
@@ -84,7 +85,8 @@ export function composeRows<T>(
|
|
|
84
85
|
}
|
|
85
86
|
const results: T[] = [];
|
|
86
87
|
for (const columnValues of columnValuesList) {
|
|
87
|
-
|
|
88
|
+
// TODO(cedric): make these types more generic and tighten the returned object type based on provided column names/values
|
|
89
|
+
const row: { [key in SQLiteColumnNames[number]]: SQLiteColumnValues[number] } = {};
|
|
88
90
|
for (let i = 0; i < columnNames.length; i++) {
|
|
89
91
|
row[columnNames[i]] = columnValues[i];
|
|
90
92
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// NOTE(@kitten): We really shouldn't have to reference this, but we get a cascading type error
|
|
2
|
+
// because ts-jest isolates our typings in a way that makes expo-modules-core fail in our tests only
|
|
3
|
+
|
|
4
|
+
/// <reference path="../../../expo/src/ts-declarations/whatwg-url-without-unicode" />
|
package/web/SQLiteModule.ts
CHANGED
|
@@ -447,5 +447,5 @@ export class SQLiteModule extends NativeModule {
|
|
|
447
447
|
readonly NativeSession: typeof NativeSession = NativeSession;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
const SQLiteModuleInstance = registerWebModule(SQLiteModule);
|
|
450
|
+
const SQLiteModuleInstance = registerWebModule(SQLiteModule, 'SQLiteModule');
|
|
451
451
|
export default SQLiteModuleInstance;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
78afd26f474fa331cf29e66ab6757b3a
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5597e5de47b0526c62530ee554e9b176cfe501b6
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
041f65f98b805afa35b4b3c561ac08616c631ef46486168a42393b2046b0b4e3
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f7d6e507ee34ebcd5c93343e06c3d2a9391c716f85f58095c674afec8ddb5963342a6a0629fa460ee2379bb28cf58a8ec5fb95d3796199495bbf9fa1cc47e844
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
746bd550c7824af35f6cbc79ae21014d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
e60cedcda9aa53638520db9c2ba411520fd2dbda
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
9656d32852edb238158d2568974811ee65a7ef36c7d5d23e8aa91993ea0b4660
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1afd41c5a8629ef077b35bfd856fd23337ada257f2f65f799e9348d7206f1ae5d6217486091998f657d9423574158b52fd4160eb25a63874b7dd78f1ecdf750c
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|