@equinor/echo-base
Advanced tools
Comparing version 0.6.6 to 0.6.7
@@ -73,18 +73,7 @@ import { __awaiter, __generator } from "tslib"; | ||
window[depName] = getLocalRequire(dependencies); | ||
script.onload = function () { | ||
console.log("LOADED ".concat(name, " WITH FILE URI ").concat(fileUri, " SUCCESSFULLY")); | ||
resolve(verifyAppWithModule(name, script.module)); | ||
}; | ||
script.onload = function () { return resolve(verifyAppWithModule(name, script.module)); }; | ||
script.onerror = function () { | ||
console.log('ON ERROR TRIGGERED'); | ||
console.log("COULDN'T LOAD ".concat(name, " WITH FILE URI ").concat(fileUri)); | ||
reject(); | ||
reject("Could not load module ".concat(name)); | ||
}; | ||
try { | ||
document.head.appendChild(script); | ||
} | ||
catch (e) { | ||
console.error(e); | ||
reject('Could not add script tag'); | ||
} | ||
document.head.appendChild(script); | ||
})]; | ||
@@ -139,6 +128,4 @@ }); | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity)]; | ||
case 1: return [2 /*return*/, _b.sent()]; | ||
} | ||
appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity).catch(function () { return console.error; }); | ||
return [2 /*return*/, appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity)]; | ||
}); | ||
@@ -145,0 +132,0 @@ }); |
@@ -47,3 +47,3 @@ import { __awaiter, __generator } from "tslib"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var modules; | ||
var modules, settledModulePromises; | ||
return __generator(this, function (_a) { | ||
@@ -55,4 +55,7 @@ switch (_a.label) { | ||
if (!(modules instanceof Array)) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, Promise.all(modules.map(loader))]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
return [4 /*yield*/, Promise.allSettled(modules.map(loader))]; | ||
case 2: | ||
settledModulePromises = _a.sent(); | ||
consoleLogErrorsForRejectedModules(settledModulePromises); | ||
return [2 /*return*/, getResolvedModules(settledModulePromises)]; | ||
case 3: throw new ModulesMetaError({ message: 'Invalid modules meta-data, argument is not an Array' }); | ||
@@ -63,2 +66,15 @@ } | ||
} | ||
function getResolvedModules(results) { | ||
return results | ||
.filter(function (result) { return result.status === 'fulfilled'; }) | ||
.map(function (result) { return result.value; }); | ||
} | ||
function consoleLogErrorsForRejectedModules(results) { | ||
results | ||
.filter(function (result) { return result.status === 'rejected'; }) | ||
.forEach(function (_a) { | ||
var reason = _a.reason; | ||
return console.error(reason); | ||
}); | ||
} | ||
//# sourceMappingURL=load.js.map |
@@ -76,18 +76,7 @@ "use strict"; | ||
window[depName] = getLocalRequire(dependencies); | ||
script.onload = function () { | ||
console.log("LOADED ".concat(name, " WITH FILE URI ").concat(fileUri, " SUCCESSFULLY")); | ||
resolve(verifyAppWithModule(name, script.module)); | ||
}; | ||
script.onload = function () { return resolve(verifyAppWithModule(name, script.module)); }; | ||
script.onerror = function () { | ||
console.log('ON ERROR TRIGGERED'); | ||
console.log("COULDN'T LOAD ".concat(name, " WITH FILE URI ").concat(fileUri)); | ||
reject(); | ||
reject("Could not load module ".concat(name)); | ||
}; | ||
try { | ||
document.head.appendChild(script); | ||
} | ||
catch (e) { | ||
console.error(e); | ||
reject('Could not add script tag'); | ||
} | ||
document.head.appendChild(script); | ||
})]; | ||
@@ -145,6 +134,4 @@ }); | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity)]; | ||
case 1: return [2 /*return*/, _b.sent()]; | ||
} | ||
appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity).catch(function () { return console.error; }); | ||
return [2 /*return*/, appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity)]; | ||
}); | ||
@@ -151,0 +138,0 @@ }); |
@@ -51,3 +51,3 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var modules; | ||
var modules, settledModulePromises; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -59,4 +59,7 @@ switch (_a.label) { | ||
if (!(modules instanceof Array)) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, Promise.all(modules.map(loader))]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
return [4 /*yield*/, Promise.allSettled(modules.map(loader))]; | ||
case 2: | ||
settledModulePromises = _a.sent(); | ||
consoleLogErrorsForRejectedModules(settledModulePromises); | ||
return [2 /*return*/, getResolvedModules(settledModulePromises)]; | ||
case 3: throw new errors_1.ModulesMetaError({ message: 'Invalid modules meta-data, argument is not an Array' }); | ||
@@ -68,2 +71,15 @@ } | ||
exports.loadModules = loadModules; | ||
function getResolvedModules(results) { | ||
return results | ||
.filter(function (result) { return result.status === 'fulfilled'; }) | ||
.map(function (result) { return result.value; }); | ||
} | ||
function consoleLogErrorsForRejectedModules(results) { | ||
results | ||
.filter(function (result) { return result.status === 'rejected'; }) | ||
.forEach(function (_a) { | ||
var reason = _a.reason; | ||
return console.error(reason); | ||
}); | ||
} | ||
//# sourceMappingURL=load.js.map |
{ | ||
"name": "@equinor/echo-base", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"module": "esm/index.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -87,18 +87,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
script.onload = (): void => { | ||
console.log(`LOADED ${name} WITH FILE URI ${fileUri} SUCCESSFULLY`); | ||
resolve(verifyAppWithModule(name, script.module)); | ||
}; | ||
script.onload = (): void => resolve(verifyAppWithModule(name, script.module)); | ||
script.onerror = (): void => { | ||
console.log('ON ERROR TRIGGERED'); | ||
console.log(`COULDN'T LOAD ${name} WITH FILE URI ${fileUri}`); | ||
reject(); | ||
reject(`Could not load module ${name}`); | ||
}; | ||
try { | ||
document.head.appendChild(script); | ||
} catch (e) { | ||
console.error(e); | ||
reject('Could not add script tag'); | ||
} | ||
document.head.appendChild(script); | ||
}); | ||
@@ -146,3 +136,4 @@ } | ||
): Promise<ModuleData> { | ||
return await appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity); | ||
appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity).catch(() => console.error); | ||
return appendScriptTagToDom(name, link, requireRef, dependencies, crossOrigin, integrity); | ||
} |
@@ -1,2 +0,2 @@ | ||
import { EchoModule, ModuleLoader, ModuleMetaData, ModuleRequester } from '../types'; | ||
import { EchoModule, ModuleData, ModuleLoader, ModuleMetaData, ModuleRequester } from '../types'; | ||
import { ModulesMetaError } from './errors'; | ||
@@ -42,3 +42,5 @@ import { checkFunction } from './utils'; | ||
if (modules instanceof Array) { | ||
return await Promise.all(modules.map(loader)); | ||
const settledModulePromises = await Promise.allSettled(modules.map(loader)); | ||
consoleLogErrorsForRejectedModules(settledModulePromises); | ||
return getResolvedModules(settledModulePromises); | ||
} else { | ||
@@ -48,1 +50,15 @@ throw new ModulesMetaError({ message: 'Invalid modules meta-data, argument is not an Array' }); | ||
} | ||
function getResolvedModules( | ||
results: PromiseSettledResult<ModuleData & ModuleMetaData>[] | ||
): (ModuleData & ModuleMetaData)[] { | ||
return results | ||
.filter((result) => result.status === 'fulfilled') | ||
.map((result: PromiseFulfilledResult<ModuleData & ModuleMetaData>) => result.value); | ||
} | ||
function consoleLogErrorsForRejectedModules(results: PromiseSettledResult<ModuleData & ModuleMetaData>[]): void { | ||
results | ||
.filter((result) => result.status === 'rejected') | ||
.forEach(({ reason }: PromiseRejectedResult) => console.error(reason)); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
273168
5517