@minnowdb/core 0.9.0 → 0.9.1
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/dist/storage/opfs/store.js +22 -10
- package/package.json +1 -1
|
@@ -954,23 +954,35 @@ for (const method of RPC_METHODS) {
|
|
|
954
954
|
}
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
|
+
const DELETE_LOCK_WAIT_MS = 1e3;
|
|
957
958
|
async function deleteOpfsDatabase(options) {
|
|
958
959
|
const encodedName = encodeSegment(validateStorageDatabaseName(options.name));
|
|
959
960
|
const locks = globalThis.navigator?.locks;
|
|
960
961
|
if (locks === void 0)
|
|
961
962
|
throw new Error("Deleting an OPFS database requires Web Locks");
|
|
962
|
-
|
|
963
|
-
|
|
963
|
+
const abort = new AbortController();
|
|
964
|
+
const timer = setTimeout(() => {
|
|
965
|
+
abort.abort();
|
|
966
|
+
}, DELETE_LOCK_WAIT_MS);
|
|
967
|
+
try {
|
|
968
|
+
await locks.request(connectionLockName(options.name), { mode: "exclusive", signal: abort.signal }, async () => {
|
|
969
|
+
const root = options.root ?? await navigator.storage.getDirectory();
|
|
970
|
+
try {
|
|
971
|
+
const namespace = await root.getDirectoryHandle("minnowdb");
|
|
972
|
+
await namespace.removeEntry(encodedName, { recursive: true });
|
|
973
|
+
} catch (error) {
|
|
974
|
+
if (!isDomError(error, "NotFoundError"))
|
|
975
|
+
throw error;
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
} catch (error) {
|
|
979
|
+
if (abort.signal.aborted && isDomError(error, "AbortError")) {
|
|
964
980
|
throw new OpfsDatabaseInUseError(options.name);
|
|
965
|
-
const root = options.root ?? await navigator.storage.getDirectory();
|
|
966
|
-
try {
|
|
967
|
-
const namespace = await root.getDirectoryHandle("minnowdb");
|
|
968
|
-
await namespace.removeEntry(encodedName, { recursive: true });
|
|
969
|
-
} catch (error) {
|
|
970
|
-
if (!isDomError(error, "NotFoundError"))
|
|
971
|
-
throw error;
|
|
972
981
|
}
|
|
973
|
-
|
|
982
|
+
throw error;
|
|
983
|
+
} finally {
|
|
984
|
+
clearTimeout(timer);
|
|
985
|
+
}
|
|
974
986
|
}
|
|
975
987
|
function connectionLockName(name) {
|
|
976
988
|
return `minnowdb-opfs-connections:${name}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minnowdb/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "A columnar SQL database for the browser: PostgreSQL-style SQL over durable IndexedDB or OPFS data, with no server or WebAssembly module.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Wilhite",
|