inversify 6.1.5-beta.0 → 6.1.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/{es → lib/cjs}/annotation/decorator_utils.d.ts +1 -0
- package/lib/cjs/annotation/decorator_utils.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/decorator_utils.js +8 -0
- package/lib/cjs/annotation/decorator_utils.js.map +1 -0
- package/{es → lib/cjs}/annotation/inject.d.ts +1 -0
- package/lib/cjs/annotation/inject.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/inject.js +1 -0
- package/lib/cjs/annotation/inject.js.map +1 -0
- package/{es → lib/cjs}/annotation/inject_base.d.ts +1 -0
- package/lib/cjs/annotation/inject_base.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/inject_base.js +2 -0
- package/lib/cjs/annotation/inject_base.js.map +1 -0
- package/{es → lib/cjs}/annotation/injectable.d.ts +1 -0
- package/lib/cjs/annotation/injectable.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/injectable.js +2 -0
- package/lib/cjs/annotation/injectable.js.map +1 -0
- package/lib/{annotation → cjs/annotation}/multi_inject.d.ts +1 -0
- package/lib/cjs/annotation/multi_inject.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/multi_inject.js +1 -0
- package/lib/cjs/annotation/multi_inject.js.map +1 -0
- package/{es → lib/cjs}/annotation/named.d.ts +1 -0
- package/lib/cjs/annotation/named.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/named.js +2 -0
- package/lib/cjs/annotation/named.js.map +1 -0
- package/{es → lib/cjs}/annotation/optional.d.ts +1 -0
- package/lib/cjs/annotation/optional.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/optional.js +1 -0
- package/lib/cjs/annotation/optional.js.map +1 -0
- package/{es → lib/cjs}/annotation/post_construct.d.ts +1 -0
- package/lib/cjs/annotation/post_construct.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/post_construct.js +1 -0
- package/lib/cjs/annotation/post_construct.js.map +1 -0
- package/{es → lib/cjs}/annotation/pre_destroy.d.ts +1 -0
- package/lib/cjs/annotation/pre_destroy.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/pre_destroy.js +1 -0
- package/lib/cjs/annotation/pre_destroy.js.map +1 -0
- package/lib/{annotation → cjs/annotation}/property_event_decorator.d.ts +1 -0
- package/lib/cjs/annotation/property_event_decorator.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/property_event_decorator.js +1 -0
- package/lib/cjs/annotation/property_event_decorator.js.map +1 -0
- package/{es → lib/cjs}/annotation/tagged.d.ts +1 -0
- package/lib/cjs/annotation/tagged.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/tagged.js +2 -0
- package/lib/cjs/annotation/tagged.js.map +1 -0
- package/lib/{annotation → cjs/annotation}/target_name.d.ts +1 -0
- package/lib/cjs/annotation/target_name.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/target_name.js +1 -0
- package/lib/cjs/annotation/target_name.js.map +1 -0
- package/lib/{annotation → cjs/annotation}/unmanaged.d.ts +1 -0
- package/lib/cjs/annotation/unmanaged.d.ts.map +1 -0
- package/lib/{annotation → cjs/annotation}/unmanaged.js +1 -0
- package/lib/cjs/annotation/unmanaged.js.map +1 -0
- package/lib/{bindings → cjs/bindings}/binding.d.ts +1 -0
- package/lib/cjs/bindings/binding.d.ts.map +1 -0
- package/lib/{bindings → cjs/bindings}/binding.js +15 -0
- package/lib/cjs/bindings/binding.js.map +1 -0
- package/lib/{bindings → cjs/bindings}/binding_count.d.ts +1 -0
- package/lib/cjs/bindings/binding_count.d.ts.map +1 -0
- package/lib/{bindings → cjs/bindings}/binding_count.js +1 -0
- package/lib/cjs/bindings/binding_count.js.map +1 -0
- package/{es → lib/cjs}/constants/error_msgs.d.ts +1 -0
- package/lib/cjs/constants/error_msgs.d.ts.map +1 -0
- package/lib/{constants → cjs/constants}/error_msgs.js +2 -0
- package/lib/cjs/constants/error_msgs.js.map +1 -0
- package/lib/{constants → cjs/constants}/literal_types.d.ts +1 -0
- package/lib/cjs/constants/literal_types.d.ts.map +1 -0
- package/lib/{constants → cjs/constants}/literal_types.js +4 -0
- package/lib/cjs/constants/literal_types.js.map +1 -0
- package/{es → lib/cjs}/constants/metadata_keys.d.ts +1 -0
- package/lib/cjs/constants/metadata_keys.d.ts.map +1 -0
- package/lib/{constants → cjs/constants}/metadata_keys.js +13 -0
- package/lib/cjs/constants/metadata_keys.js.map +1 -0
- package/lib/{container → cjs/container}/container.d.ts +1 -0
- package/lib/cjs/container/container.d.ts.map +1 -0
- package/lib/{container → cjs/container}/container.js +29 -1
- package/lib/cjs/container/container.js.map +1 -0
- package/{es → lib/cjs}/container/container_module.d.ts +1 -0
- package/lib/cjs/container/container_module.d.ts.map +1 -0
- package/lib/{container → cjs/container}/container_module.js +1 -0
- package/lib/cjs/container/container_module.js.map +1 -0
- package/lib/{container → cjs/container}/container_snapshot.d.ts +1 -0
- package/lib/cjs/container/container_snapshot.d.ts.map +1 -0
- package/lib/{container → cjs/container}/container_snapshot.js +1 -0
- package/lib/cjs/container/container_snapshot.js.map +1 -0
- package/lib/{container → cjs/container}/lookup.d.ts +1 -0
- package/lib/cjs/container/lookup.d.ts.map +1 -0
- package/lib/{container → cjs/container}/lookup.js +8 -0
- package/lib/cjs/container/lookup.js.map +1 -0
- package/{es → lib/cjs}/container/module_activation_store.d.ts +1 -0
- package/lib/cjs/container/module_activation_store.d.ts.map +1 -0
- package/lib/{container → cjs/container}/module_activation_store.js +1 -0
- package/lib/cjs/container/module_activation_store.js.map +1 -0
- package/{es/inversify.d.ts → lib/cjs/index.d.ts} +1 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/{inversify.js → cjs/index.js} +2 -0
- package/lib/cjs/index.js.map +1 -0
- package/{es → lib/cjs}/interfaces/interfaces.d.ts +2 -1
- package/lib/cjs/interfaces/interfaces.d.ts.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/interfaces.js +1 -0
- package/lib/cjs/interfaces/interfaces.js.map +1 -0
- package/lib/cjs/interfaces/interfaces_common_exports.d.ts +4 -0
- package/lib/cjs/interfaces/interfaces_common_exports.d.ts.map +1 -0
- package/lib/{annotation/lazy_service_identifier.js → cjs/interfaces/interfaces_common_exports.js} +1 -0
- package/lib/cjs/interfaces/interfaces_common_exports.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/{es → lib/cjs}/planning/context.d.ts +1 -0
- package/lib/cjs/planning/context.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/context.js +1 -0
- package/lib/cjs/planning/context.js.map +1 -0
- package/lib/{planning → cjs/planning}/metadata.d.ts +1 -0
- package/lib/cjs/planning/metadata.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/metadata.js +1 -0
- package/lib/cjs/planning/metadata.js.map +1 -0
- package/lib/{planning → cjs/planning}/metadata_reader.d.ts +1 -0
- package/lib/cjs/planning/metadata_reader.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/metadata_reader.js +4 -0
- package/lib/cjs/planning/metadata_reader.js.map +1 -0
- package/{es → lib/cjs}/planning/plan.d.ts +1 -0
- package/lib/cjs/planning/plan.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/plan.js +1 -0
- package/lib/cjs/planning/plan.js.map +1 -0
- package/{es → lib/cjs}/planning/planner.d.ts +1 -0
- package/lib/cjs/planning/planner.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/planner.js +10 -0
- package/lib/cjs/planning/planner.js.map +1 -0
- package/{es → lib/cjs}/planning/queryable_string.d.ts +1 -0
- package/lib/cjs/planning/queryable_string.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/queryable_string.js +2 -0
- package/lib/cjs/planning/queryable_string.js.map +1 -0
- package/{es → lib/cjs}/planning/reflection_utils.d.ts +1 -0
- package/lib/cjs/planning/reflection_utils.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/reflection_utils.js +8 -1
- package/lib/cjs/planning/reflection_utils.js.map +1 -0
- package/{es → lib/cjs}/planning/request.d.ts +1 -0
- package/lib/cjs/planning/request.d.ts.map +1 -0
- package/lib/{planning → cjs/planning}/request.js +5 -1
- package/lib/cjs/planning/request.js.map +1 -0
- package/lib/{resolution → cjs/resolution}/instantiation.d.ts +1 -0
- package/lib/cjs/resolution/instantiation.d.ts.map +1 -0
- package/lib/{resolution → cjs/resolution}/instantiation.js +1 -0
- package/lib/cjs/resolution/instantiation.js.map +1 -0
- package/{es → lib/cjs}/resolution/resolver.d.ts +1 -0
- package/lib/cjs/resolution/resolver.d.ts.map +1 -0
- package/lib/{resolution → cjs/resolution}/resolver.js +18 -0
- package/lib/cjs/resolution/resolver.js.map +1 -0
- package/{es → lib/cjs}/scope/scope.d.ts +1 -0
- package/lib/cjs/scope/scope.d.ts.map +1 -0
- package/lib/{scope → cjs/scope}/scope.js +7 -0
- package/lib/cjs/scope/scope.js.map +1 -0
- package/{es → lib/cjs}/syntax/binding_in_syntax.d.ts +1 -0
- package/lib/cjs/syntax/binding_in_syntax.d.ts.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_in_syntax.js +1 -0
- package/lib/cjs/syntax/binding_in_syntax.js.map +1 -0
- package/{es → lib/cjs}/syntax/binding_in_when_on_syntax.d.ts +1 -0
- package/lib/cjs/syntax/binding_in_when_on_syntax.d.ts.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_in_when_on_syntax.js +1 -0
- package/lib/cjs/syntax/binding_in_when_on_syntax.js.map +1 -0
- package/{es → lib/cjs}/syntax/binding_on_syntax.d.ts +1 -0
- package/lib/cjs/syntax/binding_on_syntax.d.ts.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_on_syntax.js +1 -0
- package/lib/cjs/syntax/binding_on_syntax.js.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_to_syntax.d.ts +1 -0
- package/lib/cjs/syntax/binding_to_syntax.d.ts.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_to_syntax.js +7 -0
- package/lib/cjs/syntax/binding_to_syntax.js.map +1 -0
- package/{es → lib/cjs}/syntax/binding_when_on_syntax.d.ts +1 -0
- package/lib/cjs/syntax/binding_when_on_syntax.d.ts.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_when_on_syntax.js +1 -0
- package/lib/cjs/syntax/binding_when_on_syntax.js.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_when_syntax.d.ts +1 -0
- package/lib/cjs/syntax/binding_when_syntax.d.ts.map +1 -0
- package/lib/{syntax → cjs/syntax}/binding_when_syntax.js +4 -1
- package/lib/cjs/syntax/binding_when_syntax.js.map +1 -0
- package/{es → lib/cjs}/syntax/constraint_helpers.d.ts +1 -0
- package/lib/cjs/syntax/constraint_helpers.d.ts.map +1 -0
- package/lib/{syntax → cjs/syntax}/constraint_helpers.js +5 -0
- package/lib/cjs/syntax/constraint_helpers.js.map +1 -0
- package/{es → lib/cjs}/utils/async.d.ts +1 -0
- package/lib/cjs/utils/async.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/async.js +1 -0
- package/lib/cjs/utils/async.js.map +1 -0
- package/{es → lib/cjs}/utils/binding_utils.d.ts +1 -0
- package/lib/cjs/utils/binding_utils.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/binding_utils.js +4 -0
- package/lib/cjs/utils/binding_utils.js.map +1 -0
- package/{es → lib/cjs}/utils/clonable.d.ts +1 -0
- package/lib/cjs/utils/clonable.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/clonable.js +1 -0
- package/lib/cjs/utils/clonable.js.map +1 -0
- package/{es → lib/cjs}/utils/exceptions.d.ts +1 -0
- package/lib/cjs/utils/exceptions.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/exceptions.js +1 -0
- package/lib/cjs/utils/exceptions.js.map +1 -0
- package/lib/{utils → cjs/utils}/factory_type.d.ts +1 -0
- package/lib/cjs/utils/factory_type.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/factory_type.js +1 -0
- package/lib/cjs/utils/factory_type.js.map +1 -0
- package/{es → lib/cjs}/utils/id.d.ts +1 -0
- package/lib/cjs/utils/id.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/id.js +1 -0
- package/lib/cjs/utils/id.js.map +1 -0
- package/{es → lib/cjs}/utils/js.d.ts +1 -0
- package/lib/cjs/utils/js.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/js.js +1 -0
- package/lib/cjs/utils/js.js.map +1 -0
- package/{es → lib/cjs}/utils/serialization.d.ts +1 -0
- package/lib/cjs/utils/serialization.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/serialization.js +6 -0
- package/lib/cjs/utils/serialization.js.map +1 -0
- package/lib/{interfaces/interfaces.d.ts → esm/index.d.ts} +206 -4
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -0
- package/package.json +21 -24
- package/es/annotation/decorator_utils.js +0 -90
- package/es/annotation/inject.js +0 -4
- package/es/annotation/inject_base.js +0 -14
- package/es/annotation/injectable.js +0 -13
- package/es/annotation/lazy_service_identifier.js +0 -1
- package/es/annotation/multi_inject.d.ts +0 -5
- package/es/annotation/multi_inject.js +0 -4
- package/es/annotation/named.js +0 -7
- package/es/annotation/optional.js +0 -7
- package/es/annotation/post_construct.js +0 -5
- package/es/annotation/pre_destroy.js +0 -5
- package/es/annotation/property_event_decorator.d.ts +0 -4
- package/es/annotation/property_event_decorator.js +0 -13
- package/es/annotation/tagged.js +0 -6
- package/es/annotation/target_name.d.ts +0 -3
- package/es/annotation/target_name.js +0 -10
- package/es/annotation/unmanaged.d.ts +0 -3
- package/es/annotation/unmanaged.js +0 -10
- package/es/bindings/binding.d.ts +0 -20
- package/es/bindings/binding.js +0 -37
- package/es/bindings/binding_count.d.ts +0 -5
- package/es/bindings/binding_count.js +0 -6
- package/es/constants/error_msgs.js +0 -62
- package/es/constants/literal_types.d.ts +0 -5
- package/es/constants/literal_types.js +0 -21
- package/es/constants/metadata_keys.js +0 -23
- package/es/container/container.d.ts +0 -75
- package/es/container/container.js +0 -750
- package/es/container/container_module.js +0 -17
- package/es/container/container_snapshot.d.ts +0 -10
- package/es/container/container_snapshot.js +0 -15
- package/es/container/lookup.d.ts +0 -17
- package/es/container/lookup.js +0 -105
- package/es/container/module_activation_store.js +0 -47
- package/es/interfaces/interfaces.js +0 -1
- package/es/inversify.js +0 -3
- package/es/inversify.js.LICENSE.txt +0 -14
- package/es/planning/context.js +0 -15
- package/es/planning/metadata.d.ts +0 -8
- package/es/planning/metadata.js +0 -17
- package/es/planning/metadata_reader.d.ts +0 -6
- package/es/planning/metadata_reader.js +0 -21
- package/es/planning/plan.js +0 -8
- package/es/planning/planner.js +0 -168
- package/es/planning/queryable_string.js +0 -28
- package/es/planning/reflection_utils.js +0 -27
- package/es/planning/request.js +0 -20
- package/es/planning/target.js +0 -87
- package/es/resolution/instantiation.d.ts +0 -3
- package/es/resolution/instantiation.js +0 -195
- package/es/resolution/resolver.js +0 -214
- package/es/scope/scope.js +0 -88
- package/es/syntax/binding_in_syntax.js +0 -21
- package/es/syntax/binding_in_when_on_syntax.js +0 -73
- package/es/syntax/binding_on_syntax.js +0 -16
- package/es/syntax/binding_to_syntax.d.ts +0 -18
- package/es/syntax/binding_to_syntax.js +0 -91
- package/es/syntax/binding_when_on_syntax.js +0 -62
- package/es/syntax/binding_when_syntax.d.ts +0 -21
- package/es/syntax/binding_when_syntax.js +0 -104
- package/es/syntax/constraint_helpers.js +0 -36
- package/es/utils/async.js +0 -12
- package/es/utils/binding_utils.js +0 -58
- package/es/utils/clonable.js +0 -7
- package/es/utils/exceptions.js +0 -16
- package/es/utils/factory_type.d.ts +0 -5
- package/es/utils/factory_type.js +0 -6
- package/es/utils/id.js +0 -5
- package/es/utils/js.js +0 -13
- package/es/utils/serialization.js +0 -103
- package/lib/annotation/decorator_utils.d.ts +0 -16
- package/lib/annotation/inject.d.ts +0 -5
- package/lib/annotation/inject_base.d.ts +0 -4
- package/lib/annotation/injectable.d.ts +0 -2
- package/lib/annotation/lazy_service_identifier.d.ts +0 -3
- package/lib/annotation/named.d.ts +0 -2
- package/lib/annotation/optional.d.ts +0 -2
- package/lib/annotation/post_construct.d.ts +0 -4
- package/lib/annotation/pre_destroy.d.ts +0 -4
- package/lib/annotation/tagged.d.ts +0 -2
- package/lib/constants/error_msgs.d.ts +0 -30
- package/lib/constants/metadata_keys.d.ts +0 -13
- package/lib/container/container_module.d.ts +0 -11
- package/lib/container/module_activation_store.d.ts +0 -10
- package/lib/inversify.d.ts +0 -25
- package/lib/planning/context.d.ts +0 -11
- package/lib/planning/plan.d.ts +0 -7
- package/lib/planning/planner.d.ts +0 -5
- package/lib/planning/queryable_string.d.ts +0 -10
- package/lib/planning/reflection_utils.d.ts +0 -5
- package/lib/planning/request.d.ts +0 -14
- package/lib/planning/target.d.ts +0 -23
- package/lib/planning/target.js +0 -113
- package/lib/resolution/resolver.d.ts +0 -3
- package/lib/scope/scope.d.ts +0 -3
- package/lib/syntax/binding_in_syntax.d.ts +0 -9
- package/lib/syntax/binding_in_when_on_syntax.d.ts +0 -29
- package/lib/syntax/binding_on_syntax.d.ts +0 -8
- package/lib/syntax/binding_when_on_syntax.d.ts +0 -25
- package/lib/syntax/constraint_helpers.d.ts +0 -6
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/utils/async.d.ts +0 -3
- package/lib/utils/binding_utils.d.ts +0 -4
- package/lib/utils/clonable.d.ts +0 -3
- package/lib/utils/exceptions.d.ts +0 -2
- package/lib/utils/id.d.ts +0 -2
- package/lib/utils/js.d.ts +0 -1
- package/lib/utils/serialization.d.ts +0 -10
- /package/{es → lib/esm}/package.json +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (C) Microsoft. All rights reserved.
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
5
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
8
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
9
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
10
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
11
|
-
|
|
12
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
|
-
and limitations under the License.
|
|
14
|
-
***************************************************************************** */
|
package/es/planning/context.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { id } from '../utils/id';
|
|
2
|
-
var Context = (function () {
|
|
3
|
-
function Context(container) {
|
|
4
|
-
this.id = id();
|
|
5
|
-
this.container = container;
|
|
6
|
-
}
|
|
7
|
-
Context.prototype.addPlan = function (plan) {
|
|
8
|
-
this.plan = plan;
|
|
9
|
-
};
|
|
10
|
-
Context.prototype.setCurrentRequest = function (currentRequest) {
|
|
11
|
-
this.currentRequest = currentRequest;
|
|
12
|
-
};
|
|
13
|
-
return Context;
|
|
14
|
-
}());
|
|
15
|
-
export { Context };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { interfaces } from '../interfaces/interfaces';
|
|
2
|
-
declare class Metadata implements interfaces.Metadata {
|
|
3
|
-
key: string | number | symbol;
|
|
4
|
-
value: unknown;
|
|
5
|
-
constructor(key: string | number | symbol, value: unknown);
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
|
8
|
-
export { Metadata };
|
package/es/planning/metadata.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as METADATA_KEY from '../constants/metadata_keys';
|
|
2
|
-
var Metadata = (function () {
|
|
3
|
-
function Metadata(key, value) {
|
|
4
|
-
this.key = key;
|
|
5
|
-
this.value = value;
|
|
6
|
-
}
|
|
7
|
-
Metadata.prototype.toString = function () {
|
|
8
|
-
if (this.key === METADATA_KEY.NAMED_TAG) {
|
|
9
|
-
return "named: ".concat(String(this.value).toString(), " ");
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
return "tagged: { key:".concat(this.key.toString(), ", value: ").concat(String(this.value), " }");
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
return Metadata;
|
|
16
|
-
}());
|
|
17
|
-
export { Metadata };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { interfaces } from '../interfaces/interfaces';
|
|
2
|
-
declare class MetadataReader implements interfaces.MetadataReader {
|
|
3
|
-
getConstructorMetadata(constructorFunc: NewableFunction): interfaces.ConstructorMetadata;
|
|
4
|
-
getPropertiesMetadata(constructorFunc: NewableFunction): interfaces.MetadataMap;
|
|
5
|
-
}
|
|
6
|
-
export { MetadataReader };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as METADATA_KEY from '../constants/metadata_keys';
|
|
2
|
-
var MetadataReader = (function () {
|
|
3
|
-
function MetadataReader() {
|
|
4
|
-
}
|
|
5
|
-
MetadataReader.prototype.getConstructorMetadata = function (constructorFunc) {
|
|
6
|
-
var _a;
|
|
7
|
-
var compilerGeneratedMetadata = (_a = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, constructorFunc)) !== null && _a !== void 0 ? _a : [];
|
|
8
|
-
var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED, constructorFunc);
|
|
9
|
-
return {
|
|
10
|
-
compilerGeneratedMetadata: compilerGeneratedMetadata,
|
|
11
|
-
userGeneratedMetadata: userGeneratedMetadata !== null && userGeneratedMetadata !== void 0 ? userGeneratedMetadata : {},
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
MetadataReader.prototype.getPropertiesMetadata = function (constructorFunc) {
|
|
15
|
-
var _a;
|
|
16
|
-
var userGeneratedMetadata = (_a = Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, constructorFunc)) !== null && _a !== void 0 ? _a : {};
|
|
17
|
-
return userGeneratedMetadata;
|
|
18
|
-
};
|
|
19
|
-
return MetadataReader;
|
|
20
|
-
}());
|
|
21
|
-
export { MetadataReader };
|
package/es/planning/plan.js
DELETED
package/es/planning/planner.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { ClassElementMetadataKind, getClassElementMetadataFromLegacyMetadata, LegacyTargetImpl as TargetImpl, } from '@inversifyjs/core';
|
|
2
|
-
import { BindingCount } from '../bindings/binding_count';
|
|
3
|
-
import * as ERROR_MSGS from '../constants/error_msgs';
|
|
4
|
-
import { BindingTypeEnum } from '../constants/literal_types';
|
|
5
|
-
import * as METADATA_KEY from '../constants/metadata_keys';
|
|
6
|
-
import { isStackOverflowException } from '../utils/exceptions';
|
|
7
|
-
import { circularDependencyToException, getServiceIdentifierAsString, listMetadataForTarget, listRegisteredBindingsForServiceIdentifier, } from '../utils/serialization';
|
|
8
|
-
import { Context } from './context';
|
|
9
|
-
import { Metadata } from './metadata';
|
|
10
|
-
import { Plan } from './plan';
|
|
11
|
-
import { getBaseClassDependencyCount, getDependencies, getFunctionName, } from './reflection_utils';
|
|
12
|
-
import { Request } from './request';
|
|
13
|
-
function getBindingDictionary(cntnr) {
|
|
14
|
-
return cntnr._bindingDictionary;
|
|
15
|
-
}
|
|
16
|
-
function _createTarget(isMultiInject, targetType, serviceIdentifier, name, key, value) {
|
|
17
|
-
var metadataList = _getTargetMetadata(isMultiInject, serviceIdentifier, key, value);
|
|
18
|
-
var classElementMetadata = getClassElementMetadataFromLegacyMetadata(metadataList);
|
|
19
|
-
if (classElementMetadata.kind === ClassElementMetadataKind.unmanaged) {
|
|
20
|
-
throw new Error('Unexpected metadata when creating target');
|
|
21
|
-
}
|
|
22
|
-
var target = new TargetImpl(name, classElementMetadata, targetType);
|
|
23
|
-
return target;
|
|
24
|
-
}
|
|
25
|
-
function _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target) {
|
|
26
|
-
var bindings = getBindings(context.container, target.serviceIdentifier);
|
|
27
|
-
var activeBindings = [];
|
|
28
|
-
if (bindings.length === BindingCount.NoBindingsAvailable &&
|
|
29
|
-
context.container.options.autoBindInjectable === true &&
|
|
30
|
-
typeof target.serviceIdentifier === 'function' &&
|
|
31
|
-
metadataReader.getConstructorMetadata(target.serviceIdentifier)
|
|
32
|
-
.compilerGeneratedMetadata) {
|
|
33
|
-
context.container.bind(target.serviceIdentifier).toSelf();
|
|
34
|
-
bindings = getBindings(context.container, target.serviceIdentifier);
|
|
35
|
-
}
|
|
36
|
-
if (!avoidConstraints) {
|
|
37
|
-
activeBindings = bindings.filter(function (binding) {
|
|
38
|
-
var request = new Request(binding.serviceIdentifier, context, parentRequest, binding, target);
|
|
39
|
-
return binding.constraint(request);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
activeBindings = bindings;
|
|
44
|
-
}
|
|
45
|
-
_validateActiveBindingCount(target.serviceIdentifier, activeBindings, parentRequest, target, context.container);
|
|
46
|
-
return activeBindings;
|
|
47
|
-
}
|
|
48
|
-
function _getTargetMetadata(isMultiInject, serviceIdentifier, key, value) {
|
|
49
|
-
var metadataKey = isMultiInject
|
|
50
|
-
? METADATA_KEY.MULTI_INJECT_TAG
|
|
51
|
-
: METADATA_KEY.INJECT_TAG;
|
|
52
|
-
var metadataList = [
|
|
53
|
-
new Metadata(metadataKey, serviceIdentifier),
|
|
54
|
-
];
|
|
55
|
-
if (key !== undefined) {
|
|
56
|
-
metadataList.push(new Metadata(key, value));
|
|
57
|
-
}
|
|
58
|
-
return metadataList;
|
|
59
|
-
}
|
|
60
|
-
function _validateActiveBindingCount(serviceIdentifier, bindings, parentRequest, target, container) {
|
|
61
|
-
switch (bindings.length) {
|
|
62
|
-
case BindingCount.NoBindingsAvailable:
|
|
63
|
-
if (target.isOptional()) {
|
|
64
|
-
return bindings;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
var serviceIdentifierString = getServiceIdentifierAsString(serviceIdentifier);
|
|
68
|
-
var msg = ERROR_MSGS.NOT_REGISTERED;
|
|
69
|
-
msg += listMetadataForTarget(serviceIdentifierString, target);
|
|
70
|
-
msg += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
|
|
71
|
-
if (parentRequest !== null) {
|
|
72
|
-
msg += "\n".concat(ERROR_MSGS.TRYING_TO_RESOLVE_BINDINGS(getServiceIdentifierAsString(parentRequest.serviceIdentifier)));
|
|
73
|
-
}
|
|
74
|
-
throw new Error(msg);
|
|
75
|
-
}
|
|
76
|
-
case BindingCount.OnlyOneBindingAvailable:
|
|
77
|
-
return bindings;
|
|
78
|
-
case BindingCount.MultipleBindingsAvailable:
|
|
79
|
-
default:
|
|
80
|
-
if (!target.isArray()) {
|
|
81
|
-
var serviceIdentifierString = getServiceIdentifierAsString(serviceIdentifier);
|
|
82
|
-
var msg = "".concat(ERROR_MSGS.AMBIGUOUS_MATCH, " ").concat(serviceIdentifierString);
|
|
83
|
-
msg += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
|
|
84
|
-
throw new Error(msg);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
return bindings;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, parentRequest, target) {
|
|
92
|
-
var activeBindings;
|
|
93
|
-
var childRequest;
|
|
94
|
-
if (parentRequest === null) {
|
|
95
|
-
activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, null, target);
|
|
96
|
-
childRequest = new Request(serviceIdentifier, context, null, activeBindings, target);
|
|
97
|
-
var thePlan = new Plan(context, childRequest);
|
|
98
|
-
context.addPlan(thePlan);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target);
|
|
102
|
-
childRequest = parentRequest.addChildRequest(target.serviceIdentifier, activeBindings, target);
|
|
103
|
-
}
|
|
104
|
-
activeBindings.forEach(function (binding) {
|
|
105
|
-
var subChildRequest = null;
|
|
106
|
-
if (target.isArray()) {
|
|
107
|
-
subChildRequest = childRequest.addChildRequest(binding.serviceIdentifier, binding, target);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
if (binding.cache !== null) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
subChildRequest = childRequest;
|
|
114
|
-
}
|
|
115
|
-
if (binding.type === BindingTypeEnum.Instance &&
|
|
116
|
-
binding.implementationType !== null) {
|
|
117
|
-
var dependencies = getDependencies(metadataReader, binding.implementationType);
|
|
118
|
-
if (context.container.options.skipBaseClassChecks !== true) {
|
|
119
|
-
var baseClassDependencyCount = getBaseClassDependencyCount(metadataReader, binding.implementationType);
|
|
120
|
-
if (dependencies.length < baseClassDependencyCount) {
|
|
121
|
-
var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH(getFunctionName(binding.implementationType));
|
|
122
|
-
throw new Error(error);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
dependencies.forEach(function (dependency) {
|
|
126
|
-
_createSubRequests(metadataReader, false, dependency.serviceIdentifier, context, subChildRequest, dependency);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function getBindings(container, serviceIdentifier) {
|
|
132
|
-
var bindings = [];
|
|
133
|
-
var bindingDictionary = getBindingDictionary(container);
|
|
134
|
-
if (bindingDictionary.hasKey(serviceIdentifier)) {
|
|
135
|
-
bindings = bindingDictionary.get(serviceIdentifier);
|
|
136
|
-
}
|
|
137
|
-
else if (container.parent !== null) {
|
|
138
|
-
bindings = getBindings(container.parent, serviceIdentifier);
|
|
139
|
-
}
|
|
140
|
-
return bindings;
|
|
141
|
-
}
|
|
142
|
-
function plan(metadataReader, container, isMultiInject, targetType, serviceIdentifier, key, value, avoidConstraints) {
|
|
143
|
-
if (avoidConstraints === void 0) { avoidConstraints = false; }
|
|
144
|
-
var context = new Context(container);
|
|
145
|
-
var target = _createTarget(isMultiInject, targetType, serviceIdentifier, '', key, value);
|
|
146
|
-
try {
|
|
147
|
-
_createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, null, target);
|
|
148
|
-
return context;
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
if (isStackOverflowException(error)) {
|
|
152
|
-
circularDependencyToException(context.plan.rootRequest);
|
|
153
|
-
}
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function createMockRequest(container, serviceIdentifier, key, value) {
|
|
158
|
-
var metadataList = _getTargetMetadata(false, serviceIdentifier, key, value);
|
|
159
|
-
var classElementMetadata = getClassElementMetadataFromLegacyMetadata(metadataList);
|
|
160
|
-
if (classElementMetadata.kind === ClassElementMetadataKind.unmanaged) {
|
|
161
|
-
throw new Error('Unexpected metadata when creating target');
|
|
162
|
-
}
|
|
163
|
-
var target = new TargetImpl('', classElementMetadata, 'Variable');
|
|
164
|
-
var context = new Context(container);
|
|
165
|
-
var request = new Request(serviceIdentifier, context, null, [], target);
|
|
166
|
-
return request;
|
|
167
|
-
}
|
|
168
|
-
export { plan, createMockRequest, getBindingDictionary };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var QueryableString = (function () {
|
|
2
|
-
function QueryableString(str) {
|
|
3
|
-
this.str = str;
|
|
4
|
-
}
|
|
5
|
-
QueryableString.prototype.startsWith = function (searchString) {
|
|
6
|
-
return this.str.indexOf(searchString) === 0;
|
|
7
|
-
};
|
|
8
|
-
QueryableString.prototype.endsWith = function (searchString) {
|
|
9
|
-
var reverseString = '';
|
|
10
|
-
var reverseSearchString = searchString
|
|
11
|
-
.split('')
|
|
12
|
-
.reverse()
|
|
13
|
-
.join('');
|
|
14
|
-
reverseString = this.str.split('').reverse().join('');
|
|
15
|
-
return this.startsWith.call({ str: reverseString }, reverseSearchString);
|
|
16
|
-
};
|
|
17
|
-
QueryableString.prototype.contains = function (searchString) {
|
|
18
|
-
return this.str.indexOf(searchString) !== -1;
|
|
19
|
-
};
|
|
20
|
-
QueryableString.prototype.equals = function (compareString) {
|
|
21
|
-
return this.str === compareString;
|
|
22
|
-
};
|
|
23
|
-
QueryableString.prototype.value = function () {
|
|
24
|
-
return this.str;
|
|
25
|
-
};
|
|
26
|
-
return QueryableString;
|
|
27
|
-
}());
|
|
28
|
-
export { QueryableString };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getTargets } from '@inversifyjs/core';
|
|
2
|
-
import * as METADATA_KEY from '../constants/metadata_keys';
|
|
3
|
-
import { getFunctionName } from '../utils/serialization';
|
|
4
|
-
function getDependencies(metadataReader, func) {
|
|
5
|
-
return getTargets(metadataReader)(func);
|
|
6
|
-
}
|
|
7
|
-
function getBaseClassDependencyCount(metadataReader, func) {
|
|
8
|
-
var baseConstructor = Object.getPrototypeOf(func.prototype).constructor;
|
|
9
|
-
if (baseConstructor !== Object) {
|
|
10
|
-
var targets = getTargets(metadataReader)(baseConstructor);
|
|
11
|
-
var metadata = targets.map(function (t) {
|
|
12
|
-
return t.metadata.filter(function (m) { return m.key === METADATA_KEY.UNMANAGED_TAG; });
|
|
13
|
-
});
|
|
14
|
-
var unmanagedCount = [].concat.apply([], metadata).length;
|
|
15
|
-
var dependencyCount = targets.length - unmanagedCount;
|
|
16
|
-
if (dependencyCount > 0) {
|
|
17
|
-
return dependencyCount;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return getBaseClassDependencyCount(metadataReader, baseConstructor);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export { getDependencies, getBaseClassDependencyCount, getFunctionName };
|
package/es/planning/request.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { id } from '../utils/id';
|
|
2
|
-
var Request = (function () {
|
|
3
|
-
function Request(serviceIdentifier, parentContext, parentRequest, bindings, target) {
|
|
4
|
-
this.id = id();
|
|
5
|
-
this.serviceIdentifier = serviceIdentifier;
|
|
6
|
-
this.parentContext = parentContext;
|
|
7
|
-
this.parentRequest = parentRequest;
|
|
8
|
-
this.target = target;
|
|
9
|
-
this.childRequests = [];
|
|
10
|
-
this.bindings = Array.isArray(bindings) ? bindings : [bindings];
|
|
11
|
-
this.requestScope = parentRequest === null ? new Map() : null;
|
|
12
|
-
}
|
|
13
|
-
Request.prototype.addChildRequest = function (serviceIdentifier, bindings, target) {
|
|
14
|
-
var child = new Request(serviceIdentifier, this.parentContext, this, bindings, target);
|
|
15
|
-
this.childRequests.push(child);
|
|
16
|
-
return child;
|
|
17
|
-
};
|
|
18
|
-
return Request;
|
|
19
|
-
}());
|
|
20
|
-
export { Request };
|
package/es/planning/target.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import * as METADATA_KEY from '../constants/metadata_keys';
|
|
2
|
-
import { id } from '../utils/id';
|
|
3
|
-
import { getSymbolDescription } from '../utils/serialization';
|
|
4
|
-
import { Metadata } from './metadata';
|
|
5
|
-
import { QueryableString } from './queryable_string';
|
|
6
|
-
var Target = (function () {
|
|
7
|
-
function Target(type, identifier, serviceIdentifier, namedOrTagged) {
|
|
8
|
-
this.id = id();
|
|
9
|
-
this.type = type;
|
|
10
|
-
this.serviceIdentifier = serviceIdentifier;
|
|
11
|
-
var queryableName = typeof identifier === 'symbol'
|
|
12
|
-
? getSymbolDescription(identifier)
|
|
13
|
-
: identifier;
|
|
14
|
-
this.name = new QueryableString(queryableName || '');
|
|
15
|
-
this.identifier = identifier;
|
|
16
|
-
this.metadata = new Array();
|
|
17
|
-
var metadataItem = null;
|
|
18
|
-
if (typeof namedOrTagged === 'string') {
|
|
19
|
-
metadataItem = new Metadata(METADATA_KEY.NAMED_TAG, namedOrTagged);
|
|
20
|
-
}
|
|
21
|
-
else if (namedOrTagged instanceof Metadata) {
|
|
22
|
-
metadataItem = namedOrTagged;
|
|
23
|
-
}
|
|
24
|
-
if (metadataItem !== null) {
|
|
25
|
-
this.metadata.push(metadataItem);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
Target.prototype.hasTag = function (key) {
|
|
29
|
-
for (var _i = 0, _a = this.metadata; _i < _a.length; _i++) {
|
|
30
|
-
var m = _a[_i];
|
|
31
|
-
if (m.key === key) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
Target.prototype.isArray = function () {
|
|
38
|
-
return this.hasTag(METADATA_KEY.MULTI_INJECT_TAG);
|
|
39
|
-
};
|
|
40
|
-
Target.prototype.matchesArray = function (name) {
|
|
41
|
-
return this.matchesTag(METADATA_KEY.MULTI_INJECT_TAG)(name);
|
|
42
|
-
};
|
|
43
|
-
Target.prototype.isNamed = function () {
|
|
44
|
-
return this.hasTag(METADATA_KEY.NAMED_TAG);
|
|
45
|
-
};
|
|
46
|
-
Target.prototype.isTagged = function () {
|
|
47
|
-
return this.metadata.some(function (metadata) {
|
|
48
|
-
return METADATA_KEY.NON_CUSTOM_TAG_KEYS.every(function (key) { return metadata.key !== key; });
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
Target.prototype.isOptional = function () {
|
|
52
|
-
return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true);
|
|
53
|
-
};
|
|
54
|
-
Target.prototype.getNamedTag = function () {
|
|
55
|
-
if (this.isNamed()) {
|
|
56
|
-
return this.metadata.filter(function (m) { return m.key === METADATA_KEY.NAMED_TAG; })[0];
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
};
|
|
60
|
-
Target.prototype.getCustomTags = function () {
|
|
61
|
-
if (this.isTagged()) {
|
|
62
|
-
return this.metadata.filter(function (metadata) {
|
|
63
|
-
return METADATA_KEY.NON_CUSTOM_TAG_KEYS.every(function (key) { return metadata.key !== key; });
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
Target.prototype.matchesNamedTag = function (name) {
|
|
71
|
-
return this.matchesTag(METADATA_KEY.NAMED_TAG)(name);
|
|
72
|
-
};
|
|
73
|
-
Target.prototype.matchesTag = function (key) {
|
|
74
|
-
var _this = this;
|
|
75
|
-
return function (value) {
|
|
76
|
-
for (var _i = 0, _a = _this.metadata; _i < _a.length; _i++) {
|
|
77
|
-
var m = _a[_i];
|
|
78
|
-
if (m.key === key && m.value === value) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
return Target;
|
|
86
|
-
}());
|
|
87
|
-
export { Target };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { interfaces } from '../interfaces/interfaces';
|
|
2
|
-
declare function resolveInstance<T>(binding: interfaces.Binding<T>, constr: interfaces.Newable<T>, childRequests: interfaces.Request[], resolveRequest: interfaces.ResolveRequestHandler): T | Promise<T>;
|
|
3
|
-
export { resolveInstance };
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { ON_DEACTIVATION_ERROR, POST_CONSTRUCT_ERROR, PRE_DESTROY_ERROR, } from '../constants/error_msgs';
|
|
58
|
-
import { BindingScopeEnum, TargetTypeEnum } from '../constants/literal_types';
|
|
59
|
-
import * as METADATA_KEY from '../constants/metadata_keys';
|
|
60
|
-
import { isPromise, isPromiseOrContainsPromise } from '../utils/async';
|
|
61
|
-
function _resolveRequests(childRequests, resolveRequest) {
|
|
62
|
-
return childRequests.reduce(function (resolvedRequests, childRequest) {
|
|
63
|
-
var injection = resolveRequest(childRequest);
|
|
64
|
-
var targetType = childRequest.target.type;
|
|
65
|
-
if (targetType === TargetTypeEnum.ConstructorArgument) {
|
|
66
|
-
resolvedRequests.constructorInjections.push(injection);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
resolvedRequests.propertyRequests.push(childRequest);
|
|
70
|
-
resolvedRequests.propertyInjections.push(injection);
|
|
71
|
-
}
|
|
72
|
-
if (!resolvedRequests.isAsync) {
|
|
73
|
-
resolvedRequests.isAsync = isPromiseOrContainsPromise(injection);
|
|
74
|
-
}
|
|
75
|
-
return resolvedRequests;
|
|
76
|
-
}, {
|
|
77
|
-
constructorInjections: [],
|
|
78
|
-
isAsync: false,
|
|
79
|
-
propertyInjections: [],
|
|
80
|
-
propertyRequests: [],
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function _createInstance(constr, childRequests, resolveRequest) {
|
|
84
|
-
var result;
|
|
85
|
-
if (childRequests.length > 0) {
|
|
86
|
-
var resolved = _resolveRequests(childRequests, resolveRequest);
|
|
87
|
-
var createInstanceWithInjectionsArg = __assign(__assign({}, resolved), { constr: constr });
|
|
88
|
-
if (resolved.isAsync) {
|
|
89
|
-
result = createInstanceWithInjectionsAsync(createInstanceWithInjectionsArg);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
result = createInstanceWithInjections(createInstanceWithInjectionsArg);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
result = new constr();
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
function createInstanceWithInjections(args) {
|
|
101
|
-
var _a;
|
|
102
|
-
var instance = new ((_a = args.constr).bind.apply(_a, __spreadArray([void 0], args.constructorInjections, false)))();
|
|
103
|
-
args.propertyRequests.forEach(function (r, index) {
|
|
104
|
-
var property = r.target.identifier;
|
|
105
|
-
var injection = args.propertyInjections[index];
|
|
106
|
-
if (!r.target.isOptional() || injection !== undefined) {
|
|
107
|
-
instance[property] = injection;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
return instance;
|
|
111
|
-
}
|
|
112
|
-
function createInstanceWithInjectionsAsync(args) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var constructorInjections, propertyInjections;
|
|
115
|
-
return __generator(this, function (_a) {
|
|
116
|
-
switch (_a.label) {
|
|
117
|
-
case 0: return [4, possiblyWaitInjections(args.constructorInjections)];
|
|
118
|
-
case 1:
|
|
119
|
-
constructorInjections = _a.sent();
|
|
120
|
-
return [4, possiblyWaitInjections(args.propertyInjections)];
|
|
121
|
-
case 2:
|
|
122
|
-
propertyInjections = _a.sent();
|
|
123
|
-
return [2, createInstanceWithInjections(__assign(__assign({}, args), { constructorInjections: constructorInjections, propertyInjections: propertyInjections }))];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
function possiblyWaitInjections(possiblePromiseinjections) {
|
|
129
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
-
var injections, _i, possiblePromiseinjections_1, injection;
|
|
131
|
-
return __generator(this, function (_a) {
|
|
132
|
-
injections = [];
|
|
133
|
-
for (_i = 0, possiblePromiseinjections_1 = possiblePromiseinjections; _i < possiblePromiseinjections_1.length; _i++) {
|
|
134
|
-
injection = possiblePromiseinjections_1[_i];
|
|
135
|
-
if (Array.isArray(injection)) {
|
|
136
|
-
injections.push(Promise.all(injection));
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
injections.push(injection);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return [2, Promise.all(injections)];
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
function _getInstanceAfterPostConstruct(constr, result) {
|
|
147
|
-
var postConstructResult = _postConstruct(constr, result);
|
|
148
|
-
if (isPromise(postConstructResult)) {
|
|
149
|
-
return postConstructResult.then(function () { return result; });
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
return result;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function _postConstruct(constr, instance) {
|
|
156
|
-
var _a, _b;
|
|
157
|
-
if (Reflect.hasMetadata(METADATA_KEY.POST_CONSTRUCT, constr)) {
|
|
158
|
-
var data = Reflect.getMetadata(METADATA_KEY.POST_CONSTRUCT, constr);
|
|
159
|
-
try {
|
|
160
|
-
return (_b = (_a = instance)[data.value]) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
161
|
-
}
|
|
162
|
-
catch (e) {
|
|
163
|
-
if (e instanceof Error) {
|
|
164
|
-
throw new Error(POST_CONSTRUCT_ERROR(constr.name, e.message));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function _validateInstanceResolution(binding, constr) {
|
|
170
|
-
if (binding.scope !== BindingScopeEnum.Singleton) {
|
|
171
|
-
_throwIfHandlingDeactivation(binding, constr);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function _throwIfHandlingDeactivation(binding, constr) {
|
|
175
|
-
var scopeErrorMessage = "Class cannot be instantiated in ".concat(binding.scope === BindingScopeEnum.Request ? 'request' : 'transient', " scope.");
|
|
176
|
-
if (typeof binding.onDeactivation === 'function') {
|
|
177
|
-
throw new Error(ON_DEACTIVATION_ERROR(constr.name, scopeErrorMessage));
|
|
178
|
-
}
|
|
179
|
-
if (Reflect.hasMetadata(METADATA_KEY.PRE_DESTROY, constr)) {
|
|
180
|
-
throw new Error(PRE_DESTROY_ERROR(constr.name, scopeErrorMessage));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function resolveInstance(binding, constr, childRequests, resolveRequest) {
|
|
184
|
-
_validateInstanceResolution(binding, constr);
|
|
185
|
-
var result = _createInstance(constr, childRequests, resolveRequest);
|
|
186
|
-
if (isPromise(result)) {
|
|
187
|
-
return result.then(function (resolvedResult) {
|
|
188
|
-
return _getInstanceAfterPostConstruct(constr, resolvedResult);
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
return _getInstanceAfterPostConstruct(constr, result);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export { resolveInstance };
|