@shellicar/core-di 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +6 -0
  2. package/dist/index.cjs +2 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +70 -0
  5. package/dist/index.d.mts +70 -0
  6. package/dist/index.mjs +2 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +29 -30
  9. package/dist/cjs/ServiceCollection.d.ts +0 -13
  10. package/dist/cjs/ServiceCollection.d.ts.map +0 -1
  11. package/dist/cjs/ServiceCollection.js +0 -64
  12. package/dist/cjs/ServiceCollection.js.map +0 -1
  13. package/dist/cjs/ServiceProvider.d.ts +0 -22
  14. package/dist/cjs/ServiceProvider.d.ts.map +0 -1
  15. package/dist/cjs/ServiceProvider.js +0 -138
  16. package/dist/cjs/ServiceProvider.js.map +0 -1
  17. package/dist/cjs/constants.d.ts +0 -8
  18. package/dist/cjs/constants.d.ts.map +0 -1
  19. package/dist/cjs/constants.js +0 -12
  20. package/dist/cjs/constants.js.map +0 -1
  21. package/dist/cjs/createServiceCollection.d.ts +0 -3
  22. package/dist/cjs/createServiceCollection.d.ts.map +0 -1
  23. package/dist/cjs/createServiceCollection.js +0 -7
  24. package/dist/cjs/createServiceCollection.js.map +0 -1
  25. package/dist/cjs/debug.d.ts +0 -4
  26. package/dist/cjs/debug.d.ts.map +0 -1
  27. package/dist/cjs/debug.js +0 -25
  28. package/dist/cjs/debug.js.map +0 -1
  29. package/dist/cjs/dependsOn.d.ts +0 -3
  30. package/dist/cjs/dependsOn.d.ts.map +0 -1
  31. package/dist/cjs/dependsOn.js +0 -24
  32. package/dist/cjs/dependsOn.js.map +0 -1
  33. package/dist/cjs/errors.d.ts +0 -11
  34. package/dist/cjs/errors.d.ts.map +0 -1
  35. package/dist/cjs/errors.js +0 -22
  36. package/dist/cjs/errors.js.map +0 -1
  37. package/dist/cjs/index.d.ts +0 -6
  38. package/dist/cjs/index.d.ts.map +0 -1
  39. package/dist/cjs/index.js +0 -17
  40. package/dist/cjs/index.js.map +0 -1
  41. package/dist/cjs/interfaces.d.ts +0 -22
  42. package/dist/cjs/interfaces.d.ts.map +0 -1
  43. package/dist/cjs/interfaces.js +0 -19
  44. package/dist/cjs/interfaces.js.map +0 -1
  45. package/dist/cjs/metadata.d.ts +0 -5
  46. package/dist/cjs/metadata.d.ts.map +0 -1
  47. package/dist/cjs/metadata.js +0 -23
  48. package/dist/cjs/metadata.js.map +0 -1
  49. package/dist/cjs/types.d.ts +0 -35
  50. package/dist/cjs/types.d.ts.map +0 -1
  51. package/dist/cjs/types.js +0 -3
  52. package/dist/cjs/types.js.map +0 -1
  53. package/dist/esm/ServiceCollection.d.ts +0 -13
  54. package/dist/esm/ServiceCollection.d.ts.map +0 -1
  55. package/dist/esm/ServiceCollection.js +0 -60
  56. package/dist/esm/ServiceCollection.js.map +0 -1
  57. package/dist/esm/ServiceProvider.d.ts +0 -22
  58. package/dist/esm/ServiceProvider.d.ts.map +0 -1
  59. package/dist/esm/ServiceProvider.js +0 -134
  60. package/dist/esm/ServiceProvider.js.map +0 -1
  61. package/dist/esm/constants.d.ts +0 -8
  62. package/dist/esm/constants.d.ts.map +0 -1
  63. package/dist/esm/constants.js +0 -9
  64. package/dist/esm/constants.js.map +0 -1
  65. package/dist/esm/createServiceCollection.d.ts +0 -3
  66. package/dist/esm/createServiceCollection.d.ts.map +0 -1
  67. package/dist/esm/createServiceCollection.js +0 -3
  68. package/dist/esm/createServiceCollection.js.map +0 -1
  69. package/dist/esm/debug.d.ts +0 -4
  70. package/dist/esm/debug.d.ts.map +0 -1
  71. package/dist/esm/debug.js +0 -22
  72. package/dist/esm/debug.js.map +0 -1
  73. package/dist/esm/dependsOn.d.ts +0 -3
  74. package/dist/esm/dependsOn.d.ts.map +0 -1
  75. package/dist/esm/dependsOn.js +0 -20
  76. package/dist/esm/dependsOn.js.map +0 -1
  77. package/dist/esm/errors.d.ts +0 -11
  78. package/dist/esm/errors.d.ts.map +0 -1
  79. package/dist/esm/errors.js +0 -16
  80. package/dist/esm/errors.js.map +0 -1
  81. package/dist/esm/index.d.ts +0 -6
  82. package/dist/esm/index.d.ts.map +0 -1
  83. package/dist/esm/index.js +0 -5
  84. package/dist/esm/index.js.map +0 -1
  85. package/dist/esm/interfaces.d.ts +0 -22
  86. package/dist/esm/interfaces.d.ts.map +0 -1
  87. package/dist/esm/interfaces.js +0 -11
  88. package/dist/esm/interfaces.js.map +0 -1
  89. package/dist/esm/metadata.d.ts +0 -5
  90. package/dist/esm/metadata.d.ts.map +0 -1
  91. package/dist/esm/metadata.js +0 -18
  92. package/dist/esm/metadata.js.map +0 -1
  93. package/dist/esm/types.d.ts +0 -35
  94. package/dist/esm/types.d.ts.map +0 -1
  95. package/dist/esm/types.js +0 -2
  96. package/dist/esm/types.js.map +0 -1
  97. package/dist/types/ServiceCollection.d.ts +0 -13
  98. package/dist/types/ServiceCollection.d.ts.map +0 -1
  99. package/dist/types/ServiceProvider.d.ts +0 -22
  100. package/dist/types/ServiceProvider.d.ts.map +0 -1
  101. package/dist/types/constants.d.ts +0 -8
  102. package/dist/types/constants.d.ts.map +0 -1
  103. package/dist/types/createServiceCollection.d.ts +0 -3
  104. package/dist/types/createServiceCollection.d.ts.map +0 -1
  105. package/dist/types/debug.d.ts +0 -4
  106. package/dist/types/debug.d.ts.map +0 -1
  107. package/dist/types/dependsOn.d.ts +0 -3
  108. package/dist/types/dependsOn.d.ts.map +0 -1
  109. package/dist/types/errors.d.ts +0 -11
  110. package/dist/types/errors.d.ts.map +0 -1
  111. package/dist/types/index.d.ts +0 -6
  112. package/dist/types/index.d.ts.map +0 -1
  113. package/dist/types/interfaces.d.ts +0 -22
  114. package/dist/types/interfaces.d.ts.map +0 -1
  115. package/dist/types/metadata.d.ts +0 -5
  116. package/dist/types/metadata.d.ts.map +0 -1
  117. package/dist/types/types.d.ts +0 -35
  118. package/dist/types/types.d.ts.map +0 -1
package/README.md CHANGED
@@ -59,6 +59,12 @@ const provider = services.buildProvider();
59
59
  using scope = provider.createScope();
