@kaokei/di 3.0.6 → 3.0.7

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.
@@ -1,13 +1,5 @@
1
- import { CommonToken, META_KEY_INJECTED_PARAMS, META_KEY_INJECTED_PROPS, META_KEY_POST_CONSTRUCT, META_KEY_PRE_DESTROY, META_VALUE_INJECTED_PARAMS, META_VALUE_INJECTED_PROPS, META_VALUE_POST_CONSTRUCT, META_VALUE_PRE_DESTROY } from './interfaces';
2
- export declare function defineMetadata(metadataKey: META_KEY_INJECTED_PARAMS, metadataValue: META_VALUE_INJECTED_PARAMS, target: CommonToken): void;
3
- export declare function defineMetadata(metadataKey: META_KEY_INJECTED_PROPS, metadataValue: META_VALUE_INJECTED_PROPS, target: CommonToken): void;
4
- export declare function defineMetadata(metadataKey: META_KEY_POST_CONSTRUCT, metadataValue: META_VALUE_POST_CONSTRUCT, target: CommonToken): void;
5
- export declare function defineMetadata(metadataKey: META_KEY_PRE_DESTROY, metadataValue: META_VALUE_PRE_DESTROY, target: CommonToken): void;
1
+ import { CommonToken } from './interfaces';
6
2
  export declare function defineMetadata(metadataKey: string, metadataValue: any, target: CommonToken): void;
7
- export declare function getOwnMetadata(metadataKey: META_KEY_INJECTED_PARAMS, target: CommonToken): META_VALUE_INJECTED_PARAMS | undefined;
8
- export declare function getOwnMetadata(metadataKey: META_KEY_INJECTED_PROPS, target: CommonToken): META_VALUE_INJECTED_PROPS | undefined;
9
- export declare function getOwnMetadata(metadataKey: META_KEY_POST_CONSTRUCT, target: CommonToken): META_VALUE_POST_CONSTRUCT | undefined;
10
- export declare function getOwnMetadata(metadataKey: META_KEY_PRE_DESTROY, target: CommonToken): META_VALUE_PRE_DESTROY | undefined;
11
3
  export declare function getOwnMetadata(metadataKey: string, target: CommonToken): any | undefined;
12
4
  /**
13
5
  * 使用hasParentClass判断当前target有没有父类
@@ -15,7 +7,4 @@ export declare function getOwnMetadata(metadataKey: string, target: CommonToken)
15
7
  * 如果有父类,那么需要合并getOwnMetadata(target)和getMetadata(target的父类)
16
8
  * 不支持META_KEY_INJECTED_PARAMS作为metadataKey
17
9
  */
18
- export declare function getMetadata(metadataKey: META_KEY_INJECTED_PROPS, target: CommonToken): META_VALUE_INJECTED_PROPS | undefined;
19
- export declare function getMetadata(metadataKey: META_KEY_POST_CONSTRUCT, target: CommonToken): META_VALUE_POST_CONSTRUCT | undefined;
20
- export declare function getMetadata(metadataKey: META_KEY_PRE_DESTROY, target: CommonToken): META_VALUE_PRE_DESTROY | undefined;
21
10
  export declare function getMetadata(metadataKey: string, target: CommonToken): any | undefined;
@@ -1,13 +1,5 @@
1
- import { CommonToken, META_KEY_INJECTED_PARAMS, META_KEY_INJECTED_PROPS, META_KEY_POST_CONSTRUCT, META_KEY_PRE_DESTROY, META_VALUE_INJECTED_PARAMS, META_VALUE_INJECTED_PROPS, META_VALUE_POST_CONSTRUCT, META_VALUE_PRE_DESTROY } from './interfaces';
2
- export declare function defineMetadata(metadataKey: META_KEY_INJECTED_PARAMS, metadataValue: META_VALUE_INJECTED_PARAMS, target: CommonToken): void;
3
- export declare function defineMetadata(metadataKey: META_KEY_INJECTED_PROPS, metadataValue: META_VALUE_INJECTED_PROPS, target: CommonToken): void;
4
- export declare function defineMetadata(metadataKey: META_KEY_POST_CONSTRUCT, metadataValue: META_VALUE_POST_CONSTRUCT, target: CommonToken): void;
5
- export declare function defineMetadata(metadataKey: META_KEY_PRE_DESTROY, metadataValue: META_VALUE_PRE_DESTROY, target: CommonToken): void;
1
+ import { CommonToken } from './interfaces';
6
2
  export declare function defineMetadata(metadataKey: string, metadataValue: any, target: CommonToken): void;
7
- export declare function getOwnMetadata(metadataKey: META_KEY_INJECTED_PARAMS, target: CommonToken): META_VALUE_INJECTED_PARAMS | undefined;
8
- export declare function getOwnMetadata(metadataKey: META_KEY_INJECTED_PROPS, target: CommonToken): META_VALUE_INJECTED_PROPS | undefined;
9
- export declare function getOwnMetadata(metadataKey: META_KEY_POST_CONSTRUCT, target: CommonToken): META_VALUE_POST_CONSTRUCT | undefined;
10
- export declare function getOwnMetadata(metadataKey: META_KEY_PRE_DESTROY, target: CommonToken): META_VALUE_PRE_DESTROY | undefined;
11
3
  export declare function getOwnMetadata(metadataKey: string, target: CommonToken): any | undefined;
12
4
  /**
13
5
  * 使用hasParentClass判断当前target有没有父类
@@ -15,7 +7,4 @@ export declare function getOwnMetadata(metadataKey: string, target: CommonToken)
15
7
  * 如果有父类,那么需要合并getOwnMetadata(target)和getMetadata(target的父类)
16
8
  * 不支持META_KEY_INJECTED_PARAMS作为metadataKey
17
9
  */
18
- export declare function getMetadata(metadataKey: META_KEY_INJECTED_PROPS, target: CommonToken): META_VALUE_INJECTED_PROPS | undefined;
19
- export declare function getMetadata(metadataKey: META_KEY_POST_CONSTRUCT, target: CommonToken): META_VALUE_POST_CONSTRUCT | undefined;
20
- export declare function getMetadata(metadataKey: META_KEY_PRE_DESTROY, target: CommonToken): META_VALUE_PRE_DESTROY | undefined;
21
10
  export declare function getMetadata(metadataKey: string, target: CommonToken): any | undefined;
@@ -1,6 +1,7 @@
1
1
  import { Binding } from './binding';
