Skip to content

Commit

Permalink
Merge pull request #25 from quolpr/safari-await-open
Browse files Browse the repository at this point in the history
Safari 14 IndexedDB fix
  • Loading branch information
jlongster committed Oct 13, 2021
2 parents 5cc7dad + 39dabd8 commit ade37d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"README.md",
"dist/**/*",
"src/**/*"
]
],
"dependencies": {
"safari-14-idb-fix": "^1.0.4"
}
}
3 changes: 3 additions & 0 deletions src/indexeddb/file-ops-fallback.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LOCK_TYPES, isSafeToWrite, getPageSize } from '../sqlite-util';
import idbReady from 'safari-14-idb-fix';

function positionToKey(pos, blockSize) {
// We are forced to round because of floating point error. `pos`
Expand All @@ -7,6 +8,8 @@ function positionToKey(pos, blockSize) {
}

async function openDb(name) {
await idbReady();

return new Promise((resolve, reject) => {
let req = globalThis.indexedDB.open(name, 2);
req.onsuccess = event => {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5209,6 +5209,11 @@ rw@1:
resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4"
integrity sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q=

safari-14-idb-fix@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/safari-14-idb-fix/-/safari-14-idb-fix-1.0.4.tgz#5c68ba63e2a8ae0d89a0aa1e13fe89e3aef7da19"
integrity sha512-4+Y2baQdgJpzu84d0QjySl70Kyygzf0pepVg8NVg4NnQEPpfC91fAn0baNvtStlCjUUxxiu0BOMiafa98fRRuA==

[email protected], safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
Expand Down

0 comments on commit ade37d9

Please sign in to comment.