ts-ioc-container 72.1.0 → 72.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/AGENTS.md +179 -0
- package/cjm/container/Container.js +2 -2
- package/cjm/container/EmptyContainer.js +17 -15
- package/cjm/errors/ArgumentNotFoundError.js +1 -0
- package/cjm/errors/CannonSingletonApplyTwiceError.js +2 -14
- package/cjm/errors/CannotApplySingletonTwiceError.js +18 -0
- package/cjm/errors/ContainerDisposedError.js +1 -0
- package/cjm/errors/ContainerError.js +1 -0
- package/cjm/errors/ContainerNotFoundError.js +1 -0
- package/cjm/errors/DependencyMissingKeyError.js +1 -0
- package/cjm/errors/DependencyNotFoundError.js +1 -0
- package/cjm/errors/MethodNotImplementedError.js +1 -0
- package/cjm/errors/ProviderDisposedError.js +1 -0
- package/cjm/errors/TypedEventDisposedError.js +1 -0
- package/cjm/errors/UnsupportedTokenTypeError.js +1 -0
- package/cjm/index.js +5 -3
- package/cjm/provider/Provider.js +6 -6
- package/cjm/registration/Registration.js +2 -2
- package/cjm/token/ConstantToken.js +4 -4
- package/cjm/token/FunctionToken.js +1 -1
- package/cjm/token/GroupInstanceToken.js +4 -4
- package/cjm/token/toToken.js +1 -1
- package/cjm/utils/TypedEvent.js +1 -1
- package/cjm/utils/array.js +1 -1
- package/esm/container/Container.js +2 -2
- package/esm/container/EmptyContainer.js +17 -15
- package/esm/errors/ArgumentNotFoundError.js +1 -0
- package/esm/errors/CannonSingletonApplyTwiceError.js +2 -13
- package/esm/errors/CannotApplySingletonTwiceError.js +14 -0
- package/esm/errors/ContainerDisposedError.js +1 -0
- package/esm/errors/ContainerError.js +1 -0
- package/esm/errors/ContainerNotFoundError.js +1 -0
- package/esm/errors/DependencyMissingKeyError.js +1 -0
- package/esm/errors/DependencyNotFoundError.js +1 -0
- package/esm/errors/MethodNotImplementedError.js +1 -0
- package/esm/errors/ProviderDisposedError.js +1 -0
- package/esm/errors/TypedEventDisposedError.js +1 -0
- package/esm/errors/UnsupportedTokenTypeError.js +1 -0
- package/esm/index.js +1 -0
- package/esm/provider/Provider.js +6 -6
- package/esm/registration/Registration.js +2 -2
- package/esm/token/ConstantToken.js +4 -4
- package/esm/token/FunctionToken.js +1 -1
- package/esm/token/GroupInstanceToken.js +4 -4
- package/esm/token/toToken.js +1 -1
- package/esm/utils/TypedEvent.js +1 -1
- package/esm/utils/array.js +1 -1
- package/lib/ExecutionContext.ts +6 -0
- package/lib/container/AliasMap.ts +30 -0
- package/lib/container/AutoResolveModule.ts +24 -0
- package/lib/container/Container.ts +311 -0
- package/lib/container/EmptyContainer.ts +166 -0
- package/lib/container/IContainer.ts +156 -0
- package/lib/errors/ArgumentNotFoundError.ts +13 -0
- package/lib/errors/CannonSingletonApplyTwiceError.ts +6 -0
- package/lib/errors/CannotApplySingletonTwiceError.ts +22 -0
- package/lib/errors/ContainerDisposedError.ts +13 -0
- package/lib/errors/ContainerError.ts +15 -0
- package/lib/errors/ContainerNotFoundError.ts +13 -0
- package/lib/errors/DependencyMissingKeyError.ts +13 -0
- package/lib/errors/DependencyNotFoundError.ts +13 -0
- package/lib/errors/MethodNotImplementedError.ts +13 -0
- package/lib/errors/ProviderDisposedError.ts +22 -0
- package/lib/errors/TypedEventDisposedError.ts +22 -0
- package/lib/errors/UnsupportedTokenTypeError.ts +13 -0
- package/lib/hooks/HookCollector.ts +109 -0
- package/lib/hooks/HookContext.ts +85 -0
- package/lib/hooks/combinators.ts +51 -0
- package/lib/hooks/hook.ts +89 -0
- package/lib/hooks/injectProp.ts +14 -0
- package/lib/index.ts +181 -0
- package/lib/injector/IInjector.ts +88 -0
- package/lib/injector/MetadataInjector.ts +100 -0
- package/lib/injector/ProxyInjector.ts +31 -0
- package/lib/injector/SimpleInjector.ts +20 -0
- package/lib/metadata/class.ts +50 -0
- package/lib/metadata/method.ts +47 -0
- package/lib/metadata/parameter.ts +60 -0
- package/lib/metadata/target.ts +25 -0
- package/lib/provider/IProvider.ts +65 -0
- package/lib/provider/Provider.ts +174 -0
- package/lib/registration/IRegistration.ts +235 -0
- package/lib/registration/Registration.ts +122 -0
- package/lib/select.ts +33 -0
- package/lib/token/BindToken.ts +13 -0
- package/lib/token/ClassToken.ts +72 -0
- package/lib/token/ConstantToken.ts +50 -0
- package/lib/token/FunctionToken.ts +79 -0
- package/lib/token/GroupAliasToken.ts +92 -0
- package/lib/token/GroupInstanceToken.ts +70 -0
- package/lib/token/InjectionToken.ts +46 -0
- package/lib/token/SingleAliasToken.ts +84 -0
- package/lib/token/SingleToken.ts +93 -0
- package/lib/token/toToken.ts +46 -0
- package/lib/utils/ProxyRegistry.ts +149 -0
- package/lib/utils/TypedEvent.ts +96 -0
- package/lib/utils/array.ts +28 -0
- package/lib/utils/basic.ts +34 -0
- package/lib/utils/debounce.ts +18 -0
- package/lib/utils/errorHandler.ts +34 -0
- package/lib/utils/fp.ts +86 -0
- package/lib/utils/getConstructorChain.ts +17 -0
- package/lib/utils/memoize.ts +24 -0
- package/lib/utils/once.ts +24 -0
- package/lib/utils/shallowCache.ts +22 -0
- package/lib/utils/task.ts +33 -0
- package/lib/utils/throttle.ts +17 -0
- package/package.json +5 -3
- package/typings/ExecutionContext.d.ts +2 -0
- package/typings/ExecutionContext.d.ts.map +1 -0
- package/typings/container/AliasMap.d.ts +1 -0
- package/typings/container/AliasMap.d.ts.map +1 -0
- package/typings/container/AutoResolveModule.d.ts +16 -0
- package/typings/container/AutoResolveModule.d.ts.map +1 -0
- package/typings/container/Container.d.ts +60 -0
- package/typings/container/Container.d.ts.map +1 -0
- package/typings/container/EmptyContainer.d.ts +51 -0
- package/typings/container/EmptyContainer.d.ts.map +1 -0
- package/typings/container/IContainer.d.ts +75 -0
- package/typings/container/IContainer.d.ts.map +1 -0
- package/typings/errors/ArgumentNotFoundError.d.ts +3 -0
- package/typings/errors/ArgumentNotFoundError.d.ts.map +1 -0
- package/typings/errors/CannonSingletonApplyTwiceError.d.ts +6 -6
- package/typings/errors/CannonSingletonApplyTwiceError.d.ts.map +1 -0
- package/typings/errors/CannotApplySingletonTwiceError.d.ts +12 -0
- package/typings/errors/CannotApplySingletonTwiceError.d.ts.map +1 -0
- package/typings/errors/ContainerDisposedError.d.ts +3 -0
- package/typings/errors/ContainerDisposedError.d.ts.map +1 -0
- package/typings/errors/ContainerError.d.ts +7 -0
- package/typings/errors/ContainerError.d.ts.map +1 -0
- package/typings/errors/ContainerNotFoundError.d.ts +3 -0
- package/typings/errors/ContainerNotFoundError.d.ts.map +1 -0
- package/typings/errors/DependencyMissingKeyError.d.ts +3 -0
- package/typings/errors/DependencyMissingKeyError.d.ts.map +1 -0
- package/typings/errors/DependencyNotFoundError.d.ts +3 -0
- package/typings/errors/DependencyNotFoundError.d.ts.map +1 -0
- package/typings/errors/MethodNotImplementedError.d.ts +3 -0
- package/typings/errors/MethodNotImplementedError.d.ts.map +1 -0
- package/typings/errors/ProviderDisposedError.d.ts +6 -0
- package/typings/errors/ProviderDisposedError.d.ts.map +1 -0
- package/typings/errors/TypedEventDisposedError.d.ts +6 -0
- package/typings/errors/TypedEventDisposedError.d.ts.map +1 -0
- package/typings/errors/UnsupportedTokenTypeError.d.ts +3 -0
- package/typings/errors/UnsupportedTokenTypeError.d.ts.map +1 -0
- package/typings/hooks/HookCollector.d.ts +36 -0
- package/typings/hooks/HookCollector.d.ts.map +1 -0
- package/typings/hooks/HookContext.d.ts +10 -0
- package/typings/hooks/HookContext.d.ts.map +1 -0
- package/typings/hooks/combinators.d.ts +23 -0
- package/typings/hooks/combinators.d.ts.map +1 -0
- package/typings/hooks/hook.d.ts +39 -0
- package/typings/hooks/hook.d.ts.map +1 -0
- package/typings/hooks/injectProp.d.ts +9 -0
- package/typings/hooks/injectProp.d.ts.map +1 -0
- package/typings/index.d.ts +2 -0
- package/typings/index.d.ts.map +1 -0
- package/typings/injector/IInjector.d.ts +32 -0
- package/typings/injector/IInjector.d.ts.map +1 -0
- package/typings/injector/MetadataInjector.d.ts +58 -0
- package/typings/injector/MetadataInjector.d.ts.map +1 -0
- package/typings/injector/ProxyInjector.d.ts +13 -0
- package/typings/injector/ProxyInjector.d.ts.map +1 -0
- package/typings/injector/SimpleInjector.d.ts +13 -0
- package/typings/injector/SimpleInjector.d.ts.map +1 -0
- package/typings/metadata/class.d.ts +27 -0
- package/typings/metadata/class.d.ts.map +1 -0
- package/typings/metadata/method.d.ts +24 -0
- package/typings/metadata/method.d.ts.map +1 -0
- package/typings/metadata/parameter.d.ts +21 -0
- package/typings/metadata/parameter.d.ts.map +1 -0
- package/typings/metadata/target.d.ts +19 -0
- package/typings/metadata/target.d.ts.map +1 -0
- package/typings/provider/IProvider.d.ts +25 -0
- package/typings/provider/IProvider.d.ts.map +1 -0
- package/typings/provider/Provider.d.ts +30 -0
- package/typings/provider/Provider.d.ts.map +1 -0
- package/typings/registration/IRegistration.d.ts +137 -0
- package/typings/registration/IRegistration.d.ts.map +1 -0
- package/typings/registration/Registration.d.ts +23 -0
- package/typings/registration/Registration.d.ts.map +1 -0
- package/typings/select.d.ts +15 -0
- package/typings/select.d.ts.map +1 -0
- package/typings/token/BindToken.d.ts +3 -0
- package/typings/token/BindToken.d.ts.map +1 -0
- package/typings/token/ClassToken.d.ts +2 -0
- package/typings/token/ClassToken.d.ts.map +1 -0
- package/typings/token/ConstantToken.d.ts +14 -0
- package/typings/token/ConstantToken.d.ts.map +1 -0
- package/typings/token/FunctionToken.d.ts +10 -0
- package/typings/token/FunctionToken.d.ts.map +1 -0
- package/typings/token/GroupAliasToken.d.ts +14 -0
- package/typings/token/GroupAliasToken.d.ts.map +1 -0
- package/typings/token/GroupInstanceToken.d.ts +19 -0
- package/typings/token/GroupInstanceToken.d.ts.map +1 -0
- package/typings/token/InjectionToken.d.ts +8 -0
- package/typings/token/InjectionToken.d.ts.map +1 -0
- package/typings/token/SingleAliasToken.d.ts +6 -0
- package/typings/token/SingleAliasToken.d.ts.map +1 -0
- package/typings/token/SingleToken.d.ts +18 -0
- package/typings/token/SingleToken.d.ts.map +1 -0
- package/typings/token/toToken.d.ts +12 -0
- package/typings/token/toToken.d.ts.map +1 -0
- package/typings/utils/ProxyRegistry.d.ts +63 -0
- package/typings/utils/ProxyRegistry.d.ts.map +1 -0
- package/typings/utils/TypedEvent.d.ts +42 -0
- package/typings/utils/TypedEvent.d.ts.map +1 -0
- package/typings/utils/array.d.ts +7 -0
- package/typings/utils/array.d.ts.map +1 -0
- package/typings/utils/basic.d.ts +12 -0
- package/typings/utils/basic.d.ts.map +1 -0
- package/typings/utils/debounce.d.ts +2 -0
- package/typings/utils/debounce.d.ts.map +1 -0
- package/typings/utils/errorHandler.d.ts +4 -0
- package/typings/utils/errorHandler.d.ts.map +1 -0
- package/typings/utils/fp.d.ts +8 -0
- package/typings/utils/fp.d.ts.map +1 -0
- package/typings/utils/getConstructorChain.d.ts +9 -0
- package/typings/utils/getConstructorChain.d.ts.map +1 -0
- package/typings/utils/memoize.d.ts +10 -0
- package/typings/utils/memoize.d.ts.map +1 -0
- package/typings/utils/once.d.ts +2 -0
- package/typings/utils/once.d.ts.map +1 -0
- package/typings/utils/shallowCache.d.ts +2 -0
- package/typings/utils/shallowCache.d.ts.map +1 -0
- package/typings/utils/task.d.ts +13 -0
- package/typings/utils/task.d.ts.map +1 -0
- package/typings/utils/throttle.d.ts +2 -0
- package/typings/utils/throttle.d.ts.map +1 -0
|
@@ -4,6 +4,18 @@ import { IRegistration } from '../registration/IRegistration.js';
|
|
|
4
4
|
import { BindToken } from './BindToken.js';
|
|
5
5
|
import { ArgsFn, ResolveOptions } from '../provider/IProvider.js';
|
|
6
6
|
import { Serializable } from '../utils/basic.js';
|
|
7
|
+
/**
|
|
8
|
+
* A token for every dependency registered under an alias. As a `bindTo(...)`
|
|
9
|
+
* target it adds the alias; resolving returns all matches as an array.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const IMiddlewareToken = toGroupAlias<IMiddleware>('IMiddleware');
|
|
13
|
+
*
|
|
14
|
+
* @register(bindTo(IMiddlewareToken))
|
|
15
|
+
* class Auth implements IMiddleware {}
|
|
16
|
+
*
|
|
17
|
+
* IMiddlewareToken.resolve(scope); // IMiddleware[]
|
|
18
|
+
*/
|
|
7
19
|
export declare class GroupAliasToken<T = any> extends InjectionToken<T[]> implements BindToken<T>, Serializable {
|
|
8
20
|
readonly token: DependencyKey;
|
|
9
21
|
private readonly _getArgsFn;
|
|
@@ -22,4 +34,6 @@ export declare class GroupAliasToken<T = any> extends InjectionToken<T[]> implem
|
|
|
22
34
|
addTags(...tags: string[]): GroupAliasToken<T>;
|
|
23
35
|
toString(): string;
|
|
24
36
|
}
|
|
37
|
+
/** Creates a {@link GroupAliasToken} for `token`. */
|
|
25
38
|
export declare const toGroupAlias: <T>(token: DependencyKey) => GroupAliasToken<T>;
|
|
39
|
+
//# sourceMappingURL=GroupAliasToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupAliasToken.d.ts","sourceRoot":"","sources":["../../lib/token/GroupAliasToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc,CAAC,CAAC,EAAE,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY;IAKnG,QAAQ,CAAC,KAAK,EAAE,aAAa;IAJ/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAGvB,KAAK,EAAE,aAAa,EAC7B,EACE,SAAuB,EACvB,MAAc,EACd,IAAS,GACV,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO;IAOnE,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,IACxB,GAAG,UAAU;IAGvB,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,IAAS,EAAE,IAAI,EAAE,GAAE,cAAmB,GAAG,CAAC,EAAE;IAOrE,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;IAI1B,IAAI,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE;IAS1B,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO,EAAE;IASvC,IAAI;IAQJ,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC;IAQ9C,QAAQ,IAAI,MAAM;CAGnB;AAED,qDAAqD;AACrD,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,OAAO,aAAa,uBAAkC,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { InjectionToken } from './InjectionToken.js';
|
|
2
2
|
import type { IContainer } from '../container/IContainer.js';
|
|
3
3
|
import { Instance, Serializable } from '../utils/basic.js';
|
|
4
|
+
/** Selects instances for a {@link GroupInstanceToken}. */
|
|
4
5
|
export type InstancePredicate = (dep: unknown) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the instances already created in a scope (and, by default, its
|
|
8
|
+
* child scopes) that match a predicate. Created by `select.instances(...)`.
|
|
9
|
+
*/
|
|
5
10
|
export declare class GroupInstanceToken extends InjectionToken<Instance[]> implements Serializable {
|
|
6
11
|
private predicate;
|
|
7
12
|
private isCascade;
|
|
@@ -10,11 +15,25 @@ export declare class GroupInstanceToken extends InjectionToken<Instance[]> imple
|
|
|
10
15
|
isCascade?: boolean;
|
|
11
16
|
});
|
|
12
17
|
select<R>(fn: (target: Instance) => R): (s: IContainer) => R[];
|
|
18
|
+
/**
|
|
19
|
+
* @throws {MethodNotImplementedError} always — a group instance token cannot receive static args.
|
|
20
|
+
*/
|
|
13
21
|
args(...deps: unknown[]): this;
|
|
22
|
+
/**
|
|
23
|
+
* @throws {MethodNotImplementedError} always — a group instance token cannot receive resolved args.
|
|
24
|
+
*/
|
|
14
25
|
argsFn(getArgsFn: (s: IContainer) => unknown[]): InjectionToken<Instance[]>;
|
|
26
|
+
/**
|
|
27
|
+
* @throws {MethodNotImplementedError} always — a group instance token cannot be made lazy.
|
|
28
|
+
*/
|
|
15
29
|
lazy(): InjectionToken<Instance[]>;
|
|
30
|
+
/** Whether instances of child scopes are included (default `true`). */
|
|
16
31
|
cascade(isTrue: boolean): this;
|
|
17
32
|
resolve(c: IContainer): Instance[];
|
|
18
33
|
addTags(...tags: string[]): GroupInstanceToken;
|
|
34
|
+
/**
|
|
35
|
+
* @throws {MethodNotImplementedError} always — a group instance token has no underlying key.
|
|
36
|
+
*/
|
|
19
37
|
toString(): string;
|
|
20
38
|
}
|
|
39
|
+
//# sourceMappingURL=GroupInstanceToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupInstanceToken.d.ts","sourceRoot":"","sources":["../../lib/token/GroupInstanceToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAExD,0DAA0D;AAC1D,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;AAE1D;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,QAAQ,EAAE,CAAE,YAAW,YAAY;IAItF,OAAO,CAAC,SAAS;IAHnB,OAAO,CAAC,SAAS,CAAU;gBAGjB,SAAS,EAAE,iBAAiB,EACpC,EAAE,IAAS,EAAE,SAAgB,EAAE,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAO;IAMhF,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,CAAC,IAC3B,GAAG,UAAU;IAGvB;;OAEG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO,EAAE,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IAI3E;;OAEG;IACH,IAAI,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC;IAIlC,uEAAuE;IACvE,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAK9B,OAAO,CAAC,CAAC,EAAE,UAAU,GAAG,QAAQ,EAAE;IAIlC,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,kBAAkB;IAI9C;;OAEG;IACH,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type IContainer, type Tag } from '../container/IContainer.js';
|
|
2
2
|
import { ArgsFn, ResolveOptions } from '../provider/IProvider.js';
|
|
3
|
+
/**
|
|
4
|
+
* The default `getArgsFn` of every token: the runtime `args` a token is
|
|
5
|
+
* resolved with reach the provider as they are, and `token.args(...)` /
|
|
6
|
+
* `token.argsFn(...)` append after them.
|
|
7
|
+
*/
|
|
3
8
|
export declare const forwardArgs: ArgsFn;
|
|
9
|
+
/** Base class of every token: something resolvable from a scope that can be specialized with args, lazy and tags. */
|
|
4
10
|
export declare abstract class InjectionToken<T = any> {
|
|
5
11
|
private readonly tags;
|
|
6
12
|
protected constructor(tags?: Tag[]);
|
|
@@ -12,4 +18,6 @@ export declare abstract class InjectionToken<T = any> {
|
|
|
12
18
|
hasTag(tag: Tag): boolean;
|
|
13
19
|
protected getTags(): Tag[];
|
|
14
20
|
}
|
|
21
|
+
/** Narrows `target` to an {@link InjectionToken}. */
|
|
15
22
|
export declare function isInjectionToken<T = any>(target: unknown): target is InjectionToken<T>;
|
|
23
|
+
//# sourceMappingURL=InjectionToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InjectionToken.d.ts","sourceRoot":"","sources":["../../lib/token/InjectionToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,GAAG,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG/D;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,MAAgC,CAAC;AAE3D,qHAAqH;AACrH,8BAAsB,cAAc,CAAC,CAAC,GAAG,GAAG;IAC1C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAW;IAEhC,SAAS,aAAa,IAAI,GAAE,GAAG,EAAO;IAItC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,CAAC;IAC5D,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC;IAC3E,QAAQ,CAAC,IAAI,IAAI,cAAc,CAAC,CAAC,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC;IAEnD,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;IAIzB,SAAS,CAAC,OAAO,IAAI,GAAG,EAAE;CAG3B;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC,CAUtF"}
|
|
@@ -4,6 +4,10 @@ import { IRegistration } from '../registration/IRegistration.js';
|
|
|
4
4
|
import { BindToken } from './BindToken.js';
|
|
5
5
|
import { ArgsFn, ResolveOptions } from '../provider/IProvider.js';
|
|
6
6
|
import { Serializable } from '../utils/basic.js';
|
|
7
|
+
/**
|
|
8
|
+
* Like {@link GroupAliasToken}, but resolves exactly one dependency registered
|
|
9
|
+
* under the alias, and throws `DependencyNotFoundError` when there is none.
|
|
10
|
+
*/
|
|
7
11
|
export declare class SingleAliasToken<T = any> extends InjectionToken<T> implements BindToken<T>, Serializable {
|
|
8
12
|
readonly token: DependencyKey;
|
|
9
13
|
private readonly _getArgsFn;
|
|
@@ -22,4 +26,6 @@ export declare class SingleAliasToken<T = any> extends InjectionToken<T> impleme
|
|
|
22
26
|
addTags(...tags: string[]): SingleAliasToken<T>;
|
|
23
27
|
toString(): string;
|
|
24
28
|
}
|
|
29
|
+
/** Creates a {@link SingleAliasToken} for `token`. */
|
|
25
30
|
export declare const toSingleAlias: <T>(token: DependencyKey) => SingleAliasToken<T>;
|
|
31
|
+
//# sourceMappingURL=SingleAliasToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleAliasToken.d.ts","sourceRoot":"","sources":["../../lib/token/SingleAliasToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE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a,wBAAmC,CAAC"}
|
|
@@ -3,6 +3,23 @@ import { InjectionToken } from './InjectionToken.js';
|
|
|
3
3
|
import { IRegistration } from '../registration/IRegistration.js';
|
|
4
4
|
import { ArgsFn, ResolveOptions } from '../provider/IProvider.js';
|
|
5
5
|
import { Serializable } from '../utils/basic.js';
|
|
6
|
+
/**
|
|
7
|
+
* A typed handle for one dependency key - the usual way to name a dependency.
|
|
8
|
+
* `args(...)`, `argsFn(...)` and `lazy()` return a new token and never change
|
|
9
|
+
* this one, so one token can be specialized per injection site.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const ILoggerToken = new SingleToken<ILogger>('ILogger');
|
|
13
|
+
*
|
|
14
|
+
* @register(bindTo(ILoggerToken))
|
|
15
|
+
* class Logger implements ILogger {}
|
|
16
|
+
*
|
|
17
|
+
* class App {
|
|
18
|
+
* constructor(@inject(by(ILoggerToken)) logger: ILogger) {}
|
|
19
|
+
* }
|
|
20
|
+
* ILoggerToken.resolve(scope);
|
|
21
|
+
* ILoggerToken.args('prefix').lazy().resolve(scope);
|
|
22
|
+
*/
|
|
6
23
|
export declare class SingleToken<T = any> extends InjectionToken<T> implements Serializable {
|
|
7
24
|
token: DependencyKey;
|
|
8
25
|
private readonly _getArgsFn;
|
|
@@ -21,3 +38,4 @@ export declare class SingleToken<T = any> extends InjectionToken<T> implements S
|
|
|
21
38
|
addTags(...tags: string[]): SingleToken<T>;
|
|
22
39
|
toString(): string;
|
|
23
40
|
}
|
|
41
|
+
//# sourceMappingURL=SingleToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleToken.d.ts","sourceRoot":"","sources":["../../lib/token/SingleToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAW,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAE,YAAW,YAAY;IAKxE,KAAK,EAAE,aAAa;IAJ7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAGzB,KAAK,EAAE,aAAa,EAC3B,EACE,SAAuB,EACvB,MAAc,EACd,IAAS,GACV,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO;IAOnE,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IACpB,GAAG,UAAU;IAGvB,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,IAAS,EAAE,IAAI,EAAE,GAAE,cAAmB,GAAG,CAAC;IAOnE,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;IAI1B,IAAI,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE;IAS1B,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,OAAO,EAAE;IASvC,IAAI;IAQJ,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;IAQ1C,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -2,6 +2,18 @@ import { DependencyKey } from '../container/IContainer.js';
|
|
|
2
2
|
import { InjectionToken } from './InjectionToken.js';
|
|
3
3
|
import { InjectFn } from '../hooks/hook.js';
|
|
4
4
|
import { type constructor } from '../utils/basic.js';
|
|
5
|
+
/** Anything `toToken(...)` turns into a token: a token, a key, a class or an `InjectFn`. */
|
|
5
6
|
export type Injectable<T = any> = InjectFn<T> | InjectionToken<T> | DependencyKey | constructor<T>;
|
|
7
|
+
/**
|
|
8
|
+
* @throws {UnsupportedTokenTypeError} when `token` is not an `InjectionToken`, a `DependencyKey`, a constructor, or a function.
|
|
9
|
+
*/
|
|
6
10
|
export declare const toToken: <T = any>(token: Injectable<T>) => InjectionToken<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a runtime argument so it can be resolved uniformly: an `InjectionToken`
|
|
13
|
+
* is returned as-is, anything else becomes a `ConstantToken` of itself. The
|
|
14
|
+
* library never applies it to the args list - a call site that wants
|
|
15
|
+
* "resolve tokens, pass literals through" does so explicitly, e.g.
|
|
16
|
+
* `@inject(({ scope, args = [] }) => argToToken(args[0]).resolve(scope))`.
|
|
17
|
+
*/
|
|
7
18
|
export declare const argToToken: <T = unknown>(v: T) => InjectionToken<T>;
|
|
19
|
+
//# sourceMappingURL=toToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toToken.d.ts","sourceRoot":"","sources":["../../lib/token/toToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAmB,MAAM,yBAAyB,CAAC;AAKzE,OAAO,EAAE,cAAc,EAAoB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAM,MAAM,gBAAgB,CAAC;AAGtD,4FAA4F;AAC5F,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAEnG;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,GAAG,EAAE,OAAO,UAAU,CAAC,CAAC,CAAC,KAAG,cAAc,CAAC,CAAC,CAoBvE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,OAAO,EAAE,GAAG,CAAC,KAAG,cAAc,CAAC,CAAC,CAAwD,CAAC"}
|
|
@@ -1,20 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The proxy operations the library depends on. Depend on this rather than on
|
|
3
|
+
* {@link ProxyRegistry} itself, so a caller can substitute its own
|
|
4
|
+
* implementation - the concrete registry is a singleton and cannot be
|
|
5
|
+
* constructed a second time.
|
|
6
|
+
*/
|
|
1
7
|
export interface IProxyRegistry {
|
|
8
|
+
/**
|
|
9
|
+
* Returns the real object behind `value`, unwrapping proxies stacked to any
|
|
10
|
+
* depth. A value that is not a proxy is returned as is.
|
|
11
|
+
*
|
|
12
|
+
* The library calls this itself wherever a proxy would give the wrong answer -
|
|
13
|
+
* every read of class metadata (see `resolveConstructor`, `getHooks`,
|
|
14
|
+
* `resolveArgs`) and every identity check against a tracked instance (see
|
|
15
|
+
* `IContainer.hasInstance`). Pass the container's own values to those APIs as
|
|
16
|
+
* they come; unwrapping by hand is for code that needs the real object for its
|
|
17
|
+
* own reasons.
|
|
18
|
+
*/
|
|
2
19
|
unwrap<T extends object>(value: T): T;
|
|
3
20
|
createProxy<T extends object>(target: T, handler?: ProxyHandler<T>): T;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a proxy that resolves its target on first access and caches it.
|
|
23
|
+
*/
|
|
4
24
|
createLazyProxy<T extends object>(resolveInstance: () => T): T;
|
|
25
|
+
/**
|
|
26
|
+
* Wraps `resolveInstance` in a lazy proxy when `isLazy`, otherwise calls it
|
|
27
|
+
* right away.
|
|
28
|
+
*/
|
|
5
29
|
toLazyIf<T extends object>(resolveInstance: () => T, isLazy?: boolean): T;
|
|
6
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates proxies and tracks them, so a proxy can be traced back to the real
|
|
33
|
+
* object it stands for. The library's own {@link IProxyRegistry}.
|
|
34
|
+
*
|
|
35
|
+
* Process-wide singleton: a proxy created anywhere must be unwrappable
|
|
36
|
+
* everywhere, and the registry holds no configuration that would justify a
|
|
37
|
+
* second instance. Obtain it with {@link ProxyRegistry.getInstance}.
|
|
38
|
+
*
|
|
39
|
+
* Entries are held weakly - a proxy that becomes unreachable is collected along
|
|
40
|
+
* with its state.
|
|
41
|
+
*/
|
|
7
42
|
export declare class ProxyRegistry implements IProxyRegistry {
|
|
8
43
|
private static instance?;
|
|
9
44
|
private readonly states;
|
|
10
45
|
private constructor();
|
|
11
46
|
static getInstance(): ProxyRegistry;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the real object behind `value`, unwrapping proxies stacked to any
|
|
49
|
+
* depth. A value that is not a proxy is returned as is.
|
|
50
|
+
*/
|
|
12
51
|
unwrap<T extends object>(value: T): T;
|
|
13
52
|
createProxy<T extends object>(target: T, handler?: ProxyHandler<T>): T;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a proxy that resolves its target on first access and caches it.
|
|
55
|
+
* The target is unwrapped on resolution, so wrapping a lazy proxy in another
|
|
56
|
+
* lazy proxy never stacks beyond one level.
|
|
57
|
+
*/
|
|
14
58
|
createLazyProxy<T extends object>(resolveInstance: () => T): T;
|
|
59
|
+
/**
|
|
60
|
+
* Wraps `resolveInstance` in a lazy proxy when `isLazy`, otherwise calls it
|
|
61
|
+
* right away.
|
|
62
|
+
*/
|
|
15
63
|
toLazyIf<T extends object>(resolveInstance: () => T, isLazy?: boolean): T;
|
|
16
64
|
private isProxy;
|
|
17
65
|
private getTarget;
|
|
18
66
|
private register;
|
|
19
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The real object behind `value`, unwrapping proxies stacked to any depth. A
|
|
70
|
+
* value that is not a proxy is returned as is.
|
|
71
|
+
*
|
|
72
|
+
* A shortcut for `ProxyRegistry.getInstance().unwrap(value)` - the registry is a
|
|
73
|
+
* process-wide singleton, so unwrapping never needs an instance of its own. The
|
|
74
|
+
* library already unwraps wherever a proxy would give the wrong answer (reading
|
|
75
|
+
* class metadata, and `IContainer.hasInstance`), so reach for this only when
|
|
76
|
+
* your own code needs the real object - an identity check of your own, or
|
|
77
|
+
* bypassing a lazy proxy on purpose.
|
|
78
|
+
*
|
|
79
|
+
* Note that unwrapping a lazy proxy resolves its target, which is the point:
|
|
80
|
+
* there is no real object to hand back until it does.
|
|
81
|
+
*/
|
|
20
82
|
export declare const unwrapProxy: <T extends object>(value: T) => T;
|
|
83
|
+
//# sourceMappingURL=ProxyRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyRegistry.d.ts","sourceRoot":"","sources":["../../lib/utils/ProxyRegistry.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IAEtC,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEvE;;OAEG;IACH,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAE/D;;;OAGG;IACH,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC;CAC3E;AAED;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAgB;IAExC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;IAEpE,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,aAAa;IAKnC;;;OAGG;IACH,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC;IAIrC,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,GAAE,YAAY,CAAC,CAAC,CAAM,GAAG,CAAC;IAK1E;;;;OAIG;IACH,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC;IAgC9D;;;OAGG;IACH,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM,GAAE,OAAe,GAAG,CAAC;IAIhF,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,QAAQ;CAIjB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,CAAC,KAAG,CAA8C,CAAC"}
|
|
@@ -1,17 +1,59 @@
|
|
|
1
1
|
export type TypedEventListener<TArgs extends unknown[]> = (...args: TArgs) => void;
|
|
2
2
|
export type Unsubscribe = () => void;
|
|
3
|
+
/**
|
|
4
|
+
* The subscriber's side of a {@link TypedEvent}: attach, detach, tear down.
|
|
5
|
+
* Hand this out instead of the event itself so that only the owner can `emit`.
|
|
6
|
+
*/
|
|
3
7
|
export interface ITypedEvent<TArgs extends unknown[]> {
|
|
8
|
+
/**
|
|
9
|
+
* Attaches `listener` and returns a function which detaches it again. A
|
|
10
|
+
* listener subscribed more than once is still delivered each emission once.
|
|
11
|
+
*
|
|
12
|
+
* @throws {TypedEventDisposedError} when the event has already been disposed.
|
|
13
|
+
*/
|
|
4
14
|
subscribe(listener: TypedEventListener<TArgs>): Unsubscribe;
|
|
15
|
+
/**
|
|
16
|
+
* Detaches `listener`. Harmless when it is not subscribed, or after `dispose`.
|
|
17
|
+
*/
|
|
5
18
|
unsubscribe(listener: TypedEventListener<TArgs>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Detaches every listener and rejects further `subscribe` / `emit` calls.
|
|
21
|
+
*/
|
|
6
22
|
dispose(): void;
|
|
7
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* A typed, multi-listener event. `TArgs` is the argument list a listener
|
|
26
|
+
* receives, so a `TypedEvent<[IContainer]>` accepts `(scope: IContainer) => void`
|
|
27
|
+
* listeners unchanged.
|
|
28
|
+
*
|
|
29
|
+
* Emission delivers to the listeners subscribed at the moment `emit` is called,
|
|
30
|
+
* in subscription order. A listener detached mid-emission is skipped for the
|
|
31
|
+
* rest of that emission; one attached mid-emission receives only later ones.
|
|
32
|
+
*/
|
|
8
33
|
export declare class TypedEvent<TArgs extends unknown[] = []> implements ITypedEvent<TArgs> {
|
|
9
34
|
private readonly listeners;
|
|
10
35
|
private isDisposed;
|
|
36
|
+
/**
|
|
37
|
+
* @throws {TypedEventDisposedError} when the event has already been disposed.
|
|
38
|
+
*/
|
|
11
39
|
subscribe(listener: TypedEventListener<TArgs>): Unsubscribe;
|
|
12
40
|
unsubscribe(listener: TypedEventListener<TArgs>): void;
|
|
41
|
+
/**
|
|
42
|
+
* Calls every current listener with `args`. What a listener throws surfaces
|
|
43
|
+
* out of `emit` and stops delivery to the listeners after it.
|
|
44
|
+
*
|
|
45
|
+
* @throws {TypedEventDisposedError} when the event has already been disposed.
|
|
46
|
+
* @throws {unknown} rethrows whatever a listener threw.
|
|
47
|
+
*/
|
|
13
48
|
emit(...args: TArgs): void;
|
|
49
|
+
/**
|
|
50
|
+
* A copy of the current listeners, in subscription order.
|
|
51
|
+
*/
|
|
14
52
|
getListeners(): TypedEventListener<TArgs>[];
|
|
15
53
|
dispose(): void;
|
|
54
|
+
/**
|
|
55
|
+
* @throws {TypedEventDisposedError} when the event has already been disposed.
|
|
56
|
+
*/
|
|
16
57
|
private validate;
|
|
17
58
|
}
|
|
59
|
+
//# sourceMappingURL=TypedEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedEvent.d.ts","sourceRoot":"","sources":["../../lib/utils/TypedEvent.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,CAAC,KAAK,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;AAEnF,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,SAAS,OAAO,EAAE;IAClD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC;IAE5D;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAEvD;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAU,CAAC,KAAK,SAAS,OAAO,EAAE,GAAG,EAAE,CAAE,YAAW,WAAW,CAAC,KAAK,CAAC;IACjF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;IAClE,OAAO,CAAC,UAAU,CAAS;IAE3B;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,WAAW;IAM3D,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,IAAI;IAItD;;;;;;OAMG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI;IAW1B;;OAEG;IACH,YAAY,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;IAI3C,OAAO,IAAI,IAAI;IAKf;;OAEG;IACH,OAAO,CAAC,QAAQ;CAMjB"}
|
package/typings/utils/array.d.ts
CHANGED
|
@@ -2,4 +2,11 @@ export type Predicate<T> = (value: T) => boolean;
|
|
|
2
2
|
export declare const Filter: {
|
|
3
3
|
exclude: <T>(arr: Set<T> | T[]) => (v: T) => boolean;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Returns a picker of the first argument in `args` matching `predicate` - the
|
|
7
|
+
* shape `singleton(getCacheKey)` consumers expect.
|
|
8
|
+
*
|
|
9
|
+
* @throws {ArgumentNotFoundError} when no argument matches `predicate`
|
|
10
|
+
*/
|
|
5
11
|
export declare const findOrFail: <T>(predicate: Predicate<T>) => (args?: unknown[]) => T;
|
|
12
|
+
//# sourceMappingURL=array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../lib/utils/array.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AAEjD,eAAO,MAAM,MAAM;cACP,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAEpB,GAAG,CAAC;CAEf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACpB,CAAC,EAAE,WAAW,SAAS,CAAC,CAAC,CAAC,MAC1B,OAAM,OAAO,EAAO,KAAG,CAQvB,CAAC"}
|
package/typings/utils/basic.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
/** A class that constructs `T`. */
|
|
1
2
|
export type constructor<T> = new (...args: any[]) => T;
|
|
3
|
+
/** Something with a meaningful `toString()`, e.g. a token used as a cache key. */
|
|
2
4
|
export interface Serializable {
|
|
3
5
|
toString(): string;
|
|
4
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Tags a structural type with a name, so `Instance` reads as its own type in
|
|
9
|
+
* signatures and error messages instead of a bare `object`. The tag is optional
|
|
10
|
+
* on purpose: values stay assignable without a cast.
|
|
11
|
+
*/
|
|
5
12
|
export type Branded<TBrand extends string, T> = T & {
|
|
6
13
|
readonly __brand?: TBrand;
|
|
7
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* What the container tracks and reflects on: the object a constructor produced.
|
|
17
|
+
* Deliberately not a constructor signature - an instance is not its own constructor.
|
|
18
|
+
*/
|
|
8
19
|
export type Instance = Branded<'Instance', object>;
|
|
9
20
|
export declare const Is: {
|
|
10
21
|
nullish: <T>(value: T | undefined | null) => value is null | undefined;
|
|
@@ -14,3 +25,4 @@ export declare const Is: {
|
|
|
14
25
|
};
|
|
15
26
|
export declare function isSerializable(target: unknown): target is Serializable;
|
|
16
27
|
export declare const toString: (target: unknown) => string;
|
|
28
|
+
//# sourceMappingURL=basic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../lib/utils/basic.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEvD,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,MAAM,OAAO,CAAC,MAAM,SAAS,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElF;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAEnD,eAAO,MAAM,EAAE;cACH,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,IAAI,KAAG,KAAK,IAAI,IAAI,GAAG,SAAS;qBACnD,OAAO,KAAG,MAAM,IAAI,MAAM;uBACxB,OAAO,KAAG,MAAM,IAAI,QAAQ;0BACzB,OAAO,KAAG,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC;CAC/D,CAAC;AAGF,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,YAAY,CAEtE;AAED,eAAO,MAAM,QAAQ,GAAI,QAAQ,OAAO,KAAG,MAAuE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../lib/utils/debounce.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,GAClB,IAAI,MAAM,KAAG,eAeb,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/** Receives the error with the class and method it came from. */
|
|
1
2
|
export type HandleErrorParams = (error: unknown, context: {
|
|
2
3
|
target: string;
|
|
3
4
|
method: string;
|
|
4
5
|
}) => void;
|
|
6
|
+
/** Method decorator: routes a rejection of the async method to `errorHandler` instead of throwing. */
|
|
5
7
|
export declare const handleAsyncError: (errorHandler: HandleErrorParams) => MethodDecorator;
|
|
8
|
+
/** Method decorator: routes a throw of the method to `errorHandler` instead of throwing. */
|
|
6
9
|
export declare const handleError: (errorHandler: HandleErrorParams) => MethodDecorator;
|
|
10
|
+
//# sourceMappingURL=errorHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../lib/utils/errorHandler.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAAC;AAEtG,sGAAsG;AACtG,eAAO,MAAM,gBAAgB,GAC1B,cAAc,iBAAiB,KAAG,eAWlC,CAAC;AAEJ,4FAA4F;AAC5F,eAAO,MAAM,WAAW,GACrB,cAAc,iBAAiB,KAAG,eAWlC,CAAC"}
|
package/typings/utils/fp.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
/** A one-argument transform. */
|
|
1
2
|
export type MapFn<A, B = A> = (value: A) => B;
|
|
3
|
+
/**
|
|
4
|
+
* Composes functions left to right. With `by(...)` it maps an injected value.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* @inject(pipe(by(ConfigToken), (config) => config.apiUrl))
|
|
8
|
+
*/
|
|
2
9
|
export declare function pipe<A>(fn1: MapFn<A>): MapFn<A>;
|
|
3
10
|
export declare function pipe<A, B>(fn1: MapFn<A, B>): MapFn<A, B>;
|
|
4
11
|
export declare function pipe<A, B, C>(fn1: MapFn<A, B>, fn2: MapFn<B, C>): MapFn<A, C>;
|
|
@@ -11,3 +18,4 @@ export declare function pipe<A, B, C, D, E, F, G, H, I>(fn1: MapFn<A, B>, fn2: M
|
|
|
11
18
|
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
19
|
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
20
|
export declare function pipe<T>(...mappers: MapFn<T>[]): MapFn<T>;
|
|
21
|
+
//# sourceMappingURL=fp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fp.d.ts","sourceRoot":"","sources":["../../lib/utils/fp.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;AAG9C;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AACjD,wBAAgB,IAAI,C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C,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAClD,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAChB,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAChB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAGf,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks a constructor's prototype chain, most-derived first, and collects each
|
|
3
|
+
* class in it: `[Derived, Base, ...]`, stopping before `Function.prototype`.
|
|
4
|
+
*
|
|
5
|
+
* Reading own metadata off each entry in turn is how a class inherits what its
|
|
6
|
+
* ancestors declared — `Reflect.getOwnMetadata` never looks up the chain itself.
|
|
7
|
+
* Anything which is not a function yields an empty chain.
|
|
8
|
+
*/
|
|
1
9
|
export declare const getConstructorChain: (ctor: unknown) => object[];
|
|
10
|
+
//# sourceMappingURL=getConstructorChain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConstructorChain.d.ts","sourceRoot":"","sources":["../../lib/utils/getConstructorChain.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,OAAO,KAAG,MAAM,EAQzD,CAAC"}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a two-argument function so each `(target, key)` pair is computed once
|
|
3
|
+
* and reused. `target` is held weakly, so memoizing against a class or an
|
|
4
|
+
* instance keeps nothing alive.
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const hooksOf = memoize((Target: constructor<unknown>, key: string | symbol) => merge(Target, key));
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
1
10
|
export declare const memoize: <T extends object, K, R>(fn: (target: T, key: K) => R) => ((target: T, key: K) => R);
|
|
11
|
+
//# sourceMappingURL=memoize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../lib/utils/memoize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAcvG,CAAC"}
|
package/typings/utils/once.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ type RepeatOptions = {
|
|
|
2
2
|
index: number;
|
|
3
3
|
args: unknown[];
|
|
4
4
|
};
|
|
5
|
+
/** Method decorator: runs the method once per instance and returns the cached result afterwards. */
|
|
5
6
|
export declare const once: ({ onRepeat }?: {
|
|
6
7
|
onRepeat?: (options: RepeatOptions) => void;
|
|
7
8
|
}) => MethodDecorator;
|
|
8
9
|
export {};
|
|
10
|
+
//# sourceMappingURL=once.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"once.d.ts","sourceRoot":"","sources":["../../lib/utils/once.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB,CAAC;AAEF,oGAAoG;AACpG,eAAO,MAAM,IAAI,GACd,eAAc;IAAE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;CAAO,KAAG,eAgBrE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shallowCache.d.ts","sourceRoot":"","sources":["../../lib/utils/shallowCache.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,eAAO,MAAM,YAAY,GACtB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,KAAG,eAmBhD,CAAC"}
|
package/typings/utils/task.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unit of work which may or may not go async: the sync-until-async shape the
|
|
3
|
+
* hook machinery is built on (ADR 0013).
|
|
4
|
+
*/
|
|
1
5
|
export type Task = () => void | Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Runs `tasks` in order, staying synchronous until one returns a promise and
|
|
8
|
+
* awaiting the rest from that point. `undefined` when none went async.
|
|
9
|
+
*/
|
|
2
10
|
export declare const runInOrder: (tasks: Task[], from?: number) => void | Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Starts every task at once. Settles once all have; `undefined` when none went
|
|
13
|
+
* async, so a fully synchronous run hands back no promise.
|
|
14
|
+
*/
|
|
3
15
|
export declare const runAtOnce: (tasks: Task[]) => void | Promise<void>;
|
|
16
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../lib/utils/task.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,IAAI,EAAE,EAAE,aAAQ,KAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAOvE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,IAAI,EAAE,KAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAS5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../lib/utils/throttle.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,eAAO,MAAM,QAAQ,GAClB,IAAI,MAAM,KAAG,eAcb,CAAC"}
|