2
2
  import { Options, CommonToken, ActivationHandler, DeactivationHandler } from './interfaces';
3
3
  export declare class Container {
4
+ static map: WeakMap<any, Container>;
4
5
  parent?: Container;
5
6
  children?: Set<Container>;
6
7
  private bindings;
@@ -28,4 +29,3 @@ export declare class Container {
28
29
  private getBinding;
29
30
  private checkBindingNotFoundError;
30
31
  }
31
- export declare const CONTAINER_MAP: WeakMap<any, Container>;
@@ -1,6 +1,7 @@
1
1
  import { Binding } from './binding';
2
2
  import { Options, CommonToken, ActivationHandler, DeactivationHandler } from './interfaces';
3
3
  export declare class Container {
4
+ static map: WeakMap<any, Container>;
4
5
  parent?: Container;
5
6
  children?: Set<Container>;
6
7
  private bindings;
@@ -28,4 +29,3 @@ export declare class Container {
28
29
  private getBinding;
29
30
  private checkBindingNotFoundError;
30
31
  }
31
- export declare const CONTAINER_MAP: WeakMap<any, Container>;
@@ -12,7 +12,7 @@ export declare const Inject: InjectFunction<ReturnType<typeof createDecorator>>;
12
12
  export declare const Self: (decoratorValue?: any) => (target: any, targetKey?: string, index?: number) => void;
13
13
  export declare const SkipSelf: (decoratorValue?: any) => (target: any, targetKey?: string, index?: number) => void;
14
14
  export declare const Optional: (decoratorValue?: any) => (target: any, targetKey?: string, index?: number) => void;
15
- export declare const PostConstruct: (metaValue: import('./interfaces').PostConstructParam) => (target: any, propertyKey: string) => void;
16
- export declare const PreDestroy: (metaValue: void) => (target: any, propertyKey: string) => void;
15
+ export declare const PostConstruct: (metaValue: any) => (target: any, propertyKey: string) => void;
16
+ export declare const PreDestroy: (metaValue: any) => (target: any, propertyKey: string) => void;
17
17
  export declare function decorate(decorator: any, target: any, key: number | string): void;
18
18
  export {};
@@ -12,7 +12,7 @@ export declare const Inject: InjectFunction<ReturnType<typeof createDecorator>>;
12
12
  export declare const Self: (decoratorValue?: any) => (target: any, targetKey?: string, index?: number) => void;
13
13
  export declare const SkipSelf: (decoratorValue?: any) => (target: any, targetKey?: string, index?: number) => void;
14
14
  export declare const Optional: (decoratorValue?: any) => (target: any, targetKey?: string, index?: number) => void;
15
- export declare const PostConstruct: (metaValue: import('./interfaces').PostConstructParam) => (target: any, propertyKey: string) => void;
16
- export declare const PreDestroy: (metaValue: void) => (target: any, propertyKey: string) => void;
15
+ export declare const PostConstruct: (metaValue: any) => (target: any, propertyKey: string) => void;
16
+ export declare const PreDestroy: (metaValue: any) => (target: any, propertyKey: string) => void;
17
17
  export declare function decorate(decorator: any, target: any, key: number | string): void;
18
18
  export {};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var _=(n,t,e)=>t in n?w(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>_(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l={INJECTED_PARAMS:"injected:params",INJECTED_PROPS:"injected:props",INJECT:"inject",SELF:"self",SKIP_SELF:"skipSelf",OPTIONAL:"optional",POST_CONSTRUCT:"postConstruct",PRE_DESTROY:"preDestroy"},p={DEFAULT:"default",INITING:"initing",ACTIVATED:"activated"},d={Invalid:"Invalid",Instance:"Instance",ConstantValue:"ConstantValue",DynamicValue:"DynamicValue"},C={POST_CONSTRUCT:"Cannot apply @PostConstruct decorator multiple times in the same class.",PRE_DESTROY:"Cannot apply @PreDestroy decorator multiple times in the same class.",MISS_INJECT:"Expected a @Inject decorator to explicitly specify the token.",MISS_CONTAINER:"@LazyInject decorator cannot find the corresponding container."},P=Symbol(),v=new WeakMap;function M(n){return typeof n=="function"&&Object.getPrototypeOf(n)!==Function.prototype}function D(n,t,e){const s=v.get(e)||{};s[n]=t,v.set(e,s)}function I(n,t){return(v.get(t)||{})[n]}function g(n,t){const e=I(n,t);if(!M(t))return e;const s=g(n,Object.getPrototypeOf(t));if(s||e)return{...s||{},...e||{}}}class j{constructor(t){r(this,"_","");r(this,"name");this.name=t}}class N{constructor(t){r(this,"callback");this.callback=t}resolve(){return this.callback()}}function S(n){if(!n)throw new Error(C.MISS_INJECT);return n instanceof N?n.resolve():n}class T extends Error{constructor(t,e){super(),this.name=this.constructor.name,this.message=`${t}${e==null?void 0:e.name}`}}class O extends T{constructor(t){super("");const e=[];let s=t;for(;s&&s.token;)e.push(s.token),s=s.parent;const i=e.reverse().map(o=>o.name).join(" --> ");this.message=`Circular dependency found: ${i}`}}class B extends T{constructor(t){super("Invalid binding: ",t)}}class k extends O{constructor(t){super(t),this.name="CircularDependencyError inside @PostConstruct"}}class L{constructor(t,e){r(this,"container");r(this,"context");r(this,"token");r(this,"type",d.Invalid);r(this,"status",p.DEFAULT);r(this,"classValue");r(this,"constantValue");r(this,"dynamicValue");r(this,"cache");r(this,"postConstructResult",P);r(this,"onActivationHandler");r(this,"onDeactivationHandler");this.container=e,this.context={container:this.container},this.token=t}onActivation(t){this.onActivationHandler=t}onDeactivation(t){this.onDeactivationHandler=t}activate(t){const e=this.onActivationHandler?this.onActivationHandler(this.context,t):t;return this.container.activate(e,this.token)}deactivate(){this.onDeactivationHandler&&this.onDeactivationHandler(this.cache)}to(t){return this.type=d.Instance,this.classValue=t,this}toSelf(){return this.to(this.token)}toConstantValue(t){return this.type=d.ConstantValue,this.constantValue=t,this}toDynamicValue(t){return this.type=d.DynamicValue,this.dynamicValue=t,this}toService(t){return this.toDynamicValue(e=>e.container.get(t,{parent:{token:this.token}}))}get(t){if(p.INITING===this.status)throw new O(t);if(p.ACTIVATED===this.status)return this.cache;if(d.Instance===this.type)return this.resolveInstanceValue(t);if(d.ConstantValue===this.type)return this.resolveConstantValue();if(d.DynamicValue===this.type)return this.resolveDynamicValue();throw new B(this.token)}getAwaitBindings(t,e){return e===!0?t:Array.isArray(e)?t.filter(s=>e.includes(s.token)):typeof e=="function"?t.filter(e):[]}postConstruct(t,e,s){if(d.Instance===this.type){const{key:i,value:o}=g(l.POST_CONSTRUCT,this.classValue)||{};if(i)if(o){const a=[...e,...s].filter(u=>d.Instance===(u==null?void 0:u.type)),c=this.getAwaitBindings(a,o);for(const u of c)if(u&&u.postConstructResult===P)throw new k({token:u.token,parent:t});const h=c.map(u=>u.postConstructResult);this.postConstructResult=Promise.all(h).then(()=>this.execute(i))}else this.postConstructResult=this.execute(i);else this.postConstructResult=void 0}}preDestroy(){if(d.Instance===this.type){const{key:t}=g(l.PRE_DESTROY,this.classValue)||{};if(t)return this.execute(t)}this.container=null,this.context=null}execute(t){const e=this.cache[t];return e==null?void 0:e.call(this.cache)}resolveInstanceValue(t){this.status=p.INITING;const e=this.classValue,[s,i]=this.getConstructorParameters(t),o=new e(...s);this.cache=this.activate(o),this.status=p.ACTIVATED,A.set(this.cache,this.container);const[a,c]=this.getInjectProperties(t);return Object.assign(this.cache,a),this.postConstruct(t,i,c),this.cache}resolveConstantValue(){return this.status=p.INITING,this.cache=this.activate(this.constantValue),this.status=p.ACTIVATED,this.cache}resolveDynamicValue(){this.status=p.INITING;const t=this.dynamicValue.call(this,this.context);return this.cache=this.activate(t),this.status=p.ACTIVATED,this.cache}getConstructorParameters(t){const e=I(l.INJECTED_PARAMS,this.classValue)||[],s=[],i=[];for(let o=0;o<e.length;o++){const a=e[o],{inject:c,...h}=a;h.parent=t;const u=this.container.get(S(c),h);s.push(u),i.push(h.binding)}return[s,i]}getInjectProperties(t){const e=g(l.INJECTED_PROPS,this.classValue)||{},s=Object.keys(e),i=Object.create(null),o=[];for(let a=0;a<s.length;a++){const c=s[a],h=e[c],{inject:u,...f}=h;f.parent=t;const y=this.container.get(S(u),f);y===void 0&&h.optional||(i[c]=y),o.push(f.binding)}return[i,o]}}class H extends T{constructor(t){super("No matching binding found for token: ",t)}}class x extends T{constructor(t){super("Cannot bind token multiple times: ",t)}}class m{constructor(){r(this,"parent");r(this,"children");r(this,"bindings",new Map);r(this,"onActivationHandler");r(this,"onDeactivationHandler")}bind(t){if(this.bindings.has(t))throw new x(t);const e=this.buildBinding(t);return this.bindings.set(t,e),e}unbind(t){if(this.bindings.has(t)){const e=this.getBinding(t);this.deactivate(e),e.preDestroy(),this.bindings.delete(t)}}unbindAll(){this.bindings.forEach(t=>{this.unbind(t.token)})}isCurrentBound(t){return this.bindings.has(t)}isBound(t){return this.isCurrentBound(t)||!!this.parent&&this.parent.isBound(t)}createChild(){const t=new m;return t.parent=this,this.children||(this.children=new Set),this.children.add(t),t}destroy(){var t,e,s;(e=(t=this.parent)==null?void 0:t.children)==null||e.delete(this),this.unbindAll(),this.bindings.clear(),this.parent=void 0,(s=this.children)==null||s.clear(),this.children=void 0,this.onActivationHandler=void 0,this.onDeactivationHandler=void 0}get(t,e={}){const s=this.getBinding(t);if(e.skipSelf){if(this.parent)return e.skipSelf=!1,this.parent.get(t,e)}else if(e.self||s){if(s)return e.token=t,e.binding=s,s.get(e)}else if(this.parent)return this.parent.get(t,e);return this.checkBindingNotFoundError(t,e)}onActivation(t){this.onActivationHandler=t}onDeactivation(t){this.onDeactivationHandler=t}activate(t,e){return this.onActivationHandler?this.onActivationHandler({container:this},t,e):t}deactivate(t){this.onDeactivationHandler&&this.onDeactivationHandler(t.cache,t.token),t.deactivate()}buildBinding(t){return new L(t,this)}getBinding(t){return this.bindings.get(t)}checkBindingNotFoundError(t,e){if(!e.optional)throw new H(t)}}const A=new WeakMap;function E(n,t){return function(e){return function(s,i,o){const a=typeof o=="number",c=a?s:s.constructor,h=a?o:i,u=a?l.INJECTED_PARAMS:l.INJECTED_PROPS,f=a?I(u,c)||[]:g(u,c)||{},y=f[h]||{};y[n]=e===void 0?t:e,f[h]=y,D(u,f,c)}}}function V(n,t){return e=>(s,i)=>{if(I(n,s.constructor))throw new Error(t);D(n,{key:i,value:e},s.constructor)}}const F=E(l.INJECT),J=E(l.SELF,!0),U=E(l.SKIP_SELF,!0),z=E(l.OPTIONAL,!0),G=V(l.POST_CONSTRUCT,C.POST_CONSTRUCT),Y=V(l.PRE_DESTROY,C.PRE_DESTROY);function b(n,t,e,s){for(let i=n.length-1;i>=0;i--)n[i](t,e,s)}function K(n,t,e){n=Array.isArray(n)?n:[n],typeof e=="number"?b(n,t,void 0,e):typeof e=="string"&&b(n,t.prototype,e)}function $(n,t,e,s){function i(){const a=Symbol.for(t);if(!this.hasOwnProperty(a)){const c=s||A.get(this),h=this.constructor;if(!c)throw new Error(`${C.MISS_CONTAINER} ${h.name}`);this[a]=c.get(S(e),{parent:{token:h}})}return this[a]}function o(a){const c=Symbol.for(t);this[c]=a}Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:i,set:o})}function R(n,t){return function(e,s){$(e,s,n,t)}}function W(n){return function(t){return R(t,n)}}exports.CONTAINER_MAP=A;exports.Container=m;exports.Inject=F;exports.LazyInject=R;exports.LazyToken=N;exports.Optional=z;exports.PostConstruct=G;exports.PreDestroy=Y;exports.Self=J;exports.SkipSelf=U;exports.Token=j;exports.createLazyInject=W;exports.decorate=K;exports.defineMetadata=D;exports.getMetadata=g;exports.getOwnMetadata=I;
1
+ "use strict";var w=Object.defineProperty;var j=(n,t,e)=>t in n?w(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>j(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l={INJECTED_PARAMS:"injected:params",INJECTED_PROPS:"injected:props",INJECT:"inject",SELF:"self",SKIP_SELF:"skipSelf",OPTIONAL:"optional",POST_CONSTRUCT:"postConstruct",PRE_DESTROY:"preDestroy"},p={DEFAULT:"default",INITING:"initing",ACTIVATED:"activated"},d={Invalid:"Invalid",Instance:"Instance",ConstantValue:"ConstantValue",DynamicValue:"DynamicValue"},v={POST_CONSTRUCT:"Cannot apply @PostConstruct decorator multiple times in the same class.",PRE_DESTROY:"Cannot apply @PreDestroy decorator multiple times in the same class.",MISS_INJECT:"Expected a @Inject decorator to explicitly specify the token.",MISS_CONTAINER:"@LazyInject decorator cannot find the corresponding container."},m=Symbol(),D=new WeakMap;function B(n){return typeof n=="function"&&Object.getPrototypeOf(n)!==Function.prototype}function b(n,t,e){const s=D.get(e)||{};s[n]=t,D.set(e,s)}function T(n,t){return(D.get(t)||{})[n]}function I(n,t){const e=T(n,t);if(!B(t))return e;const s=I(n,Object.getPrototypeOf(t));if(s||e)return{...s||{},...e||{}}}class _{constructor(t){r(this,"_","");r(this,"name");this.name=t}}class O{constructor(t){r(this,"callback");this.callback=t}resolve(){return this.callback()}}function A(n){if(!n)throw new Error(v.MISS_INJECT);return n instanceof O?n.resolve():n}class E extends Error{constructor(t,e){super(),this.name=this.constructor.name,this.message=`${t}${e==null?void 0:e.name}`}}class N extends E{constructor(t){super("");const e=[];let s=t;for(;s&&s.token;)e.push(s.token),s=s.parent;const i=e.reverse().map(o=>o.name).join(" --> ");this.message=`Circular dependency found: ${i}`}}class k extends E{constructor(t){super("Invalid binding: ",t)}}class H extends N{constructor(t){super(t),this.name="CircularDependencyError inside @PostConstruct"}}class L{constructor(t,e){r(this,"container");r(this,"context");r(this,"token");r(this,"type",d.Invalid);r(this,"status",p.DEFAULT);r(this,"classValue");r(this,"constantValue");r(this,"dynamicValue");r(this,"cache");r(this,"postConstructResult",m);r(this,"onActivationHandler");r(this,"onDeactivationHandler");this.container=e,this.context={container:this.container},this.token=t}onActivation(t){this.onActivationHandler=t}onDeactivation(t){this.onDeactivationHandler=t}activate(t){const e=this.onActivationHandler?this.onActivationHandler(this.context,t):t;return this.container.activate(e,this.token)}deactivate(){this.onDeactivationHandler&&this.onDeactivationHandler(this.cache)}to(t){return this.type=d.Instance,this.classValue=t,this}toSelf(){return this.to(this.token)}toConstantValue(t){return this.type=d.ConstantValue,this.constantValue=t,this}toDynamicValue(t){return this.type=d.DynamicValue,this.dynamicValue=t,this}toService(t){return this.toDynamicValue(e=>e.container.get(t,{parent:{token:this.token}}))}get(t){if(p.INITING===this.status)throw new N(t);if(p.ACTIVATED===this.status)return this.cache;if(d.Instance===this.type)return this.resolveInstanceValue(t);if(d.ConstantValue===this.type)return this.resolveConstantValue();if(d.DynamicValue===this.type)return this.resolveDynamicValue();throw new k(this.token)}getAwaitBindings(t,e){return e===!0?t:Array.isArray(e)?t.filter(s=>e.includes(s.token)):typeof e=="function"?t.filter(e):[]}postConstruct(t,e,s){if(d.Instance===this.type){const{key:i,value:o}=I(l.POST_CONSTRUCT,this.classValue)||{};if(i)if(o){const a=[...e,...s].filter(u=>d.Instance===(u==null?void 0:u.type)),c=this.getAwaitBindings(a,o);for(const u of c)if(u&&u.postConstructResult===m)throw new H({token:u.token,parent:t});const h=c.map(u=>u.postConstructResult);this.postConstructResult=Promise.all(h).then(()=>this.execute(i))}else this.postConstructResult=this.execute(i);else this.postConstructResult=void 0}}preDestroy(){if(d.Instance===this.type){const{key:t}=I(l.PRE_DESTROY,this.classValue)||{};if(t)return this.execute(t)}y.map.delete(this.cache),this.container=null,this.context=null,this.cache=null,this.postConstructResult=m,this.onActivationHandler=void 0,this.onDeactivationHandler=void 0}execute(t){const e=this.cache[t];return e==null?void 0:e.call(this.cache)}resolveInstanceValue(t){this.status=p.INITING;const e=this.classValue,[s,i]=this.getConstructorParameters(t),o=new e(...s);this.cache=this.activate(o),this.status=p.ACTIVATED,y.map.set(this.cache,this.container);const[a,c]=this.getInjectProperties(t);return Object.assign(this.cache,a),this.postConstruct(t,i,c),this.cache}resolveConstantValue(){return this.status=p.INITING,this.cache=this.activate(this.constantValue),this.status=p.ACTIVATED,this.cache}resolveDynamicValue(){this.status=p.INITING;const t=this.dynamicValue.call(this,this.context);return this.cache=this.activate(t),this.status=p.ACTIVATED,this.cache}getConstructorParameters(t){const e=T(l.INJECTED_PARAMS,this.classValue)||[],s=[],i=[];for(let o=0;o<e.length;o++){const a=e[o],{inject:c,...h}=a;h.parent=t;const u=this.container.get(A(c),h);s.push(u),i.push(h.binding)}return[s,i]}getInjectProperties(t){const e=I(l.INJECTED_PROPS,this.classValue)||{},s=Object.keys(e),i=Object.create(null),o=[];for(let a=0;a<s.length;a++){const c=s[a],h=e[c],{inject:u,...f}=h;f.parent=t;const g=this.container.get(A(u),f);g===void 0&&h.optional||(i[c]=g),o.push(f.binding)}return[i,o]}}class M extends E{constructor(t){super("No matching binding found for token: ",t)}}class x extends E{constructor(t){super("Cannot bind token multiple times: ",t)}}const C=class C{constructor(){r(this,"parent");r(this,"children");r(this,"bindings",new Map);r(this,"onActivationHandler");r(this,"onDeactivationHandler")}bind(t){if(this.bindings.has(t))throw new x(t);const e=this.buildBinding(t);return this.bindings.set(t,e),e}unbind(t){if(this.bindings.has(t)){const e=this.getBinding(t);this.deactivate(e),e.deactivate(),e.preDestroy(),this.bindings.delete(t)}}unbindAll(){this.bindings.forEach(t=>{this.unbind(t.token)})}isCurrentBound(t){return this.bindings.has(t)}isBound(t){return this.isCurrentBound(t)||!!this.parent&&this.parent.isBound(t)}createChild(){const t=new C;return t.parent=this,this.children||(this.children=new Set),this.children.add(t),t}destroy(){var t,e,s;this.unbindAll(),this.bindings.clear(),(e=(t=this.parent)==null?void 0:t.children)==null||e.delete(this),this.parent=void 0,(s=this.children)==null||s.clear(),this.children=void 0,this.onActivationHandler=void 0,this.onDeactivationHandler=void 0}get(t,e={}){const s=this.getBinding(t);if(e.skipSelf){if(this.parent)return e.skipSelf=!1,this.parent.get(t,e)}else if(e.self||s){if(s)return e.token=t,e.binding=s,s.get(e)}else if(this.parent)return this.parent.get(t,e);return this.checkBindingNotFoundError(t,e)}onActivation(t){this.onActivationHandler=t}onDeactivation(t){this.onDeactivationHandler=t}activate(t,e){return this.onActivationHandler?this.onActivationHandler({container:this},t,e):t}deactivate(t){this.onDeactivationHandler&&this.onDeactivationHandler(t.cache,t.token)}buildBinding(t){return new L(t,this)}getBinding(t){return this.bindings.get(t)}checkBindingNotFoundError(t,e){if(!e.optional)throw new M(t)}};r(C,"map",new WeakMap);let y=C;function S(n,t){return function(e){return function(s,i,o){const a=typeof o=="number",c=a?s:s.constructor,h=a?o:i,u=a?l.INJECTED_PARAMS:l.INJECTED_PROPS,f=a?T(u,c)||[]:I(u,c)||{},g=f[h]||{};g[n]=e===void 0?t:e,f[h]=g,b(u,f,c)}}}function V(n,t){return e=>(s,i)=>{if(T(n,s.constructor))throw new Error(t);b(n,{key:i,value:e},s.constructor)}}const F=S(l.INJECT),J=S(l.SELF,!0),U=S(l.SKIP_SELF,!0),z=S(l.OPTIONAL,!0),G=V(l.POST_CONSTRUCT,v.POST_CONSTRUCT),Y=V(l.PRE_DESTROY,v.PRE_DESTROY);function P(n,t,e,s){for(let i=n.length-1;i>=0;i--)n[i](t,e,s)}function K(n,t,e){n=Array.isArray(n)?n:[n],typeof e=="number"?P(n,t,void 0,e):typeof e=="string"&&P(n,t.prototype,e)}function $(n,t,e,s){function i(){const a=Symbol.for(t);if(!this.hasOwnProperty(a)){const c=s||y.map.get(this),h=this.constructor;if(!c)throw new Error(`${v.MISS_CONTAINER} ${h.name}`);this[a]=c.get(A(e),{parent:{token:h}})}return this[a]}function o(a){const c=Symbol.for(t);this[c]=a}Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:i,set:o})}function R(n,t){return function(e,s){$(e,s,n,t)}}function W(n){return function(t){return R(t,n)}}exports.Container=y;exports.Inject=F;exports.LazyInject=R;exports.LazyToken=O;exports.Optional=z;exports.PostConstruct=G;exports.PreDestroy=Y;exports.Self=J;exports.SkipSelf=U;exports.Token=_;exports.createLazyInject=W;exports.decorate=K;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './interfaces';
2
- export { Container, CONTAINER_MAP } from './container';
2
+ export { Container } from './container';
3
3
  export { Token, LazyToken } from './token';
4
4
  export { Inject, Self, SkipSelf, Optional, PostConstruct, PreDestroy, decorate, } from './decorator';
5
5
  export { LazyInject, createLazyInject } from './lazyinject';
6
- export { defineMetadata, getOwnMetadata, getMetadata } from './cachemap';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './interfaces';
2
- export { Container, CONTAINER_MAP } from './container';
2
+ export { Container } from './container';
3
3
  export { Token, LazyToken } from './token';
4
4
  export { Inject, Self, SkipSelf, Optional, PostConstruct, PreDestroy, decorate, } from './decorator';
5
5
  export { LazyInject, createLazyInject } from './lazyinject';
6
- export { defineMetadata, getOwnMetadata, getMetadata } from './cachemap';
package/dist/index.js CHANGED
@@ -32,22 +32,19 @@ const l = {
32
32
  PRE_DESTROY: "Cannot apply @PreDestroy decorator multiple times in the same class.",
33
33
  MISS_INJECT: "Expected a @Inject decorator to explicitly specify the token.",
34
34
  MISS_CONTAINER: "@LazyInject decorator cannot find the corresponding container."
35
- }, S = Symbol(), v = /* @__PURE__ */ new WeakMap();
35
+ }, D = Symbol(), S = /* @__PURE__ */ new WeakMap();
36
36
  function w(e) {
37
37
  return typeof e == "function" && Object.getPrototypeOf(e) !== Function.prototype;
38
38
  }
39
- function A(e, t, n) {
40
- const s = v.get(n) || {};
41
- s[e] = t, v.set(n, s);
39
+ function b(e, t, n) {
40
+ const s = S.get(n) || {};
41
+ s[e] = t, S.set(n, s);
42
42
  }
43
- function I(e, t) {
44
- return (v.get(t) || {})[e];
43
+ function E(e, t) {
44
+ return (S.get(t) || {})[e];
45
45
  }
46
46
  function y(e, t) {
47
- const n = I(
48
- e,
49
- t
50
- );
47
+ const n = E(e, t);
51
48
  if (!w(t))
52
49
  return n;
53
50
  const s = y(
@@ -67,7 +64,7 @@ class J {
67
64
  this.name = t;
68
65
  }
69
66
  }
70
- class _ {
67
+ class B {
71
68
  constructor(t) {
72
69
  r(this, "callback");
73
70
  this.callback = t;
@@ -76,17 +73,17 @@ class _ {
76
73
  return this.callback();
77
74
  }
78
75
  }
79
- function D(e) {
76
+ function A(e) {
80
77
  if (!e)
81
78
  throw new Error(C.MISS_INJECT);
82
- return e instanceof _ ? e.resolve() : e;
79
+ return e instanceof B ? e.resolve() : e;
83
80
  }
84
- class E extends Error {
81
+ class T extends Error {
85
82
  constructor(t, n) {
86
83
  super(), this.name = this.constructor.name, this.message = `${t}${n == null ? void 0 : n.name}`;
87
84
  }
88
85
  }
89
- class P extends E {
86
+ class N extends T {
90
87
  constructor(t) {
91
88
  super("");
92
89
  const n = [];
@@ -97,17 +94,17 @@ class P extends E {
97
94
  this.message = `Circular dependency found: ${i}`;
98
95
  }
99
96
  }
100
- class B extends E {
97
+ class _ extends T {
101
98
  constructor(t) {
102
99
  super("Invalid binding: ", t);
103
100
  }
104
101
  }
105
- class j extends P {
102
+ class H extends N {
106
103
  constructor(t) {
107
104
  super(t), this.name = "CircularDependencyError inside @PostConstruct";
108
105
  }
109
106
  }
110
- class M {
107
+ class j {
111
108
  constructor(t, n) {
112
109
  r(this, "container");
113
110
  r(this, "context");
@@ -118,7 +115,7 @@ class M {
118
115
  r(this, "constantValue");
119
116
  r(this, "dynamicValue");
120
117
  r(this, "cache");
121
- r(this, "postConstructResult", S);
118
+ r(this, "postConstructResult", D);
122
119
  r(this, "onActivationHandler");
123
120
  r(this, "onDeactivationHandler");
124
121
  this.container = n, this.context = { container: this.container }, this.token = t;
@@ -155,7 +152,7 @@ class M {
155
152
  }
156
153
  get(t) {
157
154
  if (p.INITING === this.status)
158
- throw new P(t);
155
+ throw new N(t);
159
156
  if (p.ACTIVATED === this.status)
160
157
  return this.cache;
161
158
  if (d.Instance === this.type)
@@ -164,7 +161,7 @@ class M {
164
161
  return this.resolveConstantValue();
165
162
  if (d.DynamicValue === this.type)
166
163
  return this.resolveDynamicValue();
167
- throw new B(this.token);
164
+ throw new _(this.token);
168
165
  }
169
166
  getAwaitBindings(t, n) {
170
167
  return n === !0 ? t : Array.isArray(n) ? t.filter((s) => n.includes(s.token)) : typeof n == "function" ? t.filter(n) : [];
@@ -178,8 +175,8 @@ class M {
178
175
  (u) => d.Instance === (u == null ? void 0 : u.type)
179
176
  ), c = this.getAwaitBindings(a, o);
180
177
  for (const u of c)
181
- if (u && u.postConstructResult === S)
182
- throw new j({
178
+ if (u && u.postConstructResult === D)
179
+ throw new H({
183
180
  token: u.token,
184
181
  parent: t
185
182
  });
@@ -199,7 +196,7 @@ class M {
199
196
  if (t)
200
197
  return this.execute(t);
201
198
  }
202
- this.container = null, this.context = null;
199
+ I.map.delete(this.cache), this.container = null, this.context = null, this.cache = null, this.postConstructResult = D, this.onActivationHandler = void 0, this.onDeactivationHandler = void 0;
203
200
  }
204
201
  execute(t) {
205
202
  const n = this.cache[t];
@@ -208,7 +205,7 @@ class M {
208
205
  resolveInstanceValue(t) {
209
206
  this.status = p.INITING;
210
207
  const n = this.classValue, [s, i] = this.getConstructorParameters(t), o = new n(...s);
211
- this.cache = this.activate(o), this.status = p.ACTIVATED, N.set(this.cache, this.container);
208
+ this.cache = this.activate(o), this.status = p.ACTIVATED, I.map.set(this.cache, this.container);
212
209
  const [a, c] = this.getInjectProperties(t);
213
210
  return Object.assign(this.cache, a), this.postConstruct(t, i, c), this.cache;
214
211
  }
@@ -221,11 +218,11 @@ class M {
221
218
  return this.cache = this.activate(t), this.status = p.ACTIVATED, this.cache;
222
219
  }
223
220
  getConstructorParameters(t) {
224
- const n = I(l.INJECTED_PARAMS, this.classValue) || [], s = [], i = [];
221
+ const n = E(l.INJECTED_PARAMS, this.classValue) || [], s = [], i = [];
225
222
  for (let o = 0; o < n.length; o++) {
226
223
  const a = n[o], { inject: c, ...h } = a;
227
224
  h.parent = t;
228
- const u = this.container.get(D(c), h);
225
+ const u = this.container.get(A(c), h);
229
226
  s.push(u), i.push(h.binding);
230
227
  }
231
228
  return [s, i];
@@ -235,23 +232,23 @@ class M {
235
232
  for (let a = 0; a < s.length; a++) {
236
233
  const c = s[a], h = n[c], { inject: u, ...f } = h;
237
234
  f.parent = t;
238
- const g = this.container.get(D(u), f);
235
+ const g = this.container.get(A(u), f);
239
236
  g === void 0 && h.optional || (i[c] = g), o.push(f.binding);
240
237
  }
241
238
  return [i, o];
242
239
  }
243
240
  }
244
- class k extends E {
241
+ class k extends T {
245
242
  constructor(t) {
246
243
  super("No matching binding found for token: ", t);
247
244
  }
248
245
  }
249
- class x extends E {
246
+ class x extends T {
250
247
  constructor(t) {
251
248
  super("Cannot bind token multiple times: ", t);
252
249
  }
253
250
  }
254
- class b {
251
+ const v = class v {
255
252
  constructor() {
256
253
  r(this, "parent");
257
254
  r(this, "children");
@@ -268,7 +265,7 @@ class b {
268
265
  unbind(t) {
269
266
  if (this.bindings.has(t)) {
270
267
  const n = this.getBinding(t);
271
- this.deactivate(n), n.preDestroy(), this.bindings.delete(t);
268
+ this.deactivate(n), n.deactivate(), n.preDestroy(), this.bindings.delete(t);
272
269
  }
273
270
  }
274
271
  unbindAll() {
@@ -283,12 +280,12 @@ class b {
283
280
  return this.isCurrentBound(t) || !!this.parent && this.parent.isBound(t);
284
281
  }
285
282
  createChild() {
286
- const t = new b();
283
+ const t = new v();
287
284
  return t.parent = this, this.children || (this.children = /* @__PURE__ */ new Set()), this.children.add(t), t;
288
285
  }
289
286
  destroy() {
290
287
  var t, n, s;
291
- (n = (t = this.parent) == null ? void 0 : t.children) == null || n.delete(this), this.unbindAll(), this.bindings.clear(), this.parent = void 0, (s = this.children) == null || s.clear(), this.children = void 0, this.onActivationHandler = void 0, this.onDeactivationHandler = void 0;
288
+ this.unbindAll(), this.bindings.clear(), (n = (t = this.parent) == null ? void 0 : t.children) == null || n.delete(this), this.parent = void 0, (s = this.children) == null || s.clear(), this.children = void 0, this.onActivationHandler = void 0, this.onDeactivationHandler = void 0;
292
289
  }
293
290
  get(t, n = {}) {
294
291
  const s = this.getBinding(t);
@@ -312,10 +309,10 @@ class b {
312
309
  return this.onActivationHandler ? this.onActivationHandler({ container: this }, t, n) : t;
313
310
  }
314
311
  deactivate(t) {
315
- this.onDeactivationHandler && this.onDeactivationHandler(t.cache, t.token), t.deactivate();
312
+ this.onDeactivationHandler && this.onDeactivationHandler(t.cache, t.token);
316
313
  }
317
314
  buildBinding(t) {
318
- return new M(t, this);
315
+ return new j(t, this);
319
316
  }
320
317
  getBinding(t) {
321
318
  return this.bindings.get(t);
@@ -324,49 +321,50 @@ class b {
324
321
  if (!n.optional)
325
322
  throw new k(t);
326
323
  }
327
- }
328
- const N = /* @__PURE__ */ new WeakMap();
329
- function T(e, t) {
324
+ };
325
+ r(v, "map", /* @__PURE__ */ new WeakMap());
326
+ let I = v;
327
+ function m(e, t) {
330
328
  return function(n) {
331
329
  return function(s, i, o) {
332
- const a = typeof o == "number", c = a ? s : s.constructor, h = a ? o : i, u = a ? l.INJECTED_PARAMS : l.INJECTED_PROPS, f = a ? I(u, c) || [] : y(u, c) || {}, g = f[h] || {};
333
- g[e] = n === void 0 ? t : n, f[h] = g, A(u, f, c);
330
+ const a = typeof o == "number", c = a ? s : s.constructor, h = a ? o : i, u = a ? l.INJECTED_PARAMS : l.INJECTED_PROPS, f = a ? E(u, c) || [] : y(u, c) || {}, g = f[h] || {};
331
+ g[e] = n === void 0 ? t : n, f[h] = g, b(u, f, c);
334
332
  };
335
333
  };
336
334
  }
337
335
  function O(e, t) {
338
336
  return (n) => (s, i) => {
339
- if (I(e, s.constructor))
337
+ if (E(e, s.constructor))
340
338
  throw new Error(t);
341
- A(
339
+ b(
342
340
  e,
343
341
  { key: i, value: n },
344
342
  s.constructor
345
343
  );
346
344
  };
347
345
  }
348
- const U = T(l.INJECT), G = T(l.SELF, !0), Y = T(l.SKIP_SELF, !0), z = T(l.OPTIONAL, !0), K = O(
346
+ const U = m(l.INJECT), G = m(l.SELF, !0), Y = m(l.SKIP_SELF, !0), z = m(l.OPTIONAL, !0), K = O(
349
347
  l.POST_CONSTRUCT,
350
348
  C.POST_CONSTRUCT
351
349
  ), $ = O(
352
350
  l.PRE_DESTROY,
353
351
  C.PRE_DESTROY
354
352
  );
355
- function m(e, t, n, s) {
353
+ function P(e, t, n, s) {
356
354
  for (let i = e.length - 1; i >= 0; i--)
357
355
  e[i](t, n, s);
358
356
  }
359
357
  function W(e, t, n) {
360
- e = Array.isArray(e) ? e : [e], typeof n == "number" ? m(e, t, void 0, n) : typeof n == "string" && m(e, t.prototype, n);
358
+ e = Array.isArray(e) ? e : [e], typeof n == "number" ? P(e, t, void 0, n) : typeof n == "string" && P(e, t.prototype, n);
361
359
  }
362
- function H(e, t, n, s) {
360
+ function M(e, t, n, s) {
363
361
  function i() {
364
362
  const a = Symbol.for(t);
365
363
  if (!this.hasOwnProperty(a)) {
366
- const c = s || N.get(this), h = this.constructor;
364
+ const c = s || I.map.get(this), h = this.constructor;
367
365
  if (!c)
368
366
  throw new Error(`${C.MISS_CONTAINER} ${h.name}`);
369
- this[a] = c.get(D(n), {
367
+ this[a] = c.get(A(n), {
370
368
  parent: { token: h }
371
369
  });
372
370
  }
@@ -385,7 +383,7 @@ function H(e, t, n, s) {
385
383
  }
386
384
  function L(e, t) {
387
385
  return function(n, s) {
388
- H(n, s, e, t);
386
+ M(n, s, e, t);
389
387
  };
390
388
  }
391
389
  function q(e) {
@@ -394,11 +392,10 @@ function q(e) {
394
392
  };
395
393
  }
396
394
  export {
397
- N as CONTAINER_MAP,
398
- b as Container,
395
+ I as Container,
399
396
  U as Inject,
400
397
  L as LazyInject,
401
- _ as LazyToken,
398
+ B as LazyToken,
402
399
  z as Optional,
403
400
  K as PostConstruct,
404
401
  $ as PreDestroy,
@@ -406,8 +403,5 @@ export {
406
403
  Y as SkipSelf,
407
404
  J as Token,
408
405
  q as createLazyInject,
409
- W as decorate,
410
- A as defineMetadata,
411
- y as getMetadata,
412
- I as getOwnMetadata
406
+ W as decorate
413
407
  };
@@ -1,7 +1,6 @@
1
1
  import { Token, LazyToken } from './token';
2
2
  import { Container } from './container';
3
3
  import { Binding } from './binding';
4
- import { KEYS } from './constants';
5
4
  export type Newable<TInstance = unknown, TArgs extends unknown[] = any[]> = new (...args: TArgs) => TInstance;
6
5
  export type InjectFunction<R extends (...args: any) => any> = (token: GenericToken) => ReturnType<R>;
7
6
  export type CommonToken<T = unknown> = Token<T> | Newable<T>;
@@ -25,25 +24,3 @@ export interface Options<T = unknown> {
25
24
  export type ActivationHandler<T = unknown> = (ctx: Context, input: T, token?: CommonToken<T>) => T;
26
25
  export type DeactivationHandler<T = unknown> = (input: T, token?: CommonToken<T>) => void;
27
26
  export type PostConstructParam = void | true | CommonToken[] | ((item: Binding, index: number, arr: Binding[]) => boolean);
28
- export type META_KEY_INJECTED_PARAMS = typeof KEYS.INJECTED_PARAMS;
29
- export type META_KEY_INJECTED_PROPS = typeof KEYS.INJECTED_PROPS;
30
- export type META_KEY_POST_CONSTRUCT = typeof KEYS.POST_CONSTRUCT;
31
- export type META_KEY_PRE_DESTROY = typeof KEYS.PRE_DESTROY;
32
- export type META_KEYS = META_KEY_INJECTED_PARAMS | META_KEY_INJECTED_PROPS | META_KEY_POST_CONSTRUCT | META_KEY_PRE_DESTROY;
33
- export type META_VALUE_INJECTED_PARAMS = Options[];
34
- export type META_VALUE_INJECTED_PROPS = Record<string, Options>;
35
- export type META_VALUE_POST_CONSTRUCT = KV<PostConstructParam>;
36
- export type META_VALUE_PRE_DESTROY = KV<void>;
37
- export type META_VALUES = META_VALUE_INJECTED_PARAMS | META_VALUE_INJECTED_PROPS | META_VALUE_POST_CONSTRUCT | META_VALUE_PRE_DESTROY;
38
- export interface KV<T> {
39
- key: string;
40
- value: T;
41
- }
42
- export type ExtractKV<T> = T extends META_KEY_POST_CONSTRUCT ? PostConstructParam : T extends META_KEY_PRE_DESTROY ? void : never;
43
- export interface CacheMapValue {
44
- [KEYS.INJECTED_PARAMS]: Options[];
45
- [KEYS.INJECTED_PROPS]: Record<string, Options>;
46
- [KEYS.POST_CONSTRUCT]: KV<PostConstructParam>;
47
- [KEYS.PRE_DESTROY]: KV<void>;
48
- [key: string]: any;
49
- }
@@ -1,7 +1,6 @@
1
1
  import { Token, LazyToken } from './token';
2
2
  import { Container } from './container';
3
3
  import { Binding } from './binding';
4
- import { KEYS } from './constants';
5
4
  export type Newable<TInstance = unknown, TArgs extends unknown[] = any[]> = new (...args: TArgs) => TInstance;
6
5
  export type InjectFunction<R extends (...args: any) => any> = (token: GenericToken) => ReturnType<R>;
7
6
  export type CommonToken<T = unknown> = Token<T> | Newable<T>;
@@ -25,25 +24,3 @@ export interface Options<T = unknown> {
25
24
  export type ActivationHandler<T = unknown> = (ctx: Context, input: T, token?: CommonToken<T>) => T;
26
25
  export type DeactivationHandler<T = unknown> = (input: T, token?: CommonToken<T>) => void;
27
26
  export type PostConstructParam = void | true | CommonToken[] | ((item: Binding, index: number, arr: Binding[]) => boolean);
28
- export type META_KEY_INJECTED_PARAMS = typeof KEYS.INJECTED_PARAMS;
29
- export type META_KEY_INJECTED_PROPS = typeof KEYS.INJECTED_PROPS;
30
- export type META_KEY_POST_CONSTRUCT = typeof KEYS.POST_CONSTRUCT;
31
- export type META_KEY_PRE_DESTROY = typeof KEYS.PRE_DESTROY;
32
- export type META_KEYS = META_KEY_INJECTED_PARAMS | META_KEY_INJECTED_PROPS | META_KEY_POST_CONSTRUCT | META_KEY_PRE_DESTROY;
33
- export type META_VALUE_INJECTED_PARAMS = Options[];
34
- export type META_VALUE_INJECTED_PROPS = Record<string, Options>;
35
- export type META_VALUE_POST_CONSTRUCT = KV<PostConstructParam>;
36
- export type META_VALUE_PRE_DESTROY = KV<void>;
37
- export type META_VALUES = META_VALUE_INJECTED_PARAMS | META_VALUE_INJECTED_PROPS | META_VALUE_POST_CONSTRUCT | META_VALUE_PRE_DESTROY;
38
- export interface KV<T> {
39
- key: string;
40
- value: T;
41
- }
42
- export type ExtractKV<T> = T extends META_KEY_POST_CONSTRUCT ? PostConstructParam : T extends META_KEY_PRE_DESTROY ? void : never;
43
- export interface CacheMapValue {
44
- [KEYS.INJECTED_PARAMS]: Options[];
45
- [KEYS.INJECTED_PROPS]: Record<string, Options>;
46
- [KEYS.POST_CONSTRUCT]: KV<PostConstructParam>;
47
- [KEYS.PRE_DESTROY]: KV<void>;
48
- [key: string]: any;
49
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaokei/di",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "type": "module",
5
5
  "description": "Tiny di library depends on typescript decorator.",
6
6
  "main": "./dist/index.cjs",