Files
NapCatQQ/.pnpm-store/v3/files/94/e8d7f1f5cde15870571dbc255edf2df1a7c61fa21d7db7eebbe0398f2a92f225ab395ab13a928c3f5bb5555f4face7dd1d5183d5bbda67596a31723f68b21a
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

49 lines
2.8 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolvePostConstruct = resolvePostConstruct;
const common_1 = require("@inversifyjs/common");
const InversifyCoreError_1 = require("../../error/models/InversifyCoreError");
const InversifyCoreErrorKind_1 = require("../../error/models/InversifyCoreErrorKind");
function resolvePostConstruct(instance, binding, postConstructMethodName) {
const postConstructResult = invokePostConstruct(instance, binding, postConstructMethodName);
if ((0, common_1.isPromise)(postConstructResult)) {
return postConstructResult.then(() => instance);
}
return instance;
}
function invokePostConstruct(instance, binding, postConstructMethodName) {
if (postConstructMethodName in instance) {
if (typeof instance[postConstructMethodName] === 'function') {
let postConstructResult;
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
postConstructResult = instance[postConstructMethodName]();
}
catch (error) {
throw new InversifyCoreError_1.InversifyCoreError(InversifyCoreErrorKind_1.InversifyCoreErrorKind.resolution, `Unexpected error found when calling "${postConstructMethodName.toString()}" @postConstruct decorated method on class "${binding.implementationType.name}"`, {
cause: error,
});
}
if ((0, common_1.isPromise)(postConstructResult)) {
return invokePostConstructAsync(binding, postConstructMethodName, postConstructResult);
}
}
else {
throw new InversifyCoreError_1.InversifyCoreError(InversifyCoreErrorKind_1.InversifyCoreErrorKind.resolution, `Expecting a "${postConstructMethodName.toString()}" method when resolving "${binding.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);
}
}
else {
throw new InversifyCoreError_1.InversifyCoreError(InversifyCoreErrorKind_1.InversifyCoreErrorKind.resolution, `Expecting a "${postConstructMethodName.toString()}" property when resolving "${binding.implementationType.name}" class @postConstruct decorated method, none found.`);
}
}
async function invokePostConstructAsync(binding, postConstructMethodName, postConstructResult) {
try {
await postConstructResult;
}
catch (error) {
throw new InversifyCoreError_1.InversifyCoreError(InversifyCoreErrorKind_1.InversifyCoreErrorKind.resolution, `Unexpected error found when calling "${postConstructMethodName.toString()}" @postConstruct decorated method on class "${binding.implementationType.name}"`, {
cause: error,
});
}
}
//# sourceMappingURL=resolvePostConstruct.js.map