From 905e3010e6469cf1f9798e074b82394ae0a0f842 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:31:36 -0600 Subject: [PATCH] Add ability to disable indexeddb --- data/emulator.js | 19 ++++++++++++++----- data/loader.js | 1 + data/storage.js | 21 +++++++++++++++++++++ index.html | 1 + 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/data/emulator.js b/data/emulator.js index 15b766e..83c3f97 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -304,11 +304,20 @@ class EmulatorJS { return check; })(); this.isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); - this.storage = { - rom: new window.EJS_STORAGE("EmulatorJS-roms", "rom"), - bios: new window.EJS_STORAGE("EmulatorJS-bios", "bios"), - core: new window.EJS_STORAGE("EmulatorJS-core", "core"), - states: new window.EJS_STORAGE("EmulatorJS-states", "states") + if (config.disableDatabases) { + this.storage = { + rom: new window.EJS_DUMMYSTORAGE(), + bios: new window.EJS_DUMMYSTORAGE(), + core: new window.EJS_DUMMYSTORAGE(), + states: new window.EJS_DUMMYSTORAGE() + } + } else { + this.storage = { + rom: new window.EJS_STORAGE("EmulatorJS-roms", "rom"), + bios: new window.EJS_STORAGE("EmulatorJS-bios", "bios"), + core: new window.EJS_STORAGE("EmulatorJS-core", "core"), + states: new window.EJS_STORAGE("EmulatorJS-states", "states") + } } this.game.classList.add("ejs_game"); diff --git a/data/loader.js b/data/loader.js index b079806..0bb7200 100644 --- a/data/loader.js +++ b/data/loader.js @@ -109,6 +109,7 @@ config.softLoad = window.EJS_softLoad; config.screenRecording = window.EJS_screenRecording; config.externalFiles = window.EJS_externalFiles; + config.disableDatabases = window.EJS_disableDatabases; if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") { try { diff --git a/data/storage.js b/data/storage.js index b4121c0..d7da688 100644 --- a/data/storage.js +++ b/data/storage.js @@ -101,4 +101,25 @@ class EJS_STORAGE { }) } } + +class EJS_DUMMYSTORAGE { + constructor() {} + addFileToDB() { + return new Promise(resolve => resolve()); + } + get() { + return new Promise(resolve => resolve()); + } + put() { + return new Promise(resolve => resolve()); + } + remove() { + return new Promise(resolve => resolve()); + } + getSizes() { + return new Promise(resolve => resolve({})); + } +} + window.EJS_STORAGE = EJS_STORAGE; +window.EJS_DUMMYSTORAGE = EJS_DUMMYSTORAGE; diff --git a/index.html b/index.html index 912b70e..fe6b85f 100644 --- a/index.html +++ b/index.html @@ -231,6 +231,7 @@ window.EJS_pathtodata = "data/"; window.EJS_startOnLoaded = true; window.EJS_DEBUG_XX = enableDebug; + window.EJS_disableDatabases = true; script.src = "data/loader.js"; document.body.appendChild(script);