inversify 6.1.4 → 6.1.5-beta.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.
Files changed (267) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +6 -15
  3. package/es/container/container.d.ts +2 -0
  4. package/es/container/module_activation_store.d.ts +2 -2
  5. package/es/interfaces/interfaces.d.ts +2 -2
  6. package/es/inversify.d.ts +1 -0
  7. package/es/inversify.js +3 -2
  8. package/es/inversify.js.LICENSE.txt +14 -0
  9. package/lib/annotation/decorator_utils.js +31 -25
  10. package/lib/annotation/inject.js +20 -10
  11. package/lib/annotation/inject_base.js +6 -6
  12. package/lib/annotation/injectable.js +20 -10
  13. package/lib/annotation/multi_inject.js +20 -10
  14. package/lib/annotation/named.js +20 -10
  15. package/lib/annotation/optional.js +20 -10
  16. package/lib/annotation/post_construct.js +21 -11
  17. package/lib/annotation/pre_destroy.js +21 -11
  18. package/lib/annotation/property_event_decorator.js +4 -4
  19. package/lib/annotation/tagged.js +2 -2
  20. package/lib/annotation/target_name.js +21 -11
  21. package/lib/annotation/unmanaged.js +21 -11
  22. package/lib/bindings/binding.js +23 -10
  23. package/lib/constants/error_msgs.js +15 -29
  24. package/lib/constants/literal_types.js +3 -3
  25. package/lib/container/container.d.ts +2 -0
  26. package/lib/container/container.js +317 -566
  27. package/lib/container/container_module.js +11 -9
  28. package/lib/container/container_snapshot.js +10 -8
  29. package/lib/container/lookup.js +61 -56
  30. package/lib/container/module_activation_store.d.ts +2 -2
  31. package/lib/container/module_activation_store.js +21 -24
  32. package/lib/interfaces/interfaces.d.ts +2 -2
  33. package/lib/inversify.d.ts +1 -0
  34. package/lib/inversify.js +19 -8
  35. package/lib/planning/context.js +12 -9
  36. package/lib/planning/metadata.js +27 -16
  37. package/lib/planning/metadata_reader.js +29 -24
  38. package/lib/planning/plan.js +5 -4
  39. package/lib/planning/planner.js +62 -53
  40. package/lib/planning/queryable_string.js +16 -16
  41. package/lib/planning/reflection_utils.js +25 -17
  42. package/lib/planning/request.js +15 -8
  43. package/lib/resolution/instantiation.js +59 -119
  44. package/lib/resolution/resolver.js +89 -134
  45. package/lib/scope/scope.js +17 -62
  46. package/lib/syntax/binding_in_syntax.js +12 -12
  47. package/lib/syntax/binding_in_when_on_syntax.js +50 -47
  48. package/lib/syntax/binding_on_syntax.js +9 -9
  49. package/lib/syntax/binding_to_syntax.js +70 -49
  50. package/lib/syntax/binding_when_on_syntax.js +42 -40
  51. package/lib/syntax/binding_when_syntax.js +54 -76
  52. package/lib/syntax/constraint_helpers.js +31 -23
  53. package/lib/utils/async.js +1 -1
  54. package/lib/utils/binding_utils.js +31 -29
  55. package/lib/utils/exceptions.js +19 -9
  56. package/lib/utils/id.js +1 -1
  57. package/lib/utils/js.js +2 -3
  58. package/lib/utils/serialization.js +42 -33
  59. package/package.json +14 -15
  60. package/amd/annotation/decorator_utils.d.ts +0 -16
  61. package/amd/annotation/decorator_utils.js +0 -119
  62. package/amd/annotation/inject.d.ts +0 -5
  63. package/amd/annotation/inject.js +0 -31
  64. package/amd/annotation/inject_base.d.ts +0 -4
  65. package/amd/annotation/inject_base.js +0 -16
  66. package/amd/annotation/injectable.d.ts +0 -2
  67. package/amd/annotation/injectable.js +0 -40
  68. package/amd/annotation/lazy_service_identifier.js +0 -4
  69. package/amd/annotation/multi_inject.d.ts +0 -5
  70. package/amd/annotation/multi_inject.js +0 -31
  71. package/amd/annotation/named.d.ts +0 -2
  72. package/amd/annotation/named.js +0 -32
  73. package/amd/annotation/optional.d.ts +0 -2
  74. package/amd/annotation/optional.js +0 -32
  75. package/amd/annotation/post_construct.d.ts +0 -4
  76. package/amd/annotation/post_construct.js +0 -32
  77. package/amd/annotation/pre_destroy.d.ts +0 -4
  78. package/amd/annotation/pre_destroy.js +0 -32
  79. package/amd/annotation/property_event_decorator.d.ts +0 -4
  80. package/amd/annotation/property_event_decorator.js +0 -16
  81. package/amd/annotation/tagged.d.ts +0 -2
  82. package/amd/annotation/tagged.js +0 -8
  83. package/amd/annotation/target_name.d.ts +0 -3
  84. package/amd/annotation/target_name.js +0 -35
  85. package/amd/annotation/unmanaged.d.ts +0 -3
  86. package/amd/annotation/unmanaged.js +0 -35
  87. package/amd/bindings/binding.d.ts +0 -20
  88. package/amd/bindings/binding.js +0 -40
  89. package/amd/bindings/binding_count.d.ts +0 -5
  90. package/amd/bindings/binding_count.js +0 -11
  91. package/amd/constants/error_msgs.d.ts +0 -30
  92. package/amd/constants/error_msgs.js +0 -75
  93. package/amd/constants/literal_types.d.ts +0 -5
  94. package/amd/constants/literal_types.js +0 -28
  95. package/amd/constants/metadata_keys.d.ts +0 -13
  96. package/amd/constants/metadata_keys.js +0 -28
  97. package/amd/container/container.d.ts +0 -73
  98. package/amd/container/container.js +0 -766
  99. package/amd/container/container_module.d.ts +0 -11
  100. package/amd/container/container_module.js +0 -21
  101. package/amd/container/container_snapshot.d.ts +0 -10
  102. package/amd/container/container_snapshot.js +0 -20
  103. package/amd/container/lookup.d.ts +0 -17
  104. package/amd/container/lookup.js +0 -132
  105. package/amd/container/module_activation_store.d.ts +0 -10
  106. package/amd/container/module_activation_store.js +0 -51
  107. package/amd/interfaces/interfaces.d.ts +0 -269
  108. package/amd/interfaces/interfaces.js +0 -4
  109. package/amd/inversify.d.ts +0 -24
  110. package/amd/inversify.js +0 -57
  111. package/amd/planning/context.d.ts +0 -11
  112. package/amd/planning/context.js +0 -19
  113. package/amd/planning/metadata.d.ts +0 -8
  114. package/amd/planning/metadata.js +0 -45
  115. package/amd/planning/metadata_reader.d.ts +0 -6
  116. package/amd/planning/metadata_reader.js +0 -49
  117. package/amd/planning/plan.d.ts +0 -7
  118. package/amd/planning/plan.js +0 -13
  119. package/amd/planning/planner.d.ts +0 -5
  120. package/amd/planning/planner.js +0 -187
  121. package/amd/planning/queryable_string.d.ts +0 -10
  122. package/amd/planning/queryable_string.js +0 -33
  123. package/amd/planning/reflection_utils.d.ts +0 -5
  124. package/amd/planning/reflection_utils.js +0 -55
  125. package/amd/planning/request.d.ts +0 -14
  126. package/amd/planning/request.js +0 -24
  127. package/amd/planning/target.js +0 -111
  128. package/amd/resolution/instantiation.d.ts +0 -3
  129. package/amd/resolution/instantiation.js +0 -219
  130. package/amd/resolution/resolver.d.ts +0 -3
  131. package/amd/resolution/resolver.js +0 -234
  132. package/amd/scope/scope.d.ts +0 -3
  133. package/amd/scope/scope.js +0 -93
  134. package/amd/syntax/binding_in_syntax.d.ts +0 -9
  135. package/amd/syntax/binding_in_syntax.js +0 -24
  136. package/amd/syntax/binding_in_when_on_syntax.d.ts +0 -29
  137. package/amd/syntax/binding_in_when_on_syntax.js +0 -75
  138. package/amd/syntax/binding_on_syntax.d.ts +0 -8
  139. package/amd/syntax/binding_on_syntax.js +0 -20
  140. package/amd/syntax/binding_to_syntax.d.ts +0 -18
  141. package/amd/syntax/binding_to_syntax.js +0 -116
  142. package/amd/syntax/binding_when_on_syntax.d.ts +0 -25
  143. package/amd/syntax/binding_when_on_syntax.js +0 -65
  144. package/amd/syntax/binding_when_syntax.d.ts +0 -21
  145. package/amd/syntax/binding_when_syntax.js +0 -107
  146. package/amd/syntax/constraint_helpers.d.ts +0 -6
  147. package/amd/syntax/constraint_helpers.js +0 -66
  148. package/amd/utils/async.d.ts +0 -3
  149. package/amd/utils/async.js +0 -17
  150. package/amd/utils/binding_utils.d.ts +0 -4
  151. package/amd/utils/binding_utils.js +0 -86
  152. package/amd/utils/clonable.d.ts +0 -3
  153. package/amd/utils/clonable.js +0 -11
  154. package/amd/utils/exceptions.d.ts +0 -2
  155. package/amd/utils/exceptions.js +0 -46
  156. package/amd/utils/factory_type.d.ts +0 -5
  157. package/amd/utils/factory_type.js +0 -11
  158. package/amd/utils/id.d.ts +0 -2
  159. package/amd/utils/id.js +0 -9
  160. package/amd/utils/js.d.ts +0 -1
  161. package/amd/utils/js.js +0 -18
  162. package/amd/utils/serialization.d.ts +0 -10
  163. package/amd/utils/serialization.js +0 -135
  164. package/es6/annotation/decorator_utils.d.ts +0 -16
  165. package/es6/annotation/decorator_utils.js +0 -114
  166. package/es6/annotation/inject.d.ts +0 -5
  167. package/es6/annotation/inject.js +0 -30
  168. package/es6/annotation/inject_base.d.ts +0 -4
  169. package/es6/annotation/inject_base.js +0 -17
  170. package/es6/annotation/injectable.d.ts +0 -2
  171. package/es6/annotation/injectable.js +0 -38
  172. package/es6/annotation/lazy_service_identifier.js +0 -2
  173. package/es6/annotation/multi_inject.d.ts +0 -5
  174. package/es6/annotation/multi_inject.js +0 -30
  175. package/es6/annotation/named.d.ts +0 -2
  176. package/es6/annotation/named.js +0 -32
  177. package/es6/annotation/optional.d.ts +0 -2
  178. package/es6/annotation/optional.js +0 -32
  179. package/es6/annotation/post_construct.d.ts +0 -4
  180. package/es6/annotation/post_construct.js +0 -31
  181. package/es6/annotation/pre_destroy.d.ts +0 -4
  182. package/es6/annotation/pre_destroy.js +0 -31
  183. package/es6/annotation/property_event_decorator.d.ts +0 -4
  184. package/es6/annotation/property_event_decorator.js +0 -15
  185. package/es6/annotation/tagged.d.ts +0 -2
  186. package/es6/annotation/tagged.js +0 -8
  187. package/es6/annotation/target_name.d.ts +0 -3
  188. package/es6/annotation/target_name.js +0 -35
  189. package/es6/annotation/unmanaged.d.ts +0 -3
  190. package/es6/annotation/unmanaged.js +0 -35
  191. package/es6/bindings/binding.d.ts +0 -20
  192. package/es6/bindings/binding.js +0 -39
  193. package/es6/bindings/binding_count.d.ts +0 -5
  194. package/es6/bindings/binding_count.js +0 -9
  195. package/es6/constants/error_msgs.d.ts +0 -30
  196. package/es6/constants/error_msgs.js +0 -59
  197. package/es6/constants/literal_types.d.ts +0 -5
  198. package/es6/constants/literal_types.js +0 -26
  199. package/es6/constants/metadata_keys.d.ts +0 -13
  200. package/es6/constants/metadata_keys.js +0 -26
  201. package/es6/container/container.d.ts +0 -73
  202. package/es6/container/container.js +0 -545
  203. package/es6/container/container_module.d.ts +0 -11
  204. package/es6/container/container_module.js +0 -18
  205. package/es6/container/container_snapshot.d.ts +0 -10
  206. package/es6/container/container_snapshot.js +0 -15
  207. package/es6/container/lookup.d.ts +0 -17
  208. package/es6/container/lookup.js +0 -125
  209. package/es6/container/module_activation_store.d.ts +0 -10
  210. package/es6/container/module_activation_store.js +0 -49
  211. package/es6/interfaces/interfaces.d.ts +0 -269
  212. package/es6/interfaces/interfaces.js +0 -2
  213. package/es6/inversify.d.ts +0 -24
  214. package/es6/inversify.js +0 -76
  215. package/es6/planning/context.d.ts +0 -11
  216. package/es6/planning/context.js +0 -17
  217. package/es6/planning/metadata.d.ts +0 -8
  218. package/es6/planning/metadata.js +0 -42
  219. package/es6/planning/metadata_reader.d.ts +0 -6
  220. package/es6/planning/metadata_reader.js +0 -44
  221. package/es6/planning/plan.d.ts +0 -7
  222. package/es6/planning/plan.js +0 -10
  223. package/es6/planning/planner.d.ts +0 -5
  224. package/es6/planning/planner.js +0 -194
  225. package/es6/planning/queryable_string.d.ts +0 -10
  226. package/es6/planning/queryable_string.js +0 -30
  227. package/es6/planning/reflection_utils.d.ts +0 -5
  228. package/es6/planning/reflection_utils.js +0 -53
  229. package/es6/planning/request.d.ts +0 -14
  230. package/es6/planning/request.js +0 -22
  231. package/es6/planning/target.js +0 -105
  232. package/es6/resolution/instantiation.d.ts +0 -3
  233. package/es6/resolution/instantiation.js +0 -158
  234. package/es6/resolution/resolver.d.ts +0 -3
  235. package/es6/resolution/resolver.js +0 -193
  236. package/es6/scope/scope.d.ts +0 -3
  237. package/es6/scope/scope.js +0 -57
  238. package/es6/syntax/binding_in_syntax.d.ts +0 -9
  239. package/es6/syntax/binding_in_syntax.js +0 -23
  240. package/es6/syntax/binding_in_when_on_syntax.d.ts +0 -29
  241. package/es6/syntax/binding_in_when_on_syntax.js +0 -75
  242. package/es6/syntax/binding_on_syntax.d.ts +0 -8
  243. package/es6/syntax/binding_on_syntax.js +0 -18
  244. package/es6/syntax/binding_to_syntax.d.ts +0 -18
  245. package/es6/syntax/binding_to_syntax.js +0 -110
  246. package/es6/syntax/binding_when_on_syntax.d.ts +0 -25
  247. package/es6/syntax/binding_when_on_syntax.js +0 -64
  248. package/es6/syntax/binding_when_syntax.d.ts +0 -21
  249. package/es6/syntax/binding_when_syntax.js +0 -84
  250. package/es6/syntax/constraint_helpers.d.ts +0 -6
  251. package/es6/syntax/constraint_helpers.js +0 -63
  252. package/es6/utils/async.d.ts +0 -3
  253. package/es6/utils/async.js +0 -15
  254. package/es6/utils/binding_utils.d.ts +0 -4
  255. package/es6/utils/binding_utils.js +0 -79
  256. package/es6/utils/clonable.d.ts +0 -3
  257. package/es6/utils/clonable.js +0 -9
  258. package/es6/utils/exceptions.d.ts +0 -2
  259. package/es6/utils/exceptions.js +0 -44
  260. package/es6/utils/factory_type.d.ts +0 -5
  261. package/es6/utils/factory_type.js +0 -9
  262. package/es6/utils/id.d.ts +0 -2
  263. package/es6/utils/id.js +0 -7
  264. package/es6/utils/js.d.ts +0 -1
  265. package/es6/utils/js.js +0 -15
  266. package/es6/utils/serialization.d.ts +0 -10
  267. package/es6/utils/serialization.js +0 -132
