relic/packages/core/src/manifest/libraries.js
2024-04-02 20:21:58 +02:00

23 lines
773 B
JavaScript

import PublicInternalLibraries from "./libs"
const isAClass = (x) => x && typeof x === "function" && x.prototype && typeof x.prototype.constructor === "function"
export default async (dependencies, bindCtx) => {
const libraries = {}
for await (const lib of dependencies) {
if (PublicInternalLibraries[lib]) {
if (typeof PublicInternalLibraries[lib] === "function" && isAClass(PublicInternalLibraries[lib])) {
libraries[lib] = new PublicInternalLibraries[lib](bindCtx)
if (libraries[lib].initialize) {
await libraries[lib].initialize()
}
} else {
libraries[lib] = PublicInternalLibraries[lib]
}
}
}
return libraries
}