inversify 4.10.0 → 4.14.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 (57) hide show
  1. package/.auditignore +2 -0
  2. package/README.md +5 -5
  3. package/amd/annotation/decorator_utils.js +1 -1
  4. package/amd/bindings/binding.js +2 -2
  5. package/amd/constants/error_msgs.js +10 -2
  6. package/amd/container/container.js +142 -68
  7. package/amd/container/container_module.js +10 -2
  8. package/amd/inversify.js +3 -2
  9. package/amd/planning/context.js +2 -2
  10. package/amd/planning/planner.js +7 -0
  11. package/amd/planning/reflection_utils.js +2 -6
  12. package/amd/planning/request.js +2 -2
  13. package/amd/planning/target.js +2 -2
  14. package/amd/resolution/resolver.js +4 -4
  15. package/amd/utils/id.js +9 -0
  16. package/dts/bindings/binding.d.ts +1 -1
  17. package/dts/constants/error_msgs.d.ts +2 -2
  18. package/dts/container/container.d.ts +4 -2
  19. package/dts/container/container_module.d.ts +7 -3
  20. package/dts/interfaces/interfaces.d.ts +13 -6
  21. package/dts/inversify.d.ts +2 -2
  22. package/dts/planning/context.d.ts +1 -1
  23. package/dts/planning/reflection_utils.d.ts +3 -1
  24. package/dts/planning/request.d.ts +1 -1
  25. package/dts/planning/target.d.ts +1 -1
  26. package/dts/utils/id.d.ts +2 -0
  27. package/dts/utils/template.d.ts +1 -0
  28. package/es/annotation/decorator_utils.js +1 -1
  29. package/es/bindings/binding.js +2 -2
  30. package/es/constants/error_msgs.js +10 -2
  31. package/es/container/container.js +142 -68
  32. package/es/container/container_module.js +10 -2
  33. package/es/inversify.js +2 -2
  34. package/es/planning/context.js +2 -2
  35. package/es/planning/planner.js +8 -1
  36. package/es/planning/reflection_utils.js +1 -7
  37. package/es/planning/request.js +2 -2
  38. package/es/planning/target.js +2 -2
  39. package/es/resolution/resolver.js +4 -4
  40. package/es/utils/id.js +5 -0
  41. package/lib/annotation/decorator_utils.js +1 -1
  42. package/lib/bindings/binding.js +2 -2
  43. package/lib/constants/error_msgs.js +10 -2
  44. package/lib/container/container.js +142 -68
  45. package/lib/container/container_module.js +10 -2
  46. package/lib/inversify.js +3 -2
  47. package/lib/planning/context.js +2 -2
  48. package/lib/planning/planner.js +7 -0
  49. package/lib/planning/reflection_utils.js +2 -6
  50. package/lib/planning/request.js +2 -2
  51. package/lib/planning/target.js +2 -2
  52. package/lib/resolution/resolver.js +4 -4
  53. package/lib/utils/id.js +7 -0
  54. package/package.json +20 -20
  55. package/amd/utils/guid.js +0 -14
  56. package/es/utils/guid.js +0 -10
  57. package/lib/utils/guid.js +0 -12
@@ -24,14 +24,22 @@ exports.INVALID_TO_SELF_VALUE = "The toSelf function can only be applied when a
24
24
  "used as service identifier";
25
25
  exports.INVALID_DECORATOR_OPERATION = "The @inject @multiInject @tagged and @named decorators " +
26
26
  "must be applied to the parameters of a class constructor or a class property.";
27
- exports.ARGUMENTS_LENGTH_MISMATCH_1 = "The number of constructor arguments in the derived class ";
28
- exports.ARGUMENTS_LENGTH_MISMATCH_2 = " must be >= than the number of constructor arguments of its base class.";
27
+ exports.ARGUMENTS_LENGTH_MISMATCH = function () {
28
+ var values = [];
29
+ for (var _i = 0; _i < arguments.length; _i++) {
30
+ values[_i] = arguments[_i];
31
+ }
32
+ return "The number of constructor arguments in the derived class " +
33
+ (values[0] + " must be >= than the number of constructor arguments of its base class.");
34
+ };
29
35
  exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = "Invalid Container constructor argument. Container options " +
30
36
  "must be an object.";
31
37
  exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = "Invalid Container option. Default scope must " +
32
38
  "be a string ('singleton' or 'transient').";
33
39
  exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = "Invalid Container option. Auto bind injectable must " +
34
40
  "be a boolean";
41
+ exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = "Invalid Container option. Skip base check must " +
42
+ "be a boolean";
35
43
  exports.MULTIPLE_POST_CONSTRUCT_METHODS = "Cannot apply @postConstruct decorator multiple times in the same class";
36
44
  exports.POST_CONSTRUCT_ERROR = function () {
37
45
  var values = [];
@@ -1,4 +1,39 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [0, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
2
37
  Object.defineProperty(exports, "__esModule", { value: true });
3
38
  var binding_1 = require("../bindings/binding");
4
39
  var ERROR_MSGS = require("../constants/error_msgs");
@@ -8,40 +43,42 @@ var metadata_reader_1 = require("../planning/metadata_reader");
8
43
  var planner_1 = require("../planning/planner");
9
44
  var resolver_1 = require("../resolution/resolver");
10
45
  var binding_to_syntax_1 = require("../syntax/binding_to_syntax");
11
- var guid_1 = require("../utils/guid");
46
+ var id_1 = require("../utils/id");
12
47
  var serialization_1 = require("../utils/serialization");
13
48
  var container_snapshot_1 = require("./container_snapshot");
14
49
  var lookup_1 = require("./lookup");
15
50
  var Container = (function () {
16
51
  function Container(containerOptions) {
17
- if (containerOptions !== undefined) {
18
- if (typeof containerOptions !== "object") {
19
- throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);
20
- }
21
- else {
22
- if (containerOptions.defaultScope !== undefined &&
23
- containerOptions.defaultScope !== literal_types_1.BindingScopeEnum.Singleton &&
24
- containerOptions.defaultScope !== literal_types_1.BindingScopeEnum.Transient &&
25
- containerOptions.defaultScope !== literal_types_1.BindingScopeEnum.Request) {
26
- throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);
27
- }
28
- if (containerOptions.autoBindInjectable !== undefined &&
29
- typeof containerOptions.autoBindInjectable !== "boolean") {
30
- throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);
31
- }
32
- }
33
- this.options = {
34
- autoBindInjectable: containerOptions.autoBindInjectable,
35
- defaultScope: containerOptions.defaultScope
36
- };
52
+ var options = containerOptions || {};
53
+ if (typeof options !== "object") {
54
+ throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);
37
55
  }
38
- else {
39
- this.options = {
40
- autoBindInjectable: false,
41
- defaultScope: literal_types_1.BindingScopeEnum.Transient
42
- };
56
+ if (options.defaultScope === undefined) {
57
+ options.defaultScope = literal_types_1.BindingScopeEnum.Transient;
58
+ }
59
+ else if (options.defaultScope !== literal_types_1.BindingScopeEnum.Singleton &&
60
+ options.defaultScope !== literal_types_1.BindingScopeEnum.Transient &&
61
+ options.defaultScope !== literal_types_1.BindingScopeEnum.Request) {
62
+ throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);
63
+ }
64
+ if (options.autoBindInjectable === undefined) {
65
+ options.autoBindInjectable = false;
43
66
  }
44
- this.guid = guid_1.guid();
67
+ else if (typeof options.autoBindInjectable !== "boolean") {
68
+ throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);
69
+ }
70
+ if (options.skipBaseClassChecks === undefined) {
71
+ options.skipBaseClassChecks = false;
72
+ }
73
+ else if (typeof options.skipBaseClassChecks !== "boolean") {
74
+ throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK);
75
+ }
76
+ this.options = {
77
+ autoBindInjectable: options.autoBindInjectable,
78
+ defaultScope: options.defaultScope,
79
+ skipBaseClassChecks: options.skipBaseClassChecks
80
+ };
81
+ this.id = id_1.id();
45
82
  this._bindingDictionary = new lookup_1.Lookup();
46
83
  this._snapshots = [];
47
84
  this._middleware = null;
