diff --git a/libantosdk/README.md b/libantosdk/README.md index 336aef9..30964c2 100644 --- a/libantosdk/README.md +++ b/libantosdk/README.md @@ -2,5 +2,6 @@ AntOSDK: development API for AntOS based applications/projects ## Change logs +- 0.0.6: add GUI application for building a JSON build file - 0.0.5: add API that supports running Linux commands on server - 0.0.4: support automatic locale generation \ No newline at end of file diff --git a/libantosdk/build.json b/libantosdk/build.json index 3a00aab..b7cf028 100644 --- a/libantosdk/build.json +++ b/libantosdk/build.json @@ -4,7 +4,7 @@ "jobs": [ { "name": "vfs-rm", - "data": ["build/debug/scheme.html"] + "data": ["build"] } ] }, @@ -15,7 +15,7 @@ "name":"locale-gen", "data": { "src": "", - "exclude": ["build/debug/", "core/", "ts/test\\.ts", "scheme\\.html"], + "exclude": ["build/debug/", "core/"], "locale": "en_GB", "dest": "package.json" } @@ -36,7 +36,7 @@ { "name": "ts-compile", "data": { - "src": ["ts/main.ts"], + "src": ["ts/main.ts", "ts/app.ts"], "dest": "build/debug/main.js" } } @@ -59,13 +59,19 @@ "src": [ "core", "package.json", - "README.md" + "README.md", + "main.css", + "scheme.html" ], "dest":"build/debug" } } ] }, + "debug": { + "depend": ["build","copy"], + "jobs": [] + }, "release": { "depend": ["build","uglify", "copy"], "require": ["zip"], diff --git a/libantosdk/build/debug/README.md b/libantosdk/build/debug/README.md index 336aef9..30964c2 100644 --- a/libantosdk/build/debug/README.md +++ b/libantosdk/build/debug/README.md @@ -2,5 +2,6 @@ AntOSDK: development API for AntOS based applications/projects ## Change logs +- 0.0.6: add GUI application for building a JSON build file - 0.0.5: add API that supports running Linux commands on server - 0.0.4: support automatic locale generation \ No newline at end of file diff --git a/libantosdk/build/debug/main.js b/libantosdk/build/debug/main.js index d23a2cc..f807405 100644 --- a/libantosdk/build/debug/main.js +++ b/libantosdk/build/debug/main.js @@ -1 +1 @@ -var OS;!function(e){let t;!function(t){class r{constructor(t){this.worker=new Worker(t.asFileHandle().getlink()),this.jobs={},this.worker.onmessage=e=>{let t=e.data,r=this.jobs[t.id];r?"log"===t.type?r.logger&&(t.error?r.logger.error(t.result):!1===t.show_time&&r.logger.print?r.logger.print(t.result):r.logger.info(t.result)):(r.callback(t),delete this.jobs[t.id]):console.log("Unable to identify result of job",t.id,t)};const r={};for(const t in e.setting.system.packages){const o=e.setting.system.packages[t];r[t]={path:o.path,name:o.pkgname}}this.submit("sdk-setup",{REST:e.API.REST,pkgs:r})}newJobID(){return"job_"+Math.random().toString(36).replace(".","")}exectue_job(e,t,r,o,s){const i=this.newJobID(),n={id:i,cmd:e,data:t,root:r};this.jobs[i]={callback:o,logger:s},this.worker.postMessage(n)}submit(e,t,r,o){return new Promise((s,i)=>{this.exectue_job(e,t,r,e=>{if(e.error)return i(e.error);s(e.result)},o)})}terminate(){this.worker.terminate()}}class o{constructor(e,t){this.root=t,this.logger=e,o.worker||(o.worker=new r("pkg://libantosdk/core/worker.js"))}require(e){return this.run("sdk-import",e.map(e=>e+".worker.js"))}compile(e,t){return new Promise(async(r,o)=>{try{await this.require([e]),r(await this.run(e+"-compile",t))}catch(e){o(__e(e))}})}run(t,r){return"sdk-run-app"===t?new Promise(async(t,o)=>{try{let o=r;1==o.split("://").length&&(o=`${this.root}/${r}`);const s=await(o+"/package.json").asFileHandle().read("json");return s.text=s.name,s.path=o,s.filename=s.pkgname,s.type="app",s.mime="antos/app",s.icon&&(s.icon=`${s.path}/${s.icon}`),s.iconclass||s.icon||(s.iconclass="fa fa-adn"),this.logger.info(__("Installing...")),e.setting.system.packages[s.pkgname]=s,s.app?(this.logger.info(__("Running {0}...",s.app)),e.GUI.forceLaunch(s.app,[])):this.logger.error(__("{0} is not an application",s.pkgname)),t(void 0)}catch(e){o(e)}}):o.worker.submit(t,r,this.root,this.logger)}batch(e,t){return t.root&&(this.root=t.root),new Promise(async(r,o)=>{try{t.targets||o("No target found");for(const r of e){const e=t.targets[r];if(!e)return o(__("No target: {0}",r));if(e.depend&&await this.batch(e.depend,t),e.require&&await this.require(e.require),this.logger&&this.logger.info(__("### RUNNING STAGE: {0}###",r).__()),e.jobs)for(const t of e.jobs)await this.run(t.name,t.data)}r(void 0)}catch(e){o(e)}})}}let s;t.AntOSDKBuilder=o,function(e){class t extends e.RemoteFileHandle{constructor(e){super(e);const t="pkg://libantosdk/"+this.genealogy.join("/");this.setPath(t.asFileHandle().path)}}e.SDKFileHandle=t,e.register("^sdk$",t)}(s=t.VFS||(t.VFS={}))}(t=e.API||(e.API={}))}(OS||(OS={})); \ No newline at end of file +var OS;!function(t){let e;!function(e){class i{constructor(e){this.worker=new Worker(e.asFileHandle().getlink()),this.jobs={},this.worker.onmessage=t=>{let e=t.data,i=this.jobs[e.id];i?"log"===e.type?i.logger&&(e.error?i.logger.error(e.result):!1===e.show_time&&i.logger.print?i.logger.print(e.result):i.logger.info(e.result)):(i.callback(e),delete this.jobs[e.id]):console.log("Unable to identify result of job",e.id,e)};const i={};for(const e in t.setting.system.packages){const s=t.setting.system.packages[e];i[e]={path:s.path,name:s.pkgname}}this.submit("sdk-setup",{REST:t.API.REST,pkgs:i})}newJobID(){return"job_"+Math.random().toString(36).replace(".","")}exectue_job(t,e,i,s,r){const o=this.newJobID(),n={id:o,cmd:t,data:e,root:i};this.jobs[o]={callback:s,logger:r},this.worker.postMessage(n)}submit(t,e,i,s){return new Promise((r,o)=>{this.exectue_job(t,e,i,t=>{if(t.error)return o(t.error);r(t.result)},s)})}terminate(){this.worker.terminate()}}class s{constructor(t,e){this.root=e,this.logger=t,s.worker||(s.worker=new i("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(i,s)=>{try{await this.require([t]),i(await this.run(t+"-compile",e))}catch(t){s(__e(t))}})}run(e,i){return"sdk-run-app"===e?new Promise(async(e,s)=>{try{let s=i;1==s.split("://").length&&(s=`${this.root}/${i}`);const r=await(s+"/package.json").asFileHandle().read("json");return r.text=r.name,r.path=s,r.filename=r.pkgname,r.type="app",r.mime="antos/app",r.icon&&(r.icon=`${r.path}/${r.icon}`),r.iconclass||r.icon||(r.iconclass="fa fa-adn"),this.logger.info(__("Installing...")),t.setting.system.packages[r.pkgname]=r,r.app?(this.logger.info(__("Running {0}...",r.app)),t.GUI.forceLaunch(r.app,[])):this.logger.error(__("{0} is not an application",r.pkgname)),e(void 0)}catch(t){s(t)}}):s.worker.submit(e,i,this.root,this.logger)}batch(t,e){return e.root&&(this.root=e.root),new Promise(async(i,s)=>{try{e.targets||s("No target found");for(const i of t){const t=e.targets[i];if(!t)return s(__("No target: {0}",i));if(t.depend&&await this.batch(t.depend,e),t.require&&await this.require(t.require),this.logger&&this.logger.info(__("### RUNNING STAGE: {0}###",i).__()),t.jobs)for(const e of t.jobs)await this.run(e.name,e.data)}i(void 0)}catch(t){s(t)}})}}let r;e.AntOSDKBuilder=s,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)}(r=e.VFS||(e.VFS={}))}(e=t.API||(t.API={}))}(OS||(OS={})),function(t){let e;!function(e){class i{constructor(t){this.target=t}info(t){this.log("info",t,!0)}warn(t){this.log("warn",t,!0)}error(t){this.log("error",t,!0)}log(t,e,i){let s=$("
").attr("class","sdk-log-"+t);if(i){let t=new Date,i=t.getDate()+"/"+(t.getMonth()+1)+"/"+t.getFullYear()+" "+t.getHours()+":"+t.getMinutes()+":"+t.getSeconds();s.text(`[${i}]: ${e.__()}`)}else s.text(e.__());$(this.target).append(s),$(this.target).scrollTop($(this.target)[0].scrollHeight)}print(t){t.match(/warn/i)?this.log("warn",t,!1):t.match(/error/i)?this.log("error",t,!1):this.log("info",t,!1)}clear(){$(this.target).empty()}}class s extends e.BaseApplication{constructor(t){super("libantosdk",t)}main(){this.logger=new i(this.find("container")),this.sdk=new t.API.AntOSDKBuilder(this.logger,""),this.filehandle=void 0,this.options=void 0,this.targets=this.find("target-list"),this.args&&this.args.length>0&&(this.filehandle=this.args[0].path.asFileHandle()),this.find("btnbuild").onbtclick=t=>{const e=this.targets.selectedItem;e&&this.load(this.compile([e.data.text]))},this.find("btnclear").onbtclick=t=>{this.logger.clear()},this.find("btnrefresh").onbtclick=t=>{this.open()},this.find("btnopen").onbtclick=async t=>{try{const t=await this.openDialog("FileDialog",{title:__("Select build file"),mimes:this.meta().mimes});this.filehandle=t.file.path.asFileHandle(),this.open()}catch(t){this.logger.error(t.toString())}},this.open()}open(){void 0!==this.filehandle&&this.filehandle.read("json").then(t=>{if(!t.targets)return this.logger.error(__("Invalid build file: {0}",this.filehandle.path));const e=Object.keys(t.targets).map(t=>({text:t}));this.scheme.apptitle=this.filehandle.path,this.options=t,this.options.root=this.filehandle.parent().path,this.targets.data=e,this.logger.info(__("Loaded: {0}",this.filehandle.path))}).catch(t=>this.logger.error(__("Unable to load build file: {0}: {1}",this.filehandle.path,t.toString())))}compile(t){return new Promise(async(e,i)=>{try{this.logger.clear(),await this.sdk.batch(t,this.options),e("OK")}catch(t){i(__e(t))}})}}e.libantosdk=s}(e=t.application||(t.application={}))}(OS||(OS={})); \ No newline at end of file diff --git a/libantosdk/build/debug/package.json b/libantosdk/build/debug/package.json index 280dfee..2d83386 100644 --- a/libantosdk/build/debug/package.json +++ b/libantosdk/build/debug/package.json @@ -1,25 +1,33 @@ { "pkgname": "libantosdk", - "name": "AntOSDK", + "name": "AntOS SDK builder", + "app": "libantosdk", "description": "AntOS Software Development Kit", "info": { "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version": "0.0.5-a", - "category": "Other", + "version": "0.0.6-a", + "category": "Development", "iconclass": "fa fa-cog", "mimes": [ - "none" + "application/json" ], "dependencies": [], "locale": { "en_GB": { + "Select build file": "Select build file", + "Invalid build file: {0}": "Invalid build file: {0}", + "Loaded: {0}": "Loaded: {0}", + "Unable to load build file: {0}: {1}": "Unable to load build file: {0}: {1}", "Installing...": "Installing...", "Running {0}...": "Running {0}...", "{0} is not an application": "{0} is not an application", "No target: {0}": "No target: {0}", - "### RUNNING STAGE: {0}###": "### RUNNING STAGE: {0}###" + "### RUNNING STAGE: {0}###": "### RUNNING STAGE: {0}###", + "AntOSDK Builder": "AntOSDK Builder", + "Run": "Run", + "Clear log": "Clear log" } } } \ No newline at end of file diff --git a/libantosdk/build/release/libantosdk.zip b/libantosdk/build/release/libantosdk.zip index f07892a..83e9b95 100644 Binary files a/libantosdk/build/release/libantosdk.zip and b/libantosdk/build/release/libantosdk.zip differ diff --git a/libantosdk/package.json b/libantosdk/package.json index 280dfee..2d83386 100644 --- a/libantosdk/package.json +++ b/libantosdk/package.json @@ -1,25 +1,33 @@ { "pkgname": "libantosdk", - "name": "AntOSDK", + "name": "AntOS SDK builder", + "app": "libantosdk", "description": "AntOS Software Development Kit", "info": { "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version": "0.0.5-a", - "category": "Other", + "version": "0.0.6-a", + "category": "Development", "iconclass": "fa fa-cog", "mimes": [ - "none" + "application/json" ], "dependencies": [], "locale": { "en_GB": { + "Select build file": "Select build file", + "Invalid build file: {0}": "Invalid build file: {0}", + "Loaded: {0}": "Loaded: {0}", + "Unable to load build file: {0}: {1}": "Unable to load build file: {0}: {1}", "Installing...": "Installing...", "Running {0}...": "Running {0}...", "{0} is not an application": "{0} is not an application", "No target: {0}": "No target: {0}", - "### RUNNING STAGE: {0}###": "### RUNNING STAGE: {0}###" + "### RUNNING STAGE: {0}###": "### RUNNING STAGE: {0}###", + "AntOSDK Builder": "AntOSDK Builder", + "Run": "Run", + "Clear log": "Clear log" } } } \ No newline at end of file diff --git a/libantosdk/project.json b/libantosdk/project.json index 33d84a9..c9a38b7 100644 --- a/libantosdk/project.json +++ b/libantosdk/project.json @@ -1,8 +1,8 @@ { "name": "libantosdk", - "css": [], + "css": ["main.css"], "javascripts": [], "coffees": [], - "ts": ["ts/main.ts", "ts/test.ts"], + "ts": ["ts/main.ts", "ts/app.ts"], "copies": ["core","package.json","scheme.html", "README.md"] } \ No newline at end of file diff --git a/libantosdk/scheme.html b/libantosdk/scheme.html index 628c02b..938ddbc 100644 --- a/libantosdk/scheme.html +++ b/libantosdk/scheme.html @@ -1,16 +1,30 @@ -