diff options
Diffstat (limited to 'src/node_modules/inversify/amd/syntax')
7 files changed, 379 insertions, 0 deletions
diff --git a/src/node_modules/inversify/amd/syntax/binding_in_syntax.js b/src/node_modules/inversify/amd/syntax/binding_in_syntax.js new file mode 100644 index 0000000..eb25c8f --- /dev/null +++ b/src/node_modules/inversify/amd/syntax/binding_in_syntax.js @@ -0,0 +1,23 @@ +define(["require", "exports", "../constants/literal_types", "./binding_when_on_syntax"], function (require, exports, literal_types_1, binding_when_on_syntax_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + 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; +}); diff --git a/src/node_modules/inversify/amd/syntax/binding_in_when_on_syntax.js b/src/node_modules/inversify/amd/syntax/binding_in_when_on_syntax.js new file mode 100644 index 0000000..0e16a7f --- /dev/null +++ b/src/node_modules/inversify/amd/syntax/binding_in_when_on_syntax.js @@ -0,0 +1,71 @@ +define(["require", "exports", "./binding_in_syntax", "./binding_on_syntax", "./binding_when_syntax"], function (require, exports, binding_in_syntax_1, binding_on_syntax_1, binding_when_syntax_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + 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; +}); diff --git a/src/node_modules/inversify/amd/syntax/binding_on_syntax.js b/src/node_modules/inversify/amd/syntax/binding_on_syntax.js new file mode 100644 index 0000000..fc6b518 --- /dev/null +++ b/src/node_modules/inversify/amd/syntax/binding_on_syntax.js @@ -0,0 +1,15 @@ +define(["require", "exports", "./binding_when_syntax"], function (require, exports, binding_when_syntax_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + 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; +}); diff --git a/src/node_modules/inversify/amd/syntax/binding_to_syntax.js b/src/node_modules/inversify/amd/syntax/binding_to_syntax.js new file mode 100644 index 0000000..b6e08f5 --- /dev/null +++ b/src/node_modules/inversify/amd/syntax/binding_to_syntax.js @@ -0,0 +1,71 @@ +define(["require", "exports", "../constants/error_msgs", "../constants/literal_types", "./binding_in_when_on_syntax", "./binding_when_on_syntax"], function (require, exports, ERROR_MSGS, literal_types_1, binding_in_when_on_syntax_1, binding_when_on_syntax_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + 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; +}); diff --git a/src/node_modules/inversify/amd/syntax/binding_when_on_syntax.js b/src/node_modules/inversify/amd/syntax/binding_when_on_syntax.js new file mode 100644 index 0000000..d811eeb --- /dev/null +++ b/src/node_modules/inversify/amd/syntax/binding_when_on_syntax.js @@ -0,0 +1,61 @@ +define(["require", "exports", "./binding_on_syntax", "./binding_when_syntax"], function (require, exports, binding_on_syntax_1, binding_when_syntax_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + 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; +}); diff --git a/src/node_modules/inversify/amd/syntax/binding_when_syntax.js b/src/node_modules/inversify/amd/syntax/binding_when_syntax.js new file mode 100644 index 0000000..e1dbe97 --- /dev/null +++ b/src/node_modules/inversify/amd/syntax/binding_when_syntax.js @@ -0,0 +1,98 @@ +define(["require", "exports", "./binding_on_syntax", "./constraint_helpers"], function (require, exports, binding_on_syntax_1, constraint_helpers_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + 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; +}); diff --git a/src/node_modules/inversify/amd/syntax/constraint_helpers.js b/src/node_modules/inversify/amd/syntax/constraint_helpers.js new file mode 100644 index 0000000..e745a44 --- /dev/null +++ b/src/node_modules/inversify/amd/syntax/constraint_helpers.js @@ -0,0 +1,40 @@ +define(["require", "exports", "../constants/metadata_keys", "../planning/metadata"], function (require, exports, METADATA_KEY, metadata_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + 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; +}); |