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

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 */
}