Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Fix bug that blocks plugin from using versions of React-Redux >= v6 #200

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cuprc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
babel: {
presets: [require.resolve('@babel/preset-react')],
plugins: [require.resolve('babel-plugin-transform-flow-strip-types')],
},
};
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules/
dist/
dist-tests/
coverage/
.nyc_output/
Expand Down
145 changes: 145 additions & 0 deletions dist/browser.es2015.es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import PropTypes from 'prop-types';
import React, { Component, Children } from 'react';
import { ReactReduxContext } from 'react-redux';
import { createRPCHandler, createRPCReactors, createRPCReducer } from 'fusion-rpc-redux';
export { createRPCReducer } from 'fusion-rpc-redux';
import { ProviderPlugin } from 'fusion-react';
import rpc, { mock, BodyParserOptionsToken, RPCToken, RPCHandlersToken, ResponseError } from 'fusion-plugin-rpc';
export { BodyParserOptionsToken, ResponseError, RPCToken, RPCHandlersToken } from 'fusion-plugin-rpc';

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/** Copyright (c) 2018 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function withRPCReactor(rpcId, reducers, {
propName,
transformParams,
mapStateToParams
} = {}) {
return withRPCRedux(rpcId, {
actions: createRPCReactors(rpcId, reducers),
propName,
rpcId,
transformParams,
mapStateToParams
});
}
function withRPCRedux(rpcId, {
propName = rpcId,
actions,
transformParams,
mapStateToParams
} = {}) {
return Component$$1 => {
const withRPCRedux = (oldProps, context) => {
const {
rpc: rpc$$1
} = context;
return context.store && !ReactReduxContext ? function () {
// eslint-disable-next-line no-console
console.warn('Warning: React-Redux 5 is deprecated. Please upgrade to a verion of React-Redux >= 6 when using fusion-plugin-rpc-redux-react.');

if (mapStateToParams) {
const mapState = mapStateToParams;

mapStateToParams = (state, args) => mapState(state, args, oldProps);
}

const handler = createRPCHandler({
rpcId,
rpc: rpc$$1,
store: context.store,
actions,
mapStateToParams,
transformParams
});

const props = _objectSpread({}, oldProps, {
[propName]: handler
});

return React.createElement(Component$$1, props);
}() : React.createElement(ReactReduxContext.Consumer, null, ({
store
}) => {
if (mapStateToParams) {
const mapState = mapStateToParams;

mapStateToParams = (state, args) => mapState(state, args, oldProps);
}

const handler = createRPCHandler({
rpcId,
rpc: rpc$$1,
store,
actions,
mapStateToParams,
transformParams
});

const props = _objectSpread({}, oldProps, {
[propName]: handler
});

return React.createElement(Component$$1, props);
});
};

const displayName = Component$$1.displayName || Component$$1.name || 'Anonymous';
withRPCRedux.displayName = 'WithRPCRedux' + '(' + displayName + ')';
withRPCRedux.contextTypes = {
rpc: PropTypes.object.isRequired,
store: PropTypes.object
};
return withRPCRedux;
};
}

/** Copyright (c) 2018 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
class RPCProvider extends Component {
constructor(props, context) {
super(props, context);
this.rpc = props.provides.from(props.ctx);
}

getChildContext() {
return {
rpc: this.rpc
};
}

render() {
return Children.only(this.props.children);
}

}

RPCProvider.childContextTypes = {
rpc: PropTypes.object.isRequired
};
var plugin = ProviderPlugin.create('rpc', rpc, RPCProvider);
const mock$1 = ProviderPlugin.create('rpc', mock, RPCProvider);

/** Copyright (c) 2018 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

export default plugin;
export { mock$1 as mock, withRPCRedux, withRPCReactor };
145 changes: 145 additions & 0 deletions dist/browser.es2017.es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import PropTypes from 'prop-types';
import React, { Component, Children } from 'react';
import { ReactReduxContext } from 'react-redux';
import { createRPCHandler, createRPCReactors, createRPCReducer } from 'fusion-rpc-redux';
export { createRPCReducer } from 'fusion-rpc-redux';
import { ProviderPlugin } from 'fusion-react';
import rpc, { mock, BodyParserOptionsToken, RPCToken, RPCHandlersToken, ResponseError } from 'fusion-plugin-rpc';
export { BodyParserOptionsToken, ResponseError, RPCToken, RPCHandlersToken } from 'fusion-plugin-rpc';

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/** Copyright (c) 2018 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
function withRPCReactor(rpcId, reducers, {
propName,
transformParams,
mapStateToParams
} = {}) {
return withRPCRedux(rpcId, {
actions: createRPCReactors(rpcId, reducers),
propName,
rpcId,
transformParams,
mapStateToParams
});
}
function withRPCRedux(rpcId, {
propName = rpcId,
actions,
transformParams,
mapStateToParams
} = {}) {
return Component$$1 => {
const withRPCRedux = (oldProps, context) => {
const {
rpc: rpc$$1
} = context;
return context.store && !ReactReduxContext ? function () {
// eslint-disable-next-line no-console
console.warn('Warning: React-Redux 5 is deprecated. Please upgrade to a verion of React-Redux >= 6 when using fusion-plugin-rpc-redux-react.');

if (mapStateToParams) {
const mapState = mapStateToParams;

mapStateToParams = (state, args) => mapState(state, args, oldProps);
}

const handler = createRPCHandler({
rpcId,
rpc: rpc$$1,
store: context.store,
actions,
mapStateToParams,
transformParams
});

const props = _objectSpread({}, oldProps, {
[propName]: handler
});

return React.createElement(Component$$1, props);
}() : React.createElement(ReactReduxContext.Consumer, null, ({
store
}) => {
if (mapStateToParams) {
const mapState = mapStateToParams;

mapStateToParams = (state, args) => mapState(state, args, oldProps);
}

const handler = createRPCHandler({
rpcId,
rpc: rpc$$1,
store,
actions,
mapStateToParams,
transformParams
});

const props = _objectSpread({}, oldProps, {
[propName]: handler
});

return React.createElement(Component$$1, props);
});
};

const displayName = Component$$1.displayName || Component$$1.name || 'Anonymous';
withRPCRedux.displayName = 'WithRPCRedux' + '(' + displayName + ')';
withRPCRedux.contextTypes = {
rpc: PropTypes.object.isRequired,
store: PropTypes.object
};
return withRPCRedux;
};
}

/** Copyright (c) 2018 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
class RPCProvider extends Component {
constructor(props, context) {
super(props, context);
this.rpc = props.provides.from(props.ctx);
}

getChildContext() {
return {
rpc: this.rpc
};
}

render() {
return Children.only(this.props.children);
}

}

RPCProvider.childContextTypes = {
rpc: PropTypes.object.isRequired
};
var plugin = ProviderPlugin.create('rpc', rpc, RPCProvider);
const mock$1 = ProviderPlugin.create('rpc', mock, RPCProvider);

/** Copyright (c) 2018 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

export default plugin;
export { mock$1 as mock, withRPCRedux, withRPCReactor };
Loading