60
60
  ```
61
61
 
62
+ * Register classes during a scope
63
+ ```ts
64
+ using scope = provider.createScope();
65
+ scope.Services.register(IContext).to(Context);
66
+ ```
67
+
62
68
  ## Usage
63
69
 
64
70
  Check the test files for different usage scenarios.
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var z=Object.defineProperty;var r=(n,e)=>z(n,"name",{value:e,configurable:!0});require("@abraham/reflection");var B=Object.defineProperty,C=r((n,e,t)=>e in n?B(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,"__defNormalProp$2"),H=r((n,e,t)=>C(n,e+"",t),"__publicField$2");const R=class R{constructor(){H(this,"debugging",!1)}enable(){this.debugging=!0}disable(){this.debugging=!1}log(e,...t){this.debugging&&console.log(e,...t)}};r(R,"DebugLogger");let m=R;const l=new m,b=l.log.bind(l),J=l.enable.bind(l),K=l.disable.bind(l);var a=(n=>(n.Resolve="RESOLVE",n.Transient="TRANSIENT",n.Scoped="SCOPED",n.Singleton="SINGLETON",n))(a||{});const q="design:dependencies",_=class _{};r(_,"IDisposable");let w=_;const x=class x{};r(x,"IServiceModule");let O=x;const A=class A{};r(A,"IServiceScope");let u=A;const F=class F extends u{};r(F,"IServiceProvider");let h=F;const D=class D{};r(D,"IServiceCollection");let S=D;const G=r((n,e)=>{if(Reflect.getMetadata===void 0)throw new Error('Please import "reflect-metadata"');const t=Reflect.getMetadata(n,e);if(t!==void 0)return t},"getMetadata"),Q=r((n,e,t)=>{if(Reflect.defineMetadata===void 0)throw new Error('Please import "reflect-metadata"');Reflect.defineMetadata(n,e,t)},"defineMetadata");var W=Object.defineProperty,X=r((n,e,t)=>e in n?W(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,"__defNormalProp$1"),P=r((n,e,t)=>X(n,e+"",t),"__publicField$1");const I=class I extends Error{constructor(e){super(`Resolving service that has not been registered: ${e}`),P(this,"name","UnregisteredServiceError"),Object.setPrototypeOf(this,new.target.prototype)}};r(I,"UnregisteredServiceError");let y=I;const T=class T extends Error{constructor(e){super(`Multiple services have been registered: ${e}`),P(this,"name","MultipleRegistrationError"),Object.setPrototypeOf(this,new.target.prototype)}};r(T,"MultipleRegistrationError");let M=T;const j=class j extends Error{constructor(){super("Service depending on itself"),P(this,"name","SelfDependencyError"),Object.setPrototypeOf(this,new.target.prototype)}};r(j,"SelfDependencyError");let E=j;var Y=Object.defineProperty,Z=r((n,e,t)=>e in n?Y(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,"__defNormalProp"),V=r((n,e,t)=>Z(n,typeof e!="symbol"?e+"":e,t),"__publicField");const g=r(()=>new Map,"createResolveMap"),f=class f{constructor(e,t=g()){this.services=e,this.singletons=t,V(this,"scoped",g()),V(this,"created",[])}get Services(){return this.services}[Symbol.dispose](){this.created.forEach(e=>e[Symbol.dispose]())}resolveFrom(e,t,s,o){let i=s.get(e);i===void 0&&(i=new Map,s.set(e,i));let c=i.get(t.implementation);return c===void 0&&(c=this.createInstance(t,o),i.set(t.implementation,c),this.setDependencies(t.implementation,c,o)),c}resolveInternal(e,t,s){const i={[a.Singleton]:this.singletons,[a.Scoped]:this.scoped,[a.Resolve]:s}[t.lifetime];if(i===void 0){const c=this.createInstance(t,s);return this.setDependencies(t.implementation,c,s),c}return this.resolveFrom(e,t,i,s)}resolveAll(e,t=g()){return this.services.get(e).map(o=>this.resolveInternal(e,o,t))}resolve(e,t=g()){if(e.prototype===u.prototype||e.prototype===h.prototype)return this;const s=this.services.get(e);if(s.length===0)throw new y(e);if(s.length>1)throw new M(e);const o=s[0];return this.resolveInternal(e,o,t)}createInstance(e,t){let s;if("factory"in e){const o=e.factory,i=r(p=>this.resolve(p,t),"resolve"),c=r(p=>this.resolveAll(p,t),"resolveAll"),d=this.createScope.bind(this);s=o({resolve:i,resolveAll:c,createScope:d,get Services(){return this.Services}})}else try{s=new e.implementation}catch(o){throw console.error(o,"Error creating service",{descriptor:e}),o}return e.lifetime!==a.Singleton&&Symbol.dispose in s&&this.created.push(s),s}createScope(){return new f(this.services.clone(),this.singletons)}setDependencies(e,t,s){var o;const i=(o=G(q,e))!=null?o:{};b("Dependencies",e.name,i);for(const[c,d]of Object.entries(i))if(d!==e){b("Resolving",d,"for",e.name);const p=this.resolve(d,s);t[c]=p}else throw new E;return t}};r(f,"ServiceProvider");let $=f;const v=class v{constructor(e=new Map){this.services=e}registerModules(e){e.forEach(t=>{new t().registerServices(this)})}get(e){var t;return(t=this.services.get(e))!=null?t:[]}register(e){return{to:r((t,s)=>{const o=s===void 0?{implementation:t,lifetime:a.Resolve}:{implementation:t,factory:s,lifetime:a.Resolve};this.addService(e,o);const i={singleton:r(()=>(o.lifetime=a.Singleton,i),"singleton"),scoped:r(()=>(o.lifetime=a.Scoped,i),"scoped"),transient:r(()=>(o.lifetime=a.Transient,i),"transient")};return i},"to")}}addService(e,t){b("Adding service",{identifier:e,descriptor:t});let s=this.services.get(e);s==null&&(s=[],this.services.set(e,s)),s.push(t)}clone(){const e=new Map;for(const[t,s]of this.services){const o=s.map(i=>({...i}));e.set(t,o)}return new v(e)}buildProvider(){const e=this.clone();return new $(e)}};r(v,"ServiceCollection");let N=v;const U=r(()=>new N,"createServiceCollection"),L=r((n,e,t,s)=>{let o=G(n,e);o===void 0&&(o={},Q(n,o,e)),o[t]=s},"tagProperty"),k=r(n=>(e,t)=>function(s){const o=this.constructor;return L(q,o,t.name,n),s},"dependsOn");exports.IDisposable=w,exports.IServiceCollection=S,exports.IServiceModule=O,exports.IServiceProvider=h,exports.IServiceScope=u,exports.createServiceCollection=U,exports.dependsOn=k,exports.disable=K,exports.enable=J;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/debug.ts","../src/constants.ts","../src/interfaces.ts","../src/metadata.ts","../src/errors.ts","../src/ServiceProvider.ts","../src/ServiceCollection.ts","../src/createServiceCollection.ts","../src/dependsOn.ts"],"sourcesContent":["\nclass DebugLogger {\n private debugging = false;\n\n public enable() { this.debugging = true; }\n public disable() { this.debugging = false; }\n public log(message?: string, ...optionalParams: unknown[]) {\n if(this.debugging) {\n console.log(message, ...optionalParams);\n }\n }\n}\n\nconst logger = new DebugLogger();\n\nexport const log = logger.log.bind(logger);\nexport const enable = logger.enable.bind(logger);\nexport const disable = logger.disable.bind(logger);\n","export enum Lifetime {\n Resolve = 'RESOLVE',\n Transient = 'TRANSIENT',\n Scoped = 'SCOPED',\n Singleton = 'SINGLETON',\n}\n\nexport const DesignDependenciesKey = 'design:dependencies';\n","import type { SourceType, ServiceBuilder, ServiceDescriptor, ServiceIdentifier, ServiceModuleType } from './types';\n\nexport abstract class IDisposable {\n public abstract [Symbol.dispose]: () => void;\n}\n\nexport abstract class IServiceModule {\n public abstract registerServices(services: IServiceCollection): void;\n}\n\nexport abstract class IServiceScope {\n public abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;\n public abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];\n}\n\nexport abstract class IServiceProvider extends IServiceScope {\n public abstract get Services(): IServiceCollection;\n public abstract createScope(): IServiceProvider & IDisposable;\n}\n\nexport abstract class IServiceCollection {\n public abstract get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[];\n public abstract register<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceBuilder<T>;\n public abstract registerModules(modules: ServiceModuleType[]): void;\n public abstract buildProvider(): IServiceProvider;\n public abstract clone(): IServiceCollection;\n}\n","import '@abraham/reflection';\nimport type { MetadataType, SourceType } from './types';\n\nexport const getMetadata = <T extends SourceType>(key: string, obj: object): MetadataType<T> | undefined => {\n if (Reflect.getMetadata === undefined) {\n throw new Error('Please import \"reflect-metadata\"');\n }\n const result = Reflect.getMetadata(key, obj);\n if (result === undefined) {\n return undefined;\n }\n return result as MetadataType<T>;\n};\n\nexport const defineMetadata = <T extends SourceType>(key: string, metadata: MetadataType<T>, obj: object) => {\n if (Reflect.defineMetadata === undefined) {\n throw new Error('Please import \"reflect-metadata\"');\n }\n Reflect.defineMetadata(key, metadata, obj);\n};\n","import type { ServiceIdentifier } from './types';\n\nexport class UnregisteredServiceError<T extends object> extends Error {\n name = 'UnregisteredServiceError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Resolving service that has not been registered: ${identifier}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class MultipleRegistrationError<T extends object> extends Error {\n name = 'MultipleRegistrationError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Multiple services have been registered: ${identifier}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class SelfDependencyError extends Error {\n name = 'SelfDependencyError';\n constructor() {\n super('Service depending on itself');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import { log } from './debug';\nimport { DesignDependenciesKey, Lifetime } from './constants';\nimport type { IDisposable, IServiceCollection} from './interfaces';\nimport { IServiceScope, IServiceProvider} from './interfaces';\nimport { getMetadata } from './metadata';\nimport type { ServiceIdentifier, ServiceDescriptor, ServiceImplementation, SourceType } from './types';\nimport { SelfDependencyError, MultipleRegistrationError, UnregisteredServiceError } from './errors';\n\ntype Id<T extends SourceType> = ServiceIdentifier<T> | ServiceImplementation<T>;\n\ntype ResolveMap<T extends SourceType> = Map<ServiceIdentifier<T>, Map<Id<T>, T>>;\n\nconst createResolveMap = <T extends SourceType>(): ResolveMap<T> => new Map<ServiceIdentifier<T>, Map<ServiceImplementation<T>, T>>();\n\nexport class ServiceProvider implements IServiceProvider, IServiceScope {\n private scoped = createResolveMap();\n private created: IDisposable[] = [];\n\n constructor(\n private services: IServiceCollection,\n private singletons = createResolveMap(),\n ) {}\n \n public get Services(): IServiceCollection {\n return this.services;\n }\n\n [Symbol.dispose]() {\n this.created.forEach(x => x[Symbol.dispose]());\n }\n\n private resolveFrom<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n descriptor: ServiceDescriptor<T>,\n lifetimeMap: ResolveMap<T>,\n currentResolve: ResolveMap<T>\n ): T {\n let resolvedInstances = lifetimeMap.get(identifier);\n if (resolvedInstances === undefined) {\n resolvedInstances = new Map();\n lifetimeMap.set(identifier, resolvedInstances);\n }\n\n let instance = resolvedInstances.get(descriptor.implementation);\n if (instance === undefined) {\n instance = this.createInstance(descriptor, currentResolve);\n resolvedInstances.set(descriptor.implementation, instance);\n this.setDependencies<T>(descriptor.implementation, instance, currentResolve);\n }\n return instance;\n }\n\n private resolveInternal<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n descriptor: ServiceDescriptor<T>,\n currentResolve: ResolveMap<T>,\n ): T {\n const mapping: Partial<Record<Lifetime, ResolveMap<any>>> = {\n [Lifetime.Singleton]: this.singletons,\n [Lifetime.Scoped]: this.scoped,\n [Lifetime.Resolve]: currentResolve,\n };\n const sourceMap = mapping[descriptor.lifetime];\n if (sourceMap === undefined) {\n const instance = this.createInstance(descriptor, currentResolve);\n this.setDependencies<T>(descriptor.implementation, instance, currentResolve);\n return instance;\n }\n return this.resolveFrom(identifier, descriptor, sourceMap, currentResolve);\n }\n\n public resolveAll<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n currentResolve = createResolveMap<T>(),\n ): T[] {\n const descriptors = this.services.get(identifier);\n return descriptors.map(descriptor => this.resolveInternal<T>(identifier, descriptor, currentResolve));\n }\n\n public resolve<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n currentResolve = createResolveMap<T>(),\n ): T {\n if (identifier.prototype === IServiceScope.prototype || identifier.prototype === IServiceProvider.prototype) {\n return this as unknown as T;\n }\n\n const descriptors = this.services.get(identifier);\n if (descriptors.length === 0) {\n throw new UnregisteredServiceError(identifier);\n }\n if (descriptors.length > 1) {\n throw new MultipleRegistrationError(identifier);\n }\n\n const descriptor = descriptors[0];\n return this.resolveInternal(identifier, descriptor, currentResolve);\n }\n\n private createInstance<T extends SourceType>(descriptor: ServiceDescriptor<T>, currentResolve: ResolveMap<T>): T {\n let instance: T;\n if ('factory' in descriptor) {\n const factory = descriptor.factory;\n const resolve = (identifier: ServiceIdentifier<any>) => this.resolve(identifier, currentResolve);\n const resolveAll = (identifier: ServiceIdentifier<any>) => this.resolveAll(identifier, currentResolve);\n const createScope = this.createScope.bind(this);\n\n // proxy requests to keep current resolved types\n instance = factory({\n resolve,\n resolveAll,\n createScope,\n get Services() { return this.Services; },\n });\n }\n else {\n try {\n instance = new descriptor.implementation();\n }\n catch (err) {\n console.error(err, 'Error creating service', {\n descriptor,\n });\n throw err;\n }\n }\n if (descriptor.lifetime !== Lifetime.Singleton && Symbol.dispose in instance) {\n this.created.push(instance as IDisposable);\n }\n return instance;\n }\n\n public createScope(): IServiceProvider & IDisposable {\n return new ServiceProvider(this.services.clone(), this.singletons);\n }\n\n private setDependencies<T extends SourceType>(\n type: Id<T>,\n instance: T,\n currentResolve: ResolveMap<T>,\n ): T {\n const dependencies = getMetadata<T>(DesignDependenciesKey, type) ?? {};\n log('Dependencies', type.name, dependencies);\n for (const [key, identifier] of Object.entries(dependencies)) {\n if (identifier !== type) {\n log('Resolving', identifier, 'for', type.name);\n const dep = this.resolve(identifier, currentResolve);\n (instance as Record<string, unknown>)[key] = dep;\n } else {\n throw new SelfDependencyError();\n }\n }\n return instance;\n }\n}\n","import { ServiceProvider } from './ServiceProvider';\nimport type { SourceType, InstanceFactory, ServiceBuilder, ServiceDescriptor, ServiceIdentifier, ServiceImplementation, Newable } from './types';\nimport type { IServiceCollection, IServiceModule, IServiceProvider } from './interfaces';\nimport { Lifetime } from './constants';\nimport { log } from './debug';\n\nexport class ServiceCollection implements IServiceCollection {\n constructor(private readonly services = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>()) {\n }\n \n public registerModules(modules: Newable<IServiceModule>[]): void {\n modules.forEach(x => {\n const module = new x();\n module.registerServices(this);\n });\n }\n\n get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[] {\n return this.services.get(key) ?? [];\n }\n\n register<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceBuilder<T> {\n return {\n // to: (implementation: ServiceImplementation<T>, func?: InstanceFactory<T>) => {\n to: (implementation: ServiceImplementation<T> | ServiceIdentifier<T>, factory?: InstanceFactory<T>) => {\n const descriptor: ServiceDescriptor<T>= (factory === undefined) ? { implementation: implementation as ServiceImplementation<T>, lifetime: Lifetime.Resolve } : { implementation, factory, lifetime: Lifetime.Resolve };\n this.addService(identifier, descriptor);\n const builder = {\n singleton: () => { descriptor.lifetime = Lifetime.Singleton; return builder; },\n scoped: () => { descriptor.lifetime = Lifetime.Scoped; return builder; },\n transient: () => { descriptor.lifetime = Lifetime.Transient; return builder; },\n };\n return builder;\n },\n };\n }\n\n private addService<T extends SourceType>(identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) {\n log('Adding service', { identifier, descriptor });\n let existing = this.services.get(identifier);\n if (existing == null) {\n existing = [];\n this.services.set(identifier, existing);\n }\n existing.push(descriptor);\n }\n\n public clone(): IServiceCollection {\n const clonedMap = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>();\n for (const [key, descriptors] of this.services) {\n const clonedDescriptors = descriptors.map(descriptor => ({ ...descriptor }));\n clonedMap.set(key, clonedDescriptors);\n }\n\n return new ServiceCollection(clonedMap);\n }\n\n public buildProvider(): IServiceProvider {\n const cloned = this.clone(); \n return new ServiceProvider(cloned);\n }\n}\n","import type { IServiceCollection } from './interfaces';\nimport { ServiceCollection } from './ServiceCollection';\n\nexport const createServiceCollection = (): IServiceCollection => new ServiceCollection() as IServiceCollection;\n","import { DesignDependenciesKey } from './constants';\nimport type { ServiceIdentifier, SourceType } from './types';\nimport { defineMetadata, getMetadata } from './metadata';\n\nconst tagProperty = <T extends SourceType>(metadataKey: string, annotationTarget: object, name: string | symbol, identifier: ServiceIdentifier<T>) => {\n let existing = getMetadata<T>(metadataKey, annotationTarget);\n if (existing === undefined) {\n existing = {};\n defineMetadata(metadataKey, existing, annotationTarget);\n }\n existing[name] = identifier;\n};\n\nexport const dependsOn = <T extends SourceType>(identifier: ServiceIdentifier<T>) => {\n return (value: undefined, ctx: ClassFieldDecoratorContext) => {\n return function (this: object, initialValue: any) {\n const target = this.constructor;\n tagProperty(DesignDependenciesKey, target, ctx.name, identifier);\n return initialValue;\n };\n };\n};\n"],"names":["__defProp","__defNormalProp","__publicField"],"mappings":";;;;AACA,IAAIA,WAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAIC,iBAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAGD,WAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAIE,eAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAKD,iBAAe,CAAC,GAAG,EAA4B,GAAG,GAAG,EAAE,CAAM,EAAE,KAAK,CAAC,CAAC;AAC/G,MAAM,WAAW,CAAC;AAClB,EAAE,WAAW,GAAG;AAChB,IAAIC,eAAa,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;AAC5C,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC1B,GAAG;AACH,EAAE,OAAO,GAAG;AACZ,IAAI,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;AAC3B,GAAG;AACH,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE;AAClC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;AACxB,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC;AAC9C,KAAK;AACL,GAAG;AACH,CAAC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<T> = abstract new (...args: any[]) => T;
10
+ type Newable<T> = new (...args: any[]) => T;
11
+ type ServiceIdentifier<T extends SourceType> = {
12
+ prototype: T;
13
+ name: string;
14
+ };
15
+ type ServiceImplementation<T extends SourceType> = Newable<T>;
16
+ type InstanceFactory<T extends SourceType> = (x: IServiceScope & IServiceProvider) => T;
17
+ type ServiceModuleType = Newable<IServiceModule>;
18
+ type ServiceDescriptorFactory<T extends SourceType> = {
19
+ implementation: ServiceIdentifier<T>;
20
+ factory: InstanceFactory<T>;
21
+ lifetime: Lifetime;
22
+ };
23
+ type ServiceDescriptorConcrete<T extends SourceType> = {
24
+ implementation: ServiceImplementation<T>;
25
+ lifetime: Lifetime;
26
+ };
27
+ type ServiceDescriptor<T extends SourceType> = ServiceDescriptorConcrete<T> | ServiceDescriptorFactory<T>;
28
+ type LifetimeBuilder = {
29
+ singleton: () => LifetimeBuilder;
30
+ scoped: () => LifetimeBuilder;
31
+ transient: () => LifetimeBuilder;
32
+ };
33
+ type ServiceBuilder<T extends SourceType> = {
34
+ to: {
35
+ (implementation: ServiceImplementation<T>): LifetimeBuilder;
36
+ (implementation: ServiceIdentifier<T>, factory: InstanceFactory<T>): LifetimeBuilder;
37
+ };
38
+ };
39
+ type MetadataType<T extends SourceType> = Record<string | symbol, ServiceIdentifier<T>>;
40
+
41
+ declare abstract class IDisposable {
42
+ abstract [Symbol.dispose]: () => void;
43
+ }
44
+ declare abstract class IServiceModule {
45
+ abstract registerServices(services: IServiceCollection): void;
46
+ }
47
+ declare abstract class IServiceScope {
48
+ abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;
49
+ abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];
50
+ }
51
+ declare abstract class IServiceProvider extends IServiceScope {
52
+ abstract get Services(): IServiceCollection;
53
+ abstract createScope(): IServiceProvider & IDisposable;
54
+ }
55
+ declare abstract class IServiceCollection {
56
+ abstract get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[];
57
+ abstract register<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceBuilder<T>;
58
+ abstract registerModules(modules: ServiceModuleType[]): void;
59
+ abstract buildProvider(): IServiceProvider;
60
+ abstract clone(): IServiceCollection;
61
+ }
62
+
63
+ declare const createServiceCollection: () => IServiceCollection;
64
+
65
+ declare const dependsOn: <T extends SourceType>(identifier: ServiceIdentifier<T>) => (value: undefined, ctx: ClassFieldDecoratorContext) => (this: object, initialValue: any) => any;
66
+
67
+ declare const enable: () => void;
68
+ declare const disable: () => void;
69
+
70
+ export { type AbstractNewable, IDisposable, IServiceCollection, IServiceModule, IServiceProvider, IServiceScope, type InstanceFactory, type LifetimeBuilder, type MetadataType, type Newable, type ServiceBuilder, type ServiceDescriptor, type ServiceDescriptorConcrete, type ServiceDescriptorFactory, type ServiceIdentifier, type ServiceImplementation, type ServiceModuleType, type SourceType, createServiceCollection, dependsOn, disable, enable };
@@ -0,0 +1,70 @@
1
+ declare enum Lifetime {
2
+ Resolve = "RESOLVE",
3
+ Transient = "TRANSIENT",
4
+ Scoped = "SCOPED",
5
+ Singleton = "SINGLETON"
6
+ }
7
+
8
+ type SourceType = object;
9
+ type AbstractNewable<T> = abstract new (...args: any[]) => T;
10
+ type Newable<T> = new (...args: any[]) => T;
11
+ type ServiceIdentifier<T extends SourceType> = {
12
+ prototype: T;
13
+ name: string;
14
+ };
15
+ type ServiceImplementation<T extends SourceType> = Newable<T>;
16
+ type InstanceFactory<T extends SourceType> = (x: IServiceScope & IServiceProvider) => T;
17
+ type ServiceModuleType = Newable<IServiceModule>;
18
+ type ServiceDescriptorFactory<T extends SourceType> = {
19
+ implementation: ServiceIdentifier<T>;
20
+ factory: InstanceFactory<T>;
21
+ lifetime: Lifetime;
22
+ };
23
+ type ServiceDescriptorConcrete<T extends SourceType> = {
24
+ implementation: ServiceImplementation<T>;
25
+ lifetime: Lifetime;
26
+ };
27
+ type ServiceDescriptor<T extends SourceType> = ServiceDescriptorConcrete<T> | ServiceDescriptorFactory<T>;
28
+ type LifetimeBuilder = {
29
+ singleton: () => LifetimeBuilder;
30
+ scoped: () => LifetimeBuilder;
31
+ transient: () => LifetimeBuilder;
32
+ };
33
+ type ServiceBuilder<T extends SourceType> = {
34
+ to: {
35
+ (implementation: ServiceImplementation<T>): LifetimeBuilder;
36
+ (implementation: ServiceIdentifier<T>, factory: InstanceFactory<T>): LifetimeBuilder;
37
+ };
38
+ };
39
+ type MetadataType<T extends SourceType> = Record<string | symbol, ServiceIdentifier<T>>;
40
+
41
+ declare abstract class IDisposable {
42
+ abstract [Symbol.dispose]: () => void;
43
+ }
44
+ declare abstract class IServiceModule {
45
+ abstract registerServices(services: IServiceCollection): void;
46
+ }
47
+ declare abstract class IServiceScope {
48
+ abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;
49
+ abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];
50
+ }
51
+ declare abstract class IServiceProvider extends IServiceScope {
52
+ abstract get Services(): IServiceCollection;
53
+ abstract createScope(): IServiceProvider & IDisposable;
54
+ }
55
+ declare abstract class IServiceCollection {
56
+ abstract get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[];
57
+ abstract register<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceBuilder<T>;
58
+ abstract registerModules(modules: ServiceModuleType[]): void;
59
+ abstract buildProvider(): IServiceProvider;
60
+ abstract clone(): IServiceCollection;
61
+ }
62
+
63
+ declare const createServiceCollection: () => IServiceCollection;
64
+
65
+ declare const dependsOn: <T extends SourceType>(identifier: ServiceIdentifier<T>) => (value: undefined, ctx: ClassFieldDecoratorContext) => (this: object, initialValue: any) => any;
66
+
67
+ declare const enable: () => void;
68
+ declare const disable: () => void;
69
+
70
+ export { type AbstractNewable, IDisposable, IServiceCollection, IServiceModule, IServiceProvider, IServiceScope, type InstanceFactory, type LifetimeBuilder, type MetadataType, type Newable, type ServiceBuilder, type ServiceDescriptor, type ServiceDescriptorConcrete, type ServiceDescriptorFactory, type ServiceIdentifier, type ServiceImplementation, type ServiceModuleType, type SourceType, createServiceCollection, dependsOn, disable, enable };
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ var B=Object.defineProperty;var r=(n,e)=>B(n,"name",{value:e,configurable:!0});import"@abraham/reflection";var H=Object.defineProperty,J=r((n,e,t)=>e in n?H(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,"__defNormalProp$2"),K=r((n,e,t)=>J(n,e+"",t),"__publicField$2");const N=class N{constructor(){K(this,"debugging",!1)}enable(){this.debugging=!0}disable(){this.debugging=!1}log(e,...t){this.debugging&&console.log(e,...t)}};r(N,"DebugLogger");let m=N;const l=new m,b=l.log.bind(l),Q=l.enable.bind(l),W=l.disable.bind(l);var a=(n=>(n.Resolve="RESOLVE",n.Transient="TRANSIENT",n.Scoped="SCOPED",n.Singleton="SINGLETON",n))(a||{});const V="design:dependencies",R=class R{};r(R,"IDisposable");let w=R;const _=class _{};r(_,"IServiceModule");let O=_;const A=class A{};r(A,"IServiceScope");let h=A;const F=class F extends h{};r(F,"IServiceProvider");let u=F;const T=class T{};r(T,"IServiceCollection");let P=T;const q=r((n,e)=>{if(Reflect.getMetadata===void 0)throw new Error('Please import "reflect-metadata"');const t=Reflect.getMetadata(n,e);if(t!==void 0)return t},"getMetadata"),X=r((n,e,t)=>{if(Reflect.defineMetadata===void 0)throw new Error('Please import "reflect-metadata"');Reflect.defineMetadata(n,e,t)},"defineMetadata");var Y=Object.defineProperty,Z=r((n,e,t)=>e in n?Y(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,"__defNormalProp$1"),y=r((n,e,t)=>Z(n,e+"",t),"__publicField$1");const D=class D extends Error{constructor(e){super(`Resolving service that has not been registered: ${e}`),y(this,"name","UnregisteredServiceError"),Object.setPrototypeOf(this,new.target.prototype)}};r(D,"UnregisteredServiceError");let M=D;const j=class j extends Error{constructor(e){super(`Multiple services have been registered: ${e}`),y(this,"name","MultipleRegistrationError"),Object.setPrototypeOf(this,new.target.prototype)}};r(j,"MultipleRegistrationError");let E=j;const G=class G extends Error{constructor(){super("Service depending on itself"),y(this,"name","SelfDependencyError"),Object.setPrototypeOf(this,new.target.prototype)}};r(G,"SelfDependencyError");let S=G;var I=Object.defineProperty,U=r((n,e,t)=>e in n?I(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,"__defNormalProp"),z=r((n,e,t)=>U(n,typeof e!="symbol"?e+"":e,t),"__publicField");const g=r(()=>new Map,"createResolveMap"),f=class f{constructor(e,t=g()){this.services=e,this.singletons=t,z(this,"scoped",g()),z(this,"created",[])}get Services(){return this.services}[Symbol.dispose](){this.created.forEach(e=>e[Symbol.dispose]())}resolveFrom(e,t,s,o){let i=s.get(e);i===void 0&&(i=new Map,s.set(e,i));let c=i.get(t.implementation);return c===void 0&&(c=this.createInstance(t,o),i.set(t.implementation,c),this.setDependencies(t.implementation,c,o)),c}resolveInternal(e,t,s){const i={[a.Singleton]:this.singletons,[a.Scoped]:this.scoped,[a.Resolve]:s}[t.lifetime];if(i===void 0){const c=this.createInstance(t,s);return this.setDependencies(t.implementation,c,s),c}return this.resolveFrom(e,t,i,s)}resolveAll(e,t=g()){return this.services.get(e).map(o=>this.resolveInternal(e,o,t))}resolve(e,t=g()){if(e.prototype===h.prototype||e.prototype===u.prototype)return this;const s=this.services.get(e);if(s.length===0)throw new M(e);if(s.length>1)throw new E(e);const o=s[0];return this.resolveInternal(e,o,t)}createInstance(e,t){let s;if("factory"in e){const o=e.factory,i=r(p=>this.resolve(p,t),"resolve"),c=r(p=>this.resolveAll(p,t),"resolveAll"),d=this.createScope.bind(this);s=o({resolve:i,resolveAll:c,createScope:d,get Services(){return this.Services}})}else try{s=new e.implementation}catch(o){throw console.error(o,"Error creating service",{descriptor:e}),o}return e.lifetime!==a.Singleton&&Symbol.dispose in s&&this.created.push(s),s}createScope(){return new f(this.services.clone(),this.singletons)}setDependencies(e,t,s){var o;const i=(o=q(V,e))!=null?o:{};b("Dependencies",e.name,i);for(const[c,d]of Object.entries(i))if(d!==e){b("Resolving",d,"for",e.name);const p=this.resolve(d,s);t[c]=p}else throw new S;return t}};r(f,"ServiceProvider");let $=f;const v=class v{constructor(e=new Map){this.services=e}registerModules(e){e.forEach(t=>{new t().registerServices(this)})}get(e){var t;return(t=this.services.get(e))!=null?t:[]}register(e){return{to:r((t,s)=>{const o=s===void 0?{implementation:t,lifetime:a.Resolve}:{implementation:t,factory:s,lifetime:a.Resolve};this.addService(e,o);const i={singleton:r(()=>(o.lifetime=a.Singleton,i),"singleton"),scoped:r(()=>(o.lifetime=a.Scoped,i),"scoped"),transient:r(()=>(o.lifetime=a.Transient,i),"transient")};return i},"to")}}addService(e,t){b("Adding service",{identifier:e,descriptor:t});let s=this.services.get(e);s==null&&(s=[],this.services.set(e,s)),s.push(t)}clone(){const e=new Map;for(const[t,s]of this.services){const o=s.map(i=>({...i}));e.set(t,o)}return new v(e)}buildProvider(){const e=this.clone();return new $(e)}};r(v,"ServiceCollection");let x=v;const C=r(()=>new x,"createServiceCollection"),L=r((n,e,t,s)=>{let o=q(n,e);o===void 0&&(o={},X(n,o,e)),o[t]=s},"tagProperty"),k=r(n=>(e,t)=>function(s){const o=this.constructor;return L(V,o,t.name,n),s},"dependsOn");export{w as IDisposable,P as IServiceCollection,O as IServiceModule,u as IServiceProvider,h as IServiceScope,C as createServiceCollection,k as dependsOn,W as disable,Q as enable};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/debug.ts","../src/constants.ts","../src/interfaces.ts","../src/metadata.ts","../src/errors.ts","../src/ServiceProvider.ts","../src/ServiceCollection.ts","../src/createServiceCollection.ts","../src/dependsOn.ts"],"sourcesContent":["\nclass DebugLogger {\n private debugging = false;\n\n public enable() { this.debugging = true; }\n public disable() { this.debugging = false; }\n public log(message?: string, ...optionalParams: unknown[]) {\n if(this.debugging) {\n console.log(message, ...optionalParams);\n }\n }\n}\n\nconst logger = new DebugLogger();\n\nexport const log = logger.log.bind(logger);\nexport const enable = logger.enable.bind(logger);\nexport const disable = logger.disable.bind(logger);\n","export enum Lifetime {\n Resolve = 'RESOLVE',\n Transient = 'TRANSIENT',\n Scoped = 'SCOPED',\n Singleton = 'SINGLETON',\n}\n\nexport const DesignDependenciesKey = 'design:dependencies';\n","import type { SourceType, ServiceBuilder, ServiceDescriptor, ServiceIdentifier, ServiceModuleType } from './types';\n\nexport abstract class IDisposable {\n public abstract [Symbol.dispose]: () => void;\n}\n\nexport abstract class IServiceModule {\n public abstract registerServices(services: IServiceCollection): void;\n}\n\nexport abstract class IServiceScope {\n public abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;\n public abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];\n}\n\nexport abstract class IServiceProvider extends IServiceScope {\n public abstract get Services(): IServiceCollection;\n public abstract createScope(): IServiceProvider & IDisposable;\n}\n\nexport abstract class IServiceCollection {\n public abstract get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[];\n public abstract register<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceBuilder<T>;\n public abstract registerModules(modules: ServiceModuleType[]): void;\n public abstract buildProvider(): IServiceProvider;\n public abstract clone(): IServiceCollection;\n}\n","import '@abraham/reflection';\nimport type { MetadataType, SourceType } from './types';\n\nexport const getMetadata = <T extends SourceType>(key: string, obj: object): MetadataType<T> | undefined => {\n if (Reflect.getMetadata === undefined) {\n throw new Error('Please import \"reflect-metadata\"');\n }\n const result = Reflect.getMetadata(key, obj);\n if (result === undefined) {\n return undefined;\n }\n return result as MetadataType<T>;\n};\n\nexport const defineMetadata = <T extends SourceType>(key: string, metadata: MetadataType<T>, obj: object) => {\n if (Reflect.defineMetadata === undefined) {\n throw new Error('Please import \"reflect-metadata\"');\n }\n Reflect.defineMetadata(key, metadata, obj);\n};\n","import type { ServiceIdentifier } from './types';\n\nexport class UnregisteredServiceError<T extends object> extends Error {\n name = 'UnregisteredServiceError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Resolving service that has not been registered: ${identifier}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class MultipleRegistrationError<T extends object> extends Error {\n name = 'MultipleRegistrationError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Multiple services have been registered: ${identifier}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class SelfDependencyError extends Error {\n name = 'SelfDependencyError';\n constructor() {\n super('Service depending on itself');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import { log } from './debug';\nimport { DesignDependenciesKey, Lifetime } from './constants';\nimport type { IDisposable, IServiceCollection} from './interfaces';\nimport { IServiceScope, IServiceProvider} from './interfaces';\nimport { getMetadata } from './metadata';\nimport type { ServiceIdentifier, ServiceDescriptor, ServiceImplementation, SourceType } from './types';\nimport { SelfDependencyError, MultipleRegistrationError, UnregisteredServiceError } from './errors';\n\ntype Id<T extends SourceType> = ServiceIdentifier<T> | ServiceImplementation<T>;\n\ntype ResolveMap<T extends SourceType> = Map<ServiceIdentifier<T>, Map<Id<T>, T>>;\n\nconst createResolveMap = <T extends SourceType>(): ResolveMap<T> => new Map<ServiceIdentifier<T>, Map<ServiceImplementation<T>, T>>();\n\nexport class ServiceProvider implements IServiceProvider, IServiceScope {\n private scoped = createResolveMap();\n private created: IDisposable[] = [];\n\n constructor(\n private services: IServiceCollection,\n private singletons = createResolveMap(),\n ) {}\n \n public get Services(): IServiceCollection {\n return this.services;\n }\n\n [Symbol.dispose]() {\n this.created.forEach(x => x[Symbol.dispose]());\n }\n\n private resolveFrom<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n descriptor: ServiceDescriptor<T>,\n lifetimeMap: ResolveMap<T>,\n currentResolve: ResolveMap<T>\n ): T {\n let resolvedInstances = lifetimeMap.get(identifier);\n if (resolvedInstances === undefined) {\n resolvedInstances = new Map();\n lifetimeMap.set(identifier, resolvedInstances);\n }\n\n let instance = resolvedInstances.get(descriptor.implementation);\n if (instance === undefined) {\n instance = this.createInstance(descriptor, currentResolve);\n resolvedInstances.set(descriptor.implementation, instance);\n this.setDependencies<T>(descriptor.implementation, instance, currentResolve);\n }\n return instance;\n }\n\n private resolveInternal<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n descriptor: ServiceDescriptor<T>,\n currentResolve: ResolveMap<T>,\n ): T {\n const mapping: Partial<Record<Lifetime, ResolveMap<any>>> = {\n [Lifetime.Singleton]: this.singletons,\n [Lifetime.Scoped]: this.scoped,\n [Lifetime.Resolve]: currentResolve,\n };\n const sourceMap = mapping[descriptor.lifetime];\n if (sourceMap === undefined) {\n const instance = this.createInstance(descriptor, currentResolve);\n this.setDependencies<T>(descriptor.implementation, instance, currentResolve);\n return instance;\n }\n return this.resolveFrom(identifier, descriptor, sourceMap, currentResolve);\n }\n\n public resolveAll<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n currentResolve = createResolveMap<T>(),\n ): T[] {\n const descriptors = this.services.get(identifier);\n return descriptors.map(descriptor => this.resolveInternal<T>(identifier, descriptor, currentResolve));\n }\n\n public resolve<T extends SourceType>(\n identifier: ServiceIdentifier<T>,\n currentResolve = createResolveMap<T>(),\n ): T {\n if (identifier.prototype === IServiceScope.prototype || identifier.prototype === IServiceProvider.prototype) {\n return this as unknown as T;\n }\n\n const descriptors = this.services.get(identifier);\n if (descriptors.length === 0) {\n throw new UnregisteredServiceError(identifier);\n }\n if (descriptors.length > 1) {\n throw new MultipleRegistrationError(identifier);\n }\n\n const descriptor = descriptors[0];\n return this.resolveInternal(identifier, descriptor, currentResolve);\n }\n\n private createInstance<T extends SourceType>(descriptor: ServiceDescriptor<T>, currentResolve: ResolveMap<T>): T {\n let instance: T;\n if ('factory' in descriptor) {\n const factory = descriptor.factory;\n const resolve = (identifier: ServiceIdentifier<any>) => this.resolve(identifier, currentResolve);\n const resolveAll = (identifier: ServiceIdentifier<any>) => this.resolveAll(identifier, currentResolve);\n const createScope = this.createScope.bind(this);\n\n // proxy requests to keep current resolved types\n instance = factory({\n resolve,\n resolveAll,\n createScope,\n get Services() { return this.Services; },\n });\n }\n else {\n try {\n instance = new descriptor.implementation();\n }\n catch (err) {\n console.error(err, 'Error creating service', {\n descriptor,\n });\n throw err;\n }\n }\n if (descriptor.lifetime !== Lifetime.Singleton && Symbol.dispose in instance) {\n this.created.push(instance as IDisposable);\n }\n return instance;\n }\n\n public createScope(): IServiceProvider & IDisposable {\n return new ServiceProvider(this.services.clone(), this.singletons);\n }\n\n private setDependencies<T extends SourceType>(\n type: Id<T>,\n instance: T,\n currentResolve: ResolveMap<T>,\n ): T {\n const dependencies = getMetadata<T>(DesignDependenciesKey, type) ?? {};\n log('Dependencies', type.name, dependencies);\n for (const [key, identifier] of Object.entries(dependencies)) {\n if (identifier !== type) {\n log('Resolving', identifier, 'for', type.name);\n const dep = this.resolve(identifier, currentResolve);\n (instance as Record<string, unknown>)[key] = dep;\n } else {\n throw new SelfDependencyError();\n }\n }\n return instance;\n }\n}\n","import { ServiceProvider } from './ServiceProvider';\nimport type { SourceType, InstanceFactory, ServiceBuilder, ServiceDescriptor, ServiceIdentifier, ServiceImplementation, Newable } from './types';\nimport type { IServiceCollection, IServiceModule, IServiceProvider } from './interfaces';\nimport { Lifetime } from './constants';\nimport { log } from './debug';\n\nexport class ServiceCollection implements IServiceCollection {\n constructor(private readonly services = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>()) {\n }\n \n public registerModules(modules: Newable<IServiceModule>[]): void {\n modules.forEach(x => {\n const module = new x();\n module.registerServices(this);\n });\n }\n\n get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[] {\n return this.services.get(key) ?? [];\n }\n\n register<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceBuilder<T> {\n return {\n // to: (implementation: ServiceImplementation<T>, func?: InstanceFactory<T>) => {\n to: (implementation: ServiceImplementation<T> | ServiceIdentifier<T>, factory?: InstanceFactory<T>) => {\n const descriptor: ServiceDescriptor<T>= (factory === undefined) ? { implementation: implementation as ServiceImplementation<T>, lifetime: Lifetime.Resolve } : { implementation, factory, lifetime: Lifetime.Resolve };\n this.addService(identifier, descriptor);\n const builder = {\n singleton: () => { descriptor.lifetime = Lifetime.Singleton; return builder; },\n scoped: () => { descriptor.lifetime = Lifetime.Scoped; return builder; },\n transient: () => { descriptor.lifetime = Lifetime.Transient; return builder; },\n };\n return builder;\n },\n };\n }\n\n private addService<T extends SourceType>(identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) {\n log('Adding service', { identifier, descriptor });\n let existing = this.services.get(identifier);\n if (existing == null) {\n existing = [];\n this.services.set(identifier, existing);\n }\n existing.push(descriptor);\n }\n\n public clone(): IServiceCollection {\n const clonedMap = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>();\n for (const [key, descriptors] of this.services) {\n const clonedDescriptors = descriptors.map(descriptor => ({ ...descriptor }));\n clonedMap.set(key, clonedDescriptors);\n }\n\n return new ServiceCollection(clonedMap);\n }\n\n public buildProvider(): IServiceProvider {\n const cloned = this.clone(); \n return new ServiceProvider(cloned);\n }\n}\n","import type { IServiceCollection } from './interfaces';\nimport { ServiceCollection } from './ServiceCollection';\n\nexport const createServiceCollection = (): IServiceCollection => new ServiceCollection() as IServiceCollection;\n","import { DesignDependenciesKey } from './constants';\nimport type { ServiceIdentifier, SourceType } from './types';\nimport { defineMetadata, getMetadata } from './metadata';\n\nconst tagProperty = <T extends SourceType>(metadataKey: string, annotationTarget: object, name: string | symbol, identifier: ServiceIdentifier<T>) => {\n let existing = getMetadata<T>(metadataKey, annotationTarget);\n if (existing === undefined) {\n existing = {};\n defineMetadata(metadataKey, existing, annotationTarget);\n }\n existing[name] = identifier;\n};\n\nexport const dependsOn = <T extends SourceType>(identifier: ServiceIdentifier<T>) => {\n return (value: undefined, ctx: ClassFieldDecoratorContext) => {\n return function (this: object, initialValue: any) {\n const target = this.constructor;\n tagProperty(DesignDependenci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C,IAAI,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;AACvC,GAAG;AACH;;AC7DY,MAAC,uBAAuB,GAAG,MAAM,IAAI,iBAAiB;;ACClE,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,KAAK;AACzE,EAAE,IAAI,QAAQ,GAAG,WAAW,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAC5D,EAAE,IAAI,QAAQ,KAAK,KAAK,CAAC,EAAE;AAC3B,IAAI,QAAQ,GAAG,EAAE,CAAC;AAClB,IAAI,cAAc,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAC5D,GAAG;AACH,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;AAC9B,CAAC,CAAC;AACU,MAAC,SAAS,GAAG,CAAC,UAAU,KAAK;AACzC,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,KAAK;AACzB,IAAI,OAAO,SAAS,YAAY,EAAE;AAClC,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;AACtC,MAAM,WAAW,CAAC,qBAAqB,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AACvE,MAAM,OAAO,YAAY,CAAC;AAC1B,KAAK,CAAC;AACN,GAAG,CAAC;AACJ;;;;"}
package/package.json CHANGED
@@ -1,37 +1,28 @@
1
1
  {
2
2
  "name": "@shellicar/core-di",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A basic dependency injection library",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/shellicar/core-di.git"
8
8
  },
9
9
  "private": false,
10
- "packageManager": "pnpm@9.9.0",
11
- "main": "./dist/cjs/index.js",
12
- "module": "./dist/esm/index.js",
13
- "types": "./dist/types/index.d.ts",
10
+ "main": "./dist/index.cjs",
11
+ "module": "./dist/index.mjs",
12
+ "types": "./dist/index.d.cts",
14
13
  "exports": {
15
- ".": {
16
- "import": "./dist/esm/index.js",
17
- "require": "./dist/cjs/index.js",
18
- "types": "./dist/types/index.d.ts"
14
+ "require": {
15
+ "types": "./dist/index.d.cts",
16
+ "default": "./dist/index.cjs"
17
+ },
18
+ "import": {
19
+ "types": "./dist/index.d.mts",
20
+ "default": "./dist/index.mjs"
19
21
  }
20
22
  },
21
23
  "files": [
22
24
  "dist"
23
25
  ],
24
- "scripts": {
25
- "clean": "rimraf dist",
26
- "build": "run-p build:esm build:cjs build:types",
27
- "build:esm": "tsc -p tsconfig.esm.json",
28
- "build:cjs": "tsc -p tsconfig.cjs.json",
29
- "build:types": "tsc -p tsconfig.types.json",
30
- "check": "tsc --noEmit --composite false --skipLibCheck",
31
- "test": "mocha",
32
- "lint": "eslint .",
33
- "prepublishOnly": "run-s clean build"
34
- },
35
26
  "keywords": [
36
27
  "dependency injection",
37
28
  "di",
@@ -45,22 +36,30 @@
45
36
  },
46
37
  "homepage": "https://github.com/shellicar/core-di#readme",
47
38
  "devDependencies": {
48
- "@stylistic/eslint-plugin": "^2.6.4",
49
- "@types/mocha": "^10.0.7",
50
- "@types/node": "^20.14.15",
51
- "@typescript-eslint/parser": "^8.3.0",
52
- "eslint": "^9.9.0",
39
+ "@stylistic/eslint-plugin": "^2.8.0",
40
+ "@types/mocha": "^10.0.8",
41
+ "@types/node": "^22.5.5",
42
+ "@typescript-eslint/parser": "^8.5.0",
43
+ "eslint": "^9.10.0",
53
44
  "eslint-plugin-prefer-arrow-functions": "^3.4.1",
54
- "eslint-plugin-turbo": "^2.1.1",
45
+ "eslint-plugin-turbo": "^2.1.2",
55
46
  "eslint-plugin-unicorn": "^55.0.0",
56
47
  "mocha": "^10.7.3",
57
- "npm-run-all2": "^6.2.2",
48
+ "npm-run-all2": "^6.2.3",
49
+ "pkgroll": "^2.5.0",
58
50
  "rimraf": "^6.0.1",
59
- "tsx": "^4.19.0",
60
- "typescript": "^5.5.4",
61
- "typescript-eslint": "^8.3.0"
51
+ "tsx": "^4.19.1",
52
+ "typescript": "^5.6.2",
53
+ "typescript-eslint": "^8.5.0"
62
54
  },
63
55
  "dependencies": {
64
56
  "@abraham/reflection": "^0.12.0"
57
+ },
58
+ "scripts": {
59
+ "clean": "rimraf dist",
60
+ "build": "pkgroll --minify --sourcemap --clean-dist",
61
+ "check": "tsc --noEmit --composite false --skipLibCheck",
62
+ "test": "mocha",
63
+ "lint": "eslint ."
65
64
  }
66
65
  }
@@ -1,13 +0,0 @@
1
- import type { SourceType, ServiceBuilder, ServiceDescriptor, ServiceIdentifier, Newable } from './types';
2
- import type { IServiceCollection, IServiceModule, IServiceProvider } from './interfaces';
3
- export declare class ServiceCollection implements IServiceCollection {
4
- private readonly services;
5
- constructor(services?: Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>);
6
- registerModules(modules: Newable<IServiceModule>[]): void;
7
- get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[];
8
- register<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceBuilder<T>;
9
- private addService;
10
- clone(): IServiceCollection;
11
- buildProvider(): IServiceProvider;
12
- }
13
- //# sourceMappingURL=ServiceCollection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ServiceCollection.d.ts","sourceRoot":"","sources":["../../src/ServiceCollection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAmB,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAyB,OAAO,EAAE,MAAM,SAAS,CAAC;AACjJ,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIzF,qBAAa,iBAAkB,YAAW,kBAAkB;IAC9C,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,wDAA8D;IAG5F,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI;IAOhE,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,EAAE;IAI5E,QAAQ,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC;IAgBnF,OAAO,CAAC,UAAU;IAUX,KAAK,IAAI,kBAAkB;IAU3B,aAAa,IAAI,gBAAgB;CAIzC"}
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServiceCollection = void 0;
4
- const ServiceProvider_1 = require("./ServiceProvider");
5
- const constants_1 = require("./constants");
6
- const debug_1 = require("./debug");
7
- class ServiceCollection {
8
- constructor(services = new Map()) {
9
- Object.defineProperty(this, "services", {
10
- enumerable: true,
11
- configurable: true,
12
- writable: true,
13
- value: services
14
- });
15
- }
16
- registerModules(modules) {
17
- modules.forEach(x => {
18
- const module = new x();
19
- module.registerServices(this);
20
- });
21
- }
22
- get(key) {
23
- var _a;
24
- return (_a = this.services.get(key)) !== null && _a !== void 0 ? _a : [];
25
- }
26
- register(identifier) {
27
- return {
28
- // to: (implementation: ServiceImplementation<T>, func?: InstanceFactory<T>) => {
29
- to: (implementation, factory) => {
30
- const descriptor = (factory === undefined) ? { implementation: implementation, lifetime: constants_1.Lifetime.Resolve } : { implementation, factory, lifetime: constants_1.Lifetime.Resolve };
31
- this.addService(identifier, descriptor);
32
- const builder = {
33
- singleton: () => { descriptor.lifetime = constants_1.Lifetime.Singleton; return builder; },
34
- scoped: () => { descriptor.lifetime = constants_1.Lifetime.Scoped; return builder; },
35
- transient: () => { descriptor.lifetime = constants_1.Lifetime.Transient; return builder; },
36
- };
37
- return builder;
38
- },
39
- };
40
- }
41
- addService(identifier, descriptor) {
42
- (0, debug_1.log)('Adding service', { identifier, descriptor });
43
- let existing = this.services.get(identifier);
44
- if (existing == null) {
45
- existing = [];
46
- this.services.set(identifier, existing);
47
- }
48
- existing.push(descriptor);
49
- }
50
- clone() {
51
- const clonedMap = new Map();
52
- for (const [key, descriptors] of this.services) {
53
- const clonedDescriptors = descriptors.map(descriptor => ({ ...descriptor }));
54
- clonedMap.set(key, clonedDescriptors);
55
- }
56
- return new ServiceCollection(clonedMap);
57
- }
58
- buildProvider() {
59
- const cloned = this.clone();
60
- return new ServiceProvider_1.ServiceProvider(cloned);
61
- }
62
- }
63
- exports.ServiceCollection = ServiceCollection;
64
- //# sourceMappingURL=ServiceCollection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ServiceCollection.js","sourceRoot":"","sources":["../../src/ServiceCollection.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAGpD,2CAAuC;AACvC,mCAA8B;AAE9B,MAAa,iBAAiB;IAC5B,YAA6B,WAAW,IAAI,GAAG,EAAoD;QAAvF;;;;mBAAiB,QAAQ;WAA8D;IACnG,CAAC;IAEM,eAAe,CAAC,OAAkC;QACvD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAClB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAuB,GAAyB;;QACjD,OAAO,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;IACtC,CAAC;IAED,QAAQ,CAAuB,UAAgC;QAC7D,OAAO;YACL,iFAAiF;YACjF,EAAE,EAAE,CAAC,cAA+D,EAAE,OAA4B,EAAE,EAAE;gBACpG,MAAM,UAAU,GAAwB,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,cAA0C,EAAE,QAAQ,EAAE,oBAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE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G,UAAU,EAAE,CAAC,CAAC,CAAC;YAC7E,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAEM,aAAa;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5B,OAAO,IAAI,iCAAe,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACF;AAvDD,8CAuDC"}
@@ -1,22 +0,0 @@
1
- import type { IServiceProvider, IDisposable, IServiceCollection } from './interfaces';
2
- import { IServiceScope } from './interfaces';
3
- import type { ServiceIdentifier, ServiceImplementation, SourceType } from './types';
4
- type Id<T extends SourceType> = ServiceIdentifier<T> | ServiceImplementation<T>;
5
- type ResolveMap<T extends SourceType> = Map<ServiceIdentifier<T>, Map<Id<T>, T>>;
6
- export declare class ServiceProvider implements IServiceProvider, IServiceScope {
7
- private services;
8
- private singletons;
9
- private scoped;
10
- private created;
11
- constructor(services: IServiceCollection, singletons?: ResolveMap<object>);
12
- [Symbol.dispose](): void;
13
- private resolveFrom;
14
- private resolveInternal;
15
- resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>, currentResolve?: ResolveMap<T>): T[];
16
- resolve<T extends SourceType>(identifier: ServiceIdentifier<T>, currentResolve?: ResolveMap<T>): T;
17
- private createInstance;
18
- createScope(): IServiceScope & IDisposable;
19
- private setDependencies;
20
- }
21
- export {};
22
- //# sourceMappingURL=ServiceProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ServiceProvider.d.ts","sourceRoot":"","sources":["../../src/ServiceProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,kBAAkB,EAAC,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAqB,qBA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