Comparing version 0.26.2 to 0.26.3
@@ -83,2 +83,30 @@ 'use strict'; | ||
var ActionComponent = function (_Component2) { | ||
(0, _inherits3.default)(ActionComponent, _Component2); | ||
function ActionComponent() { | ||
(0, _classCallCheck3.default)(this, ActionComponent); | ||
return (0, _possibleConstructorReturn3.default)(this, _Component2.apply(this, arguments)); | ||
} | ||
ActionComponent.prototype.render = function render() { | ||
return _react2.default.createElement( | ||
'div', | ||
null, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'actions' }, | ||
(0, _keys2.default)(this.actions).sort().join(',') | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'props' }, | ||
(0, _keys2.default)(this.props).sort().join(',') | ||
) | ||
); | ||
}; | ||
return ActionComponent; | ||
}(_react.Component); | ||
beforeEach(function () { | ||
@@ -324,2 +352,52 @@ (0, _index.resetKeaCache)(); | ||
wrapper.unmount(); | ||
}); | ||
test('doubly connected actions are merged', function () { | ||
var store = (0, _index.getStore)(); | ||
var firstLogic = (0, _index.kea)({ | ||
actions: function actions(_ref13) { | ||
var constants = _ref13.constants; | ||
return { | ||
updateName: function updateName(name) { | ||
return { name: name }; | ||
} | ||
}; | ||
}, | ||
reducers: function reducers(_ref14) { | ||
var _ref15; | ||
var actions = _ref14.actions, | ||
constants = _ref14.constants; | ||
return { | ||
name: ['chirpy', _propTypes2.default.string, (_ref15 = {}, _ref15[actions.updateName] = function (state, payload) { | ||
return payload.name; | ||
}, _ref15)] | ||
}; | ||
} | ||
}); | ||
var secondLogic = (0, _index.kea)({ | ||
actions: function actions(_ref16) { | ||
var constants = _ref16.constants; | ||
return { | ||
updateNameAgain: function updateNameAgain(name) { | ||
return { name: name }; | ||
} | ||
}; | ||
} | ||
}); | ||
var ConnectedComponent = firstLogic(secondLogic(ActionComponent)); | ||
var wrapper = (0, _enzyme.mount)(_react2.default.createElement( | ||
_reactRedux.Provider, | ||
{ store: store }, | ||
_react2.default.createElement(ConnectedComponent, null) | ||
)); | ||
expect(wrapper.find('.props').text()).toEqual('actions,dispatch,name,root'); | ||
expect(wrapper.find('.actions').text()).toEqual('updateName,updateNameAgain'); | ||
wrapper.unmount(); | ||
}); |
@@ -71,9 +71,11 @@ 'use strict'; | ||
function kea(_input) { | ||
// a few helpers for later | ||
var hasManualPath = !!_input.path; | ||
var hasConnect = !!_input.connect; | ||
var hasLogic = !!(_input.actions || _input.reducers || _input.selectors); | ||
// clone the input and add a path if needed | ||
var input = (0, _assign2.default)(_input.path ? {} : { path: createUniquePathFunction() }, _input); | ||
var input = (0, _assign2.default)(hasManualPath ? {} : { path: createUniquePathFunction() }, _input); | ||
var hasConnect = !!input.connect; | ||
var hasDefinedPath = !!_input.path; | ||
var hasLogic = !!(input.actions || input.reducers || input.selectors); | ||
// this will be filled in and passed to plugins as needed | ||
var output = { | ||
@@ -143,3 +145,3 @@ activePlugins: {}, | ||
// ... or the "path" is manually defined, so we must put something in redux | ||
if (hasDefinedPath || input.reducers || input.selectors) { | ||
if (hasManualPath || input.reducers || input.selectors) { | ||
// create the reducers from the input | ||
@@ -366,3 +368,3 @@ output.created.reducerObjects = input.reducers ? (0, _reducer.convertReducerArrays)(input.reducers(output)) : {}; | ||
if (!actions) { | ||
actions = {}; | ||
actions = nextOwnProps.actions ? (0, _assign2.default)({}, nextOwnProps.actions) : {}; | ||
@@ -435,3 +437,3 @@ // pass conneted actions as they are, just wrap with dispatch | ||
// - or it contains some data (e.g. reducers) | ||
response.path = output.isSingleton && (hasDefinedPath || hasLogic) ? output.path : undefined; | ||
response.path = output.isSingleton && (hasManualPath || hasLogic) ? output.path : undefined; | ||
@@ -438,0 +440,0 @@ response.constants = output.constants; |
@@ -83,2 +83,30 @@ 'use strict'; | ||
var ActionComponent = function (_Component2) { | ||
(0, _inherits3.default)(ActionComponent, _Component2); | ||
function ActionComponent() { | ||
(0, _classCallCheck3.default)(this, ActionComponent); | ||
return (0, _possibleConstructorReturn3.default)(this, _Component2.apply(this, arguments)); | ||
} | ||
ActionComponent.prototype.render = function render() { | ||
return _react2.default.createElement( | ||
'div', | ||
null, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'actions' }, | ||
(0, _keys2.default)(this.actions).sort().join(',') | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'props' }, | ||
(0, _keys2.default)(this.props).sort().join(',') | ||
) | ||
); | ||
}; | ||
return ActionComponent; | ||
}(_react.Component); | ||
beforeEach(function () { | ||
@@ -324,2 +352,52 @@ (0, _index.resetKeaCache)(); | ||
wrapper.unmount(); | ||
}); | ||
test('doubly connected actions are merged', function () { | ||
var store = (0, _index.getStore)(); | ||
var firstLogic = (0, _index.kea)({ | ||
actions: function actions(_ref13) { | ||
var constants = _ref13.constants; | ||
return { | ||
updateName: function updateName(name) { | ||
return { name: name }; | ||
} | ||
}; | ||
}, | ||
reducers: function reducers(_ref14) { | ||
var _ref15; | ||
var actions = _ref14.actions, | ||
constants = _ref14.constants; | ||
return { | ||
name: ['chirpy', _propTypes2.default.string, (_ref15 = {}, _ref15[actions.updateName] = function (state, payload) { | ||
return payload.name; | ||
}, _ref15)] | ||
}; | ||
} | ||
}); | ||
var secondLogic = (0, _index.kea)({ | ||
actions: function actions(_ref16) { | ||
var constants = _ref16.constants; | ||
return { | ||
updateNameAgain: function updateNameAgain(name) { | ||
return { name: name }; | ||
} | ||
}; | ||
} | ||
}); | ||
var ConnectedComponent = firstLogic(secondLogic(ActionComponent)); | ||
var wrapper = (0, _enzyme.mount)(_react2.default.createElement( | ||
_reactRedux.Provider, | ||
{ store: store }, | ||
_react2.default.createElement(ConnectedComponent, null) | ||
)); | ||
expect(wrapper.find('.props').text()).toEqual('actions,dispatch,name,root'); | ||
expect(wrapper.find('.actions').text()).toEqual('updateName,updateNameAgain'); | ||
wrapper.unmount(); | ||
}); |
@@ -71,9 +71,11 @@ 'use strict'; | ||
function kea(_input) { | ||
// a few helpers for later | ||
var hasManualPath = !!_input.path; | ||
var hasConnect = !!_input.connect; | ||
var hasLogic = !!(_input.actions || _input.reducers || _input.selectors); | ||
// clone the input and add a path if needed | ||
var input = (0, _assign2.default)(_input.path ? {} : { path: createUniquePathFunction() }, _input); | ||
var input = (0, _assign2.default)(hasManualPath ? {} : { path: createUniquePathFunction() }, _input); | ||
var hasConnect = !!input.connect; | ||
var hasDefinedPath = !!_input.path; | ||
var hasLogic = !!(input.actions || input.reducers || input.selectors); | ||
// this will be filled in and passed to plugins as needed | ||
var output = { | ||
@@ -143,3 +145,3 @@ activePlugins: {}, | ||
// ... or the "path" is manually defined, so we must put something in redux | ||
if (hasDefinedPath || input.reducers || input.selectors) { | ||
if (hasManualPath || input.reducers || input.selectors) { | ||
// create the reducers from the input | ||
@@ -366,3 +368,3 @@ output.created.reducerObjects = input.reducers ? (0, _reducer.convertReducerArrays)(input.reducers(output)) : {}; | ||
if (!actions) { | ||
actions = {}; | ||
actions = nextOwnProps.actions ? (0, _assign2.default)({}, nextOwnProps.actions) : {}; | ||
@@ -435,3 +437,3 @@ // pass conneted actions as they are, just wrap with dispatch | ||
// - or it contains some data (e.g. reducers) | ||
response.path = output.isSingleton && (hasDefinedPath || hasLogic) ? output.path : undefined; | ||
response.path = output.isSingleton && (hasManualPath || hasLogic) ? output.path : undefined; | ||
@@ -438,0 +440,0 @@ response.constants = output.constants; |
{ | ||
"name": "kea", | ||
"version": "0.26.2", | ||
"version": "0.26.3", | ||
"description": "Smart front-end architecture", | ||
@@ -26,11 +26,13 @@ "author": "Marius Andra", | ||
"scripts": { | ||
"build": "npm run lint && npm run build:cjs && npm run build:es", | ||
"build": "npm run lint && concurrently \"npm run build:cjs\" \"npm run build:es\"", | ||
"build:cjs": "babel src --out-dir lib", | ||
"build:es": "BABEL_ENV=es babel src --out-dir es", | ||
"start": "BABEL_ENV=es babel -w src --out-dir es", | ||
"start": "concurrently --kill-others \"npm run start:cjs\" \"npm run start:es\"", | ||
"start:cjs": "babel -w src --out-dir lib", | ||
"start:es": "BABEL_ENV=es babel -w src --out-dir es", | ||
"size": "size-limit", | ||
"test": "jest", | ||
"lint": "eslint src/**", | ||
"prepublish": "npm run build" | ||
"prepublish": "npm run build", | ||
"rollup": "rollup -c" | ||
}, | ||
@@ -71,2 +73,3 @@ "files": [ | ||
"babel-preset-react": "^6.24.1", | ||
"concurrently": "^3.5.0", | ||
"enzyme": "^2.9.1", | ||
@@ -91,4 +94,9 @@ "eslint": "^4.6.1", | ||
"reselect": "^3.0.1", | ||
"rollup": "^0.50.0", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-replace": "^2.0.0", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"size-limit": "^0.11.3" | ||
} | ||
} |
 | ||
 | ||
 | ||
@@ -5,0 +5,0 @@ A `kea` is two things: |
@@ -26,2 +26,13 @@ /* global test, expect, beforeEach */ | ||
class ActionComponent extends Component { | ||
render () { | ||
return ( | ||
<div> | ||
<div className='actions'>{Object.keys(this.actions).sort().join(',')}</div> | ||
<div className='props'>{Object.keys(this.props).sort().join(',')}</div> | ||
</div> | ||
) | ||
} | ||
} | ||
beforeEach(() => { | ||
@@ -218,1 +229,35 @@ resetKeaCache() | ||
}) | ||
test('doubly connected actions are merged', () => { | ||
const store = getStore() | ||
const firstLogic = kea({ | ||
actions: ({ constants }) => ({ | ||
updateName: name => ({ name }) | ||
}), | ||
reducers: ({ actions, constants }) => ({ | ||
name: ['chirpy', PropTypes.string, { | ||
[actions.updateName]: (state, payload) => payload.name | ||
}] | ||
}) | ||
}) | ||
const secondLogic = kea({ | ||
actions: ({ constants }) => ({ | ||
updateNameAgain: name => ({ name }) | ||
}) | ||
}) | ||
const ConnectedComponent = firstLogic(secondLogic(ActionComponent)) | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<ConnectedComponent /> | ||
</Provider> | ||
) | ||
expect(wrapper.find('.props').text()).toEqual('actions,dispatch,name,root') | ||
expect(wrapper.find('.actions').text()).toEqual('updateName,updateNameAgain') | ||
wrapper.unmount() | ||
}) |
@@ -38,9 +38,11 @@ import { selectPropsFromLogic } from './connect/props' | ||
export function kea (_input) { | ||
// a few helpers for later | ||
const hasManualPath = !!_input.path | ||
const hasConnect = !!(_input.connect) | ||
const hasLogic = !!(_input.actions || _input.reducers || _input.selectors) | ||
// clone the input and add a path if needed | ||
const input = Object.assign(_input.path ? {} : { path: createUniquePathFunction() }, _input) | ||
const input = Object.assign(hasManualPath ? {} : { path: createUniquePathFunction() }, _input) | ||
const hasConnect = !!(input.connect) | ||
const hasDefinedPath = !!_input.path | ||
const hasLogic = !!(input.actions || input.reducers || input.selectors) | ||
// this will be filled in and passed to plugins as needed | ||
let output = { | ||
@@ -110,3 +112,3 @@ activePlugins: {}, | ||
// ... or the "path" is manually defined, so we must put something in redux | ||
if (hasDefinedPath || input.reducers || input.selectors) { | ||
if (hasManualPath || input.reducers || input.selectors) { | ||
// create the reducers from the input | ||
@@ -329,3 +331,3 @@ output.created.reducerObjects = input.reducers ? convertReducerArrays(input.reducers(output)) : {} | ||
if (!actions) { | ||
actions = {} | ||
actions = nextOwnProps.actions ? Object.assign({}, nextOwnProps.actions) : {} | ||
@@ -387,3 +389,3 @@ // pass conneted actions as they are, just wrap with dispatch | ||
// - or it contains some data (e.g. reducers) | ||
response.path = output.isSingleton && (hasDefinedPath || hasLogic) ? output.path : undefined | ||
response.path = output.isSingleton && (hasManualPath || hasLogic) ? output.path : undefined | ||
@@ -390,0 +392,0 @@ response.constants = output.constants |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3
0
223920
35
68
5209