2024-04-01 14:54:53 +08:00
|
|
|
function e(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0});}var t=require("fs"),r=require("path"),n=require("child_process"),a=require("stream"),i=require("util"),o=require("stream"),s=require("util"),l=globalThis.parcelRequire810d,u=l.register;u("8Fs7q",function(n,a){e(n.exports,"ArchiveHdi",()=>d);var i=l("4ripN"),o=l("g6mhR"),s=l("1cM2y"),u=l("lU4sB");let c={ignoreUnreadableDirectories:!0},p={force:!0};class h extends o.Entry{sizeComp=null;uname=null;gname=null;constructor(e){super(e),this.archive=e.archive,this.size=e.size,this.mode=e.mode,this.uid=e.uid,this.gid=e.gid,this.atime=e.atime,this.mtime=e.mtime;}get rsrcPathRaw(){return(0,u.pathResourceFork)(this.pathRaw);}get rsrcPath(){return(0,u.pathNormalize)((0,u.pathResourceFork)(this.path));}}class d extends o.Archive{static FILE_EXTENSIONS=[".dmg",".iso",".cdr"];static HAS_NAMED_VOLUMES=!0;Entry=h;mounterMac=new i.Mounter();nobrowse=!1;constructor(e){super(e);}async read(e){await super.read(e);}async _read(e){let{mounterMac:n,nobrowse:a}=this,i=async(r,n,a)=>{let i=(0,u.statToPathType)(a);if(null===i)return!0;let{size:o,mode:l,uid:c,gid:p,atime:h,mtime:d}=a,f=i===s.PathType.FILE?async()=>(0,t.createReadStream)(r):null,m=i===s.PathType.SYMLINK?async()=>(0,u.fsReadlinkRaw)(r):null,g=new this.Entry({archive:this,type:i,pathRaw:n,size:o,mode:l,uid:c,gid:p,atime:h,mtime:d,readData:f,readSymlink:m}),D=await g.trigger(e);if(!1===D)return null;if(null===D)return!1;if(i===s.PathType.FILE){let a=(0,u.pathResourceFork)(r),i=await(0,u.fsLstatExists)(a);if(i){let r=i.size,o=async()=>(0,t.createReadStream)(a),u=new this.Entry({archive:this,type:s.PathType.RESOURCE_FORK,pathRaw:n,size:r,mode:l,uid:c,gid:p,atime:h,mtime:d,readRsrc:o}),f=await u.trigger(e);if(!1===f)return null;if(null===f)return!1;}}return!0;},o=await n.attach(this.path,{nobrowse:a,readonly:!0},p);try{for(let e of o.devices){let{mountPoint:t}=e;if(!t)continue;let n=(0,r.basename)(t);await(0,u.fsWalk)(t,async(e,a)=>{let o=(0,r.join)(t,e),s=(0,r.join)(n,e);return i(o,s,a);},c);}}finally{await o.eject(p);}}}}),u("4ripN",function(t,r){e(t.exports,"Mounter",()=>c);var a=l("2dJww"),i=l("5t69V"),o=l("cAWOc"),s=l("ico3M"),u=l("iH99z");class c{constructor(e=null){this.hdiutil=(e?e.hdiutil:null)||"hdiutil";}async attach(e,t=null,r=null){let n=await this._runAttach(this._argsAttach(e,t)),{eject:a,ejectSync:i}=this._createEjects(n);return{devices:n,eject:a,ejectSync:i};}attachSync(e,t=null,r=null){let n=this._runAttachSync(this._argsAttach(e,t)),{eject:a,ejectSync:i}=this._createEjects(n);return{devices:n,eject:a,ejectSync:i};}async eject(e,t=null){await this._runEject(this._argsEject(e,t));}ejectSync(e,t=null){this._runEjectSync(this._argsEject(e,t));}_argsAttach(e,t=null){let r=["attach","-plist"];return t&&(t.readonly&&r.push("-readonly"),t.nobrowse&&r.push("-nobrowse")),r.push(this._fileArg(e)),r;}_argsEject(e,t=null){let r=["eject"];return t&&t.force&&r.push("-force"),r.push(this._fileArg(e)),r;}async _runAttach(e){let t=[],r=(0,n.spawn)(this.hdiutil,e);r.stdout.on("data",e=>{t.push(e);});let a=await new Promise((e,t)=>{r.once("exit",e),r.once("error",t);});if(a)throw Error("Attach failed: hdiutil exit code: "+a);return this._parseDevices(Buffer.concat(t).toString());}_runAttachSync(e){let{status:t,error:r,stdout:a}=(0,n.spawnSync)(this.hdiutil,e);if(r)throw r;if(t)throw Error("Attach failed: hdiutil exit code: "+t);return this._parseDevices(a.toString());}async _runEject(e){let t=(0,n.spawn)(this.hdiutil,e),r=await new Promise((e,r)=>{t.once("exit",e),t.once("error",r);});if(r)throw Error("Eject failed: hdiutil exit code: "+r);}_runEjectSync(e){let{status:t,error:r}=(0,n.spawnSync)(this.hdiutil,e);if(r)throw r;if(t)throw Error("Eject failed: hdiutil exit code: "+t);}_fileArg(e){return e.startsWith("-")?"./"+e:e;}_parseDevices(e){let t=new a.Plist();t.fromXml(e);let r=t.valueCastAs(s.ValueDict).getValue("system-entities").castAs(i.ValueArray),n=[];for(let e of r.value){let t=e.castAs(s.ValueDict),r=t.getValue("dev-entry").castAs(u.ValueString).value,a=t.getValue("potentially-mountable").
|