(async function() { const scripts = [ "emulator.js", "nipplejs.js", "shaders.js", "storage.js", "gamepad.js", "GameManager.js", "socket.io.min.js", "compression.js" ]; const folderPath = (path) => path.substring(0, path.length - path.split('/').pop().length); let scriptPath = (typeof window.EJS_pathtodata === "string") ? window.EJS_pathtodata : folderPath((new URL(document.currentScript.src)).pathname); if (!scriptPath.endsWith('/')) scriptPath+='/'; //console.log(scriptPath); function loadScript(file) { return new Promise(function (resolve, reject) { let script = document.createElement('script'); script.src = function() { if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] === 'string') { return EJS_paths[file]; } else if (file.endsWith("emulator.min.js")) { return scriptPath + file; } else { return scriptPath + "src/" + file; } }(); script.onload = resolve; script.onerror = () => { filesmissing(file).then(e => resolve()); } document.head.appendChild(script); }) } function loadStyle(file) { return new Promise(function(resolve, reject) { let css = document.createElement('link'); css.rel = 'stylesheet'; css.href = function() { if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] === 'string') { return EJS_paths[file]; } else { return scriptPath+file; } }(); css.onload = resolve; css.onerror = () => { filesmissing(file).then(e => resolve()); } document.head.appendChild(css); }) } async function filesmissing(file) { console.error("Failed to load " + file); let minifiedFailed = file.includes(".min.") && !file.includes("socket"); console[minifiedFailed?"warn":"error"]("Failed to load " + file + " beacuse it's likly that the minified files are missing.\nTo fix this you have 3 options:\n1. You can download the zip from the latest release here: https://github.com/EmulatorJS/EmulatorJS/releases/latest - Stable\n2. You can download the zip from here: https://cdn.emulatorjs.org/latest/data/emulator.min.zip and extract it to the data/ folder. (easiest option) - Beta\n3. You can build the files by running `npm i && npm run build` in the data/minify folder. (hardest option) - Beta\nNote: you will probably need to do the same for the cores, extract them to the data/cores/ folder."); if (minifiedFailed) { console.log("Attempting to load non-minified files"); if (file === "emulator.min.js") { for (let i=0; i window.EJS_emulator.adBlocked(url, del); if (typeof window.EJS_ready === "function") { window.EJS_emulator.on("ready", window.EJS_ready); } if (typeof window.EJS_onGameStart === "function") { window.EJS_emulator.on("start", window.EJS_onGameStart); } if (typeof window.EJS_onLoadState === "function") { window.EJS_emulator.on("loadState", window.EJS_onLoadState); } if (typeof window.EJS_onSaveState === "function") { window.EJS_emulator.on("saveState", window.EJS_onSaveState); } if (typeof window.EJS_onLoadSave === "function") { window.EJS_emulator.on("loadSave", window.EJS_onLoadSave); } if (typeof window.EJS_onSaveSave === "function") { window.EJS_emulator.on("saveSave", window.EJS_onSaveSave); } })();