@kaokei/di 5.0.5 → 5.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.
- package/dist/binding.d.cts +5 -5
- package/dist/binding.d.ts +5 -5
- package/dist/constants.d.cts +2 -1
- package/dist/constants.d.ts +2 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +132 -134
- package/dist/interfaces.d.cts +4 -2
- package/dist/interfaces.d.ts +4 -2
- package/package.json +1 -1
package/dist/binding.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BindingType, StatusType } from './constants';
|
|
2
2
|
import { Container } from './container';
|
|
3
|
-
import { Newable, Context, Options, CommonToken, RecordObject, DynamicValue, PostConstructParam,
|
|
3
|
+
import { Newable, Context, Options, CommonToken, RecordObject, DynamicValue, PostConstructParam, BindingActivationHandler, BindingDeactivationHandler } from './interfaces';
|
|
4
4
|
export interface InjectPropertiesResult {
|
|
5
5
|
properties: RecordObject;
|
|
6
6
|
bindings: Binding[];
|
|
@@ -18,11 +18,11 @@ export declare class Binding<T = unknown> {
|
|
|
18
18
|
cache?: T;
|
|
19
19
|
postConstructResult: Promise<void> | symbol | undefined;
|
|
20
20
|
transient: boolean;
|
|
21
|
-
onActivationHandler?:
|
|
22
|
-
onDeactivationHandler?:
|
|
21
|
+
onActivationHandler?: BindingActivationHandler<T>;
|
|
22
|
+
onDeactivationHandler?: BindingDeactivationHandler<T>;
|
|
23
23
|
constructor(token: CommonToken<T>, container: Container);
|
|
24
|
-
onActivation(handler:
|
|
25
|
-
onDeactivation(handler:
|
|
24
|
+
onActivation(handler: BindingActivationHandler<T>): void;
|
|
25
|
+
onDeactivation(handler: BindingDeactivationHandler<T>): void;
|
|
26
26
|
activate(input: T): T;
|
|
27
27
|
deactivate(): void;
|
|
28
28
|
to(constructor: Newable<T>): this;
|
package/dist/binding.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BindingType, StatusType } from './constants';
|
|
2
2
|
import { Container } from './container';
|
|
3
|
-
import { Newable, Context, Options, CommonToken, RecordObject, DynamicValue, PostConstructParam,
|
|
3
|
+
import { Newable, Context, Options, CommonToken, RecordObject, DynamicValue, PostConstructParam, BindingActivationHandler, BindingDeactivationHandler } from './interfaces';
|
|
4
4
|
export interface InjectPropertiesResult {
|
|
5
5
|
properties: RecordObject;
|
|
6
6
|
bindings: Binding[];
|
|
@@ -18,11 +18,11 @@ export declare class Binding<T = unknown> {
|
|
|
18
18
|
cache?: T;
|
|
19
19
|
postConstructResult: Promise<void> | symbol | undefined;
|
|
20
20
|
transient: boolean;
|
|
21
|
-
onActivationHandler?:
|
|
22
|
-
onDeactivationHandler?:
|
|
21
|
+
onActivationHandler?: BindingActivationHandler<T>;
|
|
22
|
+
onDeactivationHandler?: BindingDeactivationHandler<T>;
|
|
23
23
|
constructor(token: CommonToken<T>, container: Container);
|
|
24
|
-
onActivation(handler:
|
|
25
|
-
onDeactivation(handler:
|
|
24
|
+
onActivation(handler: BindingActivationHandler<T>): void;
|
|
25
|
+
onDeactivation(handler: BindingDeactivationHandler<T>): void;
|
|
26
26
|
activate(input: T): T;
|
|
27
27
|
deactivate(): void;
|
|
28
28
|
to(constructor: Newable<T>): this;
|
package/dist/constants.d.cts
CHANGED
|
@@ -27,8 +27,9 @@ export declare const BINDING: {
|
|
|
27
27
|
export declare const ERRORS: {
|
|
28
28
|
readonly POST_CONSTRUCT: "Multiple @PostConstruct decorators are not allowed in a single class.";
|
|
29
29
|
readonly PRE_DESTROY: "Multiple @PreDestroy decorators are not allowed in a single class.";
|
|
30
|
-
readonly INVALID_TOKEN: "@Inject
|
|
30
|
+
readonly INVALID_TOKEN: "@Inject requires a valid token, but received null or undefined.";
|
|
31
31
|
readonly LAZY_INJECT_INVALID_TOKEN: "@LazyInject requires a valid token, but received null or undefined.";
|
|
32
|
+
readonly DECORATE_NOT_SUPPORT_INITIALIZER: "decorate does not support decorators that rely on context.addInitializer (e.g. @LazyInject, @autobind).";
|
|
32
33
|
};
|
|
33
34
|
export declare const UNINITIALIZED: unique symbol;
|
|
34
35
|
export type BindingType = (typeof BINDING)[keyof typeof BINDING];
|
package/dist/constants.d.ts
CHANGED
|
@@ -27,8 +27,9 @@ export declare const BINDING: {
|
|
|
27
27
|
export declare const ERRORS: {
|
|
28
28
|
readonly POST_CONSTRUCT: "Multiple @PostConstruct decorators are not allowed in a single class.";
|
|
29
29
|
readonly PRE_DESTROY: "Multiple @PreDestroy decorators are not allowed in a single class.";
|
|
30
|
-
readonly INVALID_TOKEN: "@Inject
|
|
30
|
+
readonly INVALID_TOKEN: "@Inject requires a valid token, but received null or undefined.";
|
|
31
31
|
readonly LAZY_INJECT_INVALID_TOKEN: "@LazyInject requires a valid token, but received null or undefined.";
|
|
32
|
+
readonly DECORATE_NOT_SUPPORT_INITIALIZER: "decorate does not support decorators that rely on context.addInitializer (e.g. @LazyInject, @autobind).";
|
|
32
33
|
};
|
|
33
34
|
export declare const UNINITIALIZED: unique symbol;
|
|
34
35
|
export type BindingType = (typeof BINDING)[keyof typeof BINDING];
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var W=Object.defineProperty;var Y=(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)=>Y(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l={INJECTED_PROPS:"injected:props",INJECT:"inject",SELF:"self",SKIP_SELF:"skipSelf",OPTIONAL:"optional",POST_CONSTRUCT:"postConstruct",PRE_DESTROY:"preDestroy"},d={DEFAULT:"default",INITING:"initing",ACTIVATED:"activated"},f={INVALID:"Invalid",INSTANCE:"Instance",CONSTANT:"ConstantValue",DYNAMIC:"DynamicValue"},I={POST_CONSTRUCT:"Multiple @PostConstruct decorators are not allowed in a single class.",PRE_DESTROY:"Multiple @PreDestroy decorators are not allowed in a single class.",INVALID_TOKEN:"@Inject requires a valid token, but received null or undefined.",LAZY_INJECT_INVALID_TOKEN:"@LazyInject requires a valid token, but received null or undefined.",DECORATE_NOT_SUPPORT_INITIALIZER:"decorate does not support decorators that rely on context.addInitializer (e.g. @LazyInject, @autobind)."},b=Symbol("UNINITIALIZED");function g(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function J(n){return n!==null&&typeof n=="object"}const y=new WeakMap,T=new WeakMap;function A(n){return typeof n=="function"&&Object.getPrototypeOf(n)!==Function.prototype}function P(n,t){y.set(n,t),T.delete(n)}function j(n){const t=y.get(n);if(t)return t[l.POST_CONSTRUCT];if(A(n))return j(Object.getPrototypeOf(n))}function w(n){const t=y.get(n);if(t)return t[l.PRE_DESTROY];if(A(n))return w(Object.getPrototypeOf(n))}function V(n){if(T.has(n)){const e=T.get(n);return e&&Object.assign({},e)}const t=G(n);return T.set(n,t),t&&Object.assign({},t)}function G(n){const t=y.get(n),e=t&&g(t,l.INJECTED_PROPS)?t[l.INJECTED_PROPS]:void 0;if(!A(n))return e;const i=V(Object.getPrototypeOf(n));if(i||e)return Object.assign({},i,e)}class K{constructor(t){r(this,"name");this.name=t}}class R{constructor(t){r(this,"_callback");this._callback=t}resolve(){return this._callback()}}function S(n){if(!n)throw new Error(I.INVALID_TOKEN);return n instanceof R?n.resolve():n}class p extends Error{constructor(e,i){const s=(i==null?void 0:i.name)||"<unknown token>";super(`${e}${s}`);r(this,"token");this.name=this.constructor.name,this.token=i}}function L(n){const t=[];let e=n;for(;e&&e.token;)t.push(e.token.name||"<anonymous>"),e=e.parent;return t.reverse()}class m extends p{constructor(t){super(""),this.message="Circular dependency found: "+L(t).join(" --> ")}}class B extends p{constructor(t){super(`Binding is incomplete: container.bind(${t==null?void 0:t.name}) was called but missing to/toSelf/toConstantValue/toDynamicValue method. `,t)}}class M extends m{constructor(t){super(t),this.name="CircularDependencyError inside @PostConstruct"}}const N=class N{constructor(t,e){r(this,"container");r(this,"context");r(this,"token");r(this,"type",f.INVALID);r(this,"status",d.DEFAULT);r(this,"classValue");r(this,"constantValue");r(this,"dynamicValue");r(this,"cache");r(this,"postConstructResult",b);r(this,"transient",!1);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=f.INSTANCE,this.classValue=t,this}toSelf(){return this.to(this.token)}toConstantValue(t){return this.type=f.CONSTANT,this.constantValue=t,this}toDynamicValue(t){return this.type=f.DYNAMIC,this.dynamicValue=t,this}inTransientScope(){return this.transient=!0,this}toService(t){return this.toDynamicValue(e=>e.container._resolveWithInternalOpts(t,{parent:{token:this.token}}))}get(t){if(d.INITING===this.status)throw new m(t);if(d.ACTIVATED===this.status)if(this.transient)this.status=d.DEFAULT;else return this.cache;const e=N._resolvers.get(this.type);if(e)return e.call(this,t);throw new B(this.token)}_getAwaitBindings(t,e){return e===!0?t:Array.isArray(e)?t.filter(i=>e.includes(i.token)):typeof e=="function"?t.filter(e):[]}_postConstruct(t,e){if(f.INSTANCE===this.type){const{key:i,value:s}=j(this.classValue)||{};if(i)if(s){const o=e.filter(c=>f.INSTANCE===(c==null?void 0:c.type)),a=this._getAwaitBindings(o,s);for(const c of a)if(c&&c.postConstructResult===b)throw new M({token:c.token,parent:t});const u=a.map(c=>c.postConstructResult);this.postConstructResult=Promise.all(u).then(()=>this._execute(i))}else this.postConstructResult=this._execute(i);else this.postConstructResult=void 0}}preDestroy(){if(f.INSTANCE===this.type&&this.cache!==void 0){const{key:t}=w(this.classValue)||{};t&&this._execute(t)}this.container&&!this.container._destroyed&&_._instanceContainerMap.delete(this.cache),this.container=void 0,this.context=void 0,this.classValue=void 0,this.constantValue=void 0,this.dynamicValue=void 0,this.cache=void 0,this.postConstructResult=b,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=d.INITING;const e=this._createInstance();this.cache=this.activate(e),this.status=d.ACTIVATED,this._registerInstance();const{properties:i,bindings:s}=this._getInjectProperties(t);return this._injectProperties(i),this._postConstruct(t,s),this.cache}_createInstance(){const t=this.classValue;return new t}_registerInstance(){_._instanceContainerMap.set(this.cache,this.container)}_injectProperties(t){Object.assign(this.cache,t)}_resolveConstantValue(){return this.status=d.INITING,this.cache=this.activate(this.constantValue),this.status=d.ACTIVATED,this.cache}_resolveDynamicValue(){this.status=d.INITING;const t=this.dynamicValue(this.context);return this.cache=this.activate(t),this.status=d.ACTIVATED,this.cache}_getInjectProperties(t){const e=V(this.classValue)||{},i=Object.keys(e),s=Object.create(null),o=[];for(let a=0;a<i.length;a++){const u=i[a],c=e[u],h=Object.assign({},c);h.parent=t;const v=this.container._resolveWithInternalOpts(S(h.inject),h);v===void 0&&h.optional||(s[u]=v),o.push(h.binding)}return{properties:s,bindings:o}}};r(N,"_resolvers",new Map([[f.INSTANCE,function(t){return this._resolveInstanceValue(t)}],[f.CONSTANT,function(t){return this._resolveConstantValue()}],[f.DYNAMIC,function(t){return this._resolveDynamicValue()}]]));let E=N;class H extends p{constructor(t,e){if(super("No matching binding found for token: ",t),e!=null&&e.parent){const i=L(e.parent);i.length>0&&(this.message+=`
|
|
2
2
|
`+i.map(s=>" required by: "+s).join(`
|
|
3
|
-
`))}}}class
|
|
3
|
+
`))}}}class k extends p{constructor(t){super("Cannot bind token multiple times: ",t)}}class F extends p{constructor(t){super("Container has been destroyed. Cannot call get() for token: ",t)}}const C=class C{constructor(){r(this,"parent");r(this,"children");r(this,"_bindings",new Map);r(this,"_destroyed",!1);r(this,"_onActivationHandler");r(this,"_onDeactivationHandler")}static getContainerOf(t){return C._instanceContainerMap.get(t)}bind(t){if(this._bindings.has(t))throw new k(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)}}tryGet(t){return this.get(t,{optional:!0})}rebind(t){return this._bindings.has(t)&&this.unbind(t),this.bind(t)}unbindAll(){const t=Array.from(this._bindings.keys());for(const e of t)this.unbind(e)}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;if(this._destroyed=!0,this.children){const i=Array.from(this.children);for(const s of i)s.destroy()}this.unbindAll(),this._bindings.clear(),(e=(t=this.parent)==null?void 0:t.children)==null||e.delete(this),this.parent=void 0,this.children=void 0,this._onActivationHandler=void 0,this._onDeactivationHandler=void 0}get(t,e={}){const i=Object.assign({},e);return this._resolveWithInternalOpts(t,i)}getAsync(t,e={}){const i=Object.assign({},e);let s;try{s=this._resolveWithInternalOpts(t,i)}catch(a){return Promise.reject(a)}const o=i.binding;return(o==null?void 0:o.postConstructResult)instanceof Promise?o.postConstructResult.then(()=>s):Promise.resolve(s)}_resolveWithInternalOpts(t,e){if(this._destroyed)throw new F(t);return e.skipSelf?this._resolveSkipSelf(t,e):e.self?this._resolveSelf(t,e):this._resolveDefault(t,e)}_resolveSkipSelf(t,e){if(this.parent){const i=Object.assign({},e,{skipSelf:!1});return this.parent._resolveWithInternalOpts(t,i)}return this._checkBindingNotFoundError(t,e)}_resolveSelf(t,e){const i=this._getBinding(t);return i?(e.token=t,e.binding=i,i.get(e)):this._checkBindingNotFoundError(t,e)}_resolveDefault(t,e){const i=this._getBinding(t);return i?(e.token=t,e.binding=i,i.get(e)):this.parent?this.parent._resolveWithInternalOpts(t,e):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 E(t,this)}_getBinding(t){return this._bindings.get(t)}_checkBindingNotFoundError(t,e){if(!e.optional)throw new H(t,e)}};r(C,"_instanceContainerMap",new WeakMap);let _=C;class x extends p{constructor(t,e){super(`@LazyInject(${t==null?void 0:t.name}) in class ${e.name} requires a registered container but none was found. Token: `,t)}}function O(n,t){return function(e){return function(i,s){const o=s.name,a=s.metadata;g(a,l.INJECTED_PROPS)||(a[l.INJECTED_PROPS]={});const u=a[l.INJECTED_PROPS];u[o]||(u[o]={}),u[o][n]=e===void 0?t:e}}}function z(n,t){return e=>(i,s)=>{const o=s.name,a=s.metadata;if(g(a,n))throw new Error(t);a[n]={key:o,value:e}}}const Z=O(l.INJECT),$=O(l.SELF,!0),q=O(l.SKIP_SELF,!0),Q=O(l.OPTIONAL,!0),X=z(l.POST_CONSTRUCT,I.POST_CONSTRUCT),tt=z(l.PRE_DESTROY,I.PRE_DESTROY);function et(){return function(n,t){const e=t.metadata;P(n,e)}}function nt(n,t,e,i){if(e==null)throw new Error(I.LAZY_INJECT_INVALID_TOKEN);let s,o=!1;Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get(){if(!o){const a=i||_.getContainerOf(n),u=n.constructor;if(!a)throw new x(S(e),u);s=a._resolveWithInternalOpts(S(e),{parent:{token:u}}),o=!0}return s},set(a){s=a,o=!0}})}function U(n,t){return function(e,i){const s=i.name;i.addInitializer(function(){nt(this,s,n,t)})}}function it(n){return function(t){return U(t,n)}}function st(n,t){const e=t.name;t.addInitializer(function(){this[e]=n.bind(this)})}const D=new WeakMap;function rt(n,t,e){const i=Array.isArray(n)?n:[n],s=t.prototype,o=typeof s[e]=="function";D.has(t)||D.set(t,{});const a=D.get(t),u={kind:o?"method":"field",name:e,static:!1,private:!1,addInitializer(h){throw new Error(I.DECORATE_NOT_SUPPORT_INITIALIZER)},metadata:a};let c=o?s[e]:void 0;for(let h=i.length-1;h>=0;h--){const v=i[h](c,u);o&&typeof v=="function"&&(c=v)}o&&c!==s[e]&&(s[e]=c),P(t,a)}exports.BaseError=p;exports.Binding=E;exports.BindingNotFoundError=H;exports.BindingNotValidError=B;exports.CircularDependencyError=m;exports.Container=_;exports.ContainerDestroyedError=F;exports.ContainerNotFoundError=x;exports.DuplicateBindingError=k;exports.ERRORS=I;exports.Inject=Z;exports.Injectable=et;exports.LazyInject=U;exports.LazyToken=R;exports.Optional=Q;exports.PostConstruct=X;exports.PostConstructError=M;exports.PreDestroy=tt;exports.Self=$;exports.SkipSelf=q;exports.Token=K;exports.autobind=st;exports.createLazyInject=it;exports.decorate=rt;exports.hasOwn=g;exports.isObject=J;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Newable, InjectFunction, CommonToken, TokenType, GenericToken, LazyTokenCallback, Context, DynamicValue, RecordObject, GetOptions, Options, ActivationHandler, DeactivationHandler, PostConstructParam, } from './interfaces';
|
|
1
|
+
export type { Newable, InjectFunction, CommonToken, TokenType, GenericToken, LazyTokenCallback, Context, DynamicValue, RecordObject, GetOptions, Options, ActivationHandler, BindingActivationHandler, DeactivationHandler, BindingDeactivationHandler, PostConstructParam, } from './interfaces';
|
|
2
2
|
export { Container } from './container';
|
|
3
3
|
export { Binding } from './binding';
|
|
4
4
|
export { Token, LazyToken } from './token';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Newable, InjectFunction, CommonToken, TokenType, GenericToken, LazyTokenCallback, Context, DynamicValue, RecordObject, GetOptions, Options, ActivationHandler, DeactivationHandler, PostConstructParam, } from './interfaces';
|
|
1
|
+
export type { Newable, InjectFunction, CommonToken, TokenType, GenericToken, LazyTokenCallback, Context, DynamicValue, RecordObject, GetOptions, Options, ActivationHandler, BindingActivationHandler, DeactivationHandler, BindingDeactivationHandler, PostConstructParam, } from './interfaces';
|
|
2
2
|
export { Container } from './container';
|
|
3
3
|
export { Binding } from './binding';
|
|
4
4
|
export { Token, LazyToken } from './token';
|
package/dist/index.js
CHANGED
|
@@ -16,11 +16,11 @@ const l = {
|
|
|
16
16
|
POST_CONSTRUCT: "postConstruct",
|
|
17
17
|
// PreDestroy 装饰器的键
|
|
18
18
|
PRE_DESTROY: "preDestroy"
|
|
19
|
-
},
|
|
19
|
+
}, d = {
|
|
20
20
|
DEFAULT: "default",
|
|
21
21
|
INITING: "initing",
|
|
22
22
|
ACTIVATED: "activated"
|
|
23
|
-
},
|
|
23
|
+
}, f = {
|
|
24
24
|
INVALID: "Invalid",
|
|
25
25
|
INSTANCE: "Instance",
|
|
26
26
|
CONSTANT: "ConstantValue",
|
|
@@ -30,50 +30,52 @@ const l = {
|
|
|
30
30
|
POST_CONSTRUCT: "Multiple @PostConstruct decorators are not allowed in a single class.",
|
|
31
31
|
PRE_DESTROY: "Multiple @PreDestroy decorators are not allowed in a single class.",
|
|
32
32
|
// 用于 token.ts 的 resolveToken —— 无效 token
|
|
33
|
-
INVALID_TOKEN: "@Inject
|
|
33
|
+
INVALID_TOKEN: "@Inject requires a valid token, but received null or undefined.",
|
|
34
34
|
// 用于 decorator.ts 的 defineLazyProperty —— 无效 token
|
|
35
|
-
LAZY_INJECT_INVALID_TOKEN: "@LazyInject requires a valid token, but received null or undefined."
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
LAZY_INJECT_INVALID_TOKEN: "@LazyInject requires a valid token, but received null or undefined.",
|
|
36
|
+
// 用于 decorator.ts 的 decorate —— 不支持 addInitializer 的装饰器
|
|
37
|
+
DECORATE_NOT_SUPPORT_INITIALIZER: "decorate does not support decorators that rely on context.addInitializer (e.g. @LazyInject, @autobind)."
|
|
38
|
+
}, O = Symbol("UNINITIALIZED");
|
|
39
|
+
function D(n, t) {
|
|
38
40
|
return Object.prototype.hasOwnProperty.call(n, t);
|
|
39
41
|
}
|
|
40
42
|
function Z(n) {
|
|
41
43
|
return n !== null && typeof n == "object";
|
|
42
44
|
}
|
|
43
|
-
const
|
|
44
|
-
function
|
|
45
|
+
const g = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
function m(n) {
|
|
45
47
|
return typeof n == "function" && Object.getPrototypeOf(n) !== Function.prototype;
|
|
46
48
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
+
function S(n, t) {
|
|
50
|
+
g.set(n, t), C.delete(n);
|
|
49
51
|
}
|
|
50
|
-
function
|
|
51
|
-
const t =
|
|
52
|
+
function P(n) {
|
|
53
|
+
const t = g.get(n);
|
|
52
54
|
if (t)
|
|
53
55
|
return t[l.POST_CONSTRUCT];
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
56
|
+
if (m(n))
|
|
57
|
+
return P(Object.getPrototypeOf(n));
|
|
56
58
|
}
|
|
57
59
|
function w(n) {
|
|
58
|
-
const t =
|
|
60
|
+
const t = g.get(n);
|
|
59
61
|
if (t)
|
|
60
62
|
return t[l.PRE_DESTROY];
|
|
61
|
-
if (
|
|
63
|
+
if (m(n))
|
|
62
64
|
return w(Object.getPrototypeOf(n));
|
|
63
65
|
}
|
|
64
|
-
function
|
|
65
|
-
if (
|
|
66
|
-
const e =
|
|
66
|
+
function V(n) {
|
|
67
|
+
if (C.has(n)) {
|
|
68
|
+
const e = C.get(n);
|
|
67
69
|
return e && Object.assign({}, e);
|
|
68
70
|
}
|
|
69
71
|
const t = H(n);
|
|
70
|
-
return
|
|
72
|
+
return C.set(n, t), t && Object.assign({}, t);
|
|
71
73
|
}
|
|
72
74
|
function H(n) {
|
|
73
|
-
const t =
|
|
74
|
-
if (!
|
|
75
|
+
const t = g.get(n), e = t && D(t, l.INJECTED_PROPS) ? t[l.INJECTED_PROPS] : void 0;
|
|
76
|
+
if (!m(n))
|
|
75
77
|
return e;
|
|
76
|
-
const i =
|
|
78
|
+
const i = V(Object.getPrototypeOf(n));
|
|
77
79
|
if (i || e)
|
|
78
80
|
return Object.assign({}, i, e);
|
|
79
81
|
}
|
|
@@ -84,7 +86,7 @@ class $ {
|
|
|
84
86
|
this.name = t;
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
|
-
class
|
|
89
|
+
class k {
|
|
88
90
|
constructor(t) {
|
|
89
91
|
r(this, "_callback");
|
|
90
92
|
this._callback = t;
|
|
@@ -93,12 +95,12 @@ class x {
|
|
|
93
95
|
return this._callback();
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
|
-
function
|
|
98
|
+
function b(n) {
|
|
97
99
|
if (!n)
|
|
98
100
|
throw new Error(T.INVALID_TOKEN);
|
|
99
|
-
return n instanceof
|
|
101
|
+
return n instanceof k ? n.resolve() : n;
|
|
100
102
|
}
|
|
101
|
-
class
|
|
103
|
+
class p extends Error {
|
|
102
104
|
constructor(e, i) {
|
|
103
105
|
const s = (i == null ? void 0 : i.name) || "<unknown token>";
|
|
104
106
|
super(`${e}${s}`);
|
|
@@ -106,27 +108,27 @@ class _ extends Error {
|
|
|
106
108
|
this.name = this.constructor.name, this.token = i;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
|
-
function
|
|
111
|
+
function j(n) {
|
|
110
112
|
const t = [];
|
|
111
113
|
let e = n;
|
|
112
114
|
for (; e && e.token; )
|
|
113
115
|
t.push(e.token.name || "<anonymous>"), e = e.parent;
|
|
114
116
|
return t.reverse();
|
|
115
117
|
}
|
|
116
|
-
class
|
|
118
|
+
class R extends p {
|
|
117
119
|
constructor(t) {
|
|
118
|
-
super(""), this.message = "Circular dependency found: " +
|
|
120
|
+
super(""), this.message = "Circular dependency found: " + j(t).join(" --> ");
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
|
-
class
|
|
123
|
+
class x extends p {
|
|
122
124
|
constructor(t) {
|
|
123
125
|
super(
|
|
124
|
-
|
|
126
|
+
`Binding is incomplete: container.bind(${t == null ? void 0 : t.name}) was called but missing to/toSelf/toConstantValue/toDynamicValue method. `,
|
|
125
127
|
t
|
|
126
128
|
);
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
|
-
class
|
|
131
|
+
class F extends R {
|
|
130
132
|
constructor(t) {
|
|
131
133
|
super(t), this.name = "CircularDependencyError inside @PostConstruct";
|
|
132
134
|
}
|
|
@@ -136,13 +138,13 @@ const N = class N {
|
|
|
136
138
|
r(this, "container");
|
|
137
139
|
r(this, "context");
|
|
138
140
|
r(this, "token");
|
|
139
|
-
r(this, "type",
|
|
140
|
-
r(this, "status",
|
|
141
|
+
r(this, "type", f.INVALID);
|
|
142
|
+
r(this, "status", d.DEFAULT);
|
|
141
143
|
r(this, "classValue");
|
|
142
144
|
r(this, "constantValue");
|
|
143
145
|
r(this, "dynamicValue");
|
|
144
146
|
r(this, "cache");
|
|
145
|
-
r(this, "postConstructResult",
|
|
147
|
+
r(this, "postConstructResult", O);
|
|
146
148
|
// 是否为瞬态作用域,默认 false(单例)
|
|
147
149
|
r(this, "transient", !1);
|
|
148
150
|
r(this, "onActivationHandler");
|
|
@@ -163,16 +165,16 @@ const N = class N {
|
|
|
163
165
|
this.onDeactivationHandler && this.onDeactivationHandler(this.cache);
|
|
164
166
|
}
|
|
165
167
|
to(t) {
|
|
166
|
-
return this.type =
|
|
168
|
+
return this.type = f.INSTANCE, this.classValue = t, this;
|
|
167
169
|
}
|
|
168
170
|
toSelf() {
|
|
169
171
|
return this.to(this.token);
|
|
170
172
|
}
|
|
171
173
|
toConstantValue(t) {
|
|
172
|
-
return this.type =
|
|
174
|
+
return this.type = f.CONSTANT, this.constantValue = t, this;
|
|
173
175
|
}
|
|
174
176
|
toDynamicValue(t) {
|
|
175
|
-
return this.type =
|
|
177
|
+
return this.type = f.DYNAMIC, this.dynamicValue = t, this;
|
|
176
178
|
}
|
|
177
179
|
inTransientScope() {
|
|
178
180
|
return this.transient = !0, this;
|
|
@@ -183,17 +185,17 @@ const N = class N {
|
|
|
183
185
|
);
|
|
184
186
|
}
|
|
185
187
|
get(t) {
|
|
186
|
-
if (
|
|
187
|
-
throw new
|
|
188
|
-
if (
|
|
188
|
+
if (d.INITING === this.status)
|
|
189
|
+
throw new R(t);
|
|
190
|
+
if (d.ACTIVATED === this.status)
|
|
189
191
|
if (this.transient)
|
|
190
|
-
this.status =
|
|
192
|
+
this.status = d.DEFAULT;
|
|
191
193
|
else
|
|
192
194
|
return this.cache;
|
|
193
195
|
const e = N._resolvers.get(this.type);
|
|
194
196
|
if (e)
|
|
195
197
|
return e.call(this, t);
|
|
196
|
-
throw new
|
|
198
|
+
throw new x(this.token);
|
|
197
199
|
}
|
|
198
200
|
_getAwaitBindings(t, e) {
|
|
199
201
|
return e === !0 ? t : Array.isArray(e) ? t.filter((i) => e.includes(i.token)) : typeof e == "function" ? t.filter(e) : [];
|
|
@@ -212,21 +214,21 @@ const N = class N {
|
|
|
212
214
|
* - 如果前置服务初始化失败,rejected promise 自然传播,当前服务的 PostConstruct 不执行
|
|
213
215
|
*/
|
|
214
216
|
_postConstruct(t, e) {
|
|
215
|
-
if (
|
|
216
|
-
const { key: i, value: s } =
|
|
217
|
+
if (f.INSTANCE === this.type) {
|
|
218
|
+
const { key: i, value: s } = P(this.classValue) || {};
|
|
217
219
|
if (i)
|
|
218
220
|
if (s) {
|
|
219
221
|
const o = e.filter(
|
|
220
|
-
(
|
|
222
|
+
(c) => f.INSTANCE === (c == null ? void 0 : c.type)
|
|
221
223
|
), a = this._getAwaitBindings(o, s);
|
|
222
|
-
for (const
|
|
223
|
-
if (
|
|
224
|
-
throw new
|
|
225
|
-
token:
|
|
224
|
+
for (const c of a)
|
|
225
|
+
if (c && c.postConstructResult === O)
|
|
226
|
+
throw new F({
|
|
227
|
+
token: c.token,
|
|
226
228
|
parent: t
|
|
227
229
|
});
|
|
228
|
-
const
|
|
229
|
-
this.postConstructResult = Promise.all(
|
|
230
|
+
const u = a.map((c) => c.postConstructResult);
|
|
231
|
+
this.postConstructResult = Promise.all(u).then(
|
|
230
232
|
() => this._execute(i)
|
|
231
233
|
);
|
|
232
234
|
} else
|
|
@@ -236,20 +238,20 @@ const N = class N {
|
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
240
|
preDestroy() {
|
|
239
|
-
if (
|
|
241
|
+
if (f.INSTANCE === this.type && this.cache !== void 0) {
|
|
240
242
|
const { key: t } = w(this.classValue) || {};
|
|
241
243
|
t && this._execute(t);
|
|
242
244
|
}
|
|
243
|
-
this.container && !this.container._destroyed && v._instanceContainerMap.delete(this.cache), this.container = void 0, this.context = void 0, this.classValue = void 0, this.constantValue = void 0, this.dynamicValue = void 0, this.cache = void 0, this.postConstructResult =
|
|
245
|
+
this.container && !this.container._destroyed && v._instanceContainerMap.delete(this.cache), this.container = void 0, this.context = void 0, this.classValue = void 0, this.constantValue = void 0, this.dynamicValue = void 0, this.cache = void 0, this.postConstructResult = O, this.onActivationHandler = void 0, this.onDeactivationHandler = void 0;
|
|
244
246
|
}
|
|
245
247
|
_execute(t) {
|
|
246
248
|
const e = this.cache[t];
|
|
247
249
|
return e == null ? void 0 : e.call(this.cache);
|
|
248
250
|
}
|
|
249
251
|
_resolveInstanceValue(t) {
|
|
250
|
-
this.status =
|
|
252
|
+
this.status = d.INITING;
|
|
251
253
|
const e = this._createInstance();
|
|
252
|
-
this.cache = this.activate(e), this.status =
|
|
254
|
+
this.cache = this.activate(e), this.status = d.ACTIVATED, this._registerInstance();
|
|
253
255
|
const { properties: i, bindings: s } = this._getInjectProperties(t);
|
|
254
256
|
return this._injectProperties(i), this._postConstruct(t, s), this.cache;
|
|
255
257
|
}
|
|
@@ -267,56 +269,56 @@ const N = class N {
|
|
|
267
269
|
Object.assign(this.cache, t);
|
|
268
270
|
}
|
|
269
271
|
_resolveConstantValue() {
|
|
270
|
-
return this.status =
|
|
272
|
+
return this.status = d.INITING, this.cache = this.activate(this.constantValue), this.status = d.ACTIVATED, this.cache;
|
|
271
273
|
}
|
|
272
274
|
_resolveDynamicValue() {
|
|
273
|
-
this.status =
|
|
275
|
+
this.status = d.INITING;
|
|
274
276
|
const t = this.dynamicValue(this.context);
|
|
275
|
-
return this.cache = this.activate(t), this.status =
|
|
277
|
+
return this.cache = this.activate(t), this.status = d.ACTIVATED, this.cache;
|
|
276
278
|
}
|
|
277
279
|
_getInjectProperties(t) {
|
|
278
|
-
const e =
|
|
280
|
+
const e = V(this.classValue) || {}, i = Object.keys(e), s = /* @__PURE__ */ Object.create(null), o = [];
|
|
279
281
|
for (let a = 0; a < i.length; a++) {
|
|
280
|
-
const
|
|
282
|
+
const u = i[a], c = e[u], h = Object.assign({}, c);
|
|
281
283
|
h.parent = t;
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
+
const _ = this.container._resolveWithInternalOpts(
|
|
285
|
+
b(h.inject),
|
|
284
286
|
h
|
|
285
287
|
);
|
|
286
|
-
|
|
288
|
+
_ === void 0 && h.optional || (s[u] = _), o.push(h.binding);
|
|
287
289
|
}
|
|
288
290
|
return { properties: s, bindings: o };
|
|
289
291
|
}
|
|
290
292
|
};
|
|
291
293
|
// 类型到解析函数的静态映射表,直接存储函数引用,消除字符串查表和 as any 间接调用
|
|
292
294
|
r(N, "_resolvers", /* @__PURE__ */ new Map([
|
|
293
|
-
[
|
|
295
|
+
[f.INSTANCE, function(t) {
|
|
294
296
|
return this._resolveInstanceValue(t);
|
|
295
297
|
}],
|
|
296
|
-
[
|
|
298
|
+
[f.CONSTANT, function(t) {
|
|
297
299
|
return this._resolveConstantValue();
|
|
298
300
|
}],
|
|
299
|
-
[
|
|
301
|
+
[f.DYNAMIC, function(t) {
|
|
300
302
|
return this._resolveDynamicValue();
|
|
301
303
|
}]
|
|
302
304
|
]));
|
|
303
305
|
let A = N;
|
|
304
|
-
class
|
|
306
|
+
class U extends p {
|
|
305
307
|
constructor(t, e) {
|
|
306
308
|
if (super("No matching binding found for token: ", t), e != null && e.parent) {
|
|
307
|
-
const i =
|
|
309
|
+
const i = j(e.parent);
|
|
308
310
|
i.length > 0 && (this.message += `
|
|
309
311
|
` + i.map((s) => " required by: " + s).join(`
|
|
310
312
|
`));
|
|
311
313
|
}
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
|
-
class
|
|
316
|
+
class W extends p {
|
|
315
317
|
constructor(t) {
|
|
316
318
|
super("Cannot bind token multiple times: ", t);
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
|
-
class
|
|
321
|
+
class z extends p {
|
|
320
322
|
constructor(t) {
|
|
321
323
|
super("Container has been destroyed. Cannot call get() for token: ", t);
|
|
322
324
|
}
|
|
@@ -336,7 +338,7 @@ const I = class I {
|
|
|
336
338
|
}
|
|
337
339
|
bind(t) {
|
|
338
340
|
if (this._bindings.has(t))
|
|
339
|
-
throw new
|
|
341
|
+
throw new W(t);
|
|
340
342
|
const e = this._buildBinding(t);
|
|
341
343
|
return this._bindings.set(t, e), e;
|
|
342
344
|
}
|
|
@@ -394,7 +396,7 @@ const I = class I {
|
|
|
394
396
|
// 内部解析入口,接受完整 Options;被 getAsync、toService、_getInjectProperties 等内部路径调用
|
|
395
397
|
_resolveWithInternalOpts(t, e) {
|
|
396
398
|
if (this._destroyed)
|
|
397
|
-
throw new
|
|
399
|
+
throw new z(t);
|
|
398
400
|
return e.skipSelf ? this._resolveSkipSelf(t, e) : e.self ? this._resolveSelf(t, e) : this._resolveDefault(t, e);
|
|
399
401
|
}
|
|
400
402
|
// 处理 skipSelf 选项:跳过当前容器,委托父容器解析
|
|
@@ -435,7 +437,7 @@ const I = class I {
|
|
|
435
437
|
}
|
|
436
438
|
_checkBindingNotFoundError(t, e) {
|
|
437
439
|
if (!e.optional)
|
|
438
|
-
throw new
|
|
440
|
+
throw new U(t, e);
|
|
439
441
|
}
|
|
440
442
|
};
|
|
441
443
|
// 实例到容器的映射表,用于 @LazyInject 查找实例所属容器
|
|
@@ -446,7 +448,7 @@ const I = class I {
|
|
|
446
448
|
// 由于 Instance 类型每次都通过 new ClassName() 创建新实例,不存在同一实例被多个容器注册的覆盖风险
|
|
447
449
|
r(I, "_instanceContainerMap", /* @__PURE__ */ new WeakMap());
|
|
448
450
|
let v = I;
|
|
449
|
-
class
|
|
451
|
+
class Y extends p {
|
|
450
452
|
constructor(t, e) {
|
|
451
453
|
super(
|
|
452
454
|
`@LazyInject(${t == null ? void 0 : t.name}) in class ${e.name} requires a registered container but none was found. Token: `,
|
|
@@ -454,38 +456,38 @@ class J extends _ {
|
|
|
454
456
|
);
|
|
455
457
|
}
|
|
456
458
|
}
|
|
457
|
-
function
|
|
459
|
+
function E(n, t) {
|
|
458
460
|
return function(e) {
|
|
459
461
|
return function(i, s) {
|
|
460
462
|
const o = s.name, a = s.metadata;
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
|
|
463
|
+
D(a, l.INJECTED_PROPS) || (a[l.INJECTED_PROPS] = {});
|
|
464
|
+
const u = a[l.INJECTED_PROPS];
|
|
465
|
+
u[o] || (u[o] = {}), u[o][n] = e === void 0 ? t : e;
|
|
464
466
|
};
|
|
465
467
|
};
|
|
466
468
|
}
|
|
467
|
-
function
|
|
469
|
+
function L(n, t) {
|
|
468
470
|
return (e) => (i, s) => {
|
|
469
471
|
const o = s.name, a = s.metadata;
|
|
470
|
-
if (
|
|
472
|
+
if (D(a, n))
|
|
471
473
|
throw new Error(t);
|
|
472
474
|
a[n] = { key: o, value: e };
|
|
473
475
|
};
|
|
474
476
|
}
|
|
475
|
-
const
|
|
477
|
+
const q = E(l.INJECT), Q = E(l.SELF, !0), X = E(l.SKIP_SELF, !0), tt = E(l.OPTIONAL, !0), et = L(
|
|
476
478
|
l.POST_CONSTRUCT,
|
|
477
479
|
T.POST_CONSTRUCT
|
|
478
|
-
),
|
|
480
|
+
), nt = L(
|
|
479
481
|
l.PRE_DESTROY,
|
|
480
482
|
T.PRE_DESTROY
|
|
481
483
|
);
|
|
482
|
-
function
|
|
484
|
+
function it() {
|
|
483
485
|
return function(n, t) {
|
|
484
486
|
const e = t.metadata;
|
|
485
|
-
|
|
487
|
+
S(n, e);
|
|
486
488
|
};
|
|
487
489
|
}
|
|
488
|
-
function
|
|
490
|
+
function J(n, t, e, i) {
|
|
489
491
|
if (e == null)
|
|
490
492
|
throw new Error(T.LAZY_INJECT_INVALID_TOKEN);
|
|
491
493
|
let s, o = !1;
|
|
@@ -494,11 +496,11 @@ function G(n, t, e, i) {
|
|
|
494
496
|
enumerable: !0,
|
|
495
497
|
get() {
|
|
496
498
|
if (!o) {
|
|
497
|
-
const a = i || v.getContainerOf(n),
|
|
499
|
+
const a = i || v.getContainerOf(n), u = n.constructor;
|
|
498
500
|
if (!a)
|
|
499
|
-
throw new
|
|
500
|
-
s = a._resolveWithInternalOpts(
|
|
501
|
-
parent: { token:
|
|
501
|
+
throw new Y(b(e), u);
|
|
502
|
+
s = a._resolveWithInternalOpts(b(e), {
|
|
503
|
+
parent: { token: u }
|
|
502
504
|
}), o = !0;
|
|
503
505
|
}
|
|
504
506
|
return s;
|
|
@@ -508,75 +510,71 @@ function G(n, t, e, i) {
|
|
|
508
510
|
}
|
|
509
511
|
});
|
|
510
512
|
}
|
|
511
|
-
function
|
|
513
|
+
function G(n, t) {
|
|
512
514
|
return function(e, i) {
|
|
513
515
|
const s = i.name;
|
|
514
516
|
i.addInitializer(function() {
|
|
515
|
-
|
|
517
|
+
J(this, s, n, t);
|
|
516
518
|
});
|
|
517
519
|
};
|
|
518
520
|
}
|
|
519
|
-
function
|
|
521
|
+
function st(n) {
|
|
520
522
|
return function(t) {
|
|
521
|
-
return
|
|
523
|
+
return G(t, n);
|
|
522
524
|
};
|
|
523
525
|
}
|
|
524
|
-
function
|
|
526
|
+
function rt(n, t) {
|
|
525
527
|
const e = t.name;
|
|
526
528
|
t.addInitializer(function() {
|
|
527
529
|
this[e] = n.bind(this);
|
|
528
530
|
});
|
|
529
531
|
}
|
|
530
|
-
const
|
|
531
|
-
function
|
|
532
|
-
const i = Array.isArray(n) ? n : [n], s = t.prototype, o = typeof s[e] == "function"
|
|
533
|
-
|
|
534
|
-
const
|
|
532
|
+
const y = /* @__PURE__ */ new WeakMap();
|
|
533
|
+
function ot(n, t, e) {
|
|
534
|
+
const i = Array.isArray(n) ? n : [n], s = t.prototype, o = typeof s[e] == "function";
|
|
535
|
+
y.has(t) || y.set(t, {});
|
|
536
|
+
const a = y.get(t), u = {
|
|
535
537
|
kind: o ? "method" : "field",
|
|
536
538
|
name: e,
|
|
537
539
|
static: !1,
|
|
538
540
|
private: !1,
|
|
539
|
-
addInitializer(
|
|
540
|
-
|
|
541
|
+
addInitializer(h) {
|
|
542
|
+
throw new Error(T.DECORATE_NOT_SUPPORT_INITIALIZER);
|
|
541
543
|
},
|
|
542
|
-
metadata:
|
|
544
|
+
metadata: a
|
|
543
545
|
};
|
|
544
|
-
let
|
|
545
|
-
for (let
|
|
546
|
-
const
|
|
547
|
-
o && typeof
|
|
548
|
-
}
|
|
549
|
-
if (o && h !== s[e] && (s[e] = h), P(t, c), a.length > 0) {
|
|
550
|
-
const d = Object.create(s);
|
|
551
|
-
for (const C of a)
|
|
552
|
-
C.call(d);
|
|
546
|
+
let c = o ? s[e] : void 0;
|
|
547
|
+
for (let h = i.length - 1; h >= 0; h--) {
|
|
548
|
+
const _ = i[h](c, u);
|
|
549
|
+
o && typeof _ == "function" && (c = _);
|
|
553
550
|
}
|
|
551
|
+
o && c !== s[e] && (s[e] = c), S(t, a);
|
|
554
552
|
}
|
|
555
553
|
export {
|
|
556
|
-
|
|
554
|
+
p as BaseError,
|
|
557
555
|
A as Binding,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
556
|
+
U as BindingNotFoundError,
|
|
557
|
+
x as BindingNotValidError,
|
|
558
|
+
R as CircularDependencyError,
|
|
561
559
|
v as Container,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
560
|
+
z as ContainerDestroyedError,
|
|
561
|
+
Y as ContainerNotFoundError,
|
|
562
|
+
W as DuplicateBindingError,
|
|
565
563
|
T as ERRORS,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
564
|
+
q as Inject,
|
|
565
|
+
it as Injectable,
|
|
566
|
+
G as LazyInject,
|
|
567
|
+
k as LazyToken,
|
|
568
|
+
tt as Optional,
|
|
569
|
+
et as PostConstruct,
|
|
570
|
+
F as PostConstructError,
|
|
571
|
+
nt as PreDestroy,
|
|
572
|
+
Q as Self,
|
|
573
|
+
X as SkipSelf,
|
|
576
574
|
$ as Token,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
575
|
+
rt as autobind,
|
|
576
|
+
st as createLazyInject,
|
|
577
|
+
ot as decorate,
|
|
578
|
+
D as hasOwn,
|
|
581
579
|
Z as isObject
|
|
582
580
|
};
|
package/dist/interfaces.d.cts
CHANGED
|
@@ -23,6 +23,8 @@ export interface Options<T = unknown> extends GetOptions {
|
|
|
23
23
|
binding?: Binding<T>;
|
|
24
24
|
parent?: Options<any>;
|
|
25
25
|
}
|
|
26
|
-
export type ActivationHandler<T = unknown> = (ctx: Context, input: T, token
|
|
27
|
-
export type
|
|
26
|
+
export type ActivationHandler<T = unknown> = (ctx: Context, input: T, token: CommonToken<T>) => T;
|
|
27
|
+
export type BindingActivationHandler<T = unknown> = (ctx: Context, input: T) => T;
|
|
28
|
+
export type DeactivationHandler<T = unknown> = (input: T, token: CommonToken<T>) => void;
|
|
29
|
+
export type BindingDeactivationHandler<T = unknown> = (input: T) => void;
|
|
28
30
|
export type PostConstructParam = void | true | CommonToken[] | ((item: Binding, index: number, arr: Binding[]) => boolean);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface Options<T = unknown> extends GetOptions {
|
|
|
23
23
|
binding?: Binding<T>;
|
|
24
24
|
parent?: Options<any>;
|
|
25
25
|
}
|
|
26
|
-
export type ActivationHandler<T = unknown> = (ctx: Context, input: T, token
|
|
27
|
-
export type
|
|
26
|
+
export type ActivationHandler<T = unknown> = (ctx: Context, input: T, token: CommonToken<T>) => T;
|
|
27
|
+
export type BindingActivationHandler<T = unknown> = (ctx: Context, input: T) => T;
|
|
28
|
+
export type DeactivationHandler<T = unknown> = (input: T, token: CommonToken<T>) => void;
|
|
29
|
+
export type BindingDeactivationHandler<T = unknown> = (input: T) => void;
|
|
28
30
|
export type PostConstructParam = void | true | CommonToken[] | ((item: Binding, index: number, arr: Binding[]) => boolean);
|