@@ -8,32 +8,26 @@ exports.KEY_NOT_FOUND = 'Key Not Found';
8
8
  exports.AMBIGUOUS_MATCH = 'Ambiguous match found for serviceIdentifier:';
9
9
  exports.CANNOT_UNBIND = 'Could not unbind serviceIdentifier:';
10
10
  exports.NOT_REGISTERED = 'No matching bindings found for serviceIdentifier:';
11
- var TRYING_TO_RESOLVE_BINDINGS = function (name) { return "Trying to resolve bindings for \"".concat(name, "\""); };
11
+ const TRYING_TO_RESOLVE_BINDINGS = (name) => `Trying to resolve bindings for "${name}"`;
12
12
  exports.TRYING_TO_RESOLVE_BINDINGS = TRYING_TO_RESOLVE_BINDINGS;
13
- var UNDEFINED_INJECT_ANNOTATION = function (name) {
14
- return "@inject called with undefined this could mean that the class ".concat(name, " has ") +
15
- 'a circular dependency problem. You can use a LazyServiceIdentifer to ' +
16
- 'overcome this limitation.';
17
- };
13
+ const UNDEFINED_INJECT_ANNOTATION = (name) => `@inject called with undefined this could mean that the class ${name} has ` +
14
+ 'a circular dependency problem. You can use a LazyServiceIdentifer to ' +
15
+ 'overcome this limitation.';
18
16
  exports.UNDEFINED_INJECT_ANNOTATION = UNDEFINED_INJECT_ANNOTATION;
