Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reactive-di

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactive-di - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

annotations.js

17

dist/__tests__/annotations.js

@@ -7,6 +7,4 @@ 'use strict';

var _createAnnotations = require('../createAnnotations');
var _annotations = require('../annotations');
var _createAnnotations2 = _interopRequireDefault(_createAnnotations);
var _SymbolMetaDriver = require('../drivers/SymbolMetaDriver');

@@ -25,5 +23,12 @@

var annotations = (0, _createAnnotations2.default)(driver);
exports.default = annotations;
exports.default = {
loader: (0, _annotations.createLoader)(driver),
factory: (0, _annotations.createFactory)(driver),
klass: (0, _annotations.createKlass)(driver),
model: (0, _annotations.createModel)(driver),
meta: (0, _annotations.createMeta)(driver),
observable: (0, _annotations.createObservable)(driver),
asyncsetter: (0, _annotations.createAsyncSetter)(driver),
syncsetter: (0, _annotations.createSyncSetter)(driver)
};
//# sourceMappingURL=annotations.js.map

@@ -29,2 +29,10 @@ 'use strict';

var _createPureStateDi = require('../createPureStateDi');
var _createPureStateDi2 = _interopRequireDefault(_createPureStateDi);
var _defaultPlugins = require('../defaultPlugins');
var _defaultPlugins2 = _interopRequireDefault(_defaultPlugins);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -141,2 +149,4 @@

var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);
return {

@@ -146,2 +156,3 @@ A: A,

C: C,
di: di,
cLoader: cLoader,

@@ -148,0 +159,0 @@ AppState: AppState,

@@ -38,2 +38,6 @@ 'use strict';

var _defaultPlugins = require('../defaultPlugins');
var _defaultPlugins2 = _interopRequireDefault(_defaultPlugins);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -95,3 +99,3 @@

var di = (0, _createPureStateDi2.default)(new AppState());
var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);
var MyDep = _sinon2.default.spy(function (c /*: C*/, m /*: EntityMeta*/) {

@@ -104,3 +108,3 @@ return { v: c.v, meta: m };

filepath: 'src/__tests__/DiAsyncTest.js',
line: 55
line: 57
}), _rec2._expr(_rec2._capt({

@@ -117,3 +121,3 @@ v: 'test1',

filepath: 'src/__tests__/DiAsyncTest.js',
line: 55
line: 57
}));

@@ -129,3 +133,3 @@

filepath: 'src/__tests__/DiAsyncTest.js',
line: 67
line: 69
}), _rec4._expr(_rec4._capt({

@@ -142,3 +146,3 @@ v: 'test2',

filepath: 'src/__tests__/DiAsyncTest.js',
line: 67
line: 69
}));

@@ -145,0 +149,0 @@ });

@@ -18,6 +18,2 @@ 'use strict';

var _createPureStateDi = require('../createPureStateDi');
var _createPureStateDi2 = _interopRequireDefault(_createPureStateDi);
var _TestState = require('./TestState');

@@ -37,5 +33,4 @@

var A = _createState.A;
var AppState = _createState.AppState;
var di = _createState.di;
var di = (0, _createPureStateDi2.default)(new AppState());
var fn = _sinon2.default.spy(function (v) {

@@ -50,3 +45,3 @@ return v;

filepath: 'src/__tests__/DiCacheTest.js',
line: 23
line: 21
}));

@@ -63,7 +58,6 @@ });

var B = _createState2.B;
var AppState = _createState2.AppState;
var di = _createState2.di;
var bSetter = _createState2.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var fn = _sinon2.default.spy(function (v) {

@@ -82,3 +76,3 @@ return v;

filepath: 'src/__tests__/DiCacheTest.js',
line: 38
line: 35
}));

@@ -88,3 +82,3 @@ (0, _powerAssert2.default)(_rec3._expr(_rec3._capt(_rec3._capt(_rec3._capt(fn, 'arguments/0/callee/object/object').firstCall, 'arguments/0/callee/object').calledWith(_rec3._capt({ v: 123 }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiCacheTest.js',
line: 39
line: 36
}));

@@ -94,3 +88,3 @@ (0, _powerAssert2.default)(_rec4._expr(_rec4._capt(_rec4._capt(_rec4._capt(fn, 'arguments/0/callee/object/object').secondCall, 'arguments/0/callee/object').calledWith(_rec4._capt({ v: 321 }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiCacheTest.js',
line: 40
line: 37
}));

@@ -105,6 +99,5 @@ });

var B = _createState3.B;
var AppState = _createState3.AppState;
var di = _createState3.di;
var cSetter = _createState3.cSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var fn = _sinon2.default.spy(function (v) {

@@ -121,3 +114,3 @@ return v;

filepath: 'src/__tests__/DiCacheTest.js',
line: 52
line: 48
}));

@@ -134,6 +127,5 @@ });

var B = _createState4.B;
var AppState = _createState4.AppState;
var di = _createState4.di;
var aSetter = _createState4.aSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var fn = _sinon2.default.spy(function (v) {

@@ -153,3 +145,3 @@ return v;

filepath: 'src/__tests__/DiCacheTest.js',
line: 67
line: 62
}));

@@ -156,0 +148,0 @@ });

@@ -26,2 +26,6 @@ 'use strict';

var _defaultPlugins = require('../defaultPlugins');
var _defaultPlugins2 = _interopRequireDefault(_defaultPlugins);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -43,3 +47,3 @@

_powerAssert2.default.throws(function () {
return (0, _createPureStateDi2.default)({});
return (0, _createPureStateDi2.default)({}, [], _defaultPlugins2.default);
}, /not annotated/);

@@ -51,3 +55,3 @@ });

it('should throws exception if no decorated function passed', function () {
var di = (0, _createPureStateDi2.default)(new AppState());
var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);
function WrongDep() {}

@@ -63,3 +67,3 @@

var di = (0, _createPureStateDi2.default)(new AppState());
var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);

@@ -75,3 +79,3 @@ var Test = function Test() {

filepath: 'src/__tests__/DiContainerTest.js',
line: 39
line: 40
}));

@@ -84,3 +88,3 @@ });

var di = (0, _createPureStateDi2.default)(new AppState());
var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);

@@ -98,3 +102,3 @@ var TestBase = function TestBase() {

filepath: 'src/__tests__/DiContainerTest.js',
line: 49
line: 50
}));

@@ -104,3 +108,3 @@ (0, _powerAssert2.default)(_rec3._expr(_rec3._capt(_rec3._capt(Test, 'arguments/0/object').calledOnce, 'arguments/0'), {

filepath: 'src/__tests__/DiContainerTest.js',
line: 50
line: 51
}));

@@ -113,3 +117,3 @@ });

var di = (0, _createPureStateDi2.default)(new AppState());
var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);
function testBase() {

@@ -126,3 +130,3 @@ return 123;

filepath: 'src/__tests__/DiContainerTest.js',
line: 63
line: 64
}));

@@ -132,3 +136,3 @@ (0, _powerAssert2.default)(_rec5._expr(_rec5._capt(_rec5._capt(test, 'arguments/0/object').calledOnce, 'arguments/0'), {

filepath: 'src/__tests__/DiContainerTest.js',
line: 64
line: 65
}));

@@ -140,3 +144,3 @@ });

var di = (0, _createPureStateDi2.default)(new AppState());
var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);
function MyDep() {

@@ -158,3 +162,3 @@ return 123;

filepath: 'src/__tests__/DiContainerTest.js',
line: 78
line: 79
}));

@@ -166,3 +170,3 @@ });

var di = (0, _createPureStateDi2.default)(new AppState());
var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);
function MyDep() {

@@ -184,3 +188,3 @@ return 123;

filepath: 'src/__tests__/DiContainerTest.js',
line: 92
line: 93
}));

@@ -187,0 +191,0 @@ });

@@ -34,6 +34,2 @@ 'use strict';

var _createPureStateDi = require('../createPureStateDi');
var _createPureStateDi2 = _interopRequireDefault(_createPureStateDi);
var _TestState = require('./TestState');

@@ -54,9 +50,7 @@

var B = _createState.B;
var AppState = _createState.AppState;
var di = _createState.di;
var bSetter = _createState.bSetter;
function observableProps() {}
_annotations2.default.observable({ b: B })(observableProps);
var observableProps = _annotations2.default.observable({ b: B });
var di = (0, _createPureStateDi2.default)(new AppState());
var fn = _sinon2.default.spy(function (v) {

@@ -71,3 +65,3 @@ return v;

filepath: 'src/__tests__/DiEventsTest.js',
line: 23
line: 20
}));

@@ -85,7 +79,5 @@ });

var B = _createState2.B;
var AppState = _createState2.AppState;
var di = _createState2.di;
var bSetter = _createState2.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var Observer1 = function Observer1() {

@@ -113,4 +105,3 @@ (0, _classCallCheck3.default)(this, Observer1);

var bSet = di(bSetter);
function observableProps() {}
_annotations2.default.observable({ b: B })(observableProps);
var observableProps = _annotations2.default.observable({ b: B });
observable = di(observableProps).observable;

@@ -126,3 +117,3 @@

filepath: 'src/__tests__/DiEventsTest.js',
line: 51
line: 46
}));

@@ -132,3 +123,3 @@ (0, _powerAssert2.default)(_rec3._expr(_rec3._capt(_rec3._capt(_rec3._capt(_rec3._capt(observer1, 'arguments/0/callee/object/object/object').next, 'arguments/0/callee/object/object').firstCall, 'arguments/0/callee/object').calledWith(_rec3._capt({ b: _rec3._capt({ v: 321 }, 'arguments/0/arguments/0/properties/0/value') }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 52
line: 47
}));

@@ -139,3 +130,3 @@

filepath: 'src/__tests__/DiEventsTest.js',
line: 54
line: 49
}));

@@ -145,3 +136,3 @@ (0, _powerAssert2.default)(_rec5._expr(_rec5._capt(_rec5._capt(_rec5._capt(_rec5._capt(observer2, 'arguments/0/callee/object/object/object').next, 'arguments/0/callee/object/object').firstCall, 'arguments/0/callee/object').calledWith(_rec5._capt({ b: _rec5._capt({ v: 321 }, 'arguments/0/arguments/0/properties/0/value') }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 55
line: 50
}));

@@ -158,6 +149,5 @@ });

