Skip to content

Commit 0a1c2b5

Browse files
committed
vite errors out because the manager uses version 3
1 parent 5a7fc79 commit 0a1c2b5

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

packages/installations/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
},
5151
"devDependencies": {
5252
"@firebase/app": "0.7.8",
53-
"rollup": "2.57.0",
5453
"@rollup/plugin-commonjs": "21.0.0",
5554
"@rollup/plugin-json": "4.1.0",
5655
"@rollup/plugin-node-resolve": "13.0.5",
56+
"rollup": "2.57.0",
5757
"rollup-plugin-typescript2": "0.30.0",
5858
"rollup-plugin-uglify": "6.0.4",
5959
"typescript": "4.2.2"
@@ -62,9 +62,9 @@
6262
"@firebase/app": "0.x"
6363
},
6464
"dependencies": {
65-
"@firebase/util": "1.4.2",
6665
"@firebase/component": "0.5.9",
67-
"idb": "3.0.2",
66+
"@firebase/util": "1.4.2",
67+
"idb": "6.1.5",
6868
"tslib": "^2.1.0"
6969
}
70-
}
70+
}

packages/installations/src/helpers/idb-manager.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,31 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { DB, openDb } from 'idb';
18+
import { openDB } from 'idb';
1919
import { AppConfig } from '../interfaces/installation-impl';
2020
import { InstallationEntry } from '../interfaces/installation-entry';
2121
import { getKey } from '../util/get-key';
2222
import { fidChanged } from './fid-changed';
23+
import type { IDBPDatabase } from 'idb';
2324

2425
const DATABASE_NAME = 'firebase-installations-database';
2526
const DATABASE_VERSION = 1;
2627
const OBJECT_STORE_NAME = 'firebase-installations-store';
2728

28-
let dbPromise: Promise<DB> | null = null;
29-
function getDbPromise(): Promise<DB> {
29+
let dbPromise: Promise<IDBPDatabase> | null = null;
30+
function getDbPromise(): Promise<IDBPDatabase> {
3031
if (!dbPromise) {
31-
dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, upgradeDB => {
32-
// We don't use 'break' in this switch statement, the fall-through
33-
// behavior is what we want, because if there are multiple versions between
34-
// the old version and the current version, we want ALL the migrations
35-
// that correspond to those versions to run, not only the last one.
36-
// eslint-disable-next-line default-case
37-
switch (upgradeDB.oldVersion) {
38-
case 0:
39-
upgradeDB.createObjectStore(OBJECT_STORE_NAME);
32+
dbPromise = openDB(DATABASE_NAME, DATABASE_VERSION, {
33+
upgrade: (upgradeDB, oldVersion) => {
34+
// We don't use 'break' in this switch statement, the fall-through
35+
// behavior is what we want, because if there are multiple versions between
36+
// the old version and the current version, we want ALL the migrations
37+
// that correspond to those versions to run, not only the last one.
38+
// eslint-disable-next-line default-case
39+
switch (oldVersion) {
40+
case 0:
41+
upgradeDB.createObjectStore(OBJECT_STORE_NAME);
42+
}
4043
}
4144
});
4245
}
@@ -66,7 +69,7 @@ export async function set<ValueType extends InstallationEntry>(
6669
const objectStore = tx.objectStore(OBJECT_STORE_NAME);
6770
const oldValue = await objectStore.get(key);
6871
await objectStore.put(value, key);
69-
await tx.complete;
72+
await tx.done;
7073

7174
if (!oldValue || oldValue.fid !== value.fid) {
7275
fidChanged(appConfig, value.fid);
@@ -81,7 +84,7 @@ export async function remove(appConfig: AppConfig): Promise<void> {
8184
const db = await getDbPromise();
8285
const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');
8386
await tx.objectStore(OBJECT_STORE_NAME).delete(key);
84-
await tx.complete;
87+
await tx.done;
8588
}
8689

8790
/**
@@ -106,7 +109,7 @@ export async function update<ValueType extends InstallationEntry | undefined>(
106109
} else {
107110
await store.put(newValue, key);
108111
}
109-
await tx.complete;
112+
await tx.done;
110113

111114
if (newValue && (!oldValue || oldValue.fid !== newValue.fid)) {
112115
fidChanged(appConfig, newValue.fid);
@@ -119,5 +122,5 @@ export async function clear(): Promise<void> {
119122
const db = await getDbPromise();
120123
const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');
121124
await tx.objectStore(OBJECT_STORE_NAME).clear();
122-
await tx.complete;
125+
await tx.done;
123126
}

0 commit comments

Comments
 (0)