Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const makeHook = storeInterface => {
invariant(isObject(storeInterface), 'The store interface is undefined.');
const { getEntries, ejectionKey, injectionKey, type } = storeInterface;
const pascalCaseType = toPascalCase(type);
const hookName = `use${pascalCaseType}`;
const useInjectables = (injectables, options = {}) => {
const injectableKeys = keys(injectables);
const locationMessage =
`@redux-tools: This warning happened while injecting the following ${type}: ` +
`${injectableKeys}.`;
const warn = (...args) => console.warn(locationMessage, ...args);
// NOTE: `options.global` and `options.persist` are deprecated.
const isGlobal = options.isGlobal || options.global || false;
const isPersistent = options.isPersistent || options.persist || false;
const feature = options.feature || DEFAULT_FEATURE;
const contextNamespace = useNamespace(feature);
'hoist-non-react-statics': 'HoistNonReactStatics',
'prop-types': 'PropTypes',
ramda: 'R',
'ramda-extension': 'R_',
react: 'React',
'react-dom': 'ReactDOM',
'react-union': 'ReactUnion',
};
// eslint-disable-next-line import/no-dynamic-require
const pkg = require(path.join(PACKAGE_ROOT_PATH, 'package.json'));
const dependencies = [...keys(pkg.dependencies), ...keys(pkg.peerDependencies)];
const external = id => dependencies.includes(id) || id.includes('@babel/runtime');
const globalName = toPascalCase(LERNA_PACKAGE_NAME);
const fileName = toKebabCase(LERNA_PACKAGE_NAME);
const umdExternal = ['react', 'react-dom', 'ramda', 'ramda-extension', 'prop-types'];
export default [
// CJS
{
input: INPUT_FILE,
external,
output: {
file: path.join(PACKAGE_ROOT_PATH, 'lib', `${fileName}.js`),
format: 'cjs',
indent: false,
},
plugins: [plugins.babel, plugins.cjs],
},
const makeDecorator = config => {
invariant(isObject(config), 'The injector config is undefined.');
const useInjectables = makeHook(config);
const { type } = config;
const decoratorName = type ? `With${toPascalCase(type)}` : 'Injector';
return (injectables, options = {}) => NextComponent => {
const Injector = ({ feature: propFeature, namespace: propNamespace, ...otherProps }) => {
const feature = options.feature || propFeature || DEFAULT_FEATURE;
const contextNamespace = useNamespace(feature);
const namespace = options.namespace || propNamespace || contextNamespace;
const isInitialized = useInjectables(injectables, { ...options, feature, namespace });
if (isInitialized) {
return (