19
17
  exports.CIRCULAR_DEPENDENCY = 'Circular dependency found:';
20
18
  exports.INVALID_BINDING_TYPE = 'Invalid binding type:';
21
19
  exports.NO_MORE_SNAPSHOTS_AVAILABLE = 'No snapshot available to restore.';
22
20
  exports.INVALID_MIDDLEWARE_RETURN = 'Invalid return type in middleware. Middleware must return!';
23
21
  exports.INVALID_FUNCTION_BINDING = 'Value provided to function binding must be a function!';
24
- var LAZY_IN_SYNC = function (key) {
25
- return "You are attempting to construct ".concat(keyToString(key), " in a synchronous way ") +
26
- 'but it has asynchronous dependencies.';
27
- };
22
+ const LAZY_IN_SYNC = (key) => `You are attempting to construct ${keyToString(key)} in a synchronous way ` +
23
+ 'but it has asynchronous dependencies.';
28
24
  exports.LAZY_IN_SYNC = LAZY_IN_SYNC;
29
25
  exports.INVALID_TO_SELF_VALUE = 'The toSelf function can only be applied when a constructor is ' +
30
26
  'used as service identifier';
31
27
  exports.INVALID_DECORATOR_OPERATION = 'The @inject @multiInject @tagged and @named decorators ' +
