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,51 +331,36 @@ 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) const meta = JSON.parse(new TextDecoder("utf-8").decode(d));
.then((zip: any) => { const pth = this.ext_dir(meta.name);
zip.file("extension.json").async("uint8array") const dir = [pth];
.then((d) =>{ const files = [];
const meta = JSON.parse(new TextDecoder("utf-8").decode(d)); for (let name in zip.files) {
const pth = this.ext_dir(meta.name); const file = zip.files[name];
const dir = [pth]; if (file.dir) {
const files = []; dir.push(pth + "/" + name);
for (let name in zip.files) { } else if(name != "extension.json") {
const file = zip.files[name]; files.push(name);
if (file.dir) { }
dir.push(pth + "/" + name); }
} else if(name != "extension.json") { if (dir.length > 0) {
files.push(name); await API.VFS.mkdirAll(dir, true)
} await this.installFiles(files, zip, meta);
} } else {
if (dir.length > 0) { await this.installFiles(files, zip, meta);
API.VFS.mkdirAll(dir) }
.then(() => { resolve();
this.installFiles(files, zip, meta) }
.then(() => resolve()) catch(e)
.catch((e) => {
reject(__e(e)) reject(__e(e));
); }
})
.catch((e) => reject(__e(e)));
} else {
this.installFiles(files, zip, meta)
.then(() => 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) => {
const file = files.splice(0, 1)[0]; try{
const path = `${this.ext_dir(meta.name)}/${file}`; const file = files.splice(0, 1)[0];
return zip const path = `${this.ext_dir(meta.name)}/${file}`;
.file(file) const d = await zip.file(file).async("uint8array");
.async("uint8array") const r = await path.asFileHandle()
.then((d: Uint8Array) => { .setCache(new Blob([d], { type: "octet/stream" }))
return path .write("text/plain");
.asFileHandle()
.setCache(new Blob([d], { type: "octet/stream" })) if (r.error) {
.write("text/plain") return reject(r.error);
.then((r) => { }
if (r.error) { await this.installFiles(files, zip, meta);
return reject(r.error); resolve();
} }
return this.installFiles(files, zip, meta) catch(e)
.then(() => resolve()) {
.catch((e) => reject(__e(e))); reject(__e(e));
}) }
.catch((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 {
@ -198,29 +200,31 @@ 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) => { monaco.editor.setTheme("vs-dark");
// add editor instance
this.eum
.add(new MonacoEditorModel(
this,
this.find("left-tabbar") as GUI.tag.TabBarTag,
this.find("left-editorarea")) as BaseEditorModel)
.add(new MonacoEditorModel(
this,
this.find("right-tabbar") as GUI.tag.TabBarTag,
this.find("right-editorarea")) as BaseEditorModel);
this.eum.onstatuschange = (st) =>
this.updateStatus(st)
$(wrapper).css('visibility', 'visible');
this.setup();
this.eum.active.openFile(file);
/*this.load(new Promise((resolve, reject) => {
require.config({ paths: { 'vs': "pkg://MonacoCore/vs".asFileHandle().getlink() }}); require.config({ paths: { 'vs': "pkg://MonacoCore/vs".asFileHandle().getlink() }});
require(['vs/editor/editor.main'], () => { require(['vs/editor/editor.main'], () => {
monaco.editor.setTheme("vs-dark");
// add editor instance
this.eum
.add(new MonacoEditorModel(
this,
this.find("left-tabbar") as GUI.tag.TabBarTag,
this.find("left-editorarea")) as BaseEditorModel)
.add(new MonacoEditorModel(
this,
this.find("right-tabbar") as GUI.tag.TabBarTag,
this.find("right-editorarea")) as BaseEditorModel);
this.eum.onstatuschange = (st) =>
this.updateStatus(st)
$(wrapper).css('visibility', 'visible');
this.setup();
this.eum.active.openFile(file);
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"
}, },