lakutata
Version:
An IoC-based universal application framework.
202 lines (155 loc) • 4.36 kB
JavaScript
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */
import { pathToFileURL as t } from "url";
import { Lifetime as e } from "./Lifetime.mjs";
import { RESOLVER as r, asClass as o, asFunction as s } from "./Resolvers.mjs";
import { isFunction as n, isClass as i } from "./Utils.mjs";
import { CamelCase as m } from "../base/internal/CamelCase.mjs";
import { As as a } from "../helpers/As.mjs";
import "./Errors.mjs";
import "../../exceptions/di/DependencyInjectionException.mjs";
import "../base/abstracts/Exception.mjs";
import "../../../vendor/Package.internal.5.mjs";
import "../../../vendor/Package.internal.2.mjs";
import "../../../vendor/Package.internal.6.mjs";
import "../base/internal/ThrowWarning.mjs";
import "../helpers/Templating.mjs";
import "../helpers/DevNull.mjs";
import "../helpers/NoCase.mjs";
import "../base/internal/ConstructorSymbol.mjs";
import "../../constants/DIMetadataKey.mjs";
import "../../../vendor/Package.internal.1.mjs";
import "node:crypto";
import "../../../vendor/Package.internal.7.mjs";
import "../../../vendor/Package.internal.3.mjs";
import "../base/internal/DataValidator.mjs";
import "node:util/types";
import "../validation/VLD.mjs";
import "util";
import "../../exceptions/dto/InvalidValueException.mjs";
import "../../../vendor/Package.internal.8.mjs";
import "../helpers/IsHtml.mjs";
import "../helpers/IsXML.mjs";
import "../../constants/DTOMetadataKey.mjs";
import "../helpers/ObjectConstructor.mjs";
import "../helpers/ObjectParentConstructors.mjs";
import "../helpers/ObjectParentConstructor.mjs";
import "../helpers/ObjectPrototype.mjs";
import "./InjectionMode.mjs";
import "./ParamParser.mjs";
import "./FunctionTokenizer.mjs";
// -- Shims --
import cjsUrl from 'node:url';
import cjsPath from 'node:path';
import cjsModule from 'node:module';
const __filename = cjsUrl.fileURLToPath(import.meta.url);
const __dirname = cjsPath.dirname(__filename);
const require = cjsModule.createRequire(import.meta.url);
const p = {
camelCase: t => m(t)
};
function l(t, e, r) {
r ??= {};
const o = t.container;
r = f(r);
const s = t.listModules(e, r);
if (r.esModules) {
return c(t, o, s, r);
} else {
const e = s.map(e => {
const r = t.require(e.path);
return u(r, e);
});
return j(e, o, s, r);
}
}
async function c(e, r, o, s) {
const n = [];
for (const r of o) {
const o = t(r.path).toString();
n.push(a(e.require(o)));
}
const i = await Promise.all(n);
const m = [];
for (let t = 0; t < o.length; t++) {
m.push(a(u(i[t], o[t])));
}
return j(m, r, o, s);
}
function u(t, e) {
const o = [];
if (!t) return o;
if (n(t)) {
o.push({
name: e.name,
path: e.path,
value: t,
opts: e.opts
});
return o;
}
if (t.default && n(t.default)) {
o.push({
name: e.name,
path: e.path,
value: t.default,
opts: e.opts
});
}
for (const s of Object.keys(t)) {
if (s === "default") continue;
if (n(t[s]) && r in t[s]) {
o.push({
name: s,
path: e.path,
value: t[s],
opts: e.opts
});
}
}
return o;
}
function j(t, e, r, o) {
t.reduce((t, e) => t.concat(e), []).filter(t => t).forEach(d.bind(null, e, o));
return {
loadedModules: r
};
}
function f(t) {
return {
resolverOptions: {
lifetime: e.TRANSIENT,
...t && t.resolverOptions
},
...t
};
}
function d(t, e, n) {
const m = n.value[r];
let a = m && m.name;
if (!a) {
a = n.name;
let t = e.formatName;
if (t) {
if (typeof t === "string") {
t = p[t];
}
if (t) {
a = t(a, n);
}
}
}
let l = n.opts;
if (typeof l === "string") {
l = {
lifetime: l
};
}
const c = {
...e.resolverOptions,
...l,
...m
};
const u = c.register ? c.register : i(n.value) ? o : s;
t.register(a, u(n.value, c));
}
export { l as loadModules };