Comparing version 4.0.0-rc-13 to 4.0.0-rc-14
@@ -5,7 +5,5 @@ "use strict"; | ||
const CircularDependencyError_js_1 = require("./CircularDependencyError.js"); | ||
const findMetadata_js_1 = require("./findMetadata.js"); | ||
const metadata_js_1 = require("./metadata.js"); | ||
const isSingleton_js_1 = require("./isSingleton.js"); | ||
const modifyConstructor_js_1 = require("./modifyConstructor.js"); | ||
const Trace_js_1 = require("./Trace.js"); | ||
const workWithDiSettings_js_1 = require("./workWithDiSettings.js"); | ||
class ContainerImpl { | ||
@@ -23,6 +21,4 @@ singletons; | ||
const inject = (...injectionParams) => { | ||
(0, modifyConstructor_js_1.modifyConstructor)(implementationType, (settings) => { | ||
const metadata = (0, findMetadata_js_1.findOrCreateMetadata)(settings); | ||
metadata.injected = injectionParams; | ||
}); | ||
const metadata = (0, metadata_js_1.findOrCreateMetadata)(implementationType); | ||
metadata.injected = injectionParams; | ||
}; | ||
@@ -47,7 +43,5 @@ this.dependencies.set(implementationType, implementationType); | ||
if (!(0, isSingleton_js_1.isSingleton)(implementationType)) { | ||
(0, workWithDiSettings_js_1.workWithDiSettings)(implementationType, (settings) => { | ||
const metadata = (0, findMetadata_js_1.findMetadata)(settings); | ||
metadata.modifiedClass = implementationType; | ||
metadata.singleton = true; | ||
}); | ||
const metadata = (0, metadata_js_1.findOrCreateMetadata)(implementationType); | ||
metadata.modifiedClass = implementationType; | ||
metadata.singleton = true; | ||
} | ||
@@ -122,3 +116,3 @@ return { | ||
trace.implemented = implementation.name; | ||
const metadata = (0, findMetadata_js_1.findMetadata)(implementation); | ||
const metadata = (0, metadata_js_1.findMetadata)(implementation); | ||
let injectableArguments = []; | ||
@@ -125,0 +119,0 @@ const injectionParams = []; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.inject = void 0; | ||
const findMetadata_js_1 = require("../findMetadata.js"); | ||
const workWithDiSettings_js_1 = require("../workWithDiSettings.js"); | ||
const metadata_js_1 = require("../metadata.js"); | ||
exports.inject = ((...dependencies) => { | ||
return (constructor) => { | ||
(0, workWithDiSettings_js_1.workWithDiSettings)(constructor, (settings) => { | ||
const metadata = (0, findMetadata_js_1.findMetadata)(settings); | ||
metadata.modifiedClass = constructor; | ||
metadata.injectDependencies = dependencies; | ||
}); | ||
(0, metadata_js_1.saveConstructorMetadata)(constructor, ...dependencies); | ||
return constructor; | ||
@@ -14,0 +9,0 @@ }; |
@@ -21,3 +21,3 @@ "use strict"; | ||
__exportStar(require("./decorators/inject.js"), exports); | ||
__exportStar(require("./findMetadata.js"), exports); | ||
__exportStar(require("./metadata.js"), exports); | ||
__exportStar(require("./isSingleton.js"), exports); | ||
@@ -30,3 +30,3 @@ __exportStar(require("./Trace.js"), exports); | ||
const inject_js_1 = require("./decorators/inject.js"); | ||
const findMetadata_js_1 = require("./findMetadata.js"); | ||
const metadata_js_1 = require("./metadata.js"); | ||
const isSingleton_js_1 = require("./isSingleton.js"); | ||
@@ -40,4 +40,4 @@ const Trace_js_1 = require("./Trace.js"); | ||
inject: inject_js_1.inject, | ||
findMetadata: findMetadata_js_1.findMetadata, | ||
findOrCreateMetadata: findMetadata_js_1.findOrCreateMetadata, | ||
findMetadata: metadata_js_1.findMetadata, | ||
findOrCreateMetadata: metadata_js_1.findOrCreateMetadata, | ||
isSingleton: isSingleton_js_1.isSingleton, | ||
@@ -44,0 +44,0 @@ Trace: Trace_js_1.Trace, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isSingleton = void 0; | ||
const findMetadata_js_1 = require("./findMetadata.js"); | ||
const metadata_js_1 = require("./metadata.js"); | ||
function isSingleton(constructor) { | ||
const modifiedConstructor = (0, findMetadata_js_1.findMetadata)(constructor)?.modifiedClass; | ||
const modifiedConstructor = (0, metadata_js_1.findMetadata)(constructor)?.modifiedClass; | ||
if (!modifiedConstructor) { | ||
@@ -14,5 +14,5 @@ return false; | ||
const implementationType = constructor; | ||
return (0, findMetadata_js_1.findMetadata)(implementationType)?.singleton === true; | ||
return (0, metadata_js_1.findMetadata)(implementationType)?.singleton === true; | ||
} | ||
exports.isSingleton = isSingleton; | ||
//# sourceMappingURL=isSingleton.js.map |
import { CircularDependencyError } from './CircularDependencyError.js'; | ||
import { findMetadata, findOrCreateMetadata } from './findMetadata.js'; | ||
import { findMetadata, findOrCreateMetadata } from './metadata.js'; | ||
import { isSingleton } from './isSingleton.js'; | ||
import { modifyConstructor } from './modifyConstructor.js'; | ||
import { Trace } from './Trace.js'; | ||
import { workWithDiSettings } from './workWithDiSettings.js'; | ||
class ContainerImpl { | ||
@@ -19,6 +17,4 @@ singletons; | ||
const inject = (...injectionParams) => { | ||
modifyConstructor(implementationType, (settings) => { | ||
const metadata = findOrCreateMetadata(settings); | ||
metadata.injected = injectionParams; | ||
}); | ||
const metadata = findOrCreateMetadata(implementationType); | ||
metadata.injected = injectionParams; | ||
}; | ||
@@ -43,7 +39,5 @@ this.dependencies.set(implementationType, implementationType); | ||
if (!isSingleton(implementationType)) { | ||
workWithDiSettings(implementationType, (settings) => { | ||
const metadata = findMetadata(settings); | ||
metadata.modifiedClass = implementationType; | ||
metadata.singleton = true; | ||
}); | ||
const metadata = findOrCreateMetadata(implementationType); | ||
metadata.modifiedClass = implementationType; | ||
metadata.singleton = true; | ||
} | ||
@@ -50,0 +44,0 @@ return { |
@@ -1,10 +0,5 @@ | ||
import { findMetadata } from '../findMetadata.js'; | ||
import { workWithDiSettings } from '../workWithDiSettings.js'; | ||
import { saveConstructorMetadata } from '../metadata.js'; | ||
export const inject = ((...dependencies) => { | ||
return (constructor) => { | ||
workWithDiSettings(constructor, (settings) => { | ||
const metadata = findMetadata(settings); | ||
metadata.modifiedClass = constructor; | ||
metadata.injectDependencies = dependencies; | ||
}); | ||
saveConstructorMetadata(constructor, ...dependencies); | ||
return constructor; | ||
@@ -11,0 +6,0 @@ }; |
@@ -5,3 +5,3 @@ export * from './cheapDiSymbol.js'; | ||
export * from './decorators/inject.js'; | ||
export * from './findMetadata.js'; | ||
export * from './metadata.js'; | ||
export * from './isSingleton.js'; | ||
@@ -14,3 +14,3 @@ export * from './Trace.js'; | ||
import { inject } from './decorators/inject.js'; | ||
import { findMetadata, findOrCreateMetadata } from './findMetadata.js'; | ||
import { findMetadata, findOrCreateMetadata } from './metadata.js'; | ||
import { isSingleton } from './isSingleton.js'; | ||
@@ -17,0 +17,0 @@ import { Trace } from './Trace.js'; |
@@ -1,2 +0,2 @@ | ||
import { findMetadata } from './findMetadata.js'; | ||
import { findMetadata } from './metadata.js'; | ||
export function isSingleton(constructor) { | ||
@@ -3,0 +3,0 @@ const modifiedConstructor = findMetadata(constructor)?.modifiedClass; |
@@ -5,3 +5,3 @@ export * from './cheapDiSymbol.js'; | ||
export * from './decorators/inject.js'; | ||
export * from './findMetadata.js'; | ||
export * from './metadata.js'; | ||
export * from './isSingleton.js'; | ||
@@ -12,3 +12,3 @@ export * from './Trace.js'; | ||
import { ContainerImpl } from './ContainerImpl.js'; | ||
import { findMetadata, findOrCreateMetadata } from './findMetadata.js'; | ||
import { findMetadata, findOrCreateMetadata } from './metadata.js'; | ||
import { isSingleton } from './isSingleton.js'; | ||
@@ -15,0 +15,0 @@ import { Trace } from './Trace.js'; |
@@ -7,7 +7,5 @@ import { cheapDiSymbol } from './cheapDiSymbol.js'; | ||
type ImplementationType<TClass> = Dependency<TClass> & { | ||
[cheapDiSymbol]: DiMetadata<TClass>; | ||
[cheapDiSymbol]: DiMetadata; | ||
}; | ||
interface DiMetadata<TClass> { | ||
/** reference on a constructor that was patched (helps in inheritance cases) */ | ||
patchedConstructor?: unknown; | ||
interface DiMetadata { | ||
singleton?: boolean; | ||
@@ -17,3 +15,4 @@ dependencies?: SomeDependency[]; | ||
injectDependencies?: SomeDependency[]; | ||
modifiedClass?: TClass; | ||
/** reference on a constructor that was patched (helps in inheritance cases) */ | ||
modifiedClass?: unknown; | ||
/** parameters are passed to container.registerImplementation(...).inject(parameter1, parameter2) */ | ||
@@ -20,0 +19,0 @@ injected?: unknown[]; |
{ | ||
"name": "cheap-di", | ||
"description": "TypeScript dependency injection like Autofac in .Net", | ||
"version": "4.0.0-rc-13", | ||
"version": "4.0.0-rc-14", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "compile": "tsc --build tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json", |
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
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
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
105527
49
956