@lppedd/di-wise-neo 0.26.3 → 0.27.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/dist/cjs/index.d.ts +56 -60
- package/dist/cjs/index.js +20 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.d.mts +56 -60
- package/dist/es/index.mjs +21 -24
- package/dist/es/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/es/index.d.mts
CHANGED
|
@@ -686,6 +686,61 @@ interface Container {
|
|
|
686
686
|
*/
|
|
687
687
|
declare function createContainer(options?: ContainerOptions): Container;
|
|
688
688
|
|
|
689
|
+
/**
|
|
690
|
+
* Class decorator that registers additional aliasing tokens for the decorated type.
|
|
691
|
+
*
|
|
692
|
+
* The aliases are added using {@link ExistingProvider}(s) when the class is first
|
|
693
|
+
* registered in the container.
|
|
694
|
+
*
|
|
695
|
+
* Example:
|
|
696
|
+
* ```ts
|
|
697
|
+
* @Alias(Weapon)
|
|
698
|
+
* class Rifle {}
|
|
699
|
+
* ```
|
|
700
|
+
*
|
|
701
|
+
* Note that `@Alias` decorators can be stacked to add multiple aliases.
|
|
702
|
+
*
|
|
703
|
+
* Example:
|
|
704
|
+
* ```ts
|
|
705
|
+
* @Alias(Weapon)
|
|
706
|
+
* @Alias(Gun) // Or just @Alias(Weapon, Gun)
|
|
707
|
+
* class Rifle {}
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
declare function Alias<Value, This extends Value & object>(token: Token<Value>): ClassDecorator<This>;
|
|
711
|
+
declare function Alias<VA, VB, This extends VA & VB & object>(tokenA: Token<VA>, tokenB: Token<VB>): ClassDecorator<This>;
|
|
712
|
+
declare function Alias<VA, VB, VC, This extends VA & VB & VC & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>): ClassDecorator<This>;
|
|
713
|
+
declare function Alias<VA, VB, VC, VD, This extends VA & VB & VC & VD & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>, tokenD: Token<VD>): ClassDecorator<This>;
|
|
714
|
+
declare function Alias<VA, VB, VC, VD, VE, This extends VA & VB & VC & VD & VE & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>, tokenD: Token<VD>, tokenE: Token<VE>): ClassDecorator<This>;
|
|
715
|
+
declare function Alias<VA, VB, VC, VD, VE, VF, This extends VA & VB & VC & VD & VE & VF & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>, tokenD: Token<VD>, tokenE: Token<VE>, tokenF: Token<VF>): ClassDecorator<This>;
|
|
716
|
+
/**
|
|
717
|
+
* Class decorator that registers an additional aliasing token for the decorated type.
|
|
718
|
+
*
|
|
719
|
+
* The alias is added using an {@link ExistingProvider} when the class is first
|
|
720
|
+
* registered in the container.
|
|
721
|
+
*
|
|
722
|
+
* This overload allows referencing tokens that are declared later in the file
|
|
723
|
+
* by using the {@link tokenRef} helper function.
|
|
724
|
+
*
|
|
725
|
+
* Example:
|
|
726
|
+
* ```ts
|
|
727
|
+
* @Alias(tokenRef(() => Weapon)) // Weapon is declared after Rifle
|
|
728
|
+
* class Rifle {}
|
|
729
|
+
* // Other code...
|
|
730
|
+
* const Weapon = createType("Weapon");
|
|
731
|
+
* ```
|
|
732
|
+
*
|
|
733
|
+
* Note that `@Alias` decorators can be stacked to add multiple aliases.
|
|
734
|
+
*
|
|
735
|
+
* Example:
|
|
736
|
+
* ```ts
|
|
737
|
+
* @Alias(tokenRef(() => Weapon))
|
|
738
|
+
* @Alias(Gun)
|
|
739
|
+
* class Rifle {}
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
declare function Alias<Value, This extends Value & object>(tokens: TokenRef<Value>): ClassDecorator<This>;
|
|
743
|
+
|
|
689
744
|
/**
|
|
690
745
|
* Class decorator that enables auto-registration of an unregistered class
|
|
691
746
|
* when the class is first resolved from the container.
|
|
@@ -765,65 +820,6 @@ declare function Inject<Value>(token: Token<Value>): ParameterDecorator;
|
|
|
765
820
|
*/
|
|
766
821
|
declare function Inject<Value>(tokens: TokenRef<Value>): ParameterDecorator;
|
|
767
822
|
|
|
768
|
-
/**
|
|
769
|
-
* Class decorator that registers additional aliasing tokens for the decorated type.
|
|
770
|
-
*
|
|
771
|
-
* The aliases are added using {@link ExistingProvider}(s) when the class is first
|
|
772
|
-
* registered in the container.
|
|
773
|
-
*
|
|
774
|
-
* Example:
|
|
775
|
-
* ```ts
|
|
776
|
-
* @Alias(Weapon)
|
|
777
|
-
* class Rifle {}
|
|
778
|
-
* ```
|
|
779
|
-
*
|
|
780
|
-
* Note that `@Alias` decorators can be stacked to add multiple aliases.
|
|
781
|
-
*
|
|
782
|
-
* Example:
|
|
783
|
-
* ```ts
|
|
784
|
-
* @Alias(Weapon)
|
|
785
|
-
* @Alias(Gun) // Or just @Alias(Weapon, Gun)
|
|
786
|
-
* class Rifle {}
|
|
787
|
-
* ```
|
|
788
|
-
*/
|
|
789
|
-
declare function Alias<Value, This extends Value & object>(token: Token<Value>): ClassDecorator<This>;
|
|
790
|
-
declare function Alias<VA, VB, This extends VA & VB & object>(tokenA: Token<VA>, tokenB: Token<VB>): ClassDecorator<This>;
|
|
791
|
-
declare function Alias<VA, VB, VC, This extends VA & VB & VC & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>): ClassDecorator<This>;
|
|
792
|
-
declare function Alias<VA, VB, VC, VD, This extends VA & VB & VC & VD & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>, tokenD: Token<VD>): ClassDecorator<This>;
|
|
793
|
-
declare function Alias<VA, VB, VC, VD, VE, This extends VA & VB & VC & VD & VE & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>, tokenD: Token<VD>, tokenE: Token<VE>): ClassDecorator<This>;
|
|
794
|
-
declare function Alias<VA, VB, VC, VD, VE, VF, This extends VA & VB & VC & VD & VE & VF & object>(tokenA: Token<VA>, tokenB: Token<VB>, tokenC: Token<VC>, tokenD: Token<VD>, tokenE: Token<VE>, tokenF: Token<VF>): ClassDecorator<This>;
|
|
795
|
-
/**
|
|
796
|
-
* Class decorator that registers an additional aliasing token for the decorated type.
|
|
797
|
-
*
|
|
798
|
-
* The alias is added using an {@link ExistingProvider} when the class is first
|
|
799
|
-
* registered in the container.
|
|
800
|
-
*
|
|
801
|
-
* This overload allows referencing tokens that are declared later in the file
|
|
802
|
-
* by using the {@link tokenRef} helper function.
|
|
803
|
-
*
|
|
804
|
-
* Example:
|
|
805
|
-
* ```ts
|
|
806
|
-
* @Alias(tokenRef(() => Weapon)) // Weapon is declared after Rifle
|
|
807
|
-
* class Rifle {}
|
|
808
|
-
* // Other code...
|
|
809
|
-
* const Weapon = createType("Weapon");
|
|
810
|
-
* ```
|
|
811
|
-
*
|
|
812
|
-
* Note that `@Alias` decorators can be stacked to add multiple aliases.
|
|
813
|
-
*
|
|
814
|
-
* Example:
|
|
815
|
-
* ```ts
|
|
816
|
-
* @Alias(tokenRef(() => Weapon))
|
|
817
|
-
* @Alias(Gun)
|
|
818
|
-
* class Rifle {}
|
|
819
|
-
* ```
|
|
820
|
-
*/
|
|
821
|
-
declare function Alias<Value, This extends Value & object>(tokens: TokenRef<Value>): ClassDecorator<This>;
|
|
822
|
-
/**
|
|
823
|
-
* @deprecated Use {@link Alias} instead.
|
|
824
|
-
*/
|
|
825
|
-
declare const Injectable: typeof Alias;
|
|
826
|
-
|
|
827
823
|
/**
|
|
828
824
|
* Parameter decorator that injects all instances provided by the registrations
|
|
829
825
|
* associated with the given class.
|
|
@@ -1291,5 +1287,5 @@ declare function optionalBy<Instance extends object>(thisArg: object, Class: Con
|
|
|
1291
1287
|
*/
|
|
1292
1288
|
declare function optionalBy<Value>(thisArg: object, token: Token<Value>, name?: string): Value | undefined;
|
|
1293
1289
|
|
|
1294
|
-
export { Alias, AutoRegister, ContainerScoped, EagerInstantiate, Inject, InjectAll,
|
|
1290
|
+
export { Alias, AutoRegister, ContainerScoped, EagerInstantiate, Inject, InjectAll, Injector, Named, Optional, OptionalAll, ResolutionScoped, Scope, Scoped, TransientScoped, assertInjectionContext, build, classRef, createContainer, createType, inject, injectAll, injectBy, optional, optionalAll, optionalBy, setClassIdentityMapping, tokenRef };
|
|
1295
1291
|
export type { ChildContainerOptions, ClassProvider, ClassRef, Constructor, Container, ContainerHook, ContainerOptions, ExistingProvider, FactoryProvider, Provider, ProviderType, RegistrationOptions, Token, TokenRef, Tokens, Type, ValueProvider };
|
package/dist/es/index.mjs
CHANGED
|
@@ -1128,6 +1128,26 @@ function isDisposable(value) {
|
|
|
1128
1128
|
return new ContainerImpl(undefined, options);
|
|
1129
1129
|
}
|
|
1130
1130
|
|
|
1131
|
+
// @__NO_SIDE_EFFECTS__
|
|
1132
|
+
function Alias(...args) {
|
|
1133
|
+
return (target)=>{
|
|
1134
|
+
const metadata = getMetadata(target);
|
|
1135
|
+
const arg0 = args[0];
|
|
1136
|
+
const ref = isTokenRef(arg0) ? arg0 : tokenRef(()=>args);
|
|
1137
|
+
const currentRef = metadata.tokenRef;
|
|
1138
|
+
metadata.tokenRef = {
|
|
1139
|
+
getRefToken: ()=>currentRef.getRefToken(),
|
|
1140
|
+
getRefTokens: ()=>{
|
|
1141
|
+
const existingTokens = currentRef.getRefTokens();
|
|
1142
|
+
for (const token of ref.getRefTokens()){
|
|
1143
|
+
existingTokens.add(token);
|
|
1144
|
+
}
|
|
1145
|
+
return existingTokens;
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1131
1151
|
/**
|
|
1132
1152
|
* Class decorator that enables auto-registration of an unregistered class
|
|
1133
1153
|
* when the class is first resolved from the container.
|
|
@@ -1192,29 +1212,6 @@ function Inject(token) {
|
|
|
1192
1212
|
};
|
|
1193
1213
|
}
|
|
1194
1214
|
|
|
1195
|
-
// @__NO_SIDE_EFFECTS__
|
|
1196
|
-
function Alias(...args) {
|
|
1197
|
-
return (target)=>{
|
|
1198
|
-
const metadata = getMetadata(target);
|
|
1199
|
-
const arg0 = args[0];
|
|
1200
|
-
const ref = isTokenRef(arg0) ? arg0 : tokenRef(()=>args);
|
|
1201
|
-
const currentRef = metadata.tokenRef;
|
|
1202
|
-
metadata.tokenRef = {
|
|
1203
|
-
getRefToken: ()=>currentRef.getRefToken(),
|
|
1204
|
-
getRefTokens: ()=>{
|
|
1205
|
-
const existingTokens = currentRef.getRefTokens();
|
|
1206
|
-
for (const token of ref.getRefTokens()){
|
|
1207
|
-
existingTokens.add(token);
|
|
1208
|
-
}
|
|
1209
|
-
return existingTokens;
|
|
1210
|
-
}
|
|
1211
|
-
};
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
/**
|
|
1215
|
-
* @deprecated Use {@link Alias} instead.
|
|
1216
|
-
*/ const Injectable = Alias;
|
|
1217
|
-
|
|
1218
1215
|
// @__NO_SIDE_EFFECTS__
|
|
1219
1216
|
function InjectAll(token) {
|
|
1220
1217
|
return (target, propertyKey, parameterIndex)=>{
|
|
@@ -1437,5 +1434,5 @@ const Scope = {
|
|
|
1437
1434
|
*/ Container: "Container"
|
|
1438
1435
|
};
|
|
1439
1436
|
|
|
1440
|
-
export { Alias, AutoRegister, ContainerScoped, EagerInstantiate, Inject, InjectAll,
|
|
1437
|
+
export { Alias, AutoRegister, ContainerScoped, EagerInstantiate, Inject, InjectAll, Injector, Named, Optional, OptionalAll, ResolutionScoped, Scope, Scoped, TransientScoped, assertInjectionContext, build, classRef, createContainer, createType, inject, injectAll, injectBy, optional, optionalAll, optionalBy, setClassIdentityMapping, tokenRef };
|
|
1441
1438
|
//# sourceMappingURL=index.mjs.map
|