diff --git a/libantosdk/README.md b/libantosdk/README.md index 3e23198..6806f4b 100644 --- a/libantosdk/README.md +++ b/libantosdk/README.md @@ -1,15 +1,5 @@ # libantosdk -This is an example project, generated by AntOS Development Kit +AntOSDK: development API for AntOS based applications/projects -## Howto -Use the CodePad command palette to access to the SDK functionalities: - -1. Create new project -2. Init the project from the current folder located in side bar -3. Build and run the project -4. Release the project in zip package - -## Set up build target - -Open the `project.json` file from the current project tree and add/remove -build target entries. Save the file \ No newline at end of file +## Change logs +- 0.0.4: support automatic locale generation \ No newline at end of file diff --git a/libantosdk/build.json b/libantosdk/build.json index c188db5..3c1881b 100644 --- a/libantosdk/build.json +++ b/libantosdk/build.json @@ -8,6 +8,20 @@ } ] }, + "locale": { + "require": ["locale"], + "jobs": [ + { + "name":"locale-gen", + "data": { + "src": "", + "exclude": ["build/debug/", "core/", "ts/test\\.ts", "scheme\\.html"], + "locale": "en_GB", + "dest": "package.json" + } + } + ] + }, "build": { "require": ["ts"], "jobs":[ diff --git a/libantosdk/build/debug/README.md b/libantosdk/build/debug/README.md index 3e23198..6806f4b 100644 --- a/libantosdk/build/debug/README.md +++ b/libantosdk/build/debug/README.md @@ -1,15 +1,5 @@ # libantosdk -This is an example project, generated by AntOS Development Kit +AntOSDK: development API for AntOS based applications/projects -## Howto -Use the CodePad command palette to access to the SDK functionalities: - -1. Create new project -2. Init the project from the current folder located in side bar -3. Build and run the project -4. Release the project in zip package - -## Set up build target - -Open the `project.json` file from the current project tree and add/remove -build target entries. Save the file \ No newline at end of file +## Change logs +- 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 6dc6b7b..966a176 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):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 n=this.newJobID(),i={id:n,cmd:e,data:t,root:r};this.jobs[n]={callback:o,logger:s},this.worker.postMessage(i)}submit(e,t,r,o){return new Promise((s,n)=>{this.exectue_job(e,t,r,e=>{if(e.error)return n(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: "+r));if(e.depend&&await this.batch(e.depend,t),e.require&&await this.require(e.require),this.logger&&this.logger.info(__(`### RUNNING STAGE: ${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(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):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 n=this.newJobID(),i={id:n,cmd:e,data:t,root:r};this.jobs[n]={callback:o,logger:s},this.worker.postMessage(i)}submit(e,t,r,o){return new Promise((s,n)=>{this.exectue_job(e,t,r,e=>{if(e.error)return n(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 diff --git a/libantosdk/build/debug/package.json b/libantosdk/build/debug/package.json index 2ba93d0..8f9ce9d 100644 --- a/libantosdk/build/debug/package.json +++ b/libantosdk/build/debug/package.json @@ -1,15 +1,25 @@ { "pkgname": "libantosdk", - "name":"AntOSDK", - "description":"AntOS Software Development Kit", - "info":{ + "name": "AntOSDK", + "description": "AntOS Software Development Kit", + "info": { "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version":"0.0.3-a", - "category":"Other", - "iconclass":"fa fa-cog", - "mimes":["none"], - "dependencies":[], - "locale": {} + "version": "0.0.4-a", + "category": "Other", + "iconclass": "fa fa-cog", + "mimes": [ + "none" + ], + "dependencies": [], + "locale": { + "en_GB": { + "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}###" + } + } } \ No newline at end of file diff --git a/libantosdk/build/release/libantosdk.zip b/libantosdk/build/release/libantosdk.zip index 4ef8eec..728b7b1 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 2ba93d0..8f9ce9d 100644 --- a/libantosdk/package.json +++ b/libantosdk/package.json @@ -1,15 +1,25 @@ { "pkgname": "libantosdk", - "name":"AntOSDK", - "description":"AntOS Software Development Kit", - "info":{ + "name": "AntOSDK", + "description": "AntOS Software Development Kit", + "info": { "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version":"0.0.3-a", - "category":"Other", - "iconclass":"fa fa-cog", - "mimes":["none"], - "dependencies":[], - "locale": {} + "version": "0.0.4-a", + "category": "Other", + "iconclass": "fa fa-cog", + "mimes": [ + "none" + ], + "dependencies": [], + "locale": { + "en_GB": { + "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}###" + } + } } \ No newline at end of file diff --git a/libantosdk/ts/main.ts b/libantosdk/ts/main.ts index 6f46605..99243fc 100644 --- a/libantosdk/ts/main.ts +++ b/libantosdk/ts/main.ts @@ -208,7 +208,7 @@ namespace OS { { const target = options.targets[name]; if(!target) - return reject(__(`No target: ${name}`)); + return reject(__("No target: {0}", name)); if(target.depend) { @@ -219,7 +219,7 @@ namespace OS { await this.require(target.require); } if(this.logger) - this.logger.info(__(`### RUNNING STAGE: ${name}###`).__()); + this.logger.info(__("### RUNNING STAGE: {0}###", name).__()); if(target.jobs) for(const job of target.jobs) { diff --git a/packages.json b/packages.json index 97fc8b3..ee79712 100644 --- a/packages.json +++ b/packages.json @@ -195,7 +195,7 @@ "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/README.md", "category": "Other", "author": "Xuan Sang LE", - "version": "0.0.3-a", + "version": "0.0.4-a", "dependencies": [], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/build/release/libantosdk.zip" },