Add ability to disable indexeddb

This commit is contained in:
Ethan O'Brien 2024-02-01 13:31:36 -06:00
parent 8ddd13c5f3
commit 905e3010e6
4 changed files with 37 additions and 5 deletions

View file

@ -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");

View file

@ -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 {

View file

@ -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;

View file

@ -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);