32
28
  'must be applied to the parameters of a class constructor or a class property.';
33
- var ARGUMENTS_LENGTH_MISMATCH = function (name) {
34
- return 'The number of constructor arguments in the derived class ' +
35
- "".concat(name, " must be >= than the number of constructor arguments of its base class.");
36
- };
29
+ const ARGUMENTS_LENGTH_MISMATCH = (name) => 'The number of constructor arguments in the derived class ' +
30
+ `${name} must be >= than the number of constructor arguments of its base class.`;
37
31
  exports.ARGUMENTS_LENGTH_MISMATCH = ARGUMENTS_LENGTH_MISMATCH;
38
32
  exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = 'Invalid Container constructor argument. Container options ' +
39
33
  'must be an object.';
@@ -44,30 +38,22 @@ exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = 'Invalid Container option. S
44
38
  exports.MULTIPLE_PRE_DESTROY_METHODS = 'Cannot apply @preDestroy decorator multiple times in the same class';
45
39
  exports.MULTIPLE_POST_CONSTRUCT_METHODS = 'Cannot apply @postConstruct decorator multiple times in the same class';
46
40
  exports.ASYNC_UNBIND_REQUIRED = 'Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)';
47
- var POST_CONSTRUCT_ERROR = function (clazz, errorMessage) {
48
- return "@postConstruct error in class ".concat(clazz, ": ").concat(errorMessage);
49
- };
41
+ const POST_CONSTRUCT_ERROR = (clazz, errorMessage) => `@postConstruct error in class ${clazz}: ${errorMessage}`;
50
42
  exports.POST_CONSTRUCT_ERROR = POST_CONSTRUCT_ERROR;
51
- var PRE_DESTROY_ERROR = function (clazz, errorMessage) {
52
- return "@preDestroy error in class ".concat(clazz, ": ").concat(errorMessage);
53
- };
43
+ const PRE_DESTROY_ERROR = (clazz, errorMessage) => `@preDestroy error in class ${clazz}: ${errorMessage}`;
54
44
  exports.PRE_DESTROY_ERROR = PRE_DESTROY_ERROR;
55
- var ON_DEACTIVATION_ERROR = function (clazz, errorMessage) {
56
- return "onDeactivation() error in class ".concat(clazz, ": ").concat(errorMessage);
57
- };
45
+ const ON_DEACTIVATION_ERROR = (clazz, errorMessage) => `onDeactivation() error in class ${clazz}: ${errorMessage}`;
58
46
  exports.ON_DEACTIVATION_ERROR = ON_DEACTIVATION_ERROR;
59
- var CIRCULAR_DEPENDENCY_IN_FACTORY = function (factoryType, serviceIdentifier) {
60
- return "It looks like there is a circular dependency in one of the '".concat(factoryType, "' bindings. Please investigate bindings with ") +
61
- "service identifier '".concat(serviceIdentifier, "'.");
62
- };
47
+ const CIRCULAR_DEPENDENCY_IN_FACTORY = (factoryType, serviceIdentifier) => `It looks like there is a circular dependency in one of the '${factoryType}' bindings. Please investigate bindings with ` +
48
+ `service identifier '${serviceIdentifier}'.`;
63
49
  exports.CIRCULAR_DEPENDENCY_IN_FACTORY = CIRCULAR_DEPENDENCY_IN_FACTORY;
