update antedit v0.1.5

This commit is contained in:
mrsang 2021-04-19 16:48:53 +02:00
parent 64b9eebf6d
commit 9087647527
10 changed files with 150 additions and 96 deletions

66
Antedit/build.json Normal file
View File

@ -0,0 +1,66 @@
{
"name": "Antedit",
"targets": {
"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": [
"ts/monaco.d.ts",
"ts/BaseEditorModel.ts",
"ts/MonacoEditorModel.ts",
"ts/main.ts",
"ts/EditorExtensionMaker.ts"
],
"dest": "build/debug/main.js"
}
},
{
"name": "vfs-cp",
"data": {
"src": [
"extensions",
"assets/scheme.html",
"package.json",
"README.md",
"css/main.css"
],
"dest":"build/debug"
}
}
]
},
"uglify": {
"require": ["terser"],
"jobs": [
{
"name":"terser-uglify",
"data": ["build/debug/main.js"]
}
]
},
"release": {
"depend": ["build","uglify"],
"require": ["zip"],
"jobs": [
{
"name": "zip-mk",
"data": {
"src":"build/debug",
"dest":"build/release/Antedit.zip"
}
}
]
}
}
}

View File

@ -1,4 +1,3 @@
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container
{ {
/*border-top: 1px solid #272822;*/ /*border-top: 1px solid #272822;*/

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
"author": "Xuan Sang LE", "author": "Xuan Sang LE",
"email": "mrsang@iohub.dev" "email": "mrsang@iohub.dev"
}, },
"version":"0.1.2-a", "version":"0.1.5-a",
"category":"Development", "category":"Development",
"iconclass":"bi bi-journal-code", "iconclass":"bi bi-journal-code",
"mimes":[ "mimes":[

Binary file not shown.

View File

@ -7,7 +7,7 @@
"author": "Xuan Sang LE", "author": "Xuan Sang LE",
"email": "mrsang@iohub.dev" "email": "mrsang@iohub.dev"
}, },
"version":"0.1.2-a", "version":"0.1.5-a",
"category":"Development", "category":"Development",
"iconclass":"bi bi-journal-code", "iconclass":"bi bi-journal-code",
"mimes":[ "mimes":[

View File

@ -220,10 +220,10 @@ namespace OS {
release(): void { release(): void {
this.logger().clear(); this.logger().clear();
this.metadata("extension.json") this.metadata("extension.json")
.then((meta) => { .then(async (meta) => {
this.build(async () => { this.build(async () => {
try { try {
API.VFS.mkar( await API.VFS.mkar(
`${meta.root}/build/debug`, `${meta.root}/build/debug`,
`${meta.root}/build/release/${meta.meta.name}.zip` `${meta.root}/build/release/${meta.meta.name}.zip`
); );
@ -298,7 +298,7 @@ namespace OS {
["main.tpl", `${rpath}/${name}.js`], ["main.tpl", `${rpath}/${name}.js`],
["meta.tpl", `${rpath}/extension.json`], ["meta.tpl", `${rpath}/extension.json`],
]; ];
API.VFS.mkdirAll(dirs) API.VFS.mkdirAll(dirs, true)
.then(async () => { .then(async () => {
try { try {
await API.VFS.mktpl(files, this.basedir(), (data)=>{ await API.VFS.mktpl(files, this.basedir(), (data)=>{
@ -331,16 +331,12 @@ namespace OS {
* @memberof EditorExtensionMaker * @memberof EditorExtensionMaker
*/ */
private installZip(path: string): Promise<void> { private installZip(path: string): Promise<void> {
return new Promise((resolve, reject) => { return new Promise(async (resolve, reject) => {
API.requires("os://scripts/jszip.min.js") try{
.then(() => { await API.requires("os://scripts/jszip.min.js");
path.asFileHandle() const data = await path.asFileHandle().read("binary");
.read("binary") const zip = await JSZip.loadAsync(data);
.then((data) => { const d = await zip.file("extension.json").async("uint8array");
JSZip.loadAsync(data)
.then((zip: any) => {
zip.file("extension.json").async("uint8array")
.then((d) =>{
const meta = JSON.parse(new TextDecoder("utf-8").decode(d)); const meta = JSON.parse(new TextDecoder("utf-8").decode(d));
const pth = this.ext_dir(meta.name); const pth = this.ext_dir(meta.name);
const dir = [pth]; const dir = [pth];
@ -354,28 +350,17 @@ namespace OS {
} }
} }
if (dir.length > 0) { if (dir.length > 0) {
API.VFS.mkdirAll(dir) await API.VFS.mkdirAll(dir, true)
.then(() => { await this.installFiles(files, zip, meta);
this.installFiles(files, zip, meta)
.then(() => resolve())
.catch((e) =>
reject(__e(e))
);
})
.catch((e) => reject(__e(e)));
} else { } else {
this.installFiles(files, zip, meta) await this.installFiles(files, zip, meta);
.then(() => resolve()) }
.catch((e) => reject(__e(e))); resolve();
}
catch(e)
{
reject(__e(e));
} }
})
.catch(e => reject(__e(e)));
})
.catch((e: Error) => reject(__e(e)));
})
.catch((e) => reject(__e(e)));
})
.catch((e) => reject(__e(e)));
}); });
} }
@ -403,28 +388,25 @@ namespace OS {
if (files.length === 0) { if (files.length === 0) {
return this.installMeta(meta); return this.installMeta(meta);
} }
return new Promise((resolve, reject) => { return new Promise(async (resolve, reject) => {
try{
const file = files.splice(0, 1)[0]; const file = files.splice(0, 1)[0];
const path = `${this.ext_dir(meta.name)}/${file}`; const path = `${this.ext_dir(meta.name)}/${file}`;
return zip const d = await zip.file(file).async("uint8array");
.file(file) const r = await path.asFileHandle()
.async("uint8array")
.then((d: Uint8Array) => {
return path
.asFileHandle()
.setCache(new Blob([d], { type: "octet/stream" })) .setCache(new Blob([d], { type: "octet/stream" }))
.write("text/plain") .write("text/plain");
.then((r) => {
if (r.error) { if (r.error) {
return reject(r.error); return reject(r.error);
} }
return this.installFiles(files, zip, meta) await this.installFiles(files, zip, meta);
.then(() => resolve()) resolve();
.catch((e) => reject(__e(e))); }
}) catch(e)
.catch((e) => reject(__e(e))); {
}) reject(__e(e));
.catch((e: Error) => reject(__e(e))); }
}); });
} }

View File

@ -59,7 +59,10 @@ namespace OS {
protected setTextModel(model: any): void { protected setTextModel(model: any): void {
this.editor.setModel(model.model); this.editor.setModel(model.model);
if(model.position) if(model.position)
{
this.editor.setPosition(model.position); this.editor.setPosition(model.position);
this.editor.revealLine(model.position.lineNumber);
}
} }

View File

@ -1,3 +1,5 @@
declare var __monaco_public_path__;
__monaco_public_path__ = "VFS/get/"+ "pkg://MonacoCore/bundle/".asFileHandle().path + "/";
namespace OS { namespace OS {
export namespace application { export namespace application {
@ -199,9 +201,6 @@ namespace OS {
const wrapper = this.find("wrapper"); const wrapper = this.find("wrapper");
$(wrapper).css('visibility', 'hidden'); $(wrapper).css('visibility', 'hidden');
this.load(new Promise((resolve, reject) => {
require.config({ paths: { 'vs': "pkg://MonacoCore/vs".asFileHandle().getlink() }});
require(['vs/editor/editor.main'], () => {
monaco.editor.setTheme("vs-dark"); monaco.editor.setTheme("vs-dark");
// add editor instance // add editor instance
this.eum this.eum
@ -218,9 +217,14 @@ namespace OS {
$(wrapper).css('visibility', 'visible'); $(wrapper).css('visibility', 'visible');
this.setup(); this.setup();
this.eum.active.openFile(file); this.eum.active.openFile(file);
/*this.load(new Promise((resolve, reject) => {
require.config({ paths: { 'vs': "pkg://MonacoCore/vs".asFileHandle().getlink() }});
require(['vs/editor/editor.main'], () => {
resolve(undefined); resolve(undefined);
}); });
})) }))*/
} }
/** /**
@ -1111,7 +1115,7 @@ namespace OS {
Antedit.Logger = Logger; Antedit.Logger = Logger;
Antedit.dependencies = [ Antedit.dependencies = [
"pkg://MonacoCore/vs/loader.js" "pkg://MonacoCore/bundle/app.bundle.js"
]; ];
} }
} }

View File

@ -35,7 +35,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/README.md", "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/README.md",
"category": "Development", "category": "Development",
"author": "Xuan Sang LE", "author": "Xuan Sang LE",
"version": "0.1.2-a", "version": "0.1.5-a",
"dependencies": ["MonacoCore@0.23.0-r"], "dependencies": ["MonacoCore@0.23.0-r"],
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/build/release/Antedit.zip" "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/build/release/Antedit.zip"
}, },