inversify 6.0.3 → 6.1.1

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 (150) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +14 -14
  3. package/amd/annotation/decorator_utils.js +3 -1
  4. package/amd/annotation/inject_base.js +1 -1
  5. package/amd/annotation/lazy_service_identifier.js +0 -11
  6. package/amd/bindings/binding.js +3 -2
  7. package/amd/bindings/binding_count.js +6 -5
  8. package/amd/constants/error_msgs.js +18 -18
  9. package/amd/constants/literal_types.js +3 -3
  10. package/amd/container/container.js +73 -34
  11. package/amd/container/lookup.js +15 -14
  12. package/amd/container/module_activation_store.js +8 -10
  13. package/amd/interfaces/interfaces.js +0 -5
  14. package/amd/inversify.js +3 -5
  15. package/amd/planning/metadata_reader.js +5 -3
  16. package/amd/planning/planner.js +31 -13
  17. package/amd/planning/queryable_string.js +5 -2
  18. package/amd/planning/reflection_utils.js +6 -112
  19. package/amd/planning/request.js +2 -4
  20. package/amd/planning/target.js +9 -3
  21. package/amd/resolution/instantiation.js +10 -5
  22. package/amd/resolution/resolver.js +19 -10
  23. package/amd/scope/scope.js +1 -1
  24. package/amd/syntax/binding_to_syntax.js +14 -7
  25. package/amd/syntax/binding_when_syntax.js +13 -8
  26. package/amd/syntax/constraint_helpers.js +4 -3
  27. package/amd/utils/async.js +3 -2
  28. package/amd/utils/binding_utils.js +8 -3
  29. package/amd/utils/clonable.js +4 -4
  30. package/amd/utils/exceptions.js +1 -1
  31. package/amd/utils/serialization.js +11 -8
  32. package/es/annotation/decorator_utils.js +3 -1
  33. package/es/annotation/inject_base.js +1 -1
  34. package/es/annotation/lazy_service_identifier.js +1 -10
  35. package/es/annotation/target_name.js +3 -3
  36. package/es/bindings/binding.js +3 -2
  37. package/es/bindings/binding_count.js +6 -5
  38. package/es/constants/error_msgs.js +17 -17
  39. package/es/constants/literal_types.js +3 -3
  40. package/es/container/container.js +74 -35
  41. package/es/container/lookup.js +15 -14
  42. package/es/container/module_activation_store.js +8 -10
  43. package/es/interfaces/interfaces.js +1 -5
  44. package/es/inversify.js +4 -6
  45. package/es/planning/metadata_reader.js +5 -3
  46. package/es/planning/planner.js +34 -16
  47. package/es/planning/queryable_string.js +5 -2
  48. package/es/planning/reflection_utils.js +6 -114
  49. package/es/planning/request.js +2 -4
  50. package/es/planning/target.js +9 -3
  51. package/es/resolution/instantiation.js +11 -6
  52. package/es/resolution/resolver.js +20 -11
  53. package/es/scope/scope.js +1 -1
  54. package/es/syntax/binding_to_syntax.js +18 -11
  55. package/es/syntax/binding_when_syntax.js +14 -9
  56. package/es/syntax/constraint_helpers.js +5 -4
  57. package/es/utils/async.js +3 -2
  58. package/es/utils/binding_utils.js +8 -3
  59. package/es/utils/clonable.js +4 -4
  60. package/es/utils/exceptions.js +1 -1
  61. package/es/utils/serialization.js +12 -9
  62. package/es6/annotation/decorator_utils.js +5 -3
  63. package/es6/annotation/inject_base.js +1 -1
  64. package/es6/annotation/lazy_service_identifier.js +0 -10
  65. package/es6/bindings/binding.js +3 -2
  66. package/es6/bindings/binding_count.js +6 -5
  67. package/es6/constants/error_msgs.js +5 -9
  68. package/es6/constants/literal_types.js +3 -3
  69. package/es6/container/container.js +59 -42
  70. package/es6/container/lookup.js +15 -14
  71. package/es6/container/module_activation_store.js +8 -10
  72. package/es6/interfaces/interfaces.js +0 -5
  73. package/es6/inversify.js +3 -7
  74. package/es6/planning/metadata_reader.js +5 -3
  75. package/es6/planning/planner.js +31 -13
  76. package/es6/planning/queryable_string.js +5 -2
  77. package/es6/planning/reflection_utils.js +4 -110
  78. package/es6/planning/request.js +2 -4
  79. package/es6/planning/target.js +3 -1
  80. package/es6/resolution/instantiation.js +9 -5
  81. package/es6/resolution/resolver.js +11 -8
  82. package/es6/scope/scope.js +1 -1
  83. package/es6/syntax/binding_to_syntax.js +5 -4
  84. package/es6/syntax/binding_when_syntax.js +13 -8
  85. package/es6/syntax/constraint_helpers.js +4 -3
  86. package/es6/utils/async.js +3 -2
  87. package/es6/utils/binding_utils.js +10 -3
  88. package/es6/utils/clonable.js +4 -4
  89. package/es6/utils/exceptions.js +1 -1
  90. package/es6/utils/serialization.js +11 -8
  91. package/lib/annotation/decorator_utils.d.ts +2 -2
  92. package/lib/annotation/decorator_utils.js +3 -1
  93. package/lib/annotation/inject.d.ts +4 -1
  94. package/lib/annotation/inject_base.d.ts +3 -2
  95. package/lib/annotation/inject_base.js +1 -1
  96. package/lib/annotation/lazy_service_identifier.d.ts +1 -5
  97. package/lib/annotation/lazy_service_identifier.js +0 -11
  98. package/lib/annotation/multi_inject.d.ts +4 -1
  99. package/lib/annotation/tagged.d.ts +1 -1
  100. package/lib/annotation/target_name.d.ts +1 -1
  101. package/lib/bindings/binding.js +3 -2
  102. package/lib/bindings/binding_count.d.ts +5 -5
  103. package/lib/bindings/binding_count.js +6 -5
  104. package/lib/constants/error_msgs.d.ts +18 -20
  105. package/lib/constants/error_msgs.js +18 -18
  106. package/lib/constants/literal_types.js +3 -3
  107. package/lib/constants/metadata_keys.d.ts +12 -12
  108. package/lib/container/container.d.ts +2 -2
  109. package/lib/container/container.js +73 -34
  110. package/lib/container/lookup.d.ts +2 -1
  111. package/lib/container/lookup.js +15 -14
  112. package/lib/container/module_activation_store.d.ts +1 -1
  113. package/lib/container/module_activation_store.js +8 -10
  114. package/lib/interfaces/interfaces.d.ts +14 -29
  115. package/lib/interfaces/interfaces.js +0 -5
  116. package/lib/inversify.d.ts +5 -6
  117. package/lib/inversify.js +3 -7
  118. package/lib/planning/metadata_reader.js +5 -3
  119. package/lib/planning/planner.js +31 -13
  120. package/lib/planning/queryable_string.d.ts +2 -3
  121. package/lib/planning/queryable_string.js +5 -2
  122. package/lib/planning/reflection_utils.js +6 -114
  123. package/lib/planning/request.d.ts +2 -2
  124. package/lib/planning/request.js +2 -4
  125. package/lib/planning/target.d.ts +1 -1
  126. package/lib/planning/target.js +9 -3
  127. package/lib/resolution/instantiation.js +10 -5
  128. package/lib/resolution/resolver.js +19 -10
  129. package/lib/scope/scope.js +1 -1
  130. package/lib/syntax/binding_in_syntax.d.ts +1 -1
  131. package/lib/syntax/binding_in_when_on_syntax.d.ts +7 -7
  132. package/lib/syntax/binding_on_syntax.d.ts +1 -1
  133. package/lib/syntax/binding_to_syntax.d.ts +4 -4
  134. package/lib/syntax/binding_to_syntax.js +14 -7
  135. package/lib/syntax/binding_when_on_syntax.d.ts +6 -6
  136. package/lib/syntax/binding_when_syntax.d.ts +4 -4
  137. package/lib/syntax/binding_when_syntax.js +13 -8
  138. package/lib/syntax/constraint_helpers.d.ts +2 -2
  139. package/lib/syntax/constraint_helpers.js +4 -3
  140. package/lib/tsconfig.tsbuildinfo +1 -1
  141. package/lib/utils/async.js +3 -2
  142. package/lib/utils/binding_utils.js +8 -3
  143. package/lib/utils/clonable.js +4 -4
  144. package/lib/utils/exceptions.js +1 -1
  145. package/lib/utils/serialization.d.ts +3 -3
  146. package/lib/utils/serialization.js +11 -8
  147. package/package.json +19 -5
  148. package/.nyc_output/c29b2307-4e95-47d0-b220-9efcfa7ee49f.json +0 -1
  149. package/.nyc_output/processinfo/c29b2307-4e95-47d0-b220-9efcfa7ee49f.json +0 -1
  150. package/.nyc_output/processinfo/index.json +0 -1
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isPromise = isPromise;
4
4
  exports.isPromiseOrContainsPromise = isPromiseOrContainsPromise;
