Web-Archives-Misc/public/Archive/retrogamesbot.com/8.chunk.js
2023-01-16 18:46:17 +01:00

1 line
15 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{147:function(t,e,n){t.exports={uiScreen:"_3R5EC",title:"_1ps0h",image:"_3EqVr",subtitle:"_1Z69t",inputSearch:"_24eya",searchError:"_32vIL",terms:"_kjeW",row:"_3hYs8",select:"_3ecUt"}},148:function(t,e,n){},154:function(t,e,n){t.exports={popupOverlay:"_11Bb8"}},155:function(t,e,n){t.exports={searchDialog:"_33XuH",message:"_28yGm",buttons:"_1OXJP"}},25:function(t,e,n){"use strict";n.d(e,"a",(function(){return m}));var r=n(4),o=n(9);class s{constructor(t,e,n,r){this._name=t,this._size=e,this._path=n,this._archiveRef=r}get name(){return this._name}get size(){return this._size}extract(){return this._archiveRef.extractSingleFile(this._path)}}class i{static init(t={}){return i._options={workerUrl:"../dist/worker-bundle.js",...t},i._options}static open(t,e=null){e=e||i._options||i.init()&&console.warn("Automatically initializing using options: ",i._options);return new i(t,e).open()}constructor(t,e){this._worker=n(48)(),this._worker.addEventListener("message",this._workerMsg.bind(this)),this._callbacks=[],this._content={},this._processed=0,this._file=t}async open(){return await this._postMessage({type:"HELLO"},(t,e,n)=>{"READY"===n.type&&t()}),await this._postMessage({type:"OPEN",file:this._file},(t,e,n)=>{"OPENED"===n.type&&t(this)})}close(){this._worker.terminate(),this._worker=null}hasEncryptedData(){return this._postMessage({type:"CHECK_ENCRYPTION"},(t,e,n)=>{"ENCRYPTION_STATUS"===n.type&&t(n.status)})}usePassword(t){return this._postMessage({type:"SET_PASSPHRASE",passphrase:t},(t,e,n)=>{"PASSPHRASE_STATUS"===n.type&&t(n.status)})}getFilesObject(){return this._processed>0?Promise.resolve().then(()=>this._content):this._postMessage({type:"LIST_FILES"},(t,e,n)=>{if("ENTRY"===n.type){const t=n.entry,[e,r]=this._getProp(this._content,t.path);return"FILE"===t.type&&(e[r]=new s(t.fileName,t.size,t.path,this)),!0}"END"===n.type&&(this._processed=1,t(this._cloneContent(this._content)))})}getFilesArray(){return this.getFilesObject().then(t=>this._objectToArray(t))}extractSingleFile(t){if(null===this._worker)throw new Error("Archive already closed");return this._postMessage({type:"EXTRACT_SINGLE_FILE",target:t},(t,e,n)=>{if("FILE"===n.type){t(new File([n.entry.fileData],n.entry.fileName,{type:"application/octet-stream"}))}})}extractFiles(t){return this._processed>1?Promise.resolve().then(()=>this._content):this._postMessage({type:"EXTRACT_FILES"},(e,n,r)=>{if("ENTRY"===r.type){const[e,n]=this._getProp(this._content,r.entry.path);return"FILE"===r.entry.type&&(e[n]=new File([r.entry.fileData],r.entry.fileName,{type:"application/octet-stream"}),void 0!==t&&setTimeout(t.bind(null,{file:e[n],path:r.entry.path}))),!0}"END"===r.type&&(this._processed=2,this._worker.terminate(),e(this._cloneContent(this._content)))})}_cloneContent(t){if(t instanceof File||t instanceof s||null===t)return t;const e={};for(const n of Object.keys(t))e[n]=this._cloneContent(t[n]);return e}_objectToArray(t,e=""){const n=[];for(const r of Object.keys(t))t[r]instanceof File||t[r]instanceof s||null===t[r]?n.push({file:t[r]||r,path:e}):n.push(...this._objectToArray(t[r],`${e}${r}/`));return n}_getProp(t,e){const n=e.split("/");""===n[n.length-1]&&n.pop();let r=t,o=null;for(const t of n)r[t]=r[t]||{},o=r,r=r[t];return[o,n[n.length-1]]}_postMessage(t,e){return this._worker.postMessage(t),new Promise((t,n)=>{this._callbacks.push(this._msgHandler.bind(this,e,t,n))})}_msgHandler(t,e,n,r){if("BUSY"===r.type)n("worker is busy");else{if("ERROR"!==r.type)return t(e,n,r);n(r.error)}}_workerMsg({data:t}){(0,this._callbacks[this._callbacks.length-1])(t)||this._callbacks.pop()}}var a=[],l=function(t,e,n,r){return new(n||(n=Promise))((function(o,s){function i(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,a)}l((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};i.init();var c={smc:"snes",sfc:"snes",bin:"genesis",smd:"genesis",a26:"stella"};function h(t){return l(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,Object(r.request)({url:t,method:"GET",responseType:"blob"})];case 1:return[2,p(e.sent())]}}))}))}function p(t){return l(this,void 0,void 0,(function(){var e,n,r,o,s,a;return u(this,(function(l){switch(l.label){case 0:return[4,i.open(t)];case 1:return[4,(e=l.sent()).extractFiles()];case 2:for(s in n=l.sent())if(n[s]instanceof File){r=n[s],o=s;break}return e.close(),a={name:o},[4,f(r)];case 3:return[2,(a.data=l.sent(),a)]}}))}))}function f(t){return new Promise((function(e,n){var r=new FileReader;r.onload=function(){return e(r.result)},r.onerror=n,r.readAsArrayBuffer(t)}))}function d(t){for(var e,n=t.length-1;n>0;n--){var r=Math.floor(Math.random()*(n+1));e=[t[r],t[n]],t[n]=e[0],t[r]=e[1]}}var m=new(function(){function t(){}return t.prototype.getROM=function(t){var e;return l(this,void 0,void 0,(function(){var n;return u(this,(function(o){switch(o.label){case 0:return this._token===t&&this._rom?[2,this._rom]:(this._token=t,n=this,[4,Object(r.request)({method:"GET",url:"https://europe-west3-retro-games-257212.cloudfunctions.net/session/"+t})]);case 1:if(n._rom=o.sent(),!(null===(e=this._rom)||void 0===e?void 0:e.url))throw new Error("invalid token");return[2,this.loadRom(this._rom)]}}))}))},t.prototype.loadRom=function(t){return l(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e=this,[4,h(t.url)];case 1:return e._rom=r.sent(),this._rom.platform=t.platform,Object(o.f)(this._rom.platform)&&(n=Object(o.d)(this._rom.name),this._rom.platform=c[n]||n),this._rom.platform=this._rom.platform.toLowerCase(),[2,this._rom]}}))}))},t.prototype.loadSearchRom=function(t){return l(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return this._token="local",[4,this.loadRom(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.loadLocalFile=function(t){return l(this,void 0,void 0,(function(){var e,n,r,s,i;return u(this,(function(a){switch(a.label){case 0:return e=t.name.split(".")[0],"zip"!==(n=Object(o.d)(t.name))&&"7z"!==n&&"rar"!==n?[3,2]:(r=this,[4,p(t)]);case 1:return r._rom=a.sent(),n=Object(o.d)(this._rom.name),[3,4];case 2:return s=this,i={name:e},[4,f(t)];case 3:s._rom=(i.data=a.sent(),i),a.label=4;case 4:return this._rom.platform=c[n]||n,this._token="local",[2]}}))}))},t.prototype.getPopularRequests=function(){return l(this,void 0,void 0,(function(){return u(this,(function(t){return d(a),[2,a.slice(0,10)]}))}))},t.prototype.getRandomRequest=function(){return l(this,void 0,void 0,(function(){return u(this,(function(t){return d(a),[2,a[0]]}))}))},t}())},301:function(t,e,n){"use strict";n.r(e),n.d(e,"UiComponent",(function(){return S}));var r=n(4),o=n.n(r),s=n(147),i=n.n(s);function a(){return o()("div",{class:i.a.uiScreen},o()("div",{class:"container is-fluid"},"RETRO GAMES EMULATOR",o()("div",{class:"columns is-centered"},o()("div",{class:"column has-text-centered"},o()("div",{class:i.a.image})),o()("div",{class:"column is-size-2 is-size-4-mobile"},"Meet RetroGamesBot - a game console emulator that doesn't require jailbreak nor installation. You can play directly from your smartphone.")),o()("div",{class:"columns has-text-centered is-size-4 is-size-5-mobile"},o()("div",{class:"column"},"To play your favorite retro games just load the game file (ROM):",o()("br",null),o()("button",{class:"nes-btn",onclick:this.buttonLoadRomHandler.bind(this)},"LOAD ROM")),o()("div",{class:"column has-text-left"},"Supported platforms:",o()("br",null),"- Nintendo Entertainment System",o()("br",null),"- Super Nintendo Entertainment System",o()("br",null),"- Sega Master System",o()("br",null),"- Sega Genesis/Mega Drive",o()("br",null),"- Game Boy",o()("br",null),"- Game Boy Color",o()("br",null),"- Game Boy Advance",o()("br",null),"- Atari 2600",o()("br",null),"- Atari 7800 ProSystem",o()("br",null),"- Atari Jaguar",o()("br",null),"- SuperGrafx",o()("br",null),"- Neo Geo Pocket"))))}n(148);var l=n(5),u=n(25),c=n(8),h=n.n(c),p=(n(149),n(151),n(9)),f=n(154),d=n.n(f),m=function(){function t(){}return t.show=function(t,e){return void 0===e&&(e={}),new Promise((function(n){var s=document.createElement("div");s.classList.add(d.a.popupOverlay),e.onclose||(e.onclose=function(t){Object(r.mount)(s,null),Object(r.redraw)(),setTimeout(s.remove.bind(s),100),n(t)}),document.body.appendChild(s),Object(r.mount)(s,{view:function(){return o()(t,e)}}),Object(r.redraw)()}))},t}(),b=n(155),y=n.n(b),_=n(156),v=n.n(_);function g(){return r("div",{class:v()(y.a.searchDialog,"nes-dialog","is-dark")},r("p",{class:"title"},"WARNING"),r("div",{class:y.a.message},"I use public search engines (basically, I google for you), so please make sure the game you're looking for is legally available. I can't assess what kind of game you're want me to find, therefore the search result may be fraudulent, illegal or corrupted - use it at your own risk (you are responsible for any harm or damage that you suffer as a result)",r("br",null),r("br",null),r("a",{href:"/terms",target:"_blank"},"Terms and Conditions"),r("br",null)),r("br",null),r("div",{class:y.a.buttons},r("button",{class:"nes-btn",onclick:this.buttonCancelHandler.bind(this)},"Cancel"),r("button",{class:"nes-btn is-primary",onclick:this.buttonConfirmHandler.bind(this)},"Confirm")))}var w=function(){function t(){}return t.prototype.oninit=function(t){this._onclose=t.attrs.onclose},t.prototype.buttonCancelHandler=function(){this._onclose()},t.prototype.buttonConfirmHandler=function(){this._onclose(!0)},t.prototype.view=function(){return g.call(this)},t}(),E=function(t,e,n,r){return new(n||(n=Promise))((function(o,s){function i(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,a)}l((r=r.apply(t,e||[])).next())}))},k=function(t,e){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},S=function(){function t(){this._fileChangeHandler=this.fileChangeHandler.bind(this),this._popular=[],this.search=""}return t.prototype.oninit=function(){this._inputElement=document.createElement("input"),this._inputElement.type="file",this._inputElement.style.position="absolute",this._inputElement.style.opacity="0",this._inputElement.style.pointerEvents="none",this._inputElement.addEventListener("change",this._fileChangeHandler),document.body.appendChild(this._inputElement),this.login()},t.prototype.login=function(){return E(this,void 0,void 0,(function(){var t,e,n;return k(this,(function(o){switch(o.label){case 0:return t=this,[4,new Promise((function(t){var e=h.a.auth().onAuthStateChanged((function(n){e(),t(n)}))}))];case 1:return t._user=o.sent(),this._user?[3,3]:[4,h.a.auth().signInAnonymously()];case 2:e=o.sent(),this._user=e.user,o.label=3;case 3:return n=this,[4,u.a.getPopularRequests()];case 4:return n._popular=o.sent(),Object(r.redraw)(),l.a.hide(),[2]}}))}))},t.prototype.fileChangeHandler=function(){return E(this,void 0,void 0,(function(){var t;return k(this,(function(e){switch(e.label){case 0:return 0===this._inputElement.files.length?[2]:(t=this._inputElement.files[0],this._inputElement.value=null,l.a.show(),[4,u.a.loadLocalFile(t)]);case 1:return e.sent(),r.route.set("/game/local"),[2]}}))}))},t.prototype.buttonLoadRomHandler=function(){this._inputElement.click()},t.prototype.buttonSearchHandler=function(){return E(this,void 0,void 0,(function(){var t,e;return k(this,(function(n){switch(n.label){case 0:return Object(p.f)(this.search)?(this.searchError="SEARCH QUERY IS EMPTY",[2]):this.search.length<6?(this.searchError="SEARCH QUERY TOO SHORT. PLEASE, PROVIDE AT LEAST 6 SYMBOLS",[2]):localStorage.getItem("confirmed")?[3,2]:[4,m.show(w)];case 1:if(!n.sent())return[2];localStorage.setItem("confirmed","true"),n.label=2;case 2:return l.a.show(),[4,h.a.firestore().collection("search").add({uid:this._user.uid,query:this.search.toLowerCase(),createdAt:h.a.firestore.FieldValue.serverTimestamp()})];case 3:t=n.sent(),n.label=4;case 4:return n.trys.push([4,7,,8]),[4,new Promise((function(e,n){var r=h.a.firestore().doc("search/"+t.id).onSnapshot((function(t){var o=t.data();o.result?(r(),e(o.result)):o.error&&(r(),n(o.error))}),n)}))];case 5:return e=n.sent(),[4,u.a.loadSearchRom(e)];case 6:return n.sent(),r.route.set("/game/local"),[3,8];case 7:return n.sent(),this.searchError="NOTHING FOUND",Object(r.redraw)(),l.a.hide(),[3,8];case 8:return[2]}}))}))},t.prototype.selectPopularChangeHandler=function(t){var e=t.target;this.search=e.value,e.value=""},t.prototype.buttonLuckyHandler=function(){return E(this,void 0,void 0,(function(){var t;return k(this,(function(e){switch(e.label){case 0:return t=this,[4,u.a.getRandomRequest()];case 1:return t.search=e.sent(),Object(r.redraw)(),[2]}}))}))},t.prototype.onremove=function(){this._inputElement&&(this._inputElement.removeEventListener("change",this._fileChangeHandler),document.body.removeChild(this._inputElement),this._inputElement=void 0)},t.prototype.view=function(){return a.call(this)},Object.defineProperty(t.prototype,"popular",{get:function(){return this._popular},enumerable:!1,configurable:!0}),t}()},48:function(t,e,n){t.exports=function(){return new Worker(n.p+"52f0f27e6712ae78b884.worker.js")}}}]);