| 1 | import { wrap } from './wrap-idb-value.js'; |
| 2 | |
| 3 | export interface OpenDBCallbacks<DBTypes extends DBSchema | unknown> { |
| 4 | /** |
| 5 | * Called if this version of the database has never been opened before. Use it to specify the |
| 6 | * schema for the database. |
| 7 | * |
| 8 | * @param database A database instance that you can use to add/remove stores and indexes. |
| 9 | * @param oldVersion Last version of the database opened by the user. |
| 10 | * @param newVersion Whatever new version you provided. |
| 11 | * @param transaction The transaction for this upgrade. |
| 12 | * This is useful if you need to get data from other stores as part of a migration. |
| 13 | * @param event The event object for the associated 'upgradeneeded' event. |
| 14 | */ |
| 15 | upgrade?( |
| 16 | database: IDBPDatabase<DBTypes>, |
| 17 | oldVersion: number, |
| 18 | newVersion: number | null, |
| 19 | transaction: IDBPTransaction< |
| 20 | DBTypes, |
| 21 | StoreNames<DBTypes>[], |
| 22 | 'versionchange' |
| 23 | >, |
| 24 | event: IDBVersionChangeEvent, |
| 25 | ): void; |
| 26 | /** |
| 27 | * Called if there are older versions of the database open on the origin, so this version cannot |
| 28 | * open. |
| 29 | * |
| 30 | * @param currentVersion Version of the database that's blocking this one. |
| 31 | * @param blockedVersion The version of the database being blocked (whatever version you provided to `openDB`). |
| 32 | * @param event The event object for the associated `blocked` event. |
| 33 | */ |
| 34 | blocked?( |
| 35 | currentVersion: number, |
| 36 | blockedVersion: number | null, |
| 37 | event: IDBVersionChangeEvent, |
| 38 | ): void; |
| 39 | /** |
| 40 | * Called if this connection is blocking a future version of the database from opening. |
| 41 | * |
| 42 | * @param currentVersion Version of the open database (whatever version you provided to `openDB`). |
| 43 | * @param blockedVersion The version of the database that's being blocked. |
| 44 | * @param event The event object for the associated `versionchange` event. |
| 45 | */ |
| 46 | blocking?( |
| 47 | currentVersion: number, |
| 48 | blockedVersion: number | null, |
| 49 | event: IDBVersionChangeEvent, |
| 50 | ): void; |
| 51 | /** |
| 52 | * Called if the browser abnormally terminates the connection. |
| 53 | * This is not called when `db.close()` is called. |
| 54 | */ |
| 55 | terminated?(): void; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Open a database. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…