@lppedd/di-wise-neo 0.14.1 → 0.14.2
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 +64 -14
- package/dist/cjs/index.js +7 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.d.mts +64 -14
- package/dist/es/index.mjs +7 -4
- package/dist/es/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -617,13 +617,19 @@ declare function forwardRef<Value>(token: () => Token<Value>): TokenRef<Value>;
|
|
|
617
617
|
/**
|
|
618
618
|
* Parameter decorator that injects the instance associated with the given class.
|
|
619
619
|
*
|
|
620
|
-
* Throws an error if
|
|
620
|
+
* Throws an error if:
|
|
621
|
+
* - The class is not registered in the container.
|
|
622
|
+
* - A circular dependency is detected. Use function injection with {@link injectBy}
|
|
623
|
+
* if resolving circular dependencies is necessary.
|
|
621
624
|
*/
|
|
622
625
|
declare function Inject<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;
|
|
623
626
|
/**
|
|
624
627
|
* Parameter decorator that injects the value associated with the given token.
|
|
625
628
|
*
|
|
626
|
-
* Throws an error if
|
|
629
|
+
* Throws an error if:
|
|
630
|
+
* - The token is not registered in the container.
|
|
631
|
+
* - A circular dependency is detected. Use function injection with {@link injectBy}
|
|
632
|
+
* if resolving circular dependencies is necessary.
|
|
627
633
|
*/
|
|
628
634
|
declare function Inject<Value>(token: Token<Value>): ParameterDecorator;
|
|
629
635
|
/**
|
|
@@ -632,7 +638,10 @@ declare function Inject<Value>(token: Token<Value>): ParameterDecorator;
|
|
|
632
638
|
* Allows referencing a token declared later in the file by using the
|
|
633
639
|
* {@link forwardRef} helper function.
|
|
634
640
|
*
|
|
635
|
-
* Throws an error if
|
|
641
|
+
* Throws an error if:
|
|
642
|
+
* - The token is not registered in the container.
|
|
643
|
+
* - A circular dependency is detected. Use function injection with {@link injectBy}
|
|
644
|
+
* if resolving circular dependencies is necessary.
|
|
636
645
|
*
|
|
637
646
|
* @example
|
|
638
647
|
* ```ts
|
|
@@ -681,14 +690,18 @@ declare function Injectable<This extends object, Value extends This>(tokens: Tok
|
|
|
681
690
|
* Parameter decorator that injects all instances provided by the registrations
|
|
682
691
|
* associated with the given class.
|
|
683
692
|
*
|
|
684
|
-
* Throws an error if
|
|
693
|
+
* Throws an error if:
|
|
694
|
+
* - The class is not registered in the container.
|
|
695
|
+
* - A circular dependency is detected.
|
|
685
696
|
*/
|
|
686
697
|
declare function InjectAll<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;
|
|
687
698
|
/**
|
|
688
699
|
* Parameter decorator that injects all values provided by the registrations
|
|
689
700
|
* associated with the given token.
|
|
690
701
|
*
|
|
691
|
-
* Throws an error if
|
|
702
|
+
* Throws an error if:
|
|
703
|
+
* - The token is not registered in the container.
|
|
704
|
+
* - A circular dependency is detected.
|
|
692
705
|
*/
|
|
693
706
|
declare function InjectAll<Value>(token: Token<Value>): ParameterDecorator;
|
|
694
707
|
/**
|
|
@@ -698,7 +711,9 @@ declare function InjectAll<Value>(token: Token<Value>): ParameterDecorator;
|
|
|
698
711
|
* Allows referencing a token declared later in the file by using the
|
|
699
712
|
* {@link forwardRef} helper function.
|
|
700
713
|
*
|
|
701
|
-
* Throws an error if
|
|
714
|
+
* Throws an error if:
|
|
715
|
+
* - The token is not registered in the container.
|
|
716
|
+
* - A circular dependency is detected.
|
|
702
717
|
*
|
|
703
718
|
* @example
|
|
704
719
|
* ```ts
|
|
@@ -734,11 +749,17 @@ declare function Named(name: string): ClassDecorator & ParameterDecorator;
|
|
|
734
749
|
/**
|
|
735
750
|
* Parameter decorator that injects the instance associated with the given class,
|
|
736
751
|
* or `undefined` if the class is not registered in the container.
|
|
752
|
+
*
|
|
753
|
+
* Throws an error if a circular dependency is detected. Use function injection
|
|
754
|
+
* with {@link optionalBy} if resolving circular dependencies is necessary.
|
|
737
755
|
*/
|
|
738
756
|
declare function Optional<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;
|
|
739
757
|
/**
|
|
740
758
|
* Parameter decorator that injects the value associated with the given token,
|
|
741
759
|
* or `undefined` if the token is not registered in the container.
|
|
760
|
+
*
|
|
761
|
+
* Throws an error if a circular dependency is detected. Use function injection
|
|
762
|
+
* with {@link optionalBy} if resolving circular dependencies is necessary.
|
|
742
763
|
*/
|
|
743
764
|
declare function Optional<Value>(token: Token<Value>): ParameterDecorator;
|
|
744
765
|
/**
|
|
@@ -748,6 +769,9 @@ declare function Optional<Value>(token: Token<Value>): ParameterDecorator;
|
|
|
748
769
|
* Allows referencing a token declared later in the file by using the
|
|
749
770
|
* {@link forwardRef} helper function.
|
|
750
771
|
*
|
|
772
|
+
* Throws an error if a circular dependency is detected. Use function injection
|
|
773
|
+
* with {@link optionalBy} if resolving circular dependencies is necessary.
|
|
774
|
+
*
|
|
751
775
|
* @example
|
|
752
776
|
* ```ts
|
|
753
777
|
* class Wizard {
|
|
@@ -763,12 +787,16 @@ declare function Optional<Value>(tokens: TokenRef<Value>): ParameterDecorator;
|
|
|
763
787
|
* Parameter decorator that injects all instances provided by the registrations
|
|
764
788
|
* associated with the given class or an empty array if the class is not registered
|
|
765
789
|
* in the container.
|
|
790
|
+
*
|
|
791
|
+
* Throws an error if a circular dependency is detected.
|
|
766
792
|
*/
|
|
767
793
|
declare function OptionalAll<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;
|
|
768
794
|
/**
|
|
769
795
|
* Parameter decorator that injects all values provided by the registrations
|
|
770
796
|
* associated with the given token or an empty array if the token is not registered
|
|
771
797
|
* in the container.
|
|
798
|
+
*
|
|
799
|
+
* Throws an error if a circular dependency is detected.
|
|
772
800
|
*/
|
|
773
801
|
declare function OptionalAll<Value>(token: Token<Value>): ParameterDecorator;
|
|
774
802
|
/**
|
|
@@ -779,6 +807,8 @@ declare function OptionalAll<Value>(token: Token<Value>): ParameterDecorator;
|
|
|
779
807
|
* Allows referencing a token declared later in the file by using the
|
|
780
808
|
* {@link forwardRef} helper function.
|
|
781
809
|
*
|
|
810
|
+
* Throws an error if a circular dependency is detected.
|
|
811
|
+
*
|
|
782
812
|
* @example
|
|
783
813
|
* ```ts
|
|
784
814
|
* class Wizard {
|
|
@@ -817,13 +847,19 @@ declare function Scoped(scope: Scope): ClassDecorator;
|
|
|
817
847
|
/**
|
|
818
848
|
* Injects the instance associated with the given class.
|
|
819
849
|
*
|
|
820
|
-
* Throws an error if
|
|
850
|
+
* Throws an error if:
|
|
851
|
+
* - The class is not registered in the container.
|
|
852
|
+
* - A circular dependency is detected. Use {@link injectBy} if resolving
|
|
853
|
+
* circular dependencies is necessary.
|
|
821
854
|
*/
|
|
822
855
|
declare function inject<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance;
|
|
823
856
|
/**
|
|
824
857
|
* Injects the value associated with the given token.
|
|
825
858
|
*
|
|
826
|
-
* Throws an error if
|
|
859
|
+
* Throws an error if:
|
|
860
|
+
* - The token is not registered in the container.
|
|
861
|
+
* - A circular dependency is detected. Use {@link injectBy} if resolving
|
|
862
|
+
* circular dependencies is necessary.
|
|
827
863
|
*/
|
|
828
864
|
declare function inject<Value>(token: Token<Value>, name?: string): Value;
|
|
829
865
|
/**
|
|
@@ -832,7 +868,7 @@ declare function inject<Value>(token: Token<Value>, name?: string): Value;
|
|
|
832
868
|
* Throws an error if the class is not registered in the container.
|
|
833
869
|
*
|
|
834
870
|
* Compared to {@link inject}, `injectBy` accepts a `thisArg` argument
|
|
835
|
-
* (the containing class) which is used to resolve circular dependencies.
|
|
871
|
+
* (e.g., the containing class instance) which is used to resolve circular dependencies.
|
|
836
872
|
*
|
|
837
873
|
* @example
|
|
838
874
|
* ```ts
|
|
@@ -856,7 +892,7 @@ declare function injectBy<Instance extends object>(thisArg: any, Class: Construc
|
|
|
856
892
|
* Throws an error if the token is not registered in the container.
|
|
857
893
|
*
|
|
858
894
|
* Compared to {@link inject}, `injectBy` accepts a `thisArg` argument
|
|
859
|
-
* (the containing class) which is used to resolve circular dependencies.
|
|
895
|
+
* (e.g., the containing class instance) which is used to resolve circular dependencies.
|
|
860
896
|
*
|
|
861
897
|
* @example
|
|
862
898
|
* ```ts
|
|
@@ -878,13 +914,17 @@ declare function injectBy<Value>(thisArg: any, token: Token<Value>, name?: strin
|
|
|
878
914
|
/**
|
|
879
915
|
* Injects all instances provided by the registrations associated with the given class.
|
|
880
916
|
*
|
|
881
|
-
* Throws an error if
|
|
917
|
+
* Throws an error if:
|
|
918
|
+
* - The class is not registered in the container.
|
|
919
|
+
* - A circular dependency is detected.
|
|
882
920
|
*/
|
|
883
921
|
declare function injectAll<Instance extends object>(Class: Constructor<Instance>): Instance[];
|
|
884
922
|
/**
|
|
885
923
|
* Injects all values provided by the registrations associated with the given token.
|
|
886
924
|
*
|
|
887
|
-
* Throws an error if
|
|
925
|
+
* Throws an error if:
|
|
926
|
+
* - The token is not registered in the container.
|
|
927
|
+
* - A circular dependency is detected.
|
|
888
928
|
*/
|
|
889
929
|
declare function injectAll<Value>(token: Token<Value>): Value[];
|
|
890
930
|
|
|
@@ -1044,11 +1084,17 @@ declare function applyMiddleware(container: Container, middlewares: Middleware[]
|
|
|
1044
1084
|
/**
|
|
1045
1085
|
* Injects the instance associated with the given class,
|
|
1046
1086
|
* or `undefined` if the class is not registered in the container.
|
|
1087
|
+
*
|
|
1088
|
+
* Throws an error if a circular dependency is detected.
|
|
1089
|
+
* Use {@link optionalBy} if resolving circular dependencies is necessary.
|
|
1047
1090
|
*/
|
|
1048
1091
|
declare function optional<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance | undefined;
|
|
1049
1092
|
/**
|
|
1050
1093
|
* Injects the value associated with the given token,
|
|
1051
1094
|
* or `undefined` if the token is not registered in the container.
|
|
1095
|
+
*
|
|
1096
|
+
* Throws an error if a circular dependency is detected.
|
|
1097
|
+
* Use {@link optionalBy} if resolving circular dependencies is necessary.
|
|
1052
1098
|
*/
|
|
1053
1099
|
declare function optional<Value>(token: Token<Value>, name?: string): Value | undefined;
|
|
1054
1100
|
/**
|
|
@@ -1056,7 +1102,7 @@ declare function optional<Value>(token: Token<Value>, name?: string): Value | un
|
|
|
1056
1102
|
* or `undefined` if the class is not registered in the container.
|
|
1057
1103
|
*
|
|
1058
1104
|
* Compared to {@link optional}, `optionalBy` accepts a `thisArg` argument
|
|
1059
|
-
* (the containing class) which is used to resolve circular dependencies.
|
|
1105
|
+
* (e.g., the containing class instance) which is used to resolve circular dependencies.
|
|
1060
1106
|
*
|
|
1061
1107
|
* @param thisArg - The containing instance, used to help resolve circular dependencies.
|
|
1062
1108
|
* @param Class - The class to resolve.
|
|
@@ -1068,7 +1114,7 @@ declare function optionalBy<Instance extends object>(thisArg: any, Class: Constr
|
|
|
1068
1114
|
* or `undefined` if the token is not registered in the container.
|
|
1069
1115
|
*
|
|
1070
1116
|
* Compared to {@link optional}, `optionalBy` accepts a `thisArg` argument
|
|
1071
|
-
* (the containing class) which is used to resolve circular dependencies.
|
|
1117
|
+
* (e.g., the containing class instance) which is used to resolve circular dependencies.
|
|
1072
1118
|
*
|
|
1073
1119
|
* @param thisArg - The containing instance, used to help resolve circular dependencies.
|
|
1074
1120
|
* @param token - The token to resolve.
|
|
@@ -1079,11 +1125,15 @@ declare function optionalBy<Value>(thisArg: any, token: Token<Value>, name?: str
|
|
|
1079
1125
|
/**
|
|
1080
1126
|
* Injects all instances provided by the registrations associated with the given class
|
|
1081
1127
|
* or an empty array if the class is not registered in the container.
|
|
1128
|
+
*
|
|
1129
|
+
* Throws an error if a circular dependency is detected.
|
|
1082
1130
|
*/
|
|
1083
1131
|
declare function optionalAll<Instance extends object>(Class: Constructor<Instance>): Instance[];
|
|
1084
1132
|
/**
|
|
1085
1133
|
* Injects all values provided by the registrations associated with the given token
|
|
1086
1134
|
* or an empty array if the token is not registered in the container.
|
|
1135
|
+
*
|
|
1136
|
+
* Throws an error if a circular dependency is detected.
|
|
1087
1137
|
*/
|
|
1088
1138
|
declare function optionalAll<Value>(token: Token<Value>): Value[];
|
|
1089
1139
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -337,7 +337,6 @@ const Scope = {
|
|
|
337
337
|
*/ Container: "Container"
|
|
338
338
|
};
|
|
339
339
|
|
|
340
|
-
// @internal
|
|
341
340
|
// @__NO_SIDE_EFFECTS__
|
|
342
341
|
function createType(typeName, provider, options) {
|
|
343
342
|
const name = `Type<${typeName}>`;
|
|
@@ -1008,6 +1007,7 @@ function isDisposable(value) {
|
|
|
1008
1007
|
};
|
|
1009
1008
|
}
|
|
1010
1009
|
|
|
1010
|
+
// @__NO_SIDE_EFFECTS__
|
|
1011
1011
|
function forwardRef(token) {
|
|
1012
1012
|
return {
|
|
1013
1013
|
getRefTokens: ()=>{
|
|
@@ -1083,6 +1083,7 @@ function describeParam(target, methodKey, parameterIndex) {
|
|
|
1083
1083
|
return `${location}(parameter #${parameterIndex})`;
|
|
1084
1084
|
}
|
|
1085
1085
|
|
|
1086
|
+
// @__NO_SIDE_EFFECTS__
|
|
1086
1087
|
function Inject(token) {
|
|
1087
1088
|
return function(target, propertyKey, parameterIndex) {
|
|
1088
1089
|
updateParameterMetadata("Inject", target, propertyKey, parameterIndex, (dependency)=>{
|
|
@@ -1093,9 +1094,8 @@ function Inject(token) {
|
|
|
1093
1094
|
};
|
|
1094
1095
|
}
|
|
1095
1096
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
*/ function Injectable(...args) {
|
|
1097
|
+
// @__NO_SIDE_EFFECTS__
|
|
1098
|
+
function Injectable(...args) {
|
|
1099
1099
|
return function(Class) {
|
|
1100
1100
|
const metadata = getMetadata(Class);
|
|
1101
1101
|
const arg0 = args[0];
|
|
@@ -1113,6 +1113,7 @@ function Inject(token) {
|
|
|
1113
1113
|
};
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
1116
|
+
// @__NO_SIDE_EFFECTS__
|
|
1116
1117
|
function InjectAll(token) {
|
|
1117
1118
|
return function(target, propertyKey, parameterIndex) {
|
|
1118
1119
|
updateParameterMetadata("InjectAll", target, propertyKey, parameterIndex, (dependency)=>{
|
|
@@ -1165,6 +1166,7 @@ function InjectAll(token) {
|
|
|
1165
1166
|
};
|
|
1166
1167
|
}
|
|
1167
1168
|
|
|
1169
|
+
// @__NO_SIDE_EFFECTS__
|
|
1168
1170
|
function Optional(token) {
|
|
1169
1171
|
return function(target, propertyKey, parameterIndex) {
|
|
1170
1172
|
updateParameterMetadata("Optional", target, propertyKey, parameterIndex, (dependency)=>{
|
|
@@ -1175,6 +1177,7 @@ function Optional(token) {
|
|
|
1175
1177
|
};
|
|
1176
1178
|
}
|
|
1177
1179
|
|
|
1180
|
+
// @__NO_SIDE_EFFECTS__
|
|
1178
1181
|
function OptionalAll(token) {
|
|
1179
1182
|
return function(target, propertyKey, parameterIndex) {
|
|
1180
1183
|
updateParameterMetadata("OptionalAll", target, propertyKey, parameterIndex, (dependency)=>{
|