@@ -65,46 +102,44 @@ var Container = (function () {
65
102
  return container;
66
103
  };
67
104
  Container.prototype.load = function () {
68
- var _this = this;
69
105
  var modules = [];
70
106
  for (var _i = 0; _i < arguments.length; _i++) {
71
107
  modules[_i] = arguments[_i];
72
108
  }
73
- var setModuleId = function (bindingToSyntax, moduleId) {
74
- bindingToSyntax._binding.moduleId = moduleId;
75
- };
76
- var getBindFunction = function (moduleId) {
77
- return function (serviceIdentifier) {
78
- var bindingToSyntax = _this.bind.call(_this, serviceIdentifier);
79
- setModuleId(bindingToSyntax, moduleId);
80
- return bindingToSyntax;
81
- };
82
- };
83
- var getUnbindFunction = function (moduleId) {
84
- return function (serviceIdentifier) {
85
- var _unbind = _this.unbind.bind(_this);
86
- _unbind(serviceIdentifier);
87
- };
88
- };
89
- var getIsboundFunction = function (moduleId) {
90
- return function (serviceIdentifier) {
91
- var _isBound = _this.isBound.bind(_this);
92
- return _isBound(serviceIdentifier);
93
- };
94
- };
95
- var getRebindFunction = function (moduleId) {
96
- return function (serviceIdentifier) {
97
- var bindingToSyntax = _this.rebind.call(_this, serviceIdentifier);
98
- setModuleId(bindingToSyntax, moduleId);
99
- return bindingToSyntax;
100
- };
101
- };
102
- modules.forEach(function (module) {
103
- var bindFunction = getBindFunction(module.guid);
104
- var unbindFunction = getUnbindFunction(module.guid);
105
- var isboundFunction = getIsboundFunction(module.guid);
106
- var rebindFunction = getRebindFunction(module.guid);
107
- module.registry(bindFunction, unbindFunction, isboundFunction, rebindFunction);
109
+ var getHelpers = this._getContainerModuleHelpersFactory();
110
+ for (var _a = 0, modules_1 = modules; _a < modules_1.length; _a++) {
111
+ var currentModule = modules_1[_a];
112
+ var containerModuleHelpers = getHelpers(currentModule.id);
113
+ currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction);
114
+ }
115
+ };
116
+ Container.prototype.loadAsync = function () {
117
+ var modules = [];
118
+ for (var _i = 0; _i < arguments.length; _i++) {
119
+ modules[_i] = arguments[_i];
120
+ }
121
+ return __awaiter(this, void 0, void 0, function () {
122
+ var getHelpers, _a, modules_2, currentModule, containerModuleHelpers;
123
+ return __generator(this, function (_b) {
124
+ switch (_b.label) {
125
+ case 0:
126
+ getHelpers = this._getContainerModuleHelpersFactory();
127
+ _a = 0, modules_2 = modules;
128
+ _b.label = 1;
129
+ case 1:
130
+ if (!(_a < modules_2.length)) return [3, 4];
131
+ currentModule = modules_2[_a];
132
+ containerModuleHelpers = getHelpers(currentModule.id);
133
+ return [4, currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction)];
134
+ case 2:
135
+ _b.sent();
136
+ _b.label = 3;
137
+ case 3:
138
+ _a++;
139
+ return [3, 1];
140
+ case 4: return [2];
141
+ }
142
+ });
108
143
  });
109
144
  };
110
145
  Container.prototype.unload = function () {
@@ -117,7 +152,7 @@ var Container = (function () {
117
152
  return item.moduleId === expected;
118
153
  }; };
119
154
  modules.forEach(function (module) {
120
- var condition = conditionFactory(module.guid);
155
+ var condition = conditionFactory(module.id);
121
156
  _this._bindingDictionary.removeByCondition(condition);
122
157
  });
123
158
  };
@@ -175,8 +210,8 @@ var Container = (function () {
175
210
  this._bindingDictionary = snapshot.bindings;
176
211
  this._middleware = snapshot.middleware;
177
212
  };
178
- Container.prototype.createChild = function () {
179
- var child = new Container();
213
+ Container.prototype.createChild = function (containerOptions) {
214
+ var child = new Container(containerOptions || this.options);
180
215
  child.parent = this;
181
216
  return child;
182
217
  };
@@ -210,11 +245,50 @@ var Container = (function () {
210
245
  return this.getAllTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named);
211
246
  };
212
247
  Container.prototype.resolve = function (constructorFunction) {
213
- var tempContainer = new Container();
248
+ var tempContainer = this.createChild();
214
249
  tempContainer.bind(constructorFunction).toSelf();
215
- tempContainer.parent = this;
216
250
  return tempContainer.get(constructorFunction);
217
251
  };
252
+ Container.prototype._getContainerModuleHelpersFactory = function () {
253
+ var _this = this;
254
+ var setModuleId = function (bindingToSyntax, moduleId) {
255
+ bindingToSyntax._binding.moduleId = moduleId;
256
+ };
257
+ var getBindFunction = function (moduleId) {
258
+ return function (serviceIdentifier) {
259
+ var _bind = _this.bind.bind(_this);
260
+ var bindingToSyntax = _bind(serviceIdentifier);
261
+ setModuleId(bindingToSyntax, moduleId);
262
+ return bindingToSyntax;
263
+ };
264
+ };
265
+ var getUnbindFunction = function (moduleId) {
266
+ return function (serviceIdentifier) {
267
+ var _unbind = _this.unbind.bind(_this);
268
+ _unbind(serviceIdentifier);
269
+ };
270
+ };
271
+ var getIsboundFunction = function (moduleId) {
272
+ return function (serviceIdentifier) {
273
+ var _isBound = _this.isBound.bind(_this);
274
+ return _isBound(serviceIdentifier);
275
+ };
276
+ };
277
+ var getRebindFunction = function (moduleId) {
278
+ return function (serviceIdentifier) {
279
+ var _rebind = _this.rebind.bind(_this);
280
+ var bindingToSyntax = _rebind(serviceIdentifier);
281
+ setModuleId(bindingToSyntax, moduleId);
282
+ return bindingToSyntax;
283
+ };
284
+ };
285
+ return function (mId) { return ({
286
+ bindFunction: getBindFunction(mId),
287
+ isboundFunction: getIsboundFunction(mId),
288
+ rebindFunction: getRebindFunction(mId),
289
+ unbindFunction: getUnbindFunction(mId)
290
+ }); };
291
+ };
218
292
  Container.prototype._get = function (avoidConstraints, isMultiInject, targetType, serviceIdentifier, key, value) {
219
293
  var result = null;
220
294
  var defaultArgs = {
@@ -1,11 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var guid_1 = require("../utils/guid");
3
+ var id_1 = require("../utils/id");
4
4
  var ContainerModule = (function () {
5
5
  function ContainerModule(registry) {
6
- this.guid = guid_1.guid();
6
+ this.id = id_1.id();
7
7
  this.registry = registry;
8
8
  }
9
9
  return ContainerModule;
10
10
  }());
11
11
  exports.ContainerModule = ContainerModule;
12
+ var AsyncContainerModule = (function () {
13
+ function AsyncContainerModule(registry) {
14
+ this.id = id_1.id();
15
+ this.registry = registry;
16
+ }
17
+ return AsyncContainerModule;
18
+ }());
19
+ exports.AsyncContainerModule = AsyncContainerModule;
package/lib/inversify.js CHANGED
@@ -9,6 +9,7 @@ exports.BindingScopeEnum = literal_types_1.BindingScopeEnum;
9
9
  exports.BindingTypeEnum = literal_types_1.BindingTypeEnum;
10
10
  exports.TargetTypeEnum = literal_types_1.TargetTypeEnum;
11
11
  var container_module_1 = require("./container/container_module");
12
+ exports.AsyncContainerModule = container_module_1.AsyncContainerModule;
12
13
  exports.ContainerModule = container_module_1.ContainerModule;
13
14
  var injectable_1 = require("./annotation/injectable");
14
15
  exports.injectable = injectable_1.injectable;
@@ -31,8 +32,8 @@ var post_construct_1 = require("./annotation/post_construct");
31
32
  exports.postConstruct = post_construct_1.postConstruct;
32
33
  var metadata_reader_1 = require("./planning/metadata_reader");
33
34
  exports.MetadataReader = metadata_reader_1.MetadataReader;
34
- var guid_1 = require("./utils/guid");
35
- exports.guid = guid_1.guid;
35
+ var id_1 = require("./utils/id");
36
+ exports.id = id_1.id;
36
37
  var decorator_utils_1 = require("./annotation/decorator_utils");
37
38
  exports.decorate = decorator_utils_1.decorate;
38
39
  var constraint_helpers_1 = require("./syntax/constraint_helpers");
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var guid_1 = require("../utils/guid");
3
+ var id_1 = require("../utils/id");
4
4
  var Context = (function () {
5
5
  function Context(container) {
6
- this.guid = guid_1.guid();
6
+ this.id = id_1.id();
7
7
  this.container = container;
8
8
  }
9
9
  Context.prototype.addPlan = function (plan) {
@@ -104,6 +104,13 @@ function _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier,
104
104
  }
105
105
  if (binding.type === literal_types_1.BindingTypeEnum.Instance && binding.implementationType !== null) {
106
106
  var dependencies = reflection_utils_1.getDependencies(metadataReader, binding.implementationType);
107
+ if (!context.container.options.skipBaseClassChecks) {
108
+ var baseClassDependencyCount = reflection_utils_1.getBaseClassDependencyCount(metadataReader, binding.implementationType);
109
+ if (dependencies.length < baseClassDependencyCount) {
110
+ var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH(reflection_utils_1.getFunctionName(binding.implementationType));
111
+ throw new Error(error);
112
+ }
113
+ }
107
114
  dependencies.forEach(function (dependency) {
108
115
  _createSubRequests(metadataReader, false, dependency.serviceIdentifier, context, subChildRequest, dependency);
109
116
  });
@@ -5,6 +5,7 @@ var ERROR_MSGS = require("../constants/error_msgs");
5
5
  var literal_types_1 = require("../constants/literal_types");
6
6
  var METADATA_KEY = require("../constants/metadata_keys");
7
7
  var serialization_1 = require("../utils/serialization");
8
+ exports.getFunctionName = serialization_1.getFunctionName;
8
9
  var target_1 = require("./target");
9
10
  function getDependencies(metadataReader, func) {
10
11
  var constructorName = serialization_1.getFunctionName(func);
@@ -26,12 +27,6 @@ function getTargets(metadataReader, constructorName, func, isBaseClass) {
26
27
  var constructorTargets = getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations);
27
28
  var propertyTargets = getClassPropsAsTargets(metadataReader, func);
28
29
  var targets = constructorTargets.concat(propertyTargets);
29
- var baseClassDependencyCount = getBaseClassDependencyCount(metadataReader, func);
30
- if (targets.length < baseClassDependencyCount) {
31
- var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH_1 +
32
- constructorName + ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH_2;
33
- throw new Error(error);
34
- }
35
30
  return targets;
36
31
  }
37
32
  function getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata) {
@@ -114,6 +109,7 @@ function getBaseClassDependencyCount(metadataReader, func) {
114
109
  return 0;
115
110
  }
116
111
  }
112
+ exports.getBaseClassDependencyCount = getBaseClassDependencyCount;
117
113
  function formatTargetMetadata(targetMetadata) {
118
114
  var targetMetadataMap = {};
119
115
  targetMetadata.forEach(function (m) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var guid_1 = require("../utils/guid");
3
+ var id_1 = require("../utils/id");
4
4
  var Request = (function () {
5
5
  function Request(serviceIdentifier, parentContext, parentRequest, bindings, target) {
6
- this.guid = guid_1.guid();
6
+ this.id = id_1.id();
7
7
  this.serviceIdentifier = serviceIdentifier;
8
8
  this.parentContext = parentContext;
9
9
  this.parentRequest = parentRequest;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var METADATA_KEY = require("../constants/metadata_keys");
4
- var guid_1 = require("../utils/guid");
4
+ var id_1 = require("../utils/id");
5
5
  var metadata_1 = require("./metadata");
6
6
  var queryable_string_1 = require("./queryable_string");
7
7
  var Target = (function () {
8
8
  function Target(type, name, serviceIdentifier, namedOrTagged) {
9
- this.guid = guid_1.guid();
9
+ this.id = id_1.id();
10
10
  this.type = type;
11
11
  this.serviceIdentifier = serviceIdentifier;
12
12
  this.name = new queryable_string_1.QueryableString(name || "");
@@ -47,8 +47,8 @@ var _resolveRequest = function (requestScope) {
47
47
  }
48
48
  if (isRequestSingleton &&
49
49
  requestScope !== null &&
50
- requestScope.has(binding_1.guid)) {
51
- return requestScope.get(binding_1.guid);
50
+ requestScope.has(binding_1.id)) {
51
+ return requestScope.get(binding_1.id);
52
52
  }
53
53
  if (binding_1.type === literal_types_1.BindingTypeEnum.ConstantValue) {
54
54
  result = binding_1.cache;
@@ -84,8 +84,8 @@ var _resolveRequest = function (requestScope) {
84
84
  }
85
85
  if (isRequestSingleton &&
86
86
  requestScope !== null &&
87
- !requestScope.has(binding_1.guid)) {
88
- requestScope.set(binding_1.guid, result);
87
+ !requestScope.has(binding_1.id)) {
88
+ requestScope.set(binding_1.id, result);
89
89
  }
90
90
  return result;
91
91
  }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var idCounter = 0;
4
+ function id() {
5
+ return idCounter++;
6
+ }
7
+ exports.id = id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inversify",
3
- "version": "4.10.0",
3
+ "version": "4.14.0",
4
4
  "description": "A powerful and lightweight inversion of control container for JavaScript and Node.js apps powered by TypeScript.",
5
5
  "main": "lib/inversify.js",
6
6
  "jsnext:main": "es/inversify.js",
@@ -35,27 +35,27 @@
35
35
  "homepage": "http://inversify.io",
36
36
  "engines": {},
37
37
  "devDependencies": {
38
- "@types/chai": "4.1.2",
38
+ "@types/chai": "4.1.4",
39
39
  "@types/harmony-proxy": "1.0.29",
40
- "@types/mocha": "2.2.47",
41
- "@types/sinon": "4.1.3",
42
- "bluebird": "3.5.1",
43
- "browserify": "15.2.0",
40
+ "@types/mocha": "5.2.3",
41
+ "@types/sinon": "5.0.3",
42
+ "bluebird": "3.5.2",
43
+ "browserify": "16.2.3",
44
44
  "chai": "4.1.2",
45
45
  "del": "3.0.0",
46
46
  "es6-symbol": "3.1.1",
47
47
  "gulp": "3.9.1",
48
48
  "gulp-istanbul": "1.1.3",
49
- "gulp-mocha": "5.0.0",
50
- "gulp-rename": "1.2.2",
49
+ "gulp-mocha": "6.0.0",
50
+ "gulp-rename": "1.4.0",
51
51
  "gulp-sourcemaps": "2.6.3",
52
- "gulp-tslint": "8.1.2",
53
- "gulp-typescript": "4.0.0-alpha.2",
54
- "gulp-uglify": "3.0.0",
52
+ "gulp-tslint": "8.1.3",
53
+ "gulp-typescript": "4.0.2",
54
+ "gulp-uglify": "3.0.1",
55
55
  "harmonize": "2.0.0",
56
56
  "harmony-proxy": "1.0.1",
57
57
  "istanbul": "0.4.5",
58
- "karma": "2.0.0",
58
+ "karma": "3.0.0",
59
59
  "karma-chai": "0.1.0",
60
60
  "karma-chrome-launcher": "2.2.0",
61
61
  "karma-commonjs": "1.0.0",
@@ -66,15 +66,15 @@
66
66
  "karma-mocha-reporter": "2.2.5",
67
67
  "karma-phantomjs-launcher": "1.0.4",
68
68
  "karma-sinon": "1.0.5",
69
- "mocha": "5.0.0",
69
+ "mocha": "5.2.0",
70
70
  "performance-now": "2.1.0",
71
- "publish-please": "2.3.1",
71
+ "publish-please": "4.0.1",
72
72
  "reflect-metadata": "0.1.12",
73
73
  "run-sequence": "2.2.1",
74
- "sinon": "4.2.2",
75
- "tslint": "5.8.0",
76
- "typescript": "2.6.2",
77
- "vinyl-source-stream": "2.0.0",
78
- "vinyl-buffer": "1.0.1"
74
+ "sinon": "6.0.1",
75
+ "tslint": "5.9.1",
76
+ "typescript": "^2.8.3",
77
+ "vinyl-buffer": "1.0.1",
78
+ "vinyl-source-stream": "2.0.0"
79
79
  }
80
- }
80
+ }
package/amd/utils/guid.js DELETED
@@ -1,14 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- function guid() {
5
- function s4() {
6
- return Math.floor((Math.random() + 1) * 0x10000)
7
- .toString(16)
8
- .substring(1);
9
- }
10
- return s4() + s4() + "-" + s4() + "-" + s4() + "-" +
11
- s4() + "-" + s4() + s4() + s4();
12
- }
13
- exports.guid = guid;
14
- });
package/es/utils/guid.js DELETED
@@ -1,10 +0,0 @@
1
- function guid() {
2
- function s4() {
3
- return Math.floor((Math.random() + 1) * 0x10000)
4
- .toString(16)
5
- .substring(1);
6
- }
7
- return s4() + s4() + "-" + s4() + "-" + s4() + "-" +
8
- s4() + "-" + s4() + s4() + s4();
9
- }
10
- export { guid };
package/lib/utils/guid.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function guid() {
4
- function s4() {
5
- return Math.floor((Math.random() + 1) * 0x10000)
6
- .toString(16)
7
- .substring(1);
8
- }
9
- return s4() + s4() + "-" + s4() + "-" + s4() + "-" +
10
- s4() + "-" + s4() + s4() + s4();
11
- }
12
- exports.guid = guid;