ts-ioc-container 56.1.0 → 56.2.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/cjm/ExecutionContext.js +2 -0
- package/cjm/container/AliasMap.js +25 -0
- package/cjm/container/Container.js +175 -0
- package/cjm/container/EmptyContainer.js +71 -0
- package/cjm/container/IContainer.js +6 -0
- package/cjm/errors/CannonSingletonApplyTwiceError.js +17 -0
- package/cjm/errors/ContainerDisposedError.js +12 -0
- package/cjm/errors/ContainerError.js +11 -0
- package/cjm/errors/ContainerNotFoundError.js +12 -0
- package/cjm/errors/DependencyMissingKeyError.js +12 -0
- package/cjm/errors/DependencyNotFoundError.js +12 -0
- package/cjm/errors/MethodNotImplementedError.js +12 -0
- package/cjm/errors/ProviderDisposedError.js +17 -0
- package/cjm/errors/UnexpectedHookResultError.js +12 -0
- package/cjm/errors/UnsupportedTokenTypeError.js +12 -0
- package/cjm/hooks/HookContext.js +42 -0
- package/cjm/hooks/HooksRunner.js +42 -0
- package/cjm/hooks/hook.js +55 -0
- package/cjm/hooks/injectProp.js +6 -0
- package/cjm/hooks/onConstruct.js +28 -0
- package/cjm/hooks/onConstructAsync.js +28 -0
- package/cjm/hooks/onContainerDisposed.js +18 -0
- package/cjm/index.js +141 -0
- package/cjm/injector/IInjector.js +14 -0
- package/cjm/injector/MetadataInjector.js +33 -0
- package/cjm/injector/ProxyInjector.js +18 -0
- package/cjm/injector/SimpleInjector.js +10 -0
- package/cjm/metadata/class.js +21 -0
- package/cjm/metadata/method.js +19 -0
- package/cjm/metadata/parameter.js +34 -0
- package/cjm/provider/IProvider.js +2 -0
- package/cjm/provider/Provider.js +80 -0
- package/cjm/registration/IRegistration.js +50 -0
- package/cjm/registration/Registration.js +85 -0
- package/cjm/select.js +16 -0
- package/cjm/token/BindToken.js +7 -0
- package/cjm/token/ClassToken.js +45 -0
- package/cjm/token/ConstantToken.js +25 -0
- package/cjm/token/FunctionToken.js +42 -0
- package/cjm/token/GroupAliasToken.js +50 -0
- package/cjm/token/GroupInstanceToken.js +33 -0
- package/cjm/token/InjectionToken.js +11 -0
- package/cjm/token/SingleAliasToken.js +50 -0
- package/cjm/token/SingleToken.js +48 -0
- package/cjm/token/toToken.js +29 -0
- package/cjm/utils/array.js +9 -0
- package/cjm/utils/basic.js +13 -0
- package/cjm/utils/debounce.js +16 -0
- package/cjm/utils/errorHandler.js +29 -0
- package/cjm/utils/fp.js +6 -0
- package/cjm/utils/once.js +20 -0
- package/cjm/utils/promise.js +5 -0
- package/cjm/utils/proxy.js +39 -0
- package/cjm/utils/shallowCache.js +23 -0
- package/cjm/utils/throttle.js +18 -0
- package/esm/ExecutionContext.js +1 -0
- package/esm/container/AliasMap.js +21 -0
- package/esm/container/Container.js +171 -0
- package/esm/container/EmptyContainer.js +67 -0
- package/esm/container/IContainer.js +3 -0
- package/esm/errors/CannonSingletonApplyTwiceError.js +13 -0
- package/esm/errors/ContainerDisposedError.js +8 -0
- package/esm/errors/ContainerError.js +7 -0
- package/esm/errors/ContainerNotFoundError.js +8 -0
- package/esm/errors/DependencyMissingKeyError.js +8 -0
- package/esm/errors/DependencyNotFoundError.js +8 -0
- package/esm/errors/MethodNotImplementedError.js +8 -0
- package/esm/errors/ProviderDisposedError.js +13 -0
- package/esm/errors/UnexpectedHookResultError.js +8 -0
- package/esm/errors/UnsupportedTokenTypeError.js +8 -0
- package/esm/hooks/HookContext.js +36 -0
- package/esm/hooks/HooksRunner.js +38 -0
- package/esm/hooks/hook.js +46 -0
- package/esm/hooks/injectProp.js +2 -0
- package/esm/hooks/onConstruct.js +23 -0
- package/esm/hooks/onConstructAsync.js +23 -0
- package/esm/hooks/onContainerDisposed.js +13 -0
- package/esm/index.js +46 -0
- package/esm/injector/IInjector.js +10 -0
- package/esm/injector/MetadataInjector.js +25 -0
- package/esm/injector/ProxyInjector.js +14 -0
- package/esm/injector/SimpleInjector.js +6 -0
- package/esm/metadata/class.js +12 -0
- package/esm/metadata/method.js +10 -0
- package/esm/metadata/parameter.js +25 -0
- package/esm/package.json +3 -0
- package/esm/provider/IProvider.js +1 -0
- package/esm/provider/Provider.js +76 -0
- package/esm/registration/IRegistration.js +35 -0
- package/esm/registration/Registration.js +81 -0
- package/esm/select.js +13 -0
- package/esm/token/BindToken.js +4 -0
- package/esm/token/ClassToken.js +41 -0
- package/esm/token/ConstantToken.js +21 -0
- package/esm/token/FunctionToken.js +38 -0
- package/esm/token/GroupAliasToken.js +45 -0
- package/esm/token/GroupInstanceToken.js +29 -0
- package/esm/token/InjectionToken.js +6 -0
- package/esm/token/SingleAliasToken.js +45 -0
- package/esm/token/SingleToken.js +44 -0
- package/esm/token/toToken.js +24 -0
- package/esm/utils/array.js +6 -0
- package/esm/utils/basic.js +9 -0
- package/esm/utils/debounce.js +12 -0
- package/esm/utils/errorHandler.js +24 -0
- package/esm/utils/fp.js +3 -0
- package/esm/utils/once.js +16 -0
- package/esm/utils/promise.js +1 -0
- package/esm/utils/proxy.js +33 -0
- package/esm/utils/shallowCache.js +19 -0
- package/esm/utils/throttle.js +14 -0
- package/package.json +1 -1
- package/typings/ExecutionContext.d.ts +4 -0
- package/typings/container/AliasMap.d.ts +8 -0
- package/typings/container/Container.d.ts +48 -0
- package/typings/container/EmptyContainer.d.ts +30 -0
- package/typings/container/IContainer.d.ts +56 -0
- package/typings/errors/CannonSingletonApplyTwiceError.d.ts +6 -0
- package/typings/errors/ContainerDisposedError.d.ts +5 -0
- package/typings/errors/ContainerError.d.ts +4 -0
- package/typings/errors/ContainerNotFoundError.d.ts +5 -0
- package/typings/errors/DependencyMissingKeyError.d.ts +5 -0
- package/typings/errors/DependencyNotFoundError.d.ts +5 -0
- package/typings/errors/MethodNotImplementedError.d.ts +5 -0
- package/typings/errors/ProviderDisposedError.d.ts +6 -0
- package/typings/errors/UnexpectedHookResultError.d.ts +5 -0
- package/typings/errors/UnsupportedTokenTypeError.d.ts +5 -0
- package/typings/hooks/HookContext.d.ts +35 -0
- package/typings/hooks/HooksRunner.d.ts +16 -0
- package/typings/hooks/hook.d.ts +20 -0
- package/typings/hooks/injectProp.d.ts +5 -0
- package/typings/hooks/onConstruct.d.ts +14 -0
- package/typings/hooks/onConstructAsync.d.ts +11 -0
- package/typings/hooks/onContainerDisposed.d.ts +9 -0
- package/typings/index.d.ts +48 -0
- package/typings/injector/IInjector.d.ts +17 -0
- package/typings/injector/MetadataInjector.d.ts +13 -0
- package/typings/injector/ProxyInjector.d.ts +6 -0
- package/typings/injector/SimpleInjector.d.ts +6 -0
- package/typings/metadata/class.d.ts +6 -0
- package/typings/metadata/method.d.ts +6 -0
- package/typings/metadata/parameter.d.ts +6 -0
- package/typings/provider/IProvider.d.ts +26 -0
- package/typings/provider/Provider.d.ts +26 -0
- package/typings/registration/IRegistration.d.ts +31 -0
- package/typings/registration/Registration.d.ts +28 -0
- package/typings/select.d.ts +12 -0
- package/typings/token/BindToken.d.ts +5 -0
- package/typings/token/ClassToken.d.ts +18 -0
- package/typings/token/ConstantToken.d.ts +10 -0
- package/typings/token/FunctionToken.d.ts +17 -0
- package/typings/token/GroupAliasToken.d.ts +21 -0
- package/typings/token/GroupInstanceToken.d.ts +15 -0
- package/typings/token/InjectionToken.d.ts +9 -0
- package/typings/token/SingleAliasToken.d.ts +21 -0
- package/typings/token/SingleToken.d.ts +19 -0
- package/typings/token/toToken.d.ts +6 -0
- package/typings/utils/array.d.ts +3 -0
- package/typings/utils/basic.d.ts +11 -0
- package/typings/utils/debounce.d.ts +1 -0
- package/typings/utils/errorHandler.d.ts +6 -0
- package/typings/utils/fp.d.ts +13 -0
- package/typings/utils/once.d.ts +8 -0
- package/typings/utils/promise.d.ts +1 -0
- package/typings/utils/proxy.d.ts +4 -0
- package/typings/utils/shallowCache.d.ts +1 -0
- package/typings/utils/throttle.d.ts +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DependencyKey, IContainer, ResolveOneOptions } from '../container/IContainer.js';
|
|
2
|
+
import { InjectionToken } from './InjectionToken.js';
|
|
3
|
+
import { IRegistration } from '../registration/IRegistration.js';
|
|
4
|
+
import { BindToken } from './BindToken.js';
|
|
5
|
+
import { ArgsFn } from '../provider/IProvider.js';
|
|
6
|
+
export declare class SingleAliasToken<T = any> extends InjectionToken<T> implements BindToken<T> {
|
|
7
|
+
readonly token: DependencyKey;
|
|
8
|
+
private readonly _getArgsFn;
|
|
9
|
+
private readonly _isLazy;
|
|
10
|
+
constructor(token: DependencyKey, { getArgsFn, isLazy }?: {
|
|
11
|
+
getArgsFn?: ArgsFn;
|
|
12
|
+
isLazy?: boolean;
|
|
13
|
+
});
|
|
14
|
+
select<R>(fn: (target: T) => R): (s: IContainer) => R;
|
|
15
|
+
resolve(s: IContainer, { args, lazy }?: ResolveOneOptions): T;
|
|
16
|
+
bindTo(r: IRegistration<T>): void;
|
|
17
|
+
args(...newArgs: unknown[]): SingleAliasToken<T>;
|
|
18
|
+
argsFn(fn: (s: IContainer) => unknown[]): SingleAliasToken<T>;
|
|
19
|
+
lazy(): SingleAliasToken<T>;
|
|
20
|
+
}
|
|
21
|
+
export declare const toSingleAlias: <T>(token: DependencyKey) => SingleAliasToken<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DependencyKey, IContainer } from '../container/IContainer.js';
|
|
2
|
+
import { InjectionToken } from './InjectionToken.js';
|
|
3
|
+
import { IRegistration } from '../registration/IRegistration.js';
|
|
4
|
+
import { ArgsFn, ProviderOptions } from '../provider/IProvider.js';
|
|
5
|
+
export declare class SingleToken<T = any> extends InjectionToken<T> {
|
|
6
|
+
token: DependencyKey;
|
|
7
|
+
private readonly _getArgsFn;
|
|
8
|
+
private readonly _isLazy;
|
|
9
|
+
constructor(token: DependencyKey, { getArgsFn, isLazy }?: {
|
|
10
|
+
getArgsFn?: ArgsFn;
|
|
11
|
+
isLazy?: boolean;
|
|
12
|
+
});
|
|
13
|
+
select<R>(fn: (target: T) => R): (s: IContainer) => R;
|
|
14
|
+
resolve(s: IContainer, { args, lazy }?: ProviderOptions): T;
|
|
15
|
+
bindTo(r: IRegistration<T>): void;
|
|
16
|
+
args(...newArgs: unknown[]): SingleToken<T>;
|
|
17
|
+
argsFn(fn: (s: IContainer) => unknown[]): SingleToken<T>;
|
|
18
|
+
lazy(): SingleToken<T>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DependencyKey } from '../container/IContainer.js';
|
|
2
|
+
import { InjectionToken } from './InjectionToken.js';
|
|
3
|
+
import { InjectFn } from '../hooks/hook.js';
|
|
4
|
+
import { type constructor } from '../utils/basic.js';
|
|
5
|
+
export declare const toToken: <T = any>(token: InjectFn<T> | InjectionToken<T> | DependencyKey | constructor<T>) => InjectionToken<T>;
|
|
6
|
+
export declare const argToToken: (v: unknown) => InjectionToken<unknown>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type constructor<T> = new (...args: any[]) => T;
|
|
2
|
+
export interface Instance<T = unknown> {
|
|
3
|
+
new (...args: unknown[]): T;
|
|
4
|
+
}
|
|
5
|
+
export declare const Is: {
|
|
6
|
+
nullish: <T>(value: T | undefined | null) => value is null | undefined;
|
|
7
|
+
object: (target: unknown) => target is object;
|
|
8
|
+
instance: (target: unknown) => target is Instance;
|
|
9
|
+
constructor: (target: unknown) => target is constructor<unknown>;
|
|
10
|
+
};
|
|
11
|
+
export declare function resolveConstructor(target: object): object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debounce: (ms: number) => MethodDecorator;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type HandleErrorParams = (error: unknown, context: {
|
|
2
|
+
target: string;
|
|
3
|
+
method: string;
|
|
4
|
+
}) => void;
|
|
5
|
+
export declare const handleAsyncError: (errorHandler: HandleErrorParams) => MethodDecorator;
|
|
6
|
+
export declare const handleError: (errorHandler: HandleErrorParams) => MethodDecorator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type MapFn<A, B = A> = (value: A) => B;
|
|
2
|
+
export declare function pipe<A>(fn1: MapFn<A>): MapFn<A>;
|
|
3
|
+
export declare function pipe<A, B>(fn1: MapFn<A, B>): MapFn<A, B>;
|
|
4
|
+
export declare function pipe<A, B, C>(fn1: MapFn<A, B>, fn2: MapFn<B, C>): MapFn<A, C>;
|
|
5
|
+
export declare function pipe<A, B, C, D>(fn1: MapFn<A, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>): MapFn<A, D>;
|
|
6
|
+
export declare function pipe<A, B, C, D, E>(fn1: MapFn<A, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>): MapFn<A, E>;
|
|
7
|
+
export declare function pipe<A, B, C, D, E, F>(fn1: MapFn<A, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>): MapFn<A, F>;
|
|
8
|
+
export declare function pipe<A, B, C, D, E, F, G>(fn1: MapFn<A, B>, fn2: MapFn<B, C>, fn3: MapFn<C, D>, fn4: MapFn<D, E>, fn5: MapFn<E, F>, fn6: MapFn<F, G>): MapFn<A, G>;
|
|
9
|
+
export declare function pipe<A, B, C, D, E, F, G, H>(fn1: MapFn<A, 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>): MapFn<A, H>;
|
|
10
|
+
export declare function pipe<A, B, C, D, E, F, G, H, I>(fn1: MapFn<A, 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>): MapFn<A, I>;
|
|
11
|
+
export declare function pipe<A, B, C, D, E, F, G, H, I, J>(fn1: MapFn<A, 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>): MapFn<A, J>;
|
|
12
|
+
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(fn1: MapFn<A, 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>): MapFn<A, K>;
|
|
13
|
+
export declare function pipe<T>(...mappers: MapFn<T>[]): MapFn<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const promisify: <T>(arg: T | Promise<T>) => Promise<T>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isProxy(value: object): boolean;
|
|
2
|
+
export declare function getProxyTarget<T extends object>(value: T): T;
|
|
3
|
+
export declare function lazyProxy<T extends object>(resolveInstance: () => T): T;
|
|
4
|
+
export declare function toLazyIf<T extends object>(resolveInstance: () => T, isLazy?: boolean): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const shallowCache: (getKeyByArgs: (...args: unknown[]) => unknown) => MethodDecorator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const throttle: (ms: number) => MethodDecorator;
|