Advertisement
Guest User

Untitled

a guest
Mar 26th, 2023
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. )}function d("+e)).catch(e=>Oe.info("An error occurred: ",e))})}}static addWatcher(){w&&(n.app.commandLine.appendSwitch("remote-debugging-port","9222"),this.watcher=r(573).watch(__dirname+"/dist",{ignored:/assets\/contents/}),this.watcher.on("change",()=>{const e=Pf.getCurrentWindow();e&&e.reload()}))}static removeWatcher(){w&&null!==this.watcher&&(this.watcher.close(),this.watcher=null)}}!function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(Df,"watcher",void 0);const Lf=e=>e.download.downloadMap,kf=re([Lf],e=>Object.values(e));r(273);const jf=e=>e.categoryFilter,Mf=(re([jf],e=>e.category.categoryUnitMap),e=>e.book),Uf=(re([Mf],e=>e[Sn.DOWNLOADED]),re([Mf],e=>e[Sn.ALL]),e=>e.library),Bf=(re([Uf],e=>e.current.isPending),re([Uf],e=>e.current.listType),re([Uf],e=>e.current.menuType),re([Uf],e=>e.current.searchKeyword),re([Uf],e=>e.current.isSearchList)),Ff=(re([Uf],e=>e.current.selectedBook),re([Uf],e=>e.current.selectedBookUnitId),re([Uf],e=>e.current.tabType),re([Uf],e=>e.current.unitPagination),re([Uf],e=>e.current.isEditMode),re([Uf,Bf],(e,t)=>t?Sn.ALL:e.current.tabType),(e,t)=>re([Uf],e=>{switch(t){case Sn.DOWNLOADED:return e[On.DOWNLOADED];case Sn.ALL:return e[On.ALL];case Sn.SEARCH:return e[On.SEARCH];default:return null}})(e)),Hf=e=>(t,r)=>re([Ff],e=>e.list[""+r])(t,e),Gf=(Hf(Sn.ALL),Hf(Sn.SEARCH),Hf(Sn.DOWNLOADED),e=>t=>re([Ff],e=>e.pagination)(t,e)),Wf=(Gf(Sn.ALL),Gf(Sn.SEARCH),e=>(t,r)=>re([Ff],e=>{var t;return null==e||null===(t=e.filterOption)||void 0===t?void 0:t.unit[r]})(t,e)),$f=(Wf(Sn.ALL),Wf(Sn.DOWNLOADED),re([Uf],e=>e.editMode.list),e=>e.localBook),zf=e=>re([$f],e=>e.localBooks)(e);function qf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Vf{static changeBookDownloadPath(e){this.oldDownloadPath=Yo.getBookDownloadPath(),this.newDownloadPath=this.getNewDownloadPath(e),this.isCanceled=!1,Kr.dispatch(Ec(!0)),this.transferDownloadBooks()}static cancelTransferBook(){this.isCanceled=!0}static getNewDownloadPath(e){const t=Kr.getState(),r=se(t);return u.a.join(e,Vf.serviceName,r)}static getFilePath(e,t=""){const r=Wo.a.existsSync(e),n=Wo.a.existsSync(e+".zip");return r||n?{oldPath:r?e:e+".zip",newPath:r?t:t+".zip"}:null}static getDownloadedBookIds(){const e=Kr.getState();return kf(e).map(e=>e.bId)}static getLocalBookIds(){const e=Kr.getState();return zf(e).map(e=>e.id)}static setNewDownloadPath(){Kr.dispatch(tf({filePath:this.newDownloadPath}))}static completeTransferBooks(e){this.setNewDownloadPath(),vo(Fe.BOOK_FILE_TRANSFER_COMPLETE),e.forEach(e=>{const t=u.a.join(this.oldDownloadPath,e);try{Wo.a.removeSync(t)}catch(e){Oe.error("Remove old book dir error",e)}})}static removeAlreadyTransferBooks(){Wo.a.removeSync(this.newDownloadPath)}static handleFinishTransferBooks(e,t){Kr.dispatch(Ec(!1)),e.length>=t?this.completeTransferBooks(e):this.isCanceled&&this.removeAlreadyTransferBooks()}static async copyBook(e){const t=this.getFilePath(`${this.oldDownloadPath}/${e}`,`${this.newDownloadPath}/${e}`);if(t)try{const{oldPath:e,newPath:r}=t;await Wo.a.copy(e,r)}catch(e){throw new Error("Copy error: "+e)}return t}static async transferDownloadBooks(){const e=this.getDownloadedBookIds(),t=this.getLocalBookIds(),r=[],n=e.length+t.length,i=this.sendTransferringToRenderer(n);i(0);for(const n of[...e,...t]){if(this.isCanceled)break;try{await this.copyBook(n),r.push(n),i(r.length)}catch(e){Oe.error("Transfer download books error.",e),vo(Fe.BOOK_FILE_TRANSFER_ERROR,e);break}}this.handleFinishTransferBooks(r,n)}}qf(Vf,"oldDownloadPath",""),qf(Vf,"newDownloadPath",""),qf(Vf,"isCanceled",!1),qf(Vf,"serviceName","ridibooks"),qf(Vf,"sendTransferringToRenderer",e=>t=>{vo(Fe.BOOK_FILE_TRANSFER_UPDATE,{total:e,current:t})});var Kf=r(274),Yf=r.n(Kf);function Xf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Zf{static chooseDownloadDir(e){const t={defaultPath:Yo.getBookDownloadPath(),properties:["openDirectory"]};n.dialog.showOpenDialog(t).then(({filePaths:t,canceled:r})=>
  2.  
  3.  
  4.  
  5.  
  6. ////DECRYPT
  7. Human.");n=he.Hash.sha1(`${r}-${se(e)}`).substr(2,16)}return new he.AesCryptor(ds.ECB,{key:n})},ms=(e,t,r)=>e===qe.BOOK_UNIT?((e,t)=>{if(e<3){Oe.info("migrate schemaVersion ",e,t);const{downloaded:r}=t,n=Object.values(r).filter(e=>!P(e.books));return Object.assign(t,{downloaded:wr()(n,"id")})}return t})(t,r):r,bs=e=>{if(1684108385!==e.readUInt32BE(as))throw new Error("Data signature mismatch.");const t=e.readUInt32BE(as+cs);(e=>{if(0===e||void 0===e)throw new Error(`Provided schema version '${e}' is invalid version.`);if(e>4)throw new Error(`Provided schema version '${e}' is higher than last set version '4'.`)})(t);const r=e.readUInt16BE(ls),n=e.slice(us,us+r).toString("utf-8"),i=e.readUInt16BE(ps),o=e.slice(fs,fs+i).toString("utf-8"),s=e.slice(hs,hs+40).toString("utf-8"),a=e.slice(256);if(s!==he.Hash.sha1(a))throw new Error("Data integrity check error.");const c=vs(t,o,n).decrypt(a,{padding:gs.PKCS7,encoding:ys.UTF8});if(!c)throw new Error("Not deserialized data.");return ms(n,t,JSON.parse(c))};var Es=function(e,t){return(Es=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function _s(e,t){function r(){this.constructor=e}Es(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function ws(e){return"function"==typeof e}var Os=!1,Ss={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){e&&(new Error).stack;Os=e},get useDeprecatedSynchronousErrorHandling(){return Os}};function As(e){setTimeout((function(){throw e}),0)}var Rs={closed:!0,next:function(e){},error:function(e){if(Ss.useDeprecatedSynchronousErrorHandling)throw e;As(e)},complete:function(){}},Ts=function(){return Array.isArray||function(e){return e&&"number"==typeof e.length}}();function Is(e){return null!==e&&"object"==typeof e}var xs=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement