mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-02-22 01:42:47 +01:00
add PackageFileHandle + support for library definition + minor fix
This commit is contained in:
parent
b86565212a
commit
b1649016f4
@ -571,16 +571,24 @@ namespace OS {
|
|||||||
// first load it
|
// first load it
|
||||||
loadApp(app)
|
loadApp(app)
|
||||||
.then((a) =>
|
.then((a) =>
|
||||||
PM.createProcess(
|
{
|
||||||
app,
|
if (!application[app]){
|
||||||
application[app],
|
return announcer.oserror(
|
||||||
args
|
__("{0} is not an application", app),
|
||||||
).catch((e) =>
|
API.throwe(__("Application not found"))
|
||||||
announcer.osfail(
|
);
|
||||||
__("Unable to launch: {0}", app),
|
}
|
||||||
e
|
PM.createProcess(
|
||||||
|
app,
|
||||||
|
application[app],
|
||||||
|
args
|
||||||
|
).catch((e) =>
|
||||||
|
announcer.osfail(
|
||||||
|
__("Unable to launch: {0}", app),
|
||||||
|
e
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
)
|
)
|
||||||
.catch((e) =>
|
.catch((e) =>
|
||||||
announcer.osfail(__("Unable to launch: {0}", app), e)
|
announcer.osfail(__("Unable to launch: {0}", app), e)
|
||||||
|
@ -1298,6 +1298,61 @@ namespace OS {
|
|||||||
|
|
||||||
register("^(home|desktop|os|Untitled)$", RemoteFileHandle);
|
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
|
* Application file is an AntOS special file allowing to
|
||||||
* refer to an application as a regular file. Its protocol
|
* refer to an application as a regular file. Its protocol
|
||||||
@ -1372,7 +1427,10 @@ namespace OS {
|
|||||||
const result = [];
|
const result = [];
|
||||||
for (let k in OS.setting.system.packages) {
|
for (let k in OS.setting.system.packages) {
|
||||||
const v = OS.setting.system.packages[k];
|
const v = OS.setting.system.packages[k];
|
||||||
result.push(v);
|
if(v.app)
|
||||||
|
{
|
||||||
|
result.push(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return resolve({
|
return resolve({
|
||||||
result: result,
|
result: result,
|
||||||
|
@ -1038,14 +1038,14 @@ namespace OS {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
* @memberof CodePad
|
* @memberof CodePad
|
||||||
*/
|
*/
|
||||||
private menuAction(dataid: string, r?: CodePad): void {
|
private menuAction(dataid: string, r?: CodePad): any {
|
||||||
let me: any = this;
|
let me: CodePad = this;
|
||||||
if (r) {
|
if (r) {
|
||||||
me = r;
|
me = r;
|
||||||
}
|
}
|
||||||
switch (dataid) {
|
switch (dataid) {
|
||||||
case "new":
|
case "new":
|
||||||
return me.openFile("Untitled".asFileHandle());
|
return me.openFile("Untitled".asFileHandle() as CodePadFileHandle);
|
||||||
case "open":
|
case "open":
|
||||||
return me
|
return me
|
||||||
.openDialog("FileDialog", {
|
.openDialog("FileDialog", {
|
||||||
@ -1065,7 +1065,7 @@ namespace OS {
|
|||||||
})
|
})
|
||||||
.then(function (f: API.FileInfoType) {
|
.then(function (f: API.FileInfoType) {
|
||||||
me.currdir = f.file.path.asFileHandle();
|
me.currdir = f.file.path.asFileHandle();
|
||||||
return me.initSideBar();
|
return me.toggleSideBar();
|
||||||
});
|
});
|
||||||
case "save":
|
case "save":
|
||||||
me.currfile.cache = me.editor.getValue();
|
me.currfile.cache = me.editor.getValue();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"pkgname": "{0}",
|
||||||
"app":"{0}",
|
"app":"{0}",
|
||||||
"name":"{0}",
|
"name":"{0}",
|
||||||
"description":"{0}",
|
"description":"{0}",
|
||||||
|
@ -393,7 +393,7 @@ namespace OS {
|
|||||||
.then((d: string) => {
|
.then((d: string) => {
|
||||||
let name: string;
|
let name: string;
|
||||||
const v = JSON.parse(d);
|
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 dir = [pth];
|
||||||
const files = [];
|
const files = [];
|
||||||
for (name in zip.files) {
|
for (name in zip.files) {
|
||||||
@ -408,13 +408,13 @@ namespace OS {
|
|||||||
return this.mkdirs(dir)
|
return this.mkdirs(dir)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return this.installFile(
|
return this.installFile(
|
||||||
v.app,
|
v.pkgname?v.pkgname:v.app,
|
||||||
zip,
|
zip,
|
||||||
files
|
files
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const app_meta = {
|
const app_meta = {
|
||||||
pkgname: v.app,
|
pkgname: v.pkgname?v.pkgname:v.app,
|
||||||
name: v.name,
|
name: v.name,
|
||||||
text: v.name,
|
text: v.name,
|
||||||
icon: v.icon,
|
icon: v.icon,
|
||||||
@ -430,7 +430,7 @@ namespace OS {
|
|||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
v.text = v.name;
|
v.text = v.name;
|
||||||
v.filename = v.app;
|
v.filename = v.pkgname?v.pkgname:v.app;
|
||||||
v.type = "app";
|
v.type = "app";
|
||||||
v.mime = "antos/app";
|
v.mime = "antos/app";
|
||||||
if (
|
if (
|
||||||
@ -442,7 +442,7 @@ namespace OS {
|
|||||||
}
|
}
|
||||||
v.path = pth;
|
v.path = pth;
|
||||||
this.systemsetting.system.packages[
|
this.systemsetting.system.packages[
|
||||||
v.app
|
v.pkgname?v.pkgname:v.app
|
||||||
] = v;
|
] = v;
|
||||||
this.appDetail(app_meta);
|
this.appDetail(app_meta);
|
||||||
return resolve(v.name);
|
return resolve(v.name);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "xsang.le@gmail.com"
|
"email": "xsang.le@gmail.com"
|
||||||
},
|
},
|
||||||
"version":"0.0.1-a",
|
"version":"0.1.5-a",
|
||||||
"category":"System",
|
"category":"System",
|
||||||
"iconclass":"fa fa-adn",
|
"iconclass":"fa fa-adn",
|
||||||
"mimes":["none"],
|
"mimes":["none"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user