ts-ioc-container 71.0.0 → 72.1.0
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/README.md +203 -65
- package/cjm/container/Container.js +5 -5
- package/cjm/hooks/HookContext.js +3 -2
- package/cjm/hooks/injectProp.js +2 -4
- package/cjm/index.js +7 -4
- package/cjm/injector/IInjector.js +2 -2
- package/cjm/injector/MetadataInjector.js +14 -9
- package/cjm/injector/ProxyInjector.js +1 -1
- package/cjm/injector/SimpleInjector.js +2 -2
- package/cjm/metadata/class.js +3 -1
- package/cjm/metadata/method.js +3 -1
- package/cjm/metadata/parameter.js +7 -1
- package/cjm/provider/Provider.js +9 -8
- package/cjm/registration/IRegistration.js +2 -2
- package/cjm/select.js +2 -2
- package/cjm/token/ClassToken.js +3 -3
- package/cjm/token/FunctionToken.js +5 -4
- package/cjm/token/GroupAliasToken.js +3 -3
- package/cjm/token/InjectionToken.js +1 -1
- package/cjm/token/SingleAliasToken.js +3 -3
- package/cjm/token/SingleToken.js +3 -3
- package/cjm/token/toToken.js +1 -8
- package/esm/container/Container.js +5 -5
- package/esm/hooks/HookContext.js +3 -2
- package/esm/hooks/injectProp.js +1 -4
- package/esm/index.js +5 -5
- package/esm/injector/IInjector.js +2 -2
- package/esm/injector/MetadataInjector.js +13 -9
- package/esm/injector/ProxyInjector.js +1 -1
- package/esm/injector/SimpleInjector.js +2 -2
- package/esm/metadata/class.js +1 -0
- package/esm/metadata/method.js +1 -0
- package/esm/metadata/parameter.js +5 -0
- package/esm/provider/Provider.js +9 -8
- package/esm/registration/IRegistration.js +2 -2
- package/esm/select.js +2 -2
- package/esm/token/ClassToken.js +3 -3
- package/esm/token/FunctionToken.js +5 -4
- package/esm/token/GroupAliasToken.js +3 -3
- package/esm/token/InjectionToken.js +1 -1
- package/esm/token/SingleAliasToken.js +3 -3
- package/esm/token/SingleToken.js +3 -3
- package/esm/token/toToken.js +0 -6
- package/package.json +1 -1
- package/typings/container/IContainer.d.ts +2 -2
- package/typings/hooks/HookContext.d.ts +3 -3
- package/typings/hooks/hook.d.ts +1 -2
- package/typings/hooks/injectProp.d.ts +2 -14
- package/typings/index.d.ts +7 -7
- package/typings/injector/IInjector.d.ts +7 -4
- package/typings/injector/MetadataInjector.d.ts +6 -16
- package/typings/injector/ProxyInjector.d.ts +1 -2
- package/typings/injector/SimpleInjector.d.ts +1 -2
- package/typings/metadata/class.d.ts +1 -0
- package/typings/metadata/method.d.ts +1 -0
- package/typings/metadata/parameter.d.ts +1 -0
- package/typings/provider/IProvider.d.ts +5 -4
- package/typings/provider/Provider.d.ts +2 -2
- package/typings/select.d.ts +3 -3
- package/typings/token/ClassToken.d.ts +2 -2
- package/typings/token/FunctionToken.d.ts +2 -2
- package/typings/token/GroupAliasToken.d.ts +2 -2
- package/typings/token/InjectionToken.d.ts +2 -2
- package/typings/token/SingleAliasToken.d.ts +3 -3
- package/typings/token/SingleToken.d.ts +2 -2
- package/typings/token/toToken.d.ts +0 -2
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { Injector } from './IInjector.js';
|
|
2
2
|
import { resolveConstructor } from '../metadata/target.js';
|
|
3
3
|
import { addParamMeta, getParamMeta } from '../metadata/parameter.js';
|
|
4
|
-
import {
|
|
4
|
+
import { toToken } from '../token/toToken.js';
|
|
5
5
|
export class MetadataInjector extends Injector {
|
|
6
|
-
createInstance(
|
|
7
|
-
const args = resolveArgs(Target)(scope,
|
|
6
|
+
createInstance(Target, { scope, args: deps = [] }) {
|
|
7
|
+
const args = resolveArgs(Target)({ scope, args: deps });
|
|
8
8
|
return new Target(...args);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
const hookMetaKey = (methodName = 'constructor') => `inject:${methodName}`;
|
|
12
|
-
export function inject(fn
|
|
12
|
+
export function inject(fn) {
|
|
13
13
|
return (target, propertyKey, parameterIndex) => {
|
|
14
|
-
addParamMeta(hookMetaKey(propertyKey), () =>
|
|
14
|
+
addParamMeta(hookMetaKey(propertyKey), () => fn)(resolveConstructor(target), propertyKey, parameterIndex);
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export const
|
|
17
|
+
export const by = (target) => {
|
|
18
|
+
const token = toToken(target);
|
|
19
|
+
return ({ scope, ...options }) => token.resolve(scope, options);
|
|
20
|
+
};
|
|
21
|
+
export const argsFn = (predicate) => ({ args = [] }) => args.find((value, index) => predicate(value, index));
|
|
18
22
|
export const arg = (index) => argsFn((value, i) => i === index);
|
|
19
|
-
export const args = (
|
|
23
|
+
export const args = ({ args = [] }) => args;
|
|
20
24
|
export const resolveArgs = (target, methodName) => {
|
|
21
|
-
const
|
|
22
|
-
return (
|
|
25
|
+
const fns = getParamMeta(hookMetaKey(methodName), target);
|
|
26
|
+
return (options) => fns.map((fn) => fn(options));
|
|
23
27
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Injector } from './IInjector.js';
|
|
2
2
|
export class ProxyInjector extends Injector {
|
|
3
|
-
createInstance(
|
|
3
|
+
createInstance(Target, { scope, args = [] }) {
|
|
4
4
|
const proxy = new Proxy({}, {
|
|
5
5
|
get(target, prop) {
|
|
6
6
|
if (prop === 'args') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Injector } from './IInjector.js';
|
|
2
2
|
export class SimpleInjector extends Injector {
|
|
3
|
-
createInstance(
|
|
4
|
-
return new Target(
|
|
3
|
+
createInstance(Target, { scope, args = [] }) {
|
|
4
|
+
return new Target(scope, ...args);
|
|
5
5
|
}
|
|
6
6
|
}
|
package/esm/metadata/class.js
CHANGED
|
@@ -10,3 +10,4 @@ export const addClassLabel = (key, label) => addClassMeta('label', (prev = new M
|
|
|
10
10
|
export const getClassLabels = (target) => getClassMeta(target, 'label') ?? new Map();
|
|
11
11
|
export const addClassTag = (tag) => addClassMeta('tag', (prev = new Set()) => prev.add(tag));
|
|
12
12
|
export const getClassTags = (target) => getClassMeta(target, 'tag') ?? new Set();
|
|
13
|
+
export const createComposeClassDecorator = (...decorators) => (target) => decorators.reduceRight((acc, decorate) => decorate(acc) ?? acc, target);
|
package/esm/metadata/method.js
CHANGED
|
@@ -8,3 +8,4 @@ export const addMethodLabel = (key, label) => addMethodMeta('label', (prev = new
|
|
|
8
8
|
export const getMethodLabels = (target, propertyKey) => getMethodMeta('label', target, propertyKey) ?? new Map();
|
|
9
9
|
export const addMethodTag = (tag) => addMethodMeta('tag', (prev = new Set()) => prev.add(tag));
|
|
10
10
|
export const getMethodTags = (target, propertyKey) => getMethodMeta('tag', target, propertyKey) ?? new Set();
|
|
11
|
+
export const createComposeMethodDecorator = (...decorators) => (target, propertyKey, descriptor) => decorators.reduceRight((acc, decorate) => decorate(target, propertyKey, acc) ?? acc, descriptor);
|
|
@@ -23,3 +23,8 @@ export const getParamTags = (target, parameterIndex) => {
|
|
|
23
23
|
const all = getParamMeta('tag', target);
|
|
24
24
|
return all[parameterIndex] ?? new Set();
|
|
25
25
|
};
|
|
26
|
+
export const createComposeParameterDecorator = (...decorators) => (target, propertyKey, parameterIndex) => {
|
|
27
|
+
for (let i = decorators.length - 1; i >= 0; i--) {
|
|
28
|
+
decorators[i](target, propertyKey, parameterIndex);
|
|
29
|
+
}
|
|
30
|
+
};
|
package/esm/provider/Provider.js
CHANGED
|
@@ -4,13 +4,13 @@ import { ProviderDisposedError } from '../errors/ProviderDisposedError.js';
|
|
|
4
4
|
export class Provider {
|
|
5
5
|
resolveDependency;
|
|
6
6
|
static fromClass(Target) {
|
|
7
|
-
return new Provider((
|
|
7
|
+
return new Provider(({ scope, ...options }) => scope.resolve(Target, options));
|
|
8
8
|
}
|
|
9
9
|
static fromValue(value) {
|
|
10
10
|
return new Provider(() => value);
|
|
11
11
|
}
|
|
12
12
|
static fromKey(key) {
|
|
13
|
-
return new Provider((
|
|
13
|
+
return new Provider(({ scope }) => scope.resolve(key));
|
|
14
14
|
}
|
|
15
15
|
argsFnList = [];
|
|
16
16
|
accessRules = [];
|
|
@@ -24,20 +24,21 @@ export class Provider {
|
|
|
24
24
|
constructor(resolveDependency) {
|
|
25
25
|
this.resolveDependency = resolveDependency;
|
|
26
26
|
}
|
|
27
|
-
resolve(
|
|
27
|
+
resolve(options) {
|
|
28
28
|
ProviderDisposedError.assert(!this.isDisposed, 'Provider is already disposed');
|
|
29
29
|
if (!this.getKey) {
|
|
30
|
-
return this.resolveDep(
|
|
30
|
+
return this.resolveDep(options);
|
|
31
31
|
}
|
|
32
32
|
const key = toString(this.getKey(options.args ?? []));
|
|
33
33
|
if (!this.cache.has(key)) {
|
|
34
|
-
this.cache.set(key, this.resolveDep(
|
|
34
|
+
this.cache.set(key, this.resolveDep(options));
|
|
35
35
|
}
|
|
36
36
|
return this.cache.get(key);
|
|
37
37
|
}
|
|
38
|
-
resolveDep(scope,
|
|
39
|
-
let dependency = this.resolveDependency(
|
|
40
|
-
|
|
38
|
+
resolveDep({ scope, args = [], lazy }) {
|
|
39
|
+
let dependency = this.resolveDependency({
|
|
40
|
+
scope,
|
|
41
|
+
args: this.argsFnList.reduce((acc, current) => current({ scope, args: acc }), args),
|
|
41
42
|
lazy: lazy ?? this.isLazy,
|
|
42
43
|
});
|
|
43
44
|
dependency = this.mappers.reduce((acc, current) => current(acc, scope), dependency);
|
|
@@ -28,8 +28,8 @@ export const bindTo = (...tokens) => (r) => {
|
|
|
28
28
|
return r;
|
|
29
29
|
};
|
|
30
30
|
export const scope = (...rules) => (r) => r.when(...rules);
|
|
31
|
-
export const appendArgs = (...extraArgs) => registerPipe((p) => p.addArgsFn((
|
|
32
|
-
export const appendArgsFn = (fn) => registerPipe((p) => p.addArgsFn((
|
|
31
|
+
export const appendArgs = (...extraArgs) => registerPipe((p) => p.addArgsFn(({ args = [] }) => [...args, ...extraArgs]));
|
|
32
|
+
export const appendArgsFn = (fn) => registerPipe((p) => p.addArgsFn((options) => [...(options.args ?? []), ...fn(options)]));
|
|
33
33
|
export const scopeAccess = (rule) => registerPipe((p) => p.addAccessRule(rule));
|
|
34
34
|
export const lazy = () => registerPipe((p) => p.lazy());
|
|
35
35
|
export const autoResolve = () => registerPipe((p) => p.autoResolve());
|
package/esm/select.js
CHANGED
|
@@ -7,7 +7,7 @@ export const select = {
|
|
|
7
7
|
token: toToken,
|
|
8
8
|
instances: (predicate = () => true) => new GroupInstanceToken(predicate),
|
|
9
9
|
scope: {
|
|
10
|
-
current: new FunctionToken((
|
|
11
|
-
create: (options) => new FunctionToken((
|
|
10
|
+
current: new FunctionToken(({ scope }) => scope),
|
|
11
|
+
create: (options) => new FunctionToken(({ scope }) => scope.createScope(options)),
|
|
12
12
|
},
|
|
13
13
|
};
|
package/esm/token/ClassToken.js
CHANGED
|
@@ -14,14 +14,14 @@ export class ClassToken extends InjectionToken {
|
|
|
14
14
|
}
|
|
15
15
|
resolve(s, { args = [], lazy } = {}) {
|
|
16
16
|
return s.resolve(this.target, {
|
|
17
|
-
args: this._getArgsFn(s,
|
|
17
|
+
args: this._getArgsFn({ scope: s, args }),
|
|
18
18
|
lazy: this._isLazy || lazy,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
args(...newArgs) {
|
|
22
22
|
const parentFn = this._getArgsFn;
|
|
23
23
|
return new ClassToken(this.target, {
|
|
24
|
-
getArgsFn: (
|
|
24
|
+
getArgsFn: (options) => [...parentFn(options), ...newArgs],
|
|
25
25
|
isLazy: this._isLazy,
|
|
26
26
|
tags: this.getTags(),
|
|
27
27
|
});
|
|
@@ -29,7 +29,7 @@ export class ClassToken extends InjectionToken {
|
|
|
29
29
|
argsFn(fn) {
|
|
30
30
|
const parentFn = this._getArgsFn;
|
|
31
31
|
return new ClassToken(this.target, {
|
|
32
|
-
getArgsFn: (
|
|
32
|
+
getArgsFn: (options) => [...parentFn(options), ...fn(options.scope)],
|
|
33
33
|
isLazy: this._isLazy,
|
|
34
34
|
tags: this.getTags(),
|
|
35
35
|
});
|
|
@@ -11,15 +11,16 @@ export class FunctionToken extends InjectionToken {
|
|
|
11
11
|
this._isLazy = isLazy;
|
|
12
12
|
}
|
|
13
13
|
resolve(s, { args = [], lazy } = {}) {
|
|
14
|
-
return this.fn(
|
|
15
|
-
|
|
14
|
+
return this.fn({
|
|
15
|
+
scope: s,
|
|
16
|
+
args: this._getArgsFn({ scope: s, args }),
|
|
16
17
|
lazy: this._isLazy || lazy,
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
args(...newArgs) {
|
|
20
21
|
const parentFn = this._getArgsFn;
|
|
21
22
|
return new FunctionToken(this.fn, {
|
|
22
|
-
getArgsFn: (
|
|
23
|
+
getArgsFn: (options) => [...parentFn(options), ...newArgs],
|
|
23
24
|
isLazy: this._isLazy,
|
|
24
25
|
tags: this.getTags(),
|
|
25
26
|
});
|
|
@@ -27,7 +28,7 @@ export class FunctionToken extends InjectionToken {
|
|
|
27
28
|
argsFn(fn) {
|
|
28
29
|
const parentFn = this._getArgsFn;
|
|
29
30
|
return new FunctionToken(this.fn, {
|
|
30
|
-
getArgsFn: (
|
|
31
|
+
getArgsFn: (options) => [...parentFn(options), ...fn(options.scope)],
|
|
31
32
|
isLazy: this._isLazy,
|
|
32
33
|
tags: this.getTags(),
|
|
33
34
|
});
|
|
@@ -14,7 +14,7 @@ export class GroupAliasToken extends InjectionToken {
|
|
|
14
14
|
}
|
|
15
15
|
resolve(s, { args = [], lazy } = {}) {
|
|
16
16
|
return s.resolveByAlias(this.token, {
|
|
17
|
-
args: this._getArgsFn(s,
|
|
17
|
+
args: this._getArgsFn({ scope: s, args }),
|
|
18
18
|
lazy: this._isLazy || lazy,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -24,7 +24,7 @@ export class GroupAliasToken extends InjectionToken {
|
|
|
24
24
|
args(...newArgs) {
|
|
25
25
|
const parentFn = this._getArgsFn;
|
|
26
26
|
return new GroupAliasToken(this.token, {
|
|
27
|
-
getArgsFn: (
|
|
27
|
+
getArgsFn: (options) => [...parentFn(options), ...newArgs],
|
|
28
28
|
isLazy: this._isLazy,
|
|
29
29
|
tags: this.getTags(),
|
|
30
30
|
});
|
|
@@ -32,7 +32,7 @@ export class GroupAliasToken extends InjectionToken {
|
|
|
32
32
|
argsFn(fn) {
|
|
33
33
|
const parentFn = this._getArgsFn;
|
|
34
34
|
return new GroupAliasToken(this.token, {
|
|
35
|
-
getArgsFn: (
|
|
35
|
+
getArgsFn: (options) => [...parentFn(options), ...fn(options.scope)],
|
|
36
36
|
isLazy: this._isLazy,
|
|
37
37
|
tags: this.getTags(),
|
|
38
38
|
});
|
|
@@ -14,7 +14,7 @@ export class SingleAliasToken extends InjectionToken {
|
|
|
14
14
|
}
|
|
15
15
|
resolve(s, { args = [], lazy } = {}) {
|
|
16
16
|
return s.resolveOneByAlias(this.token, {
|
|
17
|
-
args: this._getArgsFn(s,
|
|
17
|
+
args: this._getArgsFn({ scope: s, args }),
|
|
18
18
|
lazy: this._isLazy || lazy,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -24,7 +24,7 @@ export class SingleAliasToken extends InjectionToken {
|
|
|
24
24
|
args(...newArgs) {
|
|
25
25
|
const parentFn = this._getArgsFn;
|
|
26
26
|
return new SingleAliasToken(this.token, {
|
|
27
|
-
getArgsFn: (
|
|
27
|
+
getArgsFn: (options) => [...parentFn(options), ...newArgs],
|
|
28
28
|
isLazy: this._isLazy,
|
|
29
29
|
tags: this.getTags(),
|
|
30
30
|
});
|
|
@@ -32,7 +32,7 @@ export class SingleAliasToken extends InjectionToken {
|
|
|
32
32
|
argsFn(fn) {
|
|
33
33
|
const parentFn = this._getArgsFn;
|
|
34
34
|
return new SingleAliasToken(this.token, {
|
|
35
|
-
getArgsFn: (
|
|
35
|
+
getArgsFn: (options) => [...parentFn(options), ...fn(options.scope)],
|
|
36
36
|
isLazy: this._isLazy,
|
|
37
37
|
tags: this.getTags(),
|
|
38
38
|
});
|
package/esm/token/SingleToken.js
CHANGED
|
@@ -14,7 +14,7 @@ export class SingleToken extends InjectionToken {
|
|
|
14
14
|
}
|
|
15
15
|
resolve(s, { args = [], lazy } = {}) {
|
|
16
16
|
return s.resolve(this.token, {
|
|
17
|
-
args: this._getArgsFn(s,
|
|
17
|
+
args: this._getArgsFn({ scope: s, args }),
|
|
18
18
|
lazy: this._isLazy || lazy,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -24,7 +24,7 @@ export class SingleToken extends InjectionToken {
|
|
|
24
24
|
args(...newArgs) {
|
|
25
25
|
const parentFn = this._getArgsFn;
|
|
26
26
|
return new SingleToken(this.token, {
|
|
27
|
-
getArgsFn: (
|
|
27
|
+
getArgsFn: (options) => [...parentFn(options), ...newArgs],
|
|
28
28
|
isLazy: this._isLazy,
|
|
29
29
|
tags: this.getTags(),
|
|
30
30
|
});
|
|
@@ -32,7 +32,7 @@ export class SingleToken extends InjectionToken {
|
|
|
32
32
|
argsFn(fn) {
|
|
33
33
|
const parentFn = this._getArgsFn;
|
|
34
34
|
return new SingleToken(this.token, {
|
|
35
|
-
getArgsFn: (
|
|
35
|
+
getArgsFn: (options) => [...parentFn(options), ...fn(options.scope)],
|
|
36
36
|
isLazy: this._isLazy,
|
|
37
37
|
tags: this.getTags(),
|
|
38
38
|
});
|
package/esm/token/toToken.js
CHANGED
|
@@ -6,7 +6,6 @@ import { UnsupportedTokenTypeError } from '../errors/UnsupportedTokenTypeError.j
|
|
|
6
6
|
import { InjectionToken, isInjectionToken } from './InjectionToken.js';
|
|
7
7
|
import { Is } from '../utils/basic.js';
|
|
8
8
|
import { ConstantToken } from './ConstantToken.js';
|
|
9
|
-
import { pipe } from '../utils/fp.js';
|
|
10
9
|
export const toToken = (token) => {
|
|
11
10
|
if (token instanceof InjectionToken) {
|
|
12
11
|
return token;
|
|
@@ -23,8 +22,3 @@ export const toToken = (token) => {
|
|
|
23
22
|
throw new UnsupportedTokenTypeError(`Unknown token ${token}`);
|
|
24
23
|
};
|
|
25
24
|
export const argToToken = (v) => (isInjectionToken(v) ? v : new ConstantToken(v));
|
|
26
|
-
export const toMappedToken = (token, mappers) => {
|
|
27
|
-
const source = toToken(token);
|
|
28
|
-
const mapInstance = pipe(...mappers);
|
|
29
|
-
return new FunctionToken((scope, options) => mapInstance(source.resolve(scope, options)));
|
|
30
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "72.1.0",
|
|
4
4
|
"description": "Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IProvider,
|
|
1
|
+
import { type IProvider, ResolveOptions } from '../provider/IProvider.js';
|
|
2
2
|
import { type IRegistration } from '../registration/IRegistration.js';
|
|
3
3
|
import { IInjector, type WithArgs } from '../injector/IInjector.js';
|
|
4
4
|
import { type constructor, Instance } from '../utils/basic.js';
|
|
@@ -19,7 +19,7 @@ export interface Tagged {
|
|
|
19
19
|
hasTag(tag: Tag): boolean;
|
|
20
20
|
addTags(...tags: Tag[]): void;
|
|
21
21
|
}
|
|
22
|
-
export type ResolveOneOptions =
|
|
22
|
+
export type ResolveOneOptions = ResolveOptions & Partial<WithChild>;
|
|
23
23
|
export type ResolveManyOptions = ResolveOneOptions & Partial<WithExcludedKeys>;
|
|
24
24
|
export interface Resolvable {
|
|
25
25
|
resolve<T>(key: constructor<T> | DependencyKey, options?: ResolveOneOptions): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IContainer } from '../container/IContainer.js';
|
|
2
|
-
import { InjectionToken } from '../token/InjectionToken.js';
|
|
3
2
|
import { type Instance } from '../utils/basic.js';
|
|
3
|
+
import { type InjectFn } from './hook.js';
|
|
4
4
|
export interface IHookContext {
|
|
5
5
|
instance: Instance;
|
|
6
6
|
scope: IContainer;
|
|
@@ -9,7 +9,7 @@ export interface IHookContext {
|
|
|
9
9
|
invokeMethod(options?: {
|
|
10
10
|
args?: unknown[];
|
|
11
11
|
}): unknown;
|
|
12
|
-
setProperty(fn:
|
|
12
|
+
setProperty(fn: InjectFn): void;
|
|
13
13
|
getProperty(): unknown;
|
|
14
14
|
setInitialArgs(...args: unknown[]): this;
|
|
15
15
|
getInitialArgs(): unknown[];
|
|
@@ -24,7 +24,7 @@ export declare class HookContext implements IHookContext {
|
|
|
24
24
|
invokeMethod({ args }?: {
|
|
25
25
|
args?: unknown[];
|
|
26
26
|
}): unknown;
|
|
27
|
-
setProperty(fn:
|
|
27
|
+
setProperty(fn: InjectFn): void;
|
|
28
28
|
getProperty(): unknown;
|
|
29
29
|
setInitialArgs(...args: unknown[]): this;
|
|
30
30
|
getInitialArgs(): unknown[];
|
package/typings/hooks/hook.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type IHookContext } from './HookContext.js';
|
|
2
|
-
import type { IContainer } from '../container/IContainer.js';
|
|
3
2
|
import { type constructor, type Instance } from '../utils/basic.js';
|
|
4
3
|
import { ProviderOptions } from '../provider/IProvider.js';
|
|
5
|
-
export type InjectFn<T = unknown> = (
|
|
4
|
+
export type InjectFn<T = unknown> = (options: ProviderOptions) => T;
|
|
6
5
|
export type HookFn<T extends IHookContext = IHookContext> = (context: T) => void | Promise<void>;
|
|
7
6
|
export interface HookClass<T extends IHookContext = IHookContext> {
|
|
8
7
|
execute(context: Omit<T, 'scope'>): void | Promise<void>;
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
import { HookFn } from './hook.js';
|
|
2
|
-
|
|
3
|
-
import { type MapFn } from '../utils/fp.js';
|
|
4
|
-
export declare function injectProp<T, B>(fn: Injectable<T>, fn1: MapFn<T, B>): HookFn;
|
|
5
|
-
export declare function injectProp<T, B, C>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>): HookFn;
|
|
6
|
-
export declare function injectProp<T, B, C, D>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>): HookFn;
|
|
7
|
-
export declare function injectProp<T, B, C, D, E>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>): HookFn;
|
|
8
|
-
export declare function injectProp<T, B, C, D, E, F>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>): HookFn;
|
|
9
|
-
export declare function injectProp<T, B, C, D, E, F, G>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>): HookFn;
|
|
10
|
-
export declare function injectProp<T, B, C, D, E, F, G, H>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>): HookFn;
|
|
11
|
-
export declare function injectProp<T, B, C, D, E, F, G, H, I>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>, fn8: MapFn<H, I>): HookFn;
|
|
12
|
-
export declare function injectProp<T, B, C, D, E, F, G, H, I, J>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>, fn8: MapFn<H, I>, fn9: MapFn<I, J>): HookFn;
|
|
13
|
-
export declare function injectProp<T, B, C, D, E, F, G, H, I, J, K>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>, fn8: MapFn<H, I>, fn9: MapFn<I, J>, fn10: MapFn<J, K>): HookFn;
|
|
14
|
-
export declare function injectProp<T>(fn: Injectable<T>, ...mappers: MapFn<T>[]): HookFn;
|
|
1
|
+
import { HookFn, InjectFn } from './hook.js';
|
|
2
|
+
export declare const injectProp: <T>(fn: InjectFn<T>) => HookFn;
|
package/typings/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ export { type IContainer, type Resolvable, type IContainerModule, type Dependenc
|
|
|
2
2
|
export { Container } from './container/Container.js';
|
|
3
3
|
export { AutoResolveModule } from './container/AutoResolveModule.js';
|
|
4
4
|
export { EmptyContainer } from './container/EmptyContainer.js';
|
|
5
|
-
export { type IInjector, type InjectOptions, type IInjectFnResolver, type IInjectorModule, type InjectorHook, Injector, } from './injector/IInjector.js';
|
|
6
|
-
export { MetadataInjector, inject, arg, args, argsFn, resolveArgs } from './injector/MetadataInjector.js';
|
|
5
|
+
export { type IInjector, type InjectOptions, type WithScope, type WithArgs, type IInjectFnResolver, type IInjectorModule, type InjectorHook, Injector, } from './injector/IInjector.js';
|
|
6
|
+
export { MetadataInjector, inject, arg, args, argsFn, by, resolveArgs } from './injector/MetadataInjector.js';
|
|
7
7
|
export { SimpleInjector } from './injector/SimpleInjector.js';
|
|
8
8
|
export { ProxyInjector } from './injector/ProxyInjector.js';
|
|
9
|
-
export { type ResolveDependency, type IProvider, type DecorateFn, type ArgsFn, type ProviderOptions, type GetCacheKey, type ScopeAccessOptions, type ScopeAccessRule, type ProviderHook, } from './provider/IProvider.js';
|
|
9
|
+
export { type ResolveDependency, type IProvider, type DecorateFn, type ArgsFn, type ProviderOptions, type ResolveOptions, type GetCacheKey, type ScopeAccessOptions, type ScopeAccessRule, type ProviderHook, } from './provider/IProvider.js';
|
|
10
10
|
export { Provider } from './provider/Provider.js';
|
|
11
11
|
export { type IRegistration, type ReturnTypeOfRegistration, type ScopeMatchRule, type ProviderPipe, type Bindable, type ProviderMapper, type RegistrationMapper, isProviderPipe, registerPipe, toBindToken, toProviderFn, toRegistrationFn, register, bindTo, scope, scopeAccess, lazy, autoResolve, singleton, decorate, appendArgs, appendArgsFn, onResolve, } from './registration/IRegistration.js';
|
|
12
12
|
export { Registration } from './registration/Registration.js';
|
|
@@ -27,7 +27,7 @@ export { injectProp } from './hooks/injectProp.js';
|
|
|
27
27
|
export { sequential, parallel, oncePerInstance, type ResolvedObjectHook } from './hooks/combinators.js';
|
|
28
28
|
export { HookCollector, toTask, type HookAction, type HookCollectionContext, type HookCollectorOptions, type HookCollectorProps, type MapHookExecutionContext, } from './hooks/HookCollector.js';
|
|
29
29
|
export { InjectionToken, isInjectionToken, forwardArgs } from './token/InjectionToken.js';
|
|
30
|
-
export { type Injectable, toToken,
|
|
30
|
+
export { type Injectable, toToken, argToToken } from './token/toToken.js';
|
|
31
31
|
export { GroupAliasToken, toGroupAlias } from './token/GroupAliasToken.js';
|
|
32
32
|
export { SingleAliasToken, toSingleAlias } from './token/SingleAliasToken.js';
|
|
33
33
|
export { ClassToken } from './token/ClassToken.js';
|
|
@@ -36,9 +36,9 @@ export { FunctionToken } from './token/FunctionToken.js';
|
|
|
36
36
|
export { ConstantToken } from './token/ConstantToken.js';
|
|
37
37
|
export { type InstancePredicate, GroupInstanceToken } from './token/GroupInstanceToken.js';
|
|
38
38
|
export { resolveConstructor } from './metadata/target.js';
|
|
39
|
-
export { addClassMeta, getClassMeta, addClassLabel, getClassLabels, addClassTag, getClassTags } from './metadata/class.js';
|
|
40
|
-
export { addParamMeta, getParamMeta, addParamLabel, getParamLabels, addParamTag, getParamTags, } from './metadata/parameter.js';
|
|
41
|
-
export { addMethodMeta, getMethodMeta, addMethodLabel, getMethodLabels, addMethodTag, getMethodTags, } from './metadata/method.js';
|
|
39
|
+
export { addClassMeta, getClassMeta, addClassLabel, getClassLabels, addClassTag, getClassTags, createComposeClassDecorator, } from './metadata/class.js';
|
|
40
|
+
export { addParamMeta, getParamMeta, addParamLabel, getParamLabels, addParamTag, getParamTags, createComposeParameterDecorator, } from './metadata/parameter.js';
|
|
41
|
+
export { addMethodMeta, getMethodMeta, addMethodLabel, getMethodLabels, addMethodTag, getMethodTags, createComposeMethodDecorator, } from './metadata/method.js';
|
|
42
42
|
export { handleError, handleAsyncError, type HandleErrorParams } from './utils/errorHandler.js';
|
|
43
43
|
export { runInOrder, runAtOnce, type Task } from './utils/task.js';
|
|
44
44
|
export { throttle } from './utils/throttle.js';
|
|
@@ -2,13 +2,16 @@ import { type IContainer, ResolveOneOptions } from '../container/IContainer.js';
|
|
|
2
2
|
import { ProviderOptions } from '../provider/IProvider.js';
|
|
3
3
|
import { type IProxyRegistry } from '../utils/ProxyRegistry.js';
|
|
4
4
|
import { type constructor, Instance } from '../utils/basic.js';
|
|
5
|
+
export type WithScope = {
|
|
6
|
+
scope: IContainer;
|
|
7
|
+
};
|
|
5
8
|
export type WithArgs = {
|
|
6
9
|
args: unknown[];
|
|
7
10
|
};
|
|
8
|
-
export type InjectOptions = Partial<WithArgs>;
|
|
11
|
+
export type InjectOptions = WithScope & Partial<WithArgs>;
|
|
9
12
|
export type InjectorHook = (instance: Instance, scope: IContainer) => void;
|
|
10
13
|
export interface IInjector {
|
|
11
|
-
resolve<T>(
|
|
14
|
+
resolve<T>(Target: constructor<T>, options: ProviderOptions): T;
|
|
12
15
|
onConstructed(...hooks: InjectorHook[]): this;
|
|
13
16
|
}
|
|
14
17
|
export interface IInjectorModule {
|
|
@@ -21,8 +24,8 @@ export declare abstract class Injector {
|
|
|
21
24
|
private readonly proxyRegistry;
|
|
22
25
|
private readonly onConstructedHookList;
|
|
23
26
|
constructor(proxyRegistry?: IProxyRegistry);
|
|
24
|
-
resolve<T>(
|
|
27
|
+
resolve<T>(Target: constructor<T>, { scope, args, lazy }: ProviderOptions): T;
|
|
25
28
|
onConstructed(...hooks: InjectorHook[]): this;
|
|
26
29
|
useModule(module: IInjectorModule): this;
|
|
27
|
-
protected abstract createInstance<T>(
|
|
30
|
+
protected abstract createInstance<T>(Target: constructor<T>, options: InjectOptions): T;
|
|
28
31
|
}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import { IInjector, InjectOptions, Injector } from './IInjector.js';
|
|
2
|
-
import type { IContainer } from '../container/IContainer.js';
|
|
3
2
|
import { type constructor, type Instance } from '../utils/basic.js';
|
|
4
3
|
import { ProviderOptions } from '../provider/IProvider.js';
|
|
5
|
-
import { type Injectable } from '../token/toToken.js';
|
|
6
4
|
import { InjectFn } from '../hooks/hook.js';
|
|
7
|
-
import { type
|
|
5
|
+
import { type DependencyKey } from '../container/IContainer.js';
|
|
6
|
+
import { type InjectionToken } from '../token/InjectionToken.js';
|
|
8
7
|
export declare class MetadataInjector extends Injector implements IInjector {
|
|
9
|
-
protected createInstance<T>(
|
|
8
|
+
protected createInstance<T>(Target: constructor<T>, { scope, args: deps }: InjectOptions): T;
|
|
10
9
|
}
|
|
11
|
-
export declare function inject<T
|
|
12
|
-
export declare
|
|
13
|
-
export declare function inject<T, B, C, D>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>): ParameterDecorator;
|
|
14
|
-
export declare function inject<T, B, C, D, E>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>): ParameterDecorator;
|
|
15
|
-
export declare function inject<T, B, C, D, E, F>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>): ParameterDecorator;
|
|
16
|
-
export declare function inject<T, B, C, D, E, F, G>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>): ParameterDecorator;
|
|
17
|
-
export declare function inject<T, B, C, D, E, F, G, H>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>): ParameterDecorator;
|
|
18
|
-
export declare function inject<T, B, C, D, E, F, G, H, I>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>, fn8: MapFn<H, I>): ParameterDecorator;
|
|
19
|
-
export declare function inject<T, B, C, D, E, F, G, H, I, J>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>, fn8: MapFn<H, I>, fn9: MapFn<I, J>): ParameterDecorator;
|
|
20
|
-
export declare function inject<T, B, C, D, E, F, G, H, I, J, K>(fn: Injectable<T>, fn1: MapFn<T, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>, fn7: MapFn<G, H>, fn8: MapFn<H, I>, fn9: MapFn<I, J>, fn10: MapFn<J, K>): ParameterDecorator;
|
|
21
|
-
export declare function inject<T>(fn: Injectable<T>, ...mappers: MapFn<T>[]): ParameterDecorator;
|
|
10
|
+
export declare function inject<T>(fn: InjectFn<T>): ParameterDecorator;
|
|
11
|
+
export declare const by: <T>(target: InjectionToken<T> | DependencyKey | constructor<T>) => InjectFn<T>;
|
|
22
12
|
export declare const argsFn: <T = unknown>(predicate: (value: unknown, index: number) => boolean) => InjectFn<T>;
|
|
23
13
|
export declare const arg: <T = unknown>(index: number) => InjectFn<T>;
|
|
24
14
|
export declare const args: InjectFn<unknown[]>;
|
|
25
|
-
export declare const resolveArgs: (target: constructor<unknown> | Instance, methodName?: string) => (
|
|
15
|
+
export declare const resolveArgs: (target: constructor<unknown> | Instance, methodName?: string) => (options: ProviderOptions) => unknown[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IInjector, InjectOptions, Injector } from './IInjector.js';
|
|
2
|
-
import type { IContainer } from '../container/IContainer.js';
|
|
3
2
|
import { type constructor } from '../utils/basic.js';
|
|
4
3
|
export declare class ProxyInjector extends Injector implements IInjector {
|
|
5
|
-
protected createInstance<T>(
|
|
4
|
+
protected createInstance<T>(Target: constructor<T>, { scope, args }: InjectOptions): T;
|
|
6
5
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IInjector, InjectOptions, Injector } from './IInjector.js';
|
|
2
|
-
import type { IContainer } from '../container/IContainer.js';
|
|
3
2
|
import { type constructor } from '../utils/basic.js';
|
|
4
3
|
export declare class SimpleInjector extends Injector implements IInjector {
|
|
5
|
-
protected createInstance<T>(
|
|
4
|
+
protected createInstance<T>(Target: constructor<T>, { scope, args }: InjectOptions): T;
|
|
6
5
|
}
|
|
@@ -4,3 +4,4 @@ export declare const addClassLabel: (key: string, label: string) => ClassDecorat
|
|
|
4
4
|
export declare const getClassLabels: (target: object) => Map<string, string>;
|
|
5
5
|
export declare const addClassTag: (tag: string) => ClassDecorator;
|
|
6
6
|
export declare const getClassTags: (target: object) => Set<string>;
|
|
7
|
+
export declare const createComposeClassDecorator: (...decorators: ClassDecorator[]) => ClassDecorator;
|
|
@@ -4,3 +4,4 @@ export declare const addMethodLabel: (key: string, label: string) => MethodDecor
|
|
|
4
4
|
export declare const getMethodLabels: (target: object, propertyKey: string) => Map<string, string>;
|
|
5
5
|
export declare const addMethodTag: (tag: string) => MethodDecorator;
|
|
6
6
|
export declare const getMethodTags: (target: object, propertyKey: string) => Set<string>;
|
|
7
|
+
export declare const createComposeMethodDecorator: (...decorators: MethodDecorator[]) => MethodDecorator;
|
|
@@ -4,3 +4,4 @@ export declare const addParamLabel: (key: string, label: string) => ParameterDec
|
|
|
4
4
|
export declare const getParamLabels: (target: object, parameterIndex: number) => Map<string, string>;
|
|
5
5
|
export declare const addParamTag: (tag: string) => ParameterDecorator;
|
|
6
6
|
export declare const getParamTags: (target: object, parameterIndex: number) => Set<string>;
|
|
7
|
+
export declare const createComposeParameterDecorator: (...decorators: ParameterDecorator[]) => ParameterDecorator;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { IContainer, Tagged } from '../container/IContainer.js';
|
|
2
|
-
import { InjectOptions } from '../injector/IInjector.js';
|
|
2
|
+
import { InjectOptions, WithScope } from '../injector/IInjector.js';
|
|
3
3
|
import { Serializable } from '../utils/basic.js';
|
|
4
4
|
export type WithLazy = {
|
|
5
5
|
lazy: boolean;
|
|
6
6
|
};
|
|
7
7
|
export type ProviderOptions = InjectOptions & Partial<WithLazy>;
|
|
8
|
-
export type
|
|
8
|
+
export type ResolveOptions = Omit<ProviderOptions, keyof WithScope>;
|
|
9
|
+
export type ResolveDependency<T = unknown> = (options: ProviderOptions) => T;
|
|
9
10
|
export type ScopeAccessOptions = {
|
|
10
11
|
invocationScope: Tagged;
|
|
11
12
|
providerScope: Tagged;
|
|
12
13
|
args: unknown[];
|
|
13
14
|
};
|
|
14
15
|
export type ScopeAccessRule = (options: ScopeAccessOptions, prev: boolean) => boolean;
|
|
15
|
-
export type ArgsFn = (
|
|
16
|
+
export type ArgsFn = (options: InjectOptions) => unknown[];
|
|
16
17
|
export type GetCacheKey = (args: unknown[]) => string | Serializable;
|
|
17
18
|
export type DecorateFn<Instance = any> = (dep: Instance, scope: IContainer) => Instance;
|
|
18
19
|
export type ProviderHook = (dependency: unknown, scope: IContainer) => void;
|
|
19
20
|
export interface IProvider<T = any> {
|
|
20
|
-
resolve(
|
|
21
|
+
resolve(options: ProviderOptions): T;
|
|
21
22
|
hasAccess(options: ScopeAccessOptions): boolean;
|
|
22
23
|
map(...mappers: DecorateFn<T>[]): this;
|
|
23
24
|
addAccessRule(...rules: ScopeAccessRule[]): this;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ArgsFn, type DecorateFn, type GetCacheKey, type IProvider, type ProviderOptions, type ResolveDependency, type ScopeAccessOptions, type ScopeAccessRule, type ProviderHook } from './IProvider.js';
|
|
2
|
-
import type { DependencyKey
|
|
2
|
+
import type { DependencyKey } from '../container/IContainer.js';
|
|
3
3
|
import { type constructor } from '../utils/basic.js';
|
|
4
4
|
export declare class Provider<T = any> implements IProvider<T> {
|
|
5
5
|
private readonly resolveDependency;
|
|
@@ -16,7 +16,7 @@ export declare class Provider<T = any> implements IProvider<T> {
|
|
|
16
16
|
private isDisposed;
|
|
17
17
|
private readonly onResolvedHookList;
|
|
18
18
|
constructor(resolveDependency: ResolveDependency<T>);
|
|
19
|
-
resolve(
|
|
19
|
+
resolve(options: ProviderOptions): T;
|
|
20
20
|
private resolveDep;
|
|
21
21
|
map(...mappers: DecorateFn<T>[]): this;
|
|
22
22
|
addAccessRule(...rules: ScopeAccessRule[]): this;
|
package/typings/select.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreateScopeOptions
|
|
1
|
+
import { type CreateScopeOptions } from './container/IContainer.js';
|
|
2
2
|
import { FunctionToken } from './token/FunctionToken.js';
|
|
3
3
|
import { GroupInstanceToken, InstancePredicate } from './token/GroupInstanceToken.js';
|
|
4
4
|
export declare const select: {
|
|
@@ -6,7 +6,7 @@ export declare const select: {
|
|
|
6
6
|
token: <T = any>(token: import("./token/toToken.js").Injectable<T>) => import(".").InjectionToken<T>;
|
|
7
7
|
instances: (predicate?: InstancePredicate) => GroupInstanceToken;
|
|
8
8
|
scope: {
|
|
9
|
-
current: FunctionToken<IContainer>;
|
|
10
|
-
create: (options: CreateScopeOptions) => FunctionToken<IContainer>;
|
|
9
|
+
current: FunctionToken<import("./container/IContainer.js").IContainer>;
|
|
10
|
+
create: (options: CreateScopeOptions) => FunctionToken<import("./container/IContainer.js").IContainer>;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IContainer } from '../container/IContainer.js';
|
|
2
2
|
import { InjectionToken } from './InjectionToken.js';
|
|
3
3
|
import { type constructor, Serializable } from '../utils/basic.js';
|
|
4
|
-
import { ArgsFn,
|
|
4
|
+
import { ArgsFn, ResolveOptions } from '../provider/IProvider.js';
|
|
5
5
|
export declare class ClassToken<T = any> extends InjectionToken<T> implements Serializable {
|
|
6
6
|
private readonly target;
|
|
7
7
|
private readonly _getArgsFn;
|
|
@@ -12,7 +12,7 @@ export declare class ClassToken<T = any> extends InjectionToken<T> implements Se
|
|
|
12
12
|
tags?: string[];
|
|
13
13
|
});
|
|
14
14
|
select<R>(fn: (target: T) => R): (s: IContainer) => R;
|
|
15
|
-
resolve(s: IContainer, { args, lazy }?:
|
|
15
|
+
resolve(s: IContainer, { args, lazy }?: ResolveOptions): T;
|
|
16
16
|
args(...newArgs: unknown[]): ClassToken<T>;
|
|
17
17
|
argsFn(fn: (s: IContainer) => unknown[]): ClassToken<T>;
|
|
18
18
|
lazy(): ClassToken<T>;
|