update core

This commit is contained in:
lxsang 2021-04-19 15:41:35 +02:00
parent f8c19e2a4c
commit eb27b330a7
2 changed files with 41 additions and 33 deletions

Binary file not shown.

View File

@ -1395,40 +1395,48 @@ namespace OS {
* @returns {Promise<void>} a promise on the result data * @returns {Promise<void>} a promise on the result data
*/ */
export function requires(l: string, force: boolean = false): Promise<void> { export function requires(l: string, force: boolean = false): Promise<void> {
return new Promise(function (resolve, reject) { return new Promise(async (resolve, reject) =>{
if (!API.shared[l] || force) { try {
const libfp = l.asFileHandle(); if (!API.shared[l] || force) {
switch (libfp.ext) { const libfp = l.asFileHandle();
case "css": switch (libfp.ext) {
return libfp case "css":
.onready() await libfp.onready();
.then(function () { $("<link>", {
$("<link>", { rel: "stylesheet",
rel: "stylesheet", type: "text/css",
type: "text/css", href: `${libfp.getlink()}`,
href: `${libfp.getlink()}`, }).appendTo("head");
}).appendTo("head"); API.shared[l] = true;
API.shared[l] = true; console.log("Loaded :", l);
console.log("Loaded :", l); return resolve(undefined);
return resolve(undefined); case "js":
}) /*return API.script(libfp.getlink())
.catch((e: Error) => reject(__e(e))); .then(function (data: any) {
case "js": API.shared[l] = true;
return API.script(libfp.getlink()) console.log("Loaded :", l);
.then(function (data: any) { return resolve(data);
API.shared[l] = true; })
console.log("Loaded :", l); .catch((e: Error) => reject(__e(e)));*/
return resolve(data); $("<script>",{
}) async: "async",
.catch((e: Error) => reject(__e(e))); type: "text/javascript",
default: src: libfp.getlink()
return reject( }).appendTo("head");
API.throwe(__("Invalid library: {0}", l)) API.shared[l] = true;
); console.log("Loaded :", l);
return resolve(undefined);
default:
return reject(
API.throwe(__("Invalid library: {0}", l))
);
}
} else {
console.log(l, "Library exist, no need to load");
return resolve();
} }
} else { } catch (error) {
console.log(l, "Library exist, no need to load"); reject(__e(error));
return resolve();
} }
}); });
} }