mirror of
https://gitee.com/bimuziyan/ccc-obfuscated-code.git
synced 2026-06-05 11:11:48 +08:00
update
This commit is contained in:
58
node_modules/inversify/lib/annotation/decorator_utils.js
generated
vendored
Normal file
58
node_modules/inversify/lib/annotation/decorator_utils.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
function tagParameter(annotationTarget, propertyName, parameterIndex, metadata) {
|
||||
var metadataKey = METADATA_KEY.TAGGED;
|
||||
_tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex);
|
||||
}
|
||||
exports.tagParameter = tagParameter;
|
||||
function tagProperty(annotationTarget, propertyName, metadata) {
|
||||
var metadataKey = METADATA_KEY.TAGGED_PROP;
|
||||
_tagParameterOrProperty(metadataKey, annotationTarget.constructor, propertyName, metadata);
|
||||
}
|
||||
exports.tagProperty = tagProperty;
|
||||
function _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex) {
|
||||
var paramsOrPropertiesMetadata = {};
|
||||
var isParameterDecorator = (typeof parameterIndex === "number");
|
||||
var key = (parameterIndex !== undefined && isParameterDecorator) ? parameterIndex.toString() : propertyName;
|
||||
if (isParameterDecorator && propertyName !== undefined) {
|
||||
throw new Error(ERROR_MSGS.INVALID_DECORATOR_OPERATION);
|
||||
}
|
||||
if (Reflect.hasOwnMetadata(metadataKey, annotationTarget)) {
|
||||
paramsOrPropertiesMetadata = Reflect.getMetadata(metadataKey, annotationTarget);
|
||||
}
|
||||
var paramOrPropertyMetadata = paramsOrPropertiesMetadata[key];
|
||||
if (!Array.isArray(paramOrPropertyMetadata)) {
|
||||
paramOrPropertyMetadata = [];
|
||||
}
|
||||
else {
|
||||
for (var _i = 0, paramOrPropertyMetadata_1 = paramOrPropertyMetadata; _i < paramOrPropertyMetadata_1.length; _i++) {
|
||||
var m = paramOrPropertyMetadata_1[_i];
|
||||
if (m.key === metadata.key) {
|
||||
throw new Error(ERROR_MSGS.DUPLICATED_METADATA + " " + m.key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
paramOrPropertyMetadata.push(metadata);
|
||||
paramsOrPropertiesMetadata[key] = paramOrPropertyMetadata;
|
||||
Reflect.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget);
|
||||
}
|
||||
function _decorate(decorators, target) {
|
||||
Reflect.decorate(decorators, target);
|
||||
}
|
||||
function _param(paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); };
|
||||
}
|
||||
function decorate(decorator, target, parameterIndex) {
|
||||
if (typeof parameterIndex === "number") {
|
||||
_decorate([_param(parameterIndex, decorator)], target);
|
||||
}
|
||||
else if (typeof parameterIndex === "string") {
|
||||
Reflect.decorate([decorator], target, parameterIndex);
|
||||
}
|
||||
else {
|
||||
_decorate([decorator], target);
|
||||
}
|
||||
}
|
||||
exports.decorate = decorate;
|
||||
31
node_modules/inversify/lib/annotation/inject.js
generated
vendored
Normal file
31
node_modules/inversify/lib/annotation/inject.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var error_msgs_1 = require("../constants/error_msgs");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var decorator_utils_1 = require("./decorator_utils");
|
||||
var LazyServiceIdentifer = (function () {
|
||||
function LazyServiceIdentifer(cb) {
|
||||
this._cb = cb;
|
||||
}
|
||||
LazyServiceIdentifer.prototype.unwrap = function () {
|
||||
return this._cb();
|
||||
};
|
||||
return LazyServiceIdentifer;
|
||||
}());
|
||||
exports.LazyServiceIdentifer = LazyServiceIdentifer;
|
||||
function inject(serviceIdentifier) {
|
||||
return function (target, targetKey, index) {
|
||||
if (serviceIdentifier === undefined) {
|
||||
throw new Error(error_msgs_1.UNDEFINED_INJECT_ANNOTATION(target.name));
|
||||
}
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.INJECT_TAG, serviceIdentifier);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.inject = inject;
|
||||
15
node_modules/inversify/lib/annotation/injectable.js
generated
vendored
Normal file
15
node_modules/inversify/lib/annotation/injectable.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERRORS_MSGS = require("../constants/error_msgs");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
function injectable() {
|
||||
return function (target) {
|
||||
if (Reflect.hasOwnMetadata(METADATA_KEY.PARAM_TYPES, target)) {
|
||||
throw new Error(ERRORS_MSGS.DUPLICATED_INJECTABLE_DECORATOR);
|
||||
}
|
||||
var types = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, target) || [];
|
||||
Reflect.defineMetadata(METADATA_KEY.PARAM_TYPES, types, target);
|
||||
return target;
|
||||
};
|
||||
}
|
||||
exports.injectable = injectable;
|
||||
17
node_modules/inversify/lib/annotation/multi_inject.js
generated
vendored
Normal file
17
node_modules/inversify/lib/annotation/multi_inject.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var decorator_utils_1 = require("./decorator_utils");
|
||||
function multiInject(serviceIdentifier) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.MULTI_INJECT_TAG, serviceIdentifier);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.multiInject = multiInject;
|
||||
17
node_modules/inversify/lib/annotation/named.js
generated
vendored
Normal file
17
node_modules/inversify/lib/annotation/named.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var decorator_utils_1 = require("./decorator_utils");
|
||||
function named(name) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, name);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.named = named;
|
||||
17
node_modules/inversify/lib/annotation/optional.js
generated
vendored
Normal file
17
node_modules/inversify/lib/annotation/optional.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var decorator_utils_1 = require("./decorator_utils");
|
||||
function optional() {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.OPTIONAL_TAG, true);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.optional = optional;
|
||||
15
node_modules/inversify/lib/annotation/post_construct.js
generated
vendored
Normal file
15
node_modules/inversify/lib/annotation/post_construct.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERRORS_MSGS = require("../constants/error_msgs");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
function postConstruct() {
|
||||
return function (target, propertyKey, descriptor) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.POST_CONSTRUCT, propertyKey);
|
||||
if (Reflect.hasOwnMetadata(METADATA_KEY.POST_CONSTRUCT, target.constructor)) {
|
||||
throw new Error(ERRORS_MSGS.MULTIPLE_POST_CONSTRUCT_METHODS);
|
||||
}
|
||||
Reflect.defineMetadata(METADATA_KEY.POST_CONSTRUCT, metadata, target.constructor);
|
||||
};
|
||||
}
|
||||
exports.postConstruct = postConstruct;
|
||||
16
node_modules/inversify/lib/annotation/tagged.js
generated
vendored
Normal file
16
node_modules/inversify/lib/annotation/tagged.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var decorator_utils_1 = require("./decorator_utils");
|
||||
function tagged(metadataKey, metadataValue) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(metadataKey, metadataValue);
|
||||
if (typeof index === "number") {
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
}
|
||||
else {
|
||||
decorator_utils_1.tagProperty(target, targetKey, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.tagged = tagged;
|
||||
12
node_modules/inversify/lib/annotation/target_name.js
generated
vendored
Normal file
12
node_modules/inversify/lib/annotation/target_name.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var decorator_utils_1 = require("./decorator_utils");
|
||||
function targetName(name) {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.NAME_TAG, name);
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
};
|
||||
}
|
||||
exports.targetName = targetName;
|
||||
12
node_modules/inversify/lib/annotation/unmanaged.js
generated
vendored
Normal file
12
node_modules/inversify/lib/annotation/unmanaged.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var decorator_utils_1 = require("./decorator_utils");
|
||||
function unmanaged() {
|
||||
return function (target, targetKey, index) {
|
||||
var metadata = new metadata_1.Metadata(METADATA_KEY.UNMANAGED_TAG, true);
|
||||
decorator_utils_1.tagParameter(target, targetKey, index, metadata);
|
||||
};
|
||||
}
|
||||
exports.unmanaged = unmanaged;
|
||||
36
node_modules/inversify/lib/bindings/binding.js
generated
vendored
Normal file
36
node_modules/inversify/lib/bindings/binding.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var id_1 = require("../utils/id");
|
||||
var Binding = (function () {
|
||||
function Binding(serviceIdentifier, scope) {
|
||||
this.id = id_1.id();
|
||||
this.activated = false;
|
||||
this.serviceIdentifier = serviceIdentifier;
|
||||
this.scope = scope;
|
||||
this.type = literal_types_1.BindingTypeEnum.Invalid;
|
||||
this.constraint = function (request) { return true; };
|
||||
this.implementationType = null;
|
||||
this.cache = null;
|
||||
this.factory = null;
|
||||
this.provider = null;
|
||||
this.onActivation = null;
|
||||
this.dynamicValue = null;
|
||||
}
|
||||
Binding.prototype.clone = function () {
|
||||
var clone = new Binding(this.serviceIdentifier, this.scope);
|
||||
clone.activated = false;
|
||||
clone.implementationType = this.implementationType;
|
||||
clone.dynamicValue = this.dynamicValue;
|
||||
clone.scope = this.scope;
|
||||
clone.type = this.type;
|
||||
clone.factory = this.factory;
|
||||
clone.provider = this.provider;
|
||||
clone.constraint = this.constraint;
|
||||
clone.onActivation = this.onActivation;
|
||||
clone.cache = this.cache;
|
||||
return clone;
|
||||
};
|
||||
return Binding;
|
||||
}());
|
||||
exports.Binding = Binding;
|
||||
8
node_modules/inversify/lib/bindings/binding_count.js
generated
vendored
Normal file
8
node_modules/inversify/lib/bindings/binding_count.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var BindingCount = {
|
||||
MultipleBindingsAvailable: 2,
|
||||
NoBindingsAvailable: 0,
|
||||
OnlyOneBindingAvailable: 1
|
||||
};
|
||||
exports.BindingCount = BindingCount;
|
||||
60
node_modules/inversify/lib/constants/error_msgs.js
generated
vendored
Normal file
60
node_modules/inversify/lib/constants/error_msgs.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DUPLICATED_INJECTABLE_DECORATOR = "Cannot apply @injectable decorator multiple times.";
|
||||
exports.DUPLICATED_METADATA = "Metadata key was used more than once in a parameter:";
|
||||
exports.NULL_ARGUMENT = "NULL argument";
|
||||
exports.KEY_NOT_FOUND = "Key Not Found";
|
||||
exports.AMBIGUOUS_MATCH = "Ambiguous match found for serviceIdentifier:";
|
||||
exports.CANNOT_UNBIND = "Could not unbind serviceIdentifier:";
|
||||
exports.NOT_REGISTERED = "No matching bindings found for serviceIdentifier:";
|
||||
exports.MISSING_INJECTABLE_ANNOTATION = "Missing required @injectable annotation in:";
|
||||
exports.MISSING_INJECT_ANNOTATION = "Missing required @inject or @multiInject annotation in:";
|
||||
exports.UNDEFINED_INJECT_ANNOTATION = function (name) {
|
||||
return "@inject called with undefined this could mean that the class " + name + " has " +
|
||||
"a circular dependency problem. You can use a LazyServiceIdentifer to " +
|
||||
"overcome this limitation.";
|
||||
};
|
||||
exports.CIRCULAR_DEPENDENCY = "Circular dependency found:";
|
||||
exports.NOT_IMPLEMENTED = "Sorry, this feature is not fully implemented yet.";
|
||||
exports.INVALID_BINDING_TYPE = "Invalid binding type:";
|
||||
exports.NO_MORE_SNAPSHOTS_AVAILABLE = "No snapshot available to restore.";
|
||||
exports.INVALID_MIDDLEWARE_RETURN = "Invalid return type in middleware. Middleware must return!";
|
||||
exports.INVALID_FUNCTION_BINDING = "Value provided to function binding must be a function!";
|
||||
exports.INVALID_TO_SELF_VALUE = "The toSelf function can only be applied when a constructor is " +
|
||||
"used as service identifier";
|
||||
exports.INVALID_DECORATOR_OPERATION = "The @inject @multiInject @tagged and @named decorators " +
|
||||
"must be applied to the parameters of a class constructor or a class property.";
|
||||
exports.ARGUMENTS_LENGTH_MISMATCH = function () {
|
||||
var values = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
values[_i] = arguments[_i];
|
||||
}
|
||||
return "The number of constructor arguments in the derived class " +
|
||||
(values[0] + " must be >= than the number of constructor arguments of its base class.");
|
||||
};
|
||||
exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = "Invalid Container constructor argument. Container options " +
|
||||
"must be an object.";
|
||||
exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = "Invalid Container option. Default scope must " +
|
||||
"be a string ('singleton' or 'transient').";
|
||||
exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = "Invalid Container option. Auto bind injectable must " +
|
||||
"be a boolean";
|
||||
exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = "Invalid Container option. Skip base check must " +
|
||||
"be a boolean";
|
||||
exports.MULTIPLE_POST_CONSTRUCT_METHODS = "Cannot apply @postConstruct decorator multiple times in the same class";
|
||||
exports.POST_CONSTRUCT_ERROR = function () {
|
||||
var values = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
values[_i] = arguments[_i];
|
||||
}
|
||||
return "@postConstruct error in class " + values[0] + ": " + values[1];
|
||||
};
|
||||
exports.CIRCULAR_DEPENDENCY_IN_FACTORY = function () {
|
||||
var values = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
values[_i] = arguments[_i];
|
||||
}
|
||||
return "It looks like there is a circular dependency " +
|
||||
("in one of the '" + values[0] + "' bindings. Please investigate bindings with") +
|
||||
("service identifier '" + values[1] + "'.");
|
||||
};
|
||||
exports.STACK_OVERFLOW = "Maximum call stack size exceeded";
|
||||
25
node_modules/inversify/lib/constants/literal_types.js
generated
vendored
Normal file
25
node_modules/inversify/lib/constants/literal_types.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var BindingScopeEnum = {
|
||||
Request: "Request",
|
||||
Singleton: "Singleton",
|
||||
Transient: "Transient"
|
||||
};
|
||||
exports.BindingScopeEnum = BindingScopeEnum;
|
||||
var BindingTypeEnum = {
|
||||
ConstantValue: "ConstantValue",
|
||||
Constructor: "Constructor",
|
||||
DynamicValue: "DynamicValue",
|
||||
Factory: "Factory",
|
||||
Function: "Function",
|
||||
Instance: "Instance",
|
||||
Invalid: "Invalid",
|
||||
Provider: "Provider"
|
||||
};
|
||||
exports.BindingTypeEnum = BindingTypeEnum;
|
||||
var TargetTypeEnum = {
|
||||
ClassProperty: "ClassProperty",
|
||||
ConstructorArgument: "ConstructorArgument",
|
||||
Variable: "Variable"
|
||||
};
|
||||
exports.TargetTypeEnum = TargetTypeEnum;
|
||||
13
node_modules/inversify/lib/constants/metadata_keys.js
generated
vendored
Normal file
13
node_modules/inversify/lib/constants/metadata_keys.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NAMED_TAG = "named";
|
||||
exports.NAME_TAG = "name";
|
||||
exports.UNMANAGED_TAG = "unmanaged";
|
||||
exports.OPTIONAL_TAG = "optional";
|
||||
exports.INJECT_TAG = "inject";
|
||||
exports.MULTI_INJECT_TAG = "multi_inject";
|
||||
exports.TAGGED = "inversify:tagged";
|
||||
exports.TAGGED_PROP = "inversify:tagged_props";
|
||||
exports.PARAM_TYPES = "inversify:paramtypes";
|
||||
exports.DESIGN_PARAM_TYPES = "design:paramtypes";
|
||||
exports.POST_CONSTRUCT = "post_construct";
|
||||
325
node_modules/inversify/lib/container/container.js
generated
vendored
Normal file
325
node_modules/inversify/lib/container/container.js
generated
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var binding_1 = require("../bindings/binding");
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_reader_1 = require("../planning/metadata_reader");
|
||||
var planner_1 = require("../planning/planner");
|
||||
var resolver_1 = require("../resolution/resolver");
|
||||
var binding_to_syntax_1 = require("../syntax/binding_to_syntax");
|
||||
var id_1 = require("../utils/id");
|
||||
var serialization_1 = require("../utils/serialization");
|
||||
var container_snapshot_1 = require("./container_snapshot");
|
||||
var lookup_1 = require("./lookup");
|
||||
var Container = (function () {
|
||||
function Container(containerOptions) {
|
||||
var options = containerOptions || {};
|
||||
if (typeof options !== "object") {
|
||||
throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);
|
||||
}
|
||||
if (options.defaultScope === undefined) {
|
||||
options.defaultScope = literal_types_1.BindingScopeEnum.Transient;
|
||||
}
|
||||
else if (options.defaultScope !== literal_types_1.BindingScopeEnum.Singleton &&
|
||||
options.defaultScope !== literal_types_1.BindingScopeEnum.Transient &&
|
||||
options.defaultScope !== literal_types_1.BindingScopeEnum.Request) {
|
||||
throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);
|
||||
}
|
||||
if (options.autoBindInjectable === undefined) {
|
||||
options.autoBindInjectable = false;
|
||||
}
|
||||
else if (typeof options.autoBindInjectable !== "boolean") {
|
||||
throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);
|
||||
}
|
||||
if (options.skipBaseClassChecks === undefined) {
|
||||
options.skipBaseClassChecks = false;
|
||||
}
|
||||
else if (typeof options.skipBaseClassChecks !== "boolean") {
|
||||
throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK);
|
||||
}
|
||||
this.options = {
|
||||
autoBindInjectable: options.autoBindInjectable,
|
||||
defaultScope: options.defaultScope,
|
||||
skipBaseClassChecks: options.skipBaseClassChecks
|
||||
};
|
||||
this.id = id_1.id();
|
||||
this._bindingDictionary = new lookup_1.Lookup();
|
||||
this._snapshots = [];
|
||||
this._middleware = null;
|
||||
this.parent = null;
|
||||
this._metadataReader = new metadata_reader_1.MetadataReader();
|
||||
}
|
||||
Container.merge = function (container1, container2) {
|
||||
var container = new Container();
|
||||
var bindingDictionary = planner_1.getBindingDictionary(container);
|
||||
var bindingDictionary1 = planner_1.getBindingDictionary(container1);
|
||||
var bindingDictionary2 = planner_1.getBindingDictionary(container2);
|
||||
function copyDictionary(origin, destination) {
|
||||
origin.traverse(function (key, value) {
|
||||
value.forEach(function (binding) {
|
||||
destination.add(binding.serviceIdentifier, binding.clone());
|
||||
});
|
||||
});
|
||||
}
|
||||
copyDictionary(bindingDictionary1, bindingDictionary);
|
||||
copyDictionary(bindingDictionary2, bindingDictionary);
|
||||
return container;
|
||||
};
|
||||
Container.prototype.load = function () {
|
||||
var modules = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
modules[_i] = arguments[_i];
|
||||
}
|
||||
var getHelpers = this._getContainerModuleHelpersFactory();
|
||||
for (var _a = 0, modules_1 = modules; _a < modules_1.length; _a++) {
|
||||
var currentModule = modules_1[_a];
|
||||
var containerModuleHelpers = getHelpers(currentModule.id);
|
||||
currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction);
|
||||
}
|
||||
};
|
||||
Container.prototype.loadAsync = function () {
|
||||
var modules = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
modules[_i] = arguments[_i];
|
||||
}
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var getHelpers, _a, modules_2, currentModule, containerModuleHelpers;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
getHelpers = this._getContainerModuleHelpersFactory();
|
||||
_a = 0, modules_2 = modules;
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
if (!(_a < modules_2.length)) return [3, 4];
|
||||
currentModule = modules_2[_a];
|
||||
containerModuleHelpers = getHelpers(currentModule.id);
|
||||
return [4, currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction)];
|
||||
case 2:
|
||||
_b.sent();
|
||||
_b.label = 3;
|
||||
case 3:
|
||||
_a++;
|
||||
return [3, 1];
|
||||
case 4: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Container.prototype.unload = function () {
|
||||
var _this = this;
|
||||
var modules = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
modules[_i] = arguments[_i];
|
||||
}
|
||||
var conditionFactory = function (expected) { return function (item) {
|
||||
return item.moduleId === expected;
|
||||
}; };
|
||||
modules.forEach(function (module) {
|
||||
var condition = conditionFactory(module.id);
|
||||
_this._bindingDictionary.removeByCondition(condition);
|
||||
});
|
||||
};
|
||||
Container.prototype.bind = function (serviceIdentifier) {
|
||||
var scope = this.options.defaultScope || literal_types_1.BindingScopeEnum.Transient;
|
||||
var binding = new binding_1.Binding(serviceIdentifier, scope);
|
||||
this._bindingDictionary.add(serviceIdentifier, binding);
|
||||
return new binding_to_syntax_1.BindingToSyntax(binding);
|
||||
};
|
||||
Container.prototype.rebind = function (serviceIdentifier) {
|
||||
this.unbind(serviceIdentifier);
|
||||
return this.bind(serviceIdentifier);
|
||||
};
|
||||
Container.prototype.unbind = function (serviceIdentifier) {
|
||||
try {
|
||||
this._bindingDictionary.remove(serviceIdentifier);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(ERROR_MSGS.CANNOT_UNBIND + " " + serialization_1.getServiceIdentifierAsString(serviceIdentifier));
|
||||
}
|
||||
};
|
||||
Container.prototype.unbindAll = function () {
|
||||
this._bindingDictionary = new lookup_1.Lookup();
|
||||
};
|
||||
Container.prototype.isBound = function (serviceIdentifier) {
|
||||
var bound = this._bindingDictionary.hasKey(serviceIdentifier);
|
||||
if (!bound && this.parent) {
|
||||
bound = this.parent.isBound(serviceIdentifier);
|
||||
}
|
||||
return bound;
|
||||
};
|
||||
Container.prototype.isBoundNamed = function (serviceIdentifier, named) {
|
||||
return this.isBoundTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named);
|
||||
};
|
||||
Container.prototype.isBoundTagged = function (serviceIdentifier, key, value) {
|
||||
var bound = false;
|
||||
if (this._bindingDictionary.hasKey(serviceIdentifier)) {
|
||||
var bindings = this._bindingDictionary.get(serviceIdentifier);
|
||||
var request_1 = planner_1.createMockRequest(this, serviceIdentifier, key, value);
|
||||
bound = bindings.some(function (b) { return b.constraint(request_1); });
|
||||
}
|
||||
if (!bound && this.parent) {
|
||||
bound = this.parent.isBoundTagged(serviceIdentifier, key, value);
|
||||
}
|
||||
return bound;
|
||||
};
|
||||
Container.prototype.snapshot = function () {
|
||||
this._snapshots.push(container_snapshot_1.ContainerSnapshot.of(this._bindingDictionary.clone(), this._middleware));
|
||||
};
|
||||
Container.prototype.restore = function () {
|
||||
var snapshot = this._snapshots.pop();
|
||||
if (snapshot === undefined) {
|
||||
throw new Error(ERROR_MSGS.NO_MORE_SNAPSHOTS_AVAILABLE);
|
||||
}
|
||||
this._bindingDictionary = snapshot.bindings;
|
||||
this._middleware = snapshot.middleware;
|
||||
};
|
||||
Container.prototype.createChild = function (containerOptions) {
|
||||
var child = new Container(containerOptions || this.options);
|
||||
child.parent = this;
|
||||
return child;
|
||||
};
|
||||
Container.prototype.applyMiddleware = function () {
|
||||
var middlewares = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
middlewares[_i] = arguments[_i];
|
||||
}
|
||||
var initial = (this._middleware) ? this._middleware : this._planAndResolve();
|
||||
this._middleware = middlewares.reduce(function (prev, curr) { return curr(prev); }, initial);
|
||||
};
|
||||
Container.prototype.applyCustomMetadataReader = function (metadataReader) {
|
||||
this._metadataReader = metadataReader;
|
||||
};
|
||||
Container.prototype.get = function (serviceIdentifier) {
|
||||
return this._get(false, false, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier);
|
||||
};
|
||||
Container.prototype.getTagged = function (serviceIdentifier, key, value) {
|
||||
return this._get(false, false, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier, key, value);
|
||||
};
|
||||
Container.prototype.getNamed = function (serviceIdentifier, named) {
|
||||
return this.getTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named);
|
||||
};
|
||||
Container.prototype.getAll = function (serviceIdentifier) {
|
||||
return this._get(true, true, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier);
|
||||
};
|
||||
Container.prototype.getAllTagged = function (serviceIdentifier, key, value) {
|
||||
return this._get(false, true, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier, key, value);
|
||||
};
|
||||
Container.prototype.getAllNamed = function (serviceIdentifier, named) {
|
||||
return this.getAllTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named);
|
||||
};
|
||||
Container.prototype.resolve = function (constructorFunction) {
|
||||
var tempContainer = this.createChild();
|
||||
tempContainer.bind(constructorFunction).toSelf();
|
||||
return tempContainer.get(constructorFunction);
|
||||
};
|
||||
Container.prototype._getContainerModuleHelpersFactory = function () {
|
||||
var _this = this;
|
||||
var setModuleId = function (bindingToSyntax, moduleId) {
|
||||
bindingToSyntax._binding.moduleId = moduleId;
|
||||
};
|
||||
var getBindFunction = function (moduleId) {
|
||||
return function (serviceIdentifier) {
|
||||
var _bind = _this.bind.bind(_this);
|
||||
var bindingToSyntax = _bind(serviceIdentifier);
|
||||
setModuleId(bindingToSyntax, moduleId);
|
||||
return bindingToSyntax;
|
||||
};
|
||||
};
|
||||
var getUnbindFunction = function (moduleId) {
|
||||
return function (serviceIdentifier) {
|
||||
var _unbind = _this.unbind.bind(_this);
|
||||
_unbind(serviceIdentifier);
|
||||
};
|
||||
};
|
||||
var getIsboundFunction = function (moduleId) {
|
||||
return function (serviceIdentifier) {
|
||||
var _isBound = _this.isBound.bind(_this);
|
||||
return _isBound(serviceIdentifier);
|
||||
};
|
||||
};
|
||||
var getRebindFunction = function (moduleId) {
|
||||
return function (serviceIdentifier) {
|
||||
var _rebind = _this.rebind.bind(_this);
|
||||
var bindingToSyntax = _rebind(serviceIdentifier);
|
||||
setModuleId(bindingToSyntax, moduleId);
|
||||
return bindingToSyntax;
|
||||
};
|
||||
};
|
||||
return function (mId) { return ({
|
||||
bindFunction: getBindFunction(mId),
|
||||
isboundFunction: getIsboundFunction(mId),
|
||||
rebindFunction: getRebindFunction(mId),
|
||||
unbindFunction: getUnbindFunction(mId)
|
||||
}); };
|
||||
};
|
||||
Container.prototype._get = function (avoidConstraints, isMultiInject, targetType, serviceIdentifier, key, value) {
|
||||
var result = null;
|
||||
var defaultArgs = {
|
||||
avoidConstraints: avoidConstraints,
|
||||
contextInterceptor: function (context) { return context; },
|
||||
isMultiInject: isMultiInject,
|
||||
key: key,
|
||||
serviceIdentifier: serviceIdentifier,
|
||||
targetType: targetType,
|
||||
value: value
|
||||
};
|
||||
if (this._middleware) {
|
||||
result = this._middleware(defaultArgs);
|
||||
if (result === undefined || result === null) {
|
||||
throw new Error(ERROR_MSGS.INVALID_MIDDLEWARE_RETURN);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = this._planAndResolve()(defaultArgs);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
Container.prototype._planAndResolve = function () {
|
||||
var _this = this;
|
||||
return function (args) {
|
||||
var context = planner_1.plan(_this._metadataReader, _this, args.isMultiInject, args.targetType, args.serviceIdentifier, args.key, args.value, args.avoidConstraints);
|
||||
context = args.contextInterceptor(context);
|
||||
var result = resolver_1.resolve(context);
|
||||
return result;
|
||||
};
|
||||
};
|
||||
return Container;
|
||||
}());
|
||||
exports.Container = Container;
|
||||
19
node_modules/inversify/lib/container/container_module.js
generated
vendored
Normal file
19
node_modules/inversify/lib/container/container_module.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var id_1 = require("../utils/id");
|
||||
var ContainerModule = (function () {
|
||||
function ContainerModule(registry) {
|
||||
this.id = id_1.id();
|
||||
this.registry = registry;
|
||||
}
|
||||
return ContainerModule;
|
||||
}());
|
||||
exports.ContainerModule = ContainerModule;
|
||||
var AsyncContainerModule = (function () {
|
||||
function AsyncContainerModule(registry) {
|
||||
this.id = id_1.id();
|
||||
this.registry = registry;
|
||||
}
|
||||
return AsyncContainerModule;
|
||||
}());
|
||||
exports.AsyncContainerModule = AsyncContainerModule;
|
||||
14
node_modules/inversify/lib/container/container_snapshot.js
generated
vendored
Normal file
14
node_modules/inversify/lib/container/container_snapshot.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ContainerSnapshot = (function () {
|
||||
function ContainerSnapshot() {
|
||||
}
|
||||
ContainerSnapshot.of = function (bindings, middleware) {
|
||||
var snapshot = new ContainerSnapshot();
|
||||
snapshot.bindings = bindings;
|
||||
snapshot.middleware = middleware;
|
||||
return snapshot;
|
||||
};
|
||||
return ContainerSnapshot;
|
||||
}());
|
||||
exports.ContainerSnapshot = ContainerSnapshot;
|
||||
79
node_modules/inversify/lib/container/lookup.js
generated
vendored
Normal file
79
node_modules/inversify/lib/container/lookup.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
var Lookup = (function () {
|
||||
function Lookup() {
|
||||
this._map = new Map();
|
||||
}
|
||||
Lookup.prototype.getMap = function () {
|
||||
return this._map;
|
||||
};
|
||||
Lookup.prototype.add = function (serviceIdentifier, value) {
|
||||
if (serviceIdentifier === null || serviceIdentifier === undefined) {
|
||||
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
||||
}
|
||||
if (value === null || value === undefined) {
|
||||
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
||||
}
|
||||
var entry = this._map.get(serviceIdentifier);
|
||||
if (entry !== undefined) {
|
||||
entry.push(value);
|
||||
this._map.set(serviceIdentifier, entry);
|
||||
}
|
||||
else {
|
||||
this._map.set(serviceIdentifier, [value]);
|
||||
}
|
||||
};
|
||||
Lookup.prototype.get = function (serviceIdentifier) {
|
||||
if (serviceIdentifier === null || serviceIdentifier === undefined) {
|
||||
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
||||
}
|
||||
var entry = this._map.get(serviceIdentifier);
|
||||
if (entry !== undefined) {
|
||||
return entry;
|
||||
}
|
||||
else {
|
||||
throw new Error(ERROR_MSGS.KEY_NOT_FOUND);
|
||||
}
|
||||
};
|
||||
Lookup.prototype.remove = function (serviceIdentifier) {
|
||||
if (serviceIdentifier === null || serviceIdentifier === undefined) {
|
||||
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
||||
}
|
||||
if (!this._map.delete(serviceIdentifier)) {
|
||||
throw new Error(ERROR_MSGS.KEY_NOT_FOUND);
|
||||
}
|
||||
};
|
||||
Lookup.prototype.removeByCondition = function (condition) {
|
||||
var _this = this;
|
||||
this._map.forEach(function (entries, key) {
|
||||
var updatedEntries = entries.filter(function (entry) { return !condition(entry); });
|
||||
if (updatedEntries.length > 0) {
|
||||
_this._map.set(key, updatedEntries);
|
||||
}
|
||||
else {
|
||||
_this._map.delete(key);
|
||||
}
|
||||
});
|
||||
};
|
||||
Lookup.prototype.hasKey = function (serviceIdentifier) {
|
||||
if (serviceIdentifier === null || serviceIdentifier === undefined) {
|
||||
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
||||
}
|
||||
return this._map.has(serviceIdentifier);
|
||||
};
|
||||
Lookup.prototype.clone = function () {
|
||||
var copy = new Lookup();
|
||||
this._map.forEach(function (value, key) {
|
||||
value.forEach(function (b) { return copy.add(key, b.clone()); });
|
||||
});
|
||||
return copy;
|
||||
};
|
||||
Lookup.prototype.traverse = function (func) {
|
||||
this._map.forEach(function (value, key) {
|
||||
func(key, value);
|
||||
});
|
||||
};
|
||||
return Lookup;
|
||||
}());
|
||||
exports.Lookup = Lookup;
|
||||
2
node_modules/inversify/lib/interfaces/interfaces.js
generated
vendored
Normal file
2
node_modules/inversify/lib/interfaces/interfaces.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
47
node_modules/inversify/lib/inversify.js
generated
vendored
Normal file
47
node_modules/inversify/lib/inversify.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var keys = require("./constants/metadata_keys");
|
||||
exports.METADATA_KEY = keys;
|
||||
var container_1 = require("./container/container");
|
||||
exports.Container = container_1.Container;
|
||||
var literal_types_1 = require("./constants/literal_types");
|
||||
exports.BindingScopeEnum = literal_types_1.BindingScopeEnum;
|
||||
exports.BindingTypeEnum = literal_types_1.BindingTypeEnum;
|
||||
exports.TargetTypeEnum = literal_types_1.TargetTypeEnum;
|
||||
var container_module_1 = require("./container/container_module");
|
||||
exports.AsyncContainerModule = container_module_1.AsyncContainerModule;
|
||||
exports.ContainerModule = container_module_1.ContainerModule;
|
||||
var injectable_1 = require("./annotation/injectable");
|
||||
exports.injectable = injectable_1.injectable;
|
||||
var tagged_1 = require("./annotation/tagged");
|
||||
exports.tagged = tagged_1.tagged;
|
||||
var named_1 = require("./annotation/named");
|
||||
exports.named = named_1.named;
|
||||
var inject_1 = require("./annotation/inject");
|
||||
exports.inject = inject_1.inject;
|
||||
exports.LazyServiceIdentifer = inject_1.LazyServiceIdentifer;
|
||||
var optional_1 = require("./annotation/optional");
|
||||
exports.optional = optional_1.optional;
|
||||
var unmanaged_1 = require("./annotation/unmanaged");
|
||||
exports.unmanaged = unmanaged_1.unmanaged;
|
||||
var multi_inject_1 = require("./annotation/multi_inject");
|
||||
exports.multiInject = multi_inject_1.multiInject;
|
||||
var target_name_1 = require("./annotation/target_name");
|
||||
exports.targetName = target_name_1.targetName;
|
||||
var post_construct_1 = require("./annotation/post_construct");
|
||||
exports.postConstruct = post_construct_1.postConstruct;
|
||||
var metadata_reader_1 = require("./planning/metadata_reader");
|
||||
exports.MetadataReader = metadata_reader_1.MetadataReader;
|
||||
var id_1 = require("./utils/id");
|
||||
exports.id = id_1.id;
|
||||
var decorator_utils_1 = require("./annotation/decorator_utils");
|
||||
exports.decorate = decorator_utils_1.decorate;
|
||||
var constraint_helpers_1 = require("./syntax/constraint_helpers");
|
||||
exports.traverseAncerstors = constraint_helpers_1.traverseAncerstors;
|
||||
exports.taggedConstraint = constraint_helpers_1.taggedConstraint;
|
||||
exports.namedConstraint = constraint_helpers_1.namedConstraint;
|
||||
exports.typeConstraint = constraint_helpers_1.typeConstraint;
|
||||
var serialization_1 = require("./utils/serialization");
|
||||
exports.getServiceIdentifierAsString = serialization_1.getServiceIdentifierAsString;
|
||||
var binding_utils_1 = require("./utils/binding_utils");
|
||||
exports.multiBindToService = binding_utils_1.multiBindToService;
|
||||
17
node_modules/inversify/lib/planning/context.js
generated
vendored
Normal file
17
node_modules/inversify/lib/planning/context.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var id_1 = require("../utils/id");
|
||||
var Context = (function () {
|
||||
function Context(container) {
|
||||
this.id = id_1.id();
|
||||
this.container = container;
|
||||
}
|
||||
Context.prototype.addPlan = function (plan) {
|
||||
this.plan = plan;
|
||||
};
|
||||
Context.prototype.setCurrentRequest = function (currentRequest) {
|
||||
this.currentRequest = currentRequest;
|
||||
};
|
||||
return Context;
|
||||
}());
|
||||
exports.Context = Context;
|
||||
19
node_modules/inversify/lib/planning/metadata.js
generated
vendored
Normal file
19
node_modules/inversify/lib/planning/metadata.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var Metadata = (function () {
|
||||
function Metadata(key, value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
Metadata.prototype.toString = function () {
|
||||
if (this.key === METADATA_KEY.NAMED_TAG) {
|
||||
return "named: " + this.value.toString() + " ";
|
||||
}
|
||||
else {
|
||||
return "tagged: { key:" + this.key.toString() + ", value: " + this.value + " }";
|
||||
}
|
||||
};
|
||||
return Metadata;
|
||||
}());
|
||||
exports.Metadata = Metadata;
|
||||
21
node_modules/inversify/lib/planning/metadata_reader.js
generated
vendored
Normal file
21
node_modules/inversify/lib/planning/metadata_reader.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var MetadataReader = (function () {
|
||||
function MetadataReader() {
|
||||
}
|
||||
MetadataReader.prototype.getConstructorMetadata = function (constructorFunc) {
|
||||
var compilerGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.PARAM_TYPES, constructorFunc);
|
||||
var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED, constructorFunc);
|
||||
return {
|
||||
compilerGeneratedMetadata: compilerGeneratedMetadata,
|
||||
userGeneratedMetadata: userGeneratedMetadata || {}
|
||||
};
|
||||
};
|
||||
MetadataReader.prototype.getPropertiesMetadata = function (constructorFunc) {
|
||||
var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, constructorFunc) || [];
|
||||
return userGeneratedMetadata;
|
||||
};
|
||||
return MetadataReader;
|
||||
}());
|
||||
exports.MetadataReader = MetadataReader;
|
||||
10
node_modules/inversify/lib/planning/plan.js
generated
vendored
Normal file
10
node_modules/inversify/lib/planning/plan.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Plan = (function () {
|
||||
function Plan(parentContext, rootRequest) {
|
||||
this.parentContext = parentContext;
|
||||
this.rootRequest = rootRequest;
|
||||
}
|
||||
return Plan;
|
||||
}());
|
||||
exports.Plan = Plan;
|
||||
155
node_modules/inversify/lib/planning/planner.js
generated
vendored
Normal file
155
node_modules/inversify/lib/planning/planner.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var binding_count_1 = require("../bindings/binding_count");
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var exceptions_1 = require("../utils/exceptions");
|
||||
var serialization_1 = require("../utils/serialization");
|
||||
var context_1 = require("./context");
|
||||
var metadata_1 = require("./metadata");
|
||||
var plan_1 = require("./plan");
|
||||
var reflection_utils_1 = require("./reflection_utils");
|
||||
var request_1 = require("./request");
|
||||
var target_1 = require("./target");
|
||||
function getBindingDictionary(cntnr) {
|
||||
return cntnr._bindingDictionary;
|
||||
}
|
||||
exports.getBindingDictionary = getBindingDictionary;
|
||||
function _createTarget(isMultiInject, targetType, serviceIdentifier, name, key, value) {
|
||||
var metadataKey = isMultiInject ? METADATA_KEY.MULTI_INJECT_TAG : METADATA_KEY.INJECT_TAG;
|
||||
var injectMetadata = new metadata_1.Metadata(metadataKey, serviceIdentifier);
|
||||
var target = new target_1.Target(targetType, name, serviceIdentifier, injectMetadata);
|
||||
if (key !== undefined) {
|
||||
var tagMetadata = new metadata_1.Metadata(key, value);
|
||||
target.metadata.push(tagMetadata);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
function _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target) {
|
||||
var bindings = getBindings(context.container, target.serviceIdentifier);
|
||||
var activeBindings = [];
|
||||
if (bindings.length === binding_count_1.BindingCount.NoBindingsAvailable &&
|
||||
context.container.options.autoBindInjectable &&
|
||||
typeof target.serviceIdentifier === "function" &&
|
||||
metadataReader.getConstructorMetadata(target.serviceIdentifier).compilerGeneratedMetadata) {
|
||||
context.container.bind(target.serviceIdentifier).toSelf();
|
||||
bindings = getBindings(context.container, target.serviceIdentifier);
|
||||
}
|
||||
if (!avoidConstraints) {
|
||||
activeBindings = bindings.filter(function (binding) {
|
||||
var request = new request_1.Request(binding.serviceIdentifier, context, parentRequest, binding, target);
|
||||
return binding.constraint(request);
|
||||
});
|
||||
}
|
||||
else {
|
||||
activeBindings = bindings;
|
||||
}
|
||||
_validateActiveBindingCount(target.serviceIdentifier, activeBindings, target, context.container);
|
||||
return activeBindings;
|
||||
}
|
||||
function _validateActiveBindingCount(serviceIdentifier, bindings, target, container) {
|
||||
switch (bindings.length) {
|
||||
case binding_count_1.BindingCount.NoBindingsAvailable:
|
||||
if (target.isOptional()) {
|
||||
return bindings;
|
||||
}
|
||||
else {
|
||||
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier);
|
||||
var msg = ERROR_MSGS.NOT_REGISTERED;
|
||||
msg += serialization_1.listMetadataForTarget(serviceIdentifierString, target);
|
||||
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
|
||||
throw new Error(msg);
|
||||
}
|
||||
case binding_count_1.BindingCount.OnlyOneBindingAvailable:
|
||||
if (!target.isArray()) {
|
||||
return bindings;
|
||||
}
|
||||
case binding_count_1.BindingCount.MultipleBindingsAvailable:
|
||||
default:
|
||||
if (!target.isArray()) {
|
||||
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier);
|
||||
var msg = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString;
|
||||
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
|
||||
throw new Error(msg);
|
||||
}
|
||||
else {
|
||||
return bindings;
|
||||
}
|
||||
}
|
||||
}
|
||||
function _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, parentRequest, target) {
|
||||
var activeBindings;
|
||||
var childRequest;
|
||||
if (parentRequest === null) {
|
||||
activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, null, target);
|
||||
childRequest = new request_1.Request(serviceIdentifier, context, null, activeBindings, target);
|
||||
var thePlan = new plan_1.Plan(context, childRequest);
|
||||
context.addPlan(thePlan);
|
||||
}
|
||||
else {
|
||||
activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target);
|
||||
childRequest = parentRequest.addChildRequest(target.serviceIdentifier, activeBindings, target);
|
||||
}
|
||||
activeBindings.forEach(function (binding) {
|
||||
var subChildRequest = null;
|
||||
if (target.isArray()) {
|
||||
subChildRequest = childRequest.addChildRequest(binding.serviceIdentifier, binding, target);
|
||||
}
|
||||
else {
|
||||
if (binding.cache) {
|
||||
return;
|
||||
}
|
||||
subChildRequest = childRequest;
|
||||
}
|
||||
if (binding.type === literal_types_1.BindingTypeEnum.Instance && binding.implementationType !== null) {
|
||||
var dependencies = reflection_utils_1.getDependencies(metadataReader, binding.implementationType);
|
||||
if (!context.container.options.skipBaseClassChecks) {
|
||||
var baseClassDependencyCount = reflection_utils_1.getBaseClassDependencyCount(metadataReader, binding.implementationType);
|
||||
if (dependencies.length < baseClassDependencyCount) {
|
||||
var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH(reflection_utils_1.getFunctionName(binding.implementationType));
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
dependencies.forEach(function (dependency) {
|
||||
_createSubRequests(metadataReader, false, dependency.serviceIdentifier, context, subChildRequest, dependency);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function getBindings(container, serviceIdentifier) {
|
||||
var bindings = [];
|
||||
var bindingDictionary = getBindingDictionary(container);
|
||||
if (bindingDictionary.hasKey(serviceIdentifier)) {
|
||||
bindings = bindingDictionary.get(serviceIdentifier);
|
||||
}
|
||||
else if (container.parent !== null) {
|
||||
bindings = getBindings(container.parent, serviceIdentifier);
|
||||
}
|
||||
return bindings;
|
||||
}
|
||||
function plan(metadataReader, container, isMultiInject, targetType, serviceIdentifier, key, value, avoidConstraints) {
|
||||
if (avoidConstraints === void 0) { avoidConstraints = false; }
|
||||
var context = new context_1.Context(container);
|
||||
var target = _createTarget(isMultiInject, targetType, serviceIdentifier, "", key, value);
|
||||
try {
|
||||
_createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, null, target);
|
||||
return context;
|
||||
}
|
||||
catch (error) {
|
||||
if (exceptions_1.isStackOverflowExeption(error)) {
|
||||
if (context.plan) {
|
||||
serialization_1.circularDependencyToException(context.plan.rootRequest);
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
exports.plan = plan;
|
||||
function createMockRequest(container, serviceIdentifier, key, value) {
|
||||
var target = new target_1.Target(literal_types_1.TargetTypeEnum.Variable, "", serviceIdentifier, new metadata_1.Metadata(key, value));
|
||||
var context = new context_1.Context(container);
|
||||
var request = new request_1.Request(serviceIdentifier, context, null, [], target);
|
||||
return request;
|
||||
}
|
||||
exports.createMockRequest = createMockRequest;
|
||||
27
node_modules/inversify/lib/planning/queryable_string.js
generated
vendored
Normal file
27
node_modules/inversify/lib/planning/queryable_string.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var QueryableString = (function () {
|
||||
function QueryableString(str) {
|
||||
this.str = str;
|
||||
}
|
||||
QueryableString.prototype.startsWith = function (searchString) {
|
||||
return this.str.indexOf(searchString) === 0;
|
||||
};
|
||||
QueryableString.prototype.endsWith = function (searchString) {
|
||||
var reverseString = "";
|
||||
var reverseSearchString = searchString.split("").reverse().join("");
|
||||
reverseString = this.str.split("").reverse().join("");
|
||||
return this.startsWith.call({ str: reverseString }, reverseSearchString);
|
||||
};
|
||||
QueryableString.prototype.contains = function (searchString) {
|
||||
return (this.str.indexOf(searchString) !== -1);
|
||||
};
|
||||
QueryableString.prototype.equals = function (compareString) {
|
||||
return this.str === compareString;
|
||||
};
|
||||
QueryableString.prototype.value = function () {
|
||||
return this.str;
|
||||
};
|
||||
return QueryableString;
|
||||
}());
|
||||
exports.QueryableString = QueryableString;
|
||||
124
node_modules/inversify/lib/planning/reflection_utils.js
generated
vendored
Normal file
124
node_modules/inversify/lib/planning/reflection_utils.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var inject_1 = require("../annotation/inject");
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var serialization_1 = require("../utils/serialization");
|
||||
exports.getFunctionName = serialization_1.getFunctionName;
|
||||
var target_1 = require("./target");
|
||||
function getDependencies(metadataReader, func) {
|
||||
var constructorName = serialization_1.getFunctionName(func);
|
||||
var targets = getTargets(metadataReader, constructorName, func, false);
|
||||
return targets;
|
||||
}
|
||||
exports.getDependencies = getDependencies;
|
||||
function getTargets(metadataReader, constructorName, func, isBaseClass) {
|
||||
var metadata = metadataReader.getConstructorMetadata(func);
|
||||
var serviceIdentifiers = metadata.compilerGeneratedMetadata;
|
||||
if (serviceIdentifiers === undefined) {
|
||||
var msg = ERROR_MSGS.MISSING_INJECTABLE_ANNOTATION + " " + constructorName + ".";
|
||||
throw new Error(msg);
|
||||
}
|
||||
var constructorArgsMetadata = metadata.userGeneratedMetadata;
|
||||
var keys = Object.keys(constructorArgsMetadata);
|
||||
var hasUserDeclaredUnknownInjections = (func.length === 0 && keys.length > 0);
|
||||
var iterations = (hasUserDeclaredUnknownInjections) ? keys.length : func.length;
|
||||
var constructorTargets = getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations);
|
||||
var propertyTargets = getClassPropsAsTargets(metadataReader, func);
|
||||
var targets = constructorTargets.concat(propertyTargets);
|
||||
return targets;
|
||||
}
|
||||
function getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata) {
|
||||
var targetMetadata = constructorArgsMetadata[index.toString()] || [];
|
||||
var metadata = formatTargetMetadata(targetMetadata);
|
||||
var isManaged = metadata.unmanaged !== true;
|
||||
var serviceIdentifier = serviceIdentifiers[index];
|
||||
var injectIdentifier = (metadata.inject || metadata.multiInject);
|
||||
serviceIdentifier = (injectIdentifier) ? (injectIdentifier) : serviceIdentifier;
|
||||
if (serviceIdentifier instanceof inject_1.LazyServiceIdentifer) {
|
||||
serviceIdentifier = serviceIdentifier.unwrap();
|
||||
}
|
||||
if (isManaged) {
|
||||
var isObject = serviceIdentifier === Object;
|
||||
var isFunction = serviceIdentifier === Function;
|
||||
var isUndefined = serviceIdentifier === undefined;
|
||||
var isUnknownType = (isObject || isFunction || isUndefined);
|
||||
if (!isBaseClass && isUnknownType) {
|
||||
var msg = ERROR_MSGS.MISSING_INJECT_ANNOTATION + " argument " + index + " in class " + constructorName + ".";
|
||||
throw new Error(msg);
|
||||
}
|
||||
var target = new target_1.Target(literal_types_1.TargetTypeEnum.ConstructorArgument, metadata.targetName, serviceIdentifier);
|
||||
target.metadata = targetMetadata;
|
||||
return target;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations) {
|
||||
var targets = [];
|
||||
for (var i = 0; i < iterations; i++) {
|
||||
var index = i;
|
||||
var target = getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata);
|
||||
if (target !== null) {
|
||||
targets.push(target);
|
||||
}
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
function getClassPropsAsTargets(metadataReader, constructorFunc) {
|
||||
var classPropsMetadata = metadataReader.getPropertiesMetadata(constructorFunc);
|
||||
var targets = [];
|
||||
var keys = Object.keys(classPropsMetadata);
|
||||
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
||||
var key = keys_1[_i];
|
||||
var targetMetadata = classPropsMetadata[key];
|
||||
var metadata = formatTargetMetadata(classPropsMetadata[key]);
|
||||
var targetName = metadata.targetName || key;
|
||||
var serviceIdentifier = (metadata.inject || metadata.multiInject);
|
||||
var target = new target_1.Target(literal_types_1.TargetTypeEnum.ClassProperty, targetName, serviceIdentifier);
|
||||
target.metadata = targetMetadata;
|
||||
targets.push(target);
|
||||
}
|
||||
var baseConstructor = Object.getPrototypeOf(constructorFunc.prototype).constructor;
|
||||
if (baseConstructor !== Object) {
|
||||
var baseTargets = getClassPropsAsTargets(metadataReader, baseConstructor);
|
||||
targets = targets.concat(baseTargets);
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
function getBaseClassDependencyCount(metadataReader, func) {
|
||||
var baseConstructor = Object.getPrototypeOf(func.prototype).constructor;
|
||||
if (baseConstructor !== Object) {
|
||||
var baseConstructorName = serialization_1.getFunctionName(baseConstructor);
|
||||
var targets = getTargets(metadataReader, baseConstructorName, baseConstructor, true);
|
||||
var metadata = targets.map(function (t) {
|
||||
return t.metadata.filter(function (m) {
|
||||
return m.key === METADATA_KEY.UNMANAGED_TAG;
|
||||
});
|
||||
});
|
||||
var unmanagedCount = [].concat.apply([], metadata).length;
|
||||
var dependencyCount = targets.length - unmanagedCount;
|
||||
if (dependencyCount > 0) {
|
||||
return dependencyCount;
|
||||
}
|
||||
else {
|
||||
return getBaseClassDependencyCount(metadataReader, baseConstructor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
exports.getBaseClassDependencyCount = getBaseClassDependencyCount;
|
||||
function formatTargetMetadata(targetMetadata) {
|
||||
var targetMetadataMap = {};
|
||||
targetMetadata.forEach(function (m) {
|
||||
targetMetadataMap[m.key.toString()] = m.value;
|
||||
});
|
||||
return {
|
||||
inject: targetMetadataMap[METADATA_KEY.INJECT_TAG],
|
||||
multiInject: targetMetadataMap[METADATA_KEY.MULTI_INJECT_TAG],
|
||||
targetName: targetMetadataMap[METADATA_KEY.NAME_TAG],
|
||||
unmanaged: targetMetadataMap[METADATA_KEY.UNMANAGED_TAG]
|
||||
};
|
||||
}
|
||||
24
node_modules/inversify/lib/planning/request.js
generated
vendored
Normal file
24
node_modules/inversify/lib/planning/request.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var id_1 = require("../utils/id");
|
||||
var Request = (function () {
|
||||
function Request(serviceIdentifier, parentContext, parentRequest, bindings, target) {
|
||||
this.id = id_1.id();
|
||||
this.serviceIdentifier = serviceIdentifier;
|
||||
this.parentContext = parentContext;
|
||||
this.parentRequest = parentRequest;
|
||||
this.target = target;
|
||||
this.childRequests = [];
|
||||
this.bindings = (Array.isArray(bindings) ? bindings : [bindings]);
|
||||
this.requestScope = parentRequest === null
|
||||
? new Map()
|
||||
: null;
|
||||
}
|
||||
Request.prototype.addChildRequest = function (serviceIdentifier, bindings, target) {
|
||||
var child = new Request(serviceIdentifier, this.parentContext, this, bindings, target);
|
||||
this.childRequests.push(child);
|
||||
return child;
|
||||
};
|
||||
return Request;
|
||||
}());
|
||||
exports.Request = Request;
|
||||
90
node_modules/inversify/lib/planning/target.js
generated
vendored
Normal file
90
node_modules/inversify/lib/planning/target.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var id_1 = require("../utils/id");
|
||||
var metadata_1 = require("./metadata");
|
||||
var queryable_string_1 = require("./queryable_string");
|
||||
var Target = (function () {
|
||||
function Target(type, name, serviceIdentifier, namedOrTagged) {
|
||||
this.id = id_1.id();
|
||||
this.type = type;
|
||||
this.serviceIdentifier = serviceIdentifier;
|
||||
this.name = new queryable_string_1.QueryableString(name || "");
|
||||
this.metadata = new Array();
|
||||
var metadataItem = null;
|
||||
if (typeof namedOrTagged === "string") {
|
||||
metadataItem = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, namedOrTagged);
|
||||
}
|
||||
else if (namedOrTagged instanceof metadata_1.Metadata) {
|
||||
metadataItem = namedOrTagged;
|
||||
}
|
||||
if (metadataItem !== null) {
|
||||
this.metadata.push(metadataItem);
|
||||
}
|
||||
}
|
||||
Target.prototype.hasTag = function (key) {
|
||||
for (var _i = 0, _a = this.metadata; _i < _a.length; _i++) {
|
||||
var m = _a[_i];
|
||||
if (m.key === key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Target.prototype.isArray = function () {
|
||||
return this.hasTag(METADATA_KEY.MULTI_INJECT_TAG);
|
||||
};
|
||||
Target.prototype.matchesArray = function (name) {
|
||||
return this.matchesTag(METADATA_KEY.MULTI_INJECT_TAG)(name);
|
||||
};
|
||||
Target.prototype.isNamed = function () {
|
||||
return this.hasTag(METADATA_KEY.NAMED_TAG);
|
||||
};
|
||||
Target.prototype.isTagged = function () {
|
||||
return this.metadata.some(function (m) {
|
||||
return (m.key !== METADATA_KEY.INJECT_TAG) &&
|
||||
(m.key !== METADATA_KEY.MULTI_INJECT_TAG) &&
|
||||
(m.key !== METADATA_KEY.NAME_TAG) &&
|
||||
(m.key !== METADATA_KEY.UNMANAGED_TAG) &&
|
||||
(m.key !== METADATA_KEY.NAMED_TAG);
|
||||
});
|
||||
};
|
||||
Target.prototype.isOptional = function () {
|
||||
return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true);
|
||||
};
|
||||
Target.prototype.getNamedTag = function () {
|
||||
if (this.isNamed()) {
|
||||
return this.metadata.filter(function (m) { return m.key === METADATA_KEY.NAMED_TAG; })[0];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Target.prototype.getCustomTags = function () {
|
||||
if (this.isTagged()) {
|
||||
return this.metadata.filter(function (m) {
|
||||
return (m.key !== METADATA_KEY.INJECT_TAG) &&
|
||||
(m.key !== METADATA_KEY.MULTI_INJECT_TAG) &&
|
||||
(m.key !== METADATA_KEY.NAME_TAG) &&
|
||||
(m.key !== METADATA_KEY.UNMANAGED_TAG) &&
|
||||
(m.key !== METADATA_KEY.NAMED_TAG);
|
||||
});
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Target.prototype.matchesNamedTag = function (name) {
|
||||
return this.matchesTag(METADATA_KEY.NAMED_TAG)(name);
|
||||
};
|
||||
Target.prototype.matchesTag = function (key) {
|
||||
var _this = this;
|
||||
return function (value) {
|
||||
for (var _i = 0, _a = _this.metadata; _i < _a.length; _i++) {
|
||||
var m = _a[_i];
|
||||
if (m.key === key && m.value === value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
return Target;
|
||||
}());
|
||||
exports.Target = Target;
|
||||
50
node_modules/inversify/lib/resolution/instantiation.js
generated
vendored
Normal file
50
node_modules/inversify/lib/resolution/instantiation.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var error_msgs_1 = require("../constants/error_msgs");
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
function _injectProperties(instance, childRequests, resolveRequest) {
|
||||
var propertyInjectionsRequests = childRequests.filter(function (childRequest) {
|
||||
return (childRequest.target !== null &&
|
||||
childRequest.target.type === literal_types_1.TargetTypeEnum.ClassProperty);
|
||||
});
|
||||
var propertyInjections = propertyInjectionsRequests.map(resolveRequest);
|
||||
propertyInjectionsRequests.forEach(function (r, index) {
|
||||
var propertyName = "";
|
||||
propertyName = r.target.name.value();
|
||||
var injection = propertyInjections[index];
|
||||
instance[propertyName] = injection;
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
function _createInstance(Func, injections) {
|
||||
return new (Func.bind.apply(Func, [void 0].concat(injections)))();
|
||||
}
|
||||
function _postConstruct(constr, result) {
|
||||
if (Reflect.hasMetadata(METADATA_KEY.POST_CONSTRUCT, constr)) {
|
||||
var data = Reflect.getMetadata(METADATA_KEY.POST_CONSTRUCT, constr);
|
||||
try {
|
||||
result[data.value]();
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(error_msgs_1.POST_CONSTRUCT_ERROR(constr.name, e.message));
|
||||
}
|
||||
}
|
||||
}
|
||||
function resolveInstance(constr, childRequests, resolveRequest) {
|
||||
var result = null;
|
||||
if (childRequests.length > 0) {
|
||||
var constructorInjectionsRequests = childRequests.filter(function (childRequest) {
|
||||
return (childRequest.target !== null && childRequest.target.type === literal_types_1.TargetTypeEnum.ConstructorArgument);
|
||||
});
|
||||
var constructorInjections = constructorInjectionsRequests.map(resolveRequest);
|
||||
result = _createInstance(constr, constructorInjections);
|
||||
result = _injectProperties(result, childRequests, resolveRequest);
|
||||
}
|
||||
else {
|
||||
result = new constr();
|
||||
}
|
||||
_postConstruct(constr, result);
|
||||
return result;
|
||||
}
|
||||
exports.resolveInstance = resolveInstance;
|
||||
98
node_modules/inversify/lib/resolution/resolver.js
generated
vendored
Normal file
98
node_modules/inversify/lib/resolution/resolver.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var exceptions_1 = require("../utils/exceptions");
|
||||
var serialization_1 = require("../utils/serialization");
|
||||
var instantiation_1 = require("./instantiation");
|
||||
var invokeFactory = function (factoryType, serviceIdentifier, fn) {
|
||||
try {
|
||||
return fn();
|
||||
}
|
||||
catch (error) {
|
||||
if (exceptions_1.isStackOverflowExeption(error)) {
|
||||
throw new Error(ERROR_MSGS.CIRCULAR_DEPENDENCY_IN_FACTORY(factoryType, serviceIdentifier.toString()));
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
var _resolveRequest = function (requestScope) {
|
||||
return function (request) {
|
||||
request.parentContext.setCurrentRequest(request);
|
||||
var bindings = request.bindings;
|
||||
var childRequests = request.childRequests;
|
||||
var targetIsAnArray = request.target && request.target.isArray();
|
||||
var targetParentIsNotAnArray = !request.parentRequest ||
|
||||
!request.parentRequest.target ||
|
||||
!request.target ||
|
||||
!request.parentRequest.target.matchesArray(request.target.serviceIdentifier);
|
||||
if (targetIsAnArray && targetParentIsNotAnArray) {
|
||||
return childRequests.map(function (childRequest) {
|
||||
var _f = _resolveRequest(requestScope);
|
||||
return _f(childRequest);
|
||||
});
|
||||
}
|
||||
else {
|
||||
var result = null;
|
||||
if (request.target.isOptional() && bindings.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
var binding_1 = bindings[0];
|
||||
var isSingleton = binding_1.scope === literal_types_1.BindingScopeEnum.Singleton;
|
||||
var isRequestSingleton = binding_1.scope === literal_types_1.BindingScopeEnum.Request;
|
||||
if (isSingleton && binding_1.activated) {
|
||||
return binding_1.cache;
|
||||
}
|
||||
if (isRequestSingleton &&
|
||||
requestScope !== null &&
|
||||
requestScope.has(binding_1.id)) {
|
||||
return requestScope.get(binding_1.id);
|
||||
}
|
||||
if (binding_1.type === literal_types_1.BindingTypeEnum.ConstantValue) {
|
||||
result = binding_1.cache;
|
||||
}
|
||||
else if (binding_1.type === literal_types_1.BindingTypeEnum.Function) {
|
||||
result = binding_1.cache;
|
||||
}
|
||||
else if (binding_1.type === literal_types_1.BindingTypeEnum.Constructor) {
|
||||
result = binding_1.implementationType;
|
||||
}
|
||||
else if (binding_1.type === literal_types_1.BindingTypeEnum.DynamicValue && binding_1.dynamicValue !== null) {
|
||||
result = invokeFactory("toDynamicValue", binding_1.serviceIdentifier, function () { return binding_1.dynamicValue(request.parentContext); });
|
||||
}
|
||||
else if (binding_1.type === literal_types_1.BindingTypeEnum.Factory && binding_1.factory !== null) {
|
||||
result = invokeFactory("toFactory", binding_1.serviceIdentifier, function () { return binding_1.factory(request.parentContext); });
|
||||
}
|
||||
else if (binding_1.type === literal_types_1.BindingTypeEnum.Provider && binding_1.provider !== null) {
|
||||
result = invokeFactory("toProvider", binding_1.serviceIdentifier, function () { return binding_1.provider(request.parentContext); });
|
||||
}
|
||||
else if (binding_1.type === literal_types_1.BindingTypeEnum.Instance && binding_1.implementationType !== null) {
|
||||
result = instantiation_1.resolveInstance(binding_1.implementationType, childRequests, _resolveRequest(requestScope));
|
||||
}
|
||||
else {
|
||||
var serviceIdentifier = serialization_1.getServiceIdentifierAsString(request.serviceIdentifier);
|
||||
throw new Error(ERROR_MSGS.INVALID_BINDING_TYPE + " " + serviceIdentifier);
|
||||
}
|
||||
if (typeof binding_1.onActivation === "function") {
|
||||
result = binding_1.onActivation(request.parentContext, result);
|
||||
}
|
||||
if (isSingleton) {
|
||||
binding_1.cache = result;
|
||||
binding_1.activated = true;
|
||||
}
|
||||
if (isRequestSingleton &&
|
||||
requestScope !== null &&
|
||||
!requestScope.has(binding_1.id)) {
|
||||
requestScope.set(binding_1.id, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
};
|
||||
function resolve(context) {
|
||||
var _f = _resolveRequest(context.plan.rootRequest.requestScope);
|
||||
return _f(context.plan.rootRequest);
|
||||
}
|
||||
exports.resolve = resolve;
|
||||
23
node_modules/inversify/lib/syntax/binding_in_syntax.js
generated
vendored
Normal file
23
node_modules/inversify/lib/syntax/binding_in_syntax.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var binding_when_on_syntax_1 = require("./binding_when_on_syntax");
|
||||
var BindingInSyntax = (function () {
|
||||
function BindingInSyntax(binding) {
|
||||
this._binding = binding;
|
||||
}
|
||||
BindingInSyntax.prototype.inRequestScope = function () {
|
||||
this._binding.scope = literal_types_1.BindingScopeEnum.Request;
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingInSyntax.prototype.inSingletonScope = function () {
|
||||
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingInSyntax.prototype.inTransientScope = function () {
|
||||
this._binding.scope = literal_types_1.BindingScopeEnum.Transient;
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
return BindingInSyntax;
|
||||
}());
|
||||
exports.BindingInSyntax = BindingInSyntax;
|
||||
72
node_modules/inversify/lib/syntax/binding_in_when_on_syntax.js
generated
vendored
Normal file
72
node_modules/inversify/lib/syntax/binding_in_when_on_syntax.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var binding_in_syntax_1 = require("./binding_in_syntax");
|
||||
var binding_on_syntax_1 = require("./binding_on_syntax");
|
||||
var binding_when_syntax_1 = require("./binding_when_syntax");
|
||||
var BindingInWhenOnSyntax = (function () {
|
||||
function BindingInWhenOnSyntax(binding) {
|
||||
this._binding = binding;
|
||||
this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding);
|
||||
this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
this._bindingInSyntax = new binding_in_syntax_1.BindingInSyntax(binding);
|
||||
}
|
||||
BindingInWhenOnSyntax.prototype.inRequestScope = function () {
|
||||
return this._bindingInSyntax.inRequestScope();
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.inSingletonScope = function () {
|
||||
return this._bindingInSyntax.inSingletonScope();
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.inTransientScope = function () {
|
||||
return this._bindingInSyntax.inTransientScope();
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.when = function (constraint) {
|
||||
return this._bindingWhenSyntax.when(constraint);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenTargetNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenTargetNamed(name);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenTargetIsDefault = function () {
|
||||
return this._bindingWhenSyntax.whenTargetIsDefault();
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenTargetTagged(tag, value);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenInjectedInto = function (parent) {
|
||||
return this._bindingWhenSyntax.whenInjectedInto(parent);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenParentNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenParentNamed(name);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenParentTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenParentTagged(tag, value);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorIs(ancestor);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorNamed(name);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorNamed(name);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorMatches(constraint);
|
||||
};
|
||||
BindingInWhenOnSyntax.prototype.onActivation = function (handler) {
|
||||
return this._bindingOnSyntax.onActivation(handler);
|
||||
};
|
||||
return BindingInWhenOnSyntax;
|
||||
}());
|
||||
exports.BindingInWhenOnSyntax = BindingInWhenOnSyntax;
|
||||
14
node_modules/inversify/lib/syntax/binding_on_syntax.js
generated
vendored
Normal file
14
node_modules/inversify/lib/syntax/binding_on_syntax.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var binding_when_syntax_1 = require("./binding_when_syntax");
|
||||
var BindingOnSyntax = (function () {
|
||||
function BindingOnSyntax(binding) {
|
||||
this._binding = binding;
|
||||
}
|
||||
BindingOnSyntax.prototype.onActivation = function (handler) {
|
||||
this._binding.onActivation = handler;
|
||||
return new binding_when_syntax_1.BindingWhenSyntax(this._binding);
|
||||
};
|
||||
return BindingOnSyntax;
|
||||
}());
|
||||
exports.BindingOnSyntax = BindingOnSyntax;
|
||||
73
node_modules/inversify/lib/syntax/binding_to_syntax.js
generated
vendored
Normal file
73
node_modules/inversify/lib/syntax/binding_to_syntax.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
var literal_types_1 = require("../constants/literal_types");
|
||||
var binding_in_when_on_syntax_1 = require("./binding_in_when_on_syntax");
|
||||
var binding_when_on_syntax_1 = require("./binding_when_on_syntax");
|
||||
var BindingToSyntax = (function () {
|
||||
function BindingToSyntax(binding) {
|
||||
this._binding = binding;
|
||||
}
|
||||
BindingToSyntax.prototype.to = function (constructor) {
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.Instance;
|
||||
this._binding.implementationType = constructor;
|
||||
return new binding_in_when_on_syntax_1.BindingInWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingToSyntax.prototype.toSelf = function () {
|
||||
if (typeof this._binding.serviceIdentifier !== "function") {
|
||||
throw new Error("" + ERROR_MSGS.INVALID_TO_SELF_VALUE);
|
||||
}
|
||||
var self = this._binding.serviceIdentifier;
|
||||
return this.to(self);
|
||||
};
|
||||
BindingToSyntax.prototype.toConstantValue = function (value) {
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.ConstantValue;
|
||||
this._binding.cache = value;
|
||||
this._binding.dynamicValue = null;
|
||||
this._binding.implementationType = null;
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingToSyntax.prototype.toDynamicValue = function (func) {
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.DynamicValue;
|
||||
this._binding.cache = null;
|
||||
this._binding.dynamicValue = func;
|
||||
this._binding.implementationType = null;
|
||||
return new binding_in_when_on_syntax_1.BindingInWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingToSyntax.prototype.toConstructor = function (constructor) {
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.Constructor;
|
||||
this._binding.implementationType = constructor;
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingToSyntax.prototype.toFactory = function (factory) {
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.Factory;
|
||||
this._binding.factory = factory;
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingToSyntax.prototype.toFunction = function (func) {
|
||||
if (typeof func !== "function") {
|
||||
throw new Error(ERROR_MSGS.INVALID_FUNCTION_BINDING);
|
||||
}
|
||||
var bindingWhenOnSyntax = this.toConstantValue(func);
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.Function;
|
||||
return bindingWhenOnSyntax;
|
||||
};
|
||||
BindingToSyntax.prototype.toAutoFactory = function (serviceIdentifier) {
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.Factory;
|
||||
this._binding.factory = function (context) {
|
||||
var autofactory = function () { return context.container.get(serviceIdentifier); };
|
||||
return autofactory;
|
||||
};
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingToSyntax.prototype.toProvider = function (provider) {
|
||||
this._binding.type = literal_types_1.BindingTypeEnum.Provider;
|
||||
this._binding.provider = provider;
|
||||
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
||||
};
|
||||
BindingToSyntax.prototype.toService = function (service) {
|
||||
this.toDynamicValue(function (context) { return context.container.get(service); });
|
||||
};
|
||||
return BindingToSyntax;
|
||||
}());
|
||||
exports.BindingToSyntax = BindingToSyntax;
|
||||
61
node_modules/inversify/lib/syntax/binding_when_on_syntax.js
generated
vendored
Normal file
61
node_modules/inversify/lib/syntax/binding_when_on_syntax.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var binding_on_syntax_1 = require("./binding_on_syntax");
|
||||
var binding_when_syntax_1 = require("./binding_when_syntax");
|
||||
var BindingWhenOnSyntax = (function () {
|
||||
function BindingWhenOnSyntax(binding) {
|
||||
this._binding = binding;
|
||||
this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding);
|
||||
this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
}
|
||||
BindingWhenOnSyntax.prototype.when = function (constraint) {
|
||||
return this._bindingWhenSyntax.when(constraint);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenTargetNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenTargetNamed(name);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenTargetIsDefault = function () {
|
||||
return this._bindingWhenSyntax.whenTargetIsDefault();
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenTargetTagged(tag, value);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenInjectedInto = function (parent) {
|
||||
return this._bindingWhenSyntax.whenInjectedInto(parent);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenParentNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenParentNamed(name);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenParentTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenParentTagged(tag, value);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorIs(ancestor);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorNamed(name);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorNamed(name);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) {
|
||||
return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) {
|
||||
return this._bindingWhenSyntax.whenNoAncestorMatches(constraint);
|
||||
};
|
||||
BindingWhenOnSyntax.prototype.onActivation = function (handler) {
|
||||
return this._bindingOnSyntax.onActivation(handler);
|
||||
};
|
||||
return BindingWhenOnSyntax;
|
||||
}());
|
||||
exports.BindingWhenOnSyntax = BindingWhenOnSyntax;
|
||||
98
node_modules/inversify/lib/syntax/binding_when_syntax.js
generated
vendored
Normal file
98
node_modules/inversify/lib/syntax/binding_when_syntax.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var binding_on_syntax_1 = require("./binding_on_syntax");
|
||||
var constraint_helpers_1 = require("./constraint_helpers");
|
||||
var BindingWhenSyntax = (function () {
|
||||
function BindingWhenSyntax(binding) {
|
||||
this._binding = binding;
|
||||
}
|
||||
BindingWhenSyntax.prototype.when = function (constraint) {
|
||||
this._binding.constraint = constraint;
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenTargetNamed = function (name) {
|
||||
this._binding.constraint = constraint_helpers_1.namedConstraint(name);
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenTargetIsDefault = function () {
|
||||
this._binding.constraint = function (request) {
|
||||
var targetIsDefault = (request.target !== null) &&
|
||||
(!request.target.isNamed()) &&
|
||||
(!request.target.isTagged());
|
||||
return targetIsDefault;
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenTargetTagged = function (tag, value) {
|
||||
this._binding.constraint = constraint_helpers_1.taggedConstraint(tag)(value);
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenInjectedInto = function (parent) {
|
||||
this._binding.constraint = function (request) {
|
||||
return constraint_helpers_1.typeConstraint(parent)(request.parentRequest);
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenParentNamed = function (name) {
|
||||
this._binding.constraint = function (request) {
|
||||
return constraint_helpers_1.namedConstraint(name)(request.parentRequest);
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenParentTagged = function (tag, value) {
|
||||
this._binding.constraint = function (request) {
|
||||
return constraint_helpers_1.taggedConstraint(tag)(value)(request.parentRequest);
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenAnyAncestorIs = function (ancestor) {
|
||||
this._binding.constraint = function (request) {
|
||||
return constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.typeConstraint(ancestor));
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenNoAncestorIs = function (ancestor) {
|
||||
this._binding.constraint = function (request) {
|
||||
return !constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.typeConstraint(ancestor));
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenAnyAncestorNamed = function (name) {
|
||||
this._binding.constraint = function (request) {
|
||||
return constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.namedConstraint(name));
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenNoAncestorNamed = function (name) {
|
||||
this._binding.constraint = function (request) {
|
||||
return !constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.namedConstraint(name));
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenAnyAncestorTagged = function (tag, value) {
|
||||
this._binding.constraint = function (request) {
|
||||
return constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.taggedConstraint(tag)(value));
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenNoAncestorTagged = function (tag, value) {
|
||||
this._binding.constraint = function (request) {
|
||||
return !constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.taggedConstraint(tag)(value));
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenAnyAncestorMatches = function (constraint) {
|
||||
this._binding.constraint = function (request) {
|
||||
return constraint_helpers_1.traverseAncerstors(request, constraint);
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
BindingWhenSyntax.prototype.whenNoAncestorMatches = function (constraint) {
|
||||
this._binding.constraint = function (request) {
|
||||
return !constraint_helpers_1.traverseAncerstors(request, constraint);
|
||||
};
|
||||
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
||||
};
|
||||
return BindingWhenSyntax;
|
||||
}());
|
||||
exports.BindingWhenSyntax = BindingWhenSyntax;
|
||||
40
node_modules/inversify/lib/syntax/constraint_helpers.js
generated
vendored
Normal file
40
node_modules/inversify/lib/syntax/constraint_helpers.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var METADATA_KEY = require("../constants/metadata_keys");
|
||||
var metadata_1 = require("../planning/metadata");
|
||||
var traverseAncerstors = function (request, constraint) {
|
||||
var parent = request.parentRequest;
|
||||
if (parent !== null) {
|
||||
return constraint(parent) ? true : traverseAncerstors(parent, constraint);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
exports.traverseAncerstors = traverseAncerstors;
|
||||
var taggedConstraint = function (key) { return function (value) {
|
||||
var constraint = function (request) {
|
||||
return request !== null && request.target !== null && request.target.matchesTag(key)(value);
|
||||
};
|
||||
constraint.metaData = new metadata_1.Metadata(key, value);
|
||||
return constraint;
|
||||
}; };
|
||||
exports.taggedConstraint = taggedConstraint;
|
||||
var namedConstraint = taggedConstraint(METADATA_KEY.NAMED_TAG);
|
||||
exports.namedConstraint = namedConstraint;
|
||||
var typeConstraint = function (type) { return function (request) {
|
||||
var binding = null;
|
||||
if (request !== null) {
|
||||
binding = request.bindings[0];
|
||||
if (typeof type === "string") {
|
||||
var serviceIdentifier = binding.serviceIdentifier;
|
||||
return serviceIdentifier === type;
|
||||
}
|
||||
else {
|
||||
var constructor = request.bindings[0].implementationType;
|
||||
return type === constructor;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}; };
|
||||
exports.typeConstraint = typeConstraint;
|
||||
13
node_modules/inversify/lib/utils/binding_utils.js
generated
vendored
Normal file
13
node_modules/inversify/lib/utils/binding_utils.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.multiBindToService = function (container) {
|
||||
return function (service) {
|
||||
return function () {
|
||||
var types = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
types[_i] = arguments[_i];
|
||||
}
|
||||
return types.forEach(function (t) { return container.bind(t).toService(service); });
|
||||
};
|
||||
};
|
||||
};
|
||||
8
node_modules/inversify/lib/utils/exceptions.js
generated
vendored
Normal file
8
node_modules/inversify/lib/utils/exceptions.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
function isStackOverflowExeption(error) {
|
||||
return (error instanceof RangeError ||
|
||||
error.message === ERROR_MSGS.STACK_OVERFLOW);
|
||||
}
|
||||
exports.isStackOverflowExeption = isStackOverflowExeption;
|
||||
7
node_modules/inversify/lib/utils/id.js
generated
vendored
Normal file
7
node_modules/inversify/lib/utils/id.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var idCounter = 0;
|
||||
function id() {
|
||||
return idCounter++;
|
||||
}
|
||||
exports.id = id;
|
||||
103
node_modules/inversify/lib/utils/serialization.js
generated
vendored
Normal file
103
node_modules/inversify/lib/utils/serialization.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ERROR_MSGS = require("../constants/error_msgs");
|
||||
function getServiceIdentifierAsString(serviceIdentifier) {
|
||||
if (typeof serviceIdentifier === "function") {
|
||||
var _serviceIdentifier = serviceIdentifier;
|
||||
return _serviceIdentifier.name;
|
||||
}
|
||||
else if (typeof serviceIdentifier === "symbol") {
|
||||
return serviceIdentifier.toString();
|
||||
}
|
||||
else {
|
||||
var _serviceIdentifier = serviceIdentifier;
|
||||
return _serviceIdentifier;
|
||||
}
|
||||
}
|
||||
exports.getServiceIdentifierAsString = getServiceIdentifierAsString;
|
||||
function listRegisteredBindingsForServiceIdentifier(container, serviceIdentifier, getBindings) {
|
||||
var registeredBindingsList = "";
|
||||
var registeredBindings = getBindings(container, serviceIdentifier);
|
||||
if (registeredBindings.length !== 0) {
|
||||
registeredBindingsList = "\nRegistered bindings:";
|
||||
registeredBindings.forEach(function (binding) {
|
||||
var name = "Object";
|
||||
if (binding.implementationType !== null) {
|
||||
name = getFunctionName(binding.implementationType);
|
||||
}
|
||||
registeredBindingsList = registeredBindingsList + "\n " + name;
|
||||
if (binding.constraint.metaData) {
|
||||
registeredBindingsList = registeredBindingsList + " - " + binding.constraint.metaData;
|
||||
}
|
||||
});
|
||||
}
|
||||
return registeredBindingsList;
|
||||
}
|
||||
exports.listRegisteredBindingsForServiceIdentifier = listRegisteredBindingsForServiceIdentifier;
|
||||
function alreadyDependencyChain(request, serviceIdentifier) {
|
||||
if (request.parentRequest === null) {
|
||||
return false;
|
||||
}
|
||||
else if (request.parentRequest.serviceIdentifier === serviceIdentifier) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return alreadyDependencyChain(request.parentRequest, serviceIdentifier);
|
||||
}
|
||||
}
|
||||
function dependencyChainToString(request) {
|
||||
function _createStringArr(req, result) {
|
||||
if (result === void 0) { result = []; }
|
||||
var serviceIdentifier = getServiceIdentifierAsString(req.serviceIdentifier);
|
||||
result.push(serviceIdentifier);
|
||||
if (req.parentRequest !== null) {
|
||||
return _createStringArr(req.parentRequest, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var stringArr = _createStringArr(request);
|
||||
return stringArr.reverse().join(" --> ");
|
||||
}
|
||||
function circularDependencyToException(request) {
|
||||
request.childRequests.forEach(function (childRequest) {
|
||||
if (alreadyDependencyChain(childRequest, childRequest.serviceIdentifier)) {
|
||||
var services = dependencyChainToString(childRequest);
|
||||
throw new Error(ERROR_MSGS.CIRCULAR_DEPENDENCY + " " + services);
|
||||
}
|
||||
else {
|
||||
circularDependencyToException(childRequest);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.circularDependencyToException = circularDependencyToException;
|
||||
function listMetadataForTarget(serviceIdentifierString, target) {
|
||||
if (target.isTagged() || target.isNamed()) {
|
||||
var m_1 = "";
|
||||
var namedTag = target.getNamedTag();
|
||||
var otherTags = target.getCustomTags();
|
||||
if (namedTag !== null) {
|
||||
m_1 += namedTag.toString() + "\n";
|
||||
}
|
||||
if (otherTags !== null) {
|
||||
otherTags.forEach(function (tag) {
|
||||
m_1 += tag.toString() + "\n";
|
||||
});
|
||||
}
|
||||
return " " + serviceIdentifierString + "\n " + serviceIdentifierString + " - " + m_1;
|
||||
}
|
||||
else {
|
||||
return " " + serviceIdentifierString;
|
||||
}
|
||||
}
|
||||
exports.listMetadataForTarget = listMetadataForTarget;
|
||||
function getFunctionName(v) {
|
||||
if (v.name) {
|
||||
return v.name;
|
||||
}
|
||||
else {
|
||||
var name_1 = v.toString();
|
||||
var match = name_1.match(/^function\s*([^\s(]+)/);
|
||||
return match ? match[1] : "Anonymous function: " + name_1;
|
||||
}
|
||||
}
|
||||
exports.getFunctionName = getFunctionName;
|
||||
Reference in New Issue
Block a user