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
{
/*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",
"email": "mrsang@iohub.dev"
},
"version":"0.1.2-a",
"version":"0.1.5-a",
"category":"Development",
"iconclass":"bi bi-journal-code",
"mimes":[

Binary file not shown.

View File

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

View File

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

View File

@ -59,7 +59,10 @@ namespace OS {
protected setTextModel(model: any): void {
this.editor.setModel(model.model);
if(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 {
export namespace application {
@ -199,28 +201,30 @@ namespace OS {
const wrapper = this.find("wrapper");
$(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(['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);
});
}))
}))*/
}
/**
@ -1111,7 +1115,7 @@ namespace OS {
Antedit.Logger = Logger;
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",
"category": "Development",
"author": "Xuan Sang LE",
"version": "0.1.2-a",
"version": "0.1.5-a",
"dependencies": ["MonacoCore@0.23.0-r"],
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/build/release/Antedit.zip"
},