Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari 14 IndexedDB fix #25

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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