aurelia-dependency-injection
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -78,2 +78,10 @@ define('aurelia-dependency-injection', ['exports', 'aurelia-metadata', 'aurelia-pal'], function (exports, aureliaMetadata, aureliaPal) { 'use strict'; | ||
}); | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(exports.Strategy || (exports.Strategy = {})); | ||
function isStrategy(actual, expected, state) { | ||
@@ -88,6 +96,6 @@ return actual === expected; | ||
StrategyResolver.prototype.get = function (container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.singleton, this.state)) { | ||
var singleton = container.invoke(this.state); | ||
@@ -98,12 +106,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -206,3 +214,3 @@ } | ||
var resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === exports.Strategy.function) { | ||
fn = resolver.state; | ||
@@ -209,0 +217,0 @@ } |
@@ -50,3 +50,3 @@ export type Primitive = boolean | ||
} | ||
export declare const enum Strategy { | ||
export declare enum Strategy { | ||
instance = 0, | ||
@@ -66,5 +66,5 @@ singleton = 1, | ||
[Strategy.function]: StrategyFunctor<TBase, TImpl, TArgs>; | ||
[Strategy.array]: [{ | ||
[Strategy.array]: ({ | ||
get: (container: Container, key: PrimitiveOrDependencyCtor<TBase, TImpl, TArgs>) => TImpl; | ||
}, ...TImpl[]]; | ||
} | TImpl)[]; | ||
[Strategy.alias]: any; | ||
@@ -71,0 +71,0 @@ } |
@@ -83,2 +83,10 @@ 'use strict'; | ||
}); | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(exports.Strategy || (exports.Strategy = {})); | ||
function isStrategy(actual, expected, state) { | ||
@@ -93,6 +101,6 @@ return actual === expected; | ||
StrategyResolver.prototype.get = function (container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.singleton, this.state)) { | ||
var singleton = container.invoke(this.state); | ||
@@ -103,12 +111,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -211,3 +219,3 @@ } | ||
var resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === exports.Strategy.function) { | ||
fn = resolver.state; | ||
@@ -214,0 +222,0 @@ } |
@@ -76,2 +76,11 @@ import { metadata, protocol } from 'aurelia-metadata'; | ||
}); | ||
var Strategy; | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(Strategy || (Strategy = {})); | ||
function isStrategy(actual, expected, state) { | ||
@@ -86,6 +95,6 @@ return actual === expected; | ||
get(container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.singleton, this.state)) { | ||
const singleton = container.invoke(this.state); | ||
@@ -96,12 +105,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -187,3 +196,3 @@ } | ||
const resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === Strategy.function) { | ||
fn = resolver.state; | ||
@@ -593,2 +602,2 @@ } | ||
export { _emptyParameters, InvocationHandler, Container, autoinject, inject, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, resolver, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance }; | ||
export { _emptyParameters, InvocationHandler, Container, autoinject, inject, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, resolver, Strategy, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance }; |
@@ -76,2 +76,11 @@ import { metadata, protocol } from 'aurelia-metadata'; | ||
}); | ||
var Strategy; | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(Strategy || (Strategy = {})); | ||
function isStrategy(actual, expected, state) { | ||
@@ -86,6 +95,6 @@ return actual === expected; | ||
get(container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.singleton, this.state)) { | ||
const singleton = container.invoke(this.state); | ||
@@ -96,12 +105,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -187,3 +196,3 @@ } | ||
const resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === Strategy.function) { | ||
fn = resolver.state; | ||
@@ -593,2 +602,2 @@ } | ||
export { _emptyParameters, InvocationHandler, Container, autoinject, inject, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, resolver, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance }; | ||
export { _emptyParameters, InvocationHandler, Container, autoinject, inject, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, resolver, Strategy, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance }; |
@@ -79,2 +79,11 @@ import { metadata, protocol } from 'aurelia-metadata'; | ||
}); | ||
var Strategy; | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(Strategy || (Strategy = {})); | ||
function isStrategy(actual, expected, state) { | ||
@@ -89,6 +98,6 @@ return actual === expected; | ||
StrategyResolver.prototype.get = function (container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.singleton, this.state)) { | ||
var singleton = container.invoke(this.state); | ||
@@ -99,12 +108,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -207,3 +216,3 @@ } | ||
var resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === Strategy.function) { | ||
fn = resolver.state; | ||
@@ -649,2 +658,2 @@ } | ||
export { _emptyParameters, InvocationHandler, Container, autoinject, inject, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, resolver, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance }; | ||
export { _emptyParameters, InvocationHandler, Container, autoinject, inject, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, resolver, Strategy, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance }; |
@@ -21,2 +21,3 @@ System.register(['aurelia-metadata', 'aurelia-pal'], function (exports, module) { | ||
singleton: singleton, | ||
Strategy: void 0, | ||
getDecoratorDependencies: getDecoratorDependencies, | ||
@@ -106,2 +107,11 @@ lazy: lazy, | ||
})); | ||
var Strategy; | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(Strategy || (Strategy = exports('Strategy', {}))); | ||
function isStrategy(actual, expected, state) { | ||
@@ -116,6 +126,6 @@ return actual === expected; | ||
StrategyResolver.prototype.get = function (container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.singleton, this.state)) { | ||
var singleton = container.invoke(this.state); | ||
@@ -126,12 +136,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -234,3 +244,3 @@ } | ||
var resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === Strategy.function) { | ||
fn = resolver.state; | ||
@@ -237,0 +247,0 @@ } |
@@ -79,2 +79,10 @@ (function (global, factory) { | ||
}); | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(exports.Strategy || (exports.Strategy = {})); | ||
function isStrategy(actual, expected, state) { | ||
@@ -89,6 +97,6 @@ return actual === expected; | ||
get(container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.singleton, this.state)) { | ||
const singleton = container.invoke(this.state); | ||
@@ -99,12 +107,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -190,3 +198,3 @@ } | ||
const resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === exports.Strategy.function) { | ||
fn = resolver.state; | ||
@@ -193,0 +201,0 @@ } |
@@ -82,2 +82,10 @@ (function (global, factory) { | ||
}); | ||
(function (Strategy) { | ||
Strategy[Strategy["instance"] = 0] = "instance"; | ||
Strategy[Strategy["singleton"] = 1] = "singleton"; | ||
Strategy[Strategy["transient"] = 2] = "transient"; | ||
Strategy[Strategy["function"] = 3] = "function"; | ||
Strategy[Strategy["array"] = 4] = "array"; | ||
Strategy[Strategy["alias"] = 5] = "alias"; | ||
})(exports.Strategy || (exports.Strategy = {})); | ||
function isStrategy(actual, expected, state) { | ||
@@ -92,6 +100,6 @@ return actual === expected; | ||
StrategyResolver.prototype.get = function (container, key) { | ||
if (isStrategy(this.strategy, 0, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.instance, this.state)) { | ||
return this.state; | ||
} | ||
if (isStrategy(this.strategy, 1, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.singleton, this.state)) { | ||
var singleton = container.invoke(this.state); | ||
@@ -102,12 +110,12 @@ this.state = singleton; | ||
} | ||
if (isStrategy(this.strategy, 2, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.transient, this.state)) { | ||
return container.invoke(this.state); | ||
} | ||
if (isStrategy(this.strategy, 3, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.function, this.state)) { | ||
return this.state(container, key, this); | ||
} | ||
if (isStrategy(this.strategy, 4, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
} | ||
if (isStrategy(this.strategy, 5, this.state)) { | ||
if (isStrategy(this.strategy, exports.Strategy.alias, this.state)) { | ||
return container.get(this.state); | ||
@@ -210,3 +218,3 @@ } | ||
var resolver = container.getResolver(fn); | ||
if (resolver && resolver.strategy === 3) { | ||
if (resolver && resolver.strategy === exports.Strategy.function) { | ||
fn = resolver.state; | ||
@@ -213,0 +221,0 @@ } |
@@ -5,2 +5,11 @@ # Change Log | ||
## [1.5.2](https://github.com/aurelia/dependency-injection/compare/1.5.1...1.5.2) (2019-11-20) | ||
### Bug Fixes | ||
* **typings:** dont use const enum ([28bad61](https://github.com/aurelia/dependency-injection/commit/28bad61)) | ||
## [1.5.1](https://github.com/aurelia/dependency-injection/compare/1.5.0...1.5.1) (2019-09-10) | ||
@@ -7,0 +16,0 @@ |
{ | ||
"name": "aurelia-dependency-injection", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "A lightweight, extensible dependency injection container for JavaScript.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -45,3 +45,3 @@ import { protocol } from 'aurelia-metadata'; | ||
export const enum Strategy { | ||
export enum Strategy { | ||
instance = 0, | ||
@@ -75,3 +75,7 @@ singleton = 1, | ||
[Strategy.function]: StrategyFunctor<TBase, TImpl, TArgs>; | ||
[Strategy.array]: [{ | ||
/** | ||
* For typings purposes, this is done as ({ get: StrategyFunctor } | TImpl)[] | ||
* But it should be understood, and used as [{ get: StrategyFunctor }, ...TImp[]] | ||
*/ | ||
[Strategy.array]: ({ | ||
get: ( | ||
@@ -81,3 +85,3 @@ container: Container, | ||
) => TImpl | ||
}, ...TImpl[]]; | ||
} | TImpl)[]; | ||
[Strategy.alias]: any; | ||
@@ -145,3 +149,3 @@ } | ||
if (isStrategy<TBase, TImpl, TArgs, Strategy.array>(this.strategy, Strategy.array, this.state)) { | ||
return this.state[0].get(container, key); | ||
return (this.state[0] as { get: StrategyFunctor<TBase, TImpl, TArgs> }).get(container, key); | ||
} | ||
@@ -148,0 +152,0 @@ if (isStrategy<TBase, TImpl, TArgs, Strategy.alias>(this.strategy, Strategy.alias, this.state)) { |
Sorry, the diff of this file is too big to display
454100
7406