mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-17 10:48:23 +01:00
update antedit
This commit is contained in:
parent
9087647527
commit
a0f3f25338
@ -1,35 +1 @@
|
||||
|
||||
(function() {
|
||||
var About;
|
||||
|
||||
About = class About extends this.OS.application.BaseApplication {
|
||||
constructor(args) {
|
||||
super("About", args);
|
||||
}
|
||||
|
||||
main() {
|
||||
var me, path;
|
||||
me = this;
|
||||
this.container = this.find("container");
|
||||
path = "https://raw.githubusercontent.com/lxsang/antos/master/README.md";
|
||||
path.asFileHandle().read().then(function(txt) {
|
||||
var converter;
|
||||
converter = new showdown.Converter();
|
||||
return ($(me.container)).html(converter.makeHtml(txt));
|
||||
}).catch(() => {
|
||||
return this.notify(__("Unable to read: {0}", path));
|
||||
});
|
||||
return this.find("btnclose").onbtclick = () => {
|
||||
return this.quit();
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
About.singleton = true;
|
||||
|
||||
About.dependencies = ["os://scripts/showdown.min.js"];
|
||||
|
||||
this.OS.register("About", About);
|
||||
|
||||
}).call(this);
|
||||
(function(){var t;(t=class extends this.OS.application.BaseApplication{constructor(t){super("About",t)}main(){var t,n;return t=this,this.container=this.find("container"),(n="https://raw.githubusercontent.com/lxsang/antos/master/README.md").asFileHandle().read().then((function(n){var i;return i=new showdown.Converter,$(t.container).html(i.makeHtml(n))})).catch(()=>this.notify(__("Unable to read: {0}",n))),this.find("btnclose").onbtclick=()=>this.quit()}}).singleton=!0,t.dependencies=["os://scripts/showdown.min.js"],this.OS.register("About",t)}).call(this);
|
Binary file not shown.
173
Antedit/build/debug/extensions/AntOSDKExtension/main.js
Normal file
173
Antedit/build/debug/extensions/AntOSDKExtension/main.js
Normal file
@ -0,0 +1,173 @@
|
||||
|
||||
(function() {
|
||||
// import the CodePad application module
|
||||
const App = this.OS.application.Antedit;
|
||||
// define the extension
|
||||
App.extensions.AntOSDKExtension = class AntOSDKExtension extends App.EditorBaseExtension {
|
||||
constructor(app) {
|
||||
super("AntOSDKExtension",app);
|
||||
this.sdk = undefined;
|
||||
this.last_target = undefined;
|
||||
}
|
||||
init(){
|
||||
if(! OS.API.AntOSDKBuilder)
|
||||
{
|
||||
throw new Error(__("{0} is not installed, please install it", "libantosdk").__());
|
||||
return;
|
||||
}
|
||||
if(!this.sdk)
|
||||
{
|
||||
this.sdk = new OS.API.AntOSDKBuilder(this.logger(),"");
|
||||
}
|
||||
this.logger().clear();
|
||||
}
|
||||
create() {
|
||||
this.init();
|
||||
this.app
|
||||
.openDialog("FileDialog", {
|
||||
title: "__(New AntOS package at)",
|
||||
file: { basename: "PackageName" },
|
||||
mimes: ["dir"],
|
||||
})
|
||||
.then((d) => {
|
||||
return this.mktpl(d.file.path, d.name);
|
||||
});
|
||||
}
|
||||
|
||||
build() {
|
||||
this.init();
|
||||
this.metadata("build.json")
|
||||
.then(async (options) => {
|
||||
try{
|
||||
const targets = Object.keys(options.targets).map(e =>{
|
||||
return {text: e};
|
||||
} );
|
||||
console.log(targets);
|
||||
const target = await this.app.openDialog("SelectionDialog",{
|
||||
title: __("Select a build target"),
|
||||
data: targets
|
||||
});
|
||||
this.last_target = target.text;
|
||||
await this.app.load(this.sdk.batch([target.text], options));
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
this.logger().error(__("Unable to read build options:{0}", error.stack));
|
||||
}
|
||||
})
|
||||
.catch((e) => this.logger().error(__("Unable to read meta-data:{0}", e.stack)));
|
||||
}
|
||||
load_lib(){
|
||||
this.init();
|
||||
OS.API.VFS.read_files([
|
||||
"sdk://core/ts/jquery.d.ts",
|
||||
"sdk://core/ts/antos.d.ts"
|
||||
]).then((results) => {
|
||||
for(const content of results)
|
||||
{
|
||||
monaco.languages.typescript.typescriptDefaults.addExtraLib(content, "");
|
||||
}
|
||||
this.logger().info(__("Dev packages loaded"));
|
||||
})
|
||||
.catch((e) => this.logger().error(__("Unable to load AntOS dev packages:{0}", e.stack)));
|
||||
}
|
||||
build_last()
|
||||
{
|
||||
this.init();
|
||||
if(!this.last_target)
|
||||
{
|
||||
return this.build();
|
||||
}
|
||||
this.metadata("build.json")
|
||||
.then(async (options) => {
|
||||
try{
|
||||
await this.app.load(this.sdk.batch([this.last_target], options));
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
this.logger().error(__("Unable to read build options:{0}", error.stack));
|
||||
}
|
||||
})
|
||||
.catch((e) => this.logger().error(__("Unable to read meta-data:{0}", e.stack)));
|
||||
}
|
||||
|
||||
run(){
|
||||
this.metadata("/build/debug/package.json")
|
||||
.then((v) => {
|
||||
v.text = v.name;
|
||||
v.path = `${v.root}/build/debug/`;
|
||||
v.filename = v.pkgname;
|
||||
v.type = "app";
|
||||
v.mime = "antos/app";
|
||||
if (v.icon) {
|
||||
v.icon = `${v.path}/${v.icon}`;
|
||||
}
|
||||
if (!v.iconclass && !v.icon) {
|
||||
v.iconclass = "fa fa-adn";
|
||||
}
|
||||
this.logger().info(__("Installing..."));
|
||||
OS.setting.system.packages[v.pkgname] = v;
|
||||
if(v.app)
|
||||
{
|
||||
this.logger().info(__("Running {0}...", v.app));
|
||||
return OS.GUI.forceLaunch(v.app, []);
|
||||
}
|
||||
this.logger().error(__("{0} is not an application", v.pkgname));
|
||||
})
|
||||
.catch((e) => this.logger().error(__("Unable to read package meta-data:{0}", e.stack)));
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if(this.sdk)
|
||||
{
|
||||
this.sdk = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/*basedir() {
|
||||
return "home://workspace/antos-codepad-extensions/AntOSDKExtension"
|
||||
}*/
|
||||
|
||||
mktpl(path,name){
|
||||
const rpath = `${path}/${name}`;
|
||||
const dirs = [
|
||||
rpath,
|
||||
`${rpath}/build`,
|
||||
`${rpath}/build/release`,
|
||||
`${rpath}/build/debug`,
|
||||
];
|
||||
const files = [
|
||||
[`tpl/main.tpl`, `${rpath}/main.ts`],
|
||||
[`tpl/build.tpl`, `${rpath}/build.json`],
|
||||
[`tpl/package.tpl`, `${rpath}/package.json`],
|
||||
[`tpl/README.tpl`, `${rpath}/README.md`],
|
||||
[`tpl/scheme.tpl`, `${rpath}/scheme.html`],
|
||||
];
|
||||
OS.API.VFS.mkdirAll(dirs, true)
|
||||
.then(async () => {
|
||||
try {
|
||||
await OS.API.VFS.mktpl(files, this.basedir(), (data)=>{
|
||||
return data.format(name, `${path}/${name}`);
|
||||
});
|
||||
this.app.currdir = rpath.asFileHandle();
|
||||
this.app.toggleSideBar();
|
||||
return this.app.eum.active.openFile(
|
||||
`${rpath}/main.ts`.asFileHandle()
|
||||
);
|
||||
} catch (e) {
|
||||
return this.logger().error(
|
||||
__("Unable to create package from template: {0}",
|
||||
e.stack)
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((e) =>
|
||||
this.logger().error(__("Unable to create extension directories: {0}", e.stack))
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
App.extensions.AntOSDKExtension.dependencies = [
|
||||
"pkg://libantosdk/main.js"
|
||||
];
|
||||
}).call(this);
|
@ -0,0 +1,15 @@
|
||||
# {0}
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
Use the Antedit 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 `build.json` file from the current project tree and add/remove
|
||||
build target entries and jobs. Save the file
|
@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "{0}",
|
||||
"targets":{
|
||||
"clean": {
|
||||
"jobs": [
|
||||
{
|
||||
"name": "vfs-rm",
|
||||
"data": ["build/debug","build/release"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
"require": ["ts"],
|
||||
"jobs":[
|
||||
{
|
||||
"name": "vfs-mkdir",
|
||||
"data": ["build","build/debug","build/release"]
|
||||
},
|
||||
{
|
||||
"name": "ts-import",
|
||||
"data": ["sdk://core/ts/core.d.ts", "sdk://core/ts/jquery.d.ts","sdk://core/ts/antos.d.ts"]
|
||||
},
|
||||
{
|
||||
"name": "ts-compile",
|
||||
"data": {
|
||||
"src": ["main.ts"],
|
||||
"dest": "build/debug/main.js"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"uglify": {
|
||||
"require": ["terser"],
|
||||
"jobs": [
|
||||
{
|
||||
"name":"terser-uglify",
|
||||
"data": ["build/debug/main.js"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"copy": {
|
||||
"jobs": [
|
||||
{
|
||||
"name": "vfs-cp",
|
||||
"data": {
|
||||
"src": [
|
||||
"scheme.html",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"dest":"build/debug"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"release": {
|
||||
"depend": ["clean","build","uglify", "copy"],
|
||||
"require": ["zip"],
|
||||
"jobs": [
|
||||
{
|
||||
"name": "zip-mk",
|
||||
"data": {
|
||||
"src":"build/debug",
|
||||
"dest":"build/release/{0}.zip"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
18
Antedit/build/debug/extensions/AntOSDKExtension/tpl/main.tpl
Normal file
18
Antedit/build/debug/extensions/AntOSDKExtension/tpl/main.tpl
Normal file
@ -0,0 +1,18 @@
|
||||
namespace OS {
|
||||
|
||||
export namespace application {
|
||||
/**
|
||||
*
|
||||
* @class {0}
|
||||
* @extends {BaseApplication}
|
||||
*/
|
||||
export class {0} extends BaseApplication {
|
||||
constructor(args: AppArgumentsType[]) {
|
||||
super("{0}", args);
|
||||
}
|
||||
main(): void {
|
||||
// YOUR CODE HERE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"pkgname": "{0}",
|
||||
"app":"{0}",
|
||||
"name":"{0}",
|
||||
"description":"{0}",
|
||||
"info":{
|
||||
"author": "",
|
||||
"email": ""
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-adn",
|
||||
"mimes":["none"],
|
||||
"dependencies":[],
|
||||
"locale": {}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<afx-app-window apptitle="{0}" width="500" height="400" data-id="{0}">
|
||||
<afx-hbox ></afx-hbox>
|
||||
</afx-app-window>
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -27,7 +27,6 @@ namespace OS {
|
||||
* @type {boolean}
|
||||
*/
|
||||
selected: boolean;
|
||||
|
||||
};
|
||||
|
||||
export abstract class BaseEditorModel {
|
||||
|
@ -307,7 +307,7 @@ namespace OS {
|
||||
this.app.currdir = rpath.asFileHandle();
|
||||
this.app.toggleSideBar();
|
||||
return this.app.eum.active.openFile(
|
||||
`${rpath}/${name}.js`.asFileHandle() as application.EditorFileHandle
|
||||
`${rpath}/${name}.js`.asFileHandle() as OS.application.EditorFileHandle
|
||||
);
|
||||
} catch (e) {
|
||||
return this.logger().error(
|
||||
|
@ -1,4 +1,5 @@
|
||||
namespace OS {
|
||||
declare var monaco;
|
||||
export namespace application {
|
||||
/**
|
||||
* Wrapper model for the ACE text editor
|
||||
@ -7,7 +8,7 @@ namespace OS {
|
||||
* @class MonacoEditorModel
|
||||
* @extends {BaseEditorModel}
|
||||
*/
|
||||
export class MonacoEditorModel extends BaseEditorModel {
|
||||
export class MonacoEditorModel extends OS.application.BaseEditorModel {
|
||||
|
||||
static modes: GenericObject<monaco.languages.ILanguageExtensionPoint>;
|
||||
|
||||
@ -61,7 +62,7 @@ namespace OS {
|
||||
if(model.position)
|
||||
{
|
||||
this.editor.setPosition(model.position);
|
||||
this.editor.revealLine(model.position.lineNumber);
|
||||
this.editor.revealLineInCenter(model.position.lineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,11 +204,11 @@ namespace OS {
|
||||
monaco.editor.setTheme("vs-dark");
|
||||
// add editor instance
|
||||
this.eum
|
||||
.add(new MonacoEditorModel(
|
||||
.add(new OS.application.MonacoEditorModel(
|
||||
this,
|
||||
this.find("left-tabbar") as GUI.tag.TabBarTag,
|
||||
this.find("left-editorarea")) as BaseEditorModel)
|
||||
.add(new MonacoEditorModel(
|
||||
.add(new OS.application.MonacoEditorModel(
|
||||
this,
|
||||
this.find("right-tabbar") as GUI.tag.TabBarTag,
|
||||
this.find("right-editorarea")) as BaseEditorModel);
|
||||
@ -919,7 +919,7 @@ namespace OS {
|
||||
this.models = [];
|
||||
}
|
||||
|
||||
get editors(): BaseEditorModel[] {
|
||||
get editors(): OS.application.BaseEditorModel[] {
|
||||
return this.models;
|
||||
}
|
||||
set contextmenuHandle(cb: (e: any, m: any) => void) {
|
||||
|
Loading…
Reference in New Issue
Block a user