add more type, all defaults apps are now in typescript

This commit is contained in:
Xuan Sang LE
2020-06-04 17:49:48 +02:00
parent 6e95994892
commit fb462fe31b
50 changed files with 2612 additions and 1734 deletions

View File

@ -373,9 +373,9 @@ namespace OS {
v.iconclass = "fa fa-adn";
}
this.notify(__("Installing..."));
this.app.systemsetting.system.packages[meta.name] = v;
setting.system.packages[meta.name] = v;
this.notify(__("Running {0}...", meta.name));
return this.app._gui.forceLaunch(meta.name, []);
return GUI.forceLaunch(meta.name, []);
});
}
}

View File

@ -347,7 +347,7 @@ namespace OS {
.parent()
.mk(path.basename)
.then((d: any) => {
this.app.trigger("filechange", {
this.app.observable.trigger("filechange", {
file: path.parent(),
type: "dir",
});
@ -414,7 +414,7 @@ namespace OS {
return new Promise((resolve, reject) => {
if (!this.app.currdir) {
return reject(
this.app._api.throwe(__("Current folder is not found"))
API.throwe(__("Current folder is not found"))
);
}
`${this.app.currdir.path}/${file}`
@ -423,7 +423,7 @@ namespace OS {
.then((data) => resolve(data))
.catch((e) => {
return reject(
this.app._api.throwe(__("Unable to read meta-data"))
API.throwe(__("Unable to read meta-data"))
);
});
});

View File

@ -282,11 +282,11 @@ namespace OS {
private run(meta: GenericObject<any>): Promise<any> {
return new Promise(async (resolve, reject) => {
const path = `${meta.root}/build/debug/${meta.meta.name}.js`;
if (this.app._api.shared[path]) {
delete this.app._api.shared[path];
if (API.shared[path]) {
delete API.shared[path];
}
try {
await this.app._api.requires(path);
await API.requires(path);
let v: GenericObject<any>;
if (this.app.extensions[meta.meta.name]) {
this.app.extensions[meta.meta.name].child = [];
@ -306,9 +306,9 @@ namespace OS {
this.app.extensions[meta.meta.name]
);
this.app.extensions[meta.meta.name].onchildselect(
(e: GUI.TagEventType) => {
(e: GUI.TagEventType<GUI.tag.ListItemEventData>) => {
return this.app.loadAndRunExtensionAction(
e.data.item.data
e.data.item.data as any
);
}
);
@ -334,7 +334,7 @@ namespace OS {
return new Promise((resolve, reject) => {
const idx = files.indexOf("extension.json");
if (idx < 0) {
reject(this.app._api.throwe(__("No meta-data found")));
reject(API.throwe(__("No meta-data found")));
}
const metafile = files.splice(idx, 1)[0];
// read the meta file

View File

@ -178,7 +178,9 @@ namespace OS {
if (e.data.type === "dir") {
return;
}
return this.openFile(e.data.path.asFileHandle());
return this.openFile(
e.data.path.asFileHandle() as CodePadFileHandle
);
};
this.fileview.onfileselect = (e) => {
@ -188,7 +190,9 @@ namespace OS {
if (e.data.type === "dir") {
return;
}
const i = this.findTabByFile(e.data.path.asFileHandle());
const i = this.findTabByFile(
e.data.path.asFileHandle() as CodePadFileHandle
);
if (i !== -1) {
return (this.tabbar.selected = i);
}
@ -202,7 +206,9 @@ namespace OS {
m.items = [
{
text: __("Command palete"),
onmenuselect: (e: GUI.TagEventType) => {
onmenuselect: (
e: GUI.TagEventType<GUI.tag.MenuEventData>
) => {
return this.spotlight.run(this);
},
},
@ -237,17 +243,19 @@ namespace OS {
.then(function (d: any) {
const p1 = des;
const p2 = src.parent().path;
if(p1.length < p2.length)
{
if (p1.length < p2.length) {
e.data.to.update(p1);
e.data.from.parent.update(p2);
}
else
{
e.data.from.parent.update(p2);
(e.data
.from as GUI.tag.TreeViewTag).parent.update(
p2
);
} else {
(e.data
.from as GUI.tag.TreeViewTag).parent.update(
p2
);
e.data.to.update(p1);
}
})
.catch((e: Error) =>
this.error(__("Unable to move file/folder"), e)
@ -268,7 +276,6 @@ namespace OS {
return this.openFile(this.currfile);
}
/**
*
*
@ -443,7 +450,6 @@ namespace OS {
this.langstat.text = this.currfile.langmode.caption;
}
/**
*
*
@ -500,7 +506,7 @@ namespace OS {
cmdtheme.addAction({ text: v.caption, theme: v.theme });
}
cmdtheme.onchildselect(function (
d: GUI.TagEventType,
d: GUI.TagEventType<GUI.tag.ListItemEventData>,
r: CodePad
) {
const data = d.data.item.data;
@ -513,7 +519,7 @@ namespace OS {
cmdmode.addAction({ text: v.caption, mode: v.mode });
}
cmdmode.onchildselect(function (
d: GUI.TagEventType,
d: GUI.TagEventType<GUI.tag.ListItemEventData>,
r: CodePad
) {
const data = d.data.item.data;
@ -529,7 +535,6 @@ namespace OS {
this.addAction(CMDMenu.fromMenu(this.fileMenu()));
}
/**
*
*
@ -558,9 +563,13 @@ namespace OS {
this.extensions[ext.name]
);
this.extensions[ext.name].onchildselect(
(e: GUI.TagEventType) => {
(
e: GUI.TagEventType<
GUI.tag.ListItemEventData
>
) => {
return this.loadAndRunExtensionAction(
e.data.item.data
e.data.item.data as any
);
}
);
@ -601,7 +610,6 @@ namespace OS {
});
}
/**
*
*
@ -660,7 +668,10 @@ namespace OS {
shortcut: "A-W",
},
],
onchildselect: (e: GUI.TagEventType, r: CodePad) => {
onchildselect: (
e: GUI.TagEventType<GUI.tag.MenuEventData>,
r: CodePad
) => {
return this.menuAction(e.data.item.data.dataid, r);
},
};
@ -674,7 +685,9 @@ namespace OS {
* @returns {void}
* @memberof CodePad
*/
private ctxFileMenuHandle(e: GUI.TagEventType): void {
private ctxFileMenuHandle(
e: GUI.TagEventType<GUI.tag.MenuEventData>
): void {
const el = e.data.item as GUI.tag.MenuEntryTag;
if (!el) {
return;
@ -949,7 +962,7 @@ namespace OS {
},
],
onchildselect: (
e: GUI.TagEventType,
e: GUI.TagEventType<GUI.tag.MenuEventData>,
r: CodePadFileHandle
) => {
return this.spotlight.run(this);
@ -969,7 +982,10 @@ namespace OS {
private shortcut: string;
nodes: GenericObject<any>[];
parent: CMDMenu;
private select: (e: GUI.TagEventType, r: CodePad) => void;
private select: (
e: GUI.TagEventType<GUI.tag.ListItemEventData>,
r: CodePad
) => void;
static fromMenu: (mn: GUI.BasicItemType) => CMDMenu;
/**
@ -1017,7 +1033,10 @@ namespace OS {
* @memberof CMDMenu
*/
onchildselect(
f: (e: GUI.TagEventType, r: CodePad) => void
f: (
e: GUI.TagEventType<GUI.tag.ListItemEventData>,
r: CodePad
) => void
): CMDMenu {
this.select = f;
return this;
@ -1093,7 +1112,10 @@ namespace OS {
const offset = $(".afx-window-content", win).offset();
const pw = win.width / 5;
(this.scheme as GUI.tag.WindowTag).width = 3 * pw;
$(this.scheme).offset({ top: offset.top - 2, left: offset.left + pw });
$(this.scheme).offset({
top: offset.top - 2,
left: offset.left + pw,
});
var cb = (e: JQuery.MouseEventBase) => {
if ($(e.target).closest(this.scheme).length > 0) {
return $(this.find("searchbox")).focus();