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 2.3.4 to 2.3.5

src/__tests__/IsEqualTest.js

1

CustomReflect.js

@@ -0,2 +1,3 @@

/* eslint-disable */
'use strict';
module.exports = require('./dist/CustomReflect')

111

dist/adapters/ReactComponentFactory.js

@@ -28,15 +28,18 @@ 'use strict';

var dp = Object.defineProperty;
// <State: Object, Props: Object>
var ComponentMixin = {
// static __rdiCtx: StaticContext<Props, State>
// setState: (state: State) => void
// state: ?State
// props: Props
//
// _target: SrcComponent<Props, ?State>
// _controllable: IComponentControllable<State, ReactComponentClass<Props, State>>
// _createElement: ReactCreateElement
var ComponentMixin = function () {
function ComponentMixin() {
_classCallCheck(this, ComponentMixin);
}
ComponentMixin.prototype.componentWillMount = function componentWillMount() {
var _this = this;
componentWillMount: function componentWillMount() {
var ctx = this.constructor.__rdiCtx;
var t = this;
var setState = function setState(state) {
return _this.setState(state);
return t.setState(state);
};

@@ -46,41 +49,74 @@ var controllable = this._controllable = new _ComponentControllable2.default(ctx.info, setState);

var state = this.state = controllable.getState();
this.state = controllable.getState();
this._target = ctx.info.target;
this._controllable.onWillMount(this);
};
ComponentMixin.prototype.componentDidMount = function componentDidMount() {
},
componentDidMount: function componentDidMount() {
this._controllable.onMount();
};
ComponentMixin.prototype.componentDidUpdate = function componentDidUpdate(props, state) {
},
componentDidUpdate: function componentDidUpdate(_props, _state) {
this._controllable.onUpdate(this);
};
ComponentMixin.prototype.componentWillUnmount = function componentWillUnmount() {
},
componentWillUnmount: function componentWillUnmount() {
this._controllable.onUnmount();
};
ComponentMixin.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
},
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
return !(0, _shallowEqual2.default)(this.props, nextProps) || !(0, _shallowEqual.shallowStrictEqual)(this.state, nextState);
};
},
render: function render() {
return this._target(this.props, this.state, this._createElement);
}
};
ComponentMixin.prototype.render = function render() {
var ComponentDevMixin = {
_showError: function _showError(e) {
console.error(e); // eslint-disable-line
},
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
return ComponentMixin.shouldComponentUpdate.call(this, nextProps, nextState);
},
componentWillMount: function componentWillMount() {
try {
return this._target(this.props, this.state, this._createElement);
ComponentMixin.componentWillMount.call(this);
} catch (e) {
console.error(e);
this._showError(e);
throw e;
}
};
return ComponentMixin;
}();
var dummyProps = {
render: function render() {}
},
componentDidUpdate: function componentDidUpdate() {
try {
ComponentMixin.componentDidUpdate.call(this);
} catch (e) {
this._showError(e);
throw e;
}
},
componentDidMount: function componentDidMount() {
try {
ComponentMixin.componentDidMount.call(this);
} catch (e) {
this._showError(e);
throw e;
}
},
componentWillUnmount: function componentWillUnmount() {
try {
ComponentMixin.componentWillUnmount.call(this);
} catch (e) {
this._showError(e);
throw e;
}
},
render: function render() {
try {
return ComponentMixin.render.call(this);
} catch (e) {
this._showError(e);
throw e;
}
}
};
var ReactComponentFactory = function () {
function ReactComponentFactory(_ref) {
function ReactComponentFactory(_ref, isDebug) {
var Component = _ref.Component;

@@ -93,2 +129,3 @@ var createElement = _ref.createElement;

this._Component = Component;
this._mixin = isDebug ? ComponentDevMixin : ComponentMixin;
}

@@ -115,3 +152,3 @@

Object.assign(WrappedComponent.prototype, ComponentMixin.prototype);
Object.assign(WrappedComponent.prototype, this._mixin);
return WrappedComponent;

@@ -125,3 +162,3 @@ };

if (0) new (Function.prototype.bind.apply(ReactComponentFactory, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(ReactComponentFactory, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=ReactComponentFactory.js.map

@@ -28,5 +28,2 @@ 'use strict';

var dm = _CustomReflect2.default.defineMetadata;
var gm = _CustomReflect2.default.getMetadata;
function deps() {

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

function updaters() {
for (var _len2 = arguments.length, updaters = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
updaters[_key2] = arguments[_key2];
for (var _len2 = arguments.length, items = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
items[_key2] = arguments[_key2];
}
return function (target) {
dm(_common.metaKey, new _common.StatusMeta(updaters), target);
dm(_common.metaKey, new _common.StatusMeta(items), target);
return target;

@@ -107,3 +104,3 @@ };

target.displayName = (src.displayName || src.name) + '#clone-' + (cloneNumber || '0');
cloneNumber++;
cloneNumber++; // eslint-disable-line
Object.setPrototypeOf(target, src);

@@ -110,0 +107,0 @@ if (rec) {

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -3,0 +3,0 @@ exports.__esModule = true;

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

var ComponentMeta = exports.ComponentMeta = function ComponentMeta() {
var rec = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var rec = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

@@ -84,2 +84,4 @@ _classCallCheck(this, ComponentMeta);

var gm = _CustomReflect2.default.getMetadata;
function isAbstract(key) {

@@ -90,3 +92,2 @@ return typeof key === 'function' && gm(metaKey, key);

var defaultArr = [];
var gm = _CustomReflect2.default.getMetadata;
var defaultMeta = new DerivableMeta();

@@ -128,2 +129,6 @@

this._lc = lc;
this.isEqual = lc.isEqual ? function (a, b) {
// @todo remove b.equals after fixing https://github.com/ds300/derivablejs/issues/52
return b.equals ? true : lc.isEqual(a, b);
} : null;
}

@@ -133,4 +138,4 @@

var oldValue = this._entity;
if (oldValue && oldValue !== newValue) {
this._lc.onUpdate && this._lc.onUpdate(oldValue, newValue);
if (oldValue && this._lc.onUpdate && oldValue !== newValue) {
this._lc.onUpdate(oldValue, newValue);
}

@@ -141,9 +146,11 @@ this._entity = newValue;

InternalLifeCycle.prototype.onWillMount = function onWillMount() {
this._lc.onWillMount && this._lc.onWillMount(this._entity);
if (this._lc.onWillMount) {
this._lc.onWillMount(this._entity);
}
};
InternalLifeCycle.prototype.onMount = function onMount() {
this._count++;
if (this._count === 1) {
this._lc.onMount && this._lc.onMount(this._entity);
this._count = this._count + 1;
if (this._count === 1 && this._lc.onMount) {
this._lc.onMount(this._entity);
}

@@ -156,5 +163,5 @@ };

}
this._count--;
if (this._count === 0) {
this._lc.onUnmount && this._lc.onUnmount(this._entity);
this._count = this._count - 1;
if (this._count === 0 && this._lc.onUnmount) {
this._lc.onUnmount(this._entity);
}

@@ -161,0 +168,0 @@ };

@@ -28,3 +28,5 @@ 'use strict';

ComponentLifeCycle.prototype._onUpdate = function _onUpdate(component) {
this._lc.onUpdate && this._lc.onUpdate(component, component);
if (this._lc.onUpdate) {
this._lc.onUpdate(component, component);
}
};

@@ -74,3 +76,5 @@

function ce(tag, props) {
var args = void 0;
switch (arguments.length) {
/* eslint-disable prefer-rest-params */
case 2:

@@ -93,3 +97,3 @@ return createElement(context.wrapComponent(tag), props);

default:
var args = [context.wrapComponent(tag), props];
args = [context.wrapComponent(tag), props];
for (var i = 2, l = arguments.length; i < l; i++) {

@@ -144,3 +148,3 @@ args.push(arguments[i]);

ComponentControllable.prototype.onWillMount = function onWillMount(component) {
ComponentControllable.prototype.onWillMount = function onWillMount(_component) {
if (this._isDisposed.get()) {

@@ -163,3 +167,3 @@ throw new Error('componentDidMount called after componentWillUnmount: ' + this.displayName);

if (0) new (Function.prototype.bind.apply(ComponentControllable, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(ComponentControllable, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=ComponentControllable.js.map

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

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -39,6 +39,2 @@ var _class, _temp;

var _ComponentControllable = require('./ComponentControllable');
var _ComponentControllable2 = _interopRequireDefault(_ComponentControllable);
var _MiddlewareFactory = require('../utils/MiddlewareFactory');

@@ -69,3 +65,5 @@

this._componentFactory = componentFactory || dummyComponentFactory;
this.displayName = (displayName || 'root') + String(Di.uniqId++);
var c = this.constructor;
c.uniqId = c.uniqId + 1; // eslint-disable-line
this.displayName = (displayName || 'root') + String(c.uniqId);
this._mdlFactory = mdlFactory;

@@ -133,3 +131,2 @@ this.adapter = adapter || _derivableAtomAdapter2.default;

var cache = this._metaRegistry;
var ctx = info.ctx;

@@ -147,3 +144,2 @@ var target = info.target;

var depsAtom = void 0;
var handler = void 0;

@@ -180,5 +176,5 @@

lc = new _common.InternalLifeCycle(this.val(info.lc).get());
value.react(lc.onUpdate, {
until: this.stopped
});
if (lc.isEqual) {
value = value.withEquality(lc.isEqual);
}
}

@@ -197,5 +193,6 @@ collector.end(info.lcs, lc);

Di.prototype.preprocess = function preprocess(value, _ref) {
Di.prototype.preprocess = function preprocess(raw, _ref) {
var meta = _ref.meta;
var value = raw;
if (this._mdlFactory) {

@@ -210,3 +207,3 @@ value = this._mdlFactory.wrap(value, meta.type);

Di.prototype.resolveDeps = function resolveDeps(deps, lcs) {
Di.prototype.resolveDeps = function resolveDeps(argDeps, lcs) {
var resolvedArgs = [];

@@ -216,7 +213,8 @@ if (lcs) {

}
for (var i = 0, l = deps.length; i < l; i++) {
var argDep = deps[i];
for (var i = 0, l = argDeps.length; i < l; i++) {
var argDep = argDeps[i];
if ((typeof argDep === 'undefined' ? 'undefined' : _typeof(argDep)) === 'object') {
var result = {};
for (var prop in argDep) {
// eslint-disable-line
var dep = argDep[prop];

@@ -247,5 +245,5 @@ if (!dep) {

if (0) new (Function.prototype.bind.apply(Di, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(Di, [null].concat(0)))(); // eslint-disable-line
(0, _annotations.deps)(Di)(_Updater2.default);
//# sourceMappingURL=Di.js.map

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

function AsyncQeue(parentObserver) {
var maxQeueSize = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
var maxQeueSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;

@@ -341,3 +341,3 @@ _classCallCheck(this, AsyncQeue);

if (0) new (Function.prototype.bind.apply(UpdaterObserver, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(UpdaterObserver, [null].concat(0)))(); // eslint-disable-line

@@ -344,0 +344,0 @@ var Updater = (_temp = _class7 = function () {

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

defineMetadata: function defineMetadata(key, params, target) {
target[Symbol.for(key)] = params;
target[Symbol.for(key)] = params; // eslint-disable-line
},

@@ -11,0 +11,0 @@ getMetadata: function getMetadata(key, target) {

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

if (0) new (Function.prototype.bind.apply(AbstractHandler, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(AbstractHandler, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=AbstractHandler.js.map

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

var fn = isFactory ? _fastCall.fastCall : _fastCall.fastCreateObject;
var deriveItem = function deriveItem(args) {
return ctx.preprocess(fn(target, args), di);
};
deriveItem.displayName = ctx.displayName + '#derive';

@@ -42,3 +44,3 @@

if (0) new (Function.prototype.bind.apply(DerivableHandler, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(DerivableHandler, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=DerivableHandler.js.map

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

if (0) new (Function.prototype.bind.apply(ServiceHandler, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(ServiceHandler, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=ServiceHandler.js.map

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

var value = ctx.defaults[meta.key];
/* eslint-disable new-cap */
if (meta.construct) {

@@ -38,3 +39,3 @@ atom = ctx.adapter.atom(ctx.preprocess(new target(value), di));

if (0) new (Function.prototype.bind.apply(SourceHandler, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(SourceHandler, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=SourceHandler.js.map

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

function mergeStatus(target, updaters) {
/* eslint-disable new-cap */
var us = new target('complete');

@@ -68,3 +69,3 @@ for (var i = 0, l = updaters.length; i < l; i++) {

if (0) new (Function.prototype.bind.apply(StatusHandler, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(StatusHandler, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=StatusHandler.js.map

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

var deps = di.deps;
var target = di.target;
var ctx = di.ctx;

@@ -63,3 +62,3 @@

if (0) new (Function.prototype.bind.apply(ThemeHandler, [null].concat(0)))();
if (0) new (Function.prototype.bind.apply(ThemeHandler, [null].concat(0)))(); // eslint-disable-line
//# sourceMappingURL=ThemeHandler.js.map

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

var subscription = Observable.from(value).subscribe({
next: function next(value) {
atom.set(value);
next: function next(v) {
atom.set(v);
},

@@ -12,0 +12,0 @@ complete: function complete() {},

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

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -8,0 +8,0 @@ exports.default = debugName;

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

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -32,3 +32,3 @@ var _fastCall = require('./fastCall');

ProxyHandlers.prototype.get = function get(target, key, receiver) {
ProxyHandlers.prototype.get = function get(target, key, _receiver) {
var prop = target[key];

@@ -43,3 +43,3 @@ if (typeof prop === 'function') {

var newValue = this._wrapper.set(value, key, target);
target[key] = newValue;
target[key] = newValue; // eslint-disable-line
return true;

@@ -46,0 +46,0 @@ };

@@ -15,4 +15,4 @@ "use strict";

var k = void 0;
for (k in objA) {
for (var k in objA) {
// eslint-disable-line
if (objA[k] !== objB[k]) {

@@ -39,3 +39,4 @@ return false;

for (k in objA) {
numA++;
// eslint-disable-line
numA++; // eslint-disable-line
if (objA[k] !== objB[k]) {

@@ -46,3 +47,4 @@ return false;

for (k in objB) {
numB++;
// eslint-disable-line
numB++; // eslint-disable-line
}

@@ -49,0 +51,0 @@

{
"name": "reactive-di",
"version": "2.3.4",
"version": "2.3.5",
"description": "Reactive dependency injection",

@@ -12,18 +12,15 @@ "publishConfig": {

"scripts": {
"postinstall": "test -d conf && conf/resources/postinstall.sh $npm_package_name || exit 0",
"prepush": "exit 0 && npm test",
"prepublish": "conf/resources/prepublish.sh",
"preversion": "conf/resources/checkgit.sh && npm test && npm run build",
"prepublish": "npm run build",
"preversion": "npm test",
"postversion": "git push && git push --tags",
"precommit": "exit 0",
"prepush": "npm test",
"update": "ncu -ua && npm install",
"clean": "rm -rf $npm_package_config_builddir/dist",
"build": "npm run clean && babel src --ignore=__tests__ --source-maps --out-dir $npm_package_config_builddir/dist",
"build.babel": "npm run clean && babel src --source-maps --out-dir $npm_package_config_builddir/dist",
"build.dev": "babel src --source-maps --out-dir $npm_package_config_builddir/dist --watch",
"lint": "exit 0 && eslint src",
"build.dev": "npm run build -- --watch",
"lint": "eslint .",
"check": "flow check",
"testonly": "mocha",
"test": "npm run lint && npm run check && npm run testonly",
"test.dev": "npm run testonly -- --growl --watch",
"test": "eslint . && flow check && mocha",
"test.dev": "mocha --growl --watch",
"test.cov": "babel-istanbul cover --report text --report html node_modules/mocha/bin/_mocha",

@@ -64,7 +61,6 @@ "start": "webpack-dev-server --config examples/app/webpack.config.es5.js --hot --history-api-fallback --inline"

"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-cli": "^6.16.0",
"babel-core": "^6.17.0",
"babel-loader": "^6.2.5",
"babel-plugin-espower": "^2.3.1",
"babel-plugin-inferno": "^0.7.7",
"babel-plugin-module-resolver": "^2.2.0",

@@ -75,25 +71,27 @@ "babel-plugin-syntax-decorators": "^6.13.0",

"babel-plugin-transform-flow-strip-types": "^6.14.0",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.5.0",
"fake-react": "^1.1.0",
"glob": "^7.0.6",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-es2015-loose": "^8.0.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"eslint-config-airplus": "^2.0.2",
"flow-bin": "^0.33.0",
"glob": "^7.1.0",
"html-webpack-plugin": "^2.22.0",
"husky": "^0.11.8",
"jsdom": "^9.5.0",
"jss": "^5.5.1",
"jss": "^5.5.5",
"jss-camel-case": "^2.0.0",
"mocha": "^3.0.2",
"mocha": "^3.1.0",
"power-assert": "^1.4.1",
"react": "^15.3.1",
"react-addons-test-utils": "^15.3.1",
"react-dom": "^15.3.1",
"sinon": "^1.17.5",
"react": "^15.3.2",
"react-addons-test-utils": "^15.3.2",
"react-dom": "^15.3.2",
"sinon": "^1.17.6",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.1"
"webpack-dev-server": "^1.16.1"
},
"dependencies": {
"derivable": "^0.12.1"
"derivable": "^0.13.0"
}
}
// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import assert from 'power-assert'
import {
service,
abstract,
deps,
source,
factory
source
} from 'reactive-di/annotations'

@@ -38,3 +35,3 @@

assert.throws(() => {
const model: ModelA = di.val(Service).get().b
di.val(Service).get()
}, /Need register Abstract entity/)

@@ -41,0 +38,0 @@ })

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import assert from 'power-assert'
import React from 'react'
import ReactDOM from 'react-dom/server'

@@ -13,3 +11,2 @@ import {

cloneComponent,
theme,
component,

@@ -20,5 +17,2 @@ source,

import type {StyleSheet} from 'reactive-di/interfaces/component'
import {Component} from 'fake-react'
import Di from 'reactive-di/core/Di'

@@ -51,3 +45,3 @@ import BaseModel from 'reactive-di/utils/BaseModel'

function TestComponent(props: {}, state: {m: Test}, h) {
function TestComponent(props: {}, state: {m: Test}, _h) {
return <div>{state.m.val}</div>

@@ -66,3 +60,3 @@ }

@source({key: 'TestB'})
class TestB extends Test{
class TestB extends Test {
static defaults: ModelARec = {

@@ -85,3 +79,3 @@ val: 'TestB'

function Main(props: {}, s, h) {
function Main(props: {}, s, _h) {
return <div>{s.a.val}/{s.b.val}, <TestComponentA/>-<TestComponentB/></div>

@@ -88,0 +82,0 @@ }

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import assert from 'power-assert'
import React from 'react'
import ReactDOM from 'react-dom/server'
import {
theme,
component,

@@ -17,5 +14,2 @@ source,

import type {StyleSheet} from 'reactive-di/interfaces/component'
import {Component} from 'fake-react'
import Di from 'reactive-di/core/Di'

@@ -53,3 +47,3 @@ import BaseModel from 'reactive-di/utils/BaseModel'

function TestComponent(props: Props, state: State, h): mixed {
function TestComponent(props: Props, state: State, _h): mixed {
return <div>{state.m.val}</div>

@@ -56,0 +50,0 @@ }

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

import {spy, stub, match} from 'sinon'
import {spy} from 'sinon'
import assert from 'power-assert'

@@ -13,3 +13,2 @@ import React from 'react'

import {
theme,
hooks,

@@ -21,5 +20,2 @@ component,

import type {StyleSheet} from 'reactive-di/interfaces/component'
import {Component} from 'fake-react'
import {Di, Updater} from 'reactive-di/index'

@@ -65,3 +61,3 @@

@deps(Fetcher, Updater)
class ModelALifeCycle {
class ModelALifeCycle { // eslint-disable-line
_fetcher: Fetcher

@@ -82,6 +78,6 @@ _updater: Updater

onMount(model)
const promise: Promise<ModelARec> = this._promise = this._fetcher.fetch({
const prm: Promise<ModelARec> = this._promise = this._fetcher.fetch({
url: '/model-a'
})
this._updater.setSingle(() => promise, ModelA)
this._updater.setSingle(() => prm, ModelA)
}

@@ -101,3 +97,3 @@

function ComponentA(props: Props, state: State, h: Function): React$Element<any> {
function ComponentA(props: Props, state: State, _h: Function): React$Element<any> {
return <div>testA-{state.m.val}</div>

@@ -108,3 +104,3 @@ }

function ComponentB(props: Props, state: State, h: Function): React$Element<any> {
function ComponentB(props: Props, state: State, _h: Function): React$Element<any> {
return <div>testB-{state.m.val}</div>

@@ -132,3 +128,3 @@ }

assert(findDOMNode(componentB2).textContent === 'testB-2')
assert(onUpdate.calledOnce)
assert(onUpdate.notCalled)

@@ -135,0 +131,0 @@ componentA.componentWillUnmount()

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import {spy} from 'sinon'
import assert from 'power-assert'
import React from 'react'
import ReactDOM from 'react-dom/server'
import {
hooks,
theme,
component,

@@ -18,5 +16,3 @@ source,

import type {StyleSheet} from 'reactive-di/interfaces/component'
import {Component} from 'fake-react'
import Di from 'reactive-di/core/Di'

@@ -28,3 +24,3 @@ import BaseModel from 'reactive-di/utils/BaseModel'

import {renderIntoDocument} from 'react-addons-test-utils'
import {findDOMNode} from 'react-dom'
type ReactComponent<Props, State> = React$Component<*, Props, State>

@@ -57,3 +53,3 @@

function TestComponent(props: Props, state: State, h): mixed {
function TestComponent(props: Props, state: State, _h): mixed {
return <div>{state.m.val}</div>

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

const onMount = spy()
const onUnmount = spy()
const onUpdate = spy()

@@ -80,3 +75,3 @@

assert(onUpdate.notCalled)
const componentA = render(TestComponentEl)
render(TestComponentEl)
assert(onMount.calledOnce)

@@ -83,0 +78,0 @@ assert(onUpdate.notCalled)

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import {spy} from 'sinon'
import assert from 'power-assert'

@@ -10,4 +10,3 @@

deps,
source,
factory
source
} from 'reactive-di/annotations'

@@ -14,0 +13,0 @@

@@ -17,12 +17,6 @@ // @flow

type Atom = {
set: any
}
const FN: (a: string) => void = ((() => {}): any);
// type FN = typeof FN
function createFn(): typeof FN {
return (a: string) => {
}
return (_a: string) => {}
}

@@ -61,3 +55,3 @@ createFn()('1')

const di = new Di()
const s: Service = di.val(Service).get()
di.val(Service).get()
const modelA: ModelA = di.val(ModelA).get()

@@ -96,5 +90,6 @@ assert(Service.calledOnce)

it('create service from factory', () => {
const FactoryService = spy(function (modelA: ModelA) {
function factoryService(modelA: ModelA): () => string {
return () => modelA.val
})
}
const FactoryService = spy(factoryService)
service(FactoryService)

@@ -105,3 +100,3 @@ factory(FactoryService)

const di = new Di()
const fn = di.val(FactoryService).get()
di.val(FactoryService).get()
const modelA: ModelA = di.val(ModelA).get()

@@ -116,5 +111,6 @@ assert(FactoryService.calledOnce)

it('dependency changed and factory changed inside', () => {
const FactoryService = spy(function factoryService(modelA: ModelA): () => string {
function factoryService(modelA: ModelA): () => string {
return () => modelA.val
})
}
const FactoryService = spy(factoryService)
service(FactoryService)

@@ -121,0 +117,0 @@ factory(FactoryService)

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import assert from 'power-assert'
import {
factory,
updaters,
component,

@@ -17,6 +14,3 @@ hooks,

import {Di, Updater} from 'reactive-di/index'
import BaseModel from 'reactive-di/utils/BaseModel'
import type {CreateControllable, IComponentControllable} from 'reactive-di/interfaces/component'
import type {Derivable} from 'reactive-di/interfaces/atom'
import type {SingleUpdate} from 'reactive-di/interfaces/updater'
import type {IComponentControllable} from 'reactive-di/interfaces/component'
import ComponentControllable from 'reactive-di/core/ComponentControllable'

@@ -49,3 +43,3 @@

@deps(ModelAUpdater)
class ModelALC {
class ModelALC { // eslint-disable-line
_updater: Updater

@@ -77,3 +71,6 @@

// console.log(this.constructor.info)
this.ctl = new ComponentControllable(this.constructor.info, (state) => this.setState(state))
this.ctl = new ComponentControllable(
this.constructor.info,
(state) => this.setState(state)
)
Object.assign(this, this.ctl.getState())

@@ -91,3 +88,3 @@ }

wrapComponent(info: any): any {
info.target.info = info
info.target.info = info // eslint-disable-line
return (info.target: any)

@@ -94,0 +91,0 @@ }

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import {spy} from 'sinon'
import assert from 'power-assert'

@@ -6,0 +6,0 @@

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import {spy} from 'sinon'
import assert from 'power-assert'
import {
service,
abstract,
deps,
source,
factory
} from 'reactive-di/annotations'
import Di from 'reactive-di/core/Di'
import BaseModel from 'reactive-di/utils/BaseModel'
import type {Middleware, ArgsInfo} from 'reactive-di/utils/MiddlewareFactory'
import type {ArgsInfo} from 'reactive-di/utils/MiddlewareFactory'

@@ -23,3 +14,3 @@ describe('MiddlewareTest', () => {

class Mdl1 {
exec<R>(fn: (args: any[]) => R, args: any[], info: ArgsInfo): R {
exec(fn: (args: any[]) => string, args: any[], info: ArgsInfo): string {
addLog(fn, args, info)

@@ -42,3 +33,3 @@ return fn(args) + 'c'

class Mdl1 {
exec<R>(fn: (args: any[]) => R, args: any[], info: ArgsInfo): R {
exec(fn: (args: any[]) => string, args: any[], info: ArgsInfo): string {
addLog(fn, args, info)

@@ -49,3 +40,3 @@ return fn(args) + 'c'

class Mdl2 {
exec<R>(fn: (args: any[]) => R, args: any[], info: ArgsInfo): R {
exec(fn: (args: any[]) => string, args: any[], info: ArgsInfo): string {
addLog(fn, args, info)

@@ -52,0 +43,0 @@ return fn(args) + 'd'

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import {spy} from 'sinon'
import assert from 'power-assert'

@@ -41,8 +41,4 @@

const di = (new Di()).register([ModelA])
let newDi = di.create('child')
// console.log(di._metaRegistry.getMeta(ModelA) === newDi._metaRegistry.getMeta(ModelA))
const newDi = di.create('child')
assert(di.val(ModelA) === newDi.val(ModelA))
// modify ModelA in parent di
// newDi.val(ModelA).set(new ModelA({val: 'test1'}))
// assert(di.val(ModelA).get().val === 'test1')
})

@@ -71,3 +67,3 @@

let newDi = di.create('child').register([ModelA])
const newDi = di.create('child').register([ModelA])

@@ -101,3 +97,3 @@ // modify ModelA in child di

const di = new Di()
let newDi = di.create('child')
const newDi = di.create('child')

@@ -104,0 +100,0 @@ // modify ModelA in parent di

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import assert from 'power-assert'
import {
factory,
service,
deps,
source,

@@ -87,3 +83,3 @@ updaters

let resolveFn: Function
const promiseB = new Promise(resolve => {
const promiseB = new Promise((resolve) => {
resolveFn = resolve

@@ -90,0 +86,0 @@ })

// @flow
/* eslint-env mocha */
import {spy, match} from 'sinon'
import assert from 'power-assert'
import {
factory,
service,
deps,
source,
updaters
source
} from 'reactive-di/annotations'

@@ -79,5 +74,9 @@

let resolve2: Function
const promise1 = new Promise(r => {resolve1 = r})
const promise2 = new Promise(r => {resolve2 = r})
const modelAObservable = new Observable((observer: Observer<ModelA|ModelA[], Error>) => {
const promise1 = new Promise((r) => {
resolve1 = r
})
const promise2 = new Promise((r) => {
resolve2 = r
})
const modelAObservable = new Observable((observer: Observer<ModelA | ModelA[], Error>) => {
setTimeout(() => {

@@ -84,0 +83,0 @@ observer.next([new ModelA({val})])

@@ -6,7 +6,4 @@ // @flow

SrcComponent,
IComponentControllable,
CreateControllable,
SetState
} from 'reactive-di/interfaces/component'
import type {IContext} from 'reactive-di/interfaces/internal'
import debugName from 'reactive-di/utils/debugName'

@@ -17,9 +14,5 @@ import shallowEqual, {shallowStrictEqual} from 'reactive-di/utils/shallowEqual'

type ReactElement = React$Element<any>
type ReactComponent<Props, State> = React$Component<*, Props, State>
type ReactComponentClass<Props, State> = Class<ReactComponent<Props, State>>
type ReactCreateElement = CreateElement<any, ReactElement>
type CreateReactControllable<Props, State> = CreateControllable<State, ReactComponentClass<Props, State>>
interface StaticContext<Props, State> {

@@ -30,19 +23,18 @@ info: DepInfo<SrcComponent<Props, State>, *>;

const dp = Object.defineProperty
// <State: Object, Props: Object>
const ComponentMixin = {
// static __rdiCtx: StaticContext<Props, State>
// setState: (state: State) => void
// state: ?State
// props: Props
//
// _target: SrcComponent<Props, ?State>
// _controllable: IComponentControllable<State, ReactComponentClass<Props, State>>
// _createElement: ReactCreateElement
class ComponentMixin<State: Object, Props: Object> {
static __rdiCtx: StaticContext<Props, State>
setState: (state: State) => void
state: ?State
props: Props
_target: SrcComponent<Props, ?State>
_controllable: IComponentControllable<State, ReactComponentClass<Props, State>>
_createElement: ReactCreateElement
componentWillMount(): void {
componentWillMount<Props, State>(): void {
const ctx: StaticContext<Props, State> = this.constructor.__rdiCtx
const t = this
const setState: SetState<State> = (state: State) => {
return this.setState(state)
return t.setState(state)
}

@@ -52,37 +44,83 @@ const controllable = this._controllable = new ComponentControllable(ctx.info, setState)

const state: ?State = this.state = controllable.getState()
this.state = controllable.getState()
this._target = ctx.info.target
this._controllable.onWillMount((this: any))
}
},
componentDidMount() {
this._controllable.onMount()
}
},
componentDidUpdate(props: Props, state: State): void {
componentDidUpdate<Props, State>(_props: Props, _state: State): void {
this._controllable.onUpdate((this: any))
}
},
componentWillUnmount(): void {
this._controllable.onUnmount()
}
},
shouldComponentUpdate(nextProps: Object, nextState: Object): boolean {
return !shallowEqual(this.props, nextProps) || !shallowStrictEqual(this.state, nextState)
},
render(): any {
return this._target(this.props, this.state, this._createElement)
}
}
render(): any {
const ComponentDevMixin = {
_showError(e: Error): void {
console.error(e) // eslint-disable-line
},
shouldComponentUpdate(nextProps: Object, nextState: Object): boolean {
return ComponentMixin.shouldComponentUpdate.call(this, nextProps, nextState)
},
componentWillMount(): void {
try {
return this._target(this.props, this.state, this._createElement)
ComponentMixin.componentWillMount.call(this)
} catch (e) {
console.error(e)
this._showError(e)
throw e
}
},
componentDidUpdate(): void {
try {
ComponentMixin.componentDidUpdate.call(this)
} catch (e) {
this._showError(e)
throw e
}
},
componentDidMount(): void {
try {
ComponentMixin.componentDidMount.call(this)
} catch (e) {
this._showError(e)
throw e
}
},
componentWillUnmount(): void {
try {
ComponentMixin.componentWillUnmount.call(this)
} catch (e) {
this._showError(e)
throw e
}
},
render(): void {
try {
return ComponentMixin.render.call(this)
} catch (e) {
this._showError(e)
throw e
}
}
}
const dummyProps = {
render() {}
}
interface React {

@@ -96,6 +134,8 @@ Component: ReactComponentClass<*, *>;

_createElement: CreateElement<*, *>
_mixin: Object
constructor({Component, createElement}: React) {
constructor({Component, createElement}: React, isDebug?: boolean) {
this._createElement = (createElement: any)
this._Component = Component
this._mixin = isDebug ? ComponentDevMixin : ComponentMixin
}

@@ -116,6 +156,6 @@

}
Object.assign((WrappedComponent.prototype: Object), ComponentMixin.prototype)
Object.assign((WrappedComponent.prototype: Object), this._mixin)
return WrappedComponent
}
}
if (0) ((new ReactComponentFactory(...(0: any))): ComponentFactory)
if (0) ((new ReactComponentFactory(...(0: any))): ComponentFactory) // eslint-disable-line

@@ -21,3 +21,2 @@ // @flow

const dm = CustomReflect.defineMetadata
const gm = CustomReflect.getMetadata

@@ -58,5 +57,5 @@ export function deps<V: Function>(...args: ArgDep[]): (target: V) => V {

export function updaters<V: Function>(...updaters: Class<Updater>[]): (target: V) => V {
export function updaters<V: Function>(...items: Class<Updater>[]): (target: V) => V {
return (target: V) => {
dm(metaKey, new StatusMeta(updaters), target)
dm(metaKey, new StatusMeta(items), target)
return target

@@ -91,3 +90,3 @@ }

target.displayName = (src.displayName || src.name) + '#clone-' + (cloneNumber || '0')
cloneNumber++
cloneNumber++ // eslint-disable-line
Object.setPrototypeOf(target, src)

@@ -94,0 +93,0 @@ if (rec) {

// @flow
import type {LifeCycle} from 'reactive-di/interfaces/deps'
export default class Collector<T> {

@@ -6,0 +4,0 @@ _parents: Set<T>[] = []

// @flow
import type {DepFn, Key, DepDict, ArgDep, DepAlias, RegisterDepItem, LifeCycle} from 'reactive-di/interfaces/deps'
import type {Atom, Adapter, CacheMap, Derivable} from 'reactive-di/interfaces/atom'
import type {Key, ArgDep, RegisterDepItem, LifeCycle} from 'reactive-di/interfaces/deps'
import type {IsEqual, Atom} from 'reactive-di/interfaces/atom'
import type {IContext} from 'reactive-di/interfaces/internal'

@@ -47,3 +47,3 @@ import type {RawStyleSheet} from 'reactive-di/interfaces/component'

if (!rec.key) {
throw new Error(`@source has no key property`)
throw new Error('@source has no key property')
}

@@ -68,4 +68,8 @@ this.key = rec.key

export type RdiMeta = ThemeMeta | ComponentMeta | AbstractMeta | SourceMeta | ServiceMeta | DerivableMeta | StatusMeta
export type RdiMeta = ThemeMeta | ComponentMeta | AbstractMeta
| SourceMeta | ServiceMeta | DerivableMeta | StatusMeta
const gm = CustomReflect.getMetadata
export function isAbstract(key: Key): boolean {

@@ -76,3 +80,2 @@ return typeof key === 'function' && gm(metaKey, key)

const defaultArr: ArgDep[] = []
const gm = CustomReflect.getMetadata
const defaultMeta = new DerivableMeta()

@@ -100,4 +103,12 @@

isEqual: ?IsEqual<*>
constructor(lc: LifeCycle<V>) {
this._lc = lc
this.isEqual = lc.isEqual
? (a: V, b: V) => {
// @todo remove b.equals after fixing https://github.com/ds300/derivablejs/issues/52
return b.equals ? true : (lc: any).isEqual(a, b)
}
: null
}

@@ -109,4 +120,4 @@

const oldValue: V = this._entity
if (oldValue && oldValue !== newValue) {
this._lc.onUpdate && this._lc.onUpdate(oldValue, newValue)
if (oldValue && this._lc.onUpdate && oldValue !== newValue) {
this._lc.onUpdate(oldValue, newValue)
}

@@ -117,9 +128,11 @@ this._entity = newValue

onWillMount() {
this._lc.onWillMount && this._lc.onWillMount(this._entity)
if (this._lc.onWillMount) {
this._lc.onWillMount(this._entity)
}
}
onMount() {
this._count++
if (this._count === 1) {
this._lc.onMount && this._lc.onMount(this._entity)
this._count = this._count + 1
if (this._count === 1 && this._lc.onMount) {
this._lc.onMount(this._entity)
}

@@ -132,5 +145,5 @@ }

}
this._count--
if (this._count === 0) {
this._lc.onUnmount && this._lc.onUnmount(this._entity)
this._count = this._count - 1
if (this._count === 0 && this._lc.onUnmount) {
this._lc.onUnmount(this._entity)
}

@@ -137,0 +150,0 @@ }

@@ -1,2 +0,2 @@

//@flow
// @flow

@@ -6,4 +6,4 @@ import {DepInfo, InternalLifeCycle, ComponentMeta} from 'reactive-di/core/common'

import type {Atom, Derivable, Adapter} from 'reactive-di/interfaces/atom'
import type {Key, LifeCycle} from 'reactive-di/interfaces/deps'
import type {CreateElement, SrcComponent, IComponentControllable} from 'reactive-di/interfaces/component'
import type {LifeCycle} from 'reactive-di/interfaces/deps'
import type {CreateElement, IComponentControllable} from 'reactive-di/interfaces/component'
import type {IContext} from 'reactive-di/interfaces/internal'

@@ -18,3 +18,5 @@

_onUpdate(component: Component): void {
this._lc.onUpdate && this._lc.onUpdate(component, component)
if (this._lc.onUpdate) {
this._lc.onUpdate(component, component)
}
}

@@ -72,3 +74,5 @@ }

) {
let args: mixed[]
switch (arguments.length) {
/* eslint-disable prefer-rest-params */
case 2:

@@ -79,19 +83,32 @@ return createElement(context.wrapComponent(tag), props)

case 4:
return createElement(context.wrapComponent(tag), props, arguments[2], arguments[3])
return createElement(context.wrapComponent(tag), props, arguments[2],
arguments[3]
)
case 5:
return createElement(context.wrapComponent(tag), props, arguments[2], arguments[3], arguments[4])
return createElement(context.wrapComponent(tag), props, arguments[2],
arguments[3], arguments[4]
)
case 6:
return createElement(context.wrapComponent(tag), props, arguments[2], arguments[3], arguments[4], arguments[5])
return createElement(context.wrapComponent(tag), props, arguments[2],
arguments[3], arguments[4], arguments[5]
)
case 7:
return createElement(context.wrapComponent(tag), props, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6])
return createElement(context.wrapComponent(tag), props, arguments[2],
arguments[3], arguments[4], arguments[5], arguments[6]
)
case 8:
return createElement(context.wrapComponent(tag), props, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7])
return createElement(context.wrapComponent(tag), props, arguments[2],
arguments[3], arguments[4], arguments[5], arguments[6], arguments[7]
)
case 9:
return createElement(context.wrapComponent(tag), props, arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8])
return createElement(context.wrapComponent(tag), props, arguments[2],
arguments[3], arguments[4], arguments[5], arguments[6],
arguments[7], arguments[8]
)
default:
const args = [context.wrapComponent(tag), props]
args = [context.wrapComponent(tag), props]
for (let i = 2, l = arguments.length; i < l; i++) {
args.push(arguments[i])
}
return createElement.apply(undefined, args)
return createElement(...args)
}

@@ -142,3 +159,3 @@ }

onWillMount(component: Component): void {
onWillMount(_component: Component): void {
if (this._isDisposed.get()) {

@@ -156,2 +173,2 @@ throw new Error(`componentDidMount called after componentWillUnmount: ${this.displayName}`)

}
if (0) ((new ComponentControllable(...(0: any))): IComponentControllable<*, *>)
if (0) ((new ComponentControllable(...(0: any))): IComponentControllable<*, *>) // eslint-disable-line
// @flow
import type {Atom, Adapter} from 'reactive-di/interfaces/atom'
import type {Adapter} from 'reactive-di/interfaces/atom'

@@ -4,0 +4,0 @@ import {

// @flow
import {DepInfo, InternalLifeCycle} from 'reactive-di/core/common'
import {DepInfo, isComponent, InternalLifeCycle} from 'reactive-di/core/common'
import type {IHandler, RdiMeta} from 'reactive-di/core/common'

@@ -8,8 +8,6 @@

import {isComponent} from 'reactive-di/core/common'
import type {IContext} from 'reactive-di/interfaces/internal'
import type {RegisterDepItem, ArgDep, Key} from 'reactive-di/interfaces/deps'
import type {Adapter, Atom, DerivableArg, DerivableDict, Derivable} from 'reactive-di/interfaces/atom'
import type {CreateElement, SetState, ComponentFactory, CreateStyleSheet} from 'reactive-di/interfaces/component'
import type {ComponentFactory, CreateStyleSheet} from 'reactive-di/interfaces/component'

@@ -22,3 +20,2 @@ import debugName from 'reactive-di/utils/debugName'

import Collector from 'reactive-di/core/Collector'
import ComponentControllable from 'reactive-di/core/ComponentControllable'
import type {Middleware} from 'reactive-di/utils/MiddlewareFactory'

@@ -62,3 +59,5 @@ import MiddlewareFactory from 'reactive-di/utils/MiddlewareFactory'

this._componentFactory = componentFactory || dummyComponentFactory
this.displayName = (displayName || 'root') + String(Di.uniqId++)
const c = this.constructor
c.uniqId = c.uniqId + 1 // eslint-disable-line
this.displayName = (displayName || 'root') + String(c.uniqId)
this._mdlFactory = mdlFactory

@@ -139,3 +138,2 @@ this.adapter = adapter || derivableAtomAdapter

const cache = this._metaRegistry
const {ctx, target, meta, name} = info

@@ -149,3 +147,2 @@ if (ctx !== this) {

let depsAtom: ?Derivable<mixed[]>
let handler: ?IHandler

@@ -182,5 +179,5 @@

lc = new InternalLifeCycle(this.val(info.lc).get())
value.react(lc.onUpdate, {
until: this.stopped
})
if (lc.isEqual) {
value = value.withEquality(lc.isEqual)
}
}

@@ -199,3 +196,4 @@ collector.end(info.lcs, lc)

preprocess(value: any, {meta}: DepInfo<*, *>): any {
preprocess(raw: any, {meta}: DepInfo<*, *>): any {
let value = raw
if (this._mdlFactory) {

@@ -210,3 +208,3 @@ value = this._mdlFactory.wrap(value, meta.type)

resolveDeps(deps: ArgDep[], lcs?: InternalLifeCycle<*>[]): Derivable<mixed[]> {
resolveDeps(argDeps: ArgDep[], lcs?: InternalLifeCycle<*>[]): Derivable<mixed[]> {
const resolvedArgs: DerivableArg[] = []

@@ -216,7 +214,7 @@ if (lcs) {

}
for (let i = 0, l = deps.length; i < l; i++) {
const argDep: ArgDep = deps[i]
for (let i = 0, l = argDeps.length; i < l; i++) {
const argDep: ArgDep = argDeps[i]
if (typeof argDep === 'object') {
const result: DerivableDict = {}
for (let prop in argDep) {
for (let prop in argDep) { // eslint-disable-line
const dep: Key = argDep[prop]

@@ -243,4 +241,4 @@ if (!dep) {

}
if (0) ((new Di(...(0: any))): IContext)
if (0) ((new Di(...(0: any))): IContext) // eslint-disable-line
deps(Di)(Updater)
// @flow
import type {Derivable} from 'reactive-di/interfaces/atom'
import type {LifeCycle, RegisterDepItem, Key} from 'reactive-di/interfaces/deps'
import type {RegisterDepItem, Key} from 'reactive-di/interfaces/deps'
import type {IContext} from 'reactive-di/interfaces/internal'
import {DepInfo, isAbstract} from 'reactive-di/core/common'
import {DepInfo} from 'reactive-di/core/common'

@@ -8,0 +7,0 @@ export default class MetaRegistry {

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

import type {
MultiSyncUpdate,
MultiAsyncUpdate,

@@ -12,3 +11,2 @@ MultiUpdate,

SingleSyncUpdate,
SingleAsyncUpdate,

@@ -59,3 +57,3 @@ SingleUpdate,

if (rawUpdate.length !== 2) {
throw new Error(`Wrong update rec: need a tuple [SingleSyncUpdate, SingleAsyncUpdate]`)
throw new Error('Wrong update rec: need a tuple [SingleSyncUpdate, SingleAsyncUpdate]')
}

@@ -361,3 +359,3 @@ this.syncs = [[target, (rawUpdate[0]: Object)]]

}
if (0) ((new UpdaterObserver(...(0: any))): Observer<UpdateBucket, OperationErrorRec>)
if (0) ((new UpdaterObserver(...(0: any))): Observer<UpdateBucket, OperationErrorRec>) // eslint-disable-line

@@ -364,0 +362,0 @@ export default class Updater {

// @flow
const isReflect: boolean = typeof Reflect !== 'undefined' && typeof (Reflect: any).defineMetadata === 'function'
const isReflect: boolean = typeof Reflect !== 'undefined' && typeof (Reflect: any).defineMetadata === 'function'
const CustomReflect = {
defineMetadata(key: string, params: any, target: Function): void {
target[Symbol.for(key)] = params
target[Symbol.for(key)] = params // eslint-disable-line
},

@@ -9,0 +9,0 @@ getMetadata(key: string, target: Function): any {

@@ -1,2 +0,2 @@

//@flow
// @flow

@@ -15,2 +15,2 @@ import {DepInfo, AbstractMeta, IHandler} from 'reactive-di/core/common'

if (0) ((new AbstractHandler(...(0: any))): IHandler)
if (0) ((new AbstractHandler(...(0: any))): IHandler) // eslint-disable-line

@@ -1,5 +0,5 @@

//@flow
// @flow
import {DepInfo, DerivableMeta, IHandler} from 'reactive-di/core/common'
import type {Atom, Adapter, CacheMap, Derivable} from 'reactive-di/interfaces/atom'
import type {Atom, Derivable} from 'reactive-di/interfaces/atom'

@@ -18,3 +18,6 @@ import {fastCall, fastCreateObject} from 'reactive-di/utils/fastCall'

const fn: (target: Function, args: mixed[]) => V = isFactory ? fastCall : fastCreateObject
const deriveItem: (args: mixed[]) => V = (args: mixed[]) => ctx.preprocess(fn(target, args), di)
const deriveItem: (args: mixed[]) => V = (args: mixed[]) =>
ctx.preprocess(fn(target, args), di)
deriveItem.displayName = `${ctx.displayName}#derive`

@@ -28,2 +31,2 @@

if (0) ((new DerivableHandler(...(0: any))): IHandler)
if (0) ((new DerivableHandler(...(0: any))): IHandler) // eslint-disable-line

@@ -1,6 +0,5 @@

//@flow
// @flow
import {DepInfo, ServiceMeta, IHandler} from 'reactive-di/core/common'
import type {Atom, Derivable} from 'reactive-di/interfaces/atom'
import type {IContext} from 'reactive-di/interfaces/internal'
import type {DepFn} from 'reactive-di/interfaces/deps'

@@ -26,3 +25,6 @@

_createDatachedObject<V: Object>(depsAtom: Derivable<mixed[]>, di: DepInfo<any, ServiceMeta>): V {
_createDatachedObject<V: Object>(
depsAtom: Derivable<mixed[]>,
di: DepInfo<any, ServiceMeta>
): V {
const {target, ctx} = di

@@ -41,3 +43,6 @@ const obj: V = fastCreateObject(target, depsAtom.get())

_createDetachedFactory<V: Function>(depsAtom: Derivable<mixed[]>, di: DepInfo<any, ServiceMeta>): V {
_createDetachedFactory<V: Function>(
depsAtom: Derivable<mixed[]>,
di: DepInfo<any, ServiceMeta>
): V {
const {target, ctx} = di

@@ -66,2 +71,2 @@ let fn: DepFn<V> = fastCall(target, depsAtom.get())

if (0) ((new ServiceHandler(...(0: any))): IHandler)
if (0) ((new ServiceHandler(...(0: any))): IHandler) // eslint-disable-line

@@ -1,2 +0,2 @@

//@flow
// @flow

@@ -15,2 +15,3 @@ import {DepInfo, SourceMeta, IHandler} from 'reactive-di/core/common'

const value: any = ctx.defaults[meta.key]
/* eslint-disable new-cap */
if (meta.construct) {

@@ -28,2 +29,2 @@ atom = ctx.adapter.atom(ctx.preprocess((new target(value): any), di))

if (0) ((new SourceHandler(...(0: any))): IHandler)
if (0) ((new SourceHandler(...(0: any))): IHandler) // eslint-disable-line

@@ -1,2 +0,2 @@

//@flow
// @flow

@@ -8,2 +8,3 @@ import {DepInfo, StatusMeta, IHandler} from 'reactive-di/core/common'

function mergeStatus(target: Class<UpdaterStatus>, updaters: UpdaterStatus[]): UpdaterStatus {
/* eslint-disable new-cap */
const us: UpdaterStatus = new target('complete')

@@ -48,2 +49,2 @@ for (let i = 0, l = updaters.length; i < l; i++) {

if (0) ((new StatusHandler(...(0: any))): IHandler)
if (0) ((new StatusHandler(...(0: any))): IHandler) // eslint-disable-line

@@ -1,5 +0,4 @@

//@flow
// @flow
import {DepInfo, ThemeMeta, IHandler} from 'reactive-di/core/common'
import type {IContext} from 'reactive-di/interfaces/internal'
import type {Atom, Derivable} from 'reactive-di/interfaces/atom'

@@ -28,3 +27,2 @@ import type {StyleSheet, CreateStyleSheet, RawStyleSheet} from 'reactive-di/interfaces/component'

deps,
target,
ctx

@@ -55,2 +53,2 @@ } = di

if (0) ((new ThemeHandler(...(0: any))): IHandler)
if (0) ((new ThemeHandler(...(0: any))): IHandler) // eslint-disable-line

@@ -8,3 +8,2 @@ // @flow

import Updater, {UpdaterStatus} from 'reactive-di/core/Updater'
import type {IDi} from 'reactive-di/interfaces/internal'
import bindObservableToAtom from 'reactive-di/utils/bindObservableToAtom'

@@ -25,2 +24,6 @@

export type {
Atom
} from 'reactive-di/interfaces/atom'
export type {
SrcComponent,

@@ -27,0 +30,0 @@ StyleSheet,

@@ -9,4 +9,7 @@ // @flow

export type IsEqual<V> = (old: V, newValue: V) => boolean
export interface Derivable<V> {
get(): V;
withEquality(isEqual: IsEqual<V>): Derivable<V>;
derive<E>(f: (value: V) => E): Derivable<E>;

@@ -17,4 +20,5 @@ react(fn: (v: V) => void, lc?: ?LifeCycle): void;

export interface Atom<V> extends Derivable<V> {
set(v: V): void;
set: (v: V) => void;
swap<E>(f: (v: V) => E): void;
withEquality(isEqual: IsEqual<V>): Atom<V>;
}

@@ -32,2 +36,2 @@

export type CacheMap = Map<Function|string, ?Atom<*>>
export type CacheMap = Map<Function | string, ?Atom<*>>
// @flow
import type {IContext} from 'reactive-di/interfaces/internal'
import type {DepInfo} from 'reactive-di/core/common'

@@ -4,0 +3,0 @@

// @flow
export type Key = Function|string
export type Key = Function | string
export type DepFn<V> = (...a: any) => V

@@ -12,6 +12,11 @@ export type DepDict = {[k: string]: Key}

export type ResultOf<F> = _ResultOf<*, F>
type _ResultOf<V, F: (...x: any[]) => V> = V
type _ResultOf<V, F: (...x: any[]) => V> = V // eslint-disable-line
export interface LifeCycle<Dep> {
/**
* Called before dep update, if returned true - component updated
*/
isEqual?: (oldDep: Dep, newDep: Dep) => boolean;
/**
* Called before first mount of any component, works on server side

@@ -18,0 +23,0 @@ */

// @flow
import type {Derivable} from 'reactive-di/interfaces/atom'
import type {Key} from 'reactive-di/interfaces/deps'
export type SingleSyncUpdate = Object
export type SingleAsyncUpdateResult = Promise<SingleSyncUpdate> | Observable<SingleSyncUpdate, Error>
export type SingleAsyncUpdateResult = Promise<SingleSyncUpdate>
| Observable<SingleSyncUpdate, Error>
export type SingleAsyncUpdate = () => SingleAsyncUpdateResult
export type SingleUpdate = (SingleSyncUpdate | SingleAsyncUpdate) | [SingleSyncUpdate, SingleAsyncUpdate]
export type SingleUpdate = (SingleSyncUpdate | SingleAsyncUpdate)
| [SingleSyncUpdate, SingleAsyncUpdate]
export type MultiSyncUpdate = [Key, Object] | Object
export type MultiAsyncUpdateResult = Promise<MultiSyncUpdate[]> | Observable<MultiSyncUpdate[], Error>
export type MultiAsyncUpdateResult = Promise<MultiSyncUpdate[]>
| Observable<MultiSyncUpdate[], Error>
export type MultiAsyncUpdate = () => MultiAsyncUpdateResult
export type MultiUpdate = MultiSyncUpdate | MultiAsyncUpdate
// @flow
/* eslint-env mocha */
import {spy} from 'sinon'
import assert from 'power-assert'
import type {ArgsInfo, Middleware} from 'reactive-di/utils/MiddlewareFactory'
import type {ArgsInfo} from 'reactive-di/utils/MiddlewareFactory'
import MiddlewareFactory from 'reactive-di/utils/MiddlewareFactory'

@@ -11,4 +13,4 @@

class Mdl1 {
exec<R>(resolve: (args: any[]) => R, args: any[], info: ArgsInfo): R {
const result: R = resolve(args)
exec(resolve: (args: any[]) => string, args: any[], _info: ArgsInfo): any {
const result: string = resolve(args)
// console.log(`${info.id} called`)

@@ -30,4 +32,4 @@ return result + 'c'

class Mdl1 {
exec<R>(resolve: (args: any[]) => R, args: any[], info: ArgsInfo): R {
const result: R = resolve(args)
exec(resolve: (args: any[]) => string, args: any[], _info: ArgsInfo): any {
const result: string = resolve(args)
return result + 'c'

@@ -37,4 +39,4 @@ }

class Mdl2 {
exec<R>(resolve: (args: any[]) => R, args: any[], info: ArgsInfo): R {
const result: R = resolve(args)
exec(resolve: (args: any[]) => string, args: any[], _info: ArgsInfo): any {
const result: string = resolve(args)
return result + 'd'

@@ -55,4 +57,4 @@ }

class Mdl1 {
exec<R>(resolve: (args: any[]) => R, args: any[], info: ArgsInfo): R {
const result: R = resolve(args)
exec(resolve: (args: any[]) => string, args: any[], info: ArgsInfo): any {
const result: string = resolve(args)
if (info.id !== 'testFuncB') {

@@ -65,4 +67,4 @@ return result

class Mdl2 {
exec<R>(resolve: (args: any[]) => R, args: any[], info: ArgsInfo): R {
const result: R = resolve(args)
exec(resolve: (args: any[]) => string, args: any[], _info: ArgsInfo): any {
const result: string = resolve(args)
return result + 'd'

@@ -91,4 +93,4 @@ }

class Mdl1 {
exec<R>(resolve: (args: any[]) => R, args: any[], info: ArgsInfo): R {
const result: R = resolve(args)
exec(resolve: (args: any[]) => string, args: any[], _info: ArgsInfo): any {
const result: string = resolve(args)
// console.log(`${info.id} called`)

@@ -117,3 +119,3 @@ return result + 'c'

class Mdl1 {
get<R>(result: R, info: ArgsInfo): R {
get(result: string, info: ArgsInfo): any {
access(result, info)

@@ -138,3 +140,3 @@ return result

class Mdl1 {
get<R>(result: R, info: ArgsInfo): R {
get(result: string, _info: ArgsInfo): any {
return result + '2'

@@ -157,3 +159,3 @@ }

class Mdl1 {
set<R>(oldValue: R, newValue: R, info: ArgsInfo): R {
set(oldValue: string, newValue: string, info: ArgsInfo): any {
setValue(oldValue, newValue, info)

@@ -178,3 +180,3 @@ return newValue

class Mdl1 {
set<R>(oldValue: R, newValue: R, info: ArgsInfo): R {
set(oldValue: string, newValue: string, _info: ArgsInfo): any {
return newValue + 'a'

@@ -181,0 +183,0 @@ }

@@ -8,4 +8,4 @@ // @flow

const subscription: Subscription = Observable.from(value).subscribe({
next(value: V) {
atom.set(value)
next(v: V) {
atom.set(v)
},

@@ -12,0 +12,0 @@ complete() {},

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

func === null
|| typeof func !== 'object'
&& typeof func !== 'function'
|| (typeof func !== 'object' && typeof func !== 'function')
) {

@@ -23,0 +22,0 @@ return String(func)

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

case 0:
return new (target: any)
return new (target: any)()
case 1:

@@ -9,0 +9,0 @@ return new (target: any)(args[0])

@@ -13,11 +13,14 @@ // @flow

export interface Middleware {
get?: <R>(value: R, info: ArgsInfo) => R;
set?: <R>(oldValue: R, newValue: R, info: ArgsInfo) => R;
exec?: <R>(resolve: (...args: any[]) => R, args: any[], info: ArgsInfo) => R;
get?: <R: any>(value: R, info: ArgsInfo) => R;
set?: <R: any>(oldValue: R, newValue: R, info: ArgsInfo) => R;
exec?: <R: any>(resolve: (...args: any[]) => R, args: any[], info: ArgsInfo) => R;
}
type OrigFn<R> = (...args: any[]) => R
type Wrap = (type: string, origMethod: OrigFn<*>, obj?: ?Object) => OrigFn<*>
function createExec<R>(middleware: Middleware, method: OrigFn<R>, info: ArgsInfo): (args: any[]) => R {
function createExec<R>(
middleware: Middleware,
method: OrigFn<R>,
info: ArgsInfo
): (args: any[]) => R {
return function exec(args: any[]): R {

@@ -35,3 +38,3 @@ return (middleware.exec: any)(method, args, info)

get(target: T, key: string, receiver: Proxy<T>): any {
get(target: T, key: string, _receiver: Proxy<T>): any {
const prop: mixed = target[key]

@@ -46,3 +49,3 @@ if (typeof prop === 'function') {

const newValue = this._wrapper.set(value, key, target)
target[key] = newValue
target[key] = newValue // eslint-disable-line
return true

@@ -58,3 +61,3 @@ }

constructor(type: string, obj: ?Object, method: Function|string) {
constructor(type: string, obj: ?Object, method: Function | string) {
const propName: string = typeof method === 'string'

@@ -61,0 +64,0 @@ ? method

@@ -12,4 +12,3 @@ // @flow

let k: string
for (k in objA) {
for (let k in objA) { // eslint-disable-line
if (objA[k] !== objB[k]) {

@@ -27,3 +26,3 @@ return false

if (!objA && objB || objA && !objB) {
if ((!objA && objB) || (objA && !objB)) {
return false

@@ -36,4 +35,4 @@ }

let numB: number = 0
for (k in objA) {
numA++
for (k in objA) { // eslint-disable-line
numA++ // eslint-disable-line
if (objA[k] !== objB[k]) {

@@ -43,4 +42,4 @@ return false

}
for (k in objB) {
numB++
for (k in objB) { // eslint-disable-line
numB++ // eslint-disable-line
}

@@ -47,0 +46,0 @@

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