@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/cjs/index.d.ts
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/cjs/index.js
CHANGED
|
@@ -1130,6 +1130,26 @@ function isDisposable(value) {
|
|
|
1130
1130
|
return new ContainerImpl(undefined, options);
|
|
1131
1131
|
}
|
|
1132
1132
|
|
|
1133
|
+
// @__NO_SIDE_EFFECTS__
|
|
1134
|
+
function Alias(...args) {
|
|
1135
|
+
return (target)=>{
|
|
1136
|
+
const metadata = getMetadata(target);
|
|
1137
|
+
const arg0 = args[0];
|
|
1138
|
+
const ref = isTokenRef(arg0) ? arg0 : tokenRef(()=>args);
|
|
1139
|
+
const currentRef = metadata.tokenRef;
|
|
1140
|
+
metadata.tokenRef = {
|
|
1141
|
+
getRefToken: ()=>currentRef.getRefToken(),
|
|
1142
|
+
getRefTokens: ()=>{
|
|
1143
|
+
const existingTokens = currentRef.getRefTokens();
|
|
1144
|
+
for (const token of ref.getRefTokens()){
|
|
1145
|
+
existingTokens.add(token);
|
|
1146
|
+
}
|
|
1147
|
+
return existingTokens;
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1133
1153
|
/**
|
|
1134
1154
|
* Class decorator that enables auto-registration of an unregistered class
|
|
1135
1155
|
* when the class is first resolved from the container.
|
|
@@ -1194,29 +1214,6 @@ function Inject(token) {
|
|
|
1194
1214
|
};
|
|
1195
1215
|
}
|
|
1196
1216
|
|
|
1197
|
-
// @__NO_SIDE_EFFECTS__
|
|
1198
|
-
function Alias(...args) {
|
|
1199
|
-
return (target)=>{
|
|
1200
|
-
const metadata = getMetadata(target);
|
|
1201
|
-
const arg0 = args[0];
|
|
1202
|
-
const ref = isTokenRef(arg0) ? arg0 : tokenRef(()=>args);
|
|
1203
|
-
const currentRef = metadata.tokenRef;
|
|
1204
|
-
metadata.tokenRef = {
|
|
1205
|
-
getRefToken: ()=>currentRef.getRefToken(),
|
|
1206
|
-
getRefTokens: ()=>{
|
|
1207
|
-
const existingTokens = currentRef.getRefTokens();
|
|
1208
|
-
for (const token of ref.getRefTokens()){
|
|
1209
|
-
existingTokens.add(token);
|
|
1210
|
-
}
|
|
1211
|
-
return existingTokens;
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
};
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* @deprecated Use {@link Alias} instead.
|
|
1218
|
-
*/ const Injectable = Alias;
|
|
1219
|
-
|
|
1220
1217
|
// @__NO_SIDE_EFFECTS__
|
|
1221
1218
|
function InjectAll(token) {
|
|
1222
1219
|
return (target, propertyKey, parameterIndex)=>{
|
|
@@ -1445,7 +1442,6 @@ exports.ContainerScoped = ContainerScoped;
|
|
|
1445
1442
|
exports.EagerInstantiate = EagerInstantiate;
|
|
1446
1443
|
exports.Inject = Inject;
|
|
1447
1444
|
exports.InjectAll = InjectAll;
|
|
1448
|
-
exports.Injectable = Injectable;
|
|
1449
1445
|
exports.Injector = Injector;
|
|
1450
1446
|
exports.Named = Named;
|
|
1451
1447
|
exports.Optional = Optional;
|