5
5
  function isPromise(object) {
6
- const isObjectOrFunction = (typeof object === 'object' && object !== null) || typeof object === 'function';
7
- return isObjectOrFunction && typeof object.then === "function";
6
+ const isObjectOrFunction = (typeof object === 'object' && object !== null) ||
7
+ typeof object === 'function';
8
+ return (isObjectOrFunction && typeof object.then === 'function');
8
9
  }
9
10
  function isPromiseOrContainsPromise(object) {
10
11
  if (isPromise(object)) {
@@ -24,11 +24,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getFactoryDetails = exports.ensureFullyBound = exports.multiBindToService = void 0;
27
- const serialization_1 = require("../utils/serialization");
28
27
  const ERROR_MSGS = __importStar(require("../constants/error_msgs"));
29
28
  const literal_types_1 = require("../constants/literal_types");
29
+ const serialization_1 = require("../utils/serialization");
30
30
  const factory_type_1 = require("./factory_type");
31
- const multiBindToService = (container) => (service) => (...types) => types.forEach((t) => container.bind(t).toService(service));
31
+ const multiBindToService = (container) => (service) => (...types) => {
32
+ types.forEach((t) => {
33
+ container.bind(t).toService(service);
34
+ });
35
+ };
32
36
  exports.multiBindToService = multiBindToService;
33
37
  const ensureFullyBound = (binding) => {
34
38
  let boundValue = null;
@@ -64,7 +68,10 @@ const getFactoryDetails = (binding) => {
64
68
  case literal_types_1.BindingTypeEnum.Provider:
65
69
  return { factory: binding.provider, factoryType: factory_type_1.FactoryType.Provider };
66
70
  case literal_types_1.BindingTypeEnum.DynamicValue:
67
- return { factory: binding.dynamicValue, factoryType: factory_type_1.FactoryType.DynamicValue };
71
+ return {
72
+ factory: binding.dynamicValue,
73
+ factoryType: factory_type_1.FactoryType.DynamicValue,
74
+ };
68
75
  default:
69
76
  throw new Error(`Unexpected factory type ${binding.type}`);
70
77
  }
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isClonable = isClonable;
4
4
  function isClonable(obj) {
5
- return (typeof obj === 'object')
6
- && (obj !== null)
7
- && ('clone' in obj)
8
- && typeof obj.clone === 'function';
5
+ return (typeof obj === 'object' &&
6
+ obj !== null &&
7
+ 'clone' in obj &&
8
+ typeof obj.clone === 'function');
9
9
  }
@@ -36,7 +36,7 @@ const tryAndThrowErrorIfStackOverflow = (fn, errorCallback) => {
36
36
  }
37
37
  catch (error) {
38
38
  if (isStackOverflowException(error)) {
39
- error = errorCallback();
39
+ throw errorCallback();
40
40
  }
41
41
  throw error;
42
42
  }
@@ -32,15 +32,13 @@ exports.getSymbolDescription = getSymbolDescription;
32
32
  const ERROR_MSGS = __importStar(require("../constants/error_msgs"));
33
33
  function getServiceIdentifierAsString(serviceIdentifier) {
34
34
  if (typeof serviceIdentifier === 'function') {
35
- const _serviceIdentifier = serviceIdentifier;
36
- return _serviceIdentifier.name;
35
+ return serviceIdentifier.name;
37
36
  }
38
37
  else if (typeof serviceIdentifier === 'symbol') {
39
38
  return serviceIdentifier.toString();
40
39
  }
41
40
  else {
42
- const _serviceIdentifier = serviceIdentifier;
43
- return _serviceIdentifier;
41
+ return serviceIdentifier;
44
42
  }
45
43
  }
46
44
  function listRegisteredBindingsForServiceIdentifier(container, serviceIdentifier, getBindings) {
@@ -101,11 +99,11 @@ function listMetadataForTarget(serviceIdentifierString, target) {
101
99
  const namedTag = target.getNamedTag();
102
100
  const otherTags = target.getCustomTags();
103
101
  if (namedTag !== null) {
104
- m += namedTag.toString() + '\n';
102
+ m += stringifyMetadata(namedTag) + '\n';
105
103
  }
106
104
  if (otherTags !== null) {
107
105
  otherTags.forEach((tag) => {
108
- m += tag.toString() + '\n';
106
+ m += stringifyMetadata(tag) + '\n';
109
107
  });
110
108
  }
111
109
  return ` ${serviceIdentifierString}\n ${serviceIdentifierString} - ${m}`;
@@ -115,15 +113,20 @@ function listMetadataForTarget(serviceIdentifierString, target) {
115
113
  }
116
114
  }
117
115
  function getFunctionName(func) {
118
- if (func.name) {
116
+ if (func.name != null && func.name !== '') {
119
117
  return func.name;
120
118
  }
121
119
  else {
122
120
  const name = func.toString();
123
121
  const match = name.match(/^function\s*([^\s(]+)/);
124
- return match ? match[1] : `Anonymous function: ${name}`;
122
+ return match === null
123
+ ? `Anonymous function: ${name}`
124
+ : match[1];
125
125
  }
126
126
  }
127
127
  function getSymbolDescription(symbol) {
128
128
  return symbol.toString().slice(7, -1);
129
129
  }
130
+ function stringifyMetadata(metadata) {
131
+ return `{"key":"${metadata.key.toString()}","value":"${metadata.value.toString()}"}`;
132
+ }
@@ -5,12 +5,12 @@ type Prototype<T> = {
5
5
  constructor: NewableFunction;
6
6
  };
7
7
  interface ConstructorFunction<T = Record<string, unknown>> {
8
- new (...args: unknown[]): T;
9
8
  prototype: Prototype<T>;
9
+ new (...args: unknown[]): T;
10
10
  }
11
11
  export type DecoratorTarget<T = unknown> = ConstructorFunction<T> | Prototype<T>;
12
12
  declare function tagParameter(annotationTarget: DecoratorTarget, parameterName: string | symbol | undefined, parameterIndex: number, metadata: interfaces.MetadataOrMetadataArray): void;
13
13
  declare function tagProperty(annotationTarget: DecoratorTarget, propertyName: string | symbol, metadata: interfaces.MetadataOrMetadataArray): void;
14
14
  declare function createTaggedDecorator(metadata: interfaces.MetadataOrMetadataArray): <T>(target: DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
15
- declare function decorate(decorator: (DecoratorTarget | ParameterDecorator | MethodDecorator), target: object, parameterIndexOrProperty?: number | string): void;
15
+ declare function decorate(decorator: DecoratorTarget | ParameterDecorator | MethodDecorator, target: object, parameterIndexOrProperty?: number | string): void;
16
16
  export { decorate, tagParameter, tagProperty, createTaggedDecorator };
@@ -101,7 +101,9 @@ function _decorate(decorators, target) {
101
101
  Reflect.decorate(decorators, target);
102
102
  }
103
103
  function _param(paramIndex, decorator) {
104
- return function (target, key) { decorator(target, key, paramIndex); };
104
+ return function (target, key) {
105
+ decorator(target, key, paramIndex);
106
+ };
105
107
  }
106
108
  function decorate(decorator, target, parameterIndexOrProperty) {
107
109
  if (typeof parameterIndexOrProperty === 'number') {
@@ -1,2 +1,5 @@
1
- declare const inject: <T = unknown>(serviceIdentifier: import("./lazy_service_identifier").ServiceIdentifierOrFunc<T>) => (target: import("./decorator_utils").DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
1
+ import { LazyServiceIdentifier } from '@inversifyjs/common';
2
+ import { interfaces } from '../interfaces/interfaces';
3
+ import { DecoratorTarget } from './decorator_utils';
4
+ declare const inject: <T = unknown>(serviceIdentifier: interfaces.ServiceIdentifier<T> | LazyServiceIdentifier<T>) => (target: DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
2
5
  export { inject };
@@ -1,3 +1,4 @@
1
+ import { LazyServiceIdentifier } from '@inversifyjs/common';
2
+ import { interfaces } from '../interfaces/interfaces';
1
3
  import { DecoratorTarget } from './decorator_utils';
2
- import { ServiceIdentifierOrFunc } from './lazy_service_identifier';
3
- export declare function injectBase(metadataKey: string): <T = unknown>(serviceIdentifier: ServiceIdentifierOrFunc<T>) => (target: DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
4
+ export declare function injectBase(metadataKey: string): <T = unknown>(serviceIdentifier: interfaces.ServiceIdentifier<T> | LazyServiceIdentifier<T>) => (target: DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
@@ -11,7 +11,7 @@ function injectBase(metadataKey) {
11
11
  var className = typeof target === 'function' ? target.name : target.constructor.name;
12
12
  throw new Error((0, error_msgs_1.UNDEFINED_INJECT_ANNOTATION)(className));
13
13
  }
14
- return (0, decorator_utils_1.createTaggedDecorator)(new metadata_1.Metadata(metadataKey, serviceIdentifier))(target, targetKey, indexOrPropertyDescriptor);
14
+ (0, decorator_utils_1.createTaggedDecorator)(new metadata_1.Metadata(metadataKey, serviceIdentifier))(target, targetKey, indexOrPropertyDescriptor);
15
15
  };
16
16
  };
17
17
  }
@@ -1,7 +1,3 @@
1
+ import { LazyServiceIdentifier } from '@inversifyjs/common';
1
2
  import { interfaces } from '../interfaces/interfaces';
2
3
  export type ServiceIdentifierOrFunc<T> = interfaces.ServiceIdentifier<T> | LazyServiceIdentifier<T>;
3
- export declare class LazyServiceIdentifier<T = unknown> {
4
- private _cb;
5
- constructor(cb: () => interfaces.ServiceIdentifier<T>);
6
- unwrap(): interfaces.ServiceIdentifier<T>;
7
- }
@@ -1,13 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LazyServiceIdentifier = void 0;
4
- var LazyServiceIdentifier = (function () {
5
- function LazyServiceIdentifier(cb) {
6
- this._cb = cb;
7
- }
8
- LazyServiceIdentifier.prototype.unwrap = function () {
9
- return this._cb();
10
- };
11
- return LazyServiceIdentifier;
12
- }());
13
- exports.LazyServiceIdentifier = LazyServiceIdentifier;
@@ -1,2 +1,5 @@
1
- declare const multiInject: <T = unknown>(serviceIdentifier: import("./lazy_service_identifier").ServiceIdentifierOrFunc<T>) => (target: import("./decorator_utils").DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
1
+ import { LazyServiceIdentifier } from '@inversifyjs/common';
2
+ import { interfaces } from '../interfaces/interfaces';
3
+ import { DecoratorTarget } from './decorator_utils';
4
+ declare const multiInject: <T = unknown>(serviceIdentifier: interfaces.ServiceIdentifier<T> | LazyServiceIdentifier<T>) => (target: DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
2
5
  export { multiInject };
@@ -1,2 +1,2 @@
1
- declare function tagged<T>(metadataKey: string | number | symbol, metadataValue: unknown): <T_1>(target: import("./decorator_utils").DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T_1>) => void;
1
+ declare function tagged(metadataKey: string | number | symbol, metadataValue: unknown): <T>(target: import("./decorator_utils").DecoratorTarget, targetKey?: string | symbol, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<T>) => void;
2
2
  export { tagged };
@@ -1,3 +1,3 @@
1
- import { DecoratorTarget } from "./decorator_utils";
1
+ import { DecoratorTarget } from './decorator_utils';
2
2
  declare function targetName(name: string): (target: DecoratorTarget, targetKey: string | undefined, index: number) => void;
3
3
  export { targetName };
@@ -10,7 +10,7 @@ var Binding = (function () {
10
10
  this.serviceIdentifier = serviceIdentifier;
11
11
  this.scope = scope;
12
12
  this.type = literal_types_1.BindingTypeEnum.Invalid;
13
- this.constraint = function (request) { return true; };
13
+ this.constraint = function (_request) { return true; };
14
14
  this.implementationType = null;
15
15
  this.cache = null;
16
16
  this.factory = null;
@@ -21,7 +21,8 @@ var Binding = (function () {
21
21
  }
22
22
  Binding.prototype.clone = function () {
23
23
  var clone = new Binding(this.serviceIdentifier, this.scope);
24
- clone.activated = (clone.scope === literal_types_1.BindingScopeEnum.Singleton) ? this.activated : false;
24
+ clone.activated =
25
+ clone.scope === literal_types_1.BindingScopeEnum.Singleton ? this.activated : false;
25
26
  clone.implementationType = this.implementationType;
26
27
  clone.dynamicValue = this.dynamicValue;
27
28
  clone.scope = this.scope;
@@ -1,5 +1,5 @@
1
- export declare const BindingCount: {
2
- MultipleBindingsAvailable: number;
3
- NoBindingsAvailable: number;
4
- OnlyOneBindingAvailable: number;
5
- };
1
+ export declare enum BindingCount {
2
+ MultipleBindingsAvailable = 2,
3
+ NoBindingsAvailable = 0,
4
+ OnlyOneBindingAvailable = 1
5
+ }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BindingCount = void 0;
4
- exports.BindingCount = {
5
- MultipleBindingsAvailable: 2,
6
- NoBindingsAvailable: 0,
7
- OnlyOneBindingAvailable: 1
8
- };
4
+ var BindingCount;
5
+ (function (BindingCount) {
6
+ BindingCount[BindingCount["MultipleBindingsAvailable"] = 2] = "MultipleBindingsAvailable";
7
+ BindingCount[BindingCount["NoBindingsAvailable"] = 0] = "NoBindingsAvailable";
8
+ BindingCount[BindingCount["OnlyOneBindingAvailable"] = 1] = "OnlyOneBindingAvailable";
9
+ })(BindingCount || (exports.BindingCount = BindingCount = {}));
@@ -1,32 +1,30 @@
1
- export declare const DUPLICATED_INJECTABLE_DECORATOR = "Cannot apply @injectable decorator multiple times.";
2
- export declare const DUPLICATED_METADATA = "Metadata key was used more than once in a parameter:";
3
- export declare const NULL_ARGUMENT = "NULL argument";
4
- export declare const KEY_NOT_FOUND = "Key Not Found";
5
- export declare const AMBIGUOUS_MATCH = "Ambiguous match found for serviceIdentifier:";
6
- export declare const CANNOT_UNBIND = "Could not unbind serviceIdentifier:";
7
- export declare const NOT_REGISTERED = "No matching bindings found for serviceIdentifier:";
8
- export declare const MISSING_INJECTABLE_ANNOTATION = "Missing required @injectable annotation in:";
9
- export declare const MISSING_INJECT_ANNOTATION = "Missing required @inject or @multiInject annotation in:";
1
+ export declare const DUPLICATED_INJECTABLE_DECORATOR: string;
2
+ export declare const DUPLICATED_METADATA: string;
3
+ export declare const NULL_ARGUMENT: string;
4
+ export declare const KEY_NOT_FOUND: string;
5
+ export declare const AMBIGUOUS_MATCH: string;
6
+ export declare const CANNOT_UNBIND: string;
7
+ export declare const NOT_REGISTERED: string;
8
+ export declare const MISSING_INJECTABLE_ANNOTATION: string;
10
9
  export declare const UNDEFINED_INJECT_ANNOTATION: (name: string) => string;
11
- export declare const CIRCULAR_DEPENDENCY = "Circular dependency found:";
12
- export declare const NOT_IMPLEMENTED = "Sorry, this feature is not fully implemented yet.";
13
- export declare const INVALID_BINDING_TYPE = "Invalid binding type:";
14
- export declare const NO_MORE_SNAPSHOTS_AVAILABLE = "No snapshot available to restore.";
15
- export declare const INVALID_MIDDLEWARE_RETURN = "Invalid return type in middleware. Middleware must return!";
16
- export declare const INVALID_FUNCTION_BINDING = "Value provided to function binding must be a function!";
10
+ export declare const CIRCULAR_DEPENDENCY: string;
11
+ export declare const INVALID_BINDING_TYPE: string;
12
+ export declare const NO_MORE_SNAPSHOTS_AVAILABLE: string;
13
+ export declare const INVALID_MIDDLEWARE_RETURN: string;
14
+ export declare const INVALID_FUNCTION_BINDING: string;
17
15
  export declare const LAZY_IN_SYNC: (key: unknown) => string;
18
16
  export declare const INVALID_TO_SELF_VALUE: string;
19
17
  export declare const INVALID_DECORATOR_OPERATION: string;
20
- export declare const ARGUMENTS_LENGTH_MISMATCH: (...values: unknown[]) => string;
18
+ export declare const ARGUMENTS_LENGTH_MISMATCH: (name: string) => string;
21
19
  export declare const CONTAINER_OPTIONS_MUST_BE_AN_OBJECT: string;
22
20
  export declare const CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE: string;
23
21
  export declare const CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE: string;
24
22
  export declare const CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK: string;
25
- export declare const MULTIPLE_PRE_DESTROY_METHODS = "Cannot apply @preDestroy decorator multiple times in the same class";
26
- export declare const MULTIPLE_POST_CONSTRUCT_METHODS = "Cannot apply @postConstruct decorator multiple times in the same class";
27
- export declare const ASYNC_UNBIND_REQUIRED = "Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)";
23
+ export declare const MULTIPLE_PRE_DESTROY_METHODS: string;
24
+ export declare const MULTIPLE_POST_CONSTRUCT_METHODS: string;
25
+ export declare const ASYNC_UNBIND_REQUIRED: string;
28
26
  export declare const POST_CONSTRUCT_ERROR: (clazz: string, errorMessage: string) => string;
29
27
  export declare const PRE_DESTROY_ERROR: (clazz: string, errorMessage: string) => string;
30
28
  export declare const ON_DEACTIVATION_ERROR: (clazz: string, errorMessage: string) => string;
31
29
  export declare const CIRCULAR_DEPENDENCY_IN_FACTORY: (factoryType: string, serviceIdentifier: string) => string;
32
- export declare const STACK_OVERFLOW = "Maximum call stack size exceeded";
30
+ export declare const STACK_OVERFLOW: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STACK_OVERFLOW = exports.CIRCULAR_DEPENDENCY_IN_FACTORY = exports.ON_DEACTIVATION_ERROR = exports.PRE_DESTROY_ERROR = exports.POST_CONSTRUCT_ERROR = exports.ASYNC_UNBIND_REQUIRED = exports.MULTIPLE_POST_CONSTRUCT_METHODS = exports.MULTIPLE_PRE_DESTROY_METHODS = exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = exports.ARGUMENTS_LENGTH_MISMATCH = exports.INVALID_DECORATOR_OPERATION = exports.INVALID_TO_SELF_VALUE = exports.LAZY_IN_SYNC = exports.INVALID_FUNCTION_BINDING = exports.INVALID_MIDDLEWARE_RETURN = exports.NO_MORE_SNAPSHOTS_AVAILABLE = exports.INVALID_BINDING_TYPE = exports.NOT_IMPLEMENTED = exports.CIRCULAR_DEPENDENCY = exports.UNDEFINED_INJECT_ANNOTATION = exports.MISSING_INJECT_ANNOTATION = exports.MISSING_INJECTABLE_ANNOTATION = exports.NOT_REGISTERED = exports.CANNOT_UNBIND = exports.AMBIGUOUS_MATCH = exports.KEY_NOT_FOUND = exports.NULL_ARGUMENT = exports.DUPLICATED_METADATA = exports.DUPLICATED_INJECTABLE_DECORATOR = void 0;
3
+ exports.STACK_OVERFLOW = exports.CIRCULAR_DEPENDENCY_IN_FACTORY = exports.ON_DEACTIVATION_ERROR = exports.PRE_DESTROY_ERROR = exports.POST_CONSTRUCT_ERROR = exports.ASYNC_UNBIND_REQUIRED = exports.MULTIPLE_POST_CONSTRUCT_METHODS = exports.MULTIPLE_PRE_DESTROY_METHODS = exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = exports.ARGUMENTS_LENGTH_MISMATCH = exports.INVALID_DECORATOR_OPERATION = exports.INVALID_TO_SELF_VALUE = exports.LAZY_IN_SYNC = exports.INVALID_FUNCTION_BINDING = exports.INVALID_MIDDLEWARE_RETURN = exports.NO_MORE_SNAPSHOTS_AVAILABLE = exports.INVALID_BINDING_TYPE = exports.CIRCULAR_DEPENDENCY = exports.UNDEFINED_INJECT_ANNOTATION = exports.MISSING_INJECTABLE_ANNOTATION = exports.NOT_REGISTERED = exports.CANNOT_UNBIND = exports.AMBIGUOUS_MATCH = exports.KEY_NOT_FOUND = exports.NULL_ARGUMENT = exports.DUPLICATED_METADATA = exports.DUPLICATED_INJECTABLE_DECORATOR = void 0;
4
4
  exports.DUPLICATED_INJECTABLE_DECORATOR = 'Cannot apply @injectable decorator multiple times.';
5
5
  exports.DUPLICATED_METADATA = 'Metadata key was used more than once in a parameter:';
6
6
  exports.NULL_ARGUMENT = 'NULL argument';
@@ -9,7 +9,6 @@ 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
11
  exports.MISSING_INJECTABLE_ANNOTATION = 'Missing required @injectable annotation in:';
12
- exports.MISSING_INJECT_ANNOTATION = 'Missing required @inject or @multiInject annotation in:';
13
12
  var UNDEFINED_INJECT_ANNOTATION = function (name) {
14
13
  return "@inject called with undefined this could mean that the class ".concat(name, " has ") +
15
14
  'a circular dependency problem. You can use a LazyServiceIdentifer to ' +
@@ -17,43 +16,44 @@ var UNDEFINED_INJECT_ANNOTATION = function (name) {
17
16
  };
18
17
  exports.UNDEFINED_INJECT_ANNOTATION = UNDEFINED_INJECT_ANNOTATION;
19
18
  exports.CIRCULAR_DEPENDENCY = 'Circular dependency found:';
20
- exports.NOT_IMPLEMENTED = 'Sorry, this feature is not fully implemented yet.';
21
19
  exports.INVALID_BINDING_TYPE = 'Invalid binding type:';
22
20
  exports.NO_MORE_SNAPSHOTS_AVAILABLE = 'No snapshot available to restore.';
23
21
  exports.INVALID_MIDDLEWARE_RETURN = 'Invalid return type in middleware. Middleware must return!';
24
22
  exports.INVALID_FUNCTION_BINDING = 'Value provided to function binding must be a function!';
25
- var LAZY_IN_SYNC = function (key) { return "You are attempting to construct ".concat(keyToString(key), " in a synchronous way ") +
26
- 'but it has asynchronous dependencies.'; };
23
+ var LAZY_IN_SYNC = function (key) {
24
+ return "You are attempting to construct ".concat(keyToString(key), " in a synchronous way ") +
25
+ 'but it has asynchronous dependencies.';
26
+ };
27
27
  exports.LAZY_IN_SYNC = LAZY_IN_SYNC;
28
28
  exports.INVALID_TO_SELF_VALUE = 'The toSelf function can only be applied when a constructor is ' +
29
29
  'used as service identifier';
30
30
  exports.INVALID_DECORATOR_OPERATION = 'The @inject @multiInject @tagged and @named decorators ' +
31
31
  'must be applied to the parameters of a class constructor or a class property.';
32
- var ARGUMENTS_LENGTH_MISMATCH = function () {
33
- var values = [];
34
- for (var _i = 0; _i < arguments.length; _i++) {
35
- values[_i] = arguments[_i];
36
- }
32
+ var ARGUMENTS_LENGTH_MISMATCH = function (name) {
37
33
  return 'The number of constructor arguments in the derived class ' +
38
- "".concat(values[0], " must be >= than the number of constructor arguments of its base class.");
34
+ "".concat(name, " must be >= than the number of constructor arguments of its base class.");
39
35
  };
40
36
  exports.ARGUMENTS_LENGTH_MISMATCH = ARGUMENTS_LENGTH_MISMATCH;
41
37
  exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = 'Invalid Container constructor argument. Container options ' +
42
38
  'must be an object.';
43
39
  exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = 'Invalid Container option. Default scope must ' +
44
40
  'be a string ("singleton" or "transient").';
45
- exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = 'Invalid Container option. Auto bind injectable must ' +
46
- 'be a boolean';
47
- exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = 'Invalid Container option. Skip base check must ' +
48
- 'be a boolean';
41
+ exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = 'Invalid Container option. Auto bind injectable must ' + 'be a boolean';
42
+ exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = 'Invalid Container option. Skip base check must ' + 'be a boolean';
49
43
  exports.MULTIPLE_PRE_DESTROY_METHODS = 'Cannot apply @preDestroy decorator multiple times in the same class';
50
44
  exports.MULTIPLE_POST_CONSTRUCT_METHODS = 'Cannot apply @postConstruct decorator multiple times in the same class';
51
45
  exports.ASYNC_UNBIND_REQUIRED = 'Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)';
52
- var POST_CONSTRUCT_ERROR = function (clazz, errorMessage) { return "@postConstruct error in class ".concat(clazz, ": ").concat(errorMessage); };
46
+ var POST_CONSTRUCT_ERROR = function (clazz, errorMessage) {
47
+ return "@postConstruct error in class ".concat(clazz, ": ").concat(errorMessage);
48
+ };
53
49
  exports.POST_CONSTRUCT_ERROR = POST_CONSTRUCT_ERROR;
54
- var PRE_DESTROY_ERROR = function (clazz, errorMessage) { return "@preDestroy error in class ".concat(clazz, ": ").concat(errorMessage); };
50
+ var PRE_DESTROY_ERROR = function (clazz, errorMessage) {
51
+ return "@preDestroy error in class ".concat(clazz, ": ").concat(errorMessage);
52
+ };
55
53
  exports.PRE_DESTROY_ERROR = PRE_DESTROY_ERROR;
56
- var ON_DEACTIVATION_ERROR = function (clazz, errorMessage) { return "onDeactivation() error in class ".concat(clazz, ": ").concat(errorMessage); };
54
+ var ON_DEACTIVATION_ERROR = function (clazz, errorMessage) {
55
+ return "onDeactivation() error in class ".concat(clazz, ": ").concat(errorMessage);
56
+ };
57
57
  exports.ON_DEACTIVATION_ERROR = ON_DEACTIVATION_ERROR;
58
58
  var CIRCULAR_DEPENDENCY_IN_FACTORY = function (factoryType, serviceIdentifier) {
59
59
  return "It looks like there is a circular dependency in one of the '".concat(factoryType, "' bindings. Please investigate bindings with ") +
@@ -4,7 +4,7 @@ exports.TargetTypeEnum = exports.BindingTypeEnum = exports.BindingScopeEnum = vo
4
4
  var BindingScopeEnum = {
5
5
  Request: 'Request',
6
6
  Singleton: 'Singleton',
7
- Transient: 'Transient'
7
+ Transient: 'Transient',
8
8
  };
9
9
  exports.BindingScopeEnum = BindingScopeEnum;
10
10
  var BindingTypeEnum = {
@@ -15,12 +15,12 @@ var BindingTypeEnum = {
15
15
  Function: 'Function',
16
16
  Instance: 'Instance',
17
17
  Invalid: 'Invalid',
18
- Provider: 'Provider'
18
+ Provider: 'Provider',
19
19
  };
20
20
  exports.BindingTypeEnum = BindingTypeEnum;
21
21
  var TargetTypeEnum = {
22
22
  ClassProperty: 'ClassProperty',
23
23
  ConstructorArgument: 'ConstructorArgument',
24
- Variable: 'Variable'
24
+ Variable: 'Variable',
25
25
  };
26
26
  exports.TargetTypeEnum = TargetTypeEnum;
@@ -1,13 +1,13 @@
1
- export declare const NAMED_TAG = "named";
2
- export declare const NAME_TAG = "name";
3
- export declare const UNMANAGED_TAG = "unmanaged";
4
- export declare const OPTIONAL_TAG = "optional";
5
- export declare const INJECT_TAG = "inject";
6
- export declare const MULTI_INJECT_TAG = "multi_inject";
7
- export declare const TAGGED = "inversify:tagged";
8
- export declare const TAGGED_PROP = "inversify:tagged_props";
9
- export declare const PARAM_TYPES = "inversify:paramtypes";
10
- export declare const DESIGN_PARAM_TYPES = "design:paramtypes";
11
- export declare const POST_CONSTRUCT = "post_construct";
12
- export declare const PRE_DESTROY = "pre_destroy";
1
+ export declare const NAMED_TAG: string;
2
+ export declare const NAME_TAG: string;
3
+ export declare const UNMANAGED_TAG: string;
4
+ export declare const OPTIONAL_TAG: string;
5
+ export declare const INJECT_TAG: string;
6
+ export declare const MULTI_INJECT_TAG: string;
7
+ export declare const TAGGED: string;
8
+ export declare const TAGGED_PROP: string;
9
+ export declare const PARAM_TYPES: string;
10
+ export declare const DESIGN_PARAM_TYPES: string;
11
+ export declare const POST_CONSTRUCT: string;
12
+ export declare const PRE_DESTROY: string;
13
13
  export declare const NON_CUSTOM_TAG_KEYS: string[];
@@ -7,11 +7,11 @@ declare class Container implements interfaces.Container {
7
7
  private _bindingDictionary;
8
8
  private _activations;
9
9
  private _deactivations;
10
- private _snapshots;
10
+ private readonly _snapshots;
11
11
  private _metadataReader;
12
12
  private _moduleActivationStore;
13
- static merge(container1: interfaces.Container, container2: interfaces.Container, ...containers: interfaces.Container[]): interfaces.Container;
14
13
  constructor(containerOptions?: interfaces.ContainerOptions);
14
+ static merge(container1: interfaces.Container, container2: interfaces.Container, ...containers: interfaces.Container[]): interfaces.Container;
15
15
  load(...modules: interfaces.ContainerModule[]): void;
16
16
  loadAsync(...modules: interfaces.AsyncContainerModule[]): Promise<void>;
17
17
  unload(...modules: interfaces.ContainerModuleBase[]): void;