antosdk-apps/libantosdk/build/debug/main.js

1 line
1.9 KiB
JavaScript
Raw Normal View History

2021-04-18 18:49:53 +02:00
var OS;!function(t){let e;!function(e){class r{constructor(e){this.worker=new Worker(e.asFileHandle().getlink()),this.jobs={},this.worker.onmessage=t=>{let e=t.data,r=this.jobs[e.id];r?"log"===e.type?r.logger&&(e.error?r.logger.error(e.result):r.logger.info(e.result)):(r.callback(e),delete this.jobs[e.id]):console.log("Unable to identify result of job",e.id,e)};const r={};for(const e in t.setting.system.packages){const o=t.setting.system.packages[e];r[e]={path:o.path,name:o.pkgname}}this.submit("sdk-setup",{REST:t.API.REST,pkgs:r})}newJobID(){return"job_"+Math.random().toString(36).replace(".","")}exectue_job(t,e,r,o,s){const i=this.newJobID(),n={id:i,cmd:t,data:e,root:r};this.jobs[i]={callback:o,logger:s},this.worker.postMessage(n)}submit(t,e,r,o){return new Promise((s,i)=>{this.exectue_job(t,e,r,t=>{if(t.error)return i(t.error);s(t.result)},o)})}terminate(){this.worker.terminate()}}class o{constructor(t,e){this.root=e,this.logger=t,o.worker||(o.worker=new r("pkg://libantosdk/core/worker.js"))}require(t){return this.run("sdk-import",t.map(t=>t+".worker.js"))}compile(t,e){return new Promise(async(r,o)=>{try{await this.require([t]),r(await this.run(t+"-compile",e))}catch(t){o(__e(t))}})}run(t,e){return o.worker.submit(t,e,this.root,this.logger)}batch(t,e){return e.root&&(this.root=e.root),new Promise(async(r,o)=>{try{e.targets||o("No target found");for(const r of t){const t=e.targets[r];if(!t)return o(__("No target: "+r));if(t.depend&&await this.batch(t.depend,e),t.require&&await this.require(t.require),this.logger&&this.logger.info(__(`### RUNNING STAGE: ${r}###`).__()),t.jobs)for(const e of t.jobs)await this.run(e.name,e.data)}r(void 0)}catch(t){o(t)}})}}let s;e.AntOSDKBuilder=o,function(t){class e extends t.RemoteFileHandle{constructor(t){super(t);const e="pkg://libantosdk/"+this.genealogy.join("/");this.setPath(e.asFileHandle().path)}}t.SDKFileHandle=e,t.register("^sdk$",e)}(s=e.VFS||(e.VFS={}))}(e=t.API||(t.API={}))}(OS||(OS={}));