This commit is contained in:
77
frontend/node_modules/redux/src/applyMiddleware.ts
generated
vendored
Normal file
77
frontend/node_modules/redux/src/applyMiddleware.ts
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import compose from './compose'
|
||||
import { Middleware, MiddlewareAPI } from './types/middleware'
|
||||
import { StoreEnhancer, Dispatch } from './types/store'
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param middlewares The middleware chain to be applied.
|
||||
* @returns A store enhancer applying the middleware.
|
||||
*
|
||||
* @template Ext Dispatch signature added by a middleware.
|
||||
* @template S The type of the state supported by a middleware.
|
||||
*/
|
||||
export default function applyMiddleware(): StoreEnhancer
|
||||
export default function applyMiddleware<Ext1, S>(
|
||||
middleware1: Middleware<Ext1, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 }>
|
||||
export default function applyMiddleware<Ext1, Ext2, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 }>
|
||||
export default function applyMiddleware<Ext1, Ext2, Ext3, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>,
|
||||
middleware3: Middleware<Ext3, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 }>
|
||||
export default function applyMiddleware<Ext1, Ext2, Ext3, Ext4, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>,
|
||||
middleware3: Middleware<Ext3, S, any>,
|
||||
middleware4: Middleware<Ext4, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 }>
|
||||
export default function applyMiddleware<Ext1, Ext2, Ext3, Ext4, Ext5, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>,
|
||||
middleware3: Middleware<Ext3, S, any>,
|
||||
middleware4: Middleware<Ext4, S, any>,
|
||||
middleware5: Middleware<Ext5, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 & Ext5 }>
|
||||
export default function applyMiddleware<Ext, S = any>(
|
||||
...middlewares: Middleware<any, S, any>[]
|
||||
): StoreEnhancer<{ dispatch: Ext }>
|
||||
export default function applyMiddleware(
|
||||
...middlewares: Middleware[]
|
||||
): StoreEnhancer<any> {
|
||||
return createStore => (reducer, preloadedState) => {
|
||||
const store = createStore(reducer, preloadedState)
|
||||
let dispatch: Dispatch = () => {
|
||||
throw new Error(
|
||||
'Dispatching while constructing your middleware is not allowed. ' +
|
||||
'Other middleware would not be applied to this dispatch.'
|
||||
)
|
||||
}
|
||||
|
||||
const middlewareAPI: MiddlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: (action, ...args) => dispatch(action, ...args)
|
||||
}
|
||||
const chain = middlewares.map(middleware => middleware(middlewareAPI))
|
||||
dispatch = compose<typeof dispatch>(...chain)(store.dispatch)
|
||||
|
||||
return {
|
||||
...store,
|
||||
dispatch
|
||||
}
|
||||
}
|
||||
}
|
||||
79
frontend/node_modules/redux/src/bindActionCreators.ts
generated
vendored
Normal file
79
frontend/node_modules/redux/src/bindActionCreators.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Dispatch } from './types/store'
|
||||
import { ActionCreator, ActionCreatorsMapObject, Action } from './types/actions'
|
||||
import { kindOf } from './utils/kindOf'
|
||||
|
||||
function bindActionCreator<A extends Action>(
|
||||
actionCreator: ActionCreator<A>,
|
||||
dispatch: Dispatch<A>
|
||||
) {
|
||||
return function (this: any, ...args: any[]) {
|
||||
return dispatch(actionCreator.apply(this, args))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass an action creator as the first argument,
|
||||
* and get a dispatch wrapped function in return.
|
||||
*
|
||||
* @param actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
export default function bindActionCreators<A, C extends ActionCreator<A>>(
|
||||
actionCreator: C,
|
||||
dispatch: Dispatch
|
||||
): C
|
||||
|
||||
export default function bindActionCreators<
|
||||
A extends ActionCreator<any>,
|
||||
B extends ActionCreator<any>
|
||||
>(actionCreator: A, dispatch: Dispatch): B
|
||||
|
||||
export default function bindActionCreators<
|
||||
A,
|
||||
M extends ActionCreatorsMapObject<A>
|
||||
>(actionCreators: M, dispatch: Dispatch): M
|
||||
export default function bindActionCreators<
|
||||
M extends ActionCreatorsMapObject,
|
||||
N extends ActionCreatorsMapObject
|
||||
>(actionCreators: M, dispatch: Dispatch): N
|
||||
|
||||
export default function bindActionCreators(
|
||||
actionCreators: ActionCreator<any> | ActionCreatorsMapObject,
|
||||
dispatch: Dispatch
|
||||
) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch)
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error(
|
||||
`bindActionCreators expected an object or a function, but instead received: '${kindOf(
|
||||
actionCreators
|
||||
)}'. ` +
|
||||
`Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?`
|
||||
)
|
||||
}
|
||||
|
||||
const boundActionCreators: ActionCreatorsMapObject = {}
|
||||
for (const key in actionCreators) {
|
||||
const actionCreator = actionCreators[key]
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch)
|
||||
}
|
||||
}
|
||||
return boundActionCreators
|
||||
}
|
||||
201
frontend/node_modules/redux/src/combineReducers.ts
generated
vendored
Normal file
201
frontend/node_modules/redux/src/combineReducers.ts
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
import { Action } from './types/actions'
|
||||
import {
|
||||
ActionFromReducersMapObject,
|
||||
PreloadedStateShapeFromReducersMapObject,
|
||||
Reducer,
|
||||
StateFromReducersMapObject
|
||||
} from './types/reducers'
|
||||
|
||||
import ActionTypes from './utils/actionTypes'
|
||||
import isPlainObject from './utils/isPlainObject'
|
||||
import warning from './utils/warning'
|
||||
import { kindOf } from './utils/kindOf'
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(
|
||||
inputState: object,
|
||||
reducers: { [key: string]: Reducer<any, any, any> },
|
||||
action: Action,
|
||||
unexpectedKeyCache: { [key: string]: true }
|
||||
) {
|
||||
const reducerKeys = Object.keys(reducers)
|
||||
const argumentName =
|
||||
action && action.type === ActionTypes.INIT
|
||||
? 'preloadedState argument passed to createStore'
|
||||
: 'previous state received by the reducer'
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return (
|
||||
'Store does not have a valid reducer. Make sure the argument passed ' +
|
||||
'to combineReducers is an object whose values are reducers.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return (
|
||||
`The ${argumentName} has unexpected type of "${kindOf(
|
||||
inputState
|
||||
)}". Expected argument to be an object with the following ` +
|
||||
`keys: "${reducerKeys.join('", "')}"`
|
||||
)
|
||||
}
|
||||
|
||||
const unexpectedKeys = Object.keys(inputState).filter(
|
||||
key => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]
|
||||
)
|
||||
|
||||
unexpectedKeys.forEach(key => {
|
||||
unexpectedKeyCache[key] = true
|
||||
})
|
||||
|
||||
if (action && action.type === ActionTypes.REPLACE) return
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return (
|
||||
`Unexpected ${unexpectedKeys.length > 1 ? 'keys' : 'key'} ` +
|
||||
`"${unexpectedKeys.join('", "')}" found in ${argumentName}. ` +
|
||||
`Expected to find one of the known reducer keys instead: ` +
|
||||
`"${reducerKeys.join('", "')}". Unexpected keys will be ignored.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers: {
|
||||
[key: string]: Reducer<any, any, any>
|
||||
}) {
|
||||
Object.keys(reducers).forEach(key => {
|
||||
const reducer = reducers[key]
|
||||
const initialState = reducer(undefined, { type: ActionTypes.INIT })
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error(
|
||||
`The slice reducer for key "${key}" returned undefined during initialization. ` +
|
||||
`If the state passed to the reducer is undefined, you must ` +
|
||||
`explicitly return the initial state. The initial state may ` +
|
||||
`not be undefined. If you don't want to set a value for this reducer, ` +
|
||||
`you can use null instead of undefined.`
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
typeof reducer(undefined, {
|
||||
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
||||
}) === 'undefined'
|
||||
) {
|
||||
throw new Error(
|
||||
`The slice reducer for key "${key}" returned undefined when probed with a random type. ` +
|
||||
`Don't try to handle '${ActionTypes.INIT}' or other actions in "redux/*" ` +
|
||||
`namespace. They are considered private. Instead, you must return the ` +
|
||||
`current state for any unknown actions, unless it is undefined, ` +
|
||||
`in which case you must return the initial state, regardless of the ` +
|
||||
`action type. The initial state may not be undefined, but can be null.`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @template S Combined state object type.
|
||||
*
|
||||
* @param reducers An object whose values correspond to different reducer
|
||||
* functions that need to be combined into one. One handy way to obtain it
|
||||
* is to use `import * as reducers` syntax. The reducers may never
|
||||
* return undefined for any action. Instead, they should return their
|
||||
* initial state if the state passed to them was undefined, and the current
|
||||
* state for any unrecognized action.
|
||||
*
|
||||
* @returns A reducer function that invokes every reducer inside the passed
|
||||
* object, and builds a state object with the same shape.
|
||||
*/
|
||||
export default function combineReducers<M>(
|
||||
reducers: M
|
||||
): M[keyof M] extends Reducer<any, any, any> | undefined
|
||||
? Reducer<
|
||||
StateFromReducersMapObject<M>,
|
||||
ActionFromReducersMapObject<M>,
|
||||
Partial<PreloadedStateShapeFromReducersMapObject<M>>
|
||||
>
|
||||
: never
|
||||
export default function combineReducers(reducers: {
|
||||
[key: string]: Reducer<any, any, any>
|
||||
}) {
|
||||
const reducerKeys = Object.keys(reducers)
|
||||
const finalReducers: { [key: string]: Reducer<any, any, any> } = {}
|
||||
for (let i = 0; i < reducerKeys.length; i++) {
|
||||
const key = reducerKeys[i]
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning(`No reducer provided for key "${key}"`)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key]
|
||||
}
|
||||
}
|
||||
const finalReducerKeys = Object.keys(finalReducers)
|
||||
|
||||
// This is used to make sure we don't warn about the same
|
||||
// keys multiple times.
|
||||
let unexpectedKeyCache: { [key: string]: true }
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
unexpectedKeyCache = {}
|
||||
}
|
||||
|
||||
let shapeAssertionError: unknown
|
||||
try {
|
||||
assertReducerShape(finalReducers)
|
||||
} catch (e) {
|
||||
shapeAssertionError = e
|
||||
}
|
||||
|
||||
return function combination(
|
||||
state: StateFromReducersMapObject<typeof reducers> = {},
|
||||
action: Action
|
||||
) {
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const warningMessage = getUnexpectedStateShapeWarningMessage(
|
||||
state,
|
||||
finalReducers,
|
||||
action,
|
||||
unexpectedKeyCache
|
||||
)
|
||||
if (warningMessage) {
|
||||
warning(warningMessage)
|
||||
}
|
||||
}
|
||||
|
||||
let hasChanged = false
|
||||
const nextState: StateFromReducersMapObject<typeof reducers> = {}
|
||||
for (let i = 0; i < finalReducerKeys.length; i++) {
|
||||
const key = finalReducerKeys[i]
|
||||
const reducer = finalReducers[key]
|
||||
const previousStateForKey = state[key]
|
||||
const nextStateForKey = reducer(previousStateForKey, action)
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
const actionType = action && action.type
|
||||
throw new Error(
|
||||
`When called with an action of type ${
|
||||
actionType ? `"${String(actionType)}"` : '(unknown type)'
|
||||
}, the slice reducer for key "${key}" returned undefined. ` +
|
||||
`To ignore an action, you must explicitly return the previous state. ` +
|
||||
`If you want this reducer to hold no value, you can return null instead of undefined.`
|
||||
)
|
||||
}
|
||||
nextState[key] = nextStateForKey
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey
|
||||
}
|
||||
hasChanged =
|
||||
hasChanged || finalReducerKeys.length !== Object.keys(state).length
|
||||
return hasChanged ? nextState : state
|
||||
}
|
||||
}
|
||||
61
frontend/node_modules/redux/src/compose.ts
generated
vendored
Normal file
61
frontend/node_modules/redux/src/compose.ts
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
type Func<T extends any[], R> = (...a: T) => R
|
||||
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for the
|
||||
* resulting composite function.
|
||||
*
|
||||
* @param funcs The functions to compose.
|
||||
* @returns A function obtained by composing the argument functions from right
|
||||
* to left. For example, `compose(f, g, h)` is identical to doing
|
||||
* `(...args) => f(g(h(...args)))`.
|
||||
*/
|
||||
export default function compose(): <R>(a: R) => R
|
||||
|
||||
export default function compose<F extends Function>(f: F): F
|
||||
|
||||
/* two functions */
|
||||
export default function compose<A, T extends any[], R>(
|
||||
f1: (a: A) => R,
|
||||
f2: Func<T, A>
|
||||
): Func<T, R>
|
||||
|
||||
/* three functions */
|
||||
export default function compose<A, B, T extends any[], R>(
|
||||
f1: (b: B) => R,
|
||||
f2: (a: A) => B,
|
||||
f3: Func<T, A>
|
||||
): Func<T, R>
|
||||
|
||||
/* four functions */
|
||||
export default function compose<A, B, C, T extends any[], R>(
|
||||
f1: (c: C) => R,
|
||||
f2: (b: B) => C,
|
||||
f3: (a: A) => B,
|
||||
f4: Func<T, A>
|
||||
): Func<T, R>
|
||||
|
||||
/* rest */
|
||||
export default function compose<R>(
|
||||
f1: (a: any) => R,
|
||||
...funcs: Function[]
|
||||
): (...args: any[]) => R
|
||||
|
||||
export default function compose<R>(...funcs: Function[]): (...args: any[]) => R
|
||||
|
||||
export default function compose(...funcs: Function[]) {
|
||||
if (funcs.length === 0) {
|
||||
// infer the argument type so it is usable in inference down the line
|
||||
return <T>(arg: T) => arg
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0]
|
||||
}
|
||||
|
||||
return funcs.reduce(
|
||||
(a, b) =>
|
||||
(...args: any) =>
|
||||
a(b(...args))
|
||||
)
|
||||
}
|
||||
490
frontend/node_modules/redux/src/createStore.ts
generated
vendored
Normal file
490
frontend/node_modules/redux/src/createStore.ts
generated
vendored
Normal file
@@ -0,0 +1,490 @@
|
||||
import $$observable from './utils/symbol-observable'
|
||||
|
||||
import {
|
||||
Store,
|
||||
StoreEnhancer,
|
||||
Dispatch,
|
||||
Observer,
|
||||
ListenerCallback,
|
||||
UnknownIfNonSpecific
|
||||
} from './types/store'
|
||||
import { Action } from './types/actions'
|
||||
import { Reducer } from './types/reducers'
|
||||
import ActionTypes from './utils/actionTypes'
|
||||
import isPlainObject from './utils/isPlainObject'
|
||||
import { kindOf } from './utils/kindOf'
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* **We recommend using the `configureStore` method
|
||||
* of the `@reduxjs/toolkit` package**, which replaces `createStore`.
|
||||
*
|
||||
* Redux Toolkit is our recommended approach for writing Redux logic today,
|
||||
* including store setup, reducers, data fetching, and more.
|
||||
*
|
||||
* **For more details, please read this Redux docs page:**
|
||||
* **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
||||
*
|
||||
* `configureStore` from Redux Toolkit is an improved version of `createStore` that
|
||||
* simplifies setup and helps avoid common bugs.
|
||||
*
|
||||
* You should not be using the `redux` core package by itself today, except for learning purposes.
|
||||
* The `createStore` method from the core `redux` package will not be removed, but we encourage
|
||||
* all users to migrate to using Redux Toolkit for all Redux code.
|
||||
*
|
||||
* If you want to use `createStore` without this visual deprecation warning, use
|
||||
* the `legacy_createStore` import instead:
|
||||
*
|
||||
* `import { legacy_createStore as createStore} from 'redux'`
|
||||
*
|
||||
*/
|
||||
export function createStore<
|
||||
S,
|
||||
A extends Action,
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {}
|
||||
>(
|
||||
reducer: Reducer<S, A>,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* **We recommend using the `configureStore` method
|
||||
* of the `@reduxjs/toolkit` package**, which replaces `createStore`.
|
||||
*
|
||||
* Redux Toolkit is our recommended approach for writing Redux logic today,
|
||||
* including store setup, reducers, data fetching, and more.
|
||||
*
|
||||
* **For more details, please read this Redux docs page:**
|
||||
* **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
||||
*
|
||||
* `configureStore` from Redux Toolkit is an improved version of `createStore` that
|
||||
* simplifies setup and helps avoid common bugs.
|
||||
*
|
||||
* You should not be using the `redux` core package by itself today, except for learning purposes.
|
||||
* The `createStore` method from the core `redux` package will not be removed, but we encourage
|
||||
* all users to migrate to using Redux Toolkit for all Redux code.
|
||||
*
|
||||
* If you want to use `createStore` without this visual deprecation warning, use
|
||||
* the `legacy_createStore` import instead:
|
||||
*
|
||||
* `import { legacy_createStore as createStore} from 'redux'`
|
||||
*
|
||||
*/
|
||||
export function createStore<
|
||||
S,
|
||||
A extends Action,
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {},
|
||||
PreloadedState = S
|
||||
>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
preloadedState?: PreloadedState | undefined,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext
|
||||
export function createStore<
|
||||
S,
|
||||
A extends Action,
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {},
|
||||
PreloadedState = S
|
||||
>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
preloadedState?: PreloadedState | StoreEnhancer<Ext, StateExt> | undefined,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext {
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the root reducer to be a function. Instead, received: '${kindOf(
|
||||
reducer
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
(typeof preloadedState === 'function' && typeof enhancer === 'function') ||
|
||||
(typeof enhancer === 'function' && typeof arguments[3] === 'function')
|
||||
) {
|
||||
throw new Error(
|
||||
'It looks like you are passing several store enhancers to ' +
|
||||
'createStore(). This is not supported. Instead, compose them ' +
|
||||
'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.'
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState as StoreEnhancer<Ext, StateExt>
|
||||
preloadedState = undefined
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the enhancer to be a function. Instead, received: '${kindOf(
|
||||
enhancer
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
return enhancer(createStore)(
|
||||
reducer,
|
||||
preloadedState as PreloadedState | undefined
|
||||
)
|
||||
}
|
||||
|
||||
let currentReducer = reducer
|
||||
let currentState: S | PreloadedState | undefined = preloadedState as
|
||||
| PreloadedState
|
||||
| undefined
|
||||
let currentListeners: Map<number, ListenerCallback> | null = new Map()
|
||||
let nextListeners = currentListeners
|
||||
let listenerIdCounter = 0
|
||||
let isDispatching = false
|
||||
|
||||
/**
|
||||
* This makes a shallow copy of currentListeners so we can use
|
||||
* nextListeners as a temporary list while dispatching.
|
||||
*
|
||||
* This prevents any bugs around consumers calling
|
||||
* subscribe/unsubscribe in the middle of a dispatch.
|
||||
*/
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = new Map()
|
||||
currentListeners.forEach((listener, key) => {
|
||||
nextListeners.set(key, listener)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns The current state tree of your application.
|
||||
*/
|
||||
function getState(): S {
|
||||
if (isDispatching) {
|
||||
throw new Error(
|
||||
'You may not call store.getState() while the reducer is executing. ' +
|
||||
'The reducer has already received the state as an argument. ' +
|
||||
'Pass it down from the top reducer instead of reading it from the store.'
|
||||
)
|
||||
}
|
||||
|
||||
return currentState as S
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param listener A callback to be invoked on every dispatch.
|
||||
* @returns A function to remove this change listener.
|
||||
*/
|
||||
function subscribe(listener: () => void) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the listener to be a function. Instead, received: '${kindOf(
|
||||
listener
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(
|
||||
'You may not call store.subscribe() while the reducer is executing. ' +
|
||||
'If you would like to be notified after the store has been updated, subscribe from a ' +
|
||||
'component and invoke store.getState() in the callback to access the latest state. ' +
|
||||
'See https://redux.js.org/api/store#subscribelistener for more details.'
|
||||
)
|
||||
}
|
||||
|
||||
let isSubscribed = true
|
||||
|
||||
ensureCanMutateNextListeners()
|
||||
const listenerId = listenerIdCounter++
|
||||
nextListeners.set(listenerId, listener)
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(
|
||||
'You may not unsubscribe from a store listener while the reducer is executing. ' +
|
||||
'See https://redux.js.org/api/store#subscribelistener for more details.'
|
||||
)
|
||||
}
|
||||
|
||||
isSubscribed = false
|
||||
|
||||
ensureCanMutateNextListeners()
|
||||
nextListeners.delete(listenerId)
|
||||
currentListeners = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
function dispatch(action: A) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error(
|
||||
`Actions must be plain objects. Instead, the actual type was: '${kindOf(
|
||||
action
|
||||
)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error(
|
||||
'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.'
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof action.type !== 'string') {
|
||||
throw new Error(
|
||||
`Action "type" property must be a string. Instead, the actual type was: '${kindOf(
|
||||
action.type
|
||||
)}'. Value was: '${action.type}' (stringified)`
|
||||
)
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('Reducers may not dispatch actions.')
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true
|
||||
currentState = currentReducer(currentState, action)
|
||||
} finally {
|
||||
isDispatching = false
|
||||
}
|
||||
|
||||
const listeners = (currentListeners = nextListeners)
|
||||
listeners.forEach(listener => {
|
||||
listener()
|
||||
})
|
||||
return action
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param nextReducer The reducer for the store to use instead.
|
||||
*/
|
||||
function replaceReducer(nextReducer: Reducer<S, A>): void {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the nextReducer to be a function. Instead, received: '${kindOf(
|
||||
nextReducer
|
||||
)}`
|
||||
)
|
||||
}
|
||||
|
||||
currentReducer = nextReducer as unknown as Reducer<S, A, PreloadedState>
|
||||
|
||||
// This action has a similar effect to ActionTypes.INIT.
|
||||
// Any reducers that existed in both the new and old rootReducer
|
||||
// will receive the previous state. This effectively populates
|
||||
// the new state tree with any relevant data from the old one.
|
||||
dispatch({ type: ActionTypes.REPLACE } as A)
|
||||
}
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
function observable() {
|
||||
const outerSubscribe = subscribe
|
||||
return {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe(observer: unknown) {
|
||||
if (typeof observer !== 'object' || observer === null) {
|
||||
throw new TypeError(
|
||||
`Expected the observer to be an object. Instead, received: '${kindOf(
|
||||
observer
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
const observerAsObserver = observer as Observer<S>
|
||||
if (observerAsObserver.next) {
|
||||
observerAsObserver.next(getState())
|
||||
}
|
||||
}
|
||||
|
||||
observeState()
|
||||
const unsubscribe = outerSubscribe(observeState)
|
||||
return { unsubscribe }
|
||||
},
|
||||
|
||||
[$$observable]() {
|
||||
return this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
dispatch({ type: ActionTypes.INIT } as A)
|
||||
|
||||
const store = {
|
||||
dispatch: dispatch as Dispatch<A>,
|
||||
subscribe,
|
||||
getState,
|
||||
replaceReducer,
|
||||
[$$observable]: observable
|
||||
} as unknown as Store<S, A, StateExt> & Ext
|
||||
return store
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
*
|
||||
* **We recommend using `configureStore` from the
|
||||
* `@reduxjs/toolkit` package**, which replaces `createStore`:
|
||||
* **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
||||
*
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
export function legacy_createStore<
|
||||
S,
|
||||
A extends Action,
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {}
|
||||
>(
|
||||
reducer: Reducer<S, A>,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
*
|
||||
* **We recommend using `configureStore` from the
|
||||
* `@reduxjs/toolkit` package**, which replaces `createStore`:
|
||||
* **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
||||
*
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
export function legacy_createStore<
|
||||
S,
|
||||
A extends Action,
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {},
|
||||
PreloadedState = S
|
||||
>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
preloadedState?: PreloadedState | undefined,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext
|
||||
export function legacy_createStore<
|
||||
S,
|
||||
A extends Action,
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {},
|
||||
PreloadedState = S
|
||||
>(
|
||||
reducer: Reducer<S, A>,
|
||||
preloadedState?: PreloadedState | StoreEnhancer<Ext, StateExt> | undefined,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext {
|
||||
return createStore(reducer, preloadedState as any, enhancer)
|
||||
}
|
||||
50
frontend/node_modules/redux/src/index.ts
generated
vendored
Normal file
50
frontend/node_modules/redux/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
// functions
|
||||
import { createStore, legacy_createStore } from './createStore'
|
||||
import combineReducers from './combineReducers'
|
||||
import bindActionCreators from './bindActionCreators'
|
||||
import applyMiddleware from './applyMiddleware'
|
||||
import compose from './compose'
|
||||
import isAction from './utils/isAction'
|
||||
import isPlainObject from './utils/isPlainObject'
|
||||
import __DO_NOT_USE__ActionTypes from './utils/actionTypes'
|
||||
|
||||
// types
|
||||
// store
|
||||
export {
|
||||
Dispatch,
|
||||
Unsubscribe,
|
||||
Observable,
|
||||
Observer,
|
||||
Store,
|
||||
StoreCreator,
|
||||
StoreEnhancer,
|
||||
StoreEnhancerStoreCreator
|
||||
} from './types/store'
|
||||
// reducers
|
||||
export {
|
||||
Reducer,
|
||||
ReducersMapObject,
|
||||
StateFromReducersMapObject,
|
||||
ReducerFromReducersMapObject,
|
||||
ActionFromReducer,
|
||||
ActionFromReducersMapObject,
|
||||
PreloadedStateShapeFromReducersMapObject
|
||||
} from './types/reducers'
|
||||
// action creators
|
||||
export { ActionCreator, ActionCreatorsMapObject } from './types/actions'
|
||||
// middleware
|
||||
export { MiddlewareAPI, Middleware } from './types/middleware'
|
||||
// actions
|
||||
export { Action, UnknownAction, AnyAction } from './types/actions'
|
||||
|
||||
export {
|
||||
createStore,
|
||||
legacy_createStore,
|
||||
combineReducers,
|
||||
bindActionCreators,
|
||||
applyMiddleware,
|
||||
compose,
|
||||
isAction,
|
||||
isPlainObject,
|
||||
__DO_NOT_USE__ActionTypes
|
||||
}
|
||||
74
frontend/node_modules/redux/src/types/actions.ts
generated
vendored
Normal file
74
frontend/node_modules/redux/src/types/actions.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* An *action* is a plain object that represents an intention to change the
|
||||
* state. Actions are the only way to get data into the store. Any data,
|
||||
* whether from UI events, network callbacks, or other sources such as
|
||||
* WebSockets needs to eventually be dispatched as actions.
|
||||
*
|
||||
* Actions must have a `type` field that indicates the type of action being
|
||||
* performed. Types can be defined as constants and imported from another
|
||||
* module. These must be strings, as strings are serializable.
|
||||
*
|
||||
* Other than `type`, the structure of an action object is really up to you.
|
||||
* If you're interested, check out Flux Standard Action for recommendations on
|
||||
* how actions should be constructed.
|
||||
*
|
||||
* @template T the type of the action's `type` tag.
|
||||
*/
|
||||
// this needs to be a type, not an interface
|
||||
// https://github.com/microsoft/TypeScript/issues/15300
|
||||
export type Action<T extends string = string> = {
|
||||
type: T
|
||||
}
|
||||
|
||||
/**
|
||||
* An Action type which accepts any other properties.
|
||||
* This is mainly for the use of the `Reducer` type.
|
||||
* This is not part of `Action` itself to prevent types that extend `Action` from
|
||||
* having an index signature.
|
||||
*/
|
||||
export interface UnknownAction extends Action {
|
||||
// Allows any extra properties to be defined in an action.
|
||||
[extraProps: string]: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* An Action type which accepts any other properties.
|
||||
* This is mainly for the use of the `Reducer` type.
|
||||
* This is not part of `Action` itself to prevent types that extend `Action` from
|
||||
* having an index signature.
|
||||
* @deprecated use Action or UnknownAction instead
|
||||
*/
|
||||
export interface AnyAction extends Action {
|
||||
// Allows any extra properties to be defined in an action.
|
||||
[extraProps: string]: any
|
||||
}
|
||||
|
||||
/* action creators */
|
||||
|
||||
/**
|
||||
* An *action creator* is, quite simply, a function that creates an action. Do
|
||||
* not confuse the two terms—again, an action is a payload of information, and
|
||||
* an action creator is a factory that creates an action.
|
||||
*
|
||||
* Calling an action creator only produces an action, but does not dispatch
|
||||
* it. You need to call the store's `dispatch` function to actually cause the
|
||||
* mutation. Sometimes we say *bound action creators* to mean functions that
|
||||
* call an action creator and immediately dispatch its result to a specific
|
||||
* store instance.
|
||||
*
|
||||
* If an action creator needs to read the current state, perform an API call,
|
||||
* or cause a side effect, like a routing transition, it should return an
|
||||
* async action instead of an action.
|
||||
*
|
||||
* @template A Returned action type.
|
||||
*/
|
||||
export interface ActionCreator<A, P extends any[] = any[]> {
|
||||
(...args: P): A
|
||||
}
|
||||
|
||||
/**
|
||||
* Object whose values are action creator functions.
|
||||
*/
|
||||
export interface ActionCreatorsMapObject<A = any, P extends any[] = any[]> {
|
||||
[key: string]: ActionCreator<A, P>
|
||||
}
|
||||
30
frontend/node_modules/redux/src/types/middleware.ts
generated
vendored
Normal file
30
frontend/node_modules/redux/src/types/middleware.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Dispatch } from './store'
|
||||
|
||||
export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
|
||||
dispatch: D
|
||||
getState(): S
|
||||
}
|
||||
|
||||
/**
|
||||
* A middleware is a higher-order function that composes a dispatch function
|
||||
* to return a new dispatch function. It often turns async actions into
|
||||
* actions.
|
||||
*
|
||||
* Middleware is composable using function composition. It is useful for
|
||||
* logging actions, performing side effects like routing, or turning an
|
||||
* asynchronous API call into a series of synchronous actions.
|
||||
*
|
||||
* @template DispatchExt Extra Dispatch signature added by this middleware.
|
||||
* @template S The type of the state supported by this middleware.
|
||||
* @template D The type of Dispatch of the store where this middleware is
|
||||
* installed.
|
||||
*/
|
||||
export interface Middleware<
|
||||
_DispatchExt = {}, // TODO: see if this can be used in type definition somehow (can't be removed, as is used to get final dispatch type)
|
||||
S = any,
|
||||
D extends Dispatch = Dispatch
|
||||
> {
|
||||
(api: MiddlewareAPI<D, S>): (
|
||||
next: (action: unknown) => unknown
|
||||
) => (action: unknown) => unknown
|
||||
}
|
||||
115
frontend/node_modules/redux/src/types/reducers.ts
generated
vendored
Normal file
115
frontend/node_modules/redux/src/types/reducers.ts
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import { Action, UnknownAction } from './actions'
|
||||
|
||||
/* reducers */
|
||||
|
||||
/**
|
||||
* A *reducer* is a function that accepts
|
||||
* an accumulation and a value and returns a new accumulation. They are used
|
||||
* to reduce a collection of values down to a single value
|
||||
*
|
||||
* Reducers are not unique to Redux—they are a fundamental concept in
|
||||
* functional programming. Even most non-functional languages, like
|
||||
* JavaScript, have a built-in API for reducing. In JavaScript, it's
|
||||
* `Array.prototype.reduce()`.
|
||||
*
|
||||
* In Redux, the accumulated value is the state object, and the values being
|
||||
* accumulated are actions. Reducers calculate a new state given the previous
|
||||
* state and an action. They must be *pure functions*—functions that return
|
||||
* the exact same output for given inputs. They should also be free of
|
||||
* side-effects. This is what enables exciting features like hot reloading and
|
||||
* time travel.
|
||||
*
|
||||
* Reducers are the most important concept in Redux.
|
||||
*
|
||||
* *Do not put API calls into reducers.*
|
||||
*
|
||||
* @template S The type of state consumed and produced by this reducer.
|
||||
* @template A The type of actions the reducer can potentially respond to.
|
||||
* @template PreloadedState The type of state consumed by this reducer the first time it's called.
|
||||
*/
|
||||
export type Reducer<
|
||||
S = any,
|
||||
A extends Action = UnknownAction,
|
||||
PreloadedState = S
|
||||
> = (state: S | PreloadedState | undefined, action: A) => S
|
||||
|
||||
/**
|
||||
* Object whose values correspond to different reducer functions.
|
||||
*
|
||||
* @template S The combined state of the reducers.
|
||||
* @template A The type of actions the reducers can potentially respond to.
|
||||
* @template PreloadedState The combined preloaded state of the reducers.
|
||||
*/
|
||||
export type ReducersMapObject<
|
||||
S = any,
|
||||
A extends Action = UnknownAction,
|
||||
PreloadedState = S
|
||||
> = keyof PreloadedState extends keyof S
|
||||
? {
|
||||
[K in keyof S]: Reducer<
|
||||
S[K],
|
||||
A,
|
||||
K extends keyof PreloadedState ? PreloadedState[K] : never
|
||||
>
|
||||
}
|
||||
: never
|
||||
|
||||
/**
|
||||
* Infer a combined state shape from a `ReducersMapObject`.
|
||||
*
|
||||
* @template M Object map of reducers as provided to `combineReducers(map: M)`.
|
||||
*/
|
||||
export type StateFromReducersMapObject<M> = M[keyof M] extends
|
||||
| Reducer<any, any, any>
|
||||
| undefined
|
||||
? {
|
||||
[P in keyof M]: M[P] extends Reducer<infer S, any, any> ? S : never
|
||||
}
|
||||
: never
|
||||
|
||||
/**
|
||||
* Infer reducer union type from a `ReducersMapObject`.
|
||||
*
|
||||
* @template M Object map of reducers as provided to `combineReducers(map: M)`.
|
||||
*/
|
||||
export type ReducerFromReducersMapObject<M> = M[keyof M] extends
|
||||
| Reducer<any, any, any>
|
||||
| undefined
|
||||
? M[keyof M]
|
||||
: never
|
||||
|
||||
/**
|
||||
* Infer action type from a reducer function.
|
||||
*
|
||||
* @template R Type of reducer.
|
||||
*/
|
||||
export type ActionFromReducer<R> = R extends Reducer<any, infer A, any>
|
||||
? A
|
||||
: never
|
||||
|
||||
/**
|
||||
* Infer action union type from a `ReducersMapObject`.
|
||||
*
|
||||
* @template M Object map of reducers as provided to `combineReducers(map: M)`.
|
||||
*/
|
||||
export type ActionFromReducersMapObject<M> = ActionFromReducer<
|
||||
ReducerFromReducersMapObject<M>
|
||||
>
|
||||
|
||||
/**
|
||||
* Infer a combined preloaded state shape from a `ReducersMapObject`.
|
||||
*
|
||||
* @template M Object map of reducers as provided to `combineReducers(map: M)`.
|
||||
*/
|
||||
export type PreloadedStateShapeFromReducersMapObject<M> = M[keyof M] extends
|
||||
| Reducer<any, any, any>
|
||||
| undefined
|
||||
? {
|
||||
[P in keyof M]: M[P] extends (
|
||||
inputState: infer InputState,
|
||||
action: UnknownAction
|
||||
) => any
|
||||
? InputState
|
||||
: never
|
||||
}
|
||||
: never
|
||||
232
frontend/node_modules/redux/src/types/store.ts
generated
vendored
Normal file
232
frontend/node_modules/redux/src/types/store.ts
generated
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
import { Action, UnknownAction } from './actions'
|
||||
import { Reducer } from './reducers'
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import _$$observable from '../utils/symbol-observable'
|
||||
|
||||
/**
|
||||
* A *dispatching function* (or simply *dispatch function*) is a function that
|
||||
* accepts an action or an async action; it then may or may not dispatch one
|
||||
* or more actions to the store.
|
||||
*
|
||||
* We must distinguish between dispatching functions in general and the base
|
||||
* `dispatch` function provided by the store instance without any middleware.
|
||||
*
|
||||
* The base dispatch function *always* synchronously sends an action to the
|
||||
* store's reducer, along with the previous state returned by the store, to
|
||||
* calculate a new state. It expects actions to be plain objects ready to be
|
||||
* consumed by the reducer.
|
||||
*
|
||||
* Middleware wraps the base dispatch function. It allows the dispatch
|
||||
* function to handle async actions in addition to actions. Middleware may
|
||||
* transform, delay, ignore, or otherwise interpret actions or async actions
|
||||
* before passing them to the next middleware.
|
||||
*
|
||||
* @template A The type of things (actions or otherwise) which may be
|
||||
* dispatched.
|
||||
*/
|
||||
export interface Dispatch<A extends Action = UnknownAction> {
|
||||
<T extends A>(action: T, ...extraArgs: any[]): T
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to remove listener added by `Store.subscribe()`.
|
||||
*/
|
||||
export interface Unsubscribe {
|
||||
(): void
|
||||
}
|
||||
|
||||
export type ListenerCallback = () => void
|
||||
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
export type Observable<T> = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: (observer: Observer<T>) => { unsubscribe: Unsubscribe }
|
||||
[Symbol.observable](): Observable<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* An Observer is used to receive data from an Observable, and is supplied as
|
||||
* an argument to subscribe.
|
||||
*/
|
||||
export type Observer<T> = {
|
||||
next?(value: T): void
|
||||
}
|
||||
|
||||
/**
|
||||
* A store is an object that holds the application's state tree.
|
||||
* There should only be a single store in a Redux app, as the composition
|
||||
* happens on the reducer level.
|
||||
*
|
||||
* @template S The type of state held by this store.
|
||||
* @template A the type of actions which may be dispatched by this store.
|
||||
* @template StateExt any extension to state from store enhancers
|
||||
*/
|
||||
export interface Store<
|
||||
S = any,
|
||||
A extends Action = UnknownAction,
|
||||
StateExt extends unknown = unknown
|
||||
> {
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will be
|
||||
* considered the **next** state of the tree, and the change listeners will
|
||||
* be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want
|
||||
* to dispatch a Promise, an Observable, a thunk, or something else, you
|
||||
* need to wrap your store creating function into the corresponding
|
||||
* middleware. For example, see the documentation for the `redux-thunk`
|
||||
* package. Even the middleware will eventually dispatch plain object
|
||||
* actions using this method.
|
||||
*
|
||||
* @param action A plain object representing “what changed”. It is a good
|
||||
* idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must
|
||||
* have a `type` property which may not be `undefined`. It is a good idea
|
||||
* to use string constants for action types.
|
||||
*
|
||||
* @returns For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
dispatch: Dispatch<A>
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns The current state tree of your application.
|
||||
*/
|
||||
getState(): S & StateExt
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is
|
||||
* dispatched, and some part of the state tree may potentially have changed.
|
||||
* You may then call `getState()` to read the current state tree inside the
|
||||
* callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked,
|
||||
* this will not have any effect on the `dispatch()` that is currently in
|
||||
* progress. However, the next `dispatch()` call, whether nested or not,
|
||||
* will use a more recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all states changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param listener A callback to be invoked on every dispatch.
|
||||
* @returns A function to remove this change listener.
|
||||
*/
|
||||
subscribe(listener: ListenerCallback): Unsubscribe
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param nextReducer The reducer for the store to use instead.
|
||||
*/
|
||||
replaceReducer(nextReducer: Reducer<S, A>): void
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
[Symbol.observable](): Observable<S & StateExt>
|
||||
}
|
||||
|
||||
export type UnknownIfNonSpecific<T> = {} extends T ? unknown : T
|
||||
|
||||
/**
|
||||
* A store creator is a function that creates a Redux store. Like with
|
||||
* dispatching function, we must distinguish the base store creator,
|
||||
* `createStore(reducer, preloadedState)` exported from the Redux package, from
|
||||
* store creators that are returned from the store enhancers.
|
||||
*
|
||||
* @template S The type of state to be held by the store.
|
||||
* @template A The type of actions which may be dispatched.
|
||||
* @template PreloadedState The initial state that is passed into the reducer.
|
||||
* @template Ext Store extension that is mixed in to the Store type.
|
||||
* @template StateExt State extension that is mixed into the state type.
|
||||
*/
|
||||
export interface StoreCreator {
|
||||
<S, A extends Action, Ext extends {} = {}, StateExt extends {} = {}>(
|
||||
reducer: Reducer<S, A>,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext
|
||||
<
|
||||
S,
|
||||
A extends Action,
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {},
|
||||
PreloadedState = S
|
||||
>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
preloadedState?: PreloadedState | undefined,
|
||||
enhancer?: StoreEnhancer<Ext>
|
||||
): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext
|
||||
}
|
||||
|
||||
/**
|
||||
* A store enhancer is a higher-order function that composes a store creator
|
||||
* to return a new, enhanced store creator. This is similar to middleware in
|
||||
* that it allows you to alter the store interface in a composable way.
|
||||
*
|
||||
* Store enhancers are much the same concept as higher-order components in
|
||||
* React, which are also occasionally called “component enhancers”.
|
||||
*
|
||||
* Because a store is not an instance, but rather a plain-object collection of
|
||||
* functions, copies can be easily created and modified without mutating the
|
||||
* original store. There is an example in `compose` documentation
|
||||
* demonstrating that.
|
||||
*
|
||||
* Most likely you'll never write a store enhancer, but you may use the one
|
||||
* provided by the developer tools. It is what makes time travel possible
|
||||
* without the app being aware it is happening. Amusingly, the Redux
|
||||
* middleware implementation is itself a store enhancer.
|
||||
*
|
||||
* @template Ext Store extension that is mixed into the Store type.
|
||||
* @template StateExt State extension that is mixed into the state type.
|
||||
*/
|
||||
export type StoreEnhancer<Ext extends {} = {}, StateExt extends {} = {}> = <
|
||||
NextExt extends {},
|
||||
NextStateExt extends {}
|
||||
>(
|
||||
next: StoreEnhancerStoreCreator<NextExt, NextStateExt>
|
||||
) => StoreEnhancerStoreCreator<NextExt & Ext, NextStateExt & StateExt>
|
||||
export type StoreEnhancerStoreCreator<
|
||||
Ext extends {} = {},
|
||||
StateExt extends {} = {}
|
||||
> = <S, A extends Action, PreloadedState>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
preloadedState?: PreloadedState | undefined
|
||||
) => Store<S, A, StateExt> & Ext
|
||||
17
frontend/node_modules/redux/src/utils/actionTypes.ts
generated
vendored
Normal file
17
frontend/node_modules/redux/src/utils/actionTypes.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
|
||||
const randomString = () =>
|
||||
Math.random().toString(36).substring(7).split('').join('.')
|
||||
|
||||
const ActionTypes = {
|
||||
INIT: `@@redux/INIT${/* #__PURE__ */ randomString()}`,
|
||||
REPLACE: `@@redux/REPLACE${/* #__PURE__ */ randomString()}`,
|
||||
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
||||
}
|
||||
|
||||
export default ActionTypes
|
||||
13
frontend/node_modules/redux/src/utils/formatProdErrorMessage.ts
generated
vendored
Normal file
13
frontend/node_modules/redux/src/utils/formatProdErrorMessage.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
||||
*
|
||||
* Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
|
||||
* during build.
|
||||
* @param {number} code
|
||||
*/
|
||||
export function formatProdErrorMessage(code: number) {
|
||||
return (
|
||||
`Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or ` +
|
||||
'use the non-minified dev environment for full errors. '
|
||||
)
|
||||
}
|
||||
10
frontend/node_modules/redux/src/utils/isAction.ts
generated
vendored
Normal file
10
frontend/node_modules/redux/src/utils/isAction.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Action } from '../types/actions'
|
||||
import isPlainObject from './isPlainObject'
|
||||
|
||||
export default function isAction(action: unknown): action is Action<string> {
|
||||
return (
|
||||
isPlainObject(action) &&
|
||||
'type' in action &&
|
||||
typeof (action as Record<'type', unknown>).type === 'string'
|
||||
)
|
||||
}
|
||||
16
frontend/node_modules/redux/src/utils/isPlainObject.ts
generated
vendored
Normal file
16
frontend/node_modules/redux/src/utils/isPlainObject.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @param obj The object to inspect.
|
||||
* @returns True if the argument appears to be a plain object.
|
||||
*/
|
||||
export default function isPlainObject(obj: any): obj is object {
|
||||
if (typeof obj !== 'object' || obj === null) return false
|
||||
|
||||
let proto = obj
|
||||
while (Object.getPrototypeOf(proto) !== null) {
|
||||
proto = Object.getPrototypeOf(proto)
|
||||
}
|
||||
|
||||
return (
|
||||
Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null
|
||||
)
|
||||
}
|
||||
70
frontend/node_modules/redux/src/utils/kindOf.ts
generated
vendored
Normal file
70
frontend/node_modules/redux/src/utils/kindOf.ts
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
||||
export function miniKindOf(val: any): string {
|
||||
if (val === void 0) return 'undefined'
|
||||
if (val === null) return 'null'
|
||||
|
||||
const type = typeof val
|
||||
switch (type) {
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'symbol':
|
||||
case 'function': {
|
||||
return type
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) return 'array'
|
||||
if (isDate(val)) return 'date'
|
||||
if (isError(val)) return 'error'
|
||||
|
||||
const constructorName = ctorName(val)
|
||||
switch (constructorName) {
|
||||
case 'Symbol':
|
||||
case 'Promise':
|
||||
case 'WeakMap':
|
||||
case 'WeakSet':
|
||||
case 'Map':
|
||||
case 'Set':
|
||||
return constructorName
|
||||
}
|
||||
|
||||
// other
|
||||
return Object.prototype.toString
|
||||
.call(val)
|
||||
.slice(8, -1)
|
||||
.toLowerCase()
|
||||
.replace(/\s/g, '')
|
||||
}
|
||||
|
||||
function ctorName(val: any): string | null {
|
||||
return typeof val.constructor === 'function' ? val.constructor.name : null
|
||||
}
|
||||
|
||||
function isError(val: any) {
|
||||
return (
|
||||
val instanceof Error ||
|
||||
(typeof val.message === 'string' &&
|
||||
val.constructor &&
|
||||
typeof val.constructor.stackTraceLimit === 'number')
|
||||
)
|
||||
}
|
||||
|
||||
function isDate(val: any) {
|
||||
if (val instanceof Date) return true
|
||||
return (
|
||||
typeof val.toDateString === 'function' &&
|
||||
typeof val.getDate === 'function' &&
|
||||
typeof val.setDate === 'function'
|
||||
)
|
||||
}
|
||||
|
||||
export function kindOf(val: any) {
|
||||
let typeOfVal: string = typeof val
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
typeOfVal = miniKindOf(val)
|
||||
}
|
||||
|
||||
return typeOfVal
|
||||
}
|
||||
10
frontend/node_modules/redux/src/utils/symbol-observable.ts
generated
vendored
Normal file
10
frontend/node_modules/redux/src/utils/symbol-observable.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol
|
||||
}
|
||||
}
|
||||
|
||||
const $$observable = /* #__PURE__ */ (() =>
|
||||
(typeof Symbol === 'function' && Symbol.observable) || '@@observable')()
|
||||
|
||||
export default $$observable
|
||||
18
frontend/node_modules/redux/src/utils/warning.ts
generated
vendored
Normal file
18
frontend/node_modules/redux/src/utils/warning.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param message The warning message.
|
||||
*/
|
||||
export default function warning(message: string): void {
|
||||
/* 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)
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
Reference in New Issue
Block a user