64
50
  exports.STACK_OVERFLOW = 'Maximum call stack size exceeded';
65
51
  function keyToString(key) {
66
52
  if (typeof key === 'function') {
67
- return "[function/class ".concat(key.name || '<anonymous>', "]");
53
+ return `[function/class ${key.name || '<anonymous>'}]`;
68
54
  }
69
55
  if (typeof key === 'symbol') {
70
56
  return key.toString();
71
57
  }
72
- return "'".concat(key, "'");
58
+ return `'${key}'`;
73
59
  }
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TargetTypeEnum = exports.BindingTypeEnum = exports.BindingScopeEnum = void 0;
4
- var BindingScopeEnum = {
4
+ const BindingScopeEnum = {
5
5
  Request: 'Request',
6
6
  Singleton: 'Singleton',
7
7
  Transient: 'Transient',
8
8
  };
9
9
  exports.BindingScopeEnum = BindingScopeEnum;
10
- var BindingTypeEnum = {
10
+ const BindingTypeEnum = {
11
11
  ConstantValue: 'ConstantValue',
12
12
  Constructor: 'Constructor',
13
13
  DynamicValue: 'DynamicValue',
@@ -18,7 +18,7 @@ var BindingTypeEnum = {
18
18
  Provider: 'Provider',
19
19
  };
20
20
  exports.BindingTypeEnum = BindingTypeEnum;
21
- var TargetTypeEnum = {
21
+ const TargetTypeEnum = {
22
22
  ClassProperty: 'ClassProperty',
23
23
  ConstructorArgument: 'ConstructorArgument',
24
24
  Variable: 'Variable',
@@ -55,6 +55,8 @@ declare class Container implements interfaces.Container {
55
55
  private _deactivateContainer;
56
56
  private _deactivateContainerAsync;
57
57
  private _getContainerModuleHelpersFactory;
58
+ private _bind;
59
+ private _buildBinding;
58
60
  private _getAll;
59
61
  private _get;
60
62
  private _getButThrowIfAsync;