fix(core): update

This commit is contained in:
2022-12-28 19:43:48 +01:00
parent 76e777a3ac
commit 6de2f36964
8 changed files with 4422 additions and 18653 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartenv',
version: '5.0.3',
version: '5.0.4',
description: 'store things about your environment and let them travel across modules'
}

View File

@ -17,10 +17,14 @@ export class Smartenv {
getFunction: () => any;
}) {
if (this.isNode) {
const moduleResult = await this.getSafeNodeModule(optionsArg.nodeModuleName);
const moduleResult = await this.getSafeNodeModule(optionsArg.nodeModuleName);
return moduleResult;
} else if (this.isBrowser) {
const moduleResult = await this.getSafeWebModule(optionsArg.webUrlArg, optionsArg.getFunction);
const moduleResult = await this.getSafeWebModule(
optionsArg.webUrlArg,
optionsArg.getFunction
);
return moduleResult;
} else {
console.error('platform for loading not supported by smartenv');
}
@ -32,7 +36,7 @@ export class Smartenv {
return;
}
// tslint:disable-next-line: function-constructor
return (new Function(`return import('${moduleNameArg}')`))() as Promise<T>;
return new Function(`return import('${moduleNameArg}')`)() as Promise<T>;
}
public loadedScripts: string[] = [];
@ -41,13 +45,13 @@ export class Smartenv {
console.error('You tried to load a web module in a wrong context');
return;
}
if (this.loadedScripts.includes(urlArg)) {
return getFunctionArg();
} else {
this.loadedScripts.push(urlArg);
}
const done = plugins.smartpromise.defer();
if (globalThis.importScripts) {
globalThis.importScripts(urlArg);
@ -138,9 +142,7 @@ export class Smartenv {
public async printEnv() {
if (this.isNode) {
console.log('running on NODE');
console.log(
'node version is ' + this.nodeVersion
);
console.log('node version is ' + this.nodeVersion);
} else {
console.log('running on BROWSER');
console.log('browser is ' + this.userAgent);