mirror of
https://gitlab.com/octospacc/Web-Archives-Misc
synced 2024-12-29 09:10:28 +01:00
1 line
15 KiB
JavaScript
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)},"fun
|