This commit is contained in:
21
node_modules/react-redux/LICENSE.md
generated
vendored
Normal file
21
node_modules/react-redux/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Dan Abramov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
64
node_modules/react-redux/README.md
generated
vendored
Normal file
64
node_modules/react-redux/README.md
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# React Redux
|
||||
|
||||
Official React bindings for [Redux](https://github.com/reduxjs/redux).
|
||||
Performant and flexible.
|
||||
|
||||
 [](https://www.npmjs.com/package/react-redux)
|
||||
[](https://www.npmjs.com/package/react-redux)
|
||||
[](http://www.reactiflux.com)
|
||||
|
||||
## Installation
|
||||
|
||||
### Using Create React App
|
||||
|
||||
The recommended way to start new apps with React Redux is by using the [official Redux+JS template](https://github.com/reduxjs/cra-template-redux) for [Create React App](https://github.com/facebook/create-react-app), which takes advantage of [Redux Toolkit](https://redux-toolkit.js.org/).
|
||||
|
||||
```sh
|
||||
npx create-react-app my-app --template redux
|
||||
```
|
||||
|
||||
### An Existing React App
|
||||
|
||||
React Redux 7.1 requires **React 16.8.3 or later.**
|
||||
|
||||
To use React Redux with your React app, install it as a dependency:
|
||||
|
||||
```bash
|
||||
# If you use npm:
|
||||
npm install react-redux
|
||||
|
||||
# Or if you use Yarn:
|
||||
yarn add react-redux
|
||||
```
|
||||
|
||||
You'll also need to [install Redux](https://redux.js.org/introduction/installation) and [set up a Redux store](https://redux.js.org/recipes/configuring-your-store/) in your app.
|
||||
|
||||
This assumes that you’re using [npm](http://npmjs.com/) package manager
|
||||
with a module bundler like [Webpack](https://webpack.js.org/) or
|
||||
[Browserify](http://browserify.org/) to consume [CommonJS
|
||||
modules](https://webpack.js.org/api/module-methods/#commonjs).
|
||||
|
||||
If you don’t yet use [npm](http://npmjs.com/) or a modern module bundler, and would rather prefer a single-file [UMD](https://github.com/umdjs/umd) build that makes `ReactRedux` available as a global object, you can grab a pre-built version from [cdnjs](https://cdnjs.com/libraries/react-redux). We _don’t_ recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on [npm](http://npmjs.com/).
|
||||
|
||||
## React Native
|
||||
|
||||
As of React Native 0.18, React Redux 5.x should work with React Native. If you have any issues with React Redux 5.x on React Native, run `npm ls react` and make sure you don’t have a duplicate React installation in your `node_modules`. We recommend that you use `npm@3.x` which is better at avoiding these kinds of issues.
|
||||
|
||||
## Documentation
|
||||
|
||||
The React Redux docs are now published at **https://react-redux.js.org** .
|
||||
|
||||
We're currently expanding and rewriting our docs content - check back soon for more updates!
|
||||
|
||||
## How Does It Work?
|
||||
|
||||
We do a deep dive on how React Redux works in [this readthesource episode](https://www.youtube.com/watch?v=VJ38wSFbM3A).
|
||||
|
||||
Also, the post [The History and Implementation of React-Redux](https://blog.isquaredsoftware.com/2018/11/react-redux-history-implementation/)
|
||||
explains what it does, how it works, and how the API and implementation have evolved over time.
|
||||
|
||||
Enjoy!
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE.md)
|
||||
2834
node_modules/react-redux/dist/react-redux.js
generated
vendored
Normal file
2834
node_modules/react-redux/dist/react-redux.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/react-redux/dist/react-redux.min.js
generated
vendored
Normal file
1
node_modules/react-redux/dist/react-redux.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/react-redux/es/alternate-renderers.js
generated
vendored
Normal file
6
node_modules/react-redux/es/alternate-renderers.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './exports';
|
||||
import { getBatch } from './utils/batch'; // For other renderers besides ReactDOM and React Native,
|
||||
// use the default noop batch function
|
||||
|
||||
var batch = getBatch();
|
||||
export { batch };
|
||||
8
node_modules/react-redux/es/components/Context.js
generated
vendored
Normal file
8
node_modules/react-redux/es/components/Context.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
export var ReactReduxContext = /*#__PURE__*/React.createContext(null);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ReactReduxContext.displayName = 'ReactRedux';
|
||||
}
|
||||
|
||||
export default ReactReduxContext;
|
||||
53
node_modules/react-redux/es/components/Provider.js
generated
vendored
Normal file
53
node_modules/react-redux/es/components/Provider.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ReactReduxContext } from './Context';
|
||||
import { createSubscription } from '../utils/Subscription';
|
||||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
|
||||
|
||||
function Provider(_ref) {
|
||||
var store = _ref.store,
|
||||
context = _ref.context,
|
||||
children = _ref.children;
|
||||
var contextValue = useMemo(function () {
|
||||
var subscription = createSubscription(store);
|
||||
return {
|
||||
store: store,
|
||||
subscription: subscription
|
||||
};
|
||||
}, [store]);
|
||||
var previousState = useMemo(function () {
|
||||
return store.getState();
|
||||
}, [store]);
|
||||
useIsomorphicLayoutEffect(function () {
|
||||
var subscription = contextValue.subscription;
|
||||
subscription.onStateChange = subscription.notifyNestedSubs;
|
||||
subscription.trySubscribe();
|
||||
|
||||
if (previousState !== store.getState()) {
|
||||
subscription.notifyNestedSubs();
|
||||
}
|
||||
|
||||
return function () {
|
||||
subscription.tryUnsubscribe();
|
||||
subscription.onStateChange = null;
|
||||
};
|
||||
}, [contextValue, previousState]);
|
||||
var Context = context || ReactReduxContext;
|
||||
return /*#__PURE__*/React.createElement(Context.Provider, {
|
||||
value: contextValue
|
||||
}, children);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Provider.propTypes = {
|
||||
store: PropTypes.shape({
|
||||
subscribe: PropTypes.func.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
getState: PropTypes.func.isRequired
|
||||
}),
|
||||
context: PropTypes.object,
|
||||
children: PropTypes.any
|
||||
};
|
||||
}
|
||||
|
||||
export default Provider;
|
||||
377
node_modules/react-redux/es/components/connectAdvanced.js
generated
vendored
Normal file
377
node_modules/react-redux/es/components/connectAdvanced.js
generated
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
var _excluded = ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"],
|
||||
_excluded2 = ["reactReduxForwardedRef"];
|
||||
import hoistStatics from 'hoist-non-react-statics';
|
||||
import React, { useContext, useMemo, useRef, useReducer } from 'react';
|
||||
import { isValidElementType, isContextConsumer } from 'react-is';
|
||||
import { createSubscription } from '../utils/Subscription';
|
||||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
|
||||
import { ReactReduxContext } from './Context'; // Define some constant arrays just to avoid re-creating these
|
||||
|
||||
var EMPTY_ARRAY = [];
|
||||
var NO_SUBSCRIPTION_ARRAY = [null, null];
|
||||
|
||||
var stringifyComponent = function stringifyComponent(Comp) {
|
||||
try {
|
||||
return JSON.stringify(Comp);
|
||||
} catch (err) {
|
||||
return String(Comp);
|
||||
}
|
||||
};
|
||||
|
||||
function storeStateUpdatesReducer(state, action) {
|
||||
var updateCount = state[1];
|
||||
return [action.payload, updateCount + 1];
|
||||
}
|
||||
|
||||
function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
|
||||
useIsomorphicLayoutEffect(function () {
|
||||
return effectFunc.apply(void 0, effectArgs);
|
||||
}, dependencies);
|
||||
}
|
||||
|
||||
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs) {
|
||||
// We want to capture the wrapper props and child props we used for later comparisons
|
||||
lastWrapperProps.current = wrapperProps;
|
||||
lastChildProps.current = actualChildProps;
|
||||
renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update
|
||||
|
||||
if (childPropsFromStoreUpdate.current) {
|
||||
childPropsFromStoreUpdate.current = null;
|
||||
notifyNestedSubs();
|
||||
}
|
||||
}
|
||||
|
||||
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch) {
|
||||
// If we're not subscribed to the store, nothing to do here
|
||||
if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts
|
||||
|
||||
var didUnsubscribe = false;
|
||||
var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component
|
||||
|
||||
var checkForUpdates = function checkForUpdates() {
|
||||
if (didUnsubscribe) {
|
||||
// Don't run stale listeners.
|
||||
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
|
||||
return;
|
||||
}
|
||||
|
||||
var latestStoreState = store.getState();
|
||||
var newChildProps, error;
|
||||
|
||||
try {
|
||||
// Actually run the selector with the most recent store state and wrapper props
|
||||
// to determine what the child props should be
|
||||
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
lastThrownError = e;
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
lastThrownError = null;
|
||||
} // If the child props haven't changed, nothing to do here - cascade the subscription update
|
||||
|
||||
|
||||
if (newChildProps === lastChildProps.current) {
|
||||
if (!renderIsScheduled.current) {
|
||||
notifyNestedSubs();
|
||||
}
|
||||
} else {
|
||||
// Save references to the new child props. Note that we track the "child props from store update"
|
||||
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
|
||||
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
|
||||
// forcing another re-render, which we don't want.
|
||||
lastChildProps.current = newChildProps;
|
||||
childPropsFromStoreUpdate.current = newChildProps;
|
||||
renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
|
||||
|
||||
forceComponentUpdateDispatch({
|
||||
type: 'STORE_UPDATED',
|
||||
payload: {
|
||||
error: error
|
||||
}
|
||||
});
|
||||
}
|
||||
}; // Actually subscribe to the nearest connected ancestor (or store)
|
||||
|
||||
|
||||
subscription.onStateChange = checkForUpdates;
|
||||
subscription.trySubscribe(); // Pull data from the store after first render in case the store has
|
||||
// changed since we began.
|
||||
|
||||
checkForUpdates();
|
||||
|
||||
var unsubscribeWrapper = function unsubscribeWrapper() {
|
||||
didUnsubscribe = true;
|
||||
subscription.tryUnsubscribe();
|
||||
subscription.onStateChange = null;
|
||||
|
||||
if (lastThrownError) {
|
||||
// It's possible that we caught an error due to a bad mapState function, but the
|
||||
// parent re-rendered without this component and we're about to unmount.
|
||||
// This shouldn't happen as long as we do top-down subscriptions correctly, but
|
||||
// if we ever do those wrong, this throw will surface the error in our tests.
|
||||
// In that case, throw the error from here so it doesn't get lost.
|
||||
throw lastThrownError;
|
||||
}
|
||||
};
|
||||
|
||||
return unsubscribeWrapper;
|
||||
}
|
||||
|
||||
var initStateUpdates = function initStateUpdates() {
|
||||
return [null, 0];
|
||||
};
|
||||
|
||||
export default function connectAdvanced(
|
||||
/*
|
||||
selectorFactory is a func that is responsible for returning the selector function used to
|
||||
compute new props from state, props, and dispatch. For example:
|
||||
export default connectAdvanced((dispatch, options) => (state, props) => ({
|
||||
thing: state.things[props.thingId],
|
||||
saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)),
|
||||
}))(YourComponent)
|
||||
Access to dispatch is provided to the factory so selectorFactories can bind actionCreators
|
||||
outside of their selector as an optimization. Options passed to connectAdvanced are passed to
|
||||
the selectorFactory, along with displayName and WrappedComponent, as the second argument.
|
||||
Note that selectorFactory is responsible for all caching/memoization of inbound and outbound
|
||||
props. Do not use connectAdvanced directly without memoizing results between calls to your
|
||||
selector, otherwise the Connect component will re-render on every state or props change.
|
||||
*/
|
||||
selectorFactory, // options object:
|
||||
_ref) {
|
||||
if (_ref === void 0) {
|
||||
_ref = {};
|
||||
}
|
||||
|
||||
var _ref2 = _ref,
|
||||
_ref2$getDisplayName = _ref2.getDisplayName,
|
||||
getDisplayName = _ref2$getDisplayName === void 0 ? function (name) {
|
||||
return "ConnectAdvanced(" + name + ")";
|
||||
} : _ref2$getDisplayName,
|
||||
_ref2$methodName = _ref2.methodName,
|
||||
methodName = _ref2$methodName === void 0 ? 'connectAdvanced' : _ref2$methodName,
|
||||
_ref2$renderCountProp = _ref2.renderCountProp,
|
||||
renderCountProp = _ref2$renderCountProp === void 0 ? undefined : _ref2$renderCountProp,
|
||||
_ref2$shouldHandleSta = _ref2.shouldHandleStateChanges,
|
||||
shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta,
|
||||
_ref2$storeKey = _ref2.storeKey,
|
||||
storeKey = _ref2$storeKey === void 0 ? 'store' : _ref2$storeKey,
|
||||
_ref2$withRef = _ref2.withRef,
|
||||
withRef = _ref2$withRef === void 0 ? false : _ref2$withRef,
|
||||
_ref2$forwardRef = _ref2.forwardRef,
|
||||
forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef,
|
||||
_ref2$context = _ref2.context,
|
||||
context = _ref2$context === void 0 ? ReactReduxContext : _ref2$context,
|
||||
connectOptions = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (renderCountProp !== undefined) {
|
||||
throw new Error("renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension");
|
||||
}
|
||||
|
||||
if (withRef) {
|
||||
throw new Error('withRef is removed. To access the wrapped instance, use a ref on the connected component');
|
||||
}
|
||||
|
||||
var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect';
|
||||
|
||||
if (storeKey !== 'store') {
|
||||
throw new Error('storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var Context = context;
|
||||
return function wrapWithConnect(WrappedComponent) {
|
||||
if (process.env.NODE_ENV !== 'production' && !isValidElementType(WrappedComponent)) {
|
||||
throw new Error("You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
|
||||
}
|
||||
|
||||
var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
var displayName = getDisplayName(wrappedComponentName);
|
||||
|
||||
var selectorFactoryOptions = _extends({}, connectOptions, {
|
||||
getDisplayName: getDisplayName,
|
||||
methodName: methodName,
|
||||
renderCountProp: renderCountProp,
|
||||
shouldHandleStateChanges: shouldHandleStateChanges,
|
||||
storeKey: storeKey,
|
||||
displayName: displayName,
|
||||
wrappedComponentName: wrappedComponentName,
|
||||
WrappedComponent: WrappedComponent
|
||||
});
|
||||
|
||||
var pure = connectOptions.pure;
|
||||
|
||||
function createChildSelector(store) {
|
||||
return selectorFactory(store.dispatch, selectorFactoryOptions);
|
||||
} // If we aren't running in "pure" mode, we don't want to memoize values.
|
||||
// To avoid conditionally calling hooks, we fall back to a tiny wrapper
|
||||
// that just executes the given callback immediately.
|
||||
|
||||
|
||||
var usePureOnlyMemo = pure ? useMemo : function (callback) {
|
||||
return callback();
|
||||
};
|
||||
|
||||
function ConnectFunction(props) {
|
||||
var _useMemo = useMemo(function () {
|
||||
// Distinguish between actual "data" props that were passed to the wrapper component,
|
||||
// and values needed to control behavior (forwarded refs, alternate context instances).
|
||||
// To maintain the wrapperProps object reference, memoize this destructuring.
|
||||
var reactReduxForwardedRef = props.reactReduxForwardedRef,
|
||||
wrapperProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
||||
|
||||
return [props.context, reactReduxForwardedRef, wrapperProps];
|
||||
}, [props]),
|
||||
propsContext = _useMemo[0],
|
||||
reactReduxForwardedRef = _useMemo[1],
|
||||
wrapperProps = _useMemo[2];
|
||||
|
||||
var ContextToUse = useMemo(function () {
|
||||
// Users may optionally pass in a custom context instance to use instead of our ReactReduxContext.
|
||||
// Memoize the check that determines which context instance we should use.
|
||||
return propsContext && propsContext.Consumer && isContextConsumer( /*#__PURE__*/React.createElement(propsContext.Consumer, null)) ? propsContext : Context;
|
||||
}, [propsContext, Context]); // Retrieve the store and ancestor subscription via context, if available
|
||||
|
||||
var contextValue = useContext(ContextToUse); // The store _must_ exist as either a prop or in context.
|
||||
// We'll check to see if it _looks_ like a Redux store first.
|
||||
// This allows us to pass through a `store` prop that is just a plain value.
|
||||
|
||||
var didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch);
|
||||
var didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !didStoreComeFromProps && !didStoreComeFromContext) {
|
||||
throw new Error("Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options."));
|
||||
} // Based on the previous check, one of these must be true
|
||||
|
||||
|
||||
var store = didStoreComeFromProps ? props.store : contextValue.store;
|
||||
var childPropsSelector = useMemo(function () {
|
||||
// The child props selector needs the store reference as an input.
|
||||
// Re-create this selector whenever the store changes.
|
||||
return createChildSelector(store);
|
||||
}, [store]);
|
||||
|
||||
var _useMemo2 = useMemo(function () {
|
||||
if (!shouldHandleStateChanges) return NO_SUBSCRIPTION_ARRAY; // This Subscription's source should match where store came from: props vs. context. A component
|
||||
// connected to the store via props shouldn't use subscription from context, or vice versa.
|
||||
|
||||
// This Subscription's source should match where store came from: props vs. context. A component
|
||||
// connected to the store via props shouldn't use subscription from context, or vice versa.
|
||||
var subscription = createSubscription(store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
|
||||
// the middle of the notification loop, where `subscription` will then be null. This can
|
||||
// probably be avoided if Subscription's listeners logic is changed to not call listeners
|
||||
// that have been unsubscribed in the middle of the notification loop.
|
||||
|
||||
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
|
||||
// the middle of the notification loop, where `subscription` will then be null. This can
|
||||
// probably be avoided if Subscription's listeners logic is changed to not call listeners
|
||||
// that have been unsubscribed in the middle of the notification loop.
|
||||
var notifyNestedSubs = subscription.notifyNestedSubs.bind(subscription);
|
||||
return [subscription, notifyNestedSubs];
|
||||
}, [store, didStoreComeFromProps, contextValue]),
|
||||
subscription = _useMemo2[0],
|
||||
notifyNestedSubs = _useMemo2[1]; // Determine what {store, subscription} value should be put into nested context, if necessary,
|
||||
// and memoize that value to avoid unnecessary context updates.
|
||||
|
||||
|
||||
var overriddenContextValue = useMemo(function () {
|
||||
if (didStoreComeFromProps) {
|
||||
// This component is directly subscribed to a store from props.
|
||||
// We don't want descendants reading from this store - pass down whatever
|
||||
// the existing context value is from the nearest connected ancestor.
|
||||
return contextValue;
|
||||
} // Otherwise, put this component's subscription instance into context, so that
|
||||
// connected descendants won't update until after this component is done
|
||||
|
||||
|
||||
return _extends({}, contextValue, {
|
||||
subscription: subscription
|
||||
});
|
||||
}, [didStoreComeFromProps, contextValue, subscription]); // We need to force this wrapper component to re-render whenever a Redux store update
|
||||
// causes a change to the calculated child component props (or we caught an error in mapState)
|
||||
|
||||
var _useReducer = useReducer(storeStateUpdatesReducer, EMPTY_ARRAY, initStateUpdates),
|
||||
_useReducer$ = _useReducer[0],
|
||||
previousStateUpdateResult = _useReducer$[0],
|
||||
forceComponentUpdateDispatch = _useReducer[1]; // Propagate any mapState/mapDispatch errors upwards
|
||||
|
||||
|
||||
if (previousStateUpdateResult && previousStateUpdateResult.error) {
|
||||
throw previousStateUpdateResult.error;
|
||||
} // Set up refs to coordinate values between the subscription effect and the render logic
|
||||
|
||||
|
||||
var lastChildProps = useRef();
|
||||
var lastWrapperProps = useRef(wrapperProps);
|
||||
var childPropsFromStoreUpdate = useRef();
|
||||
var renderIsScheduled = useRef(false);
|
||||
var actualChildProps = usePureOnlyMemo(function () {
|
||||
// Tricky logic here:
|
||||
// - This render may have been triggered by a Redux store update that produced new child props
|
||||
// - However, we may have gotten new wrapper props after that
|
||||
// If we have new child props, and the same wrapper props, we know we should use the new child props as-is.
|
||||
// But, if we have new wrapper props, those might change the child props, so we have to recalculate things.
|
||||
// So, we'll use the child props from store update only if the wrapper props are the same as last time.
|
||||
if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) {
|
||||
return childPropsFromStoreUpdate.current;
|
||||
} // TODO We're reading the store directly in render() here. Bad idea?
|
||||
// This will likely cause Bad Things (TM) to happen in Concurrent Mode.
|
||||
// Note that we do this because on renders _not_ caused by store updates, we need the latest store state
|
||||
// to determine what the child props should be.
|
||||
|
||||
|
||||
return childPropsSelector(store.getState(), wrapperProps);
|
||||
}, [store, previousStateUpdateResult, wrapperProps]); // We need this to execute synchronously every time we re-render. However, React warns
|
||||
// about useLayoutEffect in SSR, so we try to detect environment and fall back to
|
||||
// just useEffect instead to avoid the warning, since neither will run anyway.
|
||||
|
||||
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs]); // Our re-subscribe logic only runs when the store/subscription setup changes
|
||||
|
||||
useIsomorphicLayoutEffectWithArgs(subscribeUpdates, [shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch], [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component.
|
||||
// We memoize the elements for the rendered child component as an optimization.
|
||||
|
||||
var renderedWrappedComponent = useMemo(function () {
|
||||
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, actualChildProps, {
|
||||
ref: reactReduxForwardedRef
|
||||
}));
|
||||
}, [reactReduxForwardedRef, WrappedComponent, actualChildProps]); // If React sees the exact same element reference as last time, it bails out of re-rendering
|
||||
// that child, same as if it was wrapped in React.memo() or returned false from shouldComponentUpdate.
|
||||
|
||||
var renderedChild = useMemo(function () {
|
||||
if (shouldHandleStateChanges) {
|
||||
// If this component is subscribed to store updates, we need to pass its own
|
||||
// subscription instance down to our descendants. That means rendering the same
|
||||
// Context instance, and putting a different value into the context.
|
||||
return /*#__PURE__*/React.createElement(ContextToUse.Provider, {
|
||||
value: overriddenContextValue
|
||||
}, renderedWrappedComponent);
|
||||
}
|
||||
|
||||
return renderedWrappedComponent;
|
||||
}, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
|
||||
return renderedChild;
|
||||
} // If we're in "pure" mode, ensure our wrapper component only re-renders when incoming props have changed.
|
||||
|
||||
|
||||
var Connect = pure ? React.memo(ConnectFunction) : ConnectFunction;
|
||||
Connect.WrappedComponent = WrappedComponent;
|
||||
Connect.displayName = ConnectFunction.displayName = displayName;
|
||||
|
||||
if (forwardRef) {
|
||||
var forwarded = React.forwardRef(function forwardConnectRef(props, ref) {
|
||||
return /*#__PURE__*/React.createElement(Connect, _extends({}, props, {
|
||||
reactReduxForwardedRef: ref
|
||||
}));
|
||||
});
|
||||
forwarded.displayName = displayName;
|
||||
forwarded.WrappedComponent = WrappedComponent;
|
||||
return hoistStatics(forwarded, WrappedComponent);
|
||||
}
|
||||
|
||||
return hoistStatics(Connect, WrappedComponent);
|
||||
};
|
||||
}
|
||||
99
node_modules/react-redux/es/connect/connect.js
generated
vendored
Normal file
99
node_modules/react-redux/es/connect/connect.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
var _excluded = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"];
|
||||
import connectAdvanced from '../components/connectAdvanced';
|
||||
import shallowEqual from '../utils/shallowEqual';
|
||||
import defaultMapDispatchToPropsFactories from './mapDispatchToProps';
|
||||
import defaultMapStateToPropsFactories from './mapStateToProps';
|
||||
import defaultMergePropsFactories from './mergeProps';
|
||||
import defaultSelectorFactory from './selectorFactory';
|
||||
/*
|
||||
connect is a facade over connectAdvanced. It turns its args into a compatible
|
||||
selectorFactory, which has the signature:
|
||||
|
||||
(dispatch, options) => (nextState, nextOwnProps) => nextFinalProps
|
||||
|
||||
connect passes its args to connectAdvanced as options, which will in turn pass them to
|
||||
selectorFactory each time a Connect component instance is instantiated or hot reloaded.
|
||||
|
||||
selectorFactory returns a final props selector from its mapStateToProps,
|
||||
mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps,
|
||||
mergePropsFactories, and pure args.
|
||||
|
||||
The resulting final props selector is called by the Connect component instance whenever
|
||||
it receives new props or store state.
|
||||
*/
|
||||
|
||||
function match(arg, factories, name) {
|
||||
for (var i = factories.length - 1; i >= 0; i--) {
|
||||
var result = factories[i](arg);
|
||||
if (result) return result;
|
||||
}
|
||||
|
||||
return function (dispatch, options) {
|
||||
throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + ".");
|
||||
};
|
||||
}
|
||||
|
||||
function strictEqual(a, b) {
|
||||
return a === b;
|
||||
} // createConnect with default args builds the 'official' connect behavior. Calling it with
|
||||
// different options opens up some testing and extensibility scenarios
|
||||
|
||||
|
||||
export function createConnect(_temp) {
|
||||
var _ref = _temp === void 0 ? {} : _temp,
|
||||
_ref$connectHOC = _ref.connectHOC,
|
||||
connectHOC = _ref$connectHOC === void 0 ? connectAdvanced : _ref$connectHOC,
|
||||
_ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
|
||||
mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? defaultMapStateToPropsFactories : _ref$mapStateToPropsF,
|
||||
_ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
|
||||
mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? defaultMapDispatchToPropsFactories : _ref$mapDispatchToPro,
|
||||
_ref$mergePropsFactor = _ref.mergePropsFactories,
|
||||
mergePropsFactories = _ref$mergePropsFactor === void 0 ? defaultMergePropsFactories : _ref$mergePropsFactor,
|
||||
_ref$selectorFactory = _ref.selectorFactory,
|
||||
selectorFactory = _ref$selectorFactory === void 0 ? defaultSelectorFactory : _ref$selectorFactory;
|
||||
|
||||
return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) {
|
||||
if (_ref2 === void 0) {
|
||||
_ref2 = {};
|
||||
}
|
||||
|
||||
var _ref3 = _ref2,
|
||||
_ref3$pure = _ref3.pure,
|
||||
pure = _ref3$pure === void 0 ? true : _ref3$pure,
|
||||
_ref3$areStatesEqual = _ref3.areStatesEqual,
|
||||
areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual,
|
||||
_ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual,
|
||||
areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? shallowEqual : _ref3$areOwnPropsEqua,
|
||||
_ref3$areStatePropsEq = _ref3.areStatePropsEqual,
|
||||
areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? shallowEqual : _ref3$areStatePropsEq,
|
||||
_ref3$areMergedPropsE = _ref3.areMergedPropsEqual,
|
||||
areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE,
|
||||
extraOptions = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
||||
|
||||
var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
|
||||
var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
|
||||
var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
|
||||
return connectHOC(selectorFactory, _extends({
|
||||
// used in error messages
|
||||
methodName: 'connect',
|
||||
// used to compute Connect's displayName from the wrapped component's displayName.
|
||||
getDisplayName: function getDisplayName(name) {
|
||||
return "Connect(" + name + ")";
|
||||
},
|
||||
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
|
||||
shouldHandleStateChanges: Boolean(mapStateToProps),
|
||||
// passed through to selectorFactory
|
||||
initMapStateToProps: initMapStateToProps,
|
||||
initMapDispatchToProps: initMapDispatchToProps,
|
||||
initMergeProps: initMergeProps,
|
||||
pure: pure,
|
||||
areStatesEqual: areStatesEqual,
|
||||
areOwnPropsEqual: areOwnPropsEqual,
|
||||
areStatePropsEqual: areStatePropsEqual,
|
||||
areMergedPropsEqual: areMergedPropsEqual
|
||||
}, extraOptions));
|
||||
};
|
||||
}
|
||||
export default /*#__PURE__*/createConnect();
|
||||
18
node_modules/react-redux/es/connect/mapDispatchToProps.js
generated
vendored
Normal file
18
node_modules/react-redux/es/connect/mapDispatchToProps.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import bindActionCreators from '../utils/bindActionCreators';
|
||||
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps';
|
||||
export function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
|
||||
return typeof mapDispatchToProps === 'function' ? wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps') : undefined;
|
||||
}
|
||||
export function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
|
||||
return !mapDispatchToProps ? wrapMapToPropsConstant(function (dispatch) {
|
||||
return {
|
||||
dispatch: dispatch
|
||||
};
|
||||
}) : undefined;
|
||||
}
|
||||
export function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
|
||||
return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? wrapMapToPropsConstant(function (dispatch) {
|
||||
return bindActionCreators(mapDispatchToProps, dispatch);
|
||||
}) : undefined;
|
||||
}
|
||||
export default [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject];
|
||||
10
node_modules/react-redux/es/connect/mapStateToProps.js
generated
vendored
Normal file
10
node_modules/react-redux/es/connect/mapStateToProps.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps';
|
||||
export function whenMapStateToPropsIsFunction(mapStateToProps) {
|
||||
return typeof mapStateToProps === 'function' ? wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps') : undefined;
|
||||
}
|
||||
export function whenMapStateToPropsIsMissing(mapStateToProps) {
|
||||
return !mapStateToProps ? wrapMapToPropsConstant(function () {
|
||||
return {};
|
||||
}) : undefined;
|
||||
}
|
||||
export default [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing];
|
||||
36
node_modules/react-redux/es/connect/mergeProps.js
generated
vendored
Normal file
36
node_modules/react-redux/es/connect/mergeProps.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import verifyPlainObject from '../utils/verifyPlainObject';
|
||||
export function defaultMergeProps(stateProps, dispatchProps, ownProps) {
|
||||
return _extends({}, ownProps, stateProps, dispatchProps);
|
||||
}
|
||||
export function wrapMergePropsFunc(mergeProps) {
|
||||
return function initMergePropsProxy(dispatch, _ref) {
|
||||
var displayName = _ref.displayName,
|
||||
pure = _ref.pure,
|
||||
areMergedPropsEqual = _ref.areMergedPropsEqual;
|
||||
var hasRunOnce = false;
|
||||
var mergedProps;
|
||||
return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
|
||||
var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
|
||||
if (hasRunOnce) {
|
||||
if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
|
||||
} else {
|
||||
hasRunOnce = true;
|
||||
mergedProps = nextMergedProps;
|
||||
if (process.env.NODE_ENV !== 'production') verifyPlainObject(mergedProps, displayName, 'mergeProps');
|
||||
}
|
||||
|
||||
return mergedProps;
|
||||
};
|
||||
};
|
||||
}
|
||||
export function whenMergePropsIsFunction(mergeProps) {
|
||||
return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined;
|
||||
}
|
||||
export function whenMergePropsIsOmitted(mergeProps) {
|
||||
return !mergeProps ? function () {
|
||||
return defaultMergeProps;
|
||||
} : undefined;
|
||||
}
|
||||
export default [whenMergePropsIsFunction, whenMergePropsIsOmitted];
|
||||
88
node_modules/react-redux/es/connect/selectorFactory.js
generated
vendored
Normal file
88
node_modules/react-redux/es/connect/selectorFactory.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
var _excluded = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"];
|
||||
import verifySubselectors from './verifySubselectors';
|
||||
export function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) {
|
||||
return function impureFinalPropsSelector(state, ownProps) {
|
||||
return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps);
|
||||
};
|
||||
}
|
||||
export function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) {
|
||||
var areStatesEqual = _ref.areStatesEqual,
|
||||
areOwnPropsEqual = _ref.areOwnPropsEqual,
|
||||
areStatePropsEqual = _ref.areStatePropsEqual;
|
||||
var hasRunAtLeastOnce = false;
|
||||
var state;
|
||||
var ownProps;
|
||||
var stateProps;
|
||||
var dispatchProps;
|
||||
var mergedProps;
|
||||
|
||||
function handleFirstCall(firstState, firstOwnProps) {
|
||||
state = firstState;
|
||||
ownProps = firstOwnProps;
|
||||
stateProps = mapStateToProps(state, ownProps);
|
||||
dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
hasRunAtLeastOnce = true;
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleNewPropsAndNewState() {
|
||||
stateProps = mapStateToProps(state, ownProps);
|
||||
if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleNewProps() {
|
||||
if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps);
|
||||
if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleNewState() {
|
||||
var nextStateProps = mapStateToProps(state, ownProps);
|
||||
var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
|
||||
stateProps = nextStateProps;
|
||||
if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleSubsequentCalls(nextState, nextOwnProps) {
|
||||
var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
|
||||
var stateChanged = !areStatesEqual(nextState, state, nextOwnProps, ownProps);
|
||||
state = nextState;
|
||||
ownProps = nextOwnProps;
|
||||
if (propsChanged && stateChanged) return handleNewPropsAndNewState();
|
||||
if (propsChanged) return handleNewProps();
|
||||
if (stateChanged) return handleNewState();
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
return function pureFinalPropsSelector(nextState, nextOwnProps) {
|
||||
return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
|
||||
};
|
||||
} // TODO: Add more comments
|
||||
// If pure is true, the selector returned by selectorFactory will memoize its results,
|
||||
// allowing connectAdvanced's shouldComponentUpdate to return false if final
|
||||
// props have not changed. If false, the selector will always return a new
|
||||
// object and shouldComponentUpdate will always return true.
|
||||
|
||||
export default function finalPropsSelectorFactory(dispatch, _ref2) {
|
||||
var initMapStateToProps = _ref2.initMapStateToProps,
|
||||
initMapDispatchToProps = _ref2.initMapDispatchToProps,
|
||||
initMergeProps = _ref2.initMergeProps,
|
||||
options = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
||||
|
||||
var mapStateToProps = initMapStateToProps(dispatch, options);
|
||||
var mapDispatchToProps = initMapDispatchToProps(dispatch, options);
|
||||
var mergeProps = initMergeProps(dispatch, options);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName);
|
||||
}
|
||||
|
||||
var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory;
|
||||
return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
|
||||
}
|
||||
17
node_modules/react-redux/es/connect/verifySubselectors.js
generated
vendored
Normal file
17
node_modules/react-redux/es/connect/verifySubselectors.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import warning from '../utils/warning';
|
||||
|
||||
function verify(selector, methodName, displayName) {
|
||||
if (!selector) {
|
||||
throw new Error("Unexpected value for " + methodName + " in " + displayName + ".");
|
||||
} else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
|
||||
if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
|
||||
warning("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
|
||||
verify(mapStateToProps, 'mapStateToProps', displayName);
|
||||
verify(mapDispatchToProps, 'mapDispatchToProps', displayName);
|
||||
verify(mergeProps, 'mergeProps', displayName);
|
||||
}
|
||||
64
node_modules/react-redux/es/connect/wrapMapToProps.js
generated
vendored
Normal file
64
node_modules/react-redux/es/connect/wrapMapToProps.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import verifyPlainObject from '../utils/verifyPlainObject';
|
||||
export function wrapMapToPropsConstant(getConstant) {
|
||||
return function initConstantSelector(dispatch, options) {
|
||||
var constant = getConstant(dispatch, options);
|
||||
|
||||
function constantSelector() {
|
||||
return constant;
|
||||
}
|
||||
|
||||
constantSelector.dependsOnOwnProps = false;
|
||||
return constantSelector;
|
||||
};
|
||||
} // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args
|
||||
// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine
|
||||
// whether mapToProps needs to be invoked when props have changed.
|
||||
//
|
||||
// A length of one signals that mapToProps does not depend on props from the parent component.
|
||||
// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and
|
||||
// therefore not reporting its length accurately..
|
||||
|
||||
export function getDependsOnOwnProps(mapToProps) {
|
||||
return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
|
||||
} // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
|
||||
// this function wraps mapToProps in a proxy function which does several things:
|
||||
//
|
||||
// * Detects whether the mapToProps function being called depends on props, which
|
||||
// is used by selectorFactory to decide if it should reinvoke on props changes.
|
||||
//
|
||||
// * On first call, handles mapToProps if returns another function, and treats that
|
||||
// new function as the true mapToProps for subsequent calls.
|
||||
//
|
||||
// * On first call, verifies the first result is a plain object, in order to warn
|
||||
// the developer that their mapToProps function is not returning a valid result.
|
||||
//
|
||||
|
||||
export function wrapMapToPropsFunc(mapToProps, methodName) {
|
||||
return function initProxySelector(dispatch, _ref) {
|
||||
var displayName = _ref.displayName;
|
||||
|
||||
var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
|
||||
return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);
|
||||
}; // allow detectFactoryAndVerify to get ownProps
|
||||
|
||||
|
||||
proxy.dependsOnOwnProps = true;
|
||||
|
||||
proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
|
||||
proxy.mapToProps = mapToProps;
|
||||
proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
|
||||
var props = proxy(stateOrDispatch, ownProps);
|
||||
|
||||
if (typeof props === 'function') {
|
||||
proxy.mapToProps = props;
|
||||
proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
|
||||
props = proxy(stateOrDispatch, ownProps);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') verifyPlainObject(props, displayName, methodName);
|
||||
return props;
|
||||
};
|
||||
|
||||
return proxy;
|
||||
};
|
||||
}
|
||||
9
node_modules/react-redux/es/exports.js
generated
vendored
Normal file
9
node_modules/react-redux/es/exports.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import Provider from './components/Provider';
|
||||
import connectAdvanced from './components/connectAdvanced';
|
||||
import { ReactReduxContext } from './components/Context';
|
||||
import connect from './connect/connect';
|
||||
import { useDispatch, createDispatchHook } from './hooks/useDispatch';
|
||||
import { useSelector, createSelectorHook } from './hooks/useSelector';
|
||||
import { useStore, createStoreHook } from './hooks/useStore';
|
||||
import shallowEqual from './utils/shallowEqual';
|
||||
export { Provider, connectAdvanced, ReactReduxContext, connect, useDispatch, createDispatchHook, useSelector, createSelectorHook, useStore, createStoreHook, shallowEqual };
|
||||
43
node_modules/react-redux/es/hooks/useDispatch.js
generated
vendored
Normal file
43
node_modules/react-redux/es/hooks/useDispatch.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import { ReactReduxContext } from '../components/Context';
|
||||
import { useStore as useDefaultStore, createStoreHook } from './useStore';
|
||||
/**
|
||||
* Hook factory, which creates a `useDispatch` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useDispatch` hook bound to the specified context.
|
||||
*/
|
||||
|
||||
export function createDispatchHook(context) {
|
||||
if (context === void 0) {
|
||||
context = ReactReduxContext;
|
||||
}
|
||||
|
||||
var useStore = context === ReactReduxContext ? useDefaultStore : createStoreHook(context);
|
||||
return function useDispatch() {
|
||||
var store = useStore();
|
||||
return store.dispatch;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A hook to access the redux `dispatch` function.
|
||||
*
|
||||
* @returns {any|function} redux store's `dispatch` function
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React, { useCallback } from 'react'
|
||||
* import { useDispatch } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = ({ value }) => {
|
||||
* const dispatch = useDispatch()
|
||||
* const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
|
||||
* return (
|
||||
* <div>
|
||||
* <span>{value}</span>
|
||||
* <button onClick={increaseCounter}>Increase counter</button>
|
||||
* </div>
|
||||
* )
|
||||
* }
|
||||
*/
|
||||
|
||||
export var useDispatch = /*#__PURE__*/createDispatchHook();
|
||||
28
node_modules/react-redux/es/hooks/useReduxContext.js
generated
vendored
Normal file
28
node_modules/react-redux/es/hooks/useReduxContext.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useContext } from 'react';
|
||||
import { ReactReduxContext } from '../components/Context';
|
||||
/**
|
||||
* A hook to access the value of the `ReactReduxContext`. This is a low-level
|
||||
* hook that you should usually not need to call directly.
|
||||
*
|
||||
* @returns {any} the value of the `ReactReduxContext`
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useReduxContext } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = ({ value }) => {
|
||||
* const { store } = useReduxContext()
|
||||
* return <div>{store.getState()}</div>
|
||||
* }
|
||||
*/
|
||||
|
||||
export function useReduxContext() {
|
||||
var contextValue = useContext(ReactReduxContext);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !contextValue) {
|
||||
throw new Error('could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
|
||||
}
|
||||
|
||||
return contextValue;
|
||||
}
|
||||
158
node_modules/react-redux/es/hooks/useSelector.js
generated
vendored
Normal file
158
node_modules/react-redux/es/hooks/useSelector.js
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
import { useReducer, useRef, useMemo, useContext, useDebugValue } from 'react';
|
||||
import { useReduxContext as useDefaultReduxContext } from './useReduxContext';
|
||||
import { createSubscription } from '../utils/Subscription';
|
||||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
|
||||
import { ReactReduxContext } from '../components/Context';
|
||||
|
||||
var refEquality = function refEquality(a, b) {
|
||||
return a === b;
|
||||
};
|
||||
|
||||
function useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub) {
|
||||
var _useReducer = useReducer(function (s) {
|
||||
return s + 1;
|
||||
}, 0),
|
||||
forceRender = _useReducer[1];
|
||||
|
||||
var subscription = useMemo(function () {
|
||||
return createSubscription(store, contextSub);
|
||||
}, [store, contextSub]);
|
||||
var latestSubscriptionCallbackError = useRef();
|
||||
var latestSelector = useRef();
|
||||
var latestStoreState = useRef();
|
||||
var latestSelectedState = useRef();
|
||||
var storeState = store.getState();
|
||||
var selectedState;
|
||||
|
||||
try {
|
||||
if (selector !== latestSelector.current || storeState !== latestStoreState.current || latestSubscriptionCallbackError.current) {
|
||||
var newSelectedState = selector(storeState); // ensure latest selected state is reused so that a custom equality function can result in identical references
|
||||
|
||||
if (latestSelectedState.current === undefined || !equalityFn(newSelectedState, latestSelectedState.current)) {
|
||||
selectedState = newSelectedState;
|
||||
} else {
|
||||
selectedState = latestSelectedState.current;
|
||||
}
|
||||
} else {
|
||||
selectedState = latestSelectedState.current;
|
||||
}
|
||||
} catch (err) {
|
||||
if (latestSubscriptionCallbackError.current) {
|
||||
err.message += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\n";
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
useIsomorphicLayoutEffect(function () {
|
||||
latestSelector.current = selector;
|
||||
latestStoreState.current = storeState;
|
||||
latestSelectedState.current = selectedState;
|
||||
latestSubscriptionCallbackError.current = undefined;
|
||||
});
|
||||
useIsomorphicLayoutEffect(function () {
|
||||
function checkForUpdates() {
|
||||
try {
|
||||
var newStoreState = store.getState(); // Avoid calling selector multiple times if the store's state has not changed
|
||||
|
||||
if (newStoreState === latestStoreState.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
var _newSelectedState = latestSelector.current(newStoreState);
|
||||
|
||||
if (equalityFn(_newSelectedState, latestSelectedState.current)) {
|
||||
return;
|
||||
}
|
||||
|
||||
latestSelectedState.current = _newSelectedState;
|
||||
latestStoreState.current = newStoreState;
|
||||
} catch (err) {
|
||||
// we ignore all errors here, since when the component
|
||||
// is re-rendered, the selectors are called again, and
|
||||
// will throw again, if neither props nor store state
|
||||
// changed
|
||||
latestSubscriptionCallbackError.current = err;
|
||||
}
|
||||
|
||||
forceRender();
|
||||
}
|
||||
|
||||
subscription.onStateChange = checkForUpdates;
|
||||
subscription.trySubscribe();
|
||||
checkForUpdates();
|
||||
return function () {
|
||||
return subscription.tryUnsubscribe();
|
||||
};
|
||||
}, [store, subscription]);
|
||||
return selectedState;
|
||||
}
|
||||
/**
|
||||
* Hook factory, which creates a `useSelector` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useSelector` hook bound to the specified context.
|
||||
*/
|
||||
|
||||
|
||||
export function createSelectorHook(context) {
|
||||
if (context === void 0) {
|
||||
context = ReactReduxContext;
|
||||
}
|
||||
|
||||
var useReduxContext = context === ReactReduxContext ? useDefaultReduxContext : function () {
|
||||
return useContext(context);
|
||||
};
|
||||
return function useSelector(selector, equalityFn) {
|
||||
if (equalityFn === void 0) {
|
||||
equalityFn = refEquality;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!selector) {
|
||||
throw new Error("You must pass a selector to useSelector");
|
||||
}
|
||||
|
||||
if (typeof selector !== 'function') {
|
||||
throw new Error("You must pass a function as a selector to useSelector");
|
||||
}
|
||||
|
||||
if (typeof equalityFn !== 'function') {
|
||||
throw new Error("You must pass a function as an equality function to useSelector");
|
||||
}
|
||||
}
|
||||
|
||||
var _useReduxContext = useReduxContext(),
|
||||
store = _useReduxContext.store,
|
||||
contextSub = _useReduxContext.subscription;
|
||||
|
||||
var selectedState = useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub);
|
||||
useDebugValue(selectedState);
|
||||
return selectedState;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A hook to access the redux store's state. This hook takes a selector function
|
||||
* as an argument. The selector is called with the store state.
|
||||
*
|
||||
* This hook takes an optional equality comparison function as the second parameter
|
||||
* that allows you to customize the way the selected state is compared to determine
|
||||
* whether the component needs to be re-rendered.
|
||||
*
|
||||
* @param {Function} selector the selector function
|
||||
* @param {Function=} equalityFn the function that will be used to determine equality
|
||||
*
|
||||
* @returns {any} the selected state
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useSelector } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = () => {
|
||||
* const counter = useSelector(state => state.counter)
|
||||
* return <div>{counter}</div>
|
||||
* }
|
||||
*/
|
||||
|
||||
export var useSelector = /*#__PURE__*/createSelectorHook();
|
||||
42
node_modules/react-redux/es/hooks/useStore.js
generated
vendored
Normal file
42
node_modules/react-redux/es/hooks/useStore.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { useContext } from 'react';
|
||||
import { ReactReduxContext } from '../components/Context';
|
||||
import { useReduxContext as useDefaultReduxContext } from './useReduxContext';
|
||||
/**
|
||||
* Hook factory, which creates a `useStore` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useStore` hook bound to the specified context.
|
||||
*/
|
||||
|
||||
export function createStoreHook(context) {
|
||||
if (context === void 0) {
|
||||
context = ReactReduxContext;
|
||||
}
|
||||
|
||||
var useReduxContext = context === ReactReduxContext ? useDefaultReduxContext : function () {
|
||||
return useContext(context);
|
||||
};
|
||||
return function useStore() {
|
||||
var _useReduxContext = useReduxContext(),
|
||||
store = _useReduxContext.store;
|
||||
|
||||
return store;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A hook to access the redux store.
|
||||
*
|
||||
* @returns {any} the redux store
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useStore } from 'react-redux'
|
||||
*
|
||||
* export const ExampleComponent = () => {
|
||||
* const store = useStore()
|
||||
* return <div>{store.getState()}</div>
|
||||
* }
|
||||
*/
|
||||
|
||||
export var useStore = /*#__PURE__*/createStoreHook();
|
||||
7
node_modules/react-redux/es/index.js
generated
vendored
Normal file
7
node_modules/react-redux/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export * from './exports';
|
||||
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates';
|
||||
import { setBatch } from './utils/batch'; // Enable batched updates in our subscriptions for use
|
||||
// with standard React renderers (ReactDOM, React Native)
|
||||
|
||||
setBatch(batch);
|
||||
export { batch };
|
||||
126
node_modules/react-redux/es/utils/Subscription.js
generated
vendored
Normal file
126
node_modules/react-redux/es/utils/Subscription.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import { getBatch } from './batch'; // encapsulates the subscription logic for connecting a component to the redux store, as
|
||||
// well as nesting subscriptions of descendant components, so that we can ensure the
|
||||
// ancestor components re-render before descendants
|
||||
|
||||
function createListenerCollection() {
|
||||
var batch = getBatch();
|
||||
var first = null;
|
||||
var last = null;
|
||||
return {
|
||||
clear: function clear() {
|
||||
first = null;
|
||||
last = null;
|
||||
},
|
||||
notify: function notify() {
|
||||
batch(function () {
|
||||
var listener = first;
|
||||
|
||||
while (listener) {
|
||||
listener.callback();
|
||||
listener = listener.next;
|
||||
}
|
||||
});
|
||||
},
|
||||
get: function get() {
|
||||
var listeners = [];
|
||||
var listener = first;
|
||||
|
||||
while (listener) {
|
||||
listeners.push(listener);
|
||||
listener = listener.next;
|
||||
}
|
||||
|
||||
return listeners;
|
||||
},
|
||||
subscribe: function subscribe(callback) {
|
||||
var isSubscribed = true;
|
||||
var listener = last = {
|
||||
callback: callback,
|
||||
next: null,
|
||||
prev: last
|
||||
};
|
||||
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener;
|
||||
} else {
|
||||
first = listener;
|
||||
}
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed || first === null) return;
|
||||
isSubscribed = false;
|
||||
|
||||
if (listener.next) {
|
||||
listener.next.prev = listener.prev;
|
||||
} else {
|
||||
last = listener.prev;
|
||||
}
|
||||
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener.next;
|
||||
} else {
|
||||
first = listener.next;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var nullListeners = {
|
||||
notify: function notify() {},
|
||||
get: function get() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
export function createSubscription(store, parentSub) {
|
||||
var unsubscribe;
|
||||
var listeners = nullListeners;
|
||||
|
||||
function addNestedSub(listener) {
|
||||
trySubscribe();
|
||||
return listeners.subscribe(listener);
|
||||
}
|
||||
|
||||
function notifyNestedSubs() {
|
||||
listeners.notify();
|
||||
}
|
||||
|
||||
function handleChangeWrapper() {
|
||||
if (subscription.onStateChange) {
|
||||
subscription.onStateChange();
|
||||
}
|
||||
}
|
||||
|
||||
function isSubscribed() {
|
||||
return Boolean(unsubscribe);
|
||||
}
|
||||
|
||||
function trySubscribe() {
|
||||
if (!unsubscribe) {
|
||||
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
|
||||
listeners = createListenerCollection();
|
||||
}
|
||||
}
|
||||
|
||||
function tryUnsubscribe() {
|
||||
if (unsubscribe) {
|
||||
unsubscribe();
|
||||
unsubscribe = undefined;
|
||||
listeners.clear();
|
||||
listeners = nullListeners;
|
||||
}
|
||||
}
|
||||
|
||||
var subscription = {
|
||||
addNestedSub: addNestedSub,
|
||||
notifyNestedSubs: notifyNestedSubs,
|
||||
handleChangeWrapper: handleChangeWrapper,
|
||||
isSubscribed: isSubscribed,
|
||||
trySubscribe: trySubscribe,
|
||||
tryUnsubscribe: tryUnsubscribe,
|
||||
getListeners: function getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
};
|
||||
return subscription;
|
||||
}
|
||||
14
node_modules/react-redux/es/utils/batch.js
generated
vendored
Normal file
14
node_modules/react-redux/es/utils/batch.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Default to a dummy "batch" implementation that just runs the callback
|
||||
function defaultNoopBatch(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
var batch = defaultNoopBatch; // Allow injecting another batching function later
|
||||
|
||||
export var setBatch = function setBatch(newBatch) {
|
||||
return batch = newBatch;
|
||||
}; // Supply a getter just to skip dealing with ESM bindings
|
||||
|
||||
export var getBatch = function getBatch() {
|
||||
return batch;
|
||||
};
|
||||
19
node_modules/react-redux/es/utils/bindActionCreators.js
generated
vendored
Normal file
19
node_modules/react-redux/es/utils/bindActionCreators.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export default function bindActionCreators(actionCreators, dispatch) {
|
||||
var boundActionCreators = {};
|
||||
|
||||
var _loop = function _loop(key) {
|
||||
var actionCreator = actionCreators[key];
|
||||
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = function () {
|
||||
return dispatch(actionCreator.apply(void 0, arguments));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
for (var key in actionCreators) {
|
||||
_loop(key);
|
||||
}
|
||||
|
||||
return boundActionCreators;
|
||||
}
|
||||
16
node_modules/react-redux/es/utils/isPlainObject.js
generated
vendored
Normal file
16
node_modules/react-redux/es/utils/isPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
export default function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false;
|
||||
var proto = Object.getPrototypeOf(obj);
|
||||
if (proto === null) return true;
|
||||
var baseProto = proto;
|
||||
|
||||
while (Object.getPrototypeOf(baseProto) !== null) {
|
||||
baseProto = Object.getPrototypeOf(baseProto);
|
||||
}
|
||||
|
||||
return proto === baseProto;
|
||||
}
|
||||
2
node_modules/react-redux/es/utils/reactBatchedUpdates.js
generated
vendored
Normal file
2
node_modules/react-redux/es/utils/reactBatchedUpdates.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* eslint-disable import/no-unresolved */
|
||||
export { unstable_batchedUpdates } from 'react-dom';
|
||||
3
node_modules/react-redux/es/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
3
node_modules/react-redux/es/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/* eslint-disable import/named */
|
||||
import { unstable_batchedUpdates } from 'react-native';
|
||||
export { unstable_batchedUpdates };
|
||||
27
node_modules/react-redux/es/utils/shallowEqual.js
generated
vendored
Normal file
27
node_modules/react-redux/es/utils/shallowEqual.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
function is(x, y) {
|
||||
if (x === y) {
|
||||
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
||||
} else {
|
||||
return x !== x && y !== y;
|
||||
}
|
||||
}
|
||||
|
||||
export default function shallowEqual(objA, objB) {
|
||||
if (is(objA, objB)) return true;
|
||||
|
||||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var keysA = Object.keys(objA);
|
||||
var keysB = Object.keys(objB);
|
||||
if (keysA.length !== keysB.length) return false;
|
||||
|
||||
for (var i = 0; i < keysA.length; i++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
10
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
10
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useEffect, useLayoutEffect } from 'react'; // React currently throws a warning when using useLayoutEffect on the server.
|
||||
// To get around it, we can conditionally useEffect on the server (no-op) and
|
||||
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
|
||||
// subscription callback always has the selector from the latest render commit
|
||||
// available, otherwise a store update may happen between render and the effect,
|
||||
// which may cause missed updates; we also must ensure the store subscription
|
||||
// is created synchronously, otherwise a store update may occur before the
|
||||
// subscription is created and an inconsistent state may be observed
|
||||
|
||||
export var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
|
||||
3
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
3
node_modules/react-redux/es/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { useLayoutEffect } from 'react'; // Under React Native, we know that we always want to use useLayoutEffect
|
||||
|
||||
export var useIsomorphicLayoutEffect = useLayoutEffect;
|
||||
7
node_modules/react-redux/es/utils/verifyPlainObject.js
generated
vendored
Normal file
7
node_modules/react-redux/es/utils/verifyPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import isPlainObject from './isPlainObject';
|
||||
import warning from './warning';
|
||||
export default function verifyPlainObject(value, displayName, methodName) {
|
||||
if (!isPlainObject(value)) {
|
||||
warning(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + ".");
|
||||
}
|
||||
}
|
||||
24
node_modules/react-redux/es/utils/warning.js
generated
vendored
Normal file
24
node_modules/react-redux/es/utils/warning.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
export default function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
|
||||
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message);
|
||||
/* eslint-disable no-empty */
|
||||
} catch (e) {}
|
||||
/* eslint-enable no-empty */
|
||||
|
||||
}
|
||||
23
node_modules/react-redux/lib/alternate-renderers.js
generated
vendored
Normal file
23
node_modules/react-redux/lib/alternate-renderers.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
var _exportNames = {
|
||||
batch: true
|
||||
};
|
||||
exports.batch = void 0;
|
||||
|
||||
var _exports = require("./exports");
|
||||
|
||||
Object.keys(_exports).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _exports[key]) return;
|
||||
exports[key] = _exports[key];
|
||||
});
|
||||
|
||||
var _batch = require("./utils/batch");
|
||||
|
||||
// For other renderers besides ReactDOM and React Native,
|
||||
// use the default noop batch function
|
||||
var batch = (0, _batch.getBatch)();
|
||||
exports.batch = batch;
|
||||
19
node_modules/react-redux/lib/components/Context.js
generated
vendored
Normal file
19
node_modules/react-redux/lib/components/Context.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = exports.ReactReduxContext = void 0;
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
var ReactReduxContext = /*#__PURE__*/_react["default"].createContext(null);
|
||||
|
||||
exports.ReactReduxContext = ReactReduxContext;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ReactReduxContext.displayName = 'ReactRedux';
|
||||
}
|
||||
|
||||
var _default = ReactReduxContext;
|
||||
exports["default"] = _default;
|
||||
67
node_modules/react-redux/lib/components/Provider.js
generated
vendored
Normal file
67
node_modules/react-redux/lib/components/Provider.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _react = _interopRequireWildcard(require("react"));
|
||||
|
||||
var _propTypes = _interopRequireDefault(require("prop-types"));
|
||||
|
||||
var _Context = require("./Context");
|
||||
|
||||
var _Subscription = require("../utils/Subscription");
|
||||
|
||||
var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect");
|
||||
|
||||
function Provider(_ref) {
|
||||
var store = _ref.store,
|
||||
context = _ref.context,
|
||||
children = _ref.children;
|
||||
var contextValue = (0, _react.useMemo)(function () {
|
||||
var subscription = (0, _Subscription.createSubscription)(store);
|
||||
return {
|
||||
store: store,
|
||||
subscription: subscription
|
||||
};
|
||||
}, [store]);
|
||||
var previousState = (0, _react.useMemo)(function () {
|
||||
return store.getState();
|
||||
}, [store]);
|
||||
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
|
||||
var subscription = contextValue.subscription;
|
||||
subscription.onStateChange = subscription.notifyNestedSubs;
|
||||
subscription.trySubscribe();
|
||||
|
||||
if (previousState !== store.getState()) {
|
||||
subscription.notifyNestedSubs();
|
||||
}
|
||||
|
||||
return function () {
|
||||
subscription.tryUnsubscribe();
|
||||
subscription.onStateChange = null;
|
||||
};
|
||||
}, [contextValue, previousState]);
|
||||
var Context = context || _Context.ReactReduxContext;
|
||||
return /*#__PURE__*/_react["default"].createElement(Context.Provider, {
|
||||
value: contextValue
|
||||
}, children);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Provider.propTypes = {
|
||||
store: _propTypes["default"].shape({
|
||||
subscribe: _propTypes["default"].func.isRequired,
|
||||
dispatch: _propTypes["default"].func.isRequired,
|
||||
getState: _propTypes["default"].func.isRequired
|
||||
}),
|
||||
context: _propTypes["default"].object,
|
||||
children: _propTypes["default"].any
|
||||
};
|
||||
}
|
||||
|
||||
var _default = Provider;
|
||||
exports["default"] = _default;
|
||||
392
node_modules/react-redux/lib/components/connectAdvanced.js
generated
vendored
Normal file
392
node_modules/react-redux/lib/components/connectAdvanced.js
generated
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = connectAdvanced;
|
||||
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
|
||||
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
||||
|
||||
var _react = _interopRequireWildcard(require("react"));
|
||||
|
||||
var _reactIs = require("react-is");
|
||||
|
||||
var _Subscription = require("../utils/Subscription");
|
||||
|
||||
var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect");
|
||||
|
||||
var _Context = require("./Context");
|
||||
|
||||
var _excluded = ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"],
|
||||
_excluded2 = ["reactReduxForwardedRef"];
|
||||
// Define some constant arrays just to avoid re-creating these
|
||||
var EMPTY_ARRAY = [];
|
||||
var NO_SUBSCRIPTION_ARRAY = [null, null];
|
||||
|
||||
var stringifyComponent = function stringifyComponent(Comp) {
|
||||
try {
|
||||
return JSON.stringify(Comp);
|
||||
} catch (err) {
|
||||
return String(Comp);
|
||||
}
|
||||
};
|
||||
|
||||
function storeStateUpdatesReducer(state, action) {
|
||||
var updateCount = state[1];
|
||||
return [action.payload, updateCount + 1];
|
||||
}
|
||||
|
||||
function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
|
||||
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
|
||||
return effectFunc.apply(void 0, effectArgs);
|
||||
}, dependencies);
|
||||
}
|
||||
|
||||
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs) {
|
||||
// We want to capture the wrapper props and child props we used for later comparisons
|
||||
lastWrapperProps.current = wrapperProps;
|
||||
lastChildProps.current = actualChildProps;
|
||||
renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update
|
||||
|
||||
if (childPropsFromStoreUpdate.current) {
|
||||
childPropsFromStoreUpdate.current = null;
|
||||
notifyNestedSubs();
|
||||
}
|
||||
}
|
||||
|
||||
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch) {
|
||||
// If we're not subscribed to the store, nothing to do here
|
||||
if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts
|
||||
|
||||
var didUnsubscribe = false;
|
||||
var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component
|
||||
|
||||
var checkForUpdates = function checkForUpdates() {
|
||||
if (didUnsubscribe) {
|
||||
// Don't run stale listeners.
|
||||
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
|
||||
return;
|
||||
}
|
||||
|
||||
var latestStoreState = store.getState();
|
||||
var newChildProps, error;
|
||||
|
||||
try {
|
||||
// Actually run the selector with the most recent store state and wrapper props
|
||||
// to determine what the child props should be
|
||||
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
lastThrownError = e;
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
lastThrownError = null;
|
||||
} // If the child props haven't changed, nothing to do here - cascade the subscription update
|
||||
|
||||
|
||||
if (newChildProps === lastChildProps.current) {
|
||||
if (!renderIsScheduled.current) {
|
||||
notifyNestedSubs();
|
||||
}
|
||||
} else {
|
||||
// Save references to the new child props. Note that we track the "child props from store update"
|
||||
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
|
||||
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
|
||||
// forcing another re-render, which we don't want.
|
||||
lastChildProps.current = newChildProps;
|
||||
childPropsFromStoreUpdate.current = newChildProps;
|
||||
renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
|
||||
|
||||
forceComponentUpdateDispatch({
|
||||
type: 'STORE_UPDATED',
|
||||
payload: {
|
||||
error: error
|
||||
}
|
||||
});
|
||||
}
|
||||
}; // Actually subscribe to the nearest connected ancestor (or store)
|
||||
|
||||
|
||||
subscription.onStateChange = checkForUpdates;
|
||||
subscription.trySubscribe(); // Pull data from the store after first render in case the store has
|
||||
// changed since we began.
|
||||
|
||||
checkForUpdates();
|
||||
|
||||
var unsubscribeWrapper = function unsubscribeWrapper() {
|
||||
didUnsubscribe = true;
|
||||
subscription.tryUnsubscribe();
|
||||
subscription.onStateChange = null;
|
||||
|
||||
if (lastThrownError) {
|
||||
// It's possible that we caught an error due to a bad mapState function, but the
|
||||
// parent re-rendered without this component and we're about to unmount.
|
||||
// This shouldn't happen as long as we do top-down subscriptions correctly, but
|
||||
// if we ever do those wrong, this throw will surface the error in our tests.
|
||||
// In that case, throw the error from here so it doesn't get lost.
|
||||
throw lastThrownError;
|
||||
}
|
||||
};
|
||||
|
||||
return unsubscribeWrapper;
|
||||
}
|
||||
|
||||
var initStateUpdates = function initStateUpdates() {
|
||||
return [null, 0];
|
||||
};
|
||||
|
||||
function connectAdvanced(
|
||||
/*
|
||||
selectorFactory is a func that is responsible for returning the selector function used to
|
||||
compute new props from state, props, and dispatch. For example:
|
||||
export default connectAdvanced((dispatch, options) => (state, props) => ({
|
||||
thing: state.things[props.thingId],
|
||||
saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)),
|
||||
}))(YourComponent)
|
||||
Access to dispatch is provided to the factory so selectorFactories can bind actionCreators
|
||||
outside of their selector as an optimization. Options passed to connectAdvanced are passed to
|
||||
the selectorFactory, along with displayName and WrappedComponent, as the second argument.
|
||||
Note that selectorFactory is responsible for all caching/memoization of inbound and outbound
|
||||
props. Do not use connectAdvanced directly without memoizing results between calls to your
|
||||
selector, otherwise the Connect component will re-render on every state or props change.
|
||||
*/
|
||||
selectorFactory, // options object:
|
||||
_ref) {
|
||||
if (_ref === void 0) {
|
||||
_ref = {};
|
||||
}
|
||||
|
||||
var _ref2 = _ref,
|
||||
_ref2$getDisplayName = _ref2.getDisplayName,
|
||||
getDisplayName = _ref2$getDisplayName === void 0 ? function (name) {
|
||||
return "ConnectAdvanced(" + name + ")";
|
||||
} : _ref2$getDisplayName,
|
||||
_ref2$methodName = _ref2.methodName,
|
||||
methodName = _ref2$methodName === void 0 ? 'connectAdvanced' : _ref2$methodName,
|
||||
_ref2$renderCountProp = _ref2.renderCountProp,
|
||||
renderCountProp = _ref2$renderCountProp === void 0 ? undefined : _ref2$renderCountProp,
|
||||
_ref2$shouldHandleSta = _ref2.shouldHandleStateChanges,
|
||||
shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta,
|
||||
_ref2$storeKey = _ref2.storeKey,
|
||||
storeKey = _ref2$storeKey === void 0 ? 'store' : _ref2$storeKey,
|
||||
_ref2$withRef = _ref2.withRef,
|
||||
withRef = _ref2$withRef === void 0 ? false : _ref2$withRef,
|
||||
_ref2$forwardRef = _ref2.forwardRef,
|
||||
forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef,
|
||||
_ref2$context = _ref2.context,
|
||||
context = _ref2$context === void 0 ? _Context.ReactReduxContext : _ref2$context,
|
||||
connectOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, _excluded);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (renderCountProp !== undefined) {
|
||||
throw new Error("renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension");
|
||||
}
|
||||
|
||||
if (withRef) {
|
||||
throw new Error('withRef is removed. To access the wrapped instance, use a ref on the connected component');
|
||||
}
|
||||
|
||||
var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect';
|
||||
|
||||
if (storeKey !== 'store') {
|
||||
throw new Error('storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var Context = context;
|
||||
return function wrapWithConnect(WrappedComponent) {
|
||||
if (process.env.NODE_ENV !== 'production' && !(0, _reactIs.isValidElementType)(WrappedComponent)) {
|
||||
throw new Error("You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
|
||||
}
|
||||
|
||||
var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
var displayName = getDisplayName(wrappedComponentName);
|
||||
var selectorFactoryOptions = (0, _extends2["default"])({}, connectOptions, {
|
||||
getDisplayName: getDisplayName,
|
||||
methodName: methodName,
|
||||
renderCountProp: renderCountProp,
|
||||
shouldHandleStateChanges: shouldHandleStateChanges,
|
||||
storeKey: storeKey,
|
||||
displayName: displayName,
|
||||
wrappedComponentName: wrappedComponentName,
|
||||
WrappedComponent: WrappedComponent
|
||||
});
|
||||
var pure = connectOptions.pure;
|
||||
|
||||
function createChildSelector(store) {
|
||||
return selectorFactory(store.dispatch, selectorFactoryOptions);
|
||||
} // If we aren't running in "pure" mode, we don't want to memoize values.
|
||||
// To avoid conditionally calling hooks, we fall back to a tiny wrapper
|
||||
// that just executes the given callback immediately.
|
||||
|
||||
|
||||
var usePureOnlyMemo = pure ? _react.useMemo : function (callback) {
|
||||
return callback();
|
||||
};
|
||||
|
||||
function ConnectFunction(props) {
|
||||
var _useMemo = (0, _react.useMemo)(function () {
|
||||
// Distinguish between actual "data" props that were passed to the wrapper component,
|
||||
// and values needed to control behavior (forwarded refs, alternate context instances).
|
||||
// To maintain the wrapperProps object reference, memoize this destructuring.
|
||||
var reactReduxForwardedRef = props.reactReduxForwardedRef,
|
||||
wrapperProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded2);
|
||||
return [props.context, reactReduxForwardedRef, wrapperProps];
|
||||
}, [props]),
|
||||
propsContext = _useMemo[0],
|
||||
reactReduxForwardedRef = _useMemo[1],
|
||||
wrapperProps = _useMemo[2];
|
||||
|
||||
var ContextToUse = (0, _react.useMemo)(function () {
|
||||
// Users may optionally pass in a custom context instance to use instead of our ReactReduxContext.
|
||||
// Memoize the check that determines which context instance we should use.
|
||||
return propsContext && propsContext.Consumer && (0, _reactIs.isContextConsumer)( /*#__PURE__*/_react["default"].createElement(propsContext.Consumer, null)) ? propsContext : Context;
|
||||
}, [propsContext, Context]); // Retrieve the store and ancestor subscription via context, if available
|
||||
|
||||
var contextValue = (0, _react.useContext)(ContextToUse); // The store _must_ exist as either a prop or in context.
|
||||
// We'll check to see if it _looks_ like a Redux store first.
|
||||
// This allows us to pass through a `store` prop that is just a plain value.
|
||||
|
||||
var didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch);
|
||||
var didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !didStoreComeFromProps && !didStoreComeFromContext) {
|
||||
throw new Error("Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options."));
|
||||
} // Based on the previous check, one of these must be true
|
||||
|
||||
|
||||
var store = didStoreComeFromProps ? props.store : contextValue.store;
|
||||
var childPropsSelector = (0, _react.useMemo)(function () {
|
||||
// The child props selector needs the store reference as an input.
|
||||
// Re-create this selector whenever the store changes.
|
||||
return createChildSelector(store);
|
||||
}, [store]);
|
||||
|
||||
var _useMemo2 = (0, _react.useMemo)(function () {
|
||||
if (!shouldHandleStateChanges) return NO_SUBSCRIPTION_ARRAY; // This Subscription's source should match where store came from: props vs. context. A component
|
||||
// connected to the store via props shouldn't use subscription from context, or vice versa.
|
||||
|
||||
// This Subscription's source should match where store came from: props vs. context. A component
|
||||
// connected to the store via props shouldn't use subscription from context, or vice versa.
|
||||
var subscription = (0, _Subscription.createSubscription)(store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
|
||||
// the middle of the notification loop, where `subscription` will then be null. This can
|
||||
// probably be avoided if Subscription's listeners logic is changed to not call listeners
|
||||
// that have been unsubscribed in the middle of the notification loop.
|
||||
|
||||
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
|
||||
// the middle of the notification loop, where `subscription` will then be null. This can
|
||||
// probably be avoided if Subscription's listeners logic is changed to not call listeners
|
||||
// that have been unsubscribed in the middle of the notification loop.
|
||||
var notifyNestedSubs = subscription.notifyNestedSubs.bind(subscription);
|
||||
return [subscription, notifyNestedSubs];
|
||||
}, [store, didStoreComeFromProps, contextValue]),
|
||||
subscription = _useMemo2[0],
|
||||
notifyNestedSubs = _useMemo2[1]; // Determine what {store, subscription} value should be put into nested context, if necessary,
|
||||
// and memoize that value to avoid unnecessary context updates.
|
||||
|
||||
|
||||
var overriddenContextValue = (0, _react.useMemo)(function () {
|
||||
if (didStoreComeFromProps) {
|
||||
// This component is directly subscribed to a store from props.
|
||||
// We don't want descendants reading from this store - pass down whatever
|
||||
// the existing context value is from the nearest connected ancestor.
|
||||
return contextValue;
|
||||
} // Otherwise, put this component's subscription instance into context, so that
|
||||
// connected descendants won't update until after this component is done
|
||||
|
||||
|
||||
return (0, _extends2["default"])({}, contextValue, {
|
||||
subscription: subscription
|
||||
});
|
||||
}, [didStoreComeFromProps, contextValue, subscription]); // We need to force this wrapper component to re-render whenever a Redux store update
|
||||
// causes a change to the calculated child component props (or we caught an error in mapState)
|
||||
|
||||
var _useReducer = (0, _react.useReducer)(storeStateUpdatesReducer, EMPTY_ARRAY, initStateUpdates),
|
||||
_useReducer$ = _useReducer[0],
|
||||
previousStateUpdateResult = _useReducer$[0],
|
||||
forceComponentUpdateDispatch = _useReducer[1]; // Propagate any mapState/mapDispatch errors upwards
|
||||
|
||||
|
||||
if (previousStateUpdateResult && previousStateUpdateResult.error) {
|
||||
throw previousStateUpdateResult.error;
|
||||
} // Set up refs to coordinate values between the subscription effect and the render logic
|
||||
|
||||
|
||||
var lastChildProps = (0, _react.useRef)();
|
||||
var lastWrapperProps = (0, _react.useRef)(wrapperProps);
|
||||
var childPropsFromStoreUpdate = (0, _react.useRef)();
|
||||
var renderIsScheduled = (0, _react.useRef)(false);
|
||||
var actualChildProps = usePureOnlyMemo(function () {
|
||||
// Tricky logic here:
|
||||
// - This render may have been triggered by a Redux store update that produced new child props
|
||||
// - However, we may have gotten new wrapper props after that
|
||||
// If we have new child props, and the same wrapper props, we know we should use the new child props as-is.
|
||||
// But, if we have new wrapper props, those might change the child props, so we have to recalculate things.
|
||||
// So, we'll use the child props from store update only if the wrapper props are the same as last time.
|
||||
if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) {
|
||||
return childPropsFromStoreUpdate.current;
|
||||
} // TODO We're reading the store directly in render() here. Bad idea?
|
||||
// This will likely cause Bad Things (TM) to happen in Concurrent Mode.
|
||||
// Note that we do this because on renders _not_ caused by store updates, we need the latest store state
|
||||
// to determine what the child props should be.
|
||||
|
||||
|
||||
return childPropsSelector(store.getState(), wrapperProps);
|
||||
}, [store, previousStateUpdateResult, wrapperProps]); // We need this to execute synchronously every time we re-render. However, React warns
|
||||
// about useLayoutEffect in SSR, so we try to detect environment and fall back to
|
||||
// just useEffect instead to avoid the warning, since neither will run anyway.
|
||||
|
||||
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs]); // Our re-subscribe logic only runs when the store/subscription setup changes
|
||||
|
||||
useIsomorphicLayoutEffectWithArgs(subscribeUpdates, [shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch], [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component.
|
||||
// We memoize the elements for the rendered child component as an optimization.
|
||||
|
||||
var renderedWrappedComponent = (0, _react.useMemo)(function () {
|
||||
return /*#__PURE__*/_react["default"].createElement(WrappedComponent, (0, _extends2["default"])({}, actualChildProps, {
|
||||
ref: reactReduxForwardedRef
|
||||
}));
|
||||
}, [reactReduxForwardedRef, WrappedComponent, actualChildProps]); // If React sees the exact same element reference as last time, it bails out of re-rendering
|
||||
// that child, same as if it was wrapped in React.memo() or returned false from shouldComponentUpdate.
|
||||
|
||||
var renderedChild = (0, _react.useMemo)(function () {
|
||||
if (shouldHandleStateChanges) {
|
||||
// If this component is subscribed to store updates, we need to pass its own
|
||||
// subscription instance down to our descendants. That means rendering the same
|
||||
// Context instance, and putting a different value into the context.
|
||||
return /*#__PURE__*/_react["default"].createElement(ContextToUse.Provider, {
|
||||
value: overriddenContextValue
|
||||
}, renderedWrappedComponent);
|
||||
}
|
||||
|
||||
return renderedWrappedComponent;
|
||||
}, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
|
||||
return renderedChild;
|
||||
} // If we're in "pure" mode, ensure our wrapper component only re-renders when incoming props have changed.
|
||||
|
||||
|
||||
var Connect = pure ? _react["default"].memo(ConnectFunction) : ConnectFunction;
|
||||
Connect.WrappedComponent = WrappedComponent;
|
||||
Connect.displayName = ConnectFunction.displayName = displayName;
|
||||
|
||||
if (forwardRef) {
|
||||
var forwarded = _react["default"].forwardRef(function forwardConnectRef(props, ref) {
|
||||
return /*#__PURE__*/_react["default"].createElement(Connect, (0, _extends2["default"])({}, props, {
|
||||
reactReduxForwardedRef: ref
|
||||
}));
|
||||
});
|
||||
|
||||
forwarded.displayName = displayName;
|
||||
forwarded.WrappedComponent = WrappedComponent;
|
||||
return (0, _hoistNonReactStatics["default"])(forwarded, WrappedComponent);
|
||||
}
|
||||
|
||||
return (0, _hoistNonReactStatics["default"])(Connect, WrappedComponent);
|
||||
};
|
||||
}
|
||||
117
node_modules/react-redux/lib/connect/connect.js
generated
vendored
Normal file
117
node_modules/react-redux/lib/connect/connect.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.createConnect = createConnect;
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
|
||||
var _connectAdvanced = _interopRequireDefault(require("../components/connectAdvanced"));
|
||||
|
||||
var _shallowEqual = _interopRequireDefault(require("../utils/shallowEqual"));
|
||||
|
||||
var _mapDispatchToProps = _interopRequireDefault(require("./mapDispatchToProps"));
|
||||
|
||||
var _mapStateToProps = _interopRequireDefault(require("./mapStateToProps"));
|
||||
|
||||
var _mergeProps = _interopRequireDefault(require("./mergeProps"));
|
||||
|
||||
var _selectorFactory = _interopRequireDefault(require("./selectorFactory"));
|
||||
|
||||
var _excluded = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"];
|
||||
|
||||
/*
|
||||
connect is a facade over connectAdvanced. It turns its args into a compatible
|
||||
selectorFactory, which has the signature:
|
||||
|
||||
(dispatch, options) => (nextState, nextOwnProps) => nextFinalProps
|
||||
|
||||
connect passes its args to connectAdvanced as options, which will in turn pass them to
|
||||
selectorFactory each time a Connect component instance is instantiated or hot reloaded.
|
||||
|
||||
selectorFactory returns a final props selector from its mapStateToProps,
|
||||
mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps,
|
||||
mergePropsFactories, and pure args.
|
||||
|
||||
The resulting final props selector is called by the Connect component instance whenever
|
||||
it receives new props or store state.
|
||||
*/
|
||||
function match(arg, factories, name) {
|
||||
for (var i = factories.length - 1; i >= 0; i--) {
|
||||
var result = factories[i](arg);
|
||||
if (result) return result;
|
||||
}
|
||||
|
||||
return function (dispatch, options) {
|
||||
throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + ".");
|
||||
};
|
||||
}
|
||||
|
||||
function strictEqual(a, b) {
|
||||
return a === b;
|
||||
} // createConnect with default args builds the 'official' connect behavior. Calling it with
|
||||
// different options opens up some testing and extensibility scenarios
|
||||
|
||||
|
||||
function createConnect(_temp) {
|
||||
var _ref = _temp === void 0 ? {} : _temp,
|
||||
_ref$connectHOC = _ref.connectHOC,
|
||||
connectHOC = _ref$connectHOC === void 0 ? _connectAdvanced["default"] : _ref$connectHOC,
|
||||
_ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
|
||||
mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? _mapStateToProps["default"] : _ref$mapStateToPropsF,
|
||||
_ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
|
||||
mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? _mapDispatchToProps["default"] : _ref$mapDispatchToPro,
|
||||
_ref$mergePropsFactor = _ref.mergePropsFactories,
|
||||
mergePropsFactories = _ref$mergePropsFactor === void 0 ? _mergeProps["default"] : _ref$mergePropsFactor,
|
||||
_ref$selectorFactory = _ref.selectorFactory,
|
||||
selectorFactory = _ref$selectorFactory === void 0 ? _selectorFactory["default"] : _ref$selectorFactory;
|
||||
|
||||
return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) {
|
||||
if (_ref2 === void 0) {
|
||||
_ref2 = {};
|
||||
}
|
||||
|
||||
var _ref3 = _ref2,
|
||||
_ref3$pure = _ref3.pure,
|
||||
pure = _ref3$pure === void 0 ? true : _ref3$pure,
|
||||
_ref3$areStatesEqual = _ref3.areStatesEqual,
|
||||
areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual,
|
||||
_ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual,
|
||||
areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? _shallowEqual["default"] : _ref3$areOwnPropsEqua,
|
||||
_ref3$areStatePropsEq = _ref3.areStatePropsEqual,
|
||||
areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? _shallowEqual["default"] : _ref3$areStatePropsEq,
|
||||
_ref3$areMergedPropsE = _ref3.areMergedPropsEqual,
|
||||
areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? _shallowEqual["default"] : _ref3$areMergedPropsE,
|
||||
extraOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref3, _excluded);
|
||||
var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
|
||||
var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
|
||||
var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
|
||||
return connectHOC(selectorFactory, (0, _extends2["default"])({
|
||||
// used in error messages
|
||||
methodName: 'connect',
|
||||
// used to compute Connect's displayName from the wrapped component's displayName.
|
||||
getDisplayName: function getDisplayName(name) {
|
||||
return "Connect(" + name + ")";
|
||||
},
|
||||
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
|
||||
shouldHandleStateChanges: Boolean(mapStateToProps),
|
||||
// passed through to selectorFactory
|
||||
initMapStateToProps: initMapStateToProps,
|
||||
initMapDispatchToProps: initMapDispatchToProps,
|
||||
initMergeProps: initMergeProps,
|
||||
pure: pure,
|
||||
areStatesEqual: areStatesEqual,
|
||||
areOwnPropsEqual: areOwnPropsEqual,
|
||||
areStatePropsEqual: areStatePropsEqual,
|
||||
areMergedPropsEqual: areMergedPropsEqual
|
||||
}, extraOptions));
|
||||
};
|
||||
}
|
||||
|
||||
var _default = /*#__PURE__*/createConnect();
|
||||
|
||||
exports["default"] = _default;
|
||||
34
node_modules/react-redux/lib/connect/mapDispatchToProps.js
generated
vendored
Normal file
34
node_modules/react-redux/lib/connect/mapDispatchToProps.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = void 0;
|
||||
exports.whenMapDispatchToPropsIsFunction = whenMapDispatchToPropsIsFunction;
|
||||
exports.whenMapDispatchToPropsIsMissing = whenMapDispatchToPropsIsMissing;
|
||||
exports.whenMapDispatchToPropsIsObject = whenMapDispatchToPropsIsObject;
|
||||
|
||||
var _bindActionCreators = _interopRequireDefault(require("../utils/bindActionCreators"));
|
||||
|
||||
var _wrapMapToProps = require("./wrapMapToProps");
|
||||
|
||||
function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
|
||||
return typeof mapDispatchToProps === 'function' ? (0, _wrapMapToProps.wrapMapToPropsFunc)(mapDispatchToProps, 'mapDispatchToProps') : undefined;
|
||||
}
|
||||
|
||||
function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
|
||||
return !mapDispatchToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
|
||||
return {
|
||||
dispatch: dispatch
|
||||
};
|
||||
}) : undefined;
|
||||
}
|
||||
|
||||
function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
|
||||
return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
|
||||
return (0, _bindActionCreators["default"])(mapDispatchToProps, dispatch);
|
||||
}) : undefined;
|
||||
}
|
||||
|
||||
var _default = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject];
|
||||
exports["default"] = _default;
|
||||
21
node_modules/react-redux/lib/connect/mapStateToProps.js
generated
vendored
Normal file
21
node_modules/react-redux/lib/connect/mapStateToProps.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = void 0;
|
||||
exports.whenMapStateToPropsIsFunction = whenMapStateToPropsIsFunction;
|
||||
exports.whenMapStateToPropsIsMissing = whenMapStateToPropsIsMissing;
|
||||
|
||||
var _wrapMapToProps = require("./wrapMapToProps");
|
||||
|
||||
function whenMapStateToPropsIsFunction(mapStateToProps) {
|
||||
return typeof mapStateToProps === 'function' ? (0, _wrapMapToProps.wrapMapToPropsFunc)(mapStateToProps, 'mapStateToProps') : undefined;
|
||||
}
|
||||
|
||||
function whenMapStateToPropsIsMissing(mapStateToProps) {
|
||||
return !mapStateToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function () {
|
||||
return {};
|
||||
}) : undefined;
|
||||
}
|
||||
|
||||
var _default = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing];
|
||||
exports["default"] = _default;
|
||||
54
node_modules/react-redux/lib/connect/mergeProps.js
generated
vendored
Normal file
54
node_modules/react-redux/lib/connect/mergeProps.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = void 0;
|
||||
exports.defaultMergeProps = defaultMergeProps;
|
||||
exports.whenMergePropsIsFunction = whenMergePropsIsFunction;
|
||||
exports.whenMergePropsIsOmitted = whenMergePropsIsOmitted;
|
||||
exports.wrapMergePropsFunc = wrapMergePropsFunc;
|
||||
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
var _verifyPlainObject = _interopRequireDefault(require("../utils/verifyPlainObject"));
|
||||
|
||||
function defaultMergeProps(stateProps, dispatchProps, ownProps) {
|
||||
return (0, _extends2["default"])({}, ownProps, stateProps, dispatchProps);
|
||||
}
|
||||
|
||||
function wrapMergePropsFunc(mergeProps) {
|
||||
return function initMergePropsProxy(dispatch, _ref) {
|
||||
var displayName = _ref.displayName,
|
||||
pure = _ref.pure,
|
||||
areMergedPropsEqual = _ref.areMergedPropsEqual;
|
||||
var hasRunOnce = false;
|
||||
var mergedProps;
|
||||
return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
|
||||
var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
|
||||
if (hasRunOnce) {
|
||||
if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
|
||||
} else {
|
||||
hasRunOnce = true;
|
||||
mergedProps = nextMergedProps;
|
||||
if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject["default"])(mergedProps, displayName, 'mergeProps');
|
||||
}
|
||||
|
||||
return mergedProps;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function whenMergePropsIsFunction(mergeProps) {
|
||||
return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined;
|
||||
}
|
||||
|
||||
function whenMergePropsIsOmitted(mergeProps) {
|
||||
return !mergeProps ? function () {
|
||||
return defaultMergeProps;
|
||||
} : undefined;
|
||||
}
|
||||
|
||||
var _default = [whenMergePropsIsFunction, whenMergePropsIsOmitted];
|
||||
exports["default"] = _default;
|
||||
101
node_modules/react-redux/lib/connect/selectorFactory.js
generated
vendored
Normal file
101
node_modules/react-redux/lib/connect/selectorFactory.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = finalPropsSelectorFactory;
|
||||
exports.impureFinalPropsSelectorFactory = impureFinalPropsSelectorFactory;
|
||||
exports.pureFinalPropsSelectorFactory = pureFinalPropsSelectorFactory;
|
||||
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
|
||||
var _verifySubselectors = _interopRequireDefault(require("./verifySubselectors"));
|
||||
|
||||
var _excluded = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"];
|
||||
|
||||
function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) {
|
||||
return function impureFinalPropsSelector(state, ownProps) {
|
||||
return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps);
|
||||
};
|
||||
}
|
||||
|
||||
function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) {
|
||||
var areStatesEqual = _ref.areStatesEqual,
|
||||
areOwnPropsEqual = _ref.areOwnPropsEqual,
|
||||
areStatePropsEqual = _ref.areStatePropsEqual;
|
||||
var hasRunAtLeastOnce = false;
|
||||
var state;
|
||||
var ownProps;
|
||||
var stateProps;
|
||||
var dispatchProps;
|
||||
var mergedProps;
|
||||
|
||||
function handleFirstCall(firstState, firstOwnProps) {
|
||||
state = firstState;
|
||||
ownProps = firstOwnProps;
|
||||
stateProps = mapStateToProps(state, ownProps);
|
||||
dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
hasRunAtLeastOnce = true;
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleNewPropsAndNewState() {
|
||||
stateProps = mapStateToProps(state, ownProps);
|
||||
if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleNewProps() {
|
||||
if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps);
|
||||
if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleNewState() {
|
||||
var nextStateProps = mapStateToProps(state, ownProps);
|
||||
var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
|
||||
stateProps = nextStateProps;
|
||||
if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
function handleSubsequentCalls(nextState, nextOwnProps) {
|
||||
var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
|
||||
var stateChanged = !areStatesEqual(nextState, state, nextOwnProps, ownProps);
|
||||
state = nextState;
|
||||
ownProps = nextOwnProps;
|
||||
if (propsChanged && stateChanged) return handleNewPropsAndNewState();
|
||||
if (propsChanged) return handleNewProps();
|
||||
if (stateChanged) return handleNewState();
|
||||
return mergedProps;
|
||||
}
|
||||
|
||||
return function pureFinalPropsSelector(nextState, nextOwnProps) {
|
||||
return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
|
||||
};
|
||||
} // TODO: Add more comments
|
||||
// If pure is true, the selector returned by selectorFactory will memoize its results,
|
||||
// allowing connectAdvanced's shouldComponentUpdate to return false if final
|
||||
// props have not changed. If false, the selector will always return a new
|
||||
// object and shouldComponentUpdate will always return true.
|
||||
|
||||
|
||||
function finalPropsSelectorFactory(dispatch, _ref2) {
|
||||
var initMapStateToProps = _ref2.initMapStateToProps,
|
||||
initMapDispatchToProps = _ref2.initMapDispatchToProps,
|
||||
initMergeProps = _ref2.initMergeProps,
|
||||
options = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, _excluded);
|
||||
var mapStateToProps = initMapStateToProps(dispatch, options);
|
||||
var mapDispatchToProps = initMapDispatchToProps(dispatch, options);
|
||||
var mergeProps = initMergeProps(dispatch, options);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
(0, _verifySubselectors["default"])(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName);
|
||||
}
|
||||
|
||||
var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory;
|
||||
return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
|
||||
}
|
||||
24
node_modules/react-redux/lib/connect/verifySubselectors.js
generated
vendored
Normal file
24
node_modules/react-redux/lib/connect/verifySubselectors.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = verifySubselectors;
|
||||
|
||||
var _warning = _interopRequireDefault(require("../utils/warning"));
|
||||
|
||||
function verify(selector, methodName, displayName) {
|
||||
if (!selector) {
|
||||
throw new Error("Unexpected value for " + methodName + " in " + displayName + ".");
|
||||
} else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
|
||||
if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
|
||||
(0, _warning["default"])("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
|
||||
verify(mapStateToProps, 'mapStateToProps', displayName);
|
||||
verify(mapDispatchToProps, 'mapDispatchToProps', displayName);
|
||||
verify(mergeProps, 'mergeProps', displayName);
|
||||
}
|
||||
76
node_modules/react-redux/lib/connect/wrapMapToProps.js
generated
vendored
Normal file
76
node_modules/react-redux/lib/connect/wrapMapToProps.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.getDependsOnOwnProps = getDependsOnOwnProps;
|
||||
exports.wrapMapToPropsConstant = wrapMapToPropsConstant;
|
||||
exports.wrapMapToPropsFunc = wrapMapToPropsFunc;
|
||||
|
||||
var _verifyPlainObject = _interopRequireDefault(require("../utils/verifyPlainObject"));
|
||||
|
||||
function wrapMapToPropsConstant(getConstant) {
|
||||
return function initConstantSelector(dispatch, options) {
|
||||
var constant = getConstant(dispatch, options);
|
||||
|
||||
function constantSelector() {
|
||||
return constant;
|
||||
}
|
||||
|
||||
constantSelector.dependsOnOwnProps = false;
|
||||
return constantSelector;
|
||||
};
|
||||
} // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args
|
||||
// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine
|
||||
// whether mapToProps needs to be invoked when props have changed.
|
||||
//
|
||||
// A length of one signals that mapToProps does not depend on props from the parent component.
|
||||
// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and
|
||||
// therefore not reporting its length accurately..
|
||||
|
||||
|
||||
function getDependsOnOwnProps(mapToProps) {
|
||||
return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
|
||||
} // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
|
||||
// this function wraps mapToProps in a proxy function which does several things:
|
||||
//
|
||||
// * Detects whether the mapToProps function being called depends on props, which
|
||||
// is used by selectorFactory to decide if it should reinvoke on props changes.
|
||||
//
|
||||
// * On first call, handles mapToProps if returns another function, and treats that
|
||||
// new function as the true mapToProps for subsequent calls.
|
||||
//
|
||||
// * On first call, verifies the first result is a plain object, in order to warn
|
||||
// the developer that their mapToProps function is not returning a valid result.
|
||||
//
|
||||
|
||||
|
||||
function wrapMapToPropsFunc(mapToProps, methodName) {
|
||||
return function initProxySelector(dispatch, _ref) {
|
||||
var displayName = _ref.displayName;
|
||||
|
||||
var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
|
||||
return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);
|
||||
}; // allow detectFactoryAndVerify to get ownProps
|
||||
|
||||
|
||||
proxy.dependsOnOwnProps = true;
|
||||
|
||||
proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
|
||||
proxy.mapToProps = mapToProps;
|
||||
proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
|
||||
var props = proxy(stateOrDispatch, ownProps);
|
||||
|
||||
if (typeof props === 'function') {
|
||||
proxy.mapToProps = props;
|
||||
proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
|
||||
props = proxy(stateOrDispatch, ownProps);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject["default"])(props, displayName, methodName);
|
||||
return props;
|
||||
};
|
||||
|
||||
return proxy;
|
||||
};
|
||||
}
|
||||
40
node_modules/react-redux/lib/exports.js
generated
vendored
Normal file
40
node_modules/react-redux/lib/exports.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _Provider = _interopRequireDefault(require("./components/Provider"));
|
||||
|
||||
exports.Provider = _Provider["default"];
|
||||
|
||||
var _connectAdvanced = _interopRequireDefault(require("./components/connectAdvanced"));
|
||||
|
||||
exports.connectAdvanced = _connectAdvanced["default"];
|
||||
|
||||
var _Context = require("./components/Context");
|
||||
|
||||
exports.ReactReduxContext = _Context.ReactReduxContext;
|
||||
|
||||
var _connect = _interopRequireDefault(require("./connect/connect"));
|
||||
|
||||
exports.connect = _connect["default"];
|
||||
|
||||
var _useDispatch = require("./hooks/useDispatch");
|
||||
|
||||
exports.useDispatch = _useDispatch.useDispatch;
|
||||
exports.createDispatchHook = _useDispatch.createDispatchHook;
|
||||
|
||||
var _useSelector = require("./hooks/useSelector");
|
||||
|
||||
exports.useSelector = _useSelector.useSelector;
|
||||
exports.createSelectorHook = _useSelector.createSelectorHook;
|
||||
|
||||
var _useStore = require("./hooks/useStore");
|
||||
|
||||
exports.useStore = _useStore.useStore;
|
||||
exports.createStoreHook = _useStore.createStoreHook;
|
||||
|
||||
var _shallowEqual = _interopRequireDefault(require("./utils/shallowEqual"));
|
||||
|
||||
exports.shallowEqual = _shallowEqual["default"];
|
||||
52
node_modules/react-redux/lib/hooks/useDispatch.js
generated
vendored
Normal file
52
node_modules/react-redux/lib/hooks/useDispatch.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.createDispatchHook = createDispatchHook;
|
||||
exports.useDispatch = void 0;
|
||||
|
||||
var _Context = require("../components/Context");
|
||||
|
||||
var _useStore = require("./useStore");
|
||||
|
||||
/**
|
||||
* Hook factory, which creates a `useDispatch` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useDispatch` hook bound to the specified context.
|
||||
*/
|
||||
function createDispatchHook(context) {
|
||||
if (context === void 0) {
|
||||
context = _Context.ReactReduxContext;
|
||||
}
|
||||
|
||||
var useStore = context === _Context.ReactReduxContext ? _useStore.useStore : (0, _useStore.createStoreHook)(context);
|
||||
return function useDispatch() {
|
||||
var store = useStore();
|
||||
return store.dispatch;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A hook to access the redux `dispatch` function.
|
||||
*
|
||||
* @returns {any|function} redux store's `dispatch` function
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React, { useCallback } from 'react'
|
||||
* import { useDispatch } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = ({ value }) => {
|
||||
* const dispatch = useDispatch()
|
||||
* const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
|
||||
* return (
|
||||
* <div>
|
||||
* <span>{value}</span>
|
||||
* <button onClick={increaseCounter}>Increase counter</button>
|
||||
* </div>
|
||||
* )
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
var useDispatch = /*#__PURE__*/createDispatchHook();
|
||||
exports.useDispatch = useDispatch;
|
||||
34
node_modules/react-redux/lib/hooks/useReduxContext.js
generated
vendored
Normal file
34
node_modules/react-redux/lib/hooks/useReduxContext.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.useReduxContext = useReduxContext;
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
var _Context = require("../components/Context");
|
||||
|
||||
/**
|
||||
* A hook to access the value of the `ReactReduxContext`. This is a low-level
|
||||
* hook that you should usually not need to call directly.
|
||||
*
|
||||
* @returns {any} the value of the `ReactReduxContext`
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useReduxContext } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = ({ value }) => {
|
||||
* const { store } = useReduxContext()
|
||||
* return <div>{store.getState()}</div>
|
||||
* }
|
||||
*/
|
||||
function useReduxContext() {
|
||||
var contextValue = (0, _react.useContext)(_Context.ReactReduxContext);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !contextValue) {
|
||||
throw new Error('could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
|
||||
}
|
||||
|
||||
return contextValue;
|
||||
}
|
||||
170
node_modules/react-redux/lib/hooks/useSelector.js
generated
vendored
Normal file
170
node_modules/react-redux/lib/hooks/useSelector.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.createSelectorHook = createSelectorHook;
|
||||
exports.useSelector = void 0;
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
var _useReduxContext2 = require("./useReduxContext");
|
||||
|
||||
var _Subscription = require("../utils/Subscription");
|
||||
|
||||
var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect");
|
||||
|
||||
var _Context = require("../components/Context");
|
||||
|
||||
var refEquality = function refEquality(a, b) {
|
||||
return a === b;
|
||||
};
|
||||
|
||||
function useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub) {
|
||||
var _useReducer = (0, _react.useReducer)(function (s) {
|
||||
return s + 1;
|
||||
}, 0),
|
||||
forceRender = _useReducer[1];
|
||||
|
||||
var subscription = (0, _react.useMemo)(function () {
|
||||
return (0, _Subscription.createSubscription)(store, contextSub);
|
||||
}, [store, contextSub]);
|
||||
var latestSubscriptionCallbackError = (0, _react.useRef)();
|
||||
var latestSelector = (0, _react.useRef)();
|
||||
var latestStoreState = (0, _react.useRef)();
|
||||
var latestSelectedState = (0, _react.useRef)();
|
||||
var storeState = store.getState();
|
||||
var selectedState;
|
||||
|
||||
try {
|
||||
if (selector !== latestSelector.current || storeState !== latestStoreState.current || latestSubscriptionCallbackError.current) {
|
||||
var newSelectedState = selector(storeState); // ensure latest selected state is reused so that a custom equality function can result in identical references
|
||||
|
||||
if (latestSelectedState.current === undefined || !equalityFn(newSelectedState, latestSelectedState.current)) {
|
||||
selectedState = newSelectedState;
|
||||
} else {
|
||||
selectedState = latestSelectedState.current;
|
||||
}
|
||||
} else {
|
||||
selectedState = latestSelectedState.current;
|
||||
}
|
||||
} catch (err) {
|
||||
if (latestSubscriptionCallbackError.current) {
|
||||
err.message += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\n";
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
|
||||
latestSelector.current = selector;
|
||||
latestStoreState.current = storeState;
|
||||
latestSelectedState.current = selectedState;
|
||||
latestSubscriptionCallbackError.current = undefined;
|
||||
});
|
||||
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
|
||||
function checkForUpdates() {
|
||||
try {
|
||||
var newStoreState = store.getState(); // Avoid calling selector multiple times if the store's state has not changed
|
||||
|
||||
if (newStoreState === latestStoreState.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
var _newSelectedState = latestSelector.current(newStoreState);
|
||||
|
||||
if (equalityFn(_newSelectedState, latestSelectedState.current)) {
|
||||
return;
|
||||
}
|
||||
|
||||
latestSelectedState.current = _newSelectedState;
|
||||
latestStoreState.current = newStoreState;
|
||||
} catch (err) {
|
||||
// we ignore all errors here, since when the component
|
||||
// is re-rendered, the selectors are called again, and
|
||||
// will throw again, if neither props nor store state
|
||||
// changed
|
||||
latestSubscriptionCallbackError.current = err;
|
||||
}
|
||||
|
||||
forceRender();
|
||||
}
|
||||
|
||||
subscription.onStateChange = checkForUpdates;
|
||||
subscription.trySubscribe();
|
||||
checkForUpdates();
|
||||
return function () {
|
||||
return subscription.tryUnsubscribe();
|
||||
};
|
||||
}, [store, subscription]);
|
||||
return selectedState;
|
||||
}
|
||||
/**
|
||||
* Hook factory, which creates a `useSelector` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useSelector` hook bound to the specified context.
|
||||
*/
|
||||
|
||||
|
||||
function createSelectorHook(context) {
|
||||
if (context === void 0) {
|
||||
context = _Context.ReactReduxContext;
|
||||
}
|
||||
|
||||
var useReduxContext = context === _Context.ReactReduxContext ? _useReduxContext2.useReduxContext : function () {
|
||||
return (0, _react.useContext)(context);
|
||||
};
|
||||
return function useSelector(selector, equalityFn) {
|
||||
if (equalityFn === void 0) {
|
||||
equalityFn = refEquality;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!selector) {
|
||||
throw new Error("You must pass a selector to useSelector");
|
||||
}
|
||||
|
||||
if (typeof selector !== 'function') {
|
||||
throw new Error("You must pass a function as a selector to useSelector");
|
||||
}
|
||||
|
||||
if (typeof equalityFn !== 'function') {
|
||||
throw new Error("You must pass a function as an equality function to useSelector");
|
||||
}
|
||||
}
|
||||
|
||||
var _useReduxContext = useReduxContext(),
|
||||
store = _useReduxContext.store,
|
||||
contextSub = _useReduxContext.subscription;
|
||||
|
||||
var selectedState = useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub);
|
||||
(0, _react.useDebugValue)(selectedState);
|
||||
return selectedState;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A hook to access the redux store's state. This hook takes a selector function
|
||||
* as an argument. The selector is called with the store state.
|
||||
*
|
||||
* This hook takes an optional equality comparison function as the second parameter
|
||||
* that allows you to customize the way the selected state is compared to determine
|
||||
* whether the component needs to be re-rendered.
|
||||
*
|
||||
* @param {Function} selector the selector function
|
||||
* @param {Function=} equalityFn the function that will be used to determine equality
|
||||
*
|
||||
* @returns {any} the selected state
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useSelector } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = () => {
|
||||
* const counter = useSelector(state => state.counter)
|
||||
* return <div>{counter}</div>
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
var useSelector = /*#__PURE__*/createSelectorHook();
|
||||
exports.useSelector = useSelector;
|
||||
52
node_modules/react-redux/lib/hooks/useStore.js
generated
vendored
Normal file
52
node_modules/react-redux/lib/hooks/useStore.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.createStoreHook = createStoreHook;
|
||||
exports.useStore = void 0;
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
var _Context = require("../components/Context");
|
||||
|
||||
var _useReduxContext2 = require("./useReduxContext");
|
||||
|
||||
/**
|
||||
* Hook factory, which creates a `useStore` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useStore` hook bound to the specified context.
|
||||
*/
|
||||
function createStoreHook(context) {
|
||||
if (context === void 0) {
|
||||
context = _Context.ReactReduxContext;
|
||||
}
|
||||
|
||||
var useReduxContext = context === _Context.ReactReduxContext ? _useReduxContext2.useReduxContext : function () {
|
||||
return (0, _react.useContext)(context);
|
||||
};
|
||||
return function useStore() {
|
||||
var _useReduxContext = useReduxContext(),
|
||||
store = _useReduxContext.store;
|
||||
|
||||
return store;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A hook to access the redux store.
|
||||
*
|
||||
* @returns {any} the redux store
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useStore } from 'react-redux'
|
||||
*
|
||||
* export const ExampleComponent = () => {
|
||||
* const store = useStore()
|
||||
* return <div>{store.getState()}</div>
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
var useStore = /*#__PURE__*/createStoreHook();
|
||||
exports.useStore = useStore;
|
||||
25
node_modules/react-redux/lib/index.js
generated
vendored
Normal file
25
node_modules/react-redux/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
var _exportNames = {
|
||||
batch: true
|
||||
};
|
||||
|
||||
var _exports = require("./exports");
|
||||
|
||||
Object.keys(_exports).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _exports[key]) return;
|
||||
exports[key] = _exports[key];
|
||||
});
|
||||
|
||||
var _reactBatchedUpdates = require("./utils/reactBatchedUpdates");
|
||||
|
||||
exports.batch = _reactBatchedUpdates.unstable_batchedUpdates;
|
||||
|
||||
var _batch = require("./utils/batch");
|
||||
|
||||
// Enable batched updates in our subscriptions for use
|
||||
// with standard React renderers (ReactDOM, React Native)
|
||||
(0, _batch.setBatch)(_reactBatchedUpdates.unstable_batchedUpdates);
|
||||
133
node_modules/react-redux/lib/utils/Subscription.js
generated
vendored
Normal file
133
node_modules/react-redux/lib/utils/Subscription.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.createSubscription = createSubscription;
|
||||
|
||||
var _batch = require("./batch");
|
||||
|
||||
// encapsulates the subscription logic for connecting a component to the redux store, as
|
||||
// well as nesting subscriptions of descendant components, so that we can ensure the
|
||||
// ancestor components re-render before descendants
|
||||
function createListenerCollection() {
|
||||
var batch = (0, _batch.getBatch)();
|
||||
var first = null;
|
||||
var last = null;
|
||||
return {
|
||||
clear: function clear() {
|
||||
first = null;
|
||||
last = null;
|
||||
},
|
||||
notify: function notify() {
|
||||
batch(function () {
|
||||
var listener = first;
|
||||
|
||||
while (listener) {
|
||||
listener.callback();
|
||||
listener = listener.next;
|
||||
}
|
||||
});
|
||||
},
|
||||
get: function get() {
|
||||
var listeners = [];
|
||||
var listener = first;
|
||||
|
||||
while (listener) {
|
||||
listeners.push(listener);
|
||||
listener = listener.next;
|
||||
}
|
||||
|
||||
return listeners;
|
||||
},
|
||||
subscribe: function subscribe(callback) {
|
||||
var isSubscribed = true;
|
||||
var listener = last = {
|
||||
callback: callback,
|
||||
next: null,
|
||||
prev: last
|
||||
};
|
||||
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener;
|
||||
} else {
|
||||
first = listener;
|
||||
}
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed || first === null) return;
|
||||
isSubscribed = false;
|
||||
|
||||
if (listener.next) {
|
||||
listener.next.prev = listener.prev;
|
||||
} else {
|
||||
last = listener.prev;
|
||||
}
|
||||
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener.next;
|
||||
} else {
|
||||
first = listener.next;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var nullListeners = {
|
||||
notify: function notify() {},
|
||||
get: function get() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
function createSubscription(store, parentSub) {
|
||||
var unsubscribe;
|
||||
var listeners = nullListeners;
|
||||
|
||||
function addNestedSub(listener) {
|
||||
trySubscribe();
|
||||
return listeners.subscribe(listener);
|
||||
}
|
||||
|
||||
function notifyNestedSubs() {
|
||||
listeners.notify();
|
||||
}
|
||||
|
||||
function handleChangeWrapper() {
|
||||
if (subscription.onStateChange) {
|
||||
subscription.onStateChange();
|
||||
}
|
||||
}
|
||||
|
||||
function isSubscribed() {
|
||||
return Boolean(unsubscribe);
|
||||
}
|
||||
|
||||
function trySubscribe() {
|
||||
if (!unsubscribe) {
|
||||
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
|
||||
listeners = createListenerCollection();
|
||||
}
|
||||
}
|
||||
|
||||
function tryUnsubscribe() {
|
||||
if (unsubscribe) {
|
||||
unsubscribe();
|
||||
unsubscribe = undefined;
|
||||
listeners.clear();
|
||||
listeners = nullListeners;
|
||||
}
|
||||
}
|
||||
|
||||
var subscription = {
|
||||
addNestedSub: addNestedSub,
|
||||
notifyNestedSubs: notifyNestedSubs,
|
||||
handleChangeWrapper: handleChangeWrapper,
|
||||
isSubscribed: isSubscribed,
|
||||
trySubscribe: trySubscribe,
|
||||
tryUnsubscribe: tryUnsubscribe,
|
||||
getListeners: function getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
};
|
||||
return subscription;
|
||||
}
|
||||
24
node_modules/react-redux/lib/utils/batch.js
generated
vendored
Normal file
24
node_modules/react-redux/lib/utils/batch.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.setBatch = exports.getBatch = void 0;
|
||||
|
||||
// Default to a dummy "batch" implementation that just runs the callback
|
||||
function defaultNoopBatch(callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
var batch = defaultNoopBatch; // Allow injecting another batching function later
|
||||
|
||||
var setBatch = function setBatch(newBatch) {
|
||||
return batch = newBatch;
|
||||
}; // Supply a getter just to skip dealing with ESM bindings
|
||||
|
||||
|
||||
exports.setBatch = setBatch;
|
||||
|
||||
var getBatch = function getBatch() {
|
||||
return batch;
|
||||
};
|
||||
|
||||
exports.getBatch = getBatch;
|
||||
24
node_modules/react-redux/lib/utils/bindActionCreators.js
generated
vendored
Normal file
24
node_modules/react-redux/lib/utils/bindActionCreators.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = bindActionCreators;
|
||||
|
||||
function bindActionCreators(actionCreators, dispatch) {
|
||||
var boundActionCreators = {};
|
||||
|
||||
var _loop = function _loop(key) {
|
||||
var actionCreator = actionCreators[key];
|
||||
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = function () {
|
||||
return dispatch(actionCreator.apply(void 0, arguments));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
for (var key in actionCreators) {
|
||||
_loop(key);
|
||||
}
|
||||
|
||||
return boundActionCreators;
|
||||
}
|
||||
21
node_modules/react-redux/lib/utils/isPlainObject.js
generated
vendored
Normal file
21
node_modules/react-redux/lib/utils/isPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = isPlainObject;
|
||||
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false;
|
||||
var proto = Object.getPrototypeOf(obj);
|
||||
if (proto === null) return true;
|
||||
var baseProto = proto;
|
||||
|
||||
while (Object.getPrototypeOf(baseProto) !== null) {
|
||||
baseProto = Object.getPrototypeOf(baseProto);
|
||||
}
|
||||
|
||||
return proto === baseProto;
|
||||
}
|
||||
8
node_modules/react-redux/lib/utils/reactBatchedUpdates.js
generated
vendored
Normal file
8
node_modules/react-redux/lib/utils/reactBatchedUpdates.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.unstable_batchedUpdates = void 0;
|
||||
|
||||
var _reactDom = require("react-dom");
|
||||
|
||||
exports.unstable_batchedUpdates = _reactDom.unstable_batchedUpdates;
|
||||
7
node_modules/react-redux/lib/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
7
node_modules/react-redux/lib/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _reactNative = require("react-native");
|
||||
|
||||
exports.unstable_batchedUpdates = _reactNative.unstable_batchedUpdates;
|
||||
32
node_modules/react-redux/lib/utils/shallowEqual.js
generated
vendored
Normal file
32
node_modules/react-redux/lib/utils/shallowEqual.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = shallowEqual;
|
||||
|
||||
function is(x, y) {
|
||||
if (x === y) {
|
||||
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
||||
} else {
|
||||
return x !== x && y !== y;
|
||||
}
|
||||
}
|
||||
|
||||
function shallowEqual(objA, objB) {
|
||||
if (is(objA, objB)) return true;
|
||||
|
||||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var keysA = Object.keys(objA);
|
||||
var keysB = Object.keys(objB);
|
||||
if (keysA.length !== keysB.length) return false;
|
||||
|
||||
for (var i = 0; i < keysA.length; i++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
17
node_modules/react-redux/lib/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
17
node_modules/react-redux/lib/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.useIsomorphicLayoutEffect = void 0;
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
// React currently throws a warning when using useLayoutEffect on the server.
|
||||
// To get around it, we can conditionally useEffect on the server (no-op) and
|
||||
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
|
||||
// subscription callback always has the selector from the latest render commit
|
||||
// available, otherwise a store update may happen between render and the effect,
|
||||
// which may cause missed updates; we also must ensure the store subscription
|
||||
// is created synchronously, otherwise a store update may occur before the
|
||||
// subscription is created and an inconsistent state may be observed
|
||||
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
|
||||
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
||||
10
node_modules/react-redux/lib/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
10
node_modules/react-redux/lib/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.useIsomorphicLayoutEffect = void 0;
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
// Under React Native, we know that we always want to use useLayoutEffect
|
||||
var useIsomorphicLayoutEffect = _react.useLayoutEffect;
|
||||
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
||||
16
node_modules/react-redux/lib/utils/verifyPlainObject.js
generated
vendored
Normal file
16
node_modules/react-redux/lib/utils/verifyPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = verifyPlainObject;
|
||||
|
||||
var _isPlainObject = _interopRequireDefault(require("./isPlainObject"));
|
||||
|
||||
var _warning = _interopRequireDefault(require("./warning"));
|
||||
|
||||
function verifyPlainObject(value, displayName, methodName) {
|
||||
if (!(0, _isPlainObject["default"])(value)) {
|
||||
(0, _warning["default"])(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + ".");
|
||||
}
|
||||
}
|
||||
29
node_modules/react-redux/lib/utils/warning.js
generated
vendored
Normal file
29
node_modules/react-redux/lib/utils/warning.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = warning;
|
||||
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
|
||||
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message);
|
||||
/* eslint-disable no-empty */
|
||||
} catch (e) {}
|
||||
/* eslint-enable no-empty */
|
||||
|
||||
}
|
||||
21
node_modules/react-redux/node_modules/react-is/LICENSE
generated
vendored
Normal file
21
node_modules/react-redux/node_modules/react-is/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
104
node_modules/react-redux/node_modules/react-is/README.md
generated
vendored
Normal file
104
node_modules/react-redux/node_modules/react-is/README.md
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
# `react-is`
|
||||
|
||||
This package allows you to test arbitrary values and see if they're a particular React element type.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
# Yarn
|
||||
yarn add react-is
|
||||
|
||||
# NPM
|
||||
npm install react-is
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Determining if a Component is Valid
|
||||
|
||||
```js
|
||||
import React from "react";
|
||||
import * as ReactIs from "react-is";
|
||||
|
||||
class ClassComponent extends React.Component {
|
||||
render() {
|
||||
return React.createElement("div");
|
||||
}
|
||||
}
|
||||
|
||||
const FunctionComponent = () => React.createElement("div");
|
||||
|
||||
const ForwardRefComponent = React.forwardRef((props, ref) =>
|
||||
React.createElement(Component, { forwardedRef: ref, ...props })
|
||||
);
|
||||
|
||||
const Context = React.createContext(false);
|
||||
|
||||
ReactIs.isValidElementType("div"); // true
|
||||
ReactIs.isValidElementType(ClassComponent); // true
|
||||
ReactIs.isValidElementType(FunctionComponent); // true
|
||||
ReactIs.isValidElementType(ForwardRefComponent); // true
|
||||
ReactIs.isValidElementType(Context.Provider); // true
|
||||
ReactIs.isValidElementType(Context.Consumer); // true
|
||||
ReactIs.isValidElementType(React.createFactory("div")); // true
|
||||
```
|
||||
|
||||
### Determining an Element's Type
|
||||
|
||||
#### Context
|
||||
|
||||
```js
|
||||
import React from "react";
|
||||
import * as ReactIs from 'react-is';
|
||||
|
||||
const ThemeContext = React.createContext("blue");
|
||||
|
||||
ReactIs.isContextConsumer(<ThemeContext.Consumer />); // true
|
||||
ReactIs.isContextProvider(<ThemeContext.Provider />); // true
|
||||
ReactIs.typeOf(<ThemeContext.Provider />) === ReactIs.ContextProvider; // true
|
||||
ReactIs.typeOf(<ThemeContext.Consumer />) === ReactIs.ContextConsumer; // true
|
||||
```
|
||||
|
||||
#### Element
|
||||
|
||||
```js
|
||||
import React from "react";
|
||||
import * as ReactIs from 'react-is';
|
||||
|
||||
ReactIs.isElement(<div />); // true
|
||||
ReactIs.typeOf(<div />) === ReactIs.Element; // true
|
||||
```
|
||||
|
||||
#### Fragment
|
||||
|
||||
```js
|
||||
import React from "react";
|
||||
import * as ReactIs from 'react-is';
|
||||
|
||||
ReactIs.isFragment(<></>); // true
|
||||
ReactIs.typeOf(<></>) === ReactIs.Fragment; // true
|
||||
```
|
||||
|
||||
#### Portal
|
||||
|
||||
```js
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import * as ReactIs from 'react-is';
|
||||
|
||||
const div = document.createElement("div");
|
||||
const portal = ReactDOM.createPortal(<div />, div);
|
||||
|
||||
ReactIs.isPortal(portal); // true
|
||||
ReactIs.typeOf(portal) === ReactIs.Portal; // true
|
||||
```
|
||||
|
||||
#### StrictMode
|
||||
|
||||
```js
|
||||
import React from "react";
|
||||
import * as ReactIs from 'react-is';
|
||||
|
||||
ReactIs.isStrictMode(<React.StrictMode />); // true
|
||||
ReactIs.typeOf(<React.StrictMode />) === ReactIs.StrictMode; // true
|
||||
```
|
||||
8
node_modules/react-redux/node_modules/react-is/build-info.json
generated
vendored
Normal file
8
node_modules/react-redux/node_modules/react-is/build-info.json
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"branch": "pull/21051",
|
||||
"buildNumber": "287151",
|
||||
"checksum": "94f5c65",
|
||||
"commit": "12adaffef",
|
||||
"environment": "ci",
|
||||
"reactVersion": "17.0.0-12adaffef"
|
||||
}
|
||||
226
node_modules/react-redux/node_modules/react-is/cjs/react-is.development.js
generated
vendored
Normal file
226
node_modules/react-redux/node_modules/react-is/cjs/react-is.development.js
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
/** @license React v17.0.2
|
||||
* react-is.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
var REACT_FRAGMENT_TYPE = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function typeOf(object) {
|
||||
if (typeof object === 'object' && object !== null) {
|
||||
var $$typeof = object.$$typeof;
|
||||
|
||||
switch ($$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
var type = object.type;
|
||||
|
||||
switch (type) {
|
||||
case REACT_FRAGMENT_TYPE:
|
||||
case REACT_PROFILER_TYPE:
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return type;
|
||||
|
||||
default:
|
||||
var $$typeofType = type && type.$$typeof;
|
||||
|
||||
switch ($$typeofType) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
case REACT_LAZY_TYPE:
|
||||
case REACT_MEMO_TYPE:
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return $$typeofType;
|
||||
|
||||
default:
|
||||
return $$typeof;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return $$typeof;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
var ContextConsumer = REACT_CONTEXT_TYPE;
|
||||
var ContextProvider = REACT_PROVIDER_TYPE;
|
||||
var Element = REACT_ELEMENT_TYPE;
|
||||
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
||||
var Fragment = REACT_FRAGMENT_TYPE;
|
||||
var Lazy = REACT_LAZY_TYPE;
|
||||
var Memo = REACT_MEMO_TYPE;
|
||||
var Portal = REACT_PORTAL_TYPE;
|
||||
var Profiler = REACT_PROFILER_TYPE;
|
||||
var StrictMode = REACT_STRICT_MODE_TYPE;
|
||||
var Suspense = REACT_SUSPENSE_TYPE;
|
||||
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
||||
var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
|
||||
|
||||
function isAsyncMode(object) {
|
||||
{
|
||||
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
||||
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
||||
|
||||
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
function isConcurrentMode(object) {
|
||||
{
|
||||
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
|
||||
hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
|
||||
|
||||
console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
function isContextConsumer(object) {
|
||||
return typeOf(object) === REACT_CONTEXT_TYPE;
|
||||
}
|
||||
function isContextProvider(object) {
|
||||
return typeOf(object) === REACT_PROVIDER_TYPE;
|
||||
}
|
||||
function isElement(object) {
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
function isForwardRef(object) {
|
||||
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
||||
}
|
||||
function isFragment(object) {
|
||||
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
||||
}
|
||||
function isLazy(object) {
|
||||
return typeOf(object) === REACT_LAZY_TYPE;
|
||||
}
|
||||
function isMemo(object) {
|
||||
return typeOf(object) === REACT_MEMO_TYPE;
|
||||
}
|
||||
function isPortal(object) {
|
||||
return typeOf(object) === REACT_PORTAL_TYPE;
|
||||
}
|
||||
function isProfiler(object) {
|
||||
return typeOf(object) === REACT_PROFILER_TYPE;
|
||||
}
|
||||
function isStrictMode(object) {
|
||||
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
||||
}
|
||||
function isSuspense(object) {
|
||||
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
||||
}
|
||||
|
||||
exports.ContextConsumer = ContextConsumer;
|
||||
exports.ContextProvider = ContextProvider;
|
||||
exports.Element = Element;
|
||||
exports.ForwardRef = ForwardRef;
|
||||
exports.Fragment = Fragment;
|
||||
exports.Lazy = Lazy;
|
||||
exports.Memo = Memo;
|
||||
exports.Portal = Portal;
|
||||
exports.Profiler = Profiler;
|
||||
exports.StrictMode = StrictMode;
|
||||
exports.Suspense = Suspense;
|
||||
exports.isAsyncMode = isAsyncMode;
|
||||
exports.isConcurrentMode = isConcurrentMode;
|
||||
exports.isContextConsumer = isContextConsumer;
|
||||
exports.isContextProvider = isContextProvider;
|
||||
exports.isElement = isElement;
|
||||
exports.isForwardRef = isForwardRef;
|
||||
exports.isFragment = isFragment;
|
||||
exports.isLazy = isLazy;
|
||||
exports.isMemo = isMemo;
|
||||
exports.isPortal = isPortal;
|
||||
exports.isProfiler = isProfiler;
|
||||
exports.isStrictMode = isStrictMode;
|
||||
exports.isSuspense = isSuspense;
|
||||
exports.isValidElementType = isValidElementType;
|
||||
exports.typeOf = typeOf;
|
||||
})();
|
||||
}
|
||||
14
node_modules/react-redux/node_modules/react-is/cjs/react-is.production.min.js
generated
vendored
Normal file
14
node_modules/react-redux/node_modules/react-is/cjs/react-is.production.min.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/** @license React v17.0.2
|
||||
* react-is.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';var b=60103,c=60106,d=60107,e=60108,f=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131;
|
||||
if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden")}
|
||||
function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f,H=e,I=l;exports.ContextConsumer=h;exports.ContextProvider=z;exports.Element=A;exports.ForwardRef=B;exports.Fragment=C;exports.Lazy=D;exports.Memo=E;exports.Portal=F;exports.Profiler=G;exports.StrictMode=H;
|
||||
exports.Suspense=I;exports.isAsyncMode=function(){return!1};exports.isConcurrentMode=function(){return!1};exports.isContextConsumer=function(a){return y(a)===h};exports.isContextProvider=function(a){return y(a)===g};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===b};exports.isForwardRef=function(a){return y(a)===k};exports.isFragment=function(a){return y(a)===d};exports.isLazy=function(a){return y(a)===p};exports.isMemo=function(a){return y(a)===n};
|
||||
exports.isPortal=function(a){return y(a)===c};exports.isProfiler=function(a){return y(a)===f};exports.isStrictMode=function(a){return y(a)===e};exports.isSuspense=function(a){return y(a)===l};exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===f||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1};
|
||||
exports.typeOf=y;
|
||||
7
node_modules/react-redux/node_modules/react-is/index.js
generated
vendored
Normal file
7
node_modules/react-redux/node_modules/react-is/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-is.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-is.development.js');
|
||||
}
|
||||
27
node_modules/react-redux/node_modules/react-is/package.json
generated
vendored
Normal file
27
node_modules/react-redux/node_modules/react-is/package.json
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "react-is",
|
||||
"version": "17.0.2",
|
||||
"description": "Brand checking of React Elements.",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/react.git",
|
||||
"directory": "packages/react-is"
|
||||
},
|
||||
"keywords": [
|
||||
"react"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/facebook/react/issues"
|
||||
},
|
||||
"homepage": "https://reactjs.org/",
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"build-info.json",
|
||||
"index.js",
|
||||
"cjs/",
|
||||
"umd/"
|
||||
]
|
||||
}
|
||||
225
node_modules/react-redux/node_modules/react-is/umd/react-is.development.js
generated
vendored
Normal file
225
node_modules/react-redux/node_modules/react-is/umd/react-is.development.js
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
/** @license React v17.0.2
|
||||
* react-is.development.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global.ReactIs = {}));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var REACT_ELEMENT_TYPE = 0xeac7;
|
||||
var REACT_PORTAL_TYPE = 0xeaca;
|
||||
var REACT_FRAGMENT_TYPE = 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
||||
var REACT_PROFILER_TYPE = 0xead2;
|
||||
var REACT_PROVIDER_TYPE = 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = 0xeace;
|
||||
var REACT_FORWARD_REF_TYPE = 0xead0;
|
||||
var REACT_SUSPENSE_TYPE = 0xead1;
|
||||
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
||||
var REACT_MEMO_TYPE = 0xead3;
|
||||
var REACT_LAZY_TYPE = 0xead4;
|
||||
var REACT_BLOCK_TYPE = 0xead9;
|
||||
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
||||
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
||||
var REACT_SCOPE_TYPE = 0xead7;
|
||||
var REACT_OPAQUE_ID_TYPE = 0xeae0;
|
||||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
||||
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
||||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.for) {
|
||||
var symbolFor = Symbol.for;
|
||||
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
||||
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
||||
REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
|
||||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
||||
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
||||
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
||||
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
||||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
||||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
||||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
||||
REACT_MEMO_TYPE = symbolFor('react.memo');
|
||||
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
||||
REACT_BLOCK_TYPE = symbolFor('react.block');
|
||||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
||||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
||||
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
||||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
|
||||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
||||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
||||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
||||
}
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
||||
|
||||
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
||||
|
||||
function isValidElementType(type) {
|
||||
if (typeof type === 'string' || typeof type === 'function') {
|
||||
return true;
|
||||
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
||||
|
||||
|
||||
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function typeOf(object) {
|
||||
if (typeof object === 'object' && object !== null) {
|
||||
var $$typeof = object.$$typeof;
|
||||
|
||||
switch ($$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
var type = object.type;
|
||||
|
||||
switch (type) {
|
||||
case REACT_FRAGMENT_TYPE:
|
||||
case REACT_PROFILER_TYPE:
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return type;
|
||||
|
||||
default:
|
||||
var $$typeofType = type && type.$$typeof;
|
||||
|
||||
switch ($$typeofType) {
|
||||
case REACT_CONTEXT_TYPE:
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
case REACT_LAZY_TYPE:
|
||||
case REACT_MEMO_TYPE:
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return $$typeofType;
|
||||
|
||||
default:
|
||||
return $$typeof;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case REACT_PORTAL_TYPE:
|
||||
return $$typeof;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
var ContextConsumer = REACT_CONTEXT_TYPE;
|
||||
var ContextProvider = REACT_PROVIDER_TYPE;
|
||||
var Element = REACT_ELEMENT_TYPE;
|
||||
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
||||
var Fragment = REACT_FRAGMENT_TYPE;
|
||||
var Lazy = REACT_LAZY_TYPE;
|
||||
var Memo = REACT_MEMO_TYPE;
|
||||
var Portal = REACT_PORTAL_TYPE;
|
||||
var Profiler = REACT_PROFILER_TYPE;
|
||||
var StrictMode = REACT_STRICT_MODE_TYPE;
|
||||
var Suspense = REACT_SUSPENSE_TYPE;
|
||||
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
||||
var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
|
||||
|
||||
function isAsyncMode(object) {
|
||||
{
|
||||
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
||||
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
||||
|
||||
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
function isConcurrentMode(object) {
|
||||
{
|
||||
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
|
||||
hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
|
||||
|
||||
console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
function isContextConsumer(object) {
|
||||
return typeOf(object) === REACT_CONTEXT_TYPE;
|
||||
}
|
||||
function isContextProvider(object) {
|
||||
return typeOf(object) === REACT_PROVIDER_TYPE;
|
||||
}
|
||||
function isElement(object) {
|
||||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
function isForwardRef(object) {
|
||||
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
||||
}
|
||||
function isFragment(object) {
|
||||
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
||||
}
|
||||
function isLazy(object) {
|
||||
return typeOf(object) === REACT_LAZY_TYPE;
|
||||
}
|
||||
function isMemo(object) {
|
||||
return typeOf(object) === REACT_MEMO_TYPE;
|
||||
}
|
||||
function isPortal(object) {
|
||||
return typeOf(object) === REACT_PORTAL_TYPE;
|
||||
}
|
||||
function isProfiler(object) {
|
||||
return typeOf(object) === REACT_PROFILER_TYPE;
|
||||
}
|
||||
function isStrictMode(object) {
|
||||
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
||||
}
|
||||
function isSuspense(object) {
|
||||
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
||||
}
|
||||
|
||||
exports.ContextConsumer = ContextConsumer;
|
||||
exports.ContextProvider = ContextProvider;
|
||||
exports.Element = Element;
|
||||
exports.ForwardRef = ForwardRef;
|
||||
exports.Fragment = Fragment;
|
||||
exports.Lazy = Lazy;
|
||||
exports.Memo = Memo;
|
||||
exports.Portal = Portal;
|
||||
exports.Profiler = Profiler;
|
||||
exports.StrictMode = StrictMode;
|
||||
exports.Suspense = Suspense;
|
||||
exports.isAsyncMode = isAsyncMode;
|
||||
exports.isConcurrentMode = isConcurrentMode;
|
||||
exports.isContextConsumer = isContextConsumer;
|
||||
exports.isContextProvider = isContextProvider;
|
||||
exports.isElement = isElement;
|
||||
exports.isForwardRef = isForwardRef;
|
||||
exports.isFragment = isFragment;
|
||||
exports.isLazy = isLazy;
|
||||
exports.isMemo = isMemo;
|
||||
exports.isPortal = isPortal;
|
||||
exports.isProfiler = isProfiler;
|
||||
exports.isStrictMode = isStrictMode;
|
||||
exports.isSuspense = isSuspense;
|
||||
exports.isValidElementType = isValidElementType;
|
||||
exports.typeOf = typeOf;
|
||||
|
||||
})));
|
||||
14
node_modules/react-redux/node_modules/react-is/umd/react-is.production.min.js
generated
vendored
Normal file
14
node_modules/react-redux/node_modules/react-is/umd/react-is.production.min.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/** @license React v17.0.2
|
||||
* react-is.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
(function(){'use strict';(function(b,d){"object"===typeof exports&&"undefined"!==typeof module?d(exports):"function"===typeof define&&define.amd?define(["exports"],d):(b=b||self,d(b.ReactIs={}))})(this,function(b){function d(a){if("object"===typeof a&&null!==a){var b=a.$$typeof;switch(b){case q:switch(a=a.type,a){case e:case f:case g:case h:case t:return a;default:switch(a=a&&a.$$typeof,a){case k:case l:case m:case n:case p:return a;default:return b}}case r:return b}}}var q=60103,r=60106,e=60107,g=60108,f=60114,
|
||||
p=60109,k=60110,l=60112,h=60113,t=60120,n=60115,m=60116,u=60121,v=60122,w=60117,x=60129,y=60131;if("function"===typeof Symbol&&Symbol.for){var c=Symbol.for;q=c("react.element");r=c("react.portal");e=c("react.fragment");g=c("react.strict_mode");f=c("react.profiler");p=c("react.provider");k=c("react.context");l=c("react.forward_ref");h=c("react.suspense");t=c("react.suspense_list");n=c("react.memo");m=c("react.lazy");u=c("react.block");v=c("react.server.block");w=c("react.fundamental");x=c("react.debug_trace_mode");
|
||||
y=c("react.legacy_hidden")}b.ContextConsumer=k;b.ContextProvider=p;b.Element=q;b.ForwardRef=l;b.Fragment=e;b.Lazy=m;b.Memo=n;b.Portal=r;b.Profiler=f;b.StrictMode=g;b.Suspense=h;b.isAsyncMode=function(a){return!1};b.isConcurrentMode=function(a){return!1};b.isContextConsumer=function(a){return d(a)===k};b.isContextProvider=function(a){return d(a)===p};b.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===q};b.isForwardRef=function(a){return d(a)===l};b.isFragment=function(a){return d(a)===
|
||||
e};b.isLazy=function(a){return d(a)===m};b.isMemo=function(a){return d(a)===n};b.isPortal=function(a){return d(a)===r};b.isProfiler=function(a){return d(a)===f};b.isStrictMode=function(a){return d(a)===g};b.isSuspense=function(a){return d(a)===h};b.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===f||a===x||a===g||a===h||a===t||a===y||"object"===typeof a&&null!==a&&(a.$$typeof===m||a.$$typeof===n||a.$$typeof===p||a.$$typeof===k||a.$$typeof===l||a.$$typeof===
|
||||
w||a.$$typeof===u||a[0]===v)?!0:!1};b.typeOf=d});
|
||||
})();
|
||||
102
node_modules/react-redux/package.json
generated
vendored
Normal file
102
node_modules/react-redux/package.json
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"name": "react-redux",
|
||||
"version": "7.2.9",
|
||||
"description": "Official React bindings for Redux",
|
||||
"keywords": [
|
||||
"react",
|
||||
"reactjs",
|
||||
"redux"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": "Dan Abramov <dan.abramov@me.com> (https://github.com/gaearon)",
|
||||
"homepage": "https://github.com/reduxjs/react-redux",
|
||||
"repository": "github:reduxjs/react-redux",
|
||||
"bugs": "https://github.com/reduxjs/react-redux/issues",
|
||||
"main": "./lib/index.js",
|
||||
"unpkg": "dist/react-redux.js",
|
||||
"module": "es/index.js",
|
||||
"files": [
|
||||
"dist",
|
||||
"lib",
|
||||
"src",
|
||||
"es"
|
||||
],
|
||||
"scripts": {
|
||||
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
|
||||
"build:es": "babel src --out-dir es",
|
||||
"build:umd": "cross-env NODE_ENV=development rollup -c -o dist/react-redux.js",
|
||||
"build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/react-redux.min.js",
|
||||
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
|
||||
"clean": "rimraf lib dist es coverage",
|
||||
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" \"docs/**/*.md\"",
|
||||
"lint": "eslint src test/utils test/components test/hooks",
|
||||
"prepare": "npm run clean && npm run build",
|
||||
"pretest": "npm run lint",
|
||||
"test": "jest",
|
||||
"coverage": "codecov"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.3 || ^17 || ^18"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@types/react-redux": "^7.1.20",
|
||||
"hoist-non-react-statics": "^3.3.2",
|
||||
"loose-envify": "^1.4.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-is": "^17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.15.7",
|
||||
"@babel/core": "^7.15.8",
|
||||
"@babel/plugin-proposal-decorators": "^7.15.8",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.15.6",
|
||||
"@babel/plugin-transform-react-display-name": "^7.15.1",
|
||||
"@babel/plugin-transform-react-jsx": "^7.14.9",
|
||||
"@babel/plugin-transform-runtime": "^7.15.8",
|
||||
"@babel/preset-env": "^7.15.8",
|
||||
"@rollup/plugin-babel": "^5.3.0",
|
||||
"@rollup/plugin-commonjs": "^21.0.1",
|
||||
"@rollup/plugin-node-resolve": "^13.0.6",
|
||||
"@rollup/plugin-replace": "^3.0.0",
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/jest-native": "^4.0.2",
|
||||
"@testing-library/react": "^12.1.2",
|
||||
"@testing-library/react-hooks": "^7.0.2",
|
||||
"@testing-library/react-native": "^8.0.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^27.3.1",
|
||||
"codecov": "^3.8.3",
|
||||
"create-react-class": "^15.7.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"es3ify": "^0.2.2",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-plugin-react": "^7.26.1",
|
||||
"glob": "^7.2.0",
|
||||
"jest": "^27.3.1",
|
||||
"prettier": "^2.4.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-native": "^0.66.1",
|
||||
"react-test-renderer": "^17.0.2",
|
||||
"redux": "^4.1.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.58.3",
|
||||
"rollup-plugin-terser": "^7.0.2"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
"loose-envify"
|
||||
]
|
||||
}
|
||||
}
|
||||
9
node_modules/react-redux/src/alternate-renderers.js
generated
vendored
Normal file
9
node_modules/react-redux/src/alternate-renderers.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export * from './exports'
|
||||
|
||||
import { getBatch } from './utils/batch'
|
||||
|
||||
// For other renderers besides ReactDOM and React Native,
|
||||
// use the default noop batch function
|
||||
const batch = getBatch()
|
||||
|
||||
export { batch }
|
||||
9
node_modules/react-redux/src/components/Context.js
generated
vendored
Normal file
9
node_modules/react-redux/src/components/Context.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
export const ReactReduxContext = /*#__PURE__*/ React.createContext(null)
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ReactReduxContext.displayName = 'ReactRedux'
|
||||
}
|
||||
|
||||
export default ReactReduxContext
|
||||
49
node_modules/react-redux/src/components/Provider.js
generated
vendored
Normal file
49
node_modules/react-redux/src/components/Provider.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { ReactReduxContext } from './Context'
|
||||
import { createSubscription } from '../utils/Subscription'
|
||||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
|
||||
|
||||
function Provider({ store, context, children }) {
|
||||
const contextValue = useMemo(() => {
|
||||
const subscription = createSubscription(store)
|
||||
return {
|
||||
store,
|
||||
subscription,
|
||||
}
|
||||
}, [store])
|
||||
|
||||
const previousState = useMemo(() => store.getState(), [store])
|
||||
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
const { subscription } = contextValue
|
||||
subscription.onStateChange = subscription.notifyNestedSubs
|
||||
subscription.trySubscribe()
|
||||
|
||||
if (previousState !== store.getState()) {
|
||||
subscription.notifyNestedSubs()
|
||||
}
|
||||
return () => {
|
||||
subscription.tryUnsubscribe()
|
||||
subscription.onStateChange = null
|
||||
}
|
||||
}, [contextValue, previousState])
|
||||
|
||||
const Context = context || ReactReduxContext
|
||||
|
||||
return <Context.Provider value={contextValue}>{children}</Context.Provider>
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Provider.propTypes = {
|
||||
store: PropTypes.shape({
|
||||
subscribe: PropTypes.func.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
getState: PropTypes.func.isRequired,
|
||||
}),
|
||||
context: PropTypes.object,
|
||||
children: PropTypes.any,
|
||||
}
|
||||
}
|
||||
|
||||
export default Provider
|
||||
488
node_modules/react-redux/src/components/connectAdvanced.js
generated
vendored
Normal file
488
node_modules/react-redux/src/components/connectAdvanced.js
generated
vendored
Normal file
@@ -0,0 +1,488 @@
|
||||
import hoistStatics from 'hoist-non-react-statics'
|
||||
import React, { useContext, useMemo, useRef, useReducer } from 'react'
|
||||
import { isValidElementType, isContextConsumer } from 'react-is'
|
||||
import { createSubscription } from '../utils/Subscription'
|
||||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
|
||||
|
||||
import { ReactReduxContext } from './Context'
|
||||
|
||||
// Define some constant arrays just to avoid re-creating these
|
||||
const EMPTY_ARRAY = []
|
||||
const NO_SUBSCRIPTION_ARRAY = [null, null]
|
||||
|
||||
const stringifyComponent = (Comp) => {
|
||||
try {
|
||||
return JSON.stringify(Comp)
|
||||
} catch (err) {
|
||||
return String(Comp)
|
||||
}
|
||||
}
|
||||
|
||||
function storeStateUpdatesReducer(state, action) {
|
||||
const [, updateCount] = state
|
||||
return [action.payload, updateCount + 1]
|
||||
}
|
||||
|
||||
function useIsomorphicLayoutEffectWithArgs(
|
||||
effectFunc,
|
||||
effectArgs,
|
||||
dependencies
|
||||
) {
|
||||
useIsomorphicLayoutEffect(() => effectFunc(...effectArgs), dependencies)
|
||||
}
|
||||
|
||||
function captureWrapperProps(
|
||||
lastWrapperProps,
|
||||
lastChildProps,
|
||||
renderIsScheduled,
|
||||
wrapperProps,
|
||||
actualChildProps,
|
||||
childPropsFromStoreUpdate,
|
||||
notifyNestedSubs
|
||||
) {
|
||||
// We want to capture the wrapper props and child props we used for later comparisons
|
||||
lastWrapperProps.current = wrapperProps
|
||||
lastChildProps.current = actualChildProps
|
||||
renderIsScheduled.current = false
|
||||
|
||||
// If the render was from a store update, clear out that reference and cascade the subscriber update
|
||||
if (childPropsFromStoreUpdate.current) {
|
||||
childPropsFromStoreUpdate.current = null
|
||||
notifyNestedSubs()
|
||||
}
|
||||
}
|
||||
|
||||
function subscribeUpdates(
|
||||
shouldHandleStateChanges,
|
||||
store,
|
||||
subscription,
|
||||
childPropsSelector,
|
||||
lastWrapperProps,
|
||||
lastChildProps,
|
||||
renderIsScheduled,
|
||||
childPropsFromStoreUpdate,
|
||||
notifyNestedSubs,
|
||||
forceComponentUpdateDispatch
|
||||
) {
|
||||
// If we're not subscribed to the store, nothing to do here
|
||||
if (!shouldHandleStateChanges) return
|
||||
|
||||
// Capture values for checking if and when this component unmounts
|
||||
let didUnsubscribe = false
|
||||
let lastThrownError = null
|
||||
|
||||
// We'll run this callback every time a store subscription update propagates to this component
|
||||
const checkForUpdates = () => {
|
||||
if (didUnsubscribe) {
|
||||
// Don't run stale listeners.
|
||||
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
|
||||
return
|
||||
}
|
||||
|
||||
const latestStoreState = store.getState()
|
||||
|
||||
let newChildProps, error
|
||||
try {
|
||||
// Actually run the selector with the most recent store state and wrapper props
|
||||
// to determine what the child props should be
|
||||
newChildProps = childPropsSelector(
|
||||
latestStoreState,
|
||||
lastWrapperProps.current
|
||||
)
|
||||
} catch (e) {
|
||||
error = e
|
||||
lastThrownError = e
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
lastThrownError = null
|
||||
}
|
||||
|
||||
// If the child props haven't changed, nothing to do here - cascade the subscription update
|
||||
if (newChildProps === lastChildProps.current) {
|
||||
if (!renderIsScheduled.current) {
|
||||
notifyNestedSubs()
|
||||
}
|
||||
} else {
|
||||
// Save references to the new child props. Note that we track the "child props from store update"
|
||||
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
|
||||
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
|
||||
// forcing another re-render, which we don't want.
|
||||
lastChildProps.current = newChildProps
|
||||
childPropsFromStoreUpdate.current = newChildProps
|
||||
renderIsScheduled.current = true
|
||||
|
||||
// If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
|
||||
forceComponentUpdateDispatch({
|
||||
type: 'STORE_UPDATED',
|
||||
payload: {
|
||||
error,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Actually subscribe to the nearest connected ancestor (or store)
|
||||
subscription.onStateChange = checkForUpdates
|
||||
subscription.trySubscribe()
|
||||
|
||||
// Pull data from the store after first render in case the store has
|
||||
// changed since we began.
|
||||
checkForUpdates()
|
||||
|
||||
const unsubscribeWrapper = () => {
|
||||
didUnsubscribe = true
|
||||
subscription.tryUnsubscribe()
|
||||
subscription.onStateChange = null
|
||||
|
||||
if (lastThrownError) {
|
||||
// It's possible that we caught an error due to a bad mapState function, but the
|
||||
// parent re-rendered without this component and we're about to unmount.
|
||||
// This shouldn't happen as long as we do top-down subscriptions correctly, but
|
||||
// if we ever do those wrong, this throw will surface the error in our tests.
|
||||
// In that case, throw the error from here so it doesn't get lost.
|
||||
throw lastThrownError
|
||||
}
|
||||
}
|
||||
|
||||
return unsubscribeWrapper
|
||||
}
|
||||
|
||||
const initStateUpdates = () => [null, 0]
|
||||
|
||||
export default function connectAdvanced(
|
||||
/*
|
||||
selectorFactory is a func that is responsible for returning the selector function used to
|
||||
compute new props from state, props, and dispatch. For example:
|
||||
|
||||
export default connectAdvanced((dispatch, options) => (state, props) => ({
|
||||
thing: state.things[props.thingId],
|
||||
saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)),
|
||||
}))(YourComponent)
|
||||
|
||||
Access to dispatch is provided to the factory so selectorFactories can bind actionCreators
|
||||
outside of their selector as an optimization. Options passed to connectAdvanced are passed to
|
||||
the selectorFactory, along with displayName and WrappedComponent, as the second argument.
|
||||
|
||||
Note that selectorFactory is responsible for all caching/memoization of inbound and outbound
|
||||
props. Do not use connectAdvanced directly without memoizing results between calls to your
|
||||
selector, otherwise the Connect component will re-render on every state or props change.
|
||||
*/
|
||||
selectorFactory,
|
||||
// options object:
|
||||
{
|
||||
// the func used to compute this HOC's displayName from the wrapped component's displayName.
|
||||
// probably overridden by wrapper functions such as connect()
|
||||
getDisplayName = (name) => `ConnectAdvanced(${name})`,
|
||||
|
||||
// shown in error messages
|
||||
// probably overridden by wrapper functions such as connect()
|
||||
methodName = 'connectAdvanced',
|
||||
|
||||
// REMOVED: if defined, the name of the property passed to the wrapped element indicating the number of
|
||||
// calls to render. useful for watching in react devtools for unnecessary re-renders.
|
||||
renderCountProp = undefined,
|
||||
|
||||
// determines whether this HOC subscribes to store changes
|
||||
shouldHandleStateChanges = true,
|
||||
|
||||
// REMOVED: the key of props/context to get the store
|
||||
storeKey = 'store',
|
||||
|
||||
// REMOVED: expose the wrapped component via refs
|
||||
withRef = false,
|
||||
|
||||
// use React's forwardRef to expose a ref of the wrapped component
|
||||
forwardRef = false,
|
||||
|
||||
// the context consumer to use
|
||||
context = ReactReduxContext,
|
||||
|
||||
// additional options are passed through to the selectorFactory
|
||||
...connectOptions
|
||||
} = {}
|
||||
) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (renderCountProp !== undefined) {
|
||||
throw new Error(
|
||||
`renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension`
|
||||
)
|
||||
}
|
||||
if (withRef) {
|
||||
throw new Error(
|
||||
'withRef is removed. To access the wrapped instance, use a ref on the connected component'
|
||||
)
|
||||
}
|
||||
|
||||
const customStoreWarningMessage =
|
||||
'To use a custom Redux store for specific components, create a custom React context with ' +
|
||||
"React.createContext(), and pass the context object to React Redux's Provider and specific components" +
|
||||
' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' +
|
||||
'You may also pass a {context : MyContext} option to connect'
|
||||
|
||||
if (storeKey !== 'store') {
|
||||
throw new Error(
|
||||
'storeKey has been removed and does not do anything. ' +
|
||||
customStoreWarningMessage
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const Context = context
|
||||
|
||||
return function wrapWithConnect(WrappedComponent) {
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
!isValidElementType(WrappedComponent)
|
||||
) {
|
||||
throw new Error(
|
||||
`You must pass a component to the function returned by ` +
|
||||
`${methodName}. Instead received ${stringifyComponent(
|
||||
WrappedComponent
|
||||
)}`
|
||||
)
|
||||
}
|
||||
|
||||
const wrappedComponentName =
|
||||
WrappedComponent.displayName || WrappedComponent.name || 'Component'
|
||||
|
||||
const displayName = getDisplayName(wrappedComponentName)
|
||||
|
||||
const selectorFactoryOptions = {
|
||||
...connectOptions,
|
||||
getDisplayName,
|
||||
methodName,
|
||||
renderCountProp,
|
||||
shouldHandleStateChanges,
|
||||
storeKey,
|
||||
displayName,
|
||||
wrappedComponentName,
|
||||
WrappedComponent,
|
||||
}
|
||||
|
||||
const { pure } = connectOptions
|
||||
|
||||
function createChildSelector(store) {
|
||||
return selectorFactory(store.dispatch, selectorFactoryOptions)
|
||||
}
|
||||
|
||||
// If we aren't running in "pure" mode, we don't want to memoize values.
|
||||
// To avoid conditionally calling hooks, we fall back to a tiny wrapper
|
||||
// that just executes the given callback immediately.
|
||||
const usePureOnlyMemo = pure ? useMemo : (callback) => callback()
|
||||
|
||||
function ConnectFunction(props) {
|
||||
const [propsContext, reactReduxForwardedRef, wrapperProps] =
|
||||
useMemo(() => {
|
||||
// Distinguish between actual "data" props that were passed to the wrapper component,
|
||||
// and values needed to control behavior (forwarded refs, alternate context instances).
|
||||
// To maintain the wrapperProps object reference, memoize this destructuring.
|
||||
const { reactReduxForwardedRef, ...wrapperProps } = props
|
||||
return [props.context, reactReduxForwardedRef, wrapperProps]
|
||||
}, [props])
|
||||
|
||||
const ContextToUse = useMemo(() => {
|
||||
// Users may optionally pass in a custom context instance to use instead of our ReactReduxContext.
|
||||
// Memoize the check that determines which context instance we should use.
|
||||
return propsContext &&
|
||||
propsContext.Consumer &&
|
||||
isContextConsumer(<propsContext.Consumer />)
|
||||
? propsContext
|
||||
: Context
|
||||
}, [propsContext, Context])
|
||||
|
||||
// Retrieve the store and ancestor subscription via context, if available
|
||||
const contextValue = useContext(ContextToUse)
|
||||
|
||||
// The store _must_ exist as either a prop or in context.
|
||||
// We'll check to see if it _looks_ like a Redux store first.
|
||||
// This allows us to pass through a `store` prop that is just a plain value.
|
||||
const didStoreComeFromProps =
|
||||
Boolean(props.store) &&
|
||||
Boolean(props.store.getState) &&
|
||||
Boolean(props.store.dispatch)
|
||||
const didStoreComeFromContext =
|
||||
Boolean(contextValue) && Boolean(contextValue.store)
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
!didStoreComeFromProps &&
|
||||
!didStoreComeFromContext
|
||||
) {
|
||||
throw new Error(
|
||||
`Could not find "store" in the context of ` +
|
||||
`"${displayName}". Either wrap the root component in a <Provider>, ` +
|
||||
`or pass a custom React context provider to <Provider> and the corresponding ` +
|
||||
`React context consumer to ${displayName} in connect options.`
|
||||
)
|
||||
}
|
||||
|
||||
// Based on the previous check, one of these must be true
|
||||
const store = didStoreComeFromProps ? props.store : contextValue.store
|
||||
|
||||
const childPropsSelector = useMemo(() => {
|
||||
// The child props selector needs the store reference as an input.
|
||||
// Re-create this selector whenever the store changes.
|
||||
return createChildSelector(store)
|
||||
}, [store])
|
||||
|
||||
const [subscription, notifyNestedSubs] = useMemo(() => {
|
||||
if (!shouldHandleStateChanges) return NO_SUBSCRIPTION_ARRAY
|
||||
|
||||
// This Subscription's source should match where store came from: props vs. context. A component
|
||||
// connected to the store via props shouldn't use subscription from context, or vice versa.
|
||||
const subscription = createSubscription(
|
||||
store,
|
||||
didStoreComeFromProps ? null : contextValue.subscription
|
||||
)
|
||||
|
||||
// `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
|
||||
// the middle of the notification loop, where `subscription` will then be null. This can
|
||||
// probably be avoided if Subscription's listeners logic is changed to not call listeners
|
||||
// that have been unsubscribed in the middle of the notification loop.
|
||||
const notifyNestedSubs =
|
||||
subscription.notifyNestedSubs.bind(subscription)
|
||||
|
||||
return [subscription, notifyNestedSubs]
|
||||
}, [store, didStoreComeFromProps, contextValue])
|
||||
|
||||
// Determine what {store, subscription} value should be put into nested context, if necessary,
|
||||
// and memoize that value to avoid unnecessary context updates.
|
||||
const overriddenContextValue = useMemo(() => {
|
||||
if (didStoreComeFromProps) {
|
||||
// This component is directly subscribed to a store from props.
|
||||
// We don't want descendants reading from this store - pass down whatever
|
||||
// the existing context value is from the nearest connected ancestor.
|
||||
return contextValue
|
||||
}
|
||||
|
||||
// Otherwise, put this component's subscription instance into context, so that
|
||||
// connected descendants won't update until after this component is done
|
||||
return {
|
||||
...contextValue,
|
||||
subscription,
|
||||
}
|
||||
}, [didStoreComeFromProps, contextValue, subscription])
|
||||
|
||||
// We need to force this wrapper component to re-render whenever a Redux store update
|
||||
// causes a change to the calculated child component props (or we caught an error in mapState)
|
||||
const [[previousStateUpdateResult], forceComponentUpdateDispatch] =
|
||||
useReducer(storeStateUpdatesReducer, EMPTY_ARRAY, initStateUpdates)
|
||||
|
||||
// Propagate any mapState/mapDispatch errors upwards
|
||||
if (previousStateUpdateResult && previousStateUpdateResult.error) {
|
||||
throw previousStateUpdateResult.error
|
||||
}
|
||||
|
||||
// Set up refs to coordinate values between the subscription effect and the render logic
|
||||
const lastChildProps = useRef()
|
||||
const lastWrapperProps = useRef(wrapperProps)
|
||||
const childPropsFromStoreUpdate = useRef()
|
||||
const renderIsScheduled = useRef(false)
|
||||
|
||||
const actualChildProps = usePureOnlyMemo(() => {
|
||||
// Tricky logic here:
|
||||
// - This render may have been triggered by a Redux store update that produced new child props
|
||||
// - However, we may have gotten new wrapper props after that
|
||||
// If we have new child props, and the same wrapper props, we know we should use the new child props as-is.
|
||||
// But, if we have new wrapper props, those might change the child props, so we have to recalculate things.
|
||||
// So, we'll use the child props from store update only if the wrapper props are the same as last time.
|
||||
if (
|
||||
childPropsFromStoreUpdate.current &&
|
||||
wrapperProps === lastWrapperProps.current
|
||||
) {
|
||||
return childPropsFromStoreUpdate.current
|
||||
}
|
||||
|
||||
// TODO We're reading the store directly in render() here. Bad idea?
|
||||
// This will likely cause Bad Things (TM) to happen in Concurrent Mode.
|
||||
// Note that we do this because on renders _not_ caused by store updates, we need the latest store state
|
||||
// to determine what the child props should be.
|
||||
return childPropsSelector(store.getState(), wrapperProps)
|
||||
}, [store, previousStateUpdateResult, wrapperProps])
|
||||
|
||||
// We need this to execute synchronously every time we re-render. However, React warns
|
||||
// about useLayoutEffect in SSR, so we try to detect environment and fall back to
|
||||
// just useEffect instead to avoid the warning, since neither will run anyway.
|
||||
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [
|
||||
lastWrapperProps,
|
||||
lastChildProps,
|
||||
renderIsScheduled,
|
||||
wrapperProps,
|
||||
actualChildProps,
|
||||
childPropsFromStoreUpdate,
|
||||
notifyNestedSubs,
|
||||
])
|
||||
|
||||
// Our re-subscribe logic only runs when the store/subscription setup changes
|
||||
useIsomorphicLayoutEffectWithArgs(
|
||||
subscribeUpdates,
|
||||
[
|
||||
shouldHandleStateChanges,
|
||||
store,
|
||||
subscription,
|
||||
childPropsSelector,
|
||||
lastWrapperProps,
|
||||
lastChildProps,
|
||||
renderIsScheduled,
|
||||
childPropsFromStoreUpdate,
|
||||
notifyNestedSubs,
|
||||
forceComponentUpdateDispatch,
|
||||
],
|
||||
[store, subscription, childPropsSelector]
|
||||
)
|
||||
|
||||
// Now that all that's done, we can finally try to actually render the child component.
|
||||
// We memoize the elements for the rendered child component as an optimization.
|
||||
const renderedWrappedComponent = useMemo(
|
||||
() => (
|
||||
<WrappedComponent
|
||||
{...actualChildProps}
|
||||
ref={reactReduxForwardedRef}
|
||||
/>
|
||||
),
|
||||
[reactReduxForwardedRef, WrappedComponent, actualChildProps]
|
||||
)
|
||||
|
||||
// If React sees the exact same element reference as last time, it bails out of re-rendering
|
||||
// that child, same as if it was wrapped in React.memo() or returned false from shouldComponentUpdate.
|
||||
const renderedChild = useMemo(() => {
|
||||
if (shouldHandleStateChanges) {
|
||||
// If this component is subscribed to store updates, we need to pass its own
|
||||
// subscription instance down to our descendants. That means rendering the same
|
||||
// Context instance, and putting a different value into the context.
|
||||
return (
|
||||
<ContextToUse.Provider value={overriddenContextValue}>
|
||||
{renderedWrappedComponent}
|
||||
</ContextToUse.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
return renderedWrappedComponent
|
||||
}, [ContextToUse, renderedWrappedComponent, overriddenContextValue])
|
||||
|
||||
return renderedChild
|
||||
}
|
||||
|
||||
// If we're in "pure" mode, ensure our wrapper component only re-renders when incoming props have changed.
|
||||
const Connect = pure ? React.memo(ConnectFunction) : ConnectFunction
|
||||
|
||||
Connect.WrappedComponent = WrappedComponent
|
||||
Connect.displayName = ConnectFunction.displayName = displayName
|
||||
|
||||
if (forwardRef) {
|
||||
const forwarded = React.forwardRef(function forwardConnectRef(
|
||||
props,
|
||||
ref
|
||||
) {
|
||||
return <Connect {...props} reactReduxForwardedRef={ref} />
|
||||
})
|
||||
|
||||
forwarded.displayName = displayName
|
||||
forwarded.WrappedComponent = WrappedComponent
|
||||
return hoistStatics(forwarded, WrappedComponent)
|
||||
}
|
||||
|
||||
return hoistStatics(Connect, WrappedComponent)
|
||||
}
|
||||
}
|
||||
104
node_modules/react-redux/src/connect/connect.js
generated
vendored
Normal file
104
node_modules/react-redux/src/connect/connect.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import connectAdvanced from '../components/connectAdvanced'
|
||||
import shallowEqual from '../utils/shallowEqual'
|
||||
import defaultMapDispatchToPropsFactories from './mapDispatchToProps'
|
||||
import defaultMapStateToPropsFactories from './mapStateToProps'
|
||||
import defaultMergePropsFactories from './mergeProps'
|
||||
import defaultSelectorFactory from './selectorFactory'
|
||||
|
||||
/*
|
||||
connect is a facade over connectAdvanced. It turns its args into a compatible
|
||||
selectorFactory, which has the signature:
|
||||
|
||||
(dispatch, options) => (nextState, nextOwnProps) => nextFinalProps
|
||||
|
||||
connect passes its args to connectAdvanced as options, which will in turn pass them to
|
||||
selectorFactory each time a Connect component instance is instantiated or hot reloaded.
|
||||
|
||||
selectorFactory returns a final props selector from its mapStateToProps,
|
||||
mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps,
|
||||
mergePropsFactories, and pure args.
|
||||
|
||||
The resulting final props selector is called by the Connect component instance whenever
|
||||
it receives new props or store state.
|
||||
*/
|
||||
|
||||
function match(arg, factories, name) {
|
||||
for (let i = factories.length - 1; i >= 0; i--) {
|
||||
const result = factories[i](arg)
|
||||
if (result) return result
|
||||
}
|
||||
|
||||
return (dispatch, options) => {
|
||||
throw new Error(
|
||||
`Invalid value of type ${typeof arg} for ${name} argument when connecting component ${
|
||||
options.wrappedComponentName
|
||||
}.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function strictEqual(a, b) {
|
||||
return a === b
|
||||
}
|
||||
|
||||
// createConnect with default args builds the 'official' connect behavior. Calling it with
|
||||
// different options opens up some testing and extensibility scenarios
|
||||
export function createConnect({
|
||||
connectHOC = connectAdvanced,
|
||||
mapStateToPropsFactories = defaultMapStateToPropsFactories,
|
||||
mapDispatchToPropsFactories = defaultMapDispatchToPropsFactories,
|
||||
mergePropsFactories = defaultMergePropsFactories,
|
||||
selectorFactory = defaultSelectorFactory,
|
||||
} = {}) {
|
||||
return function connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
mergeProps,
|
||||
{
|
||||
pure = true,
|
||||
areStatesEqual = strictEqual,
|
||||
areOwnPropsEqual = shallowEqual,
|
||||
areStatePropsEqual = shallowEqual,
|
||||
areMergedPropsEqual = shallowEqual,
|
||||
...extraOptions
|
||||
} = {}
|
||||
) {
|
||||
const initMapStateToProps = match(
|
||||
mapStateToProps,
|
||||
mapStateToPropsFactories,
|
||||
'mapStateToProps'
|
||||
)
|
||||
const initMapDispatchToProps = match(
|
||||
mapDispatchToProps,
|
||||
mapDispatchToPropsFactories,
|
||||
'mapDispatchToProps'
|
||||
)
|
||||
const initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps')
|
||||
|
||||
return connectHOC(selectorFactory, {
|
||||
// used in error messages
|
||||
methodName: 'connect',
|
||||
|
||||
// used to compute Connect's displayName from the wrapped component's displayName.
|
||||
getDisplayName: (name) => `Connect(${name})`,
|
||||
|
||||
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
|
||||
shouldHandleStateChanges: Boolean(mapStateToProps),
|
||||
|
||||
// passed through to selectorFactory
|
||||
initMapStateToProps,
|
||||
initMapDispatchToProps,
|
||||
initMergeProps,
|
||||
pure,
|
||||
areStatesEqual,
|
||||
areOwnPropsEqual,
|
||||
areStatePropsEqual,
|
||||
areMergedPropsEqual,
|
||||
|
||||
// any extra options args can override defaults of connect or connectAdvanced
|
||||
...extraOptions,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default /*#__PURE__*/ createConnect()
|
||||
28
node_modules/react-redux/src/connect/mapDispatchToProps.js
generated
vendored
Normal file
28
node_modules/react-redux/src/connect/mapDispatchToProps.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import bindActionCreators from '../utils/bindActionCreators'
|
||||
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps'
|
||||
|
||||
export function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
|
||||
return typeof mapDispatchToProps === 'function'
|
||||
? wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps')
|
||||
: undefined
|
||||
}
|
||||
|
||||
export function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
|
||||
return !mapDispatchToProps
|
||||
? wrapMapToPropsConstant((dispatch) => ({ dispatch }))
|
||||
: undefined
|
||||
}
|
||||
|
||||
export function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
|
||||
return mapDispatchToProps && typeof mapDispatchToProps === 'object'
|
||||
? wrapMapToPropsConstant((dispatch) =>
|
||||
bindActionCreators(mapDispatchToProps, dispatch)
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
|
||||
export default [
|
||||
whenMapDispatchToPropsIsFunction,
|
||||
whenMapDispatchToPropsIsMissing,
|
||||
whenMapDispatchToPropsIsObject,
|
||||
]
|
||||
13
node_modules/react-redux/src/connect/mapStateToProps.js
generated
vendored
Normal file
13
node_modules/react-redux/src/connect/mapStateToProps.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps'
|
||||
|
||||
export function whenMapStateToPropsIsFunction(mapStateToProps) {
|
||||
return typeof mapStateToProps === 'function'
|
||||
? wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps')
|
||||
: undefined
|
||||
}
|
||||
|
||||
export function whenMapStateToPropsIsMissing(mapStateToProps) {
|
||||
return !mapStateToProps ? wrapMapToPropsConstant(() => ({})) : undefined
|
||||
}
|
||||
|
||||
export default [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing]
|
||||
44
node_modules/react-redux/src/connect/mergeProps.js
generated
vendored
Normal file
44
node_modules/react-redux/src/connect/mergeProps.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import verifyPlainObject from '../utils/verifyPlainObject'
|
||||
|
||||
export function defaultMergeProps(stateProps, dispatchProps, ownProps) {
|
||||
return { ...ownProps, ...stateProps, ...dispatchProps }
|
||||
}
|
||||
|
||||
export function wrapMergePropsFunc(mergeProps) {
|
||||
return function initMergePropsProxy(
|
||||
dispatch,
|
||||
{ displayName, pure, areMergedPropsEqual }
|
||||
) {
|
||||
let hasRunOnce = false
|
||||
let mergedProps
|
||||
|
||||
return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
|
||||
const nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps)
|
||||
|
||||
if (hasRunOnce) {
|
||||
if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps))
|
||||
mergedProps = nextMergedProps
|
||||
} else {
|
||||
hasRunOnce = true
|
||||
mergedProps = nextMergedProps
|
||||
|
||||
if (process.env.NODE_ENV !== 'production')
|
||||
verifyPlainObject(mergedProps, displayName, 'mergeProps')
|
||||
}
|
||||
|
||||
return mergedProps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function whenMergePropsIsFunction(mergeProps) {
|
||||
return typeof mergeProps === 'function'
|
||||
? wrapMergePropsFunc(mergeProps)
|
||||
: undefined
|
||||
}
|
||||
|
||||
export function whenMergePropsIsOmitted(mergeProps) {
|
||||
return !mergeProps ? () => defaultMergeProps : undefined
|
||||
}
|
||||
|
||||
export default [whenMergePropsIsFunction, whenMergePropsIsOmitted]
|
||||
128
node_modules/react-redux/src/connect/selectorFactory.js
generated
vendored
Normal file
128
node_modules/react-redux/src/connect/selectorFactory.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
import verifySubselectors from './verifySubselectors'
|
||||
|
||||
export function impureFinalPropsSelectorFactory(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
mergeProps,
|
||||
dispatch
|
||||
) {
|
||||
return function impureFinalPropsSelector(state, ownProps) {
|
||||
return mergeProps(
|
||||
mapStateToProps(state, ownProps),
|
||||
mapDispatchToProps(dispatch, ownProps),
|
||||
ownProps
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export function pureFinalPropsSelectorFactory(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
mergeProps,
|
||||
dispatch,
|
||||
{ areStatesEqual, areOwnPropsEqual, areStatePropsEqual }
|
||||
) {
|
||||
let hasRunAtLeastOnce = false
|
||||
let state
|
||||
let ownProps
|
||||
let stateProps
|
||||
let dispatchProps
|
||||
let mergedProps
|
||||
|
||||
function handleFirstCall(firstState, firstOwnProps) {
|
||||
state = firstState
|
||||
ownProps = firstOwnProps
|
||||
stateProps = mapStateToProps(state, ownProps)
|
||||
dispatchProps = mapDispatchToProps(dispatch, ownProps)
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps)
|
||||
hasRunAtLeastOnce = true
|
||||
return mergedProps
|
||||
}
|
||||
|
||||
function handleNewPropsAndNewState() {
|
||||
stateProps = mapStateToProps(state, ownProps)
|
||||
|
||||
if (mapDispatchToProps.dependsOnOwnProps)
|
||||
dispatchProps = mapDispatchToProps(dispatch, ownProps)
|
||||
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps)
|
||||
return mergedProps
|
||||
}
|
||||
|
||||
function handleNewProps() {
|
||||
if (mapStateToProps.dependsOnOwnProps)
|
||||
stateProps = mapStateToProps(state, ownProps)
|
||||
|
||||
if (mapDispatchToProps.dependsOnOwnProps)
|
||||
dispatchProps = mapDispatchToProps(dispatch, ownProps)
|
||||
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps)
|
||||
return mergedProps
|
||||
}
|
||||
|
||||
function handleNewState() {
|
||||
const nextStateProps = mapStateToProps(state, ownProps)
|
||||
const statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps)
|
||||
stateProps = nextStateProps
|
||||
|
||||
if (statePropsChanged)
|
||||
mergedProps = mergeProps(stateProps, dispatchProps, ownProps)
|
||||
|
||||
return mergedProps
|
||||
}
|
||||
|
||||
function handleSubsequentCalls(nextState, nextOwnProps) {
|
||||
const propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps)
|
||||
const stateChanged = !areStatesEqual(nextState, state, nextOwnProps, ownProps)
|
||||
state = nextState
|
||||
ownProps = nextOwnProps
|
||||
|
||||
if (propsChanged && stateChanged) return handleNewPropsAndNewState()
|
||||
if (propsChanged) return handleNewProps()
|
||||
if (stateChanged) return handleNewState()
|
||||
return mergedProps
|
||||
}
|
||||
|
||||
return function pureFinalPropsSelector(nextState, nextOwnProps) {
|
||||
return hasRunAtLeastOnce
|
||||
? handleSubsequentCalls(nextState, nextOwnProps)
|
||||
: handleFirstCall(nextState, nextOwnProps)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add more comments
|
||||
|
||||
// If pure is true, the selector returned by selectorFactory will memoize its results,
|
||||
// allowing connectAdvanced's shouldComponentUpdate to return false if final
|
||||
// props have not changed. If false, the selector will always return a new
|
||||
// object and shouldComponentUpdate will always return true.
|
||||
|
||||
export default function finalPropsSelectorFactory(
|
||||
dispatch,
|
||||
{ initMapStateToProps, initMapDispatchToProps, initMergeProps, ...options }
|
||||
) {
|
||||
const mapStateToProps = initMapStateToProps(dispatch, options)
|
||||
const mapDispatchToProps = initMapDispatchToProps(dispatch, options)
|
||||
const mergeProps = initMergeProps(dispatch, options)
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
verifySubselectors(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
mergeProps,
|
||||
options.displayName
|
||||
)
|
||||
}
|
||||
|
||||
const selectorFactory = options.pure
|
||||
? pureFinalPropsSelectorFactory
|
||||
: impureFinalPropsSelectorFactory
|
||||
|
||||
return selectorFactory(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
mergeProps,
|
||||
dispatch,
|
||||
options
|
||||
)
|
||||
}
|
||||
27
node_modules/react-redux/src/connect/verifySubselectors.js
generated
vendored
Normal file
27
node_modules/react-redux/src/connect/verifySubselectors.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import warning from '../utils/warning'
|
||||
|
||||
function verify(selector, methodName, displayName) {
|
||||
if (!selector) {
|
||||
throw new Error(`Unexpected value for ${methodName} in ${displayName}.`)
|
||||
} else if (
|
||||
methodName === 'mapStateToProps' ||
|
||||
methodName === 'mapDispatchToProps'
|
||||
) {
|
||||
if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
|
||||
warning(
|
||||
`The selector for ${methodName} of ${displayName} did not specify a value for dependsOnOwnProps.`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function verifySubselectors(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
mergeProps,
|
||||
displayName
|
||||
) {
|
||||
verify(mapStateToProps, 'mapStateToProps', displayName)
|
||||
verify(mapDispatchToProps, 'mapDispatchToProps', displayName)
|
||||
verify(mergeProps, 'mergeProps', displayName)
|
||||
}
|
||||
74
node_modules/react-redux/src/connect/wrapMapToProps.js
generated
vendored
Normal file
74
node_modules/react-redux/src/connect/wrapMapToProps.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
import verifyPlainObject from '../utils/verifyPlainObject'
|
||||
|
||||
export function wrapMapToPropsConstant(getConstant) {
|
||||
return function initConstantSelector(dispatch, options) {
|
||||
const constant = getConstant(dispatch, options)
|
||||
|
||||
function constantSelector() {
|
||||
return constant
|
||||
}
|
||||
constantSelector.dependsOnOwnProps = false
|
||||
return constantSelector
|
||||
}
|
||||
}
|
||||
|
||||
// dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args
|
||||
// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine
|
||||
// whether mapToProps needs to be invoked when props have changed.
|
||||
//
|
||||
// A length of one signals that mapToProps does not depend on props from the parent component.
|
||||
// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and
|
||||
// therefore not reporting its length accurately..
|
||||
export function getDependsOnOwnProps(mapToProps) {
|
||||
return mapToProps.dependsOnOwnProps !== null &&
|
||||
mapToProps.dependsOnOwnProps !== undefined
|
||||
? Boolean(mapToProps.dependsOnOwnProps)
|
||||
: mapToProps.length !== 1
|
||||
}
|
||||
|
||||
// Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
|
||||
// this function wraps mapToProps in a proxy function which does several things:
|
||||
//
|
||||
// * Detects whether the mapToProps function being called depends on props, which
|
||||
// is used by selectorFactory to decide if it should reinvoke on props changes.
|
||||
//
|
||||
// * On first call, handles mapToProps if returns another function, and treats that
|
||||
// new function as the true mapToProps for subsequent calls.
|
||||
//
|
||||
// * On first call, verifies the first result is a plain object, in order to warn
|
||||
// the developer that their mapToProps function is not returning a valid result.
|
||||
//
|
||||
export function wrapMapToPropsFunc(mapToProps, methodName) {
|
||||
return function initProxySelector(dispatch, { displayName }) {
|
||||
const proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
|
||||
return proxy.dependsOnOwnProps
|
||||
? proxy.mapToProps(stateOrDispatch, ownProps)
|
||||
: proxy.mapToProps(stateOrDispatch)
|
||||
}
|
||||
|
||||
// allow detectFactoryAndVerify to get ownProps
|
||||
proxy.dependsOnOwnProps = true
|
||||
|
||||
proxy.mapToProps = function detectFactoryAndVerify(
|
||||
stateOrDispatch,
|
||||
ownProps
|
||||
) {
|
||||
proxy.mapToProps = mapToProps
|
||||
proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps)
|
||||
let props = proxy(stateOrDispatch, ownProps)
|
||||
|
||||
if (typeof props === 'function') {
|
||||
proxy.mapToProps = props
|
||||
proxy.dependsOnOwnProps = getDependsOnOwnProps(props)
|
||||
props = proxy(stateOrDispatch, ownProps)
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production')
|
||||
verifyPlainObject(props, displayName, methodName)
|
||||
|
||||
return props
|
||||
}
|
||||
|
||||
return proxy
|
||||
}
|
||||
}
|
||||
24
node_modules/react-redux/src/exports.js
generated
vendored
Normal file
24
node_modules/react-redux/src/exports.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import Provider from './components/Provider'
|
||||
import connectAdvanced from './components/connectAdvanced'
|
||||
import { ReactReduxContext } from './components/Context'
|
||||
import connect from './connect/connect'
|
||||
|
||||
import { useDispatch, createDispatchHook } from './hooks/useDispatch'
|
||||
import { useSelector, createSelectorHook } from './hooks/useSelector'
|
||||
import { useStore, createStoreHook } from './hooks/useStore'
|
||||
|
||||
import shallowEqual from './utils/shallowEqual'
|
||||
|
||||
export {
|
||||
Provider,
|
||||
connectAdvanced,
|
||||
ReactReduxContext,
|
||||
connect,
|
||||
useDispatch,
|
||||
createDispatchHook,
|
||||
useSelector,
|
||||
createSelectorHook,
|
||||
useStore,
|
||||
createStoreHook,
|
||||
shallowEqual,
|
||||
}
|
||||
41
node_modules/react-redux/src/hooks/useDispatch.js
generated
vendored
Normal file
41
node_modules/react-redux/src/hooks/useDispatch.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import { ReactReduxContext } from '../components/Context'
|
||||
import { useStore as useDefaultStore, createStoreHook } from './useStore'
|
||||
|
||||
/**
|
||||
* Hook factory, which creates a `useDispatch` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useDispatch` hook bound to the specified context.
|
||||
*/
|
||||
export function createDispatchHook(context = ReactReduxContext) {
|
||||
const useStore =
|
||||
context === ReactReduxContext ? useDefaultStore : createStoreHook(context)
|
||||
|
||||
return function useDispatch() {
|
||||
const store = useStore()
|
||||
return store.dispatch
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook to access the redux `dispatch` function.
|
||||
*
|
||||
* @returns {any|function} redux store's `dispatch` function
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React, { useCallback } from 'react'
|
||||
* import { useDispatch } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = ({ value }) => {
|
||||
* const dispatch = useDispatch()
|
||||
* const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
|
||||
* return (
|
||||
* <div>
|
||||
* <span>{value}</span>
|
||||
* <button onClick={increaseCounter}>Increase counter</button>
|
||||
* </div>
|
||||
* )
|
||||
* }
|
||||
*/
|
||||
export const useDispatch = /*#__PURE__*/ createDispatchHook()
|
||||
30
node_modules/react-redux/src/hooks/useReduxContext.js
generated
vendored
Normal file
30
node_modules/react-redux/src/hooks/useReduxContext.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useContext } from 'react'
|
||||
import { ReactReduxContext } from '../components/Context'
|
||||
|
||||
/**
|
||||
* A hook to access the value of the `ReactReduxContext`. This is a low-level
|
||||
* hook that you should usually not need to call directly.
|
||||
*
|
||||
* @returns {any} the value of the `ReactReduxContext`
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useReduxContext } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = ({ value }) => {
|
||||
* const { store } = useReduxContext()
|
||||
* return <div>{store.getState()}</div>
|
||||
* }
|
||||
*/
|
||||
export function useReduxContext() {
|
||||
const contextValue = useContext(ReactReduxContext)
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !contextValue) {
|
||||
throw new Error(
|
||||
'could not find react-redux context value; please ensure the component is wrapped in a <Provider>'
|
||||
)
|
||||
}
|
||||
|
||||
return contextValue
|
||||
}
|
||||
166
node_modules/react-redux/src/hooks/useSelector.js
generated
vendored
Normal file
166
node_modules/react-redux/src/hooks/useSelector.js
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
import { useReducer, useRef, useMemo, useContext, useDebugValue } from 'react'
|
||||
import { useReduxContext as useDefaultReduxContext } from './useReduxContext'
|
||||
import { createSubscription } from '../utils/Subscription'
|
||||
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
|
||||
import { ReactReduxContext } from '../components/Context'
|
||||
|
||||
const refEquality = (a, b) => a === b
|
||||
|
||||
function useSelectorWithStoreAndSubscription(
|
||||
selector,
|
||||
equalityFn,
|
||||
store,
|
||||
contextSub
|
||||
) {
|
||||
const [, forceRender] = useReducer((s) => s + 1, 0)
|
||||
|
||||
const subscription = useMemo(
|
||||
() => createSubscription(store, contextSub),
|
||||
[store, contextSub]
|
||||
)
|
||||
|
||||
const latestSubscriptionCallbackError = useRef()
|
||||
const latestSelector = useRef()
|
||||
const latestStoreState = useRef()
|
||||
const latestSelectedState = useRef()
|
||||
|
||||
const storeState = store.getState()
|
||||
let selectedState
|
||||
|
||||
try {
|
||||
if (
|
||||
selector !== latestSelector.current ||
|
||||
storeState !== latestStoreState.current ||
|
||||
latestSubscriptionCallbackError.current
|
||||
) {
|
||||
const newSelectedState = selector(storeState)
|
||||
// ensure latest selected state is reused so that a custom equality function can result in identical references
|
||||
if (
|
||||
latestSelectedState.current === undefined ||
|
||||
!equalityFn(newSelectedState, latestSelectedState.current)
|
||||
) {
|
||||
selectedState = newSelectedState
|
||||
} else {
|
||||
selectedState = latestSelectedState.current
|
||||
}
|
||||
} else {
|
||||
selectedState = latestSelectedState.current
|
||||
}
|
||||
} catch (err) {
|
||||
if (latestSubscriptionCallbackError.current) {
|
||||
err.message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
latestSelector.current = selector
|
||||
latestStoreState.current = storeState
|
||||
latestSelectedState.current = selectedState
|
||||
latestSubscriptionCallbackError.current = undefined
|
||||
})
|
||||
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
function checkForUpdates() {
|
||||
try {
|
||||
const newStoreState = store.getState()
|
||||
// Avoid calling selector multiple times if the store's state has not changed
|
||||
if (newStoreState === latestStoreState.current) {
|
||||
return
|
||||
}
|
||||
|
||||
const newSelectedState = latestSelector.current(newStoreState)
|
||||
|
||||
if (equalityFn(newSelectedState, latestSelectedState.current)) {
|
||||
return
|
||||
}
|
||||
|
||||
latestSelectedState.current = newSelectedState
|
||||
latestStoreState.current = newStoreState
|
||||
} catch (err) {
|
||||
// we ignore all errors here, since when the component
|
||||
// is re-rendered, the selectors are called again, and
|
||||
// will throw again, if neither props nor store state
|
||||
// changed
|
||||
latestSubscriptionCallbackError.current = err
|
||||
}
|
||||
|
||||
forceRender()
|
||||
}
|
||||
|
||||
subscription.onStateChange = checkForUpdates
|
||||
subscription.trySubscribe()
|
||||
|
||||
checkForUpdates()
|
||||
|
||||
return () => subscription.tryUnsubscribe()
|
||||
}, [store, subscription])
|
||||
|
||||
return selectedState
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook factory, which creates a `useSelector` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useSelector` hook bound to the specified context.
|
||||
*/
|
||||
export function createSelectorHook(context = ReactReduxContext) {
|
||||
const useReduxContext =
|
||||
context === ReactReduxContext
|
||||
? useDefaultReduxContext
|
||||
: () => useContext(context)
|
||||
return function useSelector(selector, equalityFn = refEquality) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!selector) {
|
||||
throw new Error(`You must pass a selector to useSelector`)
|
||||
}
|
||||
if (typeof selector !== 'function') {
|
||||
throw new Error(`You must pass a function as a selector to useSelector`)
|
||||
}
|
||||
if (typeof equalityFn !== 'function') {
|
||||
throw new Error(
|
||||
`You must pass a function as an equality function to useSelector`
|
||||
)
|
||||
}
|
||||
}
|
||||
const { store, subscription: contextSub } = useReduxContext()
|
||||
|
||||
const selectedState = useSelectorWithStoreAndSubscription(
|
||||
selector,
|
||||
equalityFn,
|
||||
store,
|
||||
contextSub
|
||||
)
|
||||
|
||||
useDebugValue(selectedState)
|
||||
|
||||
return selectedState
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook to access the redux store's state. This hook takes a selector function
|
||||
* as an argument. The selector is called with the store state.
|
||||
*
|
||||
* This hook takes an optional equality comparison function as the second parameter
|
||||
* that allows you to customize the way the selected state is compared to determine
|
||||
* whether the component needs to be re-rendered.
|
||||
*
|
||||
* @param {Function} selector the selector function
|
||||
* @param {Function=} equalityFn the function that will be used to determine equality
|
||||
*
|
||||
* @returns {any} the selected state
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useSelector } from 'react-redux'
|
||||
*
|
||||
* export const CounterComponent = () => {
|
||||
* const counter = useSelector(state => state.counter)
|
||||
* return <div>{counter}</div>
|
||||
* }
|
||||
*/
|
||||
export const useSelector = /*#__PURE__*/ createSelectorHook()
|
||||
37
node_modules/react-redux/src/hooks/useStore.js
generated
vendored
Normal file
37
node_modules/react-redux/src/hooks/useStore.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useContext } from 'react'
|
||||
import { ReactReduxContext } from '../components/Context'
|
||||
import { useReduxContext as useDefaultReduxContext } from './useReduxContext'
|
||||
|
||||
/**
|
||||
* Hook factory, which creates a `useStore` hook bound to a given context.
|
||||
*
|
||||
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
||||
* @returns {Function} A `useStore` hook bound to the specified context.
|
||||
*/
|
||||
export function createStoreHook(context = ReactReduxContext) {
|
||||
const useReduxContext =
|
||||
context === ReactReduxContext
|
||||
? useDefaultReduxContext
|
||||
: () => useContext(context)
|
||||
return function useStore() {
|
||||
const { store } = useReduxContext()
|
||||
return store
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook to access the redux store.
|
||||
*
|
||||
* @returns {any} the redux store
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* import React from 'react'
|
||||
* import { useStore } from 'react-redux'
|
||||
*
|
||||
* export const ExampleComponent = () => {
|
||||
* const store = useStore()
|
||||
* return <div>{store.getState()}</div>
|
||||
* }
|
||||
*/
|
||||
export const useStore = /*#__PURE__*/ createStoreHook()
|
||||
10
node_modules/react-redux/src/index.js
generated
vendored
Normal file
10
node_modules/react-redux/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export * from './exports'
|
||||
|
||||
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates'
|
||||
import { setBatch } from './utils/batch'
|
||||
|
||||
// Enable batched updates in our subscriptions for use
|
||||
// with standard React renderers (ReactDOM, React Native)
|
||||
setBatch(batch)
|
||||
|
||||
export { batch }
|
||||
130
node_modules/react-redux/src/utils/Subscription.js
generated
vendored
Normal file
130
node_modules/react-redux/src/utils/Subscription.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
import { getBatch } from './batch'
|
||||
|
||||
// encapsulates the subscription logic for connecting a component to the redux store, as
|
||||
// well as nesting subscriptions of descendant components, so that we can ensure the
|
||||
// ancestor components re-render before descendants
|
||||
|
||||
function createListenerCollection() {
|
||||
const batch = getBatch()
|
||||
let first = null
|
||||
let last = null
|
||||
|
||||
return {
|
||||
clear() {
|
||||
first = null
|
||||
last = null
|
||||
},
|
||||
|
||||
notify() {
|
||||
batch(() => {
|
||||
let listener = first
|
||||
while (listener) {
|
||||
listener.callback()
|
||||
listener = listener.next
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
get() {
|
||||
let listeners = []
|
||||
let listener = first
|
||||
while (listener) {
|
||||
listeners.push(listener)
|
||||
listener = listener.next
|
||||
}
|
||||
return listeners
|
||||
},
|
||||
|
||||
subscribe(callback) {
|
||||
let isSubscribed = true
|
||||
|
||||
let listener = (last = {
|
||||
callback,
|
||||
next: null,
|
||||
prev: last,
|
||||
})
|
||||
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener
|
||||
} else {
|
||||
first = listener
|
||||
}
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed || first === null) return
|
||||
isSubscribed = false
|
||||
|
||||
if (listener.next) {
|
||||
listener.next.prev = listener.prev
|
||||
} else {
|
||||
last = listener.prev
|
||||
}
|
||||
if (listener.prev) {
|
||||
listener.prev.next = listener.next
|
||||
} else {
|
||||
first = listener.next
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const nullListeners = {
|
||||
notify() {},
|
||||
get: () => [],
|
||||
}
|
||||
|
||||
export function createSubscription(store, parentSub) {
|
||||
let unsubscribe
|
||||
let listeners = nullListeners
|
||||
|
||||
function addNestedSub(listener) {
|
||||
trySubscribe()
|
||||
return listeners.subscribe(listener)
|
||||
}
|
||||
|
||||
function notifyNestedSubs() {
|
||||
listeners.notify()
|
||||
}
|
||||
|
||||
function handleChangeWrapper() {
|
||||
if (subscription.onStateChange) {
|
||||
subscription.onStateChange()
|
||||
}
|
||||
}
|
||||
|
||||
function isSubscribed() {
|
||||
return Boolean(unsubscribe)
|
||||
}
|
||||
|
||||
function trySubscribe() {
|
||||
if (!unsubscribe) {
|
||||
unsubscribe = parentSub
|
||||
? parentSub.addNestedSub(handleChangeWrapper)
|
||||
: store.subscribe(handleChangeWrapper)
|
||||
|
||||
listeners = createListenerCollection()
|
||||
}
|
||||
}
|
||||
|
||||
function tryUnsubscribe() {
|
||||
if (unsubscribe) {
|
||||
unsubscribe()
|
||||
unsubscribe = undefined
|
||||
listeners.clear()
|
||||
listeners = nullListeners
|
||||
}
|
||||
}
|
||||
|
||||
const subscription = {
|
||||
addNestedSub,
|
||||
notifyNestedSubs,
|
||||
handleChangeWrapper,
|
||||
isSubscribed,
|
||||
trySubscribe,
|
||||
tryUnsubscribe,
|
||||
getListeners: () => listeners,
|
||||
}
|
||||
|
||||
return subscription
|
||||
}
|
||||
12
node_modules/react-redux/src/utils/batch.js
generated
vendored
Normal file
12
node_modules/react-redux/src/utils/batch.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
// Default to a dummy "batch" implementation that just runs the callback
|
||||
function defaultNoopBatch(callback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
let batch = defaultNoopBatch
|
||||
|
||||
// Allow injecting another batching function later
|
||||
export const setBatch = (newBatch) => (batch = newBatch)
|
||||
|
||||
// Supply a getter just to skip dealing with ESM bindings
|
||||
export const getBatch = () => batch
|
||||
10
node_modules/react-redux/src/utils/bindActionCreators.js
generated
vendored
Normal file
10
node_modules/react-redux/src/utils/bindActionCreators.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export default function bindActionCreators(actionCreators, dispatch) {
|
||||
const boundActionCreators = {}
|
||||
for (const key in actionCreators) {
|
||||
const actionCreator = actionCreators[key]
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = (...args) => dispatch(actionCreator(...args))
|
||||
}
|
||||
}
|
||||
return boundActionCreators
|
||||
}
|
||||
17
node_modules/react-redux/src/utils/isPlainObject.js
generated
vendored
Normal file
17
node_modules/react-redux/src/utils/isPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
export default function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false
|
||||
|
||||
let proto = Object.getPrototypeOf(obj)
|
||||
if (proto === null) return true
|
||||
|
||||
let baseProto = proto
|
||||
while (Object.getPrototypeOf(baseProto) !== null) {
|
||||
baseProto = Object.getPrototypeOf(baseProto)
|
||||
}
|
||||
|
||||
return proto === baseProto
|
||||
}
|
||||
2
node_modules/react-redux/src/utils/reactBatchedUpdates.js
generated
vendored
Normal file
2
node_modules/react-redux/src/utils/reactBatchedUpdates.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* eslint-disable import/no-unresolved */
|
||||
export { unstable_batchedUpdates } from 'react-dom'
|
||||
4
node_modules/react-redux/src/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
4
node_modules/react-redux/src/utils/reactBatchedUpdates.native.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/* eslint-disable import/named */
|
||||
import { unstable_batchedUpdates } from 'react-native'
|
||||
|
||||
export { unstable_batchedUpdates }
|
||||
36
node_modules/react-redux/src/utils/shallowEqual.js
generated
vendored
Normal file
36
node_modules/react-redux/src/utils/shallowEqual.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
function is(x, y) {
|
||||
if (x === y) {
|
||||
return x !== 0 || y !== 0 || 1 / x === 1 / y
|
||||
} else {
|
||||
return x !== x && y !== y
|
||||
}
|
||||
}
|
||||
|
||||
export default function shallowEqual(objA, objB) {
|
||||
if (is(objA, objB)) return true
|
||||
|
||||
if (
|
||||
typeof objA !== 'object' ||
|
||||
objA === null ||
|
||||
typeof objB !== 'object' ||
|
||||
objB === null
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
const keysA = Object.keys(objA)
|
||||
const keysB = Object.keys(objB)
|
||||
|
||||
if (keysA.length !== keysB.length) return false
|
||||
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||
|
||||
!is(objA[keysA[i]], objB[keysA[i]])
|
||||
) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
17
node_modules/react-redux/src/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
17
node_modules/react-redux/src/utils/useIsomorphicLayoutEffect.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useEffect, useLayoutEffect } from 'react'
|
||||
|
||||
// React currently throws a warning when using useLayoutEffect on the server.
|
||||
// To get around it, we can conditionally useEffect on the server (no-op) and
|
||||
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
|
||||
// subscription callback always has the selector from the latest render commit
|
||||
// available, otherwise a store update may happen between render and the effect,
|
||||
// which may cause missed updates; we also must ensure the store subscription
|
||||
// is created synchronously, otherwise a store update may occur before the
|
||||
// subscription is created and an inconsistent state may be observed
|
||||
|
||||
export const useIsomorphicLayoutEffect =
|
||||
typeof window !== 'undefined' &&
|
||||
typeof window.document !== 'undefined' &&
|
||||
typeof window.document.createElement !== 'undefined'
|
||||
? useLayoutEffect
|
||||
: useEffect
|
||||
5
node_modules/react-redux/src/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
5
node_modules/react-redux/src/utils/useIsomorphicLayoutEffect.native.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { useLayoutEffect } from 'react'
|
||||
|
||||
// Under React Native, we know that we always want to use useLayoutEffect
|
||||
|
||||
export const useIsomorphicLayoutEffect = useLayoutEffect
|
||||
10
node_modules/react-redux/src/utils/verifyPlainObject.js
generated
vendored
Normal file
10
node_modules/react-redux/src/utils/verifyPlainObject.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import isPlainObject from './isPlainObject'
|
||||
import warning from './warning'
|
||||
|
||||
export default function verifyPlainObject(value, displayName, methodName) {
|
||||
if (!isPlainObject(value)) {
|
||||
warning(
|
||||
`${methodName}() in ${displayName} must return a plain object. Instead received ${value}.`
|
||||
)
|
||||
}
|
||||
}
|
||||
21
node_modules/react-redux/src/utils/warning.js
generated
vendored
Normal file
21
node_modules/react-redux/src/utils/warning.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
export default function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message)
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message)
|
||||
/* eslint-disable no-empty */
|
||||
} catch (e) {}
|
||||
/* eslint-enable no-empty */
|
||||
}
|
||||
Reference in New Issue
Block a user