add PackageFileHandle + support for library definition + minor fix

This commit is contained in:
lxsang 2020-08-04 19:51:32 +02:00
parent b86565212a
commit b1649016f4
6 changed files with 87 additions and 20 deletions

View File

@ -571,16 +571,24 @@ namespace OS {
// first load it
loadApp(app)
.then((a) =>
PM.createProcess(
app,
application[app],
args
).catch((e) =>
announcer.osfail(
__("Unable to launch: {0}", app),
e
{
if (!application[app]){
return announcer.oserror(
__("{0} is not an application", app),
API.throwe(__("Application not found"))
);
}
PM.createProcess(
app,
application[app],
args
).catch((e) =>
announcer.osfail(
__("Unable to launch: {0}", app),
e
)
)
)
}
)
.catch((e) =>
announcer.osfail(__("Unable to launch: {0}", app), e)

View File

@ -1298,6 +1298,61 @@ namespace OS {
register("^(home|desktop|os|Untitled)$", RemoteFileHandle);
/**
* Package file is remote file ([[RemoteFileHandle]]) located either in
* the local user packages location or system packages
* location, it should be in the following format:
*
* ```
* pkg://PKG_NAME/path/to/file
*
* ```
*
* The system will locale the package name PKG_NAME either in the system domain
* or in user domain and return the correct path to the package
*
* @export
* @class PackageFileHandle
* @extends {RemoteFileHandle}
*/
export class PackageFileHandle extends RemoteFileHandle
{
/**
*Creates an instance of PackageFileHandle.
* @param {string} pkg_path package path in string
* @memberof PackageFileHandle
*/
constructor(pkg_path: string) {
var error:FormattedString|string;
var pkg_name: string;
super(pkg_path);
// now find the correct path
if(!this.genealogy || this.genealogy.length == 0)
{
error = __("Invalid package path");
announcer.oserror(error, API.throwe(error));
throw new Error(error.__());
}
else {
// get the correct path of the package
pkg_name = this.genealogy[0];
if(OS.setting.system.packages[pkg_name])
{
this.setPath(OS.setting.system.packages[pkg_name].path);
}
else
{
error = __("Package not found {0}", pkg_name);
announcer.oserror(error,API.throwe(error));
throw new Error(error.__());
}
}
}
}
register("^pkg$", PackageFileHandle);
/**
* Application file is an AntOS special file allowing to
* refer to an application as a regular file. Its protocol
@ -1372,7 +1427,10 @@ namespace OS {
const result = [];
for (let k in OS.setting.system.packages) {
const v = OS.setting.system.packages[k];
result.push(v);
if(v.app)
{
result.push(v);
}
}
return resolve({
result: result,

View File

@ -1038,14 +1038,14 @@ namespace OS {
* @returns {void}
* @memberof CodePad
*/
private menuAction(dataid: string, r?: CodePad): void {
let me: any = this;
private menuAction(dataid: string, r?: CodePad): any {
let me: CodePad = this;
if (r) {
me = r;
}
switch (dataid) {
case "new":
return me.openFile("Untitled".asFileHandle());
return me.openFile("Untitled".asFileHandle() as CodePadFileHandle);
case "open":
return me
.openDialog("FileDialog", {
@ -1065,7 +1065,7 @@ namespace OS {
})
.then(function (f: API.FileInfoType) {
me.currdir = f.file.path.asFileHandle();
return me.initSideBar();
return me.toggleSideBar();
});
case "save":
me.currfile.cache = me.editor.getValue();

View File

@ -1,4 +1,5 @@
{
"pkgname": "{0}",
"app":"{0}",
"name":"{0}",
"description":"{0}",

View File

@ -393,7 +393,7 @@ namespace OS {
.then((d: string) => {
let name: string;
const v = JSON.parse(d);
const pth = `${this.installdir}/${v.app}`;
const pth = `${this.installdir}/${v.pkgname?v.pkgname:v.app}`;
const dir = [pth];
const files = [];
for (name in zip.files) {
@ -408,13 +408,13 @@ namespace OS {
return this.mkdirs(dir)
.then(() => {
return this.installFile(
v.app,
v.pkgname?v.pkgname:v.app,
zip,
files
)
.then(() => {
const app_meta = {
pkgname: v.app,
pkgname: v.pkgname?v.pkgname:v.app,
name: v.name,
text: v.name,
icon: v.icon,
@ -430,7 +430,7 @@ namespace OS {
: undefined,
};
v.text = v.name;
v.filename = v.app;
v.filename = v.pkgname?v.pkgname:v.app;
v.type = "app";
v.mime = "antos/app";
if (
@ -442,7 +442,7 @@ namespace OS {
}
v.path = pth;
this.systemsetting.system.packages[
v.app
v.pkgname?v.pkgname:v.app
] = v;
this.appDetail(app_meta);
return resolve(v.name);

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.1-a",
"version":"0.1.5-a",
"category":"System",
"iconclass":"fa fa-adn",
"mimes":["none"],