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
@@ -1,20 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AsyncContainerModule = exports.ContainerModule = void 0;
4
- var id_1 = require("../utils/id");
5
- var ContainerModule = (function () {
6
- function ContainerModule(registry) {
4
+ const id_1 = require("../utils/id");
5
+ class ContainerModule {
6
+ id;
7
+ registry;
8
+ constructor(registry) {
7
9
  this.id = (0, id_1.id)();
8
10
  this.registry = registry;
9
11
  }
10
- return ContainerModule;
11
- }());
12
+ }
12
13
  exports.ContainerModule = ContainerModule;
13
- var AsyncContainerModule = (function () {
14
- function AsyncContainerModule(registry) {
14
+ class AsyncContainerModule {
15
+ id;
16
+ registry;
17
+ constructor(registry) {
15
18
  this.id = (0, id_1.id)();
16
19
  this.registry = registry;
17
20
  }
18
- return AsyncContainerModule;
19
- }());
21
+ }
20
22
  exports.AsyncContainerModule = AsyncContainerModule;
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContainerSnapshot = void 0;
4
- var ContainerSnapshot = (function () {
5
- function ContainerSnapshot() {
6
- }
7
- ContainerSnapshot.of = function (bindings, middleware, activations, deactivations, moduleActivationStore) {
8
- var snapshot = new ContainerSnapshot();
4
+ class ContainerSnapshot {
5
+ bindings;
6
+ activations;
7
+ deactivations;
8
+ middleware;
9
+ moduleActivationStore;
10
+ static of(bindings, middleware, activations, deactivations, moduleActivationStore) {
11
+ const snapshot = new ContainerSnapshot();
9
12
  snapshot.bindings = bindings;
10
13
  snapshot.middleware = middleware;
11
14
  snapshot.deactivations = deactivations;
12
15
  snapshot.activations = activations;
13
16
  snapshot.moduleActivationStore = moduleActivationStore;
14
17
  return snapshot;
15
- };
16
- return ContainerSnapshot;
17
- }());
18
+ }
19
+ }
18
20
  exports.ContainerSnapshot = ContainerSnapshot;
@@ -15,75 +15,81 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.Lookup = void 0;
27
- var ERROR_MSGS = __importStar(require("../constants/error_msgs"));
28
- var clonable_1 = require("../utils/clonable");
29
- var Lookup = (function () {
30
- function Lookup() {
37
+ const ERROR_MSGS = __importStar(require("../constants/error_msgs"));
38
+ const clonable_1 = require("../utils/clonable");
39
+ class Lookup {
40
+ _map;
41
+ constructor() {
31
42
  this._map = new Map();
32
43
  }
33
- Lookup.prototype.getMap = function () {
44
+ getMap() {
34
45
  return this._map;
35
- };
36
- Lookup.prototype.add = function (serviceIdentifier, value) {
46
+ }
47
+ add(serviceIdentifier, value) {
37
48
  this._checkNonNulish(serviceIdentifier);
38
49
  if (value === null || value === undefined) {
39
50
  throw new Error(ERROR_MSGS.NULL_ARGUMENT);
40
51
  }
41
- var entry = this._map.get(serviceIdentifier);
52
+ const entry = this._map.get(serviceIdentifier);
42
53
  if (entry !== undefined) {
43
54
  entry.push(value);
44
55
  }
45
56
  else {
46
57
  this._map.set(serviceIdentifier, [value]);
47
58
  }
48
- };
49
- Lookup.prototype.get = function (serviceIdentifier) {
59
+ }
60
+ get(serviceIdentifier) {
50
61
  this._checkNonNulish(serviceIdentifier);
51
- var entry = this._map.get(serviceIdentifier);
62
+ const entry = this._map.get(serviceIdentifier);
52
63
  if (entry !== undefined) {
53
64
  return entry;
54
65
  }
55
66
  else {
56
67
  throw new Error(ERROR_MSGS.KEY_NOT_FOUND);
57
68
  }
58
- };
59
- Lookup.prototype.remove = function (serviceIdentifier) {
69
+ }
70
+ remove(serviceIdentifier) {
60
71
  this._checkNonNulish(serviceIdentifier);
61
72
  if (!this._map.delete(serviceIdentifier)) {
62
73
  throw new Error(ERROR_MSGS.KEY_NOT_FOUND);
63
74
  }
64
- };
65
- Lookup.prototype.removeIntersection = function (lookup) {
66
- var _this = this;
67
- this.traverse(function (serviceIdentifier, value) {
68
- var lookupActivations = lookup.hasKey(serviceIdentifier)
75
+ }
76
+ removeIntersection(lookup) {
77
+ this.traverse((serviceIdentifier, value) => {
78
+ const lookupActivations = lookup.hasKey(serviceIdentifier)
69
79
  ? lookup.get(serviceIdentifier)
70
80
  : undefined;
71
81
  if (lookupActivations !== undefined) {
72
- var filteredValues = value.filter(function (lookupValue) {
73
- return !lookupActivations.some(function (moduleActivation) { return lookupValue === moduleActivation; });
74
- });
75
- _this._setValue(serviceIdentifier, filteredValues);
82
+ const filteredValues = value.filter((lookupValue) => !lookupActivations.some((moduleActivation) => lookupValue === moduleActivation));
83
+ this._setValue(serviceIdentifier, filteredValues);
76
84
  }
77
85
  });
78
- };
79
- Lookup.prototype.removeByCondition = function (condition) {
80
- var _this = this;
81
- var removals = [];
82
- this._map.forEach(function (entries, key) {
83
- var updatedEntries = [];
84
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
85
- var entry = entries_1[_i];
86
- var remove = condition(entry);
86
+ }
87
+ removeByCondition(condition) {
88
+ const removals = [];
89
+ this._map.forEach((entries, key) => {
90
+ const updatedEntries = [];
91
+ for (const entry of entries) {
92
+ const remove = condition(entry);
87
93
  if (remove) {
88
94
  removals.push(entry);
89
95
  }
@@ -91,41 +97,40 @@ var Lookup = (function () {
91
97
  updatedEntries.push(entry);
92
98
  }
93
99
  }
94
- _this._setValue(key, updatedEntries);
100
+ this._setValue(key, updatedEntries);
95
101
  });
96
102
  return removals;
97
- };
98
- Lookup.prototype.hasKey = function (serviceIdentifier) {
103
+ }
104
+ hasKey(serviceIdentifier) {
99
105
  this._checkNonNulish(serviceIdentifier);
100
106
  return this._map.has(serviceIdentifier);
101
- };
102
- Lookup.prototype.clone = function () {
103
- var copy = new Lookup();
104
- this._map.forEach(function (value, key) {
105
- value.forEach(function (b) {
107
+ }
108
+ clone() {
109
+ const copy = new Lookup();
110
+ this._map.forEach((value, key) => {
111
+ value.forEach((b) => {
106
112
  copy.add(key, (0, clonable_1.isClonable)(b) ? b.clone() : b);
107
113
  });
108
114
  });
109
115
  return copy;
110
- };
111
- Lookup.prototype.traverse = function (func) {
112
- this._map.forEach(function (value, key) {
116
+ }
117
+ traverse(func) {
118
+ this._map.forEach((value, key) => {
113
119
  func(key, value);
114
120
  });
115
- };
116
- Lookup.prototype._checkNonNulish = function (value) {
121
+ }
122
+ _checkNonNulish(value) {
117
123
  if (value == null) {
118
124
  throw new Error(ERROR_MSGS.NULL_ARGUMENT);
119
125
  }
120
- };
121
- Lookup.prototype._setValue = function (serviceIdentifier, value) {
126
+ }
127
+ _setValue(serviceIdentifier, value) {
122
128
  if (value.length > 0) {
123
129
  this._map.set(serviceIdentifier, value);
124
130
  }
125
131
  else {
126
132
  this._map.delete(serviceIdentifier);
127
133
  }
128
- };
129
- return Lookup;
130
- }());
134
+ }
135
+ }
131
136
  exports.Lookup = Lookup;
@@ -2,8 +2,8 @@ import { interfaces } from '../interfaces/interfaces';
2
2
  export declare class ModuleActivationStore implements interfaces.ModuleActivationStore {
3
3
  private readonly _map;
4
4
  remove(moduleId: number): interfaces.ModuleActivationHandlers;
5
- addDeactivation(moduleId: number, serviceIdentifier: interfaces.ServiceIdentifier<unknown>, onDeactivation: interfaces.BindingDeactivation<unknown>): void;
6
- addActivation(moduleId: number, serviceIdentifier: interfaces.ServiceIdentifier<unknown>, onActivation: interfaces.BindingActivation<unknown>): void;
5
+ addDeactivation<T>(moduleId: number, serviceIdentifier: interfaces.ServiceIdentifier<T>, onDeactivation: interfaces.BindingDeactivation<T>): void;
6
+ addActivation<T>(moduleId: number, serviceIdentifier: interfaces.ServiceIdentifier<T>, onActivation: interfaces.BindingActivation<T>): void;
7
7
  clone(): interfaces.ModuleActivationStore;
8
8
  private _getModuleActivationHandlers;
9
9
  private _getEmptyHandlersStore;
@@ -1,50 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModuleActivationStore = void 0;
4
- var lookup_1 = require("./lookup");
5
- var ModuleActivationStore = (function () {
6
- function ModuleActivationStore() {
7
- this._map = new Map();
8
- }
9
- ModuleActivationStore.prototype.remove = function (moduleId) {
10
- var handlers = this._map.get(moduleId);
4
+ const lookup_1 = require("./lookup");
5
+ class ModuleActivationStore {
6
+ _map = new Map();
7
+ remove(moduleId) {
8
+ const handlers = this._map.get(moduleId);
11
9
  if (handlers === undefined) {
12
10
  return this._getEmptyHandlersStore();
13
11
  }
14
12
  this._map.delete(moduleId);
15
13
  return handlers;
16
- };
17
- ModuleActivationStore.prototype.addDeactivation = function (moduleId, serviceIdentifier, onDeactivation) {
14
+ }
15
+ addDeactivation(moduleId, serviceIdentifier, onDeactivation) {
18
16
  this._getModuleActivationHandlers(moduleId).onDeactivations.add(serviceIdentifier, onDeactivation);
19
- };
20
- ModuleActivationStore.prototype.addActivation = function (moduleId, serviceIdentifier, onActivation) {
17
+ }
18
+ addActivation(moduleId, serviceIdentifier, onActivation) {
21
19
  this._getModuleActivationHandlers(moduleId).onActivations.add(serviceIdentifier, onActivation);
22
- };
23
- ModuleActivationStore.prototype.clone = function () {
24
- var clone = new ModuleActivationStore();
25
- this._map.forEach(function (handlersStore, moduleId) {
20
+ }
21
+ clone() {
22
+ const clone = new ModuleActivationStore();
23
+ this._map.forEach((handlersStore, moduleId) => {
26
24
  clone._map.set(moduleId, {
27
25
  onActivations: handlersStore.onActivations.clone(),
28
26
  onDeactivations: handlersStore.onDeactivations.clone(),
29
27
  });
30
28
  });
31
29
  return clone;
32
- };
33
- ModuleActivationStore.prototype._getModuleActivationHandlers = function (moduleId) {
34
- var moduleActivationHandlers = this._map.get(moduleId);
30
+ }
31
+ _getModuleActivationHandlers(moduleId) {
32
+ let moduleActivationHandlers = this._map.get(moduleId);
35
33
  if (moduleActivationHandlers === undefined) {
36
34
  moduleActivationHandlers = this._getEmptyHandlersStore();
37
35
  this._map.set(moduleId, moduleActivationHandlers);
38
36
  }
39
37
  return moduleActivationHandlers;
40
- };
41
- ModuleActivationStore.prototype._getEmptyHandlersStore = function () {
42
- var handlersStore = {
38
+ }
39
+ _getEmptyHandlersStore() {
40
+ const handlersStore = {
43
41
  onActivations: new lookup_1.Lookup(),
44
42
  onDeactivations: new lookup_1.Lookup(),
45
43
  };
46
44
  return handlersStore;
47
- };
48
- return ModuleActivationStore;
49
- }());
45
+ }
46
+ }
50
47
  exports.ModuleActivationStore = ModuleActivationStore;
@@ -182,8 +182,8 @@ declare namespace interfaces {
182
182
  onDeactivations: Lookup<BindingDeactivation<unknown>>;
183
183
  }
184
184
  export interface ModuleActivationStore extends Clonable<ModuleActivationStore> {
185
- addDeactivation(moduleId: ContainerModuleBase['id'], serviceIdentifier: ServiceIdentifier<unknown>, onDeactivation: interfaces.BindingDeactivation<unknown>): void;
186
- addActivation(moduleId: ContainerModuleBase['id'], serviceIdentifier: ServiceIdentifier<unknown>, onActivation: interfaces.BindingActivation<unknown>): void;
185
+ addDeactivation<T>(moduleId: ContainerModuleBase['id'], serviceIdentifier: ServiceIdentifier<T>, onDeactivation: interfaces.BindingDeactivation<T>): void;
186
+ addActivation<T>(moduleId: ContainerModuleBase['id'], serviceIdentifier: ServiceIdentifier<T>, onActivation: interfaces.BindingActivation<T>): void;
187
187
  remove(moduleId: ContainerModuleBase['id']): ModuleActivationHandlers;
188
188
  }
189
189
  export type ContainerModuleCallBack = (bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind, unbindAsync: interfaces.UnbindAsync, onActivation: interfaces.Container['onActivation'], onDeactivation: interfaces.Container['onDeactivation']) => void;
@@ -1,3 +1,4 @@
1
+ import 'reflect-metadata';
1
2
  import * as keys from './constants/metadata_keys';
2
3
  export { LazyServiceIdentifier } from '@inversifyjs/common';
3
4
  export declare const METADATA_KEY: typeof keys;
package/lib/inversify.js CHANGED
@@ -15,16 +15,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.multiBindToService = exports.getServiceIdentifierAsString = exports.typeConstraint = exports.namedConstraint = exports.taggedConstraint = exports.traverseAncerstors = exports.decorate = exports.id = exports.MetadataReader = exports.preDestroy = exports.postConstruct = exports.targetName = exports.multiInject = exports.unmanaged = exports.optional = exports.inject = exports.named = exports.tagged = exports.injectable = exports.createTaggedDecorator = exports.ContainerModule = exports.AsyncContainerModule = exports.TargetTypeEnum = exports.BindingTypeEnum = exports.BindingScopeEnum = exports.Container = exports.METADATA_KEY = exports.LazyServiceIdentifier = void 0;
27
- var keys = __importStar(require("./constants/metadata_keys"));
37
+ require("reflect-metadata");
38
+ const keys = __importStar(require("./constants/metadata_keys"));
28
39
  var common_1 = require("@inversifyjs/common");
29
40
  Object.defineProperty(exports, "LazyServiceIdentifier", { enumerable: true, get: function () { return common_1.LazyServiceIdentifier; } });
30
41
  exports.METADATA_KEY = keys;
@@ -1,18 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Context = void 0;
4
- var id_1 = require("../utils/id");
5
- var Context = (function () {
6
- function Context(container) {
4
+ const id_1 = require("../utils/id");
5
+ class Context {
6
+ id;
7
+ container;
8
+ plan;
9
+ currentRequest;
10
+ constructor(container) {
7
11
  this.id = (0, id_1.id)();
8
12
  this.container = container;
9
13
  }
10
- Context.prototype.addPlan = function (plan) {
14
+ addPlan(plan) {
11
15
  this.plan = plan;
12
- };
13
- Context.prototype.setCurrentRequest = function (currentRequest) {
16
+ }
17
+ setCurrentRequest(currentRequest) {
14
18
  this.currentRequest = currentRequest;
15
- };
16
- return Context;
17
- }());
19
+ }
20
+ }
18
21
  exports.Context = Context;
@@ -15,29 +15,40 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.Metadata = void 0;
27
- var METADATA_KEY = __importStar(require("../constants/metadata_keys"));
28
- var Metadata = (function () {
29
- function Metadata(key, value) {
37
+ const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
38
+ class Metadata {
39
+ key;
40
+ value;
41
+ constructor(key, value) {
30
42
  this.key = key;
31
43
  this.value = value;
32
44
  }
33
- Metadata.prototype.toString = function () {
45
+ toString() {
34
46
  if (this.key === METADATA_KEY.NAMED_TAG) {
35
- return "named: ".concat(String(this.value).toString(), " ");
47
+ return `named: ${String(this.value).toString()} `;
36
48
  }
37
49
  else {
38
- return "tagged: { key:".concat(this.key.toString(), ", value: ").concat(String(this.value), " }");
50
+ return `tagged: { key:${this.key.toString()}, value: ${String(this.value)} }`;
39
51
  }
40
- };
41
- return Metadata;
42
- }());
52
+ }
53
+ }
43
54
  exports.Metadata = Metadata;
@@ -15,33 +15,38 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.MetadataReader = void 0;
27
- var METADATA_KEY = __importStar(require("../constants/metadata_keys"));
28
- var MetadataReader = (function () {
29
- function MetadataReader() {
30
- }
31
- MetadataReader.prototype.getConstructorMetadata = function (constructorFunc) {
32
- var _a;
33
- var compilerGeneratedMetadata = (_a = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, constructorFunc)) !== null && _a !== void 0 ? _a : [];
34
- var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED, constructorFunc);
37
+ const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
38
+ class MetadataReader {
39
+ getConstructorMetadata(constructorFunc) {
40
+ const compilerGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, constructorFunc) ?? [];
41
+ const userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED, constructorFunc);
35
42
  return {
36
- compilerGeneratedMetadata: compilerGeneratedMetadata,
37
- userGeneratedMetadata: userGeneratedMetadata !== null && userGeneratedMetadata !== void 0 ? userGeneratedMetadata : {},
43
+ compilerGeneratedMetadata,
44
+ userGeneratedMetadata: userGeneratedMetadata ?? {},
38
45
  };
39
- };
40
- MetadataReader.prototype.getPropertiesMetadata = function (constructorFunc) {
41
- var _a;
42
- var userGeneratedMetadata = (_a = Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, constructorFunc)) !== null && _a !== void 0 ? _a : {};
46
+ }
47
+ getPropertiesMetadata(constructorFunc) {
48
+ const userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, constructorFunc) ?? {};
43
49
  return userGeneratedMetadata;
44
- };
45
- return MetadataReader;
46
- }());
50
+ }
51
+ }
47
52
  exports.MetadataReader = MetadataReader;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Plan = void 0;
4
- var Plan = (function () {
5
- function Plan(parentContext, rootRequest) {
4
+ class Plan {
5
+ parentContext;
6
+ rootRequest;
7
+ constructor(parentContext, rootRequest) {
6
8
  this.parentContext = parentContext;
7
9
  this.rootRequest = rootRequest;
8
10
  }
9
- return Plan;
10
- }());
11
+ }
11
12
  exports.Plan = Plan;