node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

21
server/node_modules/react-redux/LICENSE.md generated vendored Normal file
View 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.

60
server/node_modules/react-redux/README.md generated vendored Normal file
View File

@@ -0,0 +1,60 @@
# React Redux
Official React bindings for [Redux](https://github.com/reduxjs/redux).
Performant and flexible.
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/reduxjs/react-redux/test.yml?style=flat-square) [![npm version](https://img.shields.io/npm/v/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
[![npm downloads](https://img.shields.io/npm/dm/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
[![#redux channel on Discord](https://img.shields.io/badge/discord-redux@reactiflux-61DAFB.svg?style=flat-square)](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/TS templates](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
# JS
npx create-react-app my-app --template redux
# TS
npx create-react-app my-app --template redux-typescript
```
### An Existing React App
React Redux 8.0 requires **React 16.8.3 or later** (or React Native 0.59 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 youre 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 dont 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 _dont_ recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on [npm](http://npmjs.com/).
## Documentation
The React Redux docs are published at **https://react-redux.js.org** .
## How Does It Work?
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.
There's also a [Deep Dive into React-Redux](https://blog.isquaredsoftware.com/2019/06/presentation-react-redux-deep-dive/) talk that covers some of the same material at a higher level.
## License
[MIT](LICENSE.md)

2200
server/node_modules/react-redux/dist/react-redux.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
declare const batch: (callback: () => void) => void;
export { batch };
export * from './exports';

View File

@@ -0,0 +1,16 @@
// The "alternate renderers" entry point is primarily here to fall back on a no-op
// version of `unstable_batchedUpdates`, for use with renderers other than ReactDOM/RN.
// Examples include React-Three-Fiber, Ink, etc.
// Because of that, we'll also assume the useSyncExternalStore compat shim is needed.
import { useSyncExternalStore } from 'use-sync-external-store/shim';
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
import { initializeUseSelector } from './hooks/useSelector';
import { initializeConnect } from './components/connect';
initializeUseSelector(useSyncExternalStoreWithSelector);
initializeConnect(useSyncExternalStore);
import { getBatch } from './utils/batch'; // For other renderers besides ReactDOM and React Native,
// use the default noop batch function
const batch = getBatch();
export { batch };
export * from './exports';

View File

@@ -0,0 +1,14 @@
import * as React from 'react';
import type { Action, AnyAction, Store } from 'redux';
import type { Subscription } from '../utils/Subscription';
import type { CheckFrequency } from '../hooks/useSelector';
export interface ReactReduxContextValue<SS = any, A extends Action = AnyAction> {
store: Store<SS, A>;
subscription: Subscription;
getServerState?: () => SS;
stabilityCheck: CheckFrequency;
noopCheck: CheckFrequency;
}
export declare const ReactReduxContext: React.Context<ReactReduxContextValue<any, AnyAction>>;
export declare type ReactReduxContextInstance = typeof ReactReduxContext;
export default ReactReduxContext;

View File

@@ -0,0 +1,28 @@
import * as React from 'react';
const ContextKey = Symbol.for(`react-redux-context`);
const gT = typeof globalThis !== "undefined" ? globalThis :
/* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
{};
function getContext() {
var _gT$ContextKey;
if (!React.createContext) return {};
const contextMap = (_gT$ContextKey = gT[ContextKey]) != null ? _gT$ContextKey : gT[ContextKey] = new Map();
let realContext = contextMap.get(React.createContext);
if (!realContext) {
realContext = React.createContext(null);
if (process.env.NODE_ENV !== 'production') {
realContext.displayName = 'ReactRedux';
}
contextMap.set(React.createContext, realContext);
}
return realContext;
}
export const ReactReduxContext = /*#__PURE__*/getContext();
export default ReactReduxContext;

View File

@@ -0,0 +1,27 @@
import type { Context, ReactNode } from 'react';
import type { ReactReduxContextValue } from './Context';
import type { Action, AnyAction, Store } from 'redux';
import type { CheckFrequency } from '../hooks/useSelector';
export interface ProviderProps<A extends Action = AnyAction, S = unknown> {
/**
* The single Redux store in your application.
*/
store: Store<S, A>;
/**
* An optional server state snapshot. Will be used during initial hydration render if available, to ensure that the UI output is consistent with the HTML generated on the server.
*/
serverState?: S;
/**
* Optional context to be used internally in react-redux. Use React.createContext() to create a context to be used.
* If this is used, you'll need to customize `connect` by supplying the same context provided to the Provider.
* Initial value doesn't matter, as it is overwritten with the internal state of Provider.
*/
context?: Context<ReactReduxContextValue<S, A>>;
/** Global configuration for the `useSelector` stability check */
stabilityCheck?: CheckFrequency;
/** Global configuration for the `useSelector` no-op check */
noopCheck?: CheckFrequency;
children: ReactNode;
}
declare function Provider<A extends Action = AnyAction, S = unknown>({ store, context, children, serverState, stabilityCheck, noopCheck, }: ProviderProps<A, S>): JSX.Element;
export default Provider;

View File

@@ -0,0 +1,48 @@
import * as React from 'react';
import { ReactReduxContext } from './Context';
import { createSubscription } from '../utils/Subscription';
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
function Provider({
store,
context,
children,
serverState,
stabilityCheck = 'once',
noopCheck = 'once'
}) {
const contextValue = React.useMemo(() => {
const subscription = createSubscription(store);
return {
store,
subscription,
getServerState: serverState ? () => serverState : undefined,
stabilityCheck,
noopCheck
};
}, [store, serverState, stabilityCheck, noopCheck]);
const previousState = React.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 = undefined;
};
}, [contextValue, previousState]);
const Context = context || ReactReduxContext; // @ts-ignore 'AnyAction' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype
return /*#__PURE__*/React.createElement(Context.Provider, {
value: contextValue
}, children);
}
export default Provider;

View File

@@ -0,0 +1,79 @@
import type { Store } from 'redux';
import type { InferableComponentEnhancer, InferableComponentEnhancerWithProps, ResolveThunks, DispatchProp } from '../types';
import type { MapStateToPropsParam, MapDispatchToPropsParam, MergeProps, MapDispatchToPropsNonObject } from '../connect/selectorFactory';
import type { ReactReduxContextInstance } from './Context';
import { ReactReduxContext } from './Context';
import type { uSES } from '../utils/useSyncExternalStore';
export declare const initializeConnect: (fn: uSES) => void;
export interface ConnectProps {
/** A custom Context instance that the component can use to access the store from an alternate Provider using that same Context instance */
context?: ReactReduxContextInstance;
/** A Redux store instance to be used for subscriptions instead of the store from a Provider */
store?: Store;
}
/**
* Infers the type of props that a connector will inject into a component.
*/
export declare type ConnectedProps<TConnector> = TConnector extends InferableComponentEnhancerWithProps<infer TInjectedProps, any> ? unknown extends TInjectedProps ? TConnector extends InferableComponentEnhancer<infer TInjectedProps> ? TInjectedProps : never : TInjectedProps : never;
export interface ConnectOptions<State = unknown, TStateProps = {}, TOwnProps = {}, TMergedProps = {}> {
forwardRef?: boolean;
context?: typeof ReactReduxContext;
areStatesEqual?: (nextState: State, prevState: State, nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean;
areOwnPropsEqual?: (nextOwnProps: TOwnProps, prevOwnProps: TOwnProps) => boolean;
areStatePropsEqual?: (nextStateProps: TStateProps, prevStateProps: TStateProps) => boolean;
areMergedPropsEqual?: (nextMergedProps: TMergedProps, prevMergedProps: TMergedProps) => boolean;
}
/**
* Connects a React component to a Redux store.
*
* - Without arguments, just wraps the component, without changing the behavior / props
*
* - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior
* is to override ownProps (as stated in the docs), so what remains is everything that's
* not a state or dispatch prop
*
* - When 3rd param is passed, we don't know if ownProps propagate and whether they
* should be valid component props, because it depends on mergeProps implementation.
* As such, it is the user's responsibility to extend ownProps interface from state or
* dispatch props or both when applicable
*
* @param mapStateToProps
* @param mapDispatchToProps
* @param mergeProps
* @param options
*/
export interface Connect<DefaultState = unknown> {
(): InferableComponentEnhancer<DispatchProp>;
/** mapState only */
<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>): InferableComponentEnhancerWithProps<TStateProps & DispatchProp, TOwnProps>;
/** mapDispatch only (as a function) */
<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
/** mapDispatch only (as an object) */
<no_state = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
/** mapState and mapDispatch (as a function)*/
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
/** mapState and mapDispatch (nullish) */
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined): InferableComponentEnhancerWithProps<TStateProps, TOwnProps>;
/** mapState and mapDispatch (as an object) */
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & ResolveThunks<TDispatchProps>, TOwnProps>;
/** mergeProps only */
<no_state = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: null | undefined, mergeProps: MergeProps<undefined, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
/** mapState and mergeProps */
<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: MergeProps<TStateProps, DispatchProp, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
/** mapDispatch (as a object) and mergeProps */
<no_state = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<undefined, TDispatchProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
/** mapState and options */
<TStateProps = {}, no_dispatch = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: null | undefined, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<DispatchProp & TStateProps, TOwnProps>;
/** mapDispatch (as a function) and options */
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TDispatchProps, TOwnProps>;
/** mapDispatch (as an object) and options*/
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}>(mapStateToProps: null | undefined, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<{}, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<ResolveThunks<TDispatchProps>, TOwnProps>;
/** mapState, mapDispatch (as a function), and options */
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsNonObject<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & TDispatchProps, TOwnProps>;
/** mapState, mapDispatch (as an object), and options */
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: null | undefined, options: ConnectOptions<State, TStateProps, TOwnProps>): InferableComponentEnhancerWithProps<TStateProps & ResolveThunks<TDispatchProps>, TOwnProps>;
/** mapState, mapDispatch, mergeProps, and options */
<TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, TMergedProps = {}, State = DefaultState>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>, mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>, mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>, options?: ConnectOptions<State, TStateProps, TOwnProps, TMergedProps>): InferableComponentEnhancerWithProps<TMergedProps, TOwnProps>;
}
declare const _default: Connect<unknown>;
export default _default;

View File

@@ -0,0 +1,410 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["reactReduxForwardedRef"];
/* eslint-disable valid-jsdoc, @typescript-eslint/no-unused-vars */
import hoistStatics from 'hoist-non-react-statics';
import * as React from 'react';
import { isValidElementType, isContextConsumer } from 'react-is';
import defaultSelectorFactory from '../connect/selectorFactory';
import { mapDispatchToPropsFactory } from '../connect/mapDispatchToProps';
import { mapStateToPropsFactory } from '../connect/mapStateToProps';
import { mergePropsFactory } from '../connect/mergeProps';
import { createSubscription } from '../utils/Subscription';
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
import shallowEqual from '../utils/shallowEqual';
import warning from '../utils/warning';
import { ReactReduxContext } from './Context';
import { notInitialized } from '../utils/useSyncExternalStore';
let useSyncExternalStore = notInitialized;
export const initializeConnect = fn => {
useSyncExternalStore = fn;
}; // Define some constant arrays just to avoid re-creating these
const EMPTY_ARRAY = [null, 0];
const NO_SUBSCRIPTION_ARRAY = [null, null]; // Attempts to stringify whatever not-really-a-component value we were given
// for logging in an error message
const stringifyComponent = Comp => {
try {
return JSON.stringify(Comp);
} catch (err) {
return String(Comp);
}
};
// This is "just" a `useLayoutEffect`, but with two modifications:
// - we need to fall back to `useEffect` in SSR to avoid annoying warnings
// - we extract this to a separate function to avoid closing over values
// and causing memory leaks
function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
useIsomorphicLayoutEffect(() => effectFunc(...effectArgs), dependencies);
} // Effect callback, extracted: assign the latest props values to refs for later usage
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, // actualChildProps: unknown,
childPropsFromStoreUpdate, notifyNestedSubs) {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps;
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();
}
} // Effect callback, extracted: subscribe to the Redux store or nearest connected ancestor,
// check for updates after dispatched actions, and trigger re-renders.
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, isMounted, childPropsFromStoreUpdate, notifyNestedSubs, // forceComponentUpdateDispatch: React.Dispatch<any>,
additionalSubscribeListener) {
// 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 || !isMounted.current) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return;
} // TODO We're currently calling getState ourselves here, rather than letting `uSES` do it
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; // TODO This is hacky and not how `uSES` is meant to be used
// Trigger the React `useSyncExternalStore` subscriber
additionalSubscribeListener();
}
}; // 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;
} // Reducer initial state creation for our update reducer
const initStateUpdates = () => EMPTY_ARRAY;
function strictEqual(a, b) {
return a === b;
}
/**
* Infers the type of props that a connector will inject into a component.
*/
let hasWarnedAboutDeprecatedPureOption = false;
/**
* Connects a React component to a Redux store.
*
* - Without arguments, just wraps the component, without changing the behavior / props
*
* - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior
* is to override ownProps (as stated in the docs), so what remains is everything that's
* not a state or dispatch prop
*
* - When 3rd param is passed, we don't know if ownProps propagate and whether they
* should be valid component props, because it depends on mergeProps implementation.
* As such, it is the user's responsibility to extend ownProps interface from state or
* dispatch props or both when applicable
*
* @param mapStateToProps A function that extracts values from state
* @param mapDispatchToProps Setup for dispatching actions
* @param mergeProps Optional callback to merge state and dispatch props together
* @param options Options for configuring the connection
*
*/
function connect(mapStateToProps, mapDispatchToProps, mergeProps, {
// The `pure` option has been removed, so TS doesn't like us destructuring this to check its existence.
// @ts-ignore
pure,
areStatesEqual = strictEqual,
areOwnPropsEqual = shallowEqual,
areStatePropsEqual = shallowEqual,
areMergedPropsEqual = shallowEqual,
// use React's forwardRef to expose a ref of the wrapped component
forwardRef = false,
// the context consumer to use
context = ReactReduxContext
} = {}) {
if (process.env.NODE_ENV !== 'production') {
if (pure !== undefined && !hasWarnedAboutDeprecatedPureOption) {
hasWarnedAboutDeprecatedPureOption = true;
warning('The `pure` option has been removed. `connect` is now always a "pure/memoized" component');
}
}
const Context = context;
const initMapStateToProps = mapStateToPropsFactory(mapStateToProps);
const initMapDispatchToProps = mapDispatchToPropsFactory(mapDispatchToProps);
const initMergeProps = mergePropsFactory(mergeProps);
const shouldHandleStateChanges = Boolean(mapStateToProps);
const wrapWithConnect = WrappedComponent => {
if (process.env.NODE_ENV !== 'production' && !isValidElementType(WrappedComponent)) {
throw new Error(`You must pass a component to the function returned by connect. Instead received ${stringifyComponent(WrappedComponent)}`);
}
const wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
const displayName = `Connect(${wrappedComponentName})`;
const selectorFactoryOptions = {
shouldHandleStateChanges,
displayName,
wrappedComponentName,
WrappedComponent,
// @ts-ignore
initMapStateToProps,
// @ts-ignore
initMapDispatchToProps,
initMergeProps,
areStatesEqual,
areStatePropsEqual,
areOwnPropsEqual,
areMergedPropsEqual
};
function ConnectFunction(props) {
const [propsContext, reactReduxForwardedRef, wrapperProps] = React.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
} = props,
wrapperProps = _objectWithoutPropertiesLoose(props, _excluded);
return [props.context, reactReduxForwardedRef, wrapperProps];
}, [props]);
const ContextToUse = React.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 && // @ts-ignore
isContextConsumer( /*#__PURE__*/React.createElement(propsContext.Consumer, null)) ? propsContext : Context;
}, [propsContext, Context]); // Retrieve the store and ancestor subscription via context, if available
const contextValue = 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.
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 getServerState = didStoreComeFromContext ? contextValue.getServerState : store.getState;
const childPropsSelector = React.useMemo(() => {
// The child props selector needs the store reference as an input.
// Re-create this selector whenever the store changes.
return defaultSelectorFactory(store.dispatch, selectorFactoryOptions);
}, [store]);
const [subscription, notifyNestedSubs] = React.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 ? undefined : 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 = React.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 _extends({}, contextValue, {
subscription
});
}, [didStoreComeFromProps, contextValue, subscription]); // Set up refs to coordinate values between the subscription effect and the render logic
const lastChildProps = React.useRef();
const lastWrapperProps = React.useRef(wrapperProps);
const childPropsFromStoreUpdate = React.useRef();
const renderIsScheduled = React.useRef(false);
const isProcessingDispatch = React.useRef(false);
const isMounted = React.useRef(false);
const latestSubscriptionCallbackError = React.useRef();
useIsomorphicLayoutEffect(() => {
isMounted.current = true;
return () => {
isMounted.current = false;
};
}, []);
const actualChildPropsSelector = React.useMemo(() => {
const selector = () => {
// 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);
};
return selector;
}, [store, 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.
const subscribeForReact = React.useMemo(() => {
const subscribe = reactListener => {
if (!subscription) {
return () => {};
}
return subscribeUpdates(shouldHandleStateChanges, store, subscription, // @ts-ignore
childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, isMounted, childPropsFromStoreUpdate, notifyNestedSubs, reactListener);
};
return subscribe;
}, [subscription]);
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, childPropsFromStoreUpdate, notifyNestedSubs]);
let actualChildProps;
try {
actualChildProps = useSyncExternalStore( // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
subscribeForReact, // TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
// TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
actualChildPropsSelector, getServerState ? () => childPropsSelector(getServerState(), wrapperProps) : actualChildPropsSelector);
} 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(() => {
latestSubscriptionCallbackError.current = undefined;
childPropsFromStoreUpdate.current = undefined;
lastChildProps.current = actualChildProps;
}); // 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 = React.useMemo(() => {
return (
/*#__PURE__*/
// @ts-ignore
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.
const renderedChild = React.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 /*#__PURE__*/React.createElement(ContextToUse.Provider, {
value: overriddenContextValue
}, renderedWrappedComponent);
}
return renderedWrappedComponent;
}, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
return renderedChild;
}
const _Connect = React.memo(ConnectFunction);
// Add a hacky cast to get the right output type
const Connect = _Connect;
Connect.WrappedComponent = WrappedComponent;
Connect.displayName = ConnectFunction.displayName = displayName;
if (forwardRef) {
const _forwarded = React.forwardRef(function forwardConnectRef(props, ref) {
// @ts-ignore
return /*#__PURE__*/React.createElement(Connect, _extends({}, props, {
reactReduxForwardedRef: ref
}));
});
const forwarded = _forwarded;
forwarded.displayName = displayName;
forwarded.WrappedComponent = WrappedComponent;
return hoistStatics(forwarded, WrappedComponent);
}
return hoistStatics(Connect, WrappedComponent);
};
return wrapWithConnect;
}
export default connect;

View File

@@ -0,0 +1,4 @@
import type { Action, Dispatch } from 'redux';
export declare function createInvalidArgFactory(arg: unknown, name: string): (dispatch: Dispatch<Action<unknown>>, options: {
readonly wrappedComponentName: string;
}) => never;

View File

@@ -0,0 +1,5 @@
export function createInvalidArgFactory(arg, name) {
return (dispatch, options) => {
throw new Error(`Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.`);
};
}

View File

@@ -0,0 +1,29 @@
import type { Action, Dispatch } from 'redux';
import type { MapDispatchToPropsParam } from './selectorFactory';
export declare function mapDispatchToPropsFactory<TDispatchProps, TOwnProps>(mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps> | undefined): ((dispatch: Dispatch<import("redux").AnyAction>) => {
(): import("redux").ActionCreatorsMapObject<any> | import("redux").ActionCreator<any> | {
dispatch?: Dispatch<import("redux").AnyAction> | undefined;
dependsOnOwnProps?: boolean | undefined;
};
dependsOnOwnProps: boolean;
}) | ((dispatch: Dispatch<Action<unknown>>, options: {
readonly wrappedComponentName: string;
}) => never) | ((dispatch: Dispatch<import("redux").AnyAction>, { displayName }: {
displayName: string;
}) => {
(stateOrDispatch: {
[key: string]: any;
} | Dispatch<import("redux").AnyAction>, ownProps?: {
[key: string]: any;
} | undefined): import("./wrapMapToProps").MapToProps<{
[key: string]: any;
}>;
dependsOnOwnProps: boolean;
mapToProps(stateOrDispatch: {
[key: string]: any;
} | Dispatch<import("redux").AnyAction>, ownProps?: {
[key: string]: any;
} | undefined): import("./wrapMapToProps").MapToProps<{
[key: string]: any;
}>;
});

View File

@@ -0,0 +1,10 @@
import bindActionCreators from '../utils/bindActionCreators';
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps';
import { createInvalidArgFactory } from './invalidArgFactory';
export function mapDispatchToPropsFactory(mapDispatchToProps) {
return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? wrapMapToPropsConstant(dispatch => // @ts-ignore
bindActionCreators(mapDispatchToProps, dispatch)) : !mapDispatchToProps ? wrapMapToPropsConstant(dispatch => ({
dispatch
})) : typeof mapDispatchToProps === 'function' ? // @ts-ignore
wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps') : createInvalidArgFactory(mapDispatchToProps, 'mapDispatchToProps');
}

View File

@@ -0,0 +1,28 @@
import type { MapStateToPropsParam } from './selectorFactory';
export declare function mapStateToPropsFactory<TStateProps, TOwnProps, State>(mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps, State>): ((dispatch: import("redux").Dispatch<import("redux").AnyAction>) => {
(): import("redux").ActionCreatorsMapObject<any> | import("redux").ActionCreator<any> | {
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
dependsOnOwnProps?: boolean | undefined;
};
dependsOnOwnProps: boolean;
}) | ((dispatch: import("redux").Dispatch<import("redux").Action<unknown>>, options: {
readonly wrappedComponentName: string;
}) => never) | ((dispatch: import("redux").Dispatch<import("redux").AnyAction>, { displayName }: {
displayName: string;
}) => {
(stateOrDispatch: {
[key: string]: any;
} | import("redux").Dispatch<import("redux").AnyAction>, ownProps?: {
[key: string]: any;
} | undefined): import("./wrapMapToProps").MapToProps<{
[key: string]: any;
}>;
dependsOnOwnProps: boolean;
mapToProps(stateOrDispatch: {
[key: string]: any;
} | import("redux").Dispatch<import("redux").AnyAction>, ownProps?: {
[key: string]: any;
} | undefined): import("./wrapMapToProps").MapToProps<{
[key: string]: any;
}>;
});

View File

@@ -0,0 +1,6 @@
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps';
import { createInvalidArgFactory } from './invalidArgFactory';
export function mapStateToPropsFactory(mapStateToProps) {
return !mapStateToProps ? wrapMapToPropsConstant(() => ({})) : typeof mapStateToProps === 'function' ? // @ts-ignore
wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps') : createInvalidArgFactory(mapStateToProps, 'mapStateToProps');
}

View File

@@ -0,0 +1,14 @@
import type { Action, Dispatch } from 'redux';
import type { MergeProps } from './selectorFactory';
import type { EqualityFn } from '../types';
export declare function defaultMergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>(stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps): TMergedProps;
export declare function wrapMergePropsFunc<TStateProps, TDispatchProps, TOwnProps, TMergedProps>(mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>): (dispatch: Dispatch<Action<unknown>>, options: {
readonly displayName: string;
readonly areMergedPropsEqual: EqualityFn<TMergedProps>;
}) => MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>;
export declare function mergePropsFactory<TStateProps, TDispatchProps, TOwnProps, TMergedProps>(mergeProps?: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>): ((dispatch: Dispatch<Action<unknown>>, options: {
readonly wrappedComponentName: string;
}) => never) | ((dispatch: Dispatch<Action<unknown>>, options: {
readonly displayName: string;
readonly areMergedPropsEqual: EqualityFn<TMergedProps>;
}) => MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>);

View File

@@ -0,0 +1,32 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import verifyPlainObject from '../utils/verifyPlainObject';
import { createInvalidArgFactory } from './invalidArgFactory';
export function defaultMergeProps(stateProps, dispatchProps, ownProps) {
// @ts-ignore
return _extends({}, ownProps, stateProps, dispatchProps);
}
export function wrapMergePropsFunc(mergeProps) {
return function initMergePropsProxy(dispatch, {
displayName,
areMergedPropsEqual
}) {
let hasRunOnce = false;
let mergedProps;
return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
const nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
if (hasRunOnce) {
if (!areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
} else {
hasRunOnce = true;
mergedProps = nextMergedProps;
if (process.env.NODE_ENV !== 'production') verifyPlainObject(mergedProps, displayName, 'mergeProps');
}
return mergedProps;
};
};
}
export function mergePropsFactory(mergeProps) {
return !mergeProps ? () => defaultMergeProps : typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : createInvalidArgFactory(mergeProps, 'mergeProps');
}

View File

@@ -0,0 +1,42 @@
import type { Dispatch, Action } from 'redux';
import type { ComponentType } from 'react';
import type { EqualityFn, ExtendedEqualityFn } from '../types';
export declare type SelectorFactory<S, TProps, TOwnProps, TFactoryOptions> = (dispatch: Dispatch<Action<unknown>>, factoryOptions: TFactoryOptions) => Selector<S, TProps, TOwnProps>;
export declare type Selector<S, TProps, TOwnProps = null> = TOwnProps extends null | undefined ? (state: S) => TProps : (state: S, ownProps: TOwnProps) => TProps;
export declare type MapStateToProps<TStateProps, TOwnProps, State> = (state: State, ownProps: TOwnProps) => TStateProps;
export declare type MapStateToPropsFactory<TStateProps, TOwnProps, State> = (initialState: State, ownProps: TOwnProps) => MapStateToProps<TStateProps, TOwnProps, State>;
export declare type MapStateToPropsParam<TStateProps, TOwnProps, State> = MapStateToPropsFactory<TStateProps, TOwnProps, State> | MapStateToProps<TStateProps, TOwnProps, State> | null | undefined;
export declare type MapDispatchToPropsFunction<TDispatchProps, TOwnProps> = (dispatch: Dispatch<Action<unknown>>, ownProps: TOwnProps) => TDispatchProps;
export declare type MapDispatchToProps<TDispatchProps, TOwnProps> = MapDispatchToPropsFunction<TDispatchProps, TOwnProps> | TDispatchProps;
export declare type MapDispatchToPropsFactory<TDispatchProps, TOwnProps> = (dispatch: Dispatch<Action<unknown>>, ownProps: TOwnProps) => MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
export declare type MapDispatchToPropsParam<TDispatchProps, TOwnProps> = MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToProps<TDispatchProps, TOwnProps>;
export declare type MapDispatchToPropsNonObject<TDispatchProps, TOwnProps> = MapDispatchToPropsFactory<TDispatchProps, TOwnProps> | MapDispatchToPropsFunction<TDispatchProps, TOwnProps>;
export declare type MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps> = (stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps) => TMergedProps;
interface PureSelectorFactoryComparisonOptions<TStateProps, TOwnProps, State> {
readonly areStatesEqual: ExtendedEqualityFn<State, TOwnProps>;
readonly areStatePropsEqual: EqualityFn<TStateProps>;
readonly areOwnPropsEqual: EqualityFn<TOwnProps>;
}
export declare function pureFinalPropsSelectorFactory<TStateProps, TOwnProps, TDispatchProps, TMergedProps, State>(mapStateToProps: WrappedMapStateToProps<TStateProps, TOwnProps, State>, mapDispatchToProps: WrappedMapDispatchToProps<TDispatchProps, TOwnProps>, mergeProps: MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>, dispatch: Dispatch<Action<unknown>>, { areStatesEqual, areOwnPropsEqual, areStatePropsEqual, }: PureSelectorFactoryComparisonOptions<TStateProps, TOwnProps, State>): (nextState: State, nextOwnProps: TOwnProps) => TMergedProps;
interface WrappedMapStateToProps<TStateProps, TOwnProps, State> {
(state: State, ownProps: TOwnProps): TStateProps;
readonly dependsOnOwnProps: boolean;
}
interface WrappedMapDispatchToProps<TDispatchProps, TOwnProps> {
(dispatch: Dispatch<Action<unknown>>, ownProps: TOwnProps): TDispatchProps;
readonly dependsOnOwnProps: boolean;
}
export interface InitOptions<TStateProps, TOwnProps, TMergedProps, State> extends PureSelectorFactoryComparisonOptions<TStateProps, TOwnProps, State> {
readonly shouldHandleStateChanges: boolean;
readonly displayName: string;
readonly wrappedComponentName: string;
readonly WrappedComponent: ComponentType<TOwnProps>;
readonly areMergedPropsEqual: EqualityFn<TMergedProps>;
}
export interface SelectorFactoryOptions<TStateProps, TOwnProps, TDispatchProps, TMergedProps, State> extends InitOptions<TStateProps, TOwnProps, TMergedProps, State> {
readonly initMapStateToProps: (dispatch: Dispatch<Action<unknown>>, options: InitOptions<TStateProps, TOwnProps, TMergedProps, State>) => WrappedMapStateToProps<TStateProps, TOwnProps, State>;
readonly initMapDispatchToProps: (dispatch: Dispatch<Action<unknown>>, options: InitOptions<TStateProps, TOwnProps, TMergedProps, State>) => WrappedMapDispatchToProps<TDispatchProps, TOwnProps>;
readonly initMergeProps: (dispatch: Dispatch<Action<unknown>>, options: InitOptions<TStateProps, TOwnProps, TMergedProps, State>) => MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>;
}
export default function finalPropsSelectorFactory<TStateProps, TOwnProps, TDispatchProps, TMergedProps, State>(dispatch: Dispatch<Action<unknown>>, { initMapStateToProps, initMapDispatchToProps, initMergeProps, ...options }: SelectorFactoryOptions<TStateProps, TOwnProps, TDispatchProps, TMergedProps, State>): (nextState: State, nextOwnProps: TOwnProps) => TMergedProps;
export {};

View File

@@ -0,0 +1,84 @@
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"];
import verifySubselectors from './verifySubselectors';
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
// The selector returned by selectorFactory will memoize its results,
// allowing connect's shouldComponentUpdate to return false if final
// props have not changed.
export default function finalPropsSelectorFactory(dispatch, _ref) {
let {
initMapStateToProps,
initMapDispatchToProps,
initMergeProps
} = _ref,
options = _objectWithoutPropertiesLoose(_ref, _excluded);
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);
}
return pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
}

View File

@@ -0,0 +1 @@
export default function verifySubselectors(mapStateToProps: unknown, mapDispatchToProps: unknown, mergeProps: unknown): void;

View File

@@ -0,0 +1,17 @@
import warning from '../utils/warning';
function verify(selector, methodName) {
if (!selector) {
throw new Error(`Unexpected value for ${methodName} in connect.`);
} else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
warning(`The selector for ${methodName} of connect did not specify a value for dependsOnOwnProps.`);
}
}
}
export default function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps) {
verify(mapStateToProps, 'mapStateToProps');
verify(mapDispatchToProps, 'mapDispatchToProps');
verify(mergeProps, 'mergeProps');
}

View File

@@ -0,0 +1,32 @@
import type { ActionCreatorsMapObject, Dispatch, ActionCreator } from 'redux';
import type { FixTypeLater } from '../types';
declare type AnyState = {
[key: string]: any;
};
declare type StateOrDispatch<S extends AnyState = AnyState> = S | Dispatch;
declare type AnyProps = {
[key: string]: any;
};
export declare type MapToProps<P extends AnyProps = AnyProps> = {
(stateOrDispatch: StateOrDispatch, ownProps?: P): FixTypeLater;
dependsOnOwnProps?: boolean;
};
export declare function wrapMapToPropsConstant(getConstant: (dispatch: Dispatch) => {
dispatch?: Dispatch;
dependsOnOwnProps?: boolean;
} | ActionCreatorsMapObject | ActionCreator<any>): (dispatch: Dispatch) => {
(): ActionCreatorsMapObject<any> | ActionCreator<any> | {
dispatch?: Dispatch<import("redux").AnyAction> | undefined;
dependsOnOwnProps?: boolean | undefined;
};
dependsOnOwnProps: boolean;
};
export declare function getDependsOnOwnProps(mapToProps: MapToProps): boolean;
export declare function wrapMapToPropsFunc<P extends AnyProps = AnyProps>(mapToProps: MapToProps, methodName: string): (dispatch: Dispatch, { displayName }: {
displayName: string;
}) => {
(stateOrDispatch: StateOrDispatch, ownProps?: P | undefined): MapToProps;
dependsOnOwnProps: boolean;
mapToProps(stateOrDispatch: StateOrDispatch, ownProps?: P | undefined): MapToProps;
};
export {};

View File

@@ -0,0 +1,70 @@
import verifyPlainObject from '../utils/verifyPlainObject';
export function wrapMapToPropsConstant( // * Note:
// It seems that the dispatch argument
// could be a dispatch function in some cases (ex: whenMapDispatchToPropsIsMissing)
// and a state object in some others (ex: whenMapStateToPropsIsMissing)
// eslint-disable-next-line no-unused-vars
getConstant) {
return function initConstantSelector(dispatch) {
const constant = getConstant(dispatch);
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..
// TODO Can this get pulled out so that we can subscribe directly to the store if we don't need ownProps?
export function getDependsOnOwnProps(mapToProps) {
return mapToProps.dependsOnOwnProps ? 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, undefined);
}; // 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;
};
}

15
server/node_modules/react-redux/es/exports.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import Provider from './components/Provider';
import type { ProviderProps } from './components/Provider';
import connect from './components/connect';
import type { Connect, ConnectProps, ConnectedProps } from './components/connect';
import type { SelectorFactory, Selector, MapStateToProps, MapStateToPropsFactory, MapStateToPropsParam, MapDispatchToPropsFunction, MapDispatchToProps, MapDispatchToPropsFactory, MapDispatchToPropsParam, MapDispatchToPropsNonObject, MergeProps } from './connect/selectorFactory';
import { ReactReduxContext } from './components/Context';
import type { ReactReduxContextValue } from './components/Context';
import { useDispatch, createDispatchHook } from './hooks/useDispatch';
import { useSelector, createSelectorHook } from './hooks/useSelector';
import { useStore, createStoreHook } from './hooks/useStore';
import shallowEqual from './utils/shallowEqual';
import type { Subscription } from './utils/Subscription';
export * from './types';
export type { ProviderProps, SelectorFactory, Selector, MapStateToProps, MapStateToPropsFactory, MapStateToPropsParam, Connect, ConnectProps, ConnectedProps, MapDispatchToPropsFunction, MapDispatchToProps, MapDispatchToPropsFactory, MapDispatchToPropsParam, MapDispatchToPropsNonObject, MergeProps, ReactReduxContextValue, Subscription, };
export { Provider, ReactReduxContext, connect, useDispatch, createDispatchHook, useSelector, createSelectorHook, useStore, createStoreHook, shallowEqual, };

9
server/node_modules/react-redux/es/exports.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import Provider from './components/Provider';
import connect from './components/connect';
import { ReactReduxContext } from './components/Context';
import { useDispatch, createDispatchHook } from './hooks/useDispatch';
import { useSelector, createSelectorHook } from './hooks/useSelector';
import { useStore, createStoreHook } from './hooks/useStore';
import shallowEqual from './utils/shallowEqual';
export * from './types';
export { Provider, ReactReduxContext, connect, useDispatch, createDispatchHook, useSelector, createSelectorHook, useStore, createStoreHook, shallowEqual };

View File

@@ -0,0 +1,32 @@
import type { Action, AnyAction, Dispatch } from 'redux';
import type { Context } from 'react';
import type { ReactReduxContextValue } from '../components/Context';
/**
* 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 declare function createDispatchHook<S = unknown, A extends Action = AnyAction>(context?: Context<ReactReduxContextValue<S, A>>): <AppDispatch extends Dispatch<A> = Dispatch<A>>() => AppDispatch;
/**
* 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 declare const useDispatch: <AppDispatch extends Dispatch<AnyAction> = Dispatch<AnyAction>>() => AppDispatch;

View 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 = // @ts-ignore
context === ReactReduxContext ? useDefaultStore : createStoreHook(context);
return function useDispatch() {
const store = useStore(); // @ts-ignore
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();

View File

@@ -0,0 +1,27 @@
/// <reference types="react" />
import type { ReactReduxContextValue } from '../components/Context';
/**
* Hook factory, which creates a `useReduxContext` hook bound to a given context. This is a low-level
* hook that you should usually not need to call directly.
*
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useReduxContext` hook bound to the specified context.
*/
export declare function createReduxContextHook(context?: import("react").Context<ReactReduxContextValue<any, import("redux").AnyAction>>): () => ReactReduxContextValue | null;
/**
* 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 = () => {
* const { store } = useReduxContext()
* return <div>{store.getState()}</div>
* }
*/
export declare const useReduxContext: () => ReactReduxContextValue | null;

View File

@@ -0,0 +1,39 @@
import { useContext } from 'react';
import { ReactReduxContext } from '../components/Context';
/**
* Hook factory, which creates a `useReduxContext` hook bound to a given context. This is a low-level
* hook that you should usually not need to call directly.
*
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useReduxContext` hook bound to the specified context.
*/
export function createReduxContextHook(context = ReactReduxContext) {
return function useReduxContext() {
const contextValue = useContext(context);
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;
};
}
/**
* 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 = () => {
* const { store } = useReduxContext()
* return <div>{store.getState()}</div>
* }
*/
export const useReduxContext = /*#__PURE__*/createReduxContextHook();

View File

@@ -0,0 +1,45 @@
/// <reference types="react" />
import type { EqualityFn } from '../types';
import type { uSESWS } from '../utils/useSyncExternalStore';
export declare type CheckFrequency = 'never' | 'once' | 'always';
export interface UseSelectorOptions<Selected = unknown> {
equalityFn?: EqualityFn<Selected>;
stabilityCheck?: CheckFrequency;
noopCheck?: CheckFrequency;
}
export interface UseSelector {
<TState = unknown, Selected = unknown>(selector: (state: TState) => Selected, equalityFn?: EqualityFn<Selected>): Selected;
<TState = unknown, Selected = unknown>(selector: (state: TState) => Selected, options?: UseSelectorOptions<Selected>): Selected;
}
export declare const initializeUseSelector: (fn: uSESWS) => void;
/**
* 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 declare function createSelectorHook(context?: import("react").Context<import("../components/Context").ReactReduxContextValue<any, import("redux").AnyAction>>): UseSelector;
/**
* 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 declare const useSelector: UseSelector;

141
server/node_modules/react-redux/es/hooks/useSelector.js generated vendored Normal file
View File

@@ -0,0 +1,141 @@
import { useCallback, useDebugValue, useRef } from 'react';
import { createReduxContextHook, useReduxContext as useDefaultReduxContext } from './useReduxContext';
import { ReactReduxContext } from '../components/Context';
import { notInitialized } from '../utils/useSyncExternalStore';
let useSyncExternalStoreWithSelector = notInitialized;
export const initializeUseSelector = fn => {
useSyncExternalStoreWithSelector = fn;
};
const refEquality = (a, b) => a === b;
/**
* 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 : createReduxContextHook(context);
return function useSelector(selector, equalityFnOrOptions = {}) {
const {
equalityFn = refEquality,
stabilityCheck = undefined,
noopCheck = undefined
} = typeof equalityFnOrOptions === 'function' ? {
equalityFn: equalityFnOrOptions
} : equalityFnOrOptions;
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,
getServerState,
stabilityCheck: globalStabilityCheck,
noopCheck: globalNoopCheck
} = useReduxContext();
const firstRun = useRef(true);
const wrappedSelector = useCallback({
[selector.name](state) {
const selected = selector(state);
if (process.env.NODE_ENV !== 'production') {
const finalStabilityCheck = typeof stabilityCheck === 'undefined' ? globalStabilityCheck : stabilityCheck;
if (finalStabilityCheck === 'always' || finalStabilityCheck === 'once' && firstRun.current) {
const toCompare = selector(state);
if (!equalityFn(selected, toCompare)) {
let stack = undefined;
try {
throw new Error();
} catch (e) {
;
({
stack
} = e);
}
console.warn('Selector ' + (selector.name || 'unknown') + ' returned a different result when called with the same parameters. This can lead to unnecessary rerenders.' + '\nSelectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization', {
state,
selected,
selected2: toCompare,
stack
});
}
}
const finalNoopCheck = typeof noopCheck === 'undefined' ? globalNoopCheck : noopCheck;
if (finalNoopCheck === 'always' || finalNoopCheck === 'once' && firstRun.current) {
// @ts-ignore
if (selected === state) {
let stack = undefined;
try {
throw new Error();
} catch (e) {
;
({
stack
} = e);
}
console.warn('Selector ' + (selector.name || 'unknown') + ' returned the root state when called. This can lead to unnecessary rerenders.' + '\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.', {
stack
});
}
}
if (firstRun.current) firstRun.current = false;
}
return selected;
}
}[selector.name], [selector, globalStabilityCheck, stabilityCheck]);
const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, wrappedSelector, equalityFn);
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();

26
server/node_modules/react-redux/es/hooks/useStore.d.ts generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import type { Context } from 'react';
import type { Action as BasicAction, AnyAction, Store } from 'redux';
import type { ReactReduxContextValue } from '../components/Context';
/**
* 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 declare function createStoreHook<S = unknown, A extends BasicAction = AnyAction>(context?: Context<ReactReduxContextValue<S, A>>): <State = S, Action extends BasicAction<any> = A>() => Store<State, Action>;
/**
* 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 declare const useStore: <State = unknown, Action extends BasicAction<any> = AnyAction>() => Store<State, Action>;

38
server/node_modules/react-redux/es/hooks/useStore.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import { ReactReduxContext } from '../components/Context';
import { useReduxContext as useDefaultReduxContext, createReduxContextHook } 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 = // @ts-ignore
context === ReactReduxContext ? useDefaultReduxContext : // @ts-ignore
createReduxContextHook(context);
return function useStore() {
const {
store
} = useReduxContext(); // @ts-ignore
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();

3
server/node_modules/react-redux/es/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates';
export { batch };
export * from './exports';

16
server/node_modules/react-redux/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
// The primary entry point assumes we're working with standard ReactDOM/RN, but
// older versions that do not include `useSyncExternalStore` (React 16.9 - 17.x).
// Because of that, the useSyncExternalStore compat shim is needed.
import { useSyncExternalStore } from 'use-sync-external-store/shim';
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates';
import { setBatch } from './utils/batch';
import { initializeUseSelector } from './hooks/useSelector';
import { initializeConnect } from './components/connect';
initializeUseSelector(useSyncExternalStoreWithSelector);
initializeConnect(useSyncExternalStore); // Enable batched updates in our subscriptions for use
// with standard React renderers (ReactDOM, React Native)
setBatch(batch);
export { batch };
export * from './exports';

3
server/node_modules/react-redux/es/next.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates';
export { batch };
export * from './exports';

17
server/node_modules/react-redux/es/next.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
// The secondary entry point assumes we are working with React 18, and thus have
// useSyncExternalStore available. We can import that directly from React itself.
// The useSyncExternalStoreWithSelector has to be imported, but we can use the
// non-shim version. This shaves off the byte size of the shim.
import * as React from 'react';
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector';
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates';
import { setBatch } from './utils/batch';
import { initializeUseSelector } from './hooks/useSelector';
import { initializeConnect } from './components/connect';
initializeUseSelector(useSyncExternalStoreWithSelector);
initializeConnect(React.useSyncExternalStore); // Enable batched updates in our subscriptions for use
// with standard React renderers (ReactDOM, React Native)
setBatch(batch);
export { batch };
export * from './exports';

80
server/node_modules/react-redux/es/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,80 @@
import type { ClassAttributes, ComponentClass, ComponentType, FunctionComponent } from 'react';
import type { Action, AnyAction, Dispatch } from 'redux';
import type { NonReactStatics } from 'hoist-non-react-statics';
import type { ConnectProps } from './components/connect';
import type { UseSelectorOptions } from './hooks/useSelector';
export declare type FixTypeLater = any;
export declare type EqualityFn<T> = (a: T, b: T) => boolean;
export declare type ExtendedEqualityFn<T, P> = (a: T, b: T, c: P, d: P) => boolean;
export declare type AnyIfEmpty<T extends object> = keyof T extends never ? any : T;
export declare type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
export interface DispatchProp<A extends Action = AnyAction> {
dispatch: Dispatch<A>;
}
/**
* A property P will be present if:
* - it is present in DecorationTargetProps
*
* Its value will be dependent on the following conditions
* - if property P is present in InjectedProps and its definition extends the definition
* in DecorationTargetProps, then its definition will be that of DecorationTargetProps[P]
* - if property P is not present in InjectedProps then its definition will be that of
* DecorationTargetProps[P]
* - if property P is present in InjectedProps but does not extend the
* DecorationTargetProps[P] definition, its definition will be that of InjectedProps[P]
*/
export declare type Matching<InjectedProps, DecorationTargetProps> = {
[P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P];
};
/**
* a property P will be present if :
* - it is present in both DecorationTargetProps and InjectedProps
* - InjectedProps[P] can satisfy DecorationTargetProps[P]
* ie: decorated component can accept more types than decorator is injecting
*
* For decoration, inject props or ownProps are all optionally
* required by the decorated (right hand side) component.
* But any property required by the decorated component must be satisfied by the injected property.
*/
export declare type Shared<InjectedProps, DecorationTargetProps> = {
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
};
export declare type GetProps<C> = C extends ComponentType<infer P> ? C extends ComponentClass<P> ? ClassAttributes<InstanceType<C>> & P : P : never;
export declare type GetLibraryManagedProps<C> = JSX.LibraryManagedAttributes<C, GetProps<C>>;
export declare type ConnectedComponent<C extends ComponentType<any>, P> = FunctionComponent<P> & NonReactStatics<C> & {
WrappedComponent: C;
};
export declare type ConnectPropsMaybeWithoutContext<TActualOwnProps> = TActualOwnProps extends {
context: any;
} ? Omit<ConnectProps, 'context'> : ConnectProps;
declare type Identity<T> = T;
export declare type Mapped<T> = Identity<{
[k in keyof T]: T[k];
}>;
export declare type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> = <C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(component: C) => ConnectedComponent<C, Mapped<DistributiveOmit<GetLibraryManagedProps<C>, keyof Shared<TInjectedProps, GetLibraryManagedProps<C>>> & TNeedsProps & ConnectPropsMaybeWithoutContext<TNeedsProps & GetProps<C>>>>;
export declare type InferableComponentEnhancer<TInjectedProps> = InferableComponentEnhancerWithProps<TInjectedProps, {}>;
export declare type InferThunkActionCreatorType<TActionCreator extends (...args: any[]) => any> = TActionCreator extends (...args: infer TParams) => (...args: any[]) => infer TReturn ? (...args: TParams) => TReturn : TActionCreator;
export declare type HandleThunkActionCreator<TActionCreator> = TActionCreator extends (...args: any[]) => any ? InferThunkActionCreatorType<TActionCreator> : TActionCreator;
export declare type ResolveThunks<TDispatchProps> = TDispatchProps extends {
[key: string]: any;
} ? {
[C in keyof TDispatchProps]: HandleThunkActionCreator<TDispatchProps[C]>;
} : TDispatchProps;
/**
* This interface allows you to easily create a hook that is properly typed for your
* store's root state.
*
* @example
*
* interface RootState {
* property: string;
* }
*
* const useTypedSelector: TypedUseSelectorHook<RootState> = useSelector;
*/
export interface TypedUseSelectorHook<TState> {
<TSelected>(selector: (state: TState) => TSelected, equalityFn?: EqualityFn<NoInfer<TSelected>>): TSelected;
<Selected = unknown>(selector: (state: TState) => Selected, options?: UseSelectorOptions<Selected>): Selected;
}
export declare type NoInfer<T> = [T][T extends any ? 0 : never];
export {};

1
server/node_modules/react-redux/es/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,25 @@
declare type VoidFunc = () => void;
declare type Listener = {
callback: VoidFunc;
next: Listener | null;
prev: Listener | null;
};
declare function createListenerCollection(): {
clear(): void;
notify(): void;
get(): Listener[];
subscribe(callback: () => void): () => void;
};
declare type ListenerCollection = ReturnType<typeof createListenerCollection>;
export interface Subscription {
addNestedSub: (listener: VoidFunc) => VoidFunc;
notifyNestedSubs: VoidFunc;
handleChangeWrapper: VoidFunc;
isSubscribed: () => boolean;
onStateChange?: VoidFunc | null;
trySubscribe: VoidFunc;
tryUnsubscribe: VoidFunc;
getListeners: () => ListenerCollection;
}
export declare function createSubscription(store: any, parentSub?: Subscription): Subscription;
export {};

View File

@@ -0,0 +1,158 @@
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; // Reasons to keep the subscription active
let subscriptionsAmount = 0; // Is this specific subscription subscribed (or only nested ones?)
let selfSubscribed = false;
function addNestedSub(listener) {
trySubscribe();
const cleanupListener = listeners.subscribe(listener); // cleanup nested sub
let removed = false;
return () => {
if (!removed) {
removed = true;
cleanupListener();
tryUnsubscribe();
}
};
}
function notifyNestedSubs() {
listeners.notify();
}
function handleChangeWrapper() {
if (subscription.onStateChange) {
subscription.onStateChange();
}
}
function isSubscribed() {
return selfSubscribed;
}
function trySubscribe() {
subscriptionsAmount++;
if (!unsubscribe) {
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
listeners = createListenerCollection();
}
}
function tryUnsubscribe() {
subscriptionsAmount--;
if (unsubscribe && subscriptionsAmount === 0) {
unsubscribe();
unsubscribe = undefined;
listeners.clear();
listeners = nullListeners;
}
}
function trySubscribeSelf() {
if (!selfSubscribed) {
selfSubscribed = true;
trySubscribe();
}
}
function tryUnsubscribeSelf() {
if (selfSubscribed) {
selfSubscribed = false;
tryUnsubscribe();
}
}
const subscription = {
addNestedSub,
notifyNestedSubs,
handleChangeWrapper,
isSubscribed,
trySubscribe: trySubscribeSelf,
tryUnsubscribe: tryUnsubscribeSelf,
getListeners: () => listeners
};
return subscription;
}

4
server/node_modules/react-redux/es/utils/batch.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
declare function defaultNoopBatch(callback: () => void): void;
export declare const setBatch: (newBatch: typeof defaultNoopBatch) => typeof defaultNoopBatch;
export declare const getBatch: () => typeof defaultNoopBatch;
export {};

10
server/node_modules/react-redux/es/utils/batch.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
// 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;

View File

@@ -0,0 +1,2 @@
import type { ActionCreatorsMapObject, Dispatch } from 'redux';
export default function bindActionCreators(actionCreators: ActionCreatorsMapObject, dispatch: Dispatch): ActionCreatorsMapObject;

View File

@@ -0,0 +1,13 @@
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;
}

View File

@@ -0,0 +1,5 @@
/**
* @param {any} obj The object to inspect.
* @returns {boolean} True if the argument appears to be a plain object.
*/
export default function isPlainObject(obj: unknown): boolean;

View 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;
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;
}

View File

@@ -0,0 +1 @@
export { unstable_batchedUpdates } from 'react-dom';

View File

@@ -0,0 +1 @@
export { unstable_batchedUpdates } from 'react-dom';

View File

@@ -0,0 +1,2 @@
import { unstable_batchedUpdates } from 'react-native';
export { unstable_batchedUpdates };

View File

@@ -0,0 +1,5 @@
/* eslint-disable import/namespace */
/* eslint-disable import/named */
import { unstable_batchedUpdates } from 'react-native';
export { unstable_batchedUpdates };

View File

@@ -0,0 +1 @@
export default function shallowEqual(objA: any, objB: any): boolean;

View 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;
}
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;
}

View File

@@ -0,0 +1,3 @@
import * as React from 'react';
export declare const canUseDOM: boolean;
export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;

View File

@@ -0,0 +1,12 @@
import * as React 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
// Matches logic in React's `shared/ExecutionEnvironment` file
export const canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
export const useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect;

View File

@@ -0,0 +1,2 @@
import * as React from 'react';
export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;

View File

@@ -0,0 +1,3 @@
import * as React from 'react'; // Under React Native, we know that we always want to use useLayoutEffect
export const useIsomorphicLayoutEffect = React.useLayoutEffect;

View File

@@ -0,0 +1,5 @@
import type { useSyncExternalStore } from 'use-sync-external-store';
import type { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector';
export declare const notInitialized: () => never;
export declare type uSES = typeof useSyncExternalStore;
export declare type uSESWS = typeof useSyncExternalStoreWithSelector;

View File

@@ -0,0 +1,3 @@
export const notInitialized = () => {
throw new Error('uSES not initialized!');
};

View File

@@ -0,0 +1 @@
export default function verifyPlainObject(value: unknown, displayName: string, methodName: string): void;

View 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}.`);
}
}

View File

@@ -0,0 +1,7 @@
/**
* Prints a warning in the console if it exists.
*
* @param {String} message The warning message.
* @returns {void}
*/
export default function warning(message: string): void;

24
server/node_modules/react-redux/es/utils/warning.js generated vendored Normal file
View 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 */
}

View File

@@ -0,0 +1,41 @@
"use strict";
exports.__esModule = true;
var _exportNames = {
batch: true
};
exports.batch = void 0;
var _shim = require("use-sync-external-store/shim");
var _withSelector = require("use-sync-external-store/shim/with-selector");
var _useSelector = require("./hooks/useSelector");
var _connect = require("./components/connect");
var _batch = require("./utils/batch");
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;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _exports[key];
}
});
});
// The "alternate renderers" entry point is primarily here to fall back on a no-op
// version of `unstable_batchedUpdates`, for use with renderers other than ReactDOM/RN.
// Examples include React-Three-Fiber, Ink, etc.
// Because of that, we'll also assume the useSyncExternalStore compat shim is needed.
(0, _useSelector.initializeUseSelector)(_withSelector.useSyncExternalStoreWithSelector);
(0, _connect.initializeConnect)(_shim.useSyncExternalStore);
// For other renderers besides ReactDOM and React Native,
// use the default noop batch function
const batch = (0, _batch.getBatch)();
exports.batch = batch;

View File

@@ -0,0 +1,40 @@
"use strict";
exports.__esModule = true;
exports.default = exports.ReactReduxContext = void 0;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const ContextKey = Symbol.for(`react-redux-context`);
const gT = typeof globalThis !== "undefined" ? globalThis :
/* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
{};
function getContext() {
var _gT$ContextKey;
if (!React.createContext) return {};
const contextMap = (_gT$ContextKey = gT[ContextKey]) != null ? _gT$ContextKey : gT[ContextKey] = new Map();
let realContext = contextMap.get(React.createContext);
if (!realContext) {
realContext = React.createContext(null);
if (process.env.NODE_ENV !== 'production') {
realContext.displayName = 'ReactRedux';
}
contextMap.set(React.createContext, realContext);
}
return realContext;
}
const ReactReduxContext = /*#__PURE__*/getContext();
exports.ReactReduxContext = ReactReduxContext;
var _default = ReactReduxContext;
exports.default = _default;

View File

@@ -0,0 +1,61 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _Context = require("./Context");
var _Subscription = require("../utils/Subscription");
var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function Provider({
store,
context,
children,
serverState,
stabilityCheck = 'once',
noopCheck = 'once'
}) {
const contextValue = React.useMemo(() => {
const subscription = (0, _Subscription.createSubscription)(store);
return {
store,
subscription,
getServerState: serverState ? () => serverState : undefined,
stabilityCheck,
noopCheck
};
}, [store, serverState, stabilityCheck, noopCheck]);
const previousState = React.useMemo(() => store.getState(), [store]);
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
const {
subscription
} = contextValue;
subscription.onStateChange = subscription.notifyNestedSubs;
subscription.trySubscribe();
if (previousState !== store.getState()) {
subscription.notifyNestedSubs();
}
return () => {
subscription.tryUnsubscribe();
subscription.onStateChange = undefined;
};
}, [contextValue, previousState]);
const Context = context || _Context.ReactReduxContext; // @ts-ignore 'AnyAction' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype
return /*#__PURE__*/React.createElement(Context.Provider, {
value: contextValue
}, children);
}
var _default = Provider;
exports.default = _default;

View File

@@ -0,0 +1,438 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = exports.initializeConnect = void 0;
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 _selectorFactory = _interopRequireDefault(require("../connect/selectorFactory"));
var _mapDispatchToProps = require("../connect/mapDispatchToProps");
var _mapStateToProps = require("../connect/mapStateToProps");
var _mergeProps = require("../connect/mergeProps");
var _Subscription = require("../utils/Subscription");
var _useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect");
var _shallowEqual = _interopRequireDefault(require("../utils/shallowEqual"));
var _warning = _interopRequireDefault(require("../utils/warning"));
var _Context = require("./Context");
var _useSyncExternalStore = require("../utils/useSyncExternalStore");
const _excluded = ["reactReduxForwardedRef"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
let useSyncExternalStore = _useSyncExternalStore.notInitialized;
const initializeConnect = fn => {
useSyncExternalStore = fn;
}; // Define some constant arrays just to avoid re-creating these
exports.initializeConnect = initializeConnect;
const EMPTY_ARRAY = [null, 0];
const NO_SUBSCRIPTION_ARRAY = [null, null]; // Attempts to stringify whatever not-really-a-component value we were given
// for logging in an error message
const stringifyComponent = Comp => {
try {
return JSON.stringify(Comp);
} catch (err) {
return String(Comp);
}
};
// This is "just" a `useLayoutEffect`, but with two modifications:
// - we need to fall back to `useEffect` in SSR to avoid annoying warnings
// - we extract this to a separate function to avoid closing over values
// and causing memory leaks
function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => effectFunc(...effectArgs), dependencies);
} // Effect callback, extracted: assign the latest props values to refs for later usage
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, // actualChildProps: unknown,
childPropsFromStoreUpdate, notifyNestedSubs) {
// We want to capture the wrapper props and child props we used for later comparisons
lastWrapperProps.current = wrapperProps;
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();
}
} // Effect callback, extracted: subscribe to the Redux store or nearest connected ancestor,
// check for updates after dispatched actions, and trigger re-renders.
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, isMounted, childPropsFromStoreUpdate, notifyNestedSubs, // forceComponentUpdateDispatch: React.Dispatch<any>,
additionalSubscribeListener) {
// 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 || !isMounted.current) {
// Don't run stale listeners.
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
return;
} // TODO We're currently calling getState ourselves here, rather than letting `uSES` do it
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; // TODO This is hacky and not how `uSES` is meant to be used
// Trigger the React `useSyncExternalStore` subscriber
additionalSubscribeListener();
}
}; // 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;
} // Reducer initial state creation for our update reducer
const initStateUpdates = () => EMPTY_ARRAY;
function strictEqual(a, b) {
return a === b;
}
/**
* Infers the type of props that a connector will inject into a component.
*/
let hasWarnedAboutDeprecatedPureOption = false;
/**
* Connects a React component to a Redux store.
*
* - Without arguments, just wraps the component, without changing the behavior / props
*
* - If 2 params are passed (3rd param, mergeProps, is skipped), default behavior
* is to override ownProps (as stated in the docs), so what remains is everything that's
* not a state or dispatch prop
*
* - When 3rd param is passed, we don't know if ownProps propagate and whether they
* should be valid component props, because it depends on mergeProps implementation.
* As such, it is the user's responsibility to extend ownProps interface from state or
* dispatch props or both when applicable
*
* @param mapStateToProps A function that extracts values from state
* @param mapDispatchToProps Setup for dispatching actions
* @param mergeProps Optional callback to merge state and dispatch props together
* @param options Options for configuring the connection
*
*/
function connect(mapStateToProps, mapDispatchToProps, mergeProps, {
// The `pure` option has been removed, so TS doesn't like us destructuring this to check its existence.
// @ts-ignore
pure,
areStatesEqual = strictEqual,
areOwnPropsEqual = _shallowEqual.default,
areStatePropsEqual = _shallowEqual.default,
areMergedPropsEqual = _shallowEqual.default,
// use React's forwardRef to expose a ref of the wrapped component
forwardRef = false,
// the context consumer to use
context = _Context.ReactReduxContext
} = {}) {
if (process.env.NODE_ENV !== 'production') {
if (pure !== undefined && !hasWarnedAboutDeprecatedPureOption) {
hasWarnedAboutDeprecatedPureOption = true;
(0, _warning.default)('The `pure` option has been removed. `connect` is now always a "pure/memoized" component');
}
}
const Context = context;
const initMapStateToProps = (0, _mapStateToProps.mapStateToPropsFactory)(mapStateToProps);
const initMapDispatchToProps = (0, _mapDispatchToProps.mapDispatchToPropsFactory)(mapDispatchToProps);
const initMergeProps = (0, _mergeProps.mergePropsFactory)(mergeProps);
const shouldHandleStateChanges = Boolean(mapStateToProps);
const 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 connect. Instead received ${stringifyComponent(WrappedComponent)}`);
}
const wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
const displayName = `Connect(${wrappedComponentName})`;
const selectorFactoryOptions = {
shouldHandleStateChanges,
displayName,
wrappedComponentName,
WrappedComponent,
// @ts-ignore
initMapStateToProps,
// @ts-ignore
initMapDispatchToProps,
initMergeProps,
areStatesEqual,
areStatePropsEqual,
areOwnPropsEqual,
areMergedPropsEqual
};
function ConnectFunction(props) {
const [propsContext, reactReduxForwardedRef, wrapperProps] = React.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
} = props,
wrapperProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
return [props.context, reactReduxForwardedRef, wrapperProps];
}, [props]);
const ContextToUse = React.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 && // @ts-ignore
(0, _reactIs.isContextConsumer)( /*#__PURE__*/React.createElement(propsContext.Consumer, null)) ? propsContext : Context;
}, [propsContext, Context]); // Retrieve the store and ancestor subscription via context, if available
const contextValue = 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.
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 getServerState = didStoreComeFromContext ? contextValue.getServerState : store.getState;
const childPropsSelector = React.useMemo(() => {
// The child props selector needs the store reference as an input.
// Re-create this selector whenever the store changes.
return (0, _selectorFactory.default)(store.dispatch, selectorFactoryOptions);
}, [store]);
const [subscription, notifyNestedSubs] = React.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 = (0, _Subscription.createSubscription)(store, didStoreComeFromProps ? undefined : 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 = React.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 (0, _extends2.default)({}, contextValue, {
subscription
});
}, [didStoreComeFromProps, contextValue, subscription]); // Set up refs to coordinate values between the subscription effect and the render logic
const lastChildProps = React.useRef();
const lastWrapperProps = React.useRef(wrapperProps);
const childPropsFromStoreUpdate = React.useRef();
const renderIsScheduled = React.useRef(false);
const isProcessingDispatch = React.useRef(false);
const isMounted = React.useRef(false);
const latestSubscriptionCallbackError = React.useRef();
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
isMounted.current = true;
return () => {
isMounted.current = false;
};
}, []);
const actualChildPropsSelector = React.useMemo(() => {
const selector = () => {
// 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);
};
return selector;
}, [store, 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.
const subscribeForReact = React.useMemo(() => {
const subscribe = reactListener => {
if (!subscription) {
return () => {};
}
return subscribeUpdates(shouldHandleStateChanges, store, subscription, // @ts-ignore
childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, isMounted, childPropsFromStoreUpdate, notifyNestedSubs, reactListener);
};
return subscribe;
}, [subscription]);
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, childPropsFromStoreUpdate, notifyNestedSubs]);
let actualChildProps;
try {
actualChildProps = useSyncExternalStore( // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
subscribeForReact, // TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
// TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
actualChildPropsSelector, getServerState ? () => childPropsSelector(getServerState(), wrapperProps) : actualChildPropsSelector);
} 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)(() => {
latestSubscriptionCallbackError.current = undefined;
childPropsFromStoreUpdate.current = undefined;
lastChildProps.current = actualChildProps;
}); // 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 = React.useMemo(() => {
return (
/*#__PURE__*/
// @ts-ignore
React.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.
const renderedChild = React.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 /*#__PURE__*/React.createElement(ContextToUse.Provider, {
value: overriddenContextValue
}, renderedWrappedComponent);
}
return renderedWrappedComponent;
}, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
return renderedChild;
}
const _Connect = React.memo(ConnectFunction);
// Add a hacky cast to get the right output type
const Connect = _Connect;
Connect.WrappedComponent = WrappedComponent;
Connect.displayName = ConnectFunction.displayName = displayName;
if (forwardRef) {
const _forwarded = React.forwardRef(function forwardConnectRef(props, ref) {
// @ts-ignore
return /*#__PURE__*/React.createElement(Connect, (0, _extends2.default)({}, props, {
reactReduxForwardedRef: ref
}));
});
const forwarded = _forwarded;
forwarded.displayName = displayName;
forwarded.WrappedComponent = WrappedComponent;
return (0, _hoistNonReactStatics.default)(forwarded, WrappedComponent);
}
return (0, _hoistNonReactStatics.default)(Connect, WrappedComponent);
};
return wrapWithConnect;
}
var _default = connect;
exports.default = _default;

View File

@@ -0,0 +1,10 @@
"use strict";
exports.__esModule = true;
exports.createInvalidArgFactory = createInvalidArgFactory;
function createInvalidArgFactory(arg, name) {
return (dispatch, options) => {
throw new Error(`Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.`);
};
}

View File

@@ -0,0 +1,20 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.mapDispatchToPropsFactory = mapDispatchToPropsFactory;
var _bindActionCreators = _interopRequireDefault(require("../utils/bindActionCreators"));
var _wrapMapToProps = require("./wrapMapToProps");
var _invalidArgFactory = require("./invalidArgFactory");
function mapDispatchToPropsFactory(mapDispatchToProps) {
return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? (0, _wrapMapToProps.wrapMapToPropsConstant)(dispatch => // @ts-ignore
(0, _bindActionCreators.default)(mapDispatchToProps, dispatch)) : !mapDispatchToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(dispatch => ({
dispatch
})) : typeof mapDispatchToProps === 'function' ? // @ts-ignore
(0, _wrapMapToProps.wrapMapToPropsFunc)(mapDispatchToProps, 'mapDispatchToProps') : (0, _invalidArgFactory.createInvalidArgFactory)(mapDispatchToProps, 'mapDispatchToProps');
}

View File

@@ -0,0 +1,13 @@
"use strict";
exports.__esModule = true;
exports.mapStateToPropsFactory = mapStateToPropsFactory;
var _wrapMapToProps = require("./wrapMapToProps");
var _invalidArgFactory = require("./invalidArgFactory");
function mapStateToPropsFactory(mapStateToProps) {
return !mapStateToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(() => ({})) : typeof mapStateToProps === 'function' ? // @ts-ignore
(0, _wrapMapToProps.wrapMapToPropsFunc)(mapStateToProps, 'mapStateToProps') : (0, _invalidArgFactory.createInvalidArgFactory)(mapStateToProps, 'mapStateToProps');
}

View File

@@ -0,0 +1,46 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.defaultMergeProps = defaultMergeProps;
exports.wrapMergePropsFunc = wrapMergePropsFunc;
exports.mergePropsFactory = mergePropsFactory;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _verifyPlainObject = _interopRequireDefault(require("../utils/verifyPlainObject"));
var _invalidArgFactory = require("./invalidArgFactory");
function defaultMergeProps(stateProps, dispatchProps, ownProps) {
// @ts-ignore
return (0, _extends2.default)({}, ownProps, stateProps, dispatchProps);
}
function wrapMergePropsFunc(mergeProps) {
return function initMergePropsProxy(dispatch, {
displayName,
areMergedPropsEqual
}) {
let hasRunOnce = false;
let mergedProps;
return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
const nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
if (hasRunOnce) {
if (!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 mergePropsFactory(mergeProps) {
return !mergeProps ? () => defaultMergeProps : typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : (0, _invalidArgFactory.createInvalidArgFactory)(mergeProps, 'mergeProps');
}

View File

@@ -0,0 +1,95 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.pureFinalPropsSelectorFactory = pureFinalPropsSelectorFactory;
exports.default = finalPropsSelectorFactory;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _verifySubselectors = _interopRequireDefault(require("./verifySubselectors"));
const _excluded = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"];
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
// The selector returned by selectorFactory will memoize its results,
// allowing connect's shouldComponentUpdate to return false if final
// props have not changed.
function finalPropsSelectorFactory(dispatch, _ref) {
let {
initMapStateToProps,
initMapDispatchToProps,
initMergeProps
} = _ref,
options = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
const mapStateToProps = initMapStateToProps(dispatch, options);
const mapDispatchToProps = initMapDispatchToProps(dispatch, options);
const mergeProps = initMergeProps(dispatch, options);
if (process.env.NODE_ENV !== 'production') {
(0, _verifySubselectors.default)(mapStateToProps, mapDispatchToProps, mergeProps);
}
return pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
}

View File

@@ -0,0 +1,24 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = verifySubselectors;
var _warning = _interopRequireDefault(require("../utils/warning"));
function verify(selector, methodName) {
if (!selector) {
throw new Error(`Unexpected value for ${methodName} in connect.`);
} else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
(0, _warning.default)(`The selector for ${methodName} of connect did not specify a value for dependsOnOwnProps.`);
}
}
}
function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps) {
verify(mapStateToProps, 'mapStateToProps');
verify(mapDispatchToProps, 'mapDispatchToProps');
verify(mergeProps, 'mergeProps');
}

View File

@@ -0,0 +1,82 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.wrapMapToPropsConstant = wrapMapToPropsConstant;
exports.getDependsOnOwnProps = getDependsOnOwnProps;
exports.wrapMapToPropsFunc = wrapMapToPropsFunc;
var _verifyPlainObject = _interopRequireDefault(require("../utils/verifyPlainObject"));
function wrapMapToPropsConstant( // * Note:
// It seems that the dispatch argument
// could be a dispatch function in some cases (ex: whenMapDispatchToPropsIsMissing)
// and a state object in some others (ex: whenMapStateToPropsIsMissing)
// eslint-disable-next-line no-unused-vars
getConstant) {
return function initConstantSelector(dispatch) {
const constant = getConstant(dispatch);
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..
// TODO Can this get pulled out so that we can subscribe directly to the store if we don't need ownProps?
function getDependsOnOwnProps(mapToProps) {
return mapToProps.dependsOnOwnProps ? 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, {
displayName
}) {
const proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch, undefined);
}; // 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') (0, _verifyPlainObject.default)(props, displayName, methodName);
return props;
};
return proxy;
};
}

105
server/node_modules/react-redux/lib/exports.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
var _exportNames = {
Provider: true,
connect: true,
ReactReduxContext: true,
useDispatch: true,
createDispatchHook: true,
useSelector: true,
createSelectorHook: true,
useStore: true,
createStoreHook: true,
shallowEqual: true
};
Object.defineProperty(exports, "Provider", {
enumerable: true,
get: function () {
return _Provider.default;
}
});
Object.defineProperty(exports, "connect", {
enumerable: true,
get: function () {
return _connect.default;
}
});
Object.defineProperty(exports, "ReactReduxContext", {
enumerable: true,
get: function () {
return _Context.ReactReduxContext;
}
});
Object.defineProperty(exports, "useDispatch", {
enumerable: true,
get: function () {
return _useDispatch.useDispatch;
}
});
Object.defineProperty(exports, "createDispatchHook", {
enumerable: true,
get: function () {
return _useDispatch.createDispatchHook;
}
});
Object.defineProperty(exports, "useSelector", {
enumerable: true,
get: function () {
return _useSelector.useSelector;
}
});
Object.defineProperty(exports, "createSelectorHook", {
enumerable: true,
get: function () {
return _useSelector.createSelectorHook;
}
});
Object.defineProperty(exports, "useStore", {
enumerable: true,
get: function () {
return _useStore.useStore;
}
});
Object.defineProperty(exports, "createStoreHook", {
enumerable: true,
get: function () {
return _useStore.createStoreHook;
}
});
Object.defineProperty(exports, "shallowEqual", {
enumerable: true,
get: function () {
return _shallowEqual.default;
}
});
var _Provider = _interopRequireDefault(require("./components/Provider"));
var _connect = _interopRequireDefault(require("./components/connect"));
var _Context = require("./components/Context");
var _useDispatch = require("./hooks/useDispatch");
var _useSelector = require("./hooks/useSelector");
var _useStore = require("./hooks/useStore");
var _shallowEqual = _interopRequireDefault(require("./utils/shallowEqual"));
var _types = require("./types");
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _types[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _types[key];
}
});
});

View File

@@ -0,0 +1,50 @@
"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 = _Context.ReactReduxContext) {
const useStore = // @ts-ignore
context === _Context.ReactReduxContext ? _useStore.useStore : (0, _useStore.createStoreHook)(context);
return function useDispatch() {
const store = useStore(); // @ts-ignore
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>
* )
* }
*/
const useDispatch = /*#__PURE__*/createDispatchHook();
exports.useDispatch = useDispatch;

View File

@@ -0,0 +1,48 @@
"use strict";
exports.__esModule = true;
exports.createReduxContextHook = createReduxContextHook;
exports.useReduxContext = void 0;
var _react = require("react");
var _Context = require("../components/Context");
/**
* Hook factory, which creates a `useReduxContext` hook bound to a given context. This is a low-level
* hook that you should usually not need to call directly.
*
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
* @returns {Function} A `useReduxContext` hook bound to the specified context.
*/
function createReduxContextHook(context = _Context.ReactReduxContext) {
return function useReduxContext() {
const contextValue = (0, _react.useContext)(context);
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;
};
}
/**
* 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 = () => {
* const { store } = useReduxContext()
* return <div>{store.getState()}</div>
* }
*/
const useReduxContext = /*#__PURE__*/createReduxContextHook();
exports.useReduxContext = useReduxContext;

View File

@@ -0,0 +1,156 @@
"use strict";
exports.__esModule = true;
exports.createSelectorHook = createSelectorHook;
exports.useSelector = exports.initializeUseSelector = void 0;
var _react = require("react");
var _useReduxContext = require("./useReduxContext");
var _Context = require("../components/Context");
var _useSyncExternalStore = require("../utils/useSyncExternalStore");
let useSyncExternalStoreWithSelector = _useSyncExternalStore.notInitialized;
const initializeUseSelector = fn => {
useSyncExternalStoreWithSelector = fn;
};
exports.initializeUseSelector = initializeUseSelector;
const refEquality = (a, b) => a === b;
/**
* 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 = _Context.ReactReduxContext) {
const useReduxContext = context === _Context.ReactReduxContext ? _useReduxContext.useReduxContext : (0, _useReduxContext.createReduxContextHook)(context);
return function useSelector(selector, equalityFnOrOptions = {}) {
const {
equalityFn = refEquality,
stabilityCheck = undefined,
noopCheck = undefined
} = typeof equalityFnOrOptions === 'function' ? {
equalityFn: equalityFnOrOptions
} : equalityFnOrOptions;
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,
getServerState,
stabilityCheck: globalStabilityCheck,
noopCheck: globalNoopCheck
} = useReduxContext();
const firstRun = (0, _react.useRef)(true);
const wrappedSelector = (0, _react.useCallback)({
[selector.name](state) {
const selected = selector(state);
if (process.env.NODE_ENV !== 'production') {
const finalStabilityCheck = typeof stabilityCheck === 'undefined' ? globalStabilityCheck : stabilityCheck;
if (finalStabilityCheck === 'always' || finalStabilityCheck === 'once' && firstRun.current) {
const toCompare = selector(state);
if (!equalityFn(selected, toCompare)) {
let stack = undefined;
try {
throw new Error();
} catch (e) {
;
({
stack
} = e);
}
console.warn('Selector ' + (selector.name || 'unknown') + ' returned a different result when called with the same parameters. This can lead to unnecessary rerenders.' + '\nSelectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization', {
state,
selected,
selected2: toCompare,
stack
});
}
}
const finalNoopCheck = typeof noopCheck === 'undefined' ? globalNoopCheck : noopCheck;
if (finalNoopCheck === 'always' || finalNoopCheck === 'once' && firstRun.current) {
// @ts-ignore
if (selected === state) {
let stack = undefined;
try {
throw new Error();
} catch (e) {
;
({
stack
} = e);
}
console.warn('Selector ' + (selector.name || 'unknown') + ' returned the root state when called. This can lead to unnecessary rerenders.' + '\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.', {
stack
});
}
}
if (firstRun.current) firstRun.current = false;
}
return selected;
}
}[selector.name], [selector, globalStabilityCheck, stabilityCheck]);
const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, wrappedSelector, equalityFn);
(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>
* }
*/
const useSelector = /*#__PURE__*/createSelectorHook();
exports.useSelector = useSelector;

47
server/node_modules/react-redux/lib/hooks/useStore.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
"use strict";
exports.__esModule = true;
exports.createStoreHook = createStoreHook;
exports.useStore = void 0;
var _Context = require("../components/Context");
var _useReduxContext = 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 = _Context.ReactReduxContext) {
const useReduxContext = // @ts-ignore
context === _Context.ReactReduxContext ? _useReduxContext.useReduxContext : // @ts-ignore
(0, _useReduxContext.createReduxContextHook)(context);
return function useStore() {
const {
store
} = useReduxContext(); // @ts-ignore
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>
* }
*/
const useStore = /*#__PURE__*/createStoreHook();
exports.useStore = useStore;

46
server/node_modules/react-redux/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
"use strict";
exports.__esModule = true;
var _exportNames = {
batch: true
};
Object.defineProperty(exports, "batch", {
enumerable: true,
get: function () {
return _reactBatchedUpdates.unstable_batchedUpdates;
}
});
var _shim = require("use-sync-external-store/shim");
var _withSelector = require("use-sync-external-store/shim/with-selector");
var _reactBatchedUpdates = require("./utils/reactBatchedUpdates");
var _batch = require("./utils/batch");
var _useSelector = require("./hooks/useSelector");
var _connect = require("./components/connect");
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;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _exports[key];
}
});
});
// The primary entry point assumes we're working with standard ReactDOM/RN, but
// older versions that do not include `useSyncExternalStore` (React 16.9 - 17.x).
// Because of that, the useSyncExternalStore compat shim is needed.
(0, _useSelector.initializeUseSelector)(_withSelector.useSyncExternalStoreWithSelector);
(0, _connect.initializeConnect)(_shim.useSyncExternalStore); // Enable batched updates in our subscriptions for use
// with standard React renderers (ReactDOM, React Native)
(0, _batch.setBatch)(_reactBatchedUpdates.unstable_batchedUpdates);

52
server/node_modules/react-redux/lib/next.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
"use strict";
exports.__esModule = true;
var _exportNames = {
batch: true
};
Object.defineProperty(exports, "batch", {
enumerable: true,
get: function () {
return _reactBatchedUpdates.unstable_batchedUpdates;
}
});
var React = _interopRequireWildcard(require("react"));
var _withSelector = require("use-sync-external-store/with-selector");
var _reactBatchedUpdates = require("./utils/reactBatchedUpdates");
var _batch = require("./utils/batch");
var _useSelector = require("./hooks/useSelector");
var _connect = require("./components/connect");
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;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _exports[key];
}
});
});
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// The secondary entry point assumes we are working with React 18, and thus have
// useSyncExternalStore available. We can import that directly from React itself.
// The useSyncExternalStoreWithSelector has to be imported, but we can use the
// non-shim version. This shaves off the byte size of the shim.
(0, _useSelector.initializeUseSelector)(_withSelector.useSyncExternalStoreWithSelector);
(0, _connect.initializeConnect)(React.useSyncExternalStore); // Enable batched updates in our subscriptions for use
// with standard React renderers (ReactDOM, React Native)
(0, _batch.setBatch)(_reactBatchedUpdates.unstable_batchedUpdates);

1
server/node_modules/react-redux/lib/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";

View File

@@ -0,0 +1,162 @@
"use strict";
exports.__esModule = true;
exports.createSubscription = createSubscription;
var _batch = require("./batch");
function createListenerCollection() {
const batch = (0, _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: () => []
};
function createSubscription(store, parentSub) {
let unsubscribe;
let listeners = nullListeners; // Reasons to keep the subscription active
let subscriptionsAmount = 0; // Is this specific subscription subscribed (or only nested ones?)
let selfSubscribed = false;
function addNestedSub(listener) {
trySubscribe();
const cleanupListener = listeners.subscribe(listener); // cleanup nested sub
let removed = false;
return () => {
if (!removed) {
removed = true;
cleanupListener();
tryUnsubscribe();
}
};
}
function notifyNestedSubs() {
listeners.notify();
}
function handleChangeWrapper() {
if (subscription.onStateChange) {
subscription.onStateChange();
}
}
function isSubscribed() {
return selfSubscribed;
}
function trySubscribe() {
subscriptionsAmount++;
if (!unsubscribe) {
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
listeners = createListenerCollection();
}
}
function tryUnsubscribe() {
subscriptionsAmount--;
if (unsubscribe && subscriptionsAmount === 0) {
unsubscribe();
unsubscribe = undefined;
listeners.clear();
listeners = nullListeners;
}
}
function trySubscribeSelf() {
if (!selfSubscribed) {
selfSubscribed = true;
trySubscribe();
}
}
function tryUnsubscribeSelf() {
if (selfSubscribed) {
selfSubscribed = false;
tryUnsubscribe();
}
}
const subscription = {
addNestedSub,
notifyNestedSubs,
handleChangeWrapper,
isSubscribed,
trySubscribe: trySubscribeSelf,
tryUnsubscribe: tryUnsubscribeSelf,
getListeners: () => listeners
};
return subscription;
}

20
server/node_modules/react-redux/lib/utils/batch.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
exports.__esModule = true;
exports.getBatch = exports.setBatch = void 0;
// Default to a dummy "batch" implementation that just runs the callback
function defaultNoopBatch(callback) {
callback();
}
let batch = defaultNoopBatch; // Allow injecting another batching function later
const setBatch = newBatch => batch = newBatch; // Supply a getter just to skip dealing with ESM bindings
exports.setBatch = setBatch;
const getBatch = () => batch;
exports.getBatch = getBatch;

View File

@@ -0,0 +1,18 @@
"use strict";
exports.__esModule = true;
exports.default = bindActionCreators;
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;
}

View 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;
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;
}

View File

@@ -0,0 +1,11 @@
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "unstable_batchedUpdates", {
enumerable: true,
get: function () {
return _reactDom.unstable_batchedUpdates;
}
});
var _reactDom = require("react-dom");

View File

@@ -0,0 +1,11 @@
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "unstable_batchedUpdates", {
enumerable: true,
get: function () {
return _reactNative.unstable_batchedUpdates;
}
});
var _reactNative = require("react-native");

View 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;
}
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;
}

View File

@@ -0,0 +1,24 @@
"use strict";
exports.__esModule = true;
exports.useIsomorphicLayoutEffect = exports.canUseDOM = void 0;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// 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
// Matches logic in React's `shared/ExecutionEnvironment` file
const canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
exports.canUseDOM = canUseDOM;
const useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect;
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;

View File

@@ -0,0 +1,14 @@
"use strict";
exports.__esModule = true;
exports.useIsomorphicLayoutEffect = void 0;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// Under React Native, we know that we always want to use useLayoutEffect
const useIsomorphicLayoutEffect = React.useLayoutEffect;
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;

View File

@@ -0,0 +1,10 @@
"use strict";
exports.__esModule = true;
exports.notInitialized = void 0;
const notInitialized = () => {
throw new Error('uSES not initialized!');
};
exports.notInitialized = notInitialized;

View File

@@ -0,0 +1,16 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
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
server/node_modules/react-redux/lib/utils/warning.js generated vendored Normal file
View 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 */
}

130
server/node_modules/react-redux/package.json generated vendored Normal file
View File

@@ -0,0 +1,130 @@
{
"name": "react-redux",
"version": "8.1.3",
"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",
"types": "./es/index.d.ts",
"unpkg": "dist/react-redux.js",
"module": "es/index.js",
"files": [
"dist",
"lib",
"src",
"es"
],
"scripts": {
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --extensions \".js,.ts,.tsx\" --out-dir lib",
"build:es": "babel src --extensions \".js,.ts,.tsx\" --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:types": "tsc",
"build": "yarn build:types && yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:umd:min",
"clean": "rimraf lib dist es coverage",
"api-types": "api-extractor run --local",
"format": "prettier --write \"{src,test}/**/*.{js,ts,tsx}\" \"docs/**/*.md\"",
"lint": "eslint src --ext ts,tsx,js test/utils test/components test/hooks",
"prepare": "yarn clean && yarn build",
"pretest": "yarn lint",
"test": "jest",
"type-tests": "yarn tsc -p test/typetests/tsconfig.json",
"coverage": "codecov"
},
"peerDependencies": {
"@types/react": "^16.8 || ^17.0 || ^18.0",
"@types/react-dom": "^16.8 || ^17.0 || ^18.0",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0",
"react-native": ">=0.59",
"redux": "^4 || ^5.0.0-beta.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
},
"react-dom": {
"optional": true
},
"react-native": {
"optional": true
},
"redux": {
"optional": true
}
},
"dependencies": {
"@babel/runtime": "^7.12.1",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/use-sync-external-store": "^0.0.3",
"hoist-non-react-statics": "^3.3.2",
"react-is": "^18.0.0",
"use-sync-external-store": "^1.0.0"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-decorators": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-transform-react-display-name": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-typescript": "^7.14.5",
"@microsoft/api-extractor": "^7.18.1",
"@reduxjs/toolkit": "^1.9.5",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.3",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/jest-native": "^3.4.3",
"@testing-library/react": "13.0.0",
"@testing-library/react-12": "npm:@testing-library/react@^12",
"@testing-library/react-hooks": "^3.4.2",
"@testing-library/react-native": "^7.1.0",
"@types/object-assign": "^4.0.30",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/react-is": "^17",
"@types/react-native": "^0.67.4",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.1",
"codecov": "^3.8.0",
"cross-env": "^7.0.2",
"eslint": "^7.12.0",
"eslint-config-prettier": "^6.14.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"glob": "^7.1.6",
"jest": "^26.6.1",
"prettier": "^2.1.2",
"react": "18.0.0",
"react-17": "npm:react@^17",
"react-dom": "18.0.0",
"react-dom-17": "npm:react-dom@^17",
"react-native": "^0.64.1",
"react-test-renderer": "18.0.0",
"react-test-renderer-17": "npm:react-test-renderer@^17",
"redux": "^4.0.5",
"rimraf": "^3.0.2",
"rollup": "^2.32.1",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "26.5.6",
"typescript": "^4.3.4"
}
}

View File

@@ -0,0 +1,23 @@
// The "alternate renderers" entry point is primarily here to fall back on a no-op
// version of `unstable_batchedUpdates`, for use with renderers other than ReactDOM/RN.
// Examples include React-Three-Fiber, Ink, etc.
// Because of that, we'll also assume the useSyncExternalStore compat shim is needed.
import { useSyncExternalStore } from 'use-sync-external-store/shim'
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
import { initializeUseSelector } from './hooks/useSelector'
import { initializeConnect } from './components/connect'
initializeUseSelector(useSyncExternalStoreWithSelector)
initializeConnect(useSyncExternalStore)
import { getBatch } from './utils/batch'
// For other renderers besides ReactDOM and React Native,
// use the default noop batch function
const batch = getBatch()
export { batch }
export * from './exports'

View File

@@ -0,0 +1,48 @@
import * as React from 'react'
import type { Context } from 'react'
import type { Action, AnyAction, Store } from 'redux'
import type { Subscription } from '../utils/Subscription'
import type { CheckFrequency } from '../hooks/useSelector'
export interface ReactReduxContextValue<
SS = any,
A extends Action = AnyAction
> {
store: Store<SS, A>
subscription: Subscription
getServerState?: () => SS
stabilityCheck: CheckFrequency
noopCheck: CheckFrequency
}
const ContextKey = Symbol.for(`react-redux-context`)
const gT: {
[ContextKey]?: Map<
typeof React.createContext,
Context<ReactReduxContextValue>
>
} = (typeof globalThis !== "undefined" ? globalThis : /* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */ {}) as any;
function getContext(): Context<ReactReduxContextValue> {
if (!React.createContext) return {} as any
const contextMap = (gT[ContextKey] ??= new Map<
typeof React.createContext,
Context<ReactReduxContextValue>
>())
let realContext = contextMap.get(React.createContext)
if (!realContext) {
realContext = React.createContext<ReactReduxContextValue>(null as any)
if (process.env.NODE_ENV !== 'production') {
realContext.displayName = 'ReactRedux'
}
contextMap.set(React.createContext, realContext)
}
return realContext
}
export const ReactReduxContext = /*#__PURE__*/ getContext()
export type ReactReduxContextInstance = typeof ReactReduxContext
export default ReactReduxContext

Some files were not shown because too many files have changed in this diff Show More