diff --git a/index.html b/index.html
index ea479e4..ec08c6b 100644
--- a/index.html
+++ b/index.html
@@ -110,8 +110,7 @@ function loop(deltaT) {
lib.startGameLoop(loop);
-
+
diff --git a/src/gesundheit.js b/src/gesundheit.js
new file mode 100644
index 0000000..4b4807f
--- /dev/null
+++ b/src/gesundheit.js
@@ -0,0 +1,40 @@
+async function asyncIdbRequest(req) {
+ return await new Promise((resolve, reject) => {
+ req.onerror = () => {
+ reject(req.error);
+ };
+
+ req.onsuccess = () => {
+ resolve(req.result);
+ };
+ });
+}
+
+const Idb = new Proxy(globalThis.indexedDB, {
+ get(target, prop, _receiver) {
+ if (typeof target[prop] === "function") {
+ return (...args) => {
+ const req = target[prop](...args);
+ return asyncIdbRequest(req);
+ };
+ }
+ return Reflect.get(...arguments);
+ },
+});
+
+export class Gesundheit {
+ static #isInternalConstructing = false;
+ static #idb = globalThis.indexedDB;
+
+ constructor() {
+ if (!Gesundheit.#isInternalConstructing) {
+ throw new TypeError("Gesundheit is not constructable - use Gesundheit.load()");
+ }
+ Gesundheit.#isInternalConstructing = false;
+ }
+
+ static async load(name) {
+ const db = await Idb.open(name);
+ console.log(db);
+ }
+}
diff --git a/src/index.js b/src/index.js
index 61043f6..f00b19b 100644
--- a/src/index.js
+++ b/src/index.js
@@ -14,6 +14,7 @@ import { TextCompleter } from "./text_completer.js";
import { ConsoleInput } from "./console_input.js";
import { downloadFile, slugify } from "./utils.js";
import { HtmlExporter } from "./html_exporter.js";
+import { Gesundheit } from "./gesundheit.js";
const editor = ace.edit("editor");
editor.setTheme("ace/theme/gruvbox");
@@ -150,3 +151,5 @@ addEventListener("keydown", (ev) => {
});
toggleSpriteEditorButton.addEventListener("click", () => spriteEditor.toggleEditor());
+
+Gesundheit.load("spritedb");