var B = _createState3.B;
var AppState = _createState3.AppState;
var di = _createState3.di;
var bSetter = _createState3.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var observer /*: Observer*/ = {

@@ -169,4 +159,3 @@ next: _sinon2.default.spy(),

var bSet = di(bSetter);
function observableProps() {}
_annotations2.default.observable({ b: B })(observableProps);
var observableProps = _annotations2.default.observable({ b: B });
di(observableProps).observable.subscribe(observer);

@@ -179,3 +168,3 @@ bSet(321);

filepath: 'src/__tests__/DiEventsTest.js',
line: 73
line: 66
}));

@@ -185,3 +174,3 @@ (0, _powerAssert2.default)(_rec7._expr(_rec7._capt(_rec7._capt(_rec7._capt(_rec7._capt(observer, 'arguments/0/callee/object/object/object').next, 'arguments/0/callee/object/object').firstCall, 'arguments/0/callee/object').calledWith(_rec7._capt({ b: _rec7._capt({ v: 321 }, 'arguments/0/arguments/0/properties/0/value') }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 74
line: 67
}));

@@ -191,3 +180,3 @@ (0, _powerAssert2.default)(_rec8._expr(_rec8._capt(_rec8._capt(_rec8._capt(_rec8._capt(observer, 'arguments/0/callee/object/object/object').next, 'arguments/0/callee/object/object').secondCall, 'arguments/0/callee/object').calledWith(_rec8._capt({ b: _rec8._capt({ v: 333 }, 'arguments/0/arguments/0/properties/0/value') }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 75
line: 68
}));

@@ -202,7 +191,6 @@ });

var C = _createState4.C;
var AppState = _createState4.AppState;
var di = _createState4.di;
var bSetter = _createState4.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var observer /*: Observer*/ = {

@@ -213,4 +201,3 @@ next: _sinon2.default.spy(),

};
function observableProps() {}
_annotations2.default.observable({ c: C })(observableProps);
var observableProps = _annotations2.default.observable({ c: C });

@@ -224,3 +211,3 @@ di(observableProps).observable.subscribe(observer);

filepath: 'src/__tests__/DiEventsTest.js',
line: 94
line: 85
}));

@@ -236,6 +223,5 @@ });

var B = _createState5.B;
var AppState = _createState5.AppState;
var di = _createState5.di;
var bSetter = _createState5.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var observer /*: Observer*/ = {

@@ -247,4 +233,3 @@ next: _sinon2.default.spy(),

var bSet = di(bSetter);
function observableProps() {}
_annotations2.default.observable({ b: B })(observableProps);
var observableProps = _annotations2.default.observable({ b: B });
var subscription = di(observableProps).observable.subscribe(observer);

@@ -257,3 +242,3 @@ bSet(321);

filepath: 'src/__tests__/DiEventsTest.js',
line: 112
line: 101
}));

@@ -263,3 +248,3 @@ (0, _powerAssert2.default)(_rec11._expr(_rec11._capt(_rec11._capt(_rec11._capt(observer, 'arguments/0/callee/object/object').next, 'arguments/0/callee/object').calledWith(_rec11._capt({ b: _rec11._capt({ v: 321 }, 'arguments/0/arguments/0/properties/0/value') }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 113
line: 102
}));

@@ -275,6 +260,5 @@ });

var B = _createState6.B;
var AppState = _createState6.AppState;
var di = _createState6.di;
var bSetter = _createState6.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var observer /*: Observer*/ = {

@@ -286,4 +270,3 @@ next: _sinon2.default.spy(),

var bSet = di(bSetter);
function observableProps() {}
_annotations2.default.observable({ b: B })(observableProps);
var observableProps = _annotations2.default.observable({ b: B });
var observable = di(observableProps).observable;

@@ -299,3 +282,3 @@ var subscription = observable.subscribe(observer);

filepath: 'src/__tests__/DiEventsTest.js',
line: 134
line: 121
}));

@@ -305,3 +288,3 @@ (0, _powerAssert2.default)(_rec13._expr(_rec13._capt(_rec13._capt(_rec13._capt(observer, 'arguments/0/callee/object/object').next, 'arguments/0/callee/object').calledWith(_rec13._capt({ b: _rec13._capt({ v: 324 }, 'arguments/0/arguments/0/properties/0/value') }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 135
line: 122
}));

@@ -319,6 +302,5 @@ });

var B = _createState7.B;
var AppState = _createState7.AppState;
var di = _createState7.di;
var bSetter = _createState7.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var observerB /*: Observer*/ = {

@@ -336,8 +318,5 @@ next: _sinon2.default.spy(),

function observablePropsB() {}
_annotations2.default.observable({ b: B })(observablePropsB);
var observablePropsB = _annotations2.default.observable({ b: B });
var observablePropsC = _annotations2.default.observable({ c: C });
function observablePropsC() {}
_annotations2.default.observable({ c: C })(observablePropsC);
var observableB = di(observablePropsB).observable;

@@ -353,3 +332,3 @@ var observableC = di(observablePropsC).observable;

filepath: 'src/__tests__/DiEventsTest.js',
line: 166
line: 149
}));

@@ -359,3 +338,3 @@ (0, _powerAssert2.default)(_rec15._expr(_rec15._capt(_rec15._capt(_rec15._capt(observerB, 'arguments/0/callee/object/object').next, 'arguments/0/callee/object').calledWith(_rec15._capt({ b: _rec15._capt({ v: 333 }, 'arguments/0/arguments/0/properties/0/value') }, 'arguments/0/arguments/0')), 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 167
line: 150
}));

@@ -365,3 +344,3 @@ (0, _powerAssert2.default)(_rec16._expr(_rec16._capt(_rec16._capt(_rec16._capt(observerC, 'arguments/0/object/object').next, 'arguments/0/object').notCalled, 'arguments/0'), {

filepath: 'src/__tests__/DiEventsTest.js',
line: 168
line: 151
}));

@@ -368,0 +347,0 @@ });

@@ -14,6 +14,2 @@ 'use strict';

var _createPureStateDi = require('../createPureStateDi');
var _createPureStateDi2 = _interopRequireDefault(_createPureStateDi);
var _TestState = require('./TestState');

@@ -34,6 +30,5 @@

var B = _createState.B;
var AppState = _createState.AppState;
var di = _createState.di;
var aSetter = _createState.aSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var aSet = di(aSetter);

@@ -50,7 +45,7 @@ var MyDep = factory(B)(function (v) {

filepath: 'src/__tests__/DiStateTest.js',
line: 24
line: 22
}), _rec2._expr(_rec2._capt({ v: 321 }, 'arguments/1'), {
content: 'assert.deepEqual(di(MyDep), { v: 321 })',
filepath: 'src/__tests__/DiStateTest.js',
line: 24
line: 22
}));

@@ -66,7 +61,5 @@ });

var A = _createState2.A;
var AppState = _createState2.AppState;
var di = _createState2.di;
var bSetter = _createState2.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var bSet = di(bSetter);

@@ -81,3 +74,3 @@ var MyDep = factory(A)(function (v) {

filepath: 'src/__tests__/DiStateTest.js',
line: 35
line: 31
}), _rec4._expr(_rec4._capt({

@@ -94,3 +87,3 @@ b: _rec4._capt({

filepath: 'src/__tests__/DiStateTest.js',
line: 35
line: 31
}));

@@ -106,7 +99,5 @@ });

var C = _createState3.C;
var AppState = _createState3.AppState;
var di = _createState3.di;
var bSetter = _createState3.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var bSet = di(bSetter);

@@ -122,7 +113,7 @@

filepath: 'src/__tests__/DiStateTest.js',
line: 55
line: 49
}), _rec6._expr(_rec6._capt({ v: 'test' }, 'arguments/1'), {
content: 'assert.deepEqual(di(MyDep), { v: \'test\' })',
filepath: 'src/__tests__/DiStateTest.js',
line: 55
line: 49
}));

@@ -138,7 +129,5 @@ });

var B = _createState4.B;
var AppState = _createState4.AppState;
var di = _createState4.di;
var bSetter = _createState4.bSetter;
var di = (0, _createPureStateDi2.default)(new AppState());
var bSet = di(bSetter);

@@ -154,7 +143,7 @@

filepath: 'src/__tests__/DiStateTest.js',
line: 67
line: 59
}), _rec8._expr(_rec8._capt({ v: 321 }, 'arguments/1'), {
content: 'assert.deepEqual(di(MyDep), { v: 321 })',
filepath: 'src/__tests__/DiStateTest.js',
line: 67
line: 59
}));

@@ -161,0 +150,0 @@ });

@@ -17,2 +17,10 @@ 'use strict';

var _createPureStateDi = require('../createPureStateDi');
var _createPureStateDi2 = _interopRequireDefault(_createPureStateDi);
var _defaultPlugins = require('../defaultPlugins');
var _defaultPlugins2 = _interopRequireDefault(_defaultPlugins);
var _merge = require('../utils/merge');

@@ -90,2 +98,4 @@

var di = (0, _createPureStateDi2.default)(new AppState(), [], _defaultPlugins2.default);
return {

@@ -95,2 +105,3 @@ A: A,

C: C,
di: di,
AppState: AppState,

@@ -97,0 +108,0 @@ aSetter: aSetter,

@@ -11,6 +11,2 @@ 'use strict';

var _create = require('babel-runtime/core-js/object/create');
var _create2 = _interopRequireDefault(_create);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

@@ -28,10 +24,15 @@

var _getFunctionName = require('../utils/getFunctionName');
var _getFunctionName2 = _interopRequireDefault(_getFunctionName);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*:: import type {
AnnotationDriver,
IdCreator,
Annotation,
DepId,
Dependency,
AnyAnnotation,
Tag
Tag,
AnnotationMap
} from 'reactive-di/i/annotationInterfaces'*/

@@ -44,3 +45,2 @@ /*:: import type {

/*:: import type {
AnyDep,
AnnotationResolver,

@@ -50,5 +50,5 @@ ListenerManager,

} from 'reactive-di/i/nodeInterfaces'*/
/*:: import type {FinalizeFn} from 'reactive-di/i/pluginInterfaces'*/
/*:: import type {Plugin} from 'reactive-di/i/pluginInterfaces'*/
// implements ListenerManager

@@ -112,15 +112,15 @@ /*:: type Listener<V, E> = {

// implements AnnotationResolver
/*:: type CacheMap<Dep> = SimpleMap<DepId, Dep>;*/
var AnnotationResolverImpl = function () {
function AnnotationResolverImpl(driver /*: AnnotationDriver*/, middlewares /*: Map<Dependency|Tag, Array<Dependency>>*/, overrides /*: Map<Dependency, Dependency>*/, createCursor /*: CursorCreator*/, plugins /*: SimpleMap<string, Plugin>*/, listeners /*: ListenerManager*/, cache /*: SimpleMap<DepId, AnyDep>*/) {
function AnnotationResolverImpl(middlewares /*: Map<Dependency|Tag, Array<Dependency>>*/, deps /*: AnnotationMap*/, createCursor /*: CursorCreator*/, plugins /*: SimpleMap<string, Plugin>*/, idCreator /*: IdCreator*/, listeners /*: ListenerManager*/, cache /*: CacheMap*/) {
(0, _classCallCheck3.default)(this, AnnotationResolverImpl);
this._driver = driver;
this.middlewares = middlewares;
this._overrides = overrides;
this._deps = deps;
this.createCursor = createCursor;
this._parents = [];
this._plugins = plugins;
this._cache = cache || (0, _create2.default)(null);
this._idCreator = idCreator;
this._cache = cache || {};
this.listeners = listeners || new ListenerManagerImpl();

@@ -132,7 +132,7 @@ }

value: function newRoot() {
return new AnnotationResolverImpl(this._driver, this.middlewares, this._overrides, this.createCursor, this._plugins, this.listeners, this._cache);
return new AnnotationResolverImpl(this.middlewares, this._deps, this.createCursor, this._plugins, this._idCreator, this.listeners, this._cache);
}
}, {
key: 'begin',
value: function begin(dep /*: AnyDep*/) {
value: function begin(dep /*: Dep*/) {
this._parents.push(new _set2.default());

@@ -150,8 +150,8 @@ this._cache[dep.base.id] = dep;

var iterateFn /*: FinalizeFn<T>*/ = this._plugins[dep.kind].finalize;
var plugin /*: Plugin*/ = this._plugins[dep.kind];
function iteratePathSet(relationId /*: DepId*/) /*: void*/ {
var target /*: AnyDep*/ = cache[relationId];
var target /*: ResolvableDep*/ = cache[relationId];
relations.push(relationId);
iterateFn(dep, target);
plugin.finalize(dep, target);
}

@@ -170,30 +170,19 @@ depSet.forEach(iteratePathSet);

}, {
key: 'resolveAnnotation',
value: function resolveAnnotation(annotation /*: AnyAnnotation*/) {
function dummyDependency() /*: void*/ {}
return this.resolve(this._driver.annotate(dummyDependency, annotation));
key: 'createId',
value: function createId() {
return this._idCreator.createId();
}
}, {
key: 'resolve',
value: function resolve(annotatedDep /*: Dependency*/) {
var parents = this._parents;
var annotation /*: AnyAnnotation*/ = this._driver.getAnnotation(annotatedDep);
var _annotation = annotation;
var base = _annotation.base;
var dep /*: AnyDep*/ = this._cache[base.id];
key: 'resolveAnnotation',
value: function resolveAnnotation(annotation /*: Annotation*/) {
var dep /*: ?Dep*/ = this._cache[annotation.id];
if (!dep) {
var overridedDep /*: ?Dependency*/ = this._overrides.get(annotatedDep);
if (overridedDep) {
annotation = this._driver.getAnnotation(overridedDep);
annotation.base.id = base.id;
}
var plugin /*: Plugin*/ = this._plugins[annotation.kind];
var plugin /*: ?Plugin*/ = this._plugins[annotation.kind];
if (!plugin) {
throw new Error('Plugin not found for annotation ' + annotation.base.info.displayName);
throw new Error('Plugin not found for annotation ' + (0, _getFunctionName2.default)(annotation.target));
}
plugin.create(annotation, (this /*: AnnotationResolver*/));
dep = this._cache[base.id];
} else if (parents.length) {
dep = this._cache[annotation.id];
} else if (this._parents.length) {
var parents = this._parents;
var relations = dep.base.relations;

@@ -211,2 +200,17 @@

}
}, {
key: '_getAnnotation',
value: function _getAnnotation(annotatedDep /*: Dependency*/) {
var annotation /*: ?Annotation*/ = this._deps.get(annotatedDep);
if (!annotation) {
throw new Error('Can\'t find annotation for ' + (0, _getFunctionName2.default)(annotatedDep));
}
return annotation;
}
}, {
key: 'resolve',
value: function resolve(annotatedDep /*: Dependency*/) {
return this.resolveAnnotation(this._getAnnotation(annotatedDep));
}
}]);

@@ -213,0 +217,0 @@ return AnnotationResolverImpl;

@@ -11,59 +11,48 @@ 'use strict';

exports.default = createPureStateDi;
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _createPureCursorCreator = require('./model/pure/createPureCursorCreator');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _createPureCursorCreator2 = _interopRequireDefault(_createPureCursorCreator);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _AnnotationResolverImpl = require('./core/AnnotationResolverImpl');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _AnnotationResolverImpl2 = _interopRequireDefault(_AnnotationResolverImpl);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _ClassPlugin = require('./plugins/class/ClassPlugin');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ClassPlugin2 = _interopRequireDefault(_ClassPlugin);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _FactoryPlugin = require('./plugins/factory/FactoryPlugin');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _FactoryPlugin2 = _interopRequireDefault(_FactoryPlugin);
var _get2 = require('babel-runtime/helpers/get');
var _GetterPlugin = require('./plugins/getter/GetterPlugin');
var _get3 = _interopRequireDefault(_get2);
var _GetterPlugin2 = _interopRequireDefault(_GetterPlugin);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _LoaderPlugin = require('./plugins/loader/LoaderPlugin');
var _inherits3 = _interopRequireDefault(_inherits2);
var _LoaderPlugin2 = _interopRequireDefault(_LoaderPlugin);
exports.default = createPureStateDi;
var _MetaPlugin = require('./plugins/meta/MetaPlugin');
var _createPureCursorCreator = require('./model/pure/createPureCursorCreator');
var _MetaPlugin2 = _interopRequireDefault(_MetaPlugin);
var _createPureCursorCreator2 = _interopRequireDefault(_createPureCursorCreator);
var _ModelPlugin = require('./plugins/model/ModelPlugin');
var _AnnotationResolverImpl = require('./core/AnnotationResolverImpl');
var _ModelPlugin2 = _interopRequireDefault(_ModelPlugin);
var _AnnotationResolverImpl2 = _interopRequireDefault(_AnnotationResolverImpl);
var _ObservablePlugin = require('./plugins/observable/ObservablePlugin');
var _SymbolMetaDriver = require('./drivers/SymbolMetaDriver');
var _ObservablePlugin2 = _interopRequireDefault(_ObservablePlugin);
var _SymbolMetaDriver2 = _interopRequireDefault(_SymbolMetaDriver);
var _ResetPlugin = require('./plugins/loader/ResetPlugin');
var _DefaultIdCreator = require('./core/DefaultIdCreator');
var _ResetPlugin2 = _interopRequireDefault(_ResetPlugin);
var _DefaultIdCreator2 = _interopRequireDefault(_DefaultIdCreator);
var _SyncSetterPlugin = require('./plugins/setter/SyncSetterPlugin');
var _SyncSetterPlugin2 = _interopRequireDefault(_SyncSetterPlugin);
var _AsyncSetterPlugin = require('./plugins/setter/AsyncSetterPlugin');
var _AsyncSetterPlugin2 = _interopRequireDefault(_AsyncSetterPlugin);
var _SymbolMetaDriver = require('./drivers/SymbolMetaDriver');
var _SymbolMetaDriver2 = _interopRequireDefault(_SymbolMetaDriver);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*:: import type {
Annotation,
AnnotationDriver,

@@ -75,22 +64,65 @@ Dependency,

/*:: import type {GetDep} from 'reactive-di/i/diInterfaces'*/
function createPureStateDi /*:: <T: Object>*/(state /*: T*/, plugins /*: Map<string, Object>*/, middlewares /*: Map<Dependency|Tag, Array<Dependency>>*/, overrides /*: Map<Dependency, Dependency>*/) /*: GetDep*/ {
var driver /*: AnnotationDriver*/ = new _SymbolMetaDriver2.default();
var resolver /*: AnnotationResolver*/ = new _AnnotationResolverImpl2.default(driver, middlewares || new _map2.default(), overrides || new _map2.default(), (0, _createPureCursorCreator2.default)(driver, state), {
class: new _ClassPlugin2.default(),
factory: new _FactoryPlugin2.default(),
asyncsetter: new _AsyncSetterPlugin2.default(),
syncsetter: new _SyncSetterPlugin2.default(),
getter: new _GetterPlugin2.default(),
model: new _ModelPlugin2.default(),
loader: new _LoaderPlugin2.default(),
reset: new _ResetPlugin2.default(),
observable: new _ObservablePlugin2.default(),
meta: new _MetaPlugin2.default()
});
/*:: import type {SimpleMap} from 'reactive-di/i/modelInterfaces'*/
/*:: import type {Plugin} from 'reactive-di/i/pluginInterfaces'*/
function createPluginsMap(plugins /*: Array<Plugin>*/) /*: SimpleMap<string, Plugin>*/ {
var pluginMap /*: SimpleMap<string, Plugin>*/ = {};
for (var i = 0, l = plugins.length; i < l; i++) {
pluginMap[plugins[i].kind] = plugins[i];
}
return pluginMap;
}
var AnnotationMap = function (_Map) {
(0, _inherits3.default)(AnnotationMap, _Map);
function AnnotationMap /*:: <K: Function, A: Annotation>*/(deps /*: Array<Annotation>*/, driver /*: AnnotationDriver*/) {
(0, _classCallCheck3.default)(this, AnnotationMap);
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(AnnotationMap).call(this));
for (var i = 0, l = deps.length; i < l; i++) {
var annotation /*: Annotation*/ = deps[i];
_this.set(annotation.target, (annotation /*: any*/));
}
_this._driver = driver;
return _this;
}
(0, _createClass3.default)(AnnotationMap, [{
key: 'has',
value: function has(key /*: K*/) {
if (!(0, _get3.default)((0, _getPrototypeOf2.default)(AnnotationMap.prototype), 'has', this).call(this, key)) {
return this._driver.hasAnnotation(key);
}
return true;
}
}, {
key: 'get',
value: function get( /*:: <V: Annotation> */key /*: K*/) {
// eslint-disable-line
var value /*: ?V*/ = ((0, _get3.default)((0, _getPrototypeOf2.default)(AnnotationMap.prototype), 'get', this).call(this, key) /*: any*/);
if (!value) {
value = this._driver.getAnnotation(key);
if (value) {
this.set(key, value);
}
}
return value;
}
}]);
return AnnotationMap;
}(_map2.default);
function createPureStateDi /*:: <T: Object>*/(state /*: T*/, deps /*: Array<Annotation>*/, plugins /*: Array<Plugin>*/, middlewares /*: Map<Dependency|Tag, Array<Dependency>>*/) /*: GetDep*/ {
var map /*: Map<Function, Annotation>*/ = new AnnotationMap(deps, new _SymbolMetaDriver2.default());
var resolver /*: AnnotationResolver*/ = new _AnnotationResolverImpl2.default(middlewares || new _map2.default(), map, (0, _createPureCursorCreator2.default)(map, state), createPluginsMap(plugins), new _DefaultIdCreator2.default());
resolver.resolve(state.constructor);
return function getDep /*:: <V>*/(annotatedDep /*: Dependency<V>*/) /*: V*/ {
return ((resolver.resolve(annotatedDep).resolve() /*: any*/) /*: V*/);
return function getDep /*:: <D>*/(annotatedDep /*: Dependency<D>*/) /*: D*/ {
return ((resolver.resolve(annotatedDep).resolve() /*: any*/) /*: D*/);
};
}
//# sourceMappingURL=createPureStateDi.js.map

@@ -14,6 +14,4 @@ 'use strict';

var _FactoryAnnotationImpl = require('../../plugins/factory/FactoryAnnotationImpl');
var _factory = require('../../plugins/factory/factory');
var _FactoryAnnotationImpl2 = _interopRequireDefault(_FactoryAnnotationImpl);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -26,3 +24,3 @@

function fn() {}
var meta = new _FactoryAnnotationImpl2.default('id1', fn, null, []);
var meta = (0, _factory.factory)(fn);
var driver = new _SymbolMetaDriver2.default();

@@ -29,0 +27,0 @@ driver.annotate(fn, meta);

@@ -23,3 +23,3 @@ 'use strict';

AnnotationDriver, // eslint-disable-line
AnyAnnotation,
Annotation,
Dependency

@@ -26,0 +26,0 @@ } from 'reactive-di/i/annotationInterfaces'*/

@@ -6,8 +6,4 @@ 'use strict';

});
exports.promiseToObservable = exports.merge = exports.getFunctionName = exports.createAnnotations = exports.createPureStateDi = exports.BaseCollection = exports.SymbolMetaDriver = exports.DefaultIdCreator = undefined;
exports.merge = exports.getFunctionName = exports.createPureStateDi = exports.BaseCollection = exports.SymbolMetaDriver = exports.DefaultIdCreator = exports.defaultPlugins = undefined;
var _createAnnotations = require('./createAnnotations');
var _createAnnotations2 = _interopRequireDefault(_createAnnotations);
var _createPureStateDi = require('./createPureStateDi');

@@ -25,6 +21,2 @@

var _promiseToObservable = require('./utils/promiseToObservable');
var _promiseToObservable2 = _interopRequireDefault(_promiseToObservable);
var _BaseCollection = require('./utils/BaseCollection');

@@ -42,4 +34,9 @@

var _defaultPlugins = require('./defaultPlugins');
var _defaultPlugins2 = _interopRequireDefault(_defaultPlugins);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.defaultPlugins = _defaultPlugins2.default;
exports.DefaultIdCreator = _DefaultIdCreator2.default;

@@ -49,6 +46,4 @@ exports.SymbolMetaDriver = _SymbolMetaDriver2.default;

exports.createPureStateDi = _createPureStateDi2.default;
exports.createAnnotations = _createAnnotations2.default;
exports.getFunctionName = _getFunctionName2.default;
exports.merge = _merge2.default;
exports.promiseToObservable = _promiseToObservable2.default;
//# sourceMappingURL=index.js.map

@@ -18,3 +18,3 @@ 'use strict';

/*:: import type {AnnotationDriver} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {Annotation} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {

@@ -27,4 +27,4 @@ Cursor,

// implements CursorCreator
function createPureCursorCreator /*:: <S: Object>*/(driver /*: AnnotationDriver*/, state /*: S*/) /*: CursorCreator*/ {
(0, _setupStateAnnotations2.default)(driver, state);
function createPureCursorCreator /*:: <S: Object>*/(map /*: Map<Function, Annotation>*/, state /*: S*/) /*: CursorCreator*/ {
(0, _setupStateAnnotations2.default)(map, state);
var stateRef /*: {state: S}*/ = { state: state };

@@ -31,0 +31,0 @@ return function createPureCursor /*:: <V: Object>*/(path /*: Array<string>*/) /*: Cursor<V>*/ {

@@ -19,3 +19,3 @@ 'use strict';

/*:: import type {AnnotationDriver} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {AnnotationMap} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {

@@ -44,18 +44,12 @@ FromJS,

function setupStateAnnotations /*:: <T: Object>*/(driver /*: AnnotationDriver*/, obj /*: T*/) /*: FromJS<T>*/ {
function setupStateAnnotations /*:: <T: Object>*/(annotationMap /*: AnnotationMap*/, obj /*: T*/) /*: FromJS<T>*/ {
var statePath /*: Array<string>*/ = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
var annotation /*: ModelAnnotation*/ = undefined;
try {
annotation = driver.getAnnotation(obj.constructor);
} catch (e) {
e.message = e.message + ', path: ' + statePath.join('.');
throw e;
var annotation /*: ?ModelAnnotation*/ = annotationMap.get(obj.constructor);
if (!annotation) {
throw new Error('Annotation not found for path: ' + statePath.join('.'));
}
var _annotation = annotation;
var info = _annotation.info;
if (!info.statePath.length) {
info.statePath = statePath;
if (!annotation.statePath.length) {
annotation.statePath = statePath;
var keys /*: Array<string>*/ = (0, _keys2.default)(obj);

@@ -66,13 +60,13 @@ var propCreators /*: PropCreatorMap*/ = {};

var prop /*: any*/ = obj[key];
if (prop !== null && (typeof prop === 'undefined' ? 'undefined' : (0, _typeof3.default)(prop)) === 'object' && driver.hasAnnotation(prop.constructor)) {
info.childs.push(prop.constructor);
propCreators[key] = setupStateAnnotations(driver, prop, statePath.concat(key));
if (prop !== null && (typeof prop === 'undefined' ? 'undefined' : (0, _typeof3.default)(prop)) === 'object' && annotationMap.has(prop.constructor)) {
annotation.childs.push(prop.constructor);
propCreators[key] = setupStateAnnotations(annotationMap, prop, statePath.concat(key));
}
}
var fromJS /*: FromJS<T>*/ = createFromJS(obj.constructor, propCreators);
info.fromJS = fromJS;
annotation.fromJS = fromJS;
}
return info.fromJS;
return annotation.fromJS;
}
//# sourceMappingURL=setupStateAnnotations.js.map

@@ -37,11 +37,7 @@ 'use strict';

/*:: import type {
DepId,
Info
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
DepArgs,
AnyDep,
DepBase
} from 'reactive-di/i/nodeInterfaces'*/
/*:: import type {AnnotationResolver} from 'reactive-di/i/nodeInterfaces'*/
/*:: import type {ClassAnnotation} from 'reactive-di/i/plugins/classInterfaces'*/
// eslint-disable-line

@@ -52,14 +48,11 @@ /*:: import type {Plugin} from 'reactive-di/i/pluginInterfaces'*/

// implements ClassDep
/*:: import type {
ClassDep,
ClassAnnotation
} from 'reactive-di/i/plugins/classInterfaces'*/
/*:: import type {ClassDep} from 'reactive-di/i/plugins/classInterfaces'*/
var ClassDepImpl = exports.ClassDepImpl = function () {
function ClassDepImpl /*:: <V: Object>*/(id /*: DepId*/, info /*: Info*/, target /*: Class<V>*/) {
function ClassDepImpl /*:: <V: Object>*/(annotation /*: ClassAnnotation<V>*/) {
(0, _classCallCheck3.default)(this, ClassDepImpl);
this.kind = 'class';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this._target = target;
this.base = new _pluginImpls.DepBaseImpl(annotation);
this._target = annotation.target;
}

@@ -99,2 +92,3 @@

(0, _classCallCheck3.default)(this, ClassPlugin);
this.kind = 'class';
}

@@ -105,8 +99,7 @@

value: function create(annotation /*: ClassAnnotation<V>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var dep /*: ClassDepImpl<V>*/ = new ClassDepImpl(base.id, base.info, base.target);
annotation.id = acc.createId(); // eslint-disable-line
var dep /*: ClassDepImpl<V>*/ = new ClassDepImpl(annotation);
var resolver = new _DepsResolverImpl2.default(acc);
acc.begin(dep);
dep.init(resolver.getDeps(annotation.deps, base.target, base.info.tags));
dep.init(resolver.getDeps(annotation.deps, annotation.target, dep.base.tags));
acc.end(dep);

@@ -116,4 +109,4 @@ }

key: 'finalize',
value: function finalize(dep /*: ClassDep*/, target /*: AnyDep*/) {
(0, _defaultFinalizer2.default)(dep, target);
value: function finalize(dep /*: ClassDep*/, target /*: Dep*/) {
(0, _defaultFinalizer2.default)(dep.base, target);
}

@@ -120,0 +113,0 @@ }]);

@@ -37,9 +37,6 @@ 'use strict';

/*:: import type {
DepFn,
DepId,
Info
DepFn
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
DepArgs,
AnyDep,
DepBase,

@@ -59,8 +56,8 @@ AnnotationResolver

var FactoryDepImpl = exports.FactoryDepImpl = function () {
function FactoryDepImpl /*:: <V: any>*/(id /*: DepId*/, info /*: Info*/, target /*: DepFn<V>*/) {
function FactoryDepImpl /*:: <V: any>*/(annotation /*: FactoryAnnotation<V>*/) {
(0, _classCallCheck3.default)(this, FactoryDepImpl);
this.kind = 'factory';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this._target = target;
this.base = new _pluginImpls.DepBaseImpl(annotation);
this._target = annotation.target;
}

@@ -88,3 +85,3 @@

if (typeof fn !== 'function') {
throw new Error('No callable returns from ' + this.base.info.displayName);
throw new Error('No callable returns from ' + this.base.displayName);
}

@@ -109,2 +106,3 @@ fn = (0, _createProxy.createFunctionProxy)(fn, middlewares);

(0, _classCallCheck3.default)(this, FactoryPlugin);
this.kind = 'factory';
}

@@ -115,8 +113,7 @@

value: function create(annotation /*: FactoryAnnotation<V>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var dep /*: FactoryDepImpl<V>*/ = new FactoryDepImpl(base.id, base.info, base.target);
annotation.id = acc.createId(); // eslint-disable-line
var dep = new FactoryDepImpl(annotation);
var resolver = new _DepsResolverImpl2.default(acc);
acc.begin(dep);
dep.init(resolver.getDeps(annotation.deps, base.target, base.info.tags));
dep.init(resolver.getDeps(annotation.deps, annotation.target, dep.base.tags));
acc.end(dep);

@@ -127,3 +124,3 @@ }

value: function finalize(dep /*: FactoryDep*/, target /*: AnyDep*/) {
(0, _defaultFinalizer2.default)(dep, target);
(0, _defaultFinalizer2.default)(dep.base, target);
}

@@ -130,0 +127,0 @@ }]);

@@ -19,6 +19,2 @@ 'use strict';

var _AsyncSetterAnnotationImpl = require('../setter/AsyncSetterAnnotationImpl');
var _AsyncSetterAnnotationImpl2 = _interopRequireDefault(_AsyncSetterAnnotationImpl);
var _pluginImpls = require('../../pluginsCommon/pluginImpls');

@@ -29,7 +25,2 @@

/*:: import type {
DepId,
Info
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
AnyDep,
DepBase,

@@ -48,13 +39,14 @@ AnnotationResolver

} from 'reactive-di/i/plugins/loaderInterfaces'*/
/*:: import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'*/
// implements LoaderDep
/*:: import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'*/
/*:: import type {AsyncSetterAnnotation} from 'reactive-di/i/plugins/setterInterfaces'*/
var LoaderDepImpl = function () {
function LoaderDepImpl /*:: <V: Object>*/(id /*: DepId*/, info /*: Info*/) {
function LoaderDepImpl /*:: <V: Object>*/(annotation /*: LoaderAnnotation<V, E>*/) {
(0, _classCallCheck3.default)(this, LoaderDepImpl);
this.kind = 'loader';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this.base = new _pluginImpls.DepBaseImpl(annotation);
this._setter = null;

@@ -103,2 +95,3 @@ }

(0, _classCallCheck3.default)(this, LoaderPlugin);
this.kind = 'loader';
}

@@ -109,14 +102,21 @@

value: function create(annotation /*: LoaderAnnotation<V, E>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var dep /*: LoaderDepImpl<V>*/ = new LoaderDepImpl(base.id, base.info);
var id = annotation.id = acc.createId(); // eslint-disable-line
var dep /*: LoaderDepImpl<V>*/ = new LoaderDepImpl(annotation);
acc.begin(dep);
var model /*: AnyDep*/ = acc.resolve(annotation.model);
var model /*: ModelDep*/ = acc.resolve(annotation.model);
if (model.kind !== 'model') {
throw new Error('Not an model ' + model.base.info.displayName + ' in ' + base.info.displayName);
throw new Error('Not an model ' + model.base.displayName + ' in ' + dep.base.displayName);
}
var setterDep /*: AnyDep*/ = acc.resolveAnnotation(new _AsyncSetterAnnotationImpl2.default(base.id + '.setter', annotation.model, base.target, annotation.deps, base.info.tags));
var asyncSetterAnnotation /*: AsyncSetterAnnotation<V, E>*/ = {
kind: 'asyncsetter',
id: model.base.id + '.asyncsetter',
model: annotation.model,
deps: annotation.deps,
target: annotation.target
};
var setterDep /*: AsyncSetterDep*/ = acc.resolveAnnotation(asyncSetterAnnotation);
if (setterDep.kind !== 'asyncsetter') {
throw new Error('Not a setter: ' + setterDep.base.info.displayName + ' in ' + base.info.displayName);
throw new Error('Not a setter: ' + setterDep.base.displayName + ' in ' + dep.base.displayName);
}

@@ -130,4 +130,4 @@

key: 'finalize',
value: function finalize(dep /*: LoaderDep*/, target /*: AnyDep*/) {
(0, _defaultFinalizer2.default)(dep, target);
value: function finalize(dep /*: LoaderDep*/, target /*: Dep*/) {
(0, _defaultFinalizer2.default)(dep.base, target);
}

@@ -134,0 +134,0 @@ }]);

@@ -20,7 +20,2 @@ 'use strict';

/*:: import type {
DepId,
Info
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
AnyDep,
DepBase,

@@ -41,7 +36,7 @@ AnnotationResolver

var ResetDepImpl = function () {
function ResetDepImpl /*:: <V: () => void>*/(id /*: DepId*/, info /*: Info*/, loaderDep /*: LoaderDep<V>*/) {
function ResetDepImpl /*:: <V: Object, E>*/(annotation /*: ResetAnnotation<V, E>*/, loaderDep /*: LoaderDep<V>*/) {
(0, _classCallCheck3.default)(this, ResetDepImpl);
this.kind = 'reset';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this.base = new _pluginImpls.DepBaseImpl(annotation);
function reset() /*: void*/ {

@@ -69,2 +64,3 @@ loaderDep.reset();

(0, _classCallCheck3.default)(this, ResetPlugin);
this.kind = 'reset';
}

@@ -74,10 +70,9 @@

key: 'create',
value: function create(annotation /*: ResetAnnotation*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var loaderDep /*: AnyDep*/ = acc.newRoot().resolve(base.target);
value: function create(annotation /*: ResetAnnotation<V, E>*/, acc /*: AnnotationResolver*/) {
var loaderDep /*: LoaderDep<V>*/ = acc.resolve(annotation.target);
annotation.id = loaderDep.base.id + '.reset'; // eslint-disable-line
if (loaderDep.kind !== 'loader') {
throw new Error('Not a loader as target in ' + base.info.displayName);
throw new Error('Not a loader as target in ' + loaderDep.base.displayName);
}
var dep /*: ResetDep*/ = new ResetDepImpl(base.id, base.info, loaderDep);
var dep /*: ResetDep*/ = new ResetDepImpl(annotation, loaderDep);
acc.begin(dep);

@@ -88,3 +83,3 @@ acc.end(dep);

key: 'finalize',
value: function finalize(dep /*: ResetDep*/, target /*: AnyDep*/) {} // eslint-disable-line
value: function finalize(dep /*: ResetDep*/, target /*: Dep*/) {} // eslint-disable-line

@@ -91,0 +86,0 @@ }]);

@@ -24,7 +24,5 @@ 'use strict';

/*:: import type {
DepId,
Info
DepId
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
AnyDep,
DepBase,

@@ -41,2 +39,3 @@ AnnotationResolver

} from 'reactive-di/i/plugins/metaInterfaces'*/
/*:: import type {AsyncSetterDep} from 'reactive-di/i/plugins/setterInterfaces'*/

@@ -76,7 +75,7 @@

var MetaDepImpl = function () {
function MetaDepImpl /*:: <E>*/(id /*: DepId*/, info /*: Info*/) {
function MetaDepImpl /*:: <E>*/(annotation /*: MetaAnnotation<E>*/) {
(0, _classCallCheck3.default)(this, MetaDepImpl);
this.kind = 'meta';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this.base = new _pluginImpls.DepBaseImpl(annotation);
this.sources = [];

@@ -119,2 +118,3 @@ this._value = new _pluginImpls.EntityMetaImpl({

(0, _classCallCheck3.default)(this, MetaPlugin);
this.kind = 'meta';
}

@@ -125,10 +125,9 @@

value: function create(annotation /*: MetaAnnotation<E>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var id /*: DepId*/ = annotation.id = acc.createId(); // eslint-disable-line
var dep /*: MetaDep<E>*/ = new MetaDepImpl(annotation);
var dep /*: MetaDep<E>*/ = new MetaDepImpl(base.id, base.info);
acc.addRelation(base.id);
acc.addRelation(id);
var newAcc /*: AnnotationResolver*/ = acc.newRoot();
newAcc.begin(dep);
newAcc.resolve(base.target);
newAcc.resolve(annotation.target);
newAcc.end(dep);

@@ -138,3 +137,3 @@ }

key: 'finalize',
value: function finalize(dep /*: MetaDep<E>*/, target /*: AnyDep*/) {
value: function finalize(dep /*: MetaDep<E>*/, target /*: Dep|AsyncSetterDep*/) {
if (target.kind === 'asyncsetter') {

@@ -141,0 +140,0 @@ target.metaOwners.push(dep.base);

@@ -20,6 +20,2 @@ 'use strict';

/*:: import type {
DepId,
Info
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
Notify,

@@ -37,2 +33,3 @@ Cursor,

/*:: import type {
ModelAnnotation,
ModelDep // eslint-disable-line

@@ -43,10 +40,10 @@ } from 'reactive-di/i/plugins/modelInterfaces'*/

var ModelDepImpl = function () {
function ModelDepImpl /*:: <V: Object>*/(id /*: DepId*/, info /*: Info*/, cursor /*: Cursor<V>*/, fromJS /*: FromJS<V>*/) {
function ModelDepImpl /*:: <V: Object>*/(annotation /*: ModelAnnotation<V>*/, cursor /*: Cursor<V>*/) {
(0, _classCallCheck3.default)(this, ModelDepImpl);
this.kind = 'model';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this.base.relations.push(id);
this.base = new _pluginImpls.DepBaseImpl(annotation);
this.base.relations.push(annotation.id);
this._cursor = cursor;
this._fromJS = fromJS;
this._fromJS = annotation.fromJS;

@@ -53,0 +50,0 @@ this.dataOwners = [];

@@ -23,3 +23,2 @@ 'use strict';

/*:: import type {
AnyDep,
Cacheable,

@@ -41,2 +40,3 @@ AnnotationResolver

(0, _classCallCheck3.default)(this, ModelPlugin);
this.kind = 'model';
}

@@ -47,12 +47,9 @@

value: function create(annotation /*: ModelAnnotation<V>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var info = annotation.info;
var id /*: string*/ = annotation.id = acc.createId(); // eslint-disable-line
var cursor /*: Cursor<V>*/ = acc.createCursor(annotation.statePath);
var dep /*: ModelDep<V>*/ = new _ModelDepImpl2.default(annotation, cursor);
acc.addRelation(id);
var cursor /*: Cursor<V>*/ = acc.createCursor(info.statePath);
var childs = annotation.childs;
var dep /*: ModelDep<V>*/ = new _ModelDepImpl2.default(base.id, base.info, cursor, info.fromJS);
acc.addRelation(base.id);
var childs = info.childs;
acc.begin(dep);

@@ -66,3 +63,3 @@ for (var i = 0, l = childs.length; i < l; i++) {

key: 'finalize',
value: function finalize(dep /*: ModelDep*/, child /*: AnyDep*/) {
value: function finalize(dep /*: ModelDep*/, child /*: Dep|ModelDep*/) {
var base = dep.base;

@@ -69,0 +66,0 @@

@@ -15,6 +15,2 @@ 'use strict';

var _FactoryAnnotationImpl = require('../factory/FactoryAnnotationImpl');
var _FactoryAnnotationImpl2 = _interopRequireDefault(_FactoryAnnotationImpl);
var _pluginImpls = require('../../pluginsCommon/pluginImpls');

@@ -25,7 +21,2 @@

/*:: import type {
DepId,
Info
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
AnyDep,
DepBase,

@@ -39,13 +30,24 @@ AnnotationResolver

} from 'reactive-di/i/plugins/observableInterfaces'*/
/*:: import type {StatefullObservable} from 'reactive-di/i/statefullObservable'*/
/*:: import type {
FactoryAnnotation
} from 'reactive-di/i/plugins/factoryInterfaces'*/
function getObservableParams /*:: <V: Object>*/(value /*: V*/) /*: V*/ {
return value;
}
// implements ObservableDep
/*:: import type {StatefullObservable} from 'reactive-di/i/statefullObservable'*/
var ObservableDepImpl = function () {
function ObservableDepImpl /*:: <V, E>*/(id /*: DepId*/, info /*: Info*/, observable /*: Observable<V, E>*/, factory /*: FactoryDep<V>*/) {
function ObservableDepImpl /*:: <V: Object, E>*/(annotation /*: ObservableAnnotation<V>*/, factory /*: FactoryDep<V>*/, observable /*: Observable<V, E>*/) {
(0, _classCallCheck3.default)(this, ObservableDepImpl);
this.kind = 'observable';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this.base = new _pluginImpls.DepBaseImpl({
kind: annotation.kind,
id: annotation.id,
target: getObservableParams
});
this._observable = observable;

@@ -74,2 +76,3 @@ this._factory = factory;

(0, _classCallCheck3.default)(this, ObservablePlugin);
this.kind = 'observable';
}

@@ -80,12 +83,16 @@

value: function create(annotation /*: ObservableAnnotation<V>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var factoryDep /*: AnyDep*/ = acc.newRoot().resolveAnnotation(new _FactoryAnnotationImpl2.default(base.id + '.factory', base.target, annotation.deps, base.info.tags));
var id = annotation.id = acc.createId(); // eslint-disable-line
var factoryAnnotation /*: FactoryAnnotation<V>*/ = {
kind: 'factory',
id: id + '.factory',
target: getObservableParams,
deps: [annotation.target]
};
var factoryDep /*: FactoryDep<V>*/ = acc.newRoot().resolveAnnotation(factoryAnnotation);
if (factoryDep.kind !== 'factory') {
throw new Error('Not a factory: ' + factoryDep.base.info.displayName + ' in ' + base.info.displayName);
throw new Error('Not a factory: ' + factoryDep.base.displayName + ' in ' + annotation.kind);
}
var observable /*: Observable<V, E>*/ = acc.listeners.add(factoryDep);
var dep /*: ObservableDep<V, E>*/ = new ObservableDepImpl(base.id, base.info, observable, factoryDep);
var dep /*: ObservableDep<V, E>*/ = new ObservableDepImpl(annotation, factoryDep, observable);
acc.begin(dep);

@@ -96,3 +103,3 @@ acc.end(dep);

key: 'finalize',
value: function finalize(dep /*: ObservableAnnotation*/, target /*: AnyDep*/) {} // eslint-disable-line
value: function finalize(dep /*: ObservableAnnotation*/, target /*: Object*/) {} // eslint-disable-line

@@ -99,0 +106,0 @@ }]);

@@ -26,3 +26,2 @@ 'use strict';

/*:: import type {
AnyDep,
AnnotationResolver

@@ -32,6 +31,2 @@ } from 'reactive-di/i/nodeInterfaces'*/

/*:: import type {Plugin} from 'reactive-di/i/pluginInterfaces'*/
// depends on factory, model
// implements Plugin
/*:: import type {

@@ -42,5 +37,11 @@ AsyncSetterDep,

// depends on factory, model
// implements Plugin
/*:: import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'*/
var AsyncSetterPlugin = function () {
function AsyncSetterPlugin() {
(0, _classCallCheck3.default)(this, AsyncSetterPlugin);
this.kind = 'asyncsetter';
}

@@ -51,14 +52,13 @@

value: function create(annotation /*: AsyncSetterAnnotation<V, E>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var id = annotation.id = acc.createId(); // eslint-disable-line
var newAcc = acc.newRoot();
var model /*: AnyDep*/ = newAcc.resolve(annotation.model);
var model /*: ModelDep<V>*/ = newAcc.resolve(annotation.model);
if (model.kind !== 'model') {
throw new Error('Not a model dep type: ' + model.kind + ' in ' + model.base.info.displayName);
}
var dep /*: AsyncSetterDepImpl<V, E>*/ = new _AsyncSetterDepImpl2.default(base.id, base.info, newAcc.listeners.notify, model);
var dep /*: AsyncSetterDepImpl<V, E>*/ = new _AsyncSetterDepImpl2.default(annotation, newAcc.listeners.notify, model);
newAcc.begin(dep);
dep.setInvoker((0, _createSetterInvoker2.default)(base.target, annotation.deps, base.info.tags, model, newAcc));
dep.setInvoker((0, _createSetterInvoker2.default)(annotation.target, annotation.deps, dep.base.tags, model, newAcc));
newAcc.end(dep);
acc.addRelation(base.id);
acc.addRelation(id);
var childSetters = dep.childSetters;

@@ -72,3 +72,3 @@

key: 'finalize',
value: function finalize(dep /*: AsyncSetterDep*/, target /*: AnyDep*/) {
value: function finalize(dep /*: AsyncSetterDep*/, target /*: Object|AsyncSetterDep*/) {
if (target.kind === 'asyncsetter') {

@@ -75,0 +75,0 @@ dep.childSetters.push(target);

@@ -30,6 +30,2 @@ 'use strict';

/*:: import type {
DepId,
Info
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
EntityMeta,

@@ -48,2 +44,3 @@ DepBase,

/*:: import type {ExposedPromise} from 'reactive-di/plugins/setter/impl/asyncHelpers'*/
/*:: import type {AsyncSetterAnnotation} from 'reactive-di/i/plugins/setterInterfaces'*/

@@ -89,7 +86,7 @@

var AsyncSetterDepImpl = function () {
function AsyncSetterDepImpl /*:: <V: Object, E>*/(id /*: DepId*/, info /*: Info*/, notify /*: () => void*/, model /*: ModelDep<V>*/) {
function AsyncSetterDepImpl /*:: <V: Object, E>*/(annotation /*: AsyncSetterAnnotation<V, E>*/, notify /*: () => void*/, model /*: ModelDep<V>*/) {
(0, _classCallCheck3.default)(this, AsyncSetterDepImpl);
this.kind = 'asyncsetter';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this.base = new _pluginImpls.DepBaseImpl(annotation);
this.metaOwners = [];

@@ -125,3 +122,3 @@ this.meta = new _pluginImpls.EntityMetaImpl({ fulfilled: true });

};
this._value.displayName = this.base.info.displayName + '@setValue';
this._value.displayName = this.base.displayName + '@setValue';
}

@@ -178,3 +175,3 @@

} else {
throw new Error(this.base.info.displayName + ' must return Promise or Observable in AsyncResult');
throw new Error(this.base.displayName + ' must return Promise or Observable in AsyncResult');
}

@@ -181,0 +178,0 @@

@@ -32,3 +32,3 @@ 'use strict';

Tag,
Deps
DepItem
} from 'reactive-di/i/annotationInterfaces'*/

@@ -77,3 +77,3 @@ /*:: import type {

function createSetterInvoker /*:: <V: Object, I>*/(target /*: Dependency*/, deps /*: ?Deps*/, tags /*: Array<Tag>*/, model /*: ModelDep<V>*/, acc /*: AnnotationResolver*/) /*: Invoker<I>*/ {
function createSetterInvoker /*:: <V: Object, I>*/(target /*: Dependency*/, deps /*: Array<DepItem>*/, tags /*: Array<Tag>*/, model /*: ModelDep<V>*/, acc /*: AnnotationResolver*/) /*: Invoker<I>*/ {
var resolver = new _DepsResolverImpl2.default(acc);

@@ -80,0 +80,0 @@ var depArgs /*: DepArgs*/ = resolver.getDeps(deps, target, tags);

@@ -20,6 +20,2 @@ 'use strict';

/*:: import type {
DepId,
Info
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {
Invoker,

@@ -32,13 +28,14 @@ DepBase

} from 'reactive-di/i/plugins/setterInterfaces'*/
/*:: import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'*/
// implements SyncSetterDep
/*:: import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'*/
/*:: import type {SyncSetterAnnotation} from 'reactive-di/i/plugins/setterInterfaces'*/
var SyncSetterDepImpl = function () {
function SyncSetterDepImpl /*:: <V: Object>*/(id /*: DepId*/, info /*: Info*/, notify /*: () => void*/, model /*: ModelDep<V>*/, setterInvoker /*: Invoker<V>*/) {
function SyncSetterDepImpl /*:: <V: Object>*/(annotation /*: SyncSetterAnnotation<V>*/, notify /*: () => void*/, model /*: ModelDep<V>*/, setterInvoker /*: Invoker<V>*/) {
(0, _classCallCheck3.default)(this, SyncSetterDepImpl);
this.kind = 'syncsetter';
this.base = new _pluginImpls.DepBaseImpl(id, info);
this.base = new _pluginImpls.DepBaseImpl(annotation);
this._value = function setValue() /*: void*/ {

@@ -45,0 +42,0 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

@@ -25,12 +25,5 @@ 'use strict';

/*:: import type {
AnyDep,
AnnotationResolver
} from 'reactive-di/i/nodeInterfaces'*/
/*:: import type {AnnotationResolver} from 'reactive-di/i/nodeInterfaces'*/
// eslint-disable-line
/*:: import type {Plugin} from 'reactive-di/i/pluginInterfaces'*/
// depends on factory, model
// implements Plugin
/*:: import type {

@@ -41,5 +34,11 @@ SyncSetterDep,

// depends on factory, model
// implements Plugin
/*:: import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'*/
var SyncSetterPlugin = function () {
function SyncSetterPlugin() {
(0, _classCallCheck3.default)(this, SyncSetterPlugin);
this.kind = 'syncsetter';
}

@@ -50,10 +49,9 @@

value: function create(annotation /*: SyncSetterAnnotation<V>*/, acc /*: AnnotationResolver*/) {
var base = annotation.base;
var id = annotation.id = acc.createId(); // eslint-disable-line
var newAcc = acc.newRoot();
var model /*: AnyDep*/ = newAcc.resolve(annotation.model);
var model /*: ModelDep<V>*/ = newAcc.resolve(annotation.model);
if (model.kind !== 'model') {
throw new Error('Not a model dep type: ' + model.kind + ' in ' + model.base.info.displayName);
throw new Error('Not a model dep type: ' + model.kind + ' in ' + model.base.displayName);
}
var dep /*: SyncSetterDepImpl<V>*/ = new _SyncSetterDepImpl2.default(base.id, base.info, newAcc.listeners.notify, model, (0, _createSetterInvoker2.default)(base.target, annotation.deps, base.info.tags, model, newAcc));
var dep /*: SyncSetterDepImpl<V>*/ = new _SyncSetterDepImpl2.default(annotation, newAcc.listeners.notify, model, (0, _createSetterInvoker2.default)(annotation.target, annotation.deps, [annotation.kind], model, newAcc));
newAcc.begin(dep);

@@ -64,3 +62,3 @@ newAcc.end(dep);

key: 'finalize',
value: function finalize(dep /*: SyncSetterDep*/, target /*: AnyDep*/) {} // eslint-disable-line
value: function finalize(dep /*: SyncSetterDep*/, target /*: Object*/) {} // eslint-disable-line

@@ -67,0 +65,0 @@ }]);

@@ -7,12 +7,11 @@ 'use strict';

exports.default = defaultFinalizer;
/*:: import type {
Cacheable,
AnyDep
} from 'reactive-di/i/nodeInterfaces'*/
function defaultFinalizer(dep /*: AnyDep*/, target /*: AnyDep*/) /*: void*/ {
var base = dep.base;
/*:: import type {Cacheable} from 'reactive-di/i/nodeInterfaces'*/
/*:: import type {MetaDep} from 'reactive-di/i/plugins/metaInterfaces'*/
/*:: import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'*/
/*:: import type {AsyncSetterDep} from 'reactive-di/i/plugins/setterInterfaces'*/
/*:: export type AnyDep = ModelDep | AsyncSetterDep | MetaDep;*/
function defaultFinalizer(base /*: Cacheable*/, target /*: AnyDep*/) /*: void*/ {
switch (target.kind) {
case 'model':
target.dataOwners.push((base /*: Cacheable*/));
target.dataOwners.push(base);
break;

@@ -28,3 +27,3 @@ case 'asyncsetter':

metaOwners.push((base /*: Cacheable*/));
metaOwners.push(base);
}

@@ -34,5 +33,5 @@ break;

default:
throw new TypeError('Unhandlered dep type: ' + target.base.info.displayName);
throw new TypeError('Unhandlered dep type: ' + target.base.displayName);
}
}
//# sourceMappingURL=defaultFinalizer.js.map

@@ -24,7 +24,7 @@ 'use strict';

Dependency,
Deps
DepItem
} from 'reactive-di/i/annotationInterfaces'*/
/*:: import type {SimpleMap} from 'reactive-di/i/modelInterfaces'*/
/*:: import type {
AnyDep,
ResolvableDep,
AnnotationResolver,

@@ -56,3 +56,3 @@ DepsResolver, // eslint-disable-line

var ids /*: Array<Dependency|Tag>*/ = [annotatedDep].concat(tags);
var middlewareDeps /*: Array<AnyDep>*/ = [];
var middlewareDeps /*: Array<ResolvableDep>*/ = [];
for (var i = 0, l = ids.length; i < l; i++) {

@@ -71,8 +71,8 @@ var depMiddlewares /*: ?Array<Dependency>*/ = middlewares.get(ids[i]);

key: 'getDeps',
value: function getDeps(deps /*: ?Deps*/, annotatedDep /*: Dependency*/, tags /*: Array<Tag>*/) {
value: function getDeps(deps /*: Array<DepItem>*/, target /*: Dependency*/, tags /*: Array<Tag>*/) {
var acc = this._acc;
var depNames /*: ?Array<string>*/ = null;
var resolvedDeps /*: Array<AnyDep>*/ = [];
if (deps && deps.length) {
var resolvedDeps /*: Array<ResolvableDep>*/ = [];
if (deps.length) {
if ((0, _typeof3.default)(deps[0]) === 'object' && deps.length === 1) {

@@ -88,3 +88,3 @@ depNames = [];

for (var i = 0, l = deps.length; i < l; i++) {
var dep /*: AnyDep*/ = acc.resolve(((deps /*: any*/) /*: Array<Dependency>*/)[i]);
var dep /*: ResolvableDep*/ = acc.resolve(((deps /*: any*/) /*: Array<Dependency>*/)[i]);
resolvedDeps.push(dep);

@@ -98,3 +98,3 @@ }

depNames: depNames,
middlewares: this._getMiddlewares(annotatedDep, tags)
middlewares: this._getMiddlewares(target, tags)
};

@@ -101,0 +101,0 @@ }

@@ -6,3 +6,3 @@ 'use strict';

});
exports.EntityMetaImpl = exports.AnnotationBaseImpl = exports.DepBaseImpl = undefined;
exports.EntityMetaImpl = exports.DepBaseImpl = undefined;

@@ -21,44 +21,25 @@ var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

DepId,
Info,
Tag
} from 'reactive-di/i/annotationInterfaces'*/
// eslint-disable-line
/*:: import type {EntityMeta} from 'reactive-di/i/nodeInterfaces'*/
// implements DepBase
/*:: import type {EntityMeta} from 'reactive-di/i/nodeInterfaces'*/
var DepBaseImpl = exports.DepBaseImpl = function DepBaseImpl /*:: <V>*/(id /*: DepId*/, info /*: Info*/, value /*: V*/) {
var DepBaseImpl = exports.DepBaseImpl = function DepBaseImpl(annotation /*: {
kind: string,
id: DepId,
target: Function
}*/) {
var isRecalculate /*: boolean*/ = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
(0, _classCallCheck3.default)(this, DepBaseImpl);
this.id = id;
this.info = info;
this.isRecalculate = value === undefined;
this.id = annotation.id;
this.displayName = annotation.kind + '@' + (0, _getFunctionName2.default)(annotation.target);
this.tags = [annotation.kind];
this.isRecalculate = isRecalculate;
this.relations = [];
if (value !== undefined) {
this.value = value;
}
};
// implements Info
var InfoImpl = function InfoImpl(kind /*: string*/, name /*: string*/, tags /*: Array<Tag>*/) {
(0, _classCallCheck3.default)(this, InfoImpl);
this.displayName = kind + '@' + name;
this.tags = tags.concat([kind, name]);
};
// implements AnnotationBase
var AnnotationBaseImpl = exports.AnnotationBaseImpl = function AnnotationBaseImpl /*:: <T: Function>*/(id /*: DepId*/, kind /*: string*/, tags /*: Array<string>*/, target /*: T*/) {
(0, _classCallCheck3.default)(this, AnnotationBaseImpl);
var name /*: string*/ = (0, _getFunctionName2.default)(target);
this.id = id;
this.info = new InfoImpl(kind, name, tags);
this.target = target;
};
// implements EntityMeta

@@ -65,0 +46,0 @@

@@ -8,3 +8,2 @@ 'use strict';

/*:: import type {
AnyDep,
DepArgs

@@ -17,2 +16,5 @@ } from 'reactive-di/i/nodeInterfaces'*/

} from 'reactive-di/utils/createProxy'*/
/*:: import type {FactoryDep} from 'reactive-di/i/plugins/factoryInterfaces'*/
/*:: import type {ClassDep} from 'reactive-di/i/plugins/classInterfaces'*/
/*:: type AnyDep = FactoryDep | ClassDep;*/
/*:: export type ResolveDepsResult<A> = {

@@ -44,3 +46,3 @@ deps: Array<any|SimpleMap<string, any>>,

if (mdl.kind !== 'factory' || mdl.kind !== 'class') {
throw new Error('Not an factor or class: ' + mdl.base.info.displayName);
throw new Error('Not an factory or class: ' + mdl.base.displayName);
}

@@ -47,0 +49,0 @@ resolvedMiddlewares.push(mdl.resolve());

/* @flow */
import type {SimpleMap} from 'reactive-di/i/modelInterfaces'
import type {ClassAnnotation} from 'reactive-di/i/plugins/classInterfaces'
import type {FactoryAnnotation} from 'reactive-di/i/plugins/factoryInterfaces'
import type {GetterAnnotation} from 'reactive-di/i/plugins/getterInterfaces'
import type {LoaderAnnotation, ResetAnnotation} from 'reactive-di/i/plugins/loaderInterfaces'
import type {MetaAnnotation} from 'reactive-di/i/plugins/metaInterfaces'
import type {ModelAnnotation} from 'reactive-di/i/plugins/modelInterfaces'
import type {ObservableAnnotation} from 'reactive-di/i/plugins/observableInterfaces'
import type {
AsyncSetterAnnotation,
SyncSetterAnnotation
} from 'reactive-di/i/plugins/setterInterfaces'
export type DepId = string;

@@ -28,38 +16,18 @@ export type Tag = string;

export type HooksRec<T> = {
onUnmount?: () => void;
onMount?: () => void;
onUpdate?: (currentValue: T, nextValue: T) => void;
export type Annotation<T> = {
kind: any;
target: T;
id: DepId;
}
export type Info = {
tags: Array<Tag>;
displayName: string;
export type DepAnnotation<T> = Annotation<T> & {
deps: Array<DepItem>;
}
export type AnnotationBase<T> = {
id: DepId;
info: Info;
target: T;
}
export type AnnotationMap<A: Annotation> = Map<Function, A>;
export type AnnotationDriver = {
hasAnnotation(dep: Dependency): boolean;
getAnnotation<V, A: AnyAnnotation>(dep: Dependency<V>): A; // eslint-disable-line
annotate<V, T: Dependency<V>, A: AnyAnnotation>(dep: T, annotation: A): T; // eslint-disable-line
getAnnotation<V, A: Annotation>(dep: Dependency<V>): A; // eslint-disable-line
annotate<V, T: Dependency<V>, A: Annotation>(dep: T, annotation: A): T; // eslint-disable-line
};
export type Annotations = {
}
export type AnyAnnotation =
ClassAnnotation
| FactoryAnnotation
| MetaAnnotation
| ModelAnnotation
| GetterAnnotation
| ObservableAnnotation
| LoaderAnnotation
| ResetAnnotation
| AsyncSetterAnnotation
| SyncSetterAnnotation;
/* @flow */
import type {ClassDep} from 'reactive-di/i/plugins/classInterfaces'
import type {FactoryDep} from 'reactive-di/i/plugins/factoryInterfaces'
import type {GetterDep} from 'reactive-di/i/plugins/getterInterfaces'
import type {
LoaderDep,
ResetDep
} from 'reactive-di/i/plugins/loaderInterfaces'
import type {MetaDep} from 'reactive-di/i/plugins/metaInterfaces'
import type {ModelDep} from 'reactive-di/i/plugins/modelInterfaces'
import type {ObservableDep} from 'reactive-di/i/plugins/observableInterfaces'
import type {SyncSetterDep} from 'reactive-di/i/plugins/setterInterfaces'
import type {AsyncSetterDep} from 'reactive-di/i/plugins/setterInterfaces'
import type {
Info,
Annotation,
DepId,
Dependency,
Deps,
Tag,
AnyAnnotation
Tag
} from 'reactive-di/i/annotationInterfaces'

@@ -27,13 +14,2 @@ import type {

} from 'reactive-di/i/modelInterfaces'
export type AnyDep =
ClassDep
| FactoryDep
| MetaDep
| ModelDep
| LoaderDep
| ObservableDep
| ResetDep
| SyncSetterDep
| AsyncSetterDep
| GetterDep;

@@ -55,3 +31,4 @@ export type EntityMeta<E> = {

info: Info;
displayName: string;
tags: Array<Tag>;
relations: Array<DepId>;

@@ -61,2 +38,3 @@ }

export type ResolvableDep<V> = {
kind: any;
base: DepBase;

@@ -76,7 +54,8 @@ resolve(): V;

resolveAnnotation(annotation: AnyAnnotation): AnyDep;
resolve(annotatedDep: Dependency): AnyDep;
resolveAnnotation<AnyDep: Object>(annotation: Annotation): AnyDep;
resolve<AnyDep: Object>(annotatedDep: Dependency): AnyDep;
createId(): DepId;
addRelation(id: DepId): void;
begin(dep: AnyDep): void;
end(dep: AnyDep): void;
begin<AnyDep: Object>(dep: AnyDep): void;
end<AnyDep: Object>(dep: AnyDep): void;
newRoot(): AnnotationResolver;

@@ -86,5 +65,5 @@ }

export type DepArgs = {
deps: Array<AnyDep>;
deps: Array<ResolvableDep>;
depNames: ?Array<string>;
middlewares: ?Array<AnyDep>;
middlewares: ?Array<ResolvableDep>;
}

@@ -91,0 +70,0 @@

@@ -5,3 +5,2 @@ /* @flow */

import type {
AnyDep,
AnnotationResolver

@@ -11,7 +10,6 @@ } from 'reactive-di/i/nodeInterfaces'

export interface Plugin<Annotation: Object, Dep: Object> {
kind: any;
create(annotation: Annotation, acc: AnnotationResolver): void;
finalize(dep: Dep, target: AnyDep): void;
finalize<AnyDep: Object>(dep: Dep, target: AnyDep): void;
}
export type Resolve = (dep: AnyDep) => void;
export type FinalizeFn<T> = (dep: T, target: AnyDep) => void;

@@ -5,10 +5,8 @@ /* @flow */

Deps,
AnnotationBase
DepAnnotation
} from 'reactive-di/i/annotationInterfaces'
import type {DepBase} from 'reactive-di/i/nodeInterfaces'
export type ClassAnnotation<V: Object> = {
export type ClassAnnotation<V: Object> = DepAnnotation<Class<V>> & {
kind: 'class';
base: AnnotationBase<Class<V>>;
deps: ?Deps;
}

@@ -15,0 +13,0 @@

/* @flow */
import type {
AnnotationBase,
DepItem,
DepFn,
Deps
DepAnnotation,
DepFn
} from 'reactive-di/i/annotationInterfaces'
import type {DepBase} from 'reactive-di/i/nodeInterfaces'
import type {DepArgs} from 'reactive-di/i/nodeInterfaces'
export type FactoryAnnotation<V> = {
export type FactoryAnnotation<V> = DepAnnotation<DepFn<V>> & {
kind: 'factory';
base: AnnotationBase<DepFn<V>>;
deps: ?Deps;
}

@@ -17,0 +12,0 @@

@@ -5,3 +5,4 @@ /* @flow */

Deps,
AnnotationBase
DepAnnotation,
Annotation
} from 'reactive-di/i/annotationInterfaces'

@@ -24,12 +25,9 @@ import type {DepBase} from 'reactive-di/i/nodeInterfaces'

export type LoaderAnnotation<V: Object, E> = {
export type LoaderAnnotation<V: Object, E> = DepAnnotation<AsyncUpdater<V, E>> & {
kind: 'loader';
base: AnnotationBase<AsyncUpdater<V, E>>;
deps: ?Deps;
model: Class<V>;
}
export type ResetAnnotation<V: Object, E> = {
export type ResetAnnotation<V: Object, E> = Annotation<AsyncUpdater<V, E>> & {
kind: 'reset';
base: AnnotationBase<AsyncUpdater<V, E>>;
}
/* @flow */
import type {AnnotationBase, Dependency} from 'reactive-di/i/annotationInterfaces'
import type {
Annotation,
Dependency
} from 'reactive-di/i/annotationInterfaces'
import type {
DepBase,

@@ -15,5 +18,4 @@ EntityMeta,

export type MetaAnnotation<V> = {
export type MetaAnnotation<V> = Annotation<Dependency<V>> & {
kind: 'meta';
base: AnnotationBase<Dependency<V>>;
}

@@ -20,0 +22,0 @@

/* @flow */
import type {
AnnotationBase,
Annotation,
Dependency

@@ -13,4 +13,5 @@ } from 'reactive-di/i/annotationInterfaces'

export type ModelInfo<V> = {
childs: Array<Dependency>;
export type ModelAnnotation<V: Object> = Annotation<Class<V>> & {
kind: 'model';
childs: Array<Class<*>>;
statePath: Array<string>;

@@ -20,8 +21,2 @@ fromJS: FromJS<V>;

export type ModelAnnotation<V: Object> = {
kind: 'model';
base: AnnotationBase<Class<V>>; // eslint-disable-line
info: ModelInfo<V>;
}
export type ModelDep<V: Object> = {

@@ -28,0 +23,0 @@ kind: 'model';

@@ -6,3 +6,3 @@ /* @flow */

Deps,
AnnotationBase
Annotation
} from 'reactive-di/i/annotationInterfaces'

@@ -13,6 +13,6 @@ import type {DepBase} from 'reactive-di/i/nodeInterfaces'

export type ObservableAnnotation<V> = {
type MapFn<V: Object> = (value: V) => V;
export type ObservableAnnotation<V: Object> = Annotation<V> & {
kind: 'observable';
base: AnnotationBase<DepFn<V>>;
deps: Deps;
}

@@ -19,0 +19,0 @@

@@ -5,3 +5,4 @@ /* @flow */

Deps,
AnnotationBase
DepItem,
DepAnnotation
} from 'reactive-di/i/annotationInterfaces'

@@ -47,14 +48,10 @@ import type {

export type SyncSetterAnnotation<V: Object> = {
export type SyncSetterAnnotation<V: Object> = DepAnnotation<SyncUpdater<V>> & {
kind: 'syncsetter';
base: AnnotationBase<SyncUpdater<V>>;
deps: ?Deps;
model: Class<V>;
}
export type AsyncSetterAnnotation<V: Object, E> = {
export type AsyncSetterAnnotation<V: Object, E> = DepAnnotation<AsyncUpdater<V, E>> & {
kind: 'asyncsetter';
base: AnnotationBase<AsyncUpdater<V, E>>;
deps: ?Deps;
model: Class<V>;
}
{
"name": "reactive-di",
"version": "0.0.20",
"version": "0.0.21",
"description": "Reactive dependency injection",

@@ -